本文整理汇总了PHP中gethostbynamel函数的典型用法代码示例。如果您正苦于以下问题:PHP gethostbynamel函数的具体用法?PHP gethostbynamel怎么用?PHP gethostbynamel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gethostbynamel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select_ip_address
/**
* Selects a geographically-closest working IP address.
*
* @param $host
* @param $port
* @return string "hostname:portnumber" of selected server
*/
private function select_ip_address($host, $port)
{
// First try all servers in geographically-closest datacenter
$ip_list = gethostbynamel($host);
$selected_ip = "";
if ($ip_list != false) {
shuffle($ip_list);
foreach ($ip_list as $ip) {
$socket = @stream_socket_client($ip . ":" . $port, $errno, $errstr, 0.5, STREAM_CLIENT_CONNECT);
if ($socket) {
$this->m_socket = $socket;
$selected_ip = $ip;
break;
}
}
}
// Looks like entire datacenter is down, so try our luck with one of global IPs
if ($selected_ip == "") {
$global_ip_list = gethostbynamel("api.global.kontagent.net");
shuffle($global_ip_list);
foreach ($global_ip_list as $global_ip) {
$socket = @stream_socket_client($global_ip . ":" . $port, $errno, $errstr, 0.5, STREAM_CLIENT_CONNECT);
if ($socket) {
$this->m_socket = $socket;
$selected_ip = $global_ip;
break;
}
}
}
return $selected_ip . ":" . $port;
}
示例2: vidtrial_portal_host
public function vidtrial_portal_host($val)
{
if (!gethostbynamel($val)) {
throw new ValidationError(__("The domain you entered does not have a valid DNS entry.", VIDTRIAL_TD));
}
return sanitize_text_field($val);
}
示例3: hostsByName
/**
* Resolves a hostname to one or more IP addresses.
* @param string $hostname
* @return array
* @throw Bringit_Exception_DnsError
*/
public function hostsByName($hostname)
{
if (!($hosts = gethostbynamel($hostname))) {
throw new Bringit_Exception_DnsException("Unable to resolve hostname '{$hostname}'");
}
return $hosts;
}
示例4: bb2_blackhole
function bb2_blackhole($package) {
// Only conservative lists
$bb2_blackhole_lists = array(
"sbl-xbl.spamhaus.org", // All around nasties
// "dnsbl.sorbs.net", // Old useless data.
// "list.dsbl.org", // Old useless data.
// "dnsbl.ioerror.us", // Bad Behavior Blackhole
);
// Things that shouldn't be blocked, from aggregate lists
$bb2_blackhole_exceptions = array(
"sbl-xbl.spamhaus.org" => array("127.0.0.4"), // CBL is problematic
"dnsbl.sorbs.net" => array("127.0.0.10",), // Dynamic IPs only
"list.dsbl.org" => array(),
"dnsbl.ioerror.us" => array(),
);
// Check the blackhole lists
$ip = $package['ip'];
$find = implode('.', array_reverse(explode('.', $ip)));
foreach ($bb2_blackhole_lists as $dnsbl) {
$result = gethostbynamel($find . "." . $dnsbl . ".");
if (!empty($result)) {
// Got a match and it isn't on the exception list
$result = @array_diff($result, $bb2_blackhole_exceptions[$dnsbl]);
if (!empty($result)) {
return '136673cd';
}
}
}
return false;
}
示例5: bb2_httpbl
function bb2_httpbl($settings, $package)
{
// Can't use IPv6 addresses yet
if (@is_ipv6($package['ip'])) {
return false;
}
if (@(!$settings['httpbl_key'])) {
return false;
}
// Workaround for "MySQL server has gone away"
bb2_db_query("SET @@session.wait_timeout = 90");
$find = implode('.', array_reverse(explode('.', $package['ip'])));
$result = gethostbynamel($settings['httpbl_key'] . ".{$find}.dnsbl.httpbl.org.");
if (!empty($result)) {
$ip = explode('.', $result[0]);
// Check if threat
if ($ip[0] == 127 && $ip[3] & 7 && $ip[2] >= $settings['httpbl_threat'] && $ip[1] <= $settings['httpbl_maxage']) {
return '2b021b1f';
}
// Check if search engine
if ($ip[3] == 0) {
return 1;
}
}
return false;
}
示例6: displayTask
/**
* Run any scheduled cron tasks
*
* @return void
*/
public function displayTask()
{
// If the current user doesn't have access to manage the component,
// try to see if their IP address is in the whtielist.
// Otherwise, we stop any further code execution.
if (!User::authorise('core.manage', $this->_option)) {
$ip = Request::ip();
$ips = explode(',', $this->config->get('whitelist', ''));
$ips = array_map('trim', $ips);
if (!in_array($ip, $ips)) {
$ips = gethostbynamel($_SERVER['SERVER_NAME']);
if (!in_array($ip, $ips)) {
$ips = gethostbynamel('localhost');
if (!in_array($ip, $ips)) {
header("HTTP/1.1 404 Not Found");
exit;
}
}
}
}
// Forcefully do NOT render the template
// (extra processing that's not needed)
Request::setVar('no_html', 1);
Request::setVar('tmpl', 'component');
$now = Date::toSql();
// Get the list of jobs that should be run
$results = Job::all()->whereEquals('state', 1)->where('next_run', '<=', Date::toLocal('Y-m-d H:i:s'))->whereEquals('publish_up', '0000-00-00 00:00:00', 1)->orWhere('publish_up', '<=', $now, 1)->resetDepth()->whereEquals('publish_down', '0000-00-00 00:00:00', 1)->orWhere('publish_down', '>', $now, 1)->rows();
$output = new stdClass();
$output->jobs = array();
if ($results) {
foreach ($results as $job) {
if ($job->get('active') || !$job->isAvailable()) {
continue;
}
// Show related content
$job->mark('start_run');
$results = Event::trigger('cron.' . $job->get('event'), array($job));
if ($results && is_array($results)) {
// Set it as active in case there were multiple plugins called on
// the event. This is to ensure ALL processes finished.
$job->set('active', 1);
$job->save();
foreach ($results as $result) {
if ($result) {
$job->set('active', 0);
}
}
}
$job->mark('end_run');
$job->set('last_run', Date::toLocal('Y-m-d H:i:s'));
//Date::toSql());
$job->set('next_run', $job->nextRun());
$job->save();
$output->jobs[] = $job->toArray();
}
}
// Output any data from the jobs that ran
// Largely used for debugging/monitoring purposes
$this->view->set('no_html', Request::getInt('no_html', 0))->set('output', $output)->display();
}
示例7: 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;
}
示例8: getHosts
/**
* Retrieve a list of licensing server IPs
*
* @return array
*/
function getHosts()
{
$hosts = gethostbynamel('licensing28.whmcs.com');
if ($hosts === false) {
$hosts = array();
}
return $hosts;
}
示例9: __construct
function __construct($op = null)
{
$this->op = $op;
$this->lnbr = $this->getOSVar('lnbr', PHP_OS);
$this->beta = sha1($_SERVER["SERVER_NAME"]) === "d66185da066bb74916a24bb33d134c34e8cf1073" ? true : false;
$this->clear_detect();
\frdl\webfan\App::God(false)->addFunc('getOSName', function () {
return PHP_OS;
});
\frdl\webfan\App::God(false)->addFunc('getServerIp', function ($all = true) {
$i = gethostbynamel($_SERVER['SERVER_NAME']);
if ($all === false) {
return isset($i['ips'][0]) ? $i['ips'][0] : '0.0.0.0';
}
return $i;
});
\frdl\webfan\App::God(false)->addFunc('getBaseDir', function () {
$open_basedir = ini_get('open_basedir');
if (!is_string($open_basedir) || trim($open_basedir) === '') {
return realpath($_SERVER['DOCUMENT_ROOT'] . \frdl\webfan\App::DS . '..' . \frdl\webfan\App::DS) . \frdl\webfan\App::DS;
} else {
$basedir = explode(':', $open_basedir);
$basedir = trim($basedir[0]);
return $basedir;
}
});
\frdl\webfan\App::God(false)->addFunc('removeEvalFromFilename', function () {
$args = func_get_args();
return str_replace(' : eval()\'d code', '', preg_replace("/(\\([0-9]+\\))/", "", $args[0][0]));
});
$this->str = array();
$this->str['en'] = array('English', array('__MAINTENANCE__' => '<span class="webfan-red">Our Install-Server is in maintenance mode.</span> Please try again later: <a href="http://www.webfan.de/install/">http://www.webfan.de/install/</a>', '__APPS__' => 'Applications', '__INSTALLATIONS__' => 'Installations', '__SETTINGS__' => 'Settings', '__INSTALL__' => 'install', '__INSTALL_NOW__' => 'install now', '__INSTALL_HERE__' => 'Install HERE!', '__IS_NOT_WRITABLE__' => 'is not writable', '__DOWNLOAD_FAILED__' => 'Download failed', '__CANNOT_WRITE_FILE__' => 'Cannot write file', '__CANNOT_UNZIP_FILE__' => 'Cannot unzip file', '__ACCEPT_LICENSE__' => 'Accept license', '__LANGUAGE__' => 'Language', '__VERSION_UNAVAILABLE__' => 'The selected version is not available', '__ERROR__' => 'Error', '__HINT_DEL_FILE__' => 'You should delete this file when done!\\nTo do so click the red button at bottom!', '__RECOMMENDED__' => 'recommended', '__THIS_FILE__' => 'This file', '__TEST_ONLY__' => 'For testing only', '__INCOMPLETE_OR_BROKEN__' => 'Incomplete or broken', '__SURE_BACKUP__' => 'sure/backup', '__CHECK_SURE__' => 'not confirmed', '__REQUIRED_PHP_VERSION_FAILED_1__' => 'Your php version does not apply to the requirements of the requested software. You need <strong>PHP Version</strong> ' . htmlentities('=>') . ' ', '__INSTALL_TEMP_DIR__' => 'Temp-Dir', '__NO_PRAGMAMX_FOUND_IND_DIR__' => 'No PragmaMx installation found in the given directory', '__CHECKSUM_INVALID__' => 'Invalid checksum', '__REQUIRED_BY_WEBFAN_PMX_MODULES__' => 'required by the Webfan PragmaMx Modules'));
$this->str['de'] = array('Deutsch', array('__MAINTENANCE__' => '<span class="webfan-red">Der Install-Server wird derzeit gewartet.</span> Bitte etwas später nochmal probieren: <a href="http://www.webfan.de/install/">http://www.webfan.de/install/</a>', '__APPS__' => 'Anwendungen', '__INSTALLATIONS__' => 'Installationen', '__SETTINGS__' => 'Einstellungen', '__INSTALL__' => 'installieren', '__INSTALL_NOW__' => 'jetzt installieren', '__INSTALL_HERE__' => 'HIER installieren', '__IS_NOT_WRITABLE__' => 'ist nicht beschreibbar', '__DOWNLOAD_FAILED__' => 'Download fehlgeschlagen', '__CANNOT_WRITE_FILE__' => 'Kann Datei nicht schreiben', '__CANNOT_UNZIP_FILE__' => 'Kann Datei nicht entpacken', '__ACCEPT_LICENSE__' => 'Lizenz akzeptieren', '__LANGUAGE__' => 'Sprache', '__VERSION_UNAVAILABLE__' => 'Die ausgewählte Version ist nicht verfügbar', '__ERROR__' => 'Fehler', '__HINT_DEL_FILE__' => 'Sie sollten diese Datei löschen wenn Sie fertig sind!\\nKlicken Sie hierzu auf den roten Button ganz unten!', '__RECOMMENDED__' => 'empfohlen', '__THIS_FILE__' => 'Diese Datei', '__TEST_ONLY__' => 'Nur für Testzwecke', '__INCOMPLETE_OR_BROKEN__' => 'Unvollständig oder defekt', '__SURE_BACKUP__' => 'sicher/Backup', '__CHECK_SURE__' => 'nicht bestätigt', '__REQUIRED_PHP_VERSION_FAILED_1__' => 'Ihre php Version genügt nicht den Ansprüchen der angeforderten Software. Sie benötigen <strong>PHP Version</strong> ' . htmlentities('=>') . ' ', '__INSTALL_TEMP_DIR__' => 'Temp-Dir', '__NO_PRAGMAMX_FOUND_IND_DIR__' => 'Keine PragmaMx Installation im angegebenen Verzeichnis gefunden', '__CHECKSUM_INVALID__' => 'Ungültige Prüfsumme', '__REQUIRED_BY_WEBFAN_PMX_MODULES__' => 'wird zur Installation und Betrieb der Webfan Module für das PragmaMx CMS benötigt'));
$this->str['fr'] = array('French', array('__MAINTENANCE__' => '<span class="webfan-red">Notre serveur d\'installation est en cours de maintenance.</span> Merci de réessayer plus tard: <a href="http://www.webfan.de/install/">http://www.webfan.de/install/</a>', '__APPS__' => 'Applications', '__INSTALLATIONS__' => 'Installations', '__SETTINGS__' => 'Paramètres', '__INSTALL__' => 'installer', '__INSTALL_NOW__' => 'installer maintenant', '__INSTALL_HERE__' => 'Installer ici !', '__IS_NOT_WRITABLE__' => 'n\'est pas inscriptible', '__DOWNLOAD_FAILED__' => 'Téléchargement échoué', '__CANNOT_WRITE_FILE__' => 'Impossible d\'écrire le fichier', '__CANNOT_UNZIP_FILE__' => 'Impossible de décompresser le fichier', '__ACCEPT_LICENSE__' => 'Accepter la license', '__LANGUAGE__' => 'Langage', '__VERSION_UNAVAILABLE__' => 'La version choise n\'est pas disponible', '__ERROR__' => 'Erreur', '__HINT_DEL_FILE__' => 'Vous devriez supprimer ce fichier un fois terminé !\\nPour le faire cliquer sur le bouton rouge au dessous!', '__RECOMMENDED__' => 'recommendé', '__THIS_FILE__' => 'Ce fichier', '__TEST_ONLY__' => 'Seulement pour des test', '__INCOMPLETE_OR_BROKEN__' => 'Incomplet ou cassé', '__SURE_BACKUP__' => 'sauver/sauvegarder', '__CHECK_SURE__' => 'non confirmé', '__REQUIRED_PHP_VERSION_FAILED_1__' => 'Votre version de php ne correspond pas à celle requise par le logiciel. Vous avez besoin de la <strong>Version de PHP</strong> ' . htmlentities('=>') . ' ', '__INSTALL_TEMP_DIR__' => 'Dossier temporaire', '__NO_PRAGMAMX_FOUND_IND_DIR__' => 'Aucune installation de PragmaMx n\'a été trouvé de le répertoire spécifié', '__CHECKSUM_INVALID__' => 'Checksum invalide', '__REQUIRED_BY_WEBFAN_PMX_MODULES__' => 'Requis pour les modules PragmaMx WEBFAN'));
$this->forms = array();
$this->forms[self::GROUP_CURRENT] = null;
$this->forms[self::GROUP_APPS] = array(self::APP_PMX => array('render_func' => 'form_pmx', 'flushed' => false), self::APP_WEBDOF => array('render_func' => 'form_app_webdof', 'flushed' => false));
if (!isset($_SESSION[self::SESSKEY])) {
$_SESSION[self::SESSKEY] = array();
}
if (isset($_SESSION[self::SESSKEY]['op'])) {
$this->op =& $_SESSION[self::SESSKEY]['op'];
} else {
$_SESSION[self::SESSKEY]['op'] =& $this->op;
}
$_SESSION[self::SESSKEY]['lang'] = isset($_SESSION[self::SESSKEY]['lang']) ? $_SESSION[self::SESSKEY]['lang'] : 'en';
if (isset($_REQUEST['lang']) && isset($this->str[$_REQUEST['lang']])) {
$_SESSION[self::SESSKEY]['lang'] = strip_tags($_REQUEST['lang']);
}
$this->lang =& $_SESSION[self::SESSKEY]['lang'];
$this->dir_install_temp = isset($_SESSION[self::SESSKEY]['dir_install_temp']) ? $_SESSION[self::SESSKEY]['dir_install_temp'] : __DIR__ . \frdl\webfan\App::DS;
if (!isset($_SESSION[self::SESSKEY]['repositories'])) {
Loader::repository('frdl');
}
$_SESSION[self::SESSKEY]['repositories'] = isset($_SESSION[self::SESSKEY]['repositories']) ? $_SESSION[self::SESSKEY]['repositories'] : array('webfan' => array('name' => 'Webfan Installer (webdof)'), 'frdl' => array('name' => 'frdl (Application Composer)'));
$this->katalog();
}
示例10: getRegSpamScore
static function getRegSpamScore(&$score, array $user, $verbose, $debug, $model)
{
$o = XenForo_Application::getOptions();
if ($o->TPUDetectSpamRegTORScore != 0) {
// Only IPv4 supported
if (filter_var($user['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) == FALSE) {
return;
}
$srvIp = array();
if ($o->TPUDetectSpamRegSrvIp != '') {
$list = explode(',', $o->TPUDetectSpamRegSrvIp);
foreach ($list as $entry) {
$entry = trim($entry);
if ($entry != '') {
$hosts = gethostbynamel($entry);
if (is_array($hosts)) {
foreach ($hosts as $ip) {
// Only IPv4 supported
if (filter_var($user['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$srvIp[] = $ip;
}
}
}
}
}
}
if (!$srvIp) {
if (isset($_SERVER['SERVER_ADDR'])) {
$srvIp[] = $_SERVER['SERVER_ADDR'];
} elseif (isset($_SERVER['LOCAL_ADDR'])) {
$srvIp[] = $_SERVER['LOCAL_ADDR'];
}
}
$srvIp = array_unique($srvIp);
if (!$srvIp) {
$model->logScore('Could not get server IP address for TOR detection module', 0);
return;
}
$user_ip = self::reverseIP($user['ip']);
$portsToCheck = array(80, 443);
// Check both HTTP and HTTPS
foreach ($srvIp as $ip) {
foreach ($portsToCheck as $port) {
$q = sprintf('%s.%s.%s.ip-port.exitlist.torproject.org', $user_ip, $port, self::reverseIP($ip));
if (gethostbyname($q) == '127.0.0.2') {
$model->logScore('tpu_detectspamreg_tor_fail', $o->TPUDetectSpamRegTORScore);
$score['points'] += $o->TPUDetectSpamRegTORScore;
return;
}
}
}
if ($debug) {
$model->logScore('tpu_detectspamreg_tor_ok', 0);
}
}
}
示例11: socket_connect_hostname
function socket_connect_hostname($socket, $hostname, $port)
{
$ips = gethostbynamel($hostname);
foreach ($ips as $ip) {
if (socket_connect($socket, $ip, $port)) {
return TRUE;
}
}
return FALSE;
}
示例12: nametoipl
/**
* Name to IP list,
* get all ip numbers given a certain domain or host $name.
*
* @param $name being a hostname
*
* @return array of ip numbers
*/
public function nametoipl($name = '')
{
if ('true' == Configure::read('MISP.dns')) {
if (!($ips = gethostbynamel($name))) {
$ips = array();
}
} else {
$ips = array();
}
return $ips;
}
示例13: checkHost
/**
* Checks if a host as a valid list of IPs
* @param $host
* @throws InvalidHostException
*/
protected function checkHost($host)
{
$disallowed = array('https://', 'http://');
foreach ($disallowed as $d) {
if (strpos($host, $d) === 0) {
$host = str_replace($d, '', $host);
}
}
if (false === gethostbynamel($host)) {
throw new InvalidHostException($host);
}
}
示例14: hostExists
/**
* Checks if the server specified in the url exists.
*
* @param $url url to check
* @return true, if the server exists; false otherwise
*/
function hostExists($url)
{
if (strpos($url, '/') === false) {
$server = $url;
} else {
$server = @parse_url($url, PHP_URL_HOST);
}
if (!$server) {
return false;
}
return !!gethostbynamel($server);
}
示例15: displayTask
/**
* Display a list of latest whiteboard entries
*
* @return void
*/
public function displayTask()
{
if (!User::authorise('core.manage', $this->_option)) {
$ip = Request::ip();
$ips = explode(',', $this->config->get('whitelist', ''));
$ips = array_map('trim', $ips);
if (!in_array($ip, $ips)) {
$ips = gethostbynamel($_SERVER['SERVER_NAME']);
if (!in_array($ip, $ips)) {
$ips = gethostbynamel('localhost');
if (!in_array($ip, $ips)) {
header("HTTP/1.1 404 Not Found");
exit;
}
}
}
}
Request::setVar('no_html', 1);
Request::setVar('tmpl', 'component');
$now = Date::toSql();
$results = Job::all()->whereEquals('state', 1)->where('next_run', '<=', Date::toLocal('Y-m-d H:i:s'))->whereEquals('publish_up', '0000-00-00 00:00:00', 1)->orWhere('publish_up', '<=', $now, 1)->resetDepth()->whereEquals('publish_down', '0000-00-00 00:00:00', 1)->orWhere('publish_down', '>', $now, 1)->rows();
$output = new stdClass();
$output->jobs = array();
if ($results) {
foreach ($results as $job) {
if ($job->get('active') || !$job->isAvailable()) {
continue;
}
// Show related content
$job->mark('start_run');
$results = Event::trigger('cron.' . $job->get('event'), array($job));
if ($results && is_array($results)) {
// Set it as active in case there were multiple plugins called on
// the event. This is to ensure ALL processes finished.
$job->set('active', 1);
$job->save();
foreach ($results as $result) {
if ($result) {
$job->set('active', 0);
}
}
}
$job->mark('end_run');
$job->set('last_run', Date::toLocal('Y-m-d H:i:s'));
//Date::toSql());
$job->set('next_run', $job->nextRun());
$job->save();
$output->jobs[] = $job->toArray();
}
}
$this->view->set('no_html', Request::getInt('no_html', 0))->set('output', $output)->display();
}