本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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"]);
}
}
示例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);
}
示例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;
}
示例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)));
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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));
}
}
}
}
}
示例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;
}
}
}
示例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];
}