X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fresolver.class.php;h=09846cf51343a68ac236399db753aa0b4feaf747;hb=cd7d344ea7007cfa20413acd3e03e50f0ab86d86;hp=190111b946999f9dc908196de7727ce3281b651e;hpb=0f3a135204757cc8750262871c8e62c42300acb4;p=mailer.git diff --git a/inc/classes/resolver.class.php b/inc/classes/resolver.class.php index 190111b946..09846cf513 100644 --- a/inc/classes/resolver.class.php +++ b/inc/classes/resolver.class.php @@ -16,8 +16,8 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2011 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2013 by Mailer Developer Team * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -44,7 +44,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; @@ -83,6 +83,7 @@ class HostnameResolver { } else { // Get IP address $ip = gethostbyname($hostname); + //* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, 'ip=' . $ip . ',hostname=' . $hostname . ' - RESOLVED!'); // Count lookup hit incrementStatsEntry('dns_lookup_hits'); @@ -92,11 +93,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())", + SQL_QUERY_ESC("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)); + $ret = $ip; } else { // Network address or broadcast address found //* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, sprintf("IP %s is possibly a network or broadcast address.", $ip)); @@ -106,7 +108,7 @@ 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())", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`, `hostname`, `added`) VALUES ('%s', '%s', NOW())", array($ip, $hostname), __METHOD__, __LINE__); // Set return value to $ip @@ -118,7 +120,7 @@ class HostnameResolver { // Free result SQL_FREERESULT($result); - // Return IP number (let's hope it! + // Return IP number (let's hope it) return $ret; }