X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fresolver.class.php;h=59833f025e9b85e9cc36be7f5dc74fca71c6648e;hb=a524135c24dd0a8fa359c9a92399467d50fd69e0;hp=4f1cd1a242aff77b596eaae028515eb0d49b0317;hpb=63f159414369b5ea19a8ca75d8cd8033c45d8341;p=mailer.git diff --git a/inc/classes/resolver.class.php b/inc/classes/resolver.class.php index 4f1cd1a242..59833f025e 100644 --- a/inc/classes/resolver.class.php +++ b/inc/classes/resolver.class.php @@ -10,13 +10,8 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Resolver-Klasse * * -------------------------------------------------------------------- * - * $Revision:: $ * - * $Date:: $ * - * $Tag:: 0.2.1-FINAL $ * - * $Author:: $ * - * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2016 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -44,7 +39,7 @@ if (!defined('__SECURITY')) { class HostnameResolver { // Resolve hostname -> IP address function resolveHostname ($hostname) { - // If sql_patches is not at least 0.7.0, abort here and return the hostname (gethostbyname() may return something unwanted) + // If ext-sql_patches is not at least 0.7.0, abort here and return the hostname (gethostbyname() may return something unwanted) if (!isExtensionInstalledAndNewer('sql_patches', '0.7.0')) { // Abort here return $hostname; @@ -66,13 +61,16 @@ class HostnameResolver { $ret = '0.0.0.0'; // Search for hostname in cache - $result = SQL_QUERY_ESC("SELECT `ip` FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE `hostname`='%s' LIMIT 1", - array($hostname), __METHOD__, __LINE__); + $result = sqlQueryEscaped("SELECT `ip` FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE `hostname`='%s' LIMIT 1", + array( + $hostname + ), __METHOD__, __LINE__ + ); // Does an entry exist? - if (SQL_NUMROWS($result) == 1) { + if (sqlNumRows($result) == 1) { // Then load the hostname - list($ip) = SQL_FETCHROW($result); + list($ip) = sqlFetchRow($result); // Count cache hit incrementStatsEntry('dns_cache_hits'); @@ -93,8 +91,12 @@ class HostnameResolver { // Seems to be an IP! Now check deeper... if (($matches[0] == $ip) && ($matches[1] >= 0) && ($matches[1] <= 255) && ($matches[2] >= 0) && ($matches[2] <= 255) && ($matches[3] >= 0) && ($matches[3] <= 255) && ($matches[4] > 0) && ($matches[4] < 255)) { // We also cache IP addresses - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`,`hostname`,`added`) VALUES ('%s', '%s', NOW())", - array($ip, $hostname), __METHOD__, __LINE__); + sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`, `hostname`, `added`) VALUES ('%s', '%s', NOW())", + array( + $ip, + $hostname + ), __METHOD__, __LINE__ + ); // Set return value to $ip //* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, sprintf("IP detected, cache entry written: %s->%s", $hostname, $ip)); @@ -108,8 +110,12 @@ class HostnameResolver { //* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, sprintf("Cannot lookup: %s", $hostname)); } else { // Put entry in DB - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`,`hostname`,`added`) VALUES ('%s', '%s', NOW())", - array($ip, $hostname), __METHOD__, __LINE__); + sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`, `hostname`, `added`) VALUES ('%s', '%s', NOW())", + array( + $ip, + $hostname + ), __METHOD__, __LINE__ + ); // Set return value to $ip $ret = $ip; @@ -118,7 +124,7 @@ class HostnameResolver { } // Free result - SQL_FREERESULT($result); + sqlFreeResult($result); // Return IP number (let's hope it) return $ret; @@ -127,7 +133,7 @@ class HostnameResolver { // Purge old entries function purgeEntries() { // SQL for cleaning up - SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`added`) >= {?dns_cache_timeout?})', + sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`added`) >= {?dns_cache_timeout?})', __METHOD__, __LINE__); } }