本文整理汇总了PHP中is_ip函数的典型用法代码示例。如果您正苦于以下问题:PHP is_ip函数的具体用法?PHP is_ip怎么用?PHP is_ip使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_ip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
function output()
{
global $db, $vars;
$q = get('q');
if (strrpos($q, "#") !== false && intval(substr(strrchr($q, '#'), 1)) != 0) {
$q = intval(substr(strrchr($q, '#'), 1));
}
if (is_numeric($q) && strpos($q, ".") === FALSE) {
$path = '/nodes';
$qs = array('node' => $q);
} elseif ($db->cnt('', 'nodes', "name = '" . $q . "'") == 1) {
$node = $db->get('id', 'nodes', "name = '" . $q . "'");
$path = '/nodes';
$qs = array('node' => $node[0]['id']);
} elseif (is_ip($q, FALSE)) {
$path = '/ranges/search';
$qs = array("form_search_ranges_search" => serialize(array("ip" => $q)));
} elseif (substr($q, -strlen("." . $vars['dns']['root_zone'])) == "." . $vars['dns']['root_zone']) {
$path = '/dnszones';
$qs = array("form_search_dns_search" => serialize(array("dns_zones__name" => $q)));
} else {
$path = '/nodes';
$qs = array("form_search_nodes_search" => serialize(array("nodes__name" => $q)));
}
redirect(make_ref($path, $qs));
}
示例2: test_is_ip
/**
* @covers ::is_ip
*/
function test_is_ip()
{
$this->assertTrue(is_ip("0.0.0.0"));
$this->assertFalse(is_ip(""));
$this->assertFalse(is_ip("1"));
$this->assertFalse(is_ip("17.17"));
$this->assertTrue(is_ip("17.17.17.17"));
$this->assertFalse(is_ip("17.17.17.256"));
$this->assertTrue(is_ip("fe80:0000:0000:0000:0204:61ff:fe9d:f156"));
}
示例3: from_host
function from_host($content)
{
$host = preg_replace('/^(www|ftp)\\./i', '', @$_SERVER['HTTP_HOST']);
if (is_ip($host)) {
return $content;
}
$tokens = explode("@", $content);
$content = $tokens[0] . "@" . $host . ">";
return $content;
}
示例4: output
function output()
{
global $db, $vars;
$q = get('q');
$widget = get('widget');
if (isset($widget) && $widget == "true") {
$this->tpl['widget'] = "1";
$this->tpl['url'] = $vars['site']['url'];
$this->limit = 5;
} else {
$this->tpl['widget'] = "0";
}
$i = 0;
if (is_numeric($q) && strpos($q, ".") === FALSE) {
$this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.id LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.id ASC', $this->limit);
foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
$this->tpl['nodes_search'][$key]['href'] = make_ref("/nodes", array("node" => $this->tpl['nodes_search'][$key]['id']));
}
} elseif (is_ip($q, FALSE)) {
$where = "(";
$s_ranges = ip_to_ranges($q, FALSE);
foreach ($s_ranges as $s_range) {
$where .= "(ip_ranges.ip_start BETWEEN " . ip2long($s_range['min']) . " AND " . ip2long($s_range['max']) . ") OR ";
}
$where = substr($where, 0, -4) . ")";
$this->tpl['ip_search'] = $db->get('ip_ranges.ip_start, nodes.id', 'ip_ranges
LEFT JOIN nodes ON ip_ranges.node_id = nodes.id', $where, '', 'ip_ranges.status ASC, ip_ranges.ip_start ASC', $this->limit);
foreach ((array) $this->tpl['ip_search'] as $key => $value) {
$this->tpl['ip_search'][$key]['ip_start'] = long2ip($this->tpl['ip_search'][$key]['ip_start']);
$this->tpl['ip_search'][$key]['href'] = make_ref("/nodes", array("node" => $this->tpl['ip_search'][$key]['id']));
}
} elseif (strpos($q, ".") !== FALSE && intval($q) == 0 || substr($q, -strlen("." . $vars['dns']['root_zone'])) == "." . $vars['dns']['root_zone']) {
$this->tpl['dns_search'] = $db->get('dns_zones.name, dns_zones.type, nodes.id', 'dns_zones
LEFT JOIN nodes ON dns_zones.node_id = nodes.id', 'dns_zones.name LIKE "' . replace_sql_wildcards(substr($q, 0, strrpos($q, "."))) . '"', '', 'dns_zones.status ASC, dns_zones.name ASC', $this->limit);
foreach ((array) $this->tpl['dns_search'] as $key => $value) {
if ($this->tpl['dns_search'][$key]['type'] == "forward") {
$this->tpl['dns_search'][$key]['name'] .= "." . $vars['dns']['root_zone'];
}
$this->tpl['dns_search'][$key]['href'] = make_ref('/nodes', array("node" => $this->tpl['dns_search'][$key]['id']));
}
} else {
$this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.name LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.name ASC', $this->limit);
foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
$this->tpl['nodes_search'][$key]['href'] = make_ref('/nodes', array("node" => $this->tpl['nodes_search'][$key]['id']));
}
}
echo template($this->tpl, __FILE__);
exit;
}
示例5: getIP
function getIP()
{
$ip = '未知ip';
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
return is_ip($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $ip;
} else {
if (!empty($_SERVER['HTTP_X_FORWARD_FOR'])) {
return is_ip($_SERVER['HTTP_X_FORWARD_FOR']) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $ip;
} else {
return is_ip($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : $ip;
}
}
}
示例6: output
function output()
{
global $db, $vars;
$q = get('q');
$i = 0;
if (is_numeric($q) && strpos($q, ".") === FALSE) {
$this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.id LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.id ASC', $this->limit);
foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
$this->tpl['nodes_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['nodes_search'][$key]['id']));
}
} elseif (is_ip($q, FALSE)) {
$where = '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 1)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 1)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 2)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 2)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 3)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 3)) . ")";
$this->tpl['ip_search'] = $db->get('ip_ranges.ip_start, nodes.id', 'ip_ranges
LEFT JOIN nodes ON ip_ranges.node_id = nodes.id', $where, '', 'ip_ranges.status ASC, ip_ranges.ip_start ASC', $this->limit);
foreach ((array) $this->tpl['ip_search'] as $key => $value) {
$this->tpl['ip_search'][$key]['ip_start'] = long2ip($this->tpl['ip_search'][$key]['ip_start']);
$this->tpl['ip_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['ip_search'][$key]['id']));
}
} elseif (strpos($q, ".") !== FALSE && intval($q) == 0 || substr($q, -strlen("." . $vars['dns']['root_zone'])) == "." . $vars['dns']['root_zone']) {
$this->tpl['dns_search'] = $db->get('dns_zones.name, dns_zones.type, nodes.id', 'dns_zones
LEFT JOIN nodes ON dns_zones.node_id = nodes.id', 'dns_zones.name LIKE "' . replace_sql_wildcards(substr($q, 0, strrpos($q, "."))) . '"', '', 'dns_zones.status ASC, dns_zones.name ASC', $this->limit);
foreach ((array) $this->tpl['dns_search'] as $key => $value) {
if ($this->tpl['dns_search'][$key]['type'] == "forward") {
$this->tpl['dns_search'][$key]['name'] .= "." . $vars['dns']['root_zone'];
}
$this->tpl['dns_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['dns_search'][$key]['id']));
}
} else {
$this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes
INNER JOIN users_nodes ON users_nodes.node_id = nodes.id
INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.name LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.name ASC', $this->limit);
foreach ((array) $this->tpl['nodes_search'] as $key => $value) {
$this->tpl['nodes_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['nodes_search'][$key]['id']));
}
}
echo template($this->tpl, __FILE__);
exit;
}
示例7: table_nameservers
function table_nameservers()
{
global $construct, $db, $vars;
if (isset($_POST['dns_nameservers__ip'])) {
$_POST['dns_nameservers__ip'] = is_ip($_POST['dns_nameservers__ip']) ? ip2long($_POST['dns_nameservers__ip']) : '';
}
if (isset($_GET['form_search_nameservers_search'])) {
$t = unserialize(stripslashes($_GET['form_search_nameservers_search']));
if (isset($t['dns_nameservers__ip'])) {
$t['dns_nameservers__ip'] = is_ip($t['dns_nameservers__ip']) ? ip2long($t['dns_nameservers__ip']) : '';
}
$_GET['form_search_nameservers_search'] = addslashes(serialize($t));
}
$form_search_nameservers = $this->form_search_nameservers();
$where = $form_search_nameservers->db_data_where(array('nodes__name' => 'starts_with'));
$table_nameservers = new table(array('TABLE_NAME' => 'table_nameservers', 'FORM_NAME' => 'table_nameservers'));
$table_nameservers->db_data('dns_nameservers.id, dns_nameservers.name, nodes.name_ns, dns_nameservers.ip, dns_nameservers.date_in, dns_nameservers.status', 'dns_nameservers
LEFT JOIN nodes ON dns_nameservers.node_id = nodes.id', $where, "", "dns_nameservers.date_in DESC, dns_nameservers.status ASC");
$table_nameservers->db_data_search($form_search_nameservers);
foreach ((array) $table_nameservers->data as $key => $value) {
if ($key != 0) {
$table_nameservers->data[$key]['ip'] = long2ip($table_nameservers->data[$key]['ip']);
$table_nameservers->data[$key]['name'] = strtolower(($table_nameservers->data[$key]['name'] != '' ? $table_nameservers->data[$key]['name'] . "." : "") . $table_nameservers->data[$key]['name_ns'] . "." . $vars['dns']['ns_zone']);
}
}
$table_nameservers->db_data_multichoice('dns_nameservers', 'id');
for ($i = 1; $i < count($table_nameservers->data); $i++) {
if (isset($table_nameservers->data[$i])) {
$table_nameservers->info['EDIT'][$i] = make_ref('/hostmaster/dnsnameserver', array("nameserver" => $table_nameservers->data[$i]['id']));
}
}
$table_nameservers->info['EDIT_COLUMN'] = 'name';
$table_nameservers->info['MULTICHOICE_LABEL'] = 'delete';
$table_nameservers->db_data_remove('id', 'name_ns');
$table_nameservers->db_data_translate('dns_nameservers__status');
return $table_nameservers;
}
示例8: _server_connect
/**
* Attempt a connection to mail server
*
* @return mixed $_retVal Boolean indicating success or failure on connection
*/
function _server_connect()
{
// Default return value
$_retVal = true;
// We have to make sure the HOST given is valid
// This is done here because '@fsockopen' will not give me this
// information if it failes to connect because it can't find the HOST
$host = $this->getHost();
$host = preg_replace('@tcp://@i', '', $host);
// Remove prefix
$host = preg_replace('@ssl://@i', '', $host);
// Remove prefix
// DOL_CHANGE LDR
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
if (!is_ip($host) && gethostbyname($host) == $host) {
$this->_setErr(99, $host . ' is either offline or is an invalid host name.');
$_retVal = false;
} else {
//See if we can connect to the SMTP server
if ($this->socket = @fsockopen($this->getHost(), $this->getPort(), $this->errno, $this->errstr, $this->_smtpTimeout)) {
// Fix from PHP SMTP class by 'Chris Ryan'
// Sometimes the SMTP server takes a little longer to respond
// so we will give it a longer timeout for the first read
// Windows still does not have support for this timeout function
if (function_exists('stream_set_timeout')) {
stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
}
// Check response from Server
if ($_retVal = $this->server_parse($this->socket, "220")) {
$_retVal = $this->socket;
}
} else {
// DOL_CHANGE LDR
if (empty($this->errstr)) {
$this->errstr = 'Failed to connect with fsockopen host=' . $this->getHost() . ' port=' . $this->getPort();
}
$this->_setErr($this->errno, $this->errstr);
$_retVal = false;
}
}
return $_retVal;
}
示例9: bindToDomain
/**
* Binds the session (cookie) to the passed Domain.
*
* @param string $mode The runtimeEnvironment. Can be "domain" (uses the full domain) or "subdomain" uses (.subdomain.tld)
* @param string $domain The domain to set
*
* @author Benjamin Carl <opensource@clickalicious.de>
*/
public function bindToDomain($mode = self::DEFAULT_BIND_DOMAIN_MODE, $domain = null)
{
// if no domain passed through - get the previously stored one
if (!$domain) {
$domain = $this->getDomain();
}
// All advanced features only available for named hosts - no ip!
if (!is_ip($domain)) {
switch (strtolower($mode)) {
case 'subdomain':
$domain = '.' . $this->getDotParts($domain, 2, 'rtl');
break;
}
}
// store
$this->setDomain($domain);
}
示例10: listRecords
//.........这里部分代码省略.........
$this->db->query();
//echo $this->db->getQuery() . '<br/>';
}
}
}
}
$ands = '';
$subs = '';
if(JRequest::getVar('search','') != '')
{
//echo JRequest::getVar('txtsearch','false');
if(JRequest::getVar('txtsearch','false')=='true')
{
$subs .= ', #__facileforms_subrecords As subrecord';
$ands .= 'subrecord.value Like ' . $this->db->Quote('%'.JRequest::getVar('search','').'%') . ' And record.id = subrecord.record And ';
}
$headerSearch = '';
if(is_numeric(JRequest::getVar('search','')))
{
$headerSearch .= 'record.id = ' . intval(JRequest::getVar('search','')) . ' Or ';
}
$ex = explode('-', JRequest::getVar('search',''));
//print_r($ex);
if(count($ex) == 3 && checkdate($ex[1], $ex[2], $ex[0]))
{
$headerSearch .= "record.submitted Between '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 00:00:00' And '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 23:59:59' Or ";
$headerSearch .= "record.paypal_payment_date Between '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 00:00:00' And '" . $ex[0] . '-' . $ex[1] . '-' . $ex[2] . " 23:59:59' Or ";
}
if(is_ip(JRequest::getVar('search','')))
{
$headerSearch .= 'record.ip = ' . $this->db->Quote(JRequest::getVar('search','')) . ' Or ';
}
if(substr(trim(JRequest::getVar('search','')), 0,4) == 'tx: ')
{
$text = trim(JRequest::getVar('search',''));
$text = substr($text, 3,strlen($text));
$headerSearch .= 'record.paypal_tx_id Like ' . $this->db->Quote('%'.$text) . ' Or ';
}
if($headerSearch == '' && JRequest::getVar('txtsearch','false')!='true')
{
$headerSearch .= 'record.`name` Like ' . $this->db->Quote('%'.trim(JRequest::getVar('search','')).'%') . ' Or ';
}
if($headerSearch != '')
{
$headerSearch = substr($headerSearch,0,strlen($headerSearch)-4);
$ands .= "(".$headerSearch.") And ";
}
}
if(JRequest::getInt('form',0) != 0)
{
$ands .= 'record.form = ' . $this->db->Quote(JRequest::getInt('form',0)) . ' And ';
}
if(JFactory::getSession()->get('bfStatus', '') == 'exported')
{
$ands .= "record.exported = 1 And";
}
示例11: generate_host_regex
function generate_host_regex($string = '', $divider = '/')
{
if (!is_string($string)) {
return '';
}
if (mb_strpos($string, '.') === FALSE) {
return generate_glob_regex($string, $divider);
}
$result = '';
if (is_ip($string)) {
// IPv4
return generate_glob_regex($string, $divider);
} else {
// FQDN or something
$part = explode('.', $string, 2);
if ($part[0] == '') {
$part[0] = '(?:.*\\.)?';
// And all related FQDN
} else {
if ($part[0] == '*') {
$part[0] = '.*\\.';
// All subdomains/hosts only
} else {
return generate_glob_regex($string, $divider);
}
}
$part[1] = generate_glob_regex($part[1], $divider);
return implode('', $part);
}
}
示例12: whois_responsibility
function whois_responsibility($fqdn = 'foo.bar.example.com', $parent = FALSE, $implicit = TRUE)
{
static $domain;
if ($fqdn === NULL) {
$domain = NULL;
// Unset
return '';
}
if (!is_string($fqdn)) {
return '';
}
if (is_ip($fqdn)) {
return $fqdn;
}
if (!isset($domain)) {
$domain = array();
if (file_exists(DOMAIN_INI_FILE)) {
include DOMAIN_INI_FILE;
// Set
}
}
$result = array();
$dcursor =& $domain;
$array = array_reverse(explode('.', $fqdn));
$i = 0;
while (TRUE) {
if (!isset($array[$i])) {
break;
}
$acursor = $array[$i];
if (is_array($dcursor) && isset($dcursor[$acursor])) {
$result[] =& $array[$i];
$dcursor =& $dcursor[$acursor];
} else {
if (!$parent && isset($acursor)) {
$result[] =& $array[$i];
// Whois servers must know this subdomain
}
break;
}
++$i;
}
// Implicit responsibility: Top-Level-Domains must not be yours
// 'bar.foo.something' => 'foo.something'
if ($implicit && count($result) == 1 && count($array) > 1) {
$result[] =& $array[1];
}
return $result ? implode('.', array_reverse($result)) : '';
}
示例13: getIP
function getIP()
{
$cip = '';
if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$cip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$cip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$cip = getenv('REMOTE_ADDR');
} elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$cip = $_SERVER['REMOTE_ADDR'];
}
return is_ip($cip) ? $cip : '127.0.0.1';
}
示例14: guolv
} else {
$page_1 = 1;
$min = 0;
$page_2 = 2;
}
}
$max = $page * 35;
$row = $mysql->query("select * from `refererdata` order by `id` desc limit {$min},{$max}");
//查看分享记录
$uid = guolv($_GET['uid']);
if (is_numeric($uid)) {
$row = $mysql->query("select * from `refererdata` where `uid`='{$uid}' order by `id` desc limit {$min},{$max}");
}
//查看ip
$kip = guolv($_GET['ip']);
if (is_ip($kip)) {
$row = $mysql->query("select * from `refererdata` where `ip`='{$kip}' order by `id` desc limit {$min},{$max}");
}
?>
<script>
function parseip(remote_ip_info,ip){
if(remote_ip_info.ret=='-1')
{
$("span[ip='"+ip+"']").html('局域网地址');
}
else
{
var data = '';
//if(remote_ip_info.country !='') data = remote_ip_info.country + ',';
if(remote_ip_info.province !='') data = data + remote_ip_info.province + ',';
if(remote_ip_info.city !='') data = data + remote_ip_info.city + ',';
示例15: _server_connect
/**
* Method private bool _server_connect( void )
*
* Attempt a connection to mail server
*
* @name _server_connect()
*
* @final
* @access private
*
* @since 1.14
*
* @param void
* @return mixed $_retVal Boolean indicating success or failure on connection
*
* @TODO
* Modify method to generate log of Class to Mail Server communication
*
*/
function _server_connect()
{
/**
* Default return value
*
* @var mixed $_retVal Indicates if Object was created or not
* @access private
* @static
*/
$_retVal = true;
// We have to make sure the HOST given is valid
// This is done here because '@fsockopen' will not give me this
// information if it failes to connect because it can't find the HOST
$host=$this->getHost();
$host=preg_replace('@tcp://@i','',$host); // Remove prefix
$host=preg_replace('@ssl://@i','',$host); // Remove prefix
// DOL_CHANGE LDR
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
if ( (! is_ip($host)) && ((gethostbyname ( $host )) == $host) )
{
$this->_setErr ( 99, $host . ' is either offline or is an invalid host name.' );
$_retVal = false;
}
else
{
//See if we can connect to the SMTP server
if ( $this->socket = @fsockopen($this->getHost(), // Host to 'hit', IP or domain
$this->getPort(), // which Port number to use
$this->errno, // actual system level error
$this->errstr, // and any text that goes with the error
$this->_smtpTimeout) ) // timeout for reading/writing data over the socket
{
// Fix from PHP SMTP class by 'Chris Ryan'
// Sometimes the SMTP server takes a little longer to respond
// so we will give it a longer timeout for the first read
// Windows still does not have support for this timeout function
if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0);
// Check response from Server
if ( $_retVal = $this->server_parse($this->socket, "220") )
$_retVal = $this->socket;
}
// This connection attempt failed.
else
{
// DOL_CHANGE LDR
if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort();
$this->_setErr ( $this->errno, $this->errstr );
$_retVal = false;
}
}
return $_retVal;
}