当前位置: 首页>>代码示例>>PHP>>正文


PHP gethostbyaddr函数代码示例

本文整理汇总了PHP中gethostbyaddr函数的典型用法代码示例。如果您正苦于以下问题:PHP gethostbyaddr函数的具体用法?PHP gethostbyaddr怎么用?PHP gethostbyaddr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gethostbyaddr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: system_information

function system_information()
{
    global $mysqli, $server, $redis_server, $mqtt_server;
    $result = $mysqli->query("select now() as datetime, time_format(timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00')),'%H:%i‌​') AS timezone");
    $db = $result->fetch_array();
    @(list($system, $host, $kernel) = preg_split('/[\\s,]+/', php_uname('a'), 5));
    @exec('ps ax | grep feedwriter.php | grep -v grep', $feedwriterproc);
    $meminfo = false;
    if (@is_readable('/proc/meminfo')) {
        $data = explode("\n", file_get_contents("/proc/meminfo"));
        $meminfo = array();
        foreach ($data as $line) {
            if (strpos($line, ':') !== false) {
                list($key, $val) = explode(":", $line);
                $meminfo[$key] = 1024 * floatval(trim(str_replace(' kB', '', $val)));
            }
        }
    }
    $emoncms_modules = "";
    $emoncmsModulesPath = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/')) . '/Modules';
    // Set the Modules path
    $emoncmsModuleFolders = glob("{$emoncmsModulesPath}/*", GLOB_ONLYDIR);
    // Use glob to get all the folder names only
    foreach ($emoncmsModuleFolders as $emoncmsModuleFolder) {
        // loop through the folders
        if ($emoncms_modules != "") {
            $emoncms_modules .= "   ";
        }
        $emoncms_modules .= str_replace($emoncmsModulesPath . "/", '', $emoncmsModuleFolder);
    }
    return array('date' => date('Y-m-d H:i:s T'), 'system' => $system, 'kernel' => $kernel, 'host' => $host, 'ip' => gethostbyname($host), 'uptime' => @exec('uptime'), 'http_server' => $_SERVER['SERVER_SOFTWARE'], 'php' => PHP_VERSION, 'zend' => function_exists('zend_version') ? zend_version() : 'n/a', 'db_server' => $server, 'db_ip' => gethostbyname($server), 'db_version' => 'MySQL ' . $mysqli->server_info, 'db_stat' => $mysqli->stat(), 'db_date' => $db['datetime'] . " (UTC " . $db['timezone'] . ")", 'redis_server' => $redis_server['host'] . ":" . $redis_server['port'], 'redis_ip' => gethostbyname($redis_server['host']), 'feedwriter' => !empty($feedwriterproc), 'mqtt_server' => $mqtt_server['host'], 'mqtt_ip' => gethostbyname($mqtt_server['host']), 'mqtt_port' => $mqtt_server['port'], 'hostbyaddress' => @gethostbyaddr(gethostbyname($host)), 'http_proto' => $_SERVER['SERVER_PROTOCOL'], 'http_mode' => $_SERVER['GATEWAY_INTERFACE'], 'http_port' => $_SERVER['SERVER_PORT'], 'php_modules' => get_loaded_extensions(), 'mem_info' => $meminfo, 'partitions' => disk_list(), 'emoncms_modules' => $emoncms_modules);
}
开发者ID:TrystanLea,项目名称:emoncms,代码行数:32,代码来源:admin_main_view.php

示例2: calcRange

 static function calcRange($iparray)
 {
     //print_r($iparray);
     $iparray = array_unique($iparray);
     $iparray = array_map("ip2long", $iparray[0]);
     sort($iparray);
     $iparray = array_map("long2ip", $iparray);
     $ip_begin = $iparray[0];
     $ip_end = $iparray[count($iparray) - 1];
     $ip_begin_bin = self::ip2bin($ip_begin);
     $ip_end_bin = self::ip2bin($ip_end);
     $ip_shortened = self::findMatch(implode('', $ip_begin_bin), implode('', $ip_end_bin));
     $cidr_range = strlen($ip_shortened);
     $cidr_difference = 32 - $cidr_range;
     $cidr_begin = $ip_shortened . str_repeat('0', $cidr_difference);
     $cidr_end = $ip_shortened . str_repeat('1', $cidr_difference);
     $ip_count = bindec($cidr_end) - bindec($cidr_begin) + 1;
     $ips = array();
     foreach ($iparray as $ip) {
         $ips[] = array('ip' => $ip, 'bin' => implode('.', self::ip2bin($ip)), 'rdns' => gethostbyaddr($ip), 'long' => ip2long($ip), 'hex' => implode('.', self::ip2hex($ip)), 'octal' => implode('.', self::ip2oct($ip)), 'radians' => implode('/', self::ip2rad($ip)), 'base64' => implode('.', self::ip264($ip)), 'alpha' => implode('.', self::ip2alpha($ip)));
     }
     usort($ips, array('IPCalc', 'ipsort'));
     $tmp = self::calcCIDR($ip_begin . '/' . $cidr_range);
     return array('begin' => $tmp['begin'], 'end' => $tmp['end'], 'count' => $tmp['count'], 'suffix' => $cidr_range, 'ips' => $ips);
 }
开发者ID:JackPotte,项目名称:xtools,代码行数:25,代码来源:base.php

示例3: resolve_address

 /**
  * Resolves hostname
  *
  * @access public
  * @param mixed $address		address object
  * @param boolena $override		override DNS resolving flag
  * @return void
  */
 public function resolve_address($address, $override = false)
 {
     # settings
     $this->get_settings();
     # addresses object
     $Address = new Addresses($this->Database);
     # make sure it is dotted format
     $address->ip = $Address->transform_address($address->ip_addr, "dotted");
     # if dns_nameis set try to check
     if (empty($address->dns_name) || is_null($address->dns_name)) {
         # if permitted in settings
         if ($this->settings->enableDNSresolving == 1 || $override) {
             # resolve
             $resolved = gethostbyaddr($address->ip);
             if ($resolved == $address->ip) {
                 $resolved = "";
             }
             //resolve fails
             return array("class" => "resolved", "name" => $resolved);
         } else {
             return array("class" => "", "name" => "");
         }
     } else {
         return array("class" => "", "name" => $address->dns_name);
     }
 }
开发者ID:Benchwork,项目名称:phpipam,代码行数:34,代码来源:class.DNS.php

示例4: get_mx

 function get_mx($hostname)
 {
     if (strpos($hostname, '@')) {
         list($user, $hostname) = explode('@', $hostname);
     }
     // split hostname from email address
     if (function_exists('getmxrr')) {
         @getmxrr($hostname, $mxhosts, $mxweight);
     }
     // check for a true MX record
     if (isset($mxhosts) && !empty($mxhosts)) {
         return array_shift($mxhosts);
     } else {
         // RFC says use the A line if there is no MX
         $ip = gethostbyname($hostname);
         // get the ip from hostname
         if ($ip != $hostname) {
             // continue if returned ip not hostname
             $hostname = gethostbyaddr($ip);
             // get the rdns (real) hostname
             $ip = gethostbyname($hostname);
             // check the (real) hostname has an A record
             if ($ip != $hostname) {
                 return $hostname;
             }
             // return if returned ip not hostname
         }
     }
     // If all else fails...
     return $hostname;
 }
开发者ID:digitaldevelopers,项目名称:alegrocart,代码行数:31,代码来源:mail.php

示例5: startthelog

function startthelog($logname, $quick = FALSE)
{
    logit($logname, '-----------------------------------------------------------');
    $line = '';
    //logit($logname, $_SERVER['HTTP_REFERER']);
    if (!$quick) {
        // doing the dns lookup takes some extra time so use $quick to speed things up a bid
        $line = gethostbyaddr($_SERVER["REMOTE_HOST"]);
        if ($line == $_SERVER["REMOTE_ADDR"]) {
            $line = '** No DNS entry found for calling IP';
        }
        $line = ' - ' . $line;
    }
    logit($logname, $_SERVER["REMOTE_ADDR"] . $line);
    if (key_exists('HTTP_USER_AGENT', $_SERVER)) {
        logit($logname, $_SERVER['HTTP_USER_AGENT'] . $line);
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (substr(str_replace(chr(10), '', print_r($_POST, true)), 10) == '') {
            logit($logname, 'Called as a POST, but NO values were passed in');
        } else {
            logit($logname, 'POST values: ' . substr(str_replace(chr(10), '', print_r($_POST, true)), 10));
        }
    }
    if ($_SERVER["QUERY_STRING"] != '') {
        logit($logname, 'GET param string: ' . $_SERVER["QUERY_STRING"]);
    }
}
开发者ID:kyukido22,项目名称:phplib,代码行数:28,代码来源:logitv2.php

示例6: getComputerAndUserName

function getComputerAndUserName() {
//	$host = "SIN_HOST";
//	if (isset($_SERVER["REMOTE_HOST"]))
//		$host = $_SERVER["REMOTE_HOST"];
	$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
	return substr(strtoupper($_SESSION["usuario"]."/".$host), 0, 64);
}
开发者ID:javierlov,项目名称:FuentesWeb,代码行数:7,代码来源:buscar_domicilio.php

示例7: getArrayUsuario1

 public function getArrayUsuario1($parametros)
 {
     $arrayAux = $this->dLogin->getArrayUsuario('2', $parametros['p2'], $parametros['p3']);
     //$this->dLogin->getArrayUsuario1($parametros['p4'],$parametros['p2'],$parametros['p3']);
     //sistema,usuario,clave
     $ok = $arrayAux[0]['ok'];
     if ($ok == 'ok') {
         $array = $arrayAux[0];
         if (isset($_SESSION)) {
             session_unset();
             // Finalmente, destruye la sesión
             session_destroy();
         }
         session_start();
         //echo 'sesion iniciada';
         // session_id(time());
         $_SESSION['iid_sistema'] = '2';
         $_SESSION['login_user'] = $array['vlogin_usuario'];
         $_SESSION['id_usuario'] = $array['iid_usuario'];
         $_SESSION['host'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
         $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
         $_SESSION['id_persona'] = $array['c_cod_per'];
         $_SESSION['nombre'] = $array['v_nomcompleto'];
         $_SESSION['iCodigoEmpleado'] = $array['iCodigoEmpleado'];
         if (isset($array['c_id_caja'])) {
             $_SESSION["c_id_caja"] = $array['c_id_caja'];
         } else {
             $_SESSION["c_id_caja"] = "nada";
         }
         $_SESSION['path_principal'] = '../../../';
     }
     return $ok;
 }
开发者ID:gianpascal,项目名称:yachay,代码行数:33,代码来源:LLogin.php

示例8: execute

 /**
  * @see	\wcf\system\event\listener\IParameterizedEventListener::execute()
  */
 public function execute($eventObj, $className, $eventName, array &$parameters)
 {
     if (WCF::getUser()->userID && WCF::getSession()->getPermission('admin.general.canUseAcp') && !defined(get_class($eventObj) . '::DO_NOT_LOG')) {
         // try to find existing session log
         $sql = "SELECT\tsessionLogID\n\t\t\t\tFROM\twcf" . WCF_N . "_acp_session_log\n\t\t\t\tWHERE\tsessionID = ?\n\t\t\t\t\tAND lastActivityTime >= ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array(WCF::getSession()->sessionID, TIME_NOW - SESSION_TIMEOUT));
         $row = $statement->fetchArray();
         if (!empty($row['sessionLogID'])) {
             $sessionLogID = $row['sessionLogID'];
             $sessionLogEditor = new ACPSessionLogEditor(new ACPSessionLog(null, array('sessionLogID' => $sessionLogID)));
             $sessionLogEditor->update(array('lastActivityTime' => TIME_NOW));
         } else {
             // create new session log
             $sessionLog = ACPSessionLogEditor::create(array('sessionID' => WCF::getSession()->sessionID, 'userID' => WCF::getUser()->userID, 'ipAddress' => UserUtil::getIpAddress(), 'hostname' => @gethostbyaddr(WCF::getSession()->ipAddress), 'userAgent' => WCF::getSession()->userAgent, 'time' => TIME_NOW, 'lastActivityTime' => TIME_NOW));
             $sessionLogID = $sessionLog->sessionLogID;
         }
         // format request uri
         $requestURI = WCF::getSession()->requestURI;
         // remove directories
         $URIComponents = explode('/', $requestURI);
         $requestURI = array_pop($URIComponents);
         // remove session url
         $requestURI = preg_replace('/(?:\\?|&)s=[a-f0-9]{40}/', '', $requestURI);
         // save access
         ACPSessionAccessLogEditor::create(array('sessionLogID' => $sessionLogID, 'ipAddress' => UserUtil::getIpAddress(), 'time' => TIME_NOW, 'requestURI' => $requestURI, 'requestMethod' => WCF::getSession()->requestMethod, 'className' => get_class($eventObj)));
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:31,代码来源:SessionAccessLogListener.class.php

示例9: execute

 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (WCF::getUser()->userID && WCF::getUser()->getPermission('admin.general.canUseAcp') && !defined(get_class($eventObj) . '::DO_NOT_LOG')) {
         // try to find existing session log
         $sql = "SELECT\tsessionLogID\n\t\t\t\tFROM\twcf" . WCF_N . "_acp_session_log\n\t\t\t\tWHERE\tsessionID = '" . WCF::getSession()->sessionID . "'\n\t\t\t\t\tAND lastActivityTime >= " . (TIME_NOW - SESSION_TIMEOUT);
         $row = WCF::getDB()->getFirstRow($sql);
         if (!empty($row['sessionLogID'])) {
             $sessionLogID = $row['sessionLogID'];
             // update session log
             $sql = "UPDATE\twcf" . WCF_N . "_acp_session_log\n\t\t\t\t\tSET\tlastActivityTime = " . TIME_NOW . "\n\t\t\t\t\tWHERE\tsessionLogID = " . $sessionLogID;
             WCF::getDB()->registerShutdownUpdate($sql);
         } else {
             // create new session log
             $sql = "INSERT INTO\twcf" . WCF_N . "_acp_session_log\n\t\t\t\t\t\t\t(sessionID, userID, ipAddress, hostname, userAgent, time, lastActivityTime)\n\t\t\t\t\tVALUES\t\t('" . WCF::getSession()->sessionID . "', " . WCF::getUser()->userID . ", '" . escapeString(WCF::getSession()->ipAddress) . "', '" . escapeString(@gethostbyaddr(WCF::getSession()->ipAddress)) . "', '" . escapeString(WCF::getSession()->userAgent) . "', " . TIME_NOW . ", " . TIME_NOW . ")";
             WCF::getDB()->sendQuery($sql);
             $sessionLogID = WCF::getDB()->getInsertID("wcf" . WCF_N . "_acp_session_log", 'sessionLogID');
         }
         // format request uri
         $requestURI = WCF::getSession()->requestURI;
         // remove directories
         $URIComponents = explode('/', $requestURI);
         $requestURI = array_pop($URIComponents);
         // remove session url
         $requestURI = preg_replace('/(?:\\?|&)s=[a-f0-9]{40}/', '', $requestURI);
         // save access
         $sql = "INSERT INTO\twcf" . WCF_N . "_acp_session_access_log\n\t\t\t\t\t\t(sessionLogID, packageID, ipAddress, time, requestURI, requestMethod, className)\n\t\t\t\tVALUES\t\t(" . $sessionLogID . ", " . PACKAGE_ID . ", '" . escapeString(WCF::getSession()->ipAddress) . "', " . TIME_NOW . ", '" . escapeString($requestURI) . "', '" . escapeString(WCF::getSession()->requestMethod) . "', '" . escapeString(get_class($eventObj)) . "')";
         WCF::getDB()->registerShutdownUpdate($sql);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:32,代码来源:SessionAccessLogListener.class.php

示例10: applet

 public function applet()
 {
     $f = $this->init_module('Libs/QuickForm');
     $t = $f->createElement('text', 't');
     $ok = $f->createElement('submit', 'ok', __('OK'));
     $f->addGroup(array($t, $ok), 'w');
     $f->display();
     $msg =& $this->get_module_variable('msg');
     if ($f->validate()) {
         $w = $f->exportValues();
         $w = $w['w']['t'];
         if (ip2long($w) === false) {
             $ip = gethostbynamel($w);
             if ($ip) {
                 $msg = '';
                 foreach ($ip as $i) {
                     $msg .= $i . '<br>';
                 }
             } else {
                 $msg = __('No such domain');
             }
         } else {
             $domain = gethostbyaddr($w);
             if ($domain != $w) {
                 $msg = $domain;
             } else {
                 $msg = __('No such ip entry');
             }
         }
     }
     print $msg;
 }
开发者ID:62BRAINS,项目名称:EPESI,代码行数:32,代码来源:Host_0.php

示例11: authenticate

 public function authenticate(\fpoirotte\Pssht\Messages\USERAUTH\REQUEST\Base $message, \fpoirotte\Pssht\Transport $transport, array &$context)
 {
     if (!$message instanceof \fpoirotte\Pssht\Messages\USERAUTH\REQUEST\PublicKey) {
         throw new \InvalidArgumentException();
     }
     if ($message->getSignature() === null) {
         return self::AUTH_REJECT;
     }
     $logging = \Plop\Plop::getInstance();
     $reverse = gethostbyaddr($transport->getAddress());
     $algos = \fpoirotte\Pssht\Algorithms::factory();
     $cls = $algos->getClass('PublicKey', $message->getAlgorithm());
     if ($cls === null || !$this->store->exists($message->getUserName(), $message->getKey())) {
         $logging->info('Rejected public key connection from remote host "%(reverse)s" ' . 'to "%(luser)s" (unsupported key)', array('luser' => escape($message->getUserName()), 'reverse' => $reverse));
         return self::AUTH_REJECT;
     }
     $key = $cls::loadPublic(base64_encode($message->getKey()));
     $encoder = new \fpoirotte\Pssht\Wire\Encoder();
     $encoder->encodeString($context['DH']->getExchangeHash());
     $encoder->encodeBytes(chr(\fpoirotte\Pssht\Messages\USERAUTH\REQUEST\Base::getMessageId()));
     $encoder->encodeString($message->getUserName());
     $encoder->encodeString($message->getServiceName());
     $encoder->encodeString(static::getName());
     $encoder->encodeBoolean(true);
     $encoder->encodeString($message->getAlgorithm());
     $encoder->encodeString($message->getKey());
     if ($key->check($encoder->getBuffer()->get(0), $message->getSignature())) {
         $logging->info('Accepted public key connection from remote host "%(reverse)s" ' . 'to "%(luser)s" (using "%(algorithm)s" algorithm)', array('luser' => escape($message->getUserName()), 'reverse' => $reverse, 'algorithm' => escape($message->getAlgorithm())));
         return self::AUTH_ACCEPT;
     }
     $logging->info('Rejected public key connection from remote host "%(reverse)s" ' . 'to "%(luser)s" (invalid signature)', array('luser' => escape($message->getUserName()), 'reverse' => $reverse));
     return self::AUTH_REJECT;
 }
开发者ID:fpoirotte,项目名称:pssht,代码行数:33,代码来源:PublicKey.php

示例12: writeSession

 /** Creates a new session entry in database and return its ID.
  *
  * @param $uid the id of the logged user
  * @param $suid the id of the administrator who has just su'd to the user
  * @return session the session id
  */
 private function writeSession($uid, $suid = null)
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $host = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
     $browser = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
     @(list($forward_ip, ) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
     $forward_host = $forward_ip;
     if ($forward_host) {
         $forward_host = strtolower(gethostbyaddr($forward_host));
     }
     $proxy = '';
     if ($forward_ip || @$_SERVER['HTTP_VIA']) {
         $proxy = 'proxy';
     }
     $uid = $uid == 0 ? null : $uid;
     $suid = $suid == 0 ? null : $suid;
     XDB::execute("INSERT INTO  log_sessions\n                              SET  uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}", $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy);
     if ($forward_ip) {
         $this->proxy_ip = $ip;
         $this->proxy_host = $host;
         $this->ip = $forward_ip;
         $this->host = $forward_host;
     } else {
         $this->ip = $ip;
         $this->host = $host;
     }
     return XDB::insertId();
 }
开发者ID:Ekleog,项目名称:platal,代码行数:34,代码来源:platallogger.php

示例13: getRegSpamScore

 static function getRegSpamScore(&$score, array $user, $verbose, $debug, $model)
 {
     $o = XenForo_Application::getOptions();
     if (trim($o->TPUDetectSpamRegHostname) != '') {
         $hostname = gethostbyaddr($user['ip']);
         if ($verbose) {
             $model->logScore('tpu_detectspamreg_hostname_detected', 0, array('hostname' => $hostname));
         }
         foreach (explode("\n", $o->TPUDetectSpamRegHostname) as $entry) {
             $entry = explode('|', trim($entry));
             if (count($entry) != 2) {
                 continue;
             }
             list($points, $match) = $entry;
             $regex = $model->buildWildcardRegex($match);
             if (preg_match('/^' . $regex . '$/iU', $hostname)) {
                 $model->logScore('tpu_detectspamreg_hostname_fail', $points, array('hostname' => $match));
                 if (is_numeric($points)) {
                     $score['points'] += $points;
                 } else {
                     $score[$points] = true;
                 }
             } else {
                 if ($debug) {
                     $model->logScore('tpu_detectspamreg_hostname_ok', 0, array('hostname' => $match));
                 }
             }
         }
     }
 }
开发者ID:W1zzardTPU,项目名称:XenForo_TPUDetectSpamReg,代码行数:30,代码来源:Hostname.php

示例14: resolv

 /**
  * This function puts a host
  *
  * @param string $pHost
  * @return void
  */
 public function resolv($pHost)
 {
     $aHost = explode("\\", $pHost);
     if (count($aHost) > 1) {
         $ipHost = $aHost[0];
         $this->db_instance = $aHost[1];
     } else {
         $ipHost = $pHost;
     }
     if ($this->is_ipaddress($ipHost)) {
         $this->ip = $ipHost;
         if (!($this->hostname = @gethostbyaddr($ipHost))) {
             $this->errno = 2000;
             $this->errstr = "NET::Host down";
             $this->error = G::loadTranslation('ID_HOST_UNREACHABLE');
         }
     } else {
         $ip = @gethostbyname($ipHost);
         $long = ip2long($ip);
         if ($long == -1 || $long === false) {
             $this->errno = 2000;
             $this->errstr = "NET::Host down";
             $this->error = G::loadTranslation('ID_HOST_UNREACHABLE');
         } else {
             $this->ip = @gethostbyname($ipHost);
             $this->hostname = $pHost;
         }
     }
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:35,代码来源:class.net.php

示例15: analyse

 /**
  * Discover host and port for specified prefix and ports
  *
  * @param $email
  * @param $prefix
  * @param $ports
  * @return array
  * @throws \Exception
  */
 private function analyse($email, $prefix, $ports)
 {
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new \Exception('Not a valid email');
     }
     $host = null;
     $domain = explode('@', $email);
     if ($mxServer = Dns::getTopMx($domain[1])) {
         // save MX-server information
         $mxServerDomains = explode('.', $mxServer);
         $mxServerRoot = implode('.', array_slice($mxServerDomains, -2, 2));
         $this->mxServer = $mxServer;
         $this->mxServerRoot = $mxServerRoot;
     }
     if ($port = Socket::pingPort($prefix . $domain[1], $ports)) {
         $host = $prefix . $domain[1];
     } elseif ($mxServer) {
         if ($port = Socket::pingPort($mxServer, $ports)) {
             $host = $mxServer;
         } else {
             $revMxServer = gethostbyaddr(gethostbyname($mxServer));
             $revMxServerDomains = explode('.', $revMxServer);
             $revMxServerRoot = @implode('.', array_slice($revMxServerDomains, -2, 2));
             if ($port = Socket::pingPort($prefix . $revMxServerRoot, $ports)) {
                 $host = $prefix . $revMxServerRoot;
             } else {
                 if ($port = Socket::pingPort($prefix . $mxServerRoot, $ports)) {
                     $host = $prefix . $mxServerRoot;
                 }
             }
         }
     }
     return [$host, $port];
 }
开发者ID:punarinta,项目名称:email-auth,代码行数:43,代码来源:Discover.php


注:本文中的gethostbyaddr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。