本文整理汇总了PHP中is_ip函数的典型用法代码示例。如果您正苦于以下问题:PHP is_ip函数的具体用法?PHP is_ip怎么用?PHP is_ip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_ip函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:southern-wind,项目名称:wind,代码行数:26,代码来源:search_query.php
示例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"));
}
开发者ID:keruald,项目名称:globalfunctions,代码行数:13,代码来源:coreTest.php
示例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;
}
开发者ID:r4v,项目名称:php-exploits,代码行数:10,代码来源:plugin-decoded.php
示例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;
}
开发者ID:southern-wind,项目名称:wind,代码行数:53,代码来源:search_suggest.php
示例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;
}
}
}
开发者ID:EricLee1992,项目名称:gitSpace,代码行数:13,代码来源:server.php
示例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;
}
开发者ID:codeministry,项目名称:wind-ng-mc,代码行数:40,代码来源:search_suggest.php
示例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;
}
开发者ID:southern-wind,项目名称:wind,代码行数:37,代码来源:hostmaster_dnsnameservers.php
示例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;
}
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:47,代码来源:smtps.class.php
示例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 <[email protected]>
*/
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);
}
开发者ID:clickalicious,项目名称:doozr,代码行数:25,代码来源:Service.php
示例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";
}
开发者ID:rkern21,项目名称:videoeditor,代码行数:67,代码来源:recordmanagement.class.php
示例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);
}
}
开发者ID:orangeal2o3,项目名称:pukiwiki-plugin,代码行数:30,代码来源:spam.php
示例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)) : '';
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:49,代码来源:spam.php
示例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';
}
开发者ID:rust1989,项目名称:edit,代码行数:14,代码来源:fun.php
示例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 + ',';
开发者ID:rallm008,项目名称:wzz,代码行数:31,代码来源:refererlist.php
示例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;
}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:76,代码来源:SMTPs.php
示例16: address
$er .= 'Missing Certificate Password Verification "Again"<br>';
}
if ($passwd && strlen($passwd) < 8) {
$er .= 'Certificate password is too short.<br>';
}
if ($passwd and $passwd != $passwdv) {
$er .= 'Password and password verification do not match.<br>';
}
//if ( ! is_alnum($passwd) or ! is_alnum($passwdv) )
// $er .= 'Password contains invalid characters.<br>';
if ($email && !is_email($email)) {
$er .= 'E-mail address (' . htvar($email) . ') may be invalid.<br>';
}
$ip_ar = explode("\n", $ip_addr);
foreach ($ip_ar as $value) {
if ($value && !is_ip($value)) {
$er .= 'IP address (' . htvar($value) . ') may be invalid.<br>';
}
}
$dns_n = explode("\n", $dns_names);
foreach ($dns_n as $value) {
if ($value && !is_fqdn(trim($value))) {
$er .= 'DNS Name (' . htvar($value) . ') may be invalid.<br>';
}
}
if ($er) {
$er = '<h2>ERROR(S) IN FORM:</h2><h4><blockquote>' . $er . '</blockquote></h4>';
}
if ($email && ($serial = CAdb_in($email, $common_name))) {
$er = '';
$certtext = CA_cert_text($serial);
开发者ID:rhaxton,项目名称:phpki,代码行数:31,代码来源:request_cert.php
示例17: get_env
function get_env($type)
{
switch ($type) {
case 'ip':
if (DT_WIN && isset($_SERVER['REMOTE_ADDR']) && is_ip($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (strpos($ip, ',') !== false) {
$tmp = explode(',', $ip);
$ip = trim(end($tmp));
}
if (is_ip($ip)) {
return $ip;
}
}
if (!DT_WIN && isset($_SERVER['REMOTE_ADDR']) && is_ip($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
}
if (isset($_SERVER['HTTP_CLIENT_IP']) && is_ip($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
}
return 'unknown';
break;
case 'self':
return isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['ORIG_PATH_INFO']);
break;
case 'referer':
return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
break;
case 'domain':
return $_SERVER['SERVER_NAME'];
break;
case 'scheme':
return $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
break;
case 'port':
return $_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] == '443' ? '' : ':' . $_SERVER['SERVER_PORT'];
break;
case 'host':
return preg_match("/^[a-z0-9_\\-\\.]{4,}\$/i", $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
break;
case 'url':
if (isset($_SERVER['HTTP_X_REWRITE_URL']) && $_SERVER['HTTP_X_REWRITE_URL']) {
$uri = $_SERVER['HTTP_X_REWRITE_URL'];
} else {
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI']) {
$uri = $_SERVER['REQUEST_URI'];
} else {
$uri = $_SERVER['PHP_SELF'];
if (isset($_SERVER['argv'])) {
if (isset($_SERVER['argv'][0])) {
$uri .= '?' . $_SERVER['argv'][0];
}
} else {
$uri .= '?' . $_SERVER['QUERY_STRING'];
}
}
}
$uri = dhtmlspecialchars($uri);
return get_env('scheme') . $_SERVER['HTTP_HOST'] . (strpos($_SERVER['HTTP_HOST'], ':') === false ? get_env('port') : '') . $uri;
break;
case 'mobile':
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$ck = get_cookie('mobile');
$os = $browser = '';
if (preg_match("/(iphone|ipod)/", $ua)) {
$os = 'ios';
if ($ck == 'app') {
$browser = 'app';
} else {
if ($ck == 'b2b') {
$browser = 'b2b';
} else {
if ($ck == 'screen') {
$browser = 'screen';
} else {
if (preg_match("/(safari)/i", $ua)) {
$browser = 'safari';
} else {
if (preg_match("/(micromessenger\\/)/", $ua)) {
$browser = 'weixin';
} else {
if (preg_match("/(qq\\/)/", $ua)) {
$browser = 'qq';
}
}
}
}
}
}
} else {
if (preg_match("/(android)/", $ua)) {
$os = 'android';
if ($ck == 'app') {
$browser = 'app';
} else {
if ($ck == 'b2b') {
$browser = 'b2b';
//.........这里部分代码省略.........
开发者ID:hiproz,项目名称:zhaotaoci.cc,代码行数:101,代码来源:global.func.php
示例18: getMachines
/**
* Create list of machines to scan
*
* This function will query the database for the list
* of all the machines that were specified when the
* scan was created
*
* @param string $profile_id ID of the profile to get machines of
* @return array Return array of machines listed in profile
*/
public function getMachines($profile_id)
{
require_once _ABSPATH . '/lib/Devices.php';
require_once _ABSPATH . '/lib/Clusters.php';
$db = nessquikDB::getInstance();
$_dev = Devices::getInstance();
$_clu = Clusters::getInstance();
$result = array();
$sql = array('select' => "SELECT machine FROM profile_machine_list WHERE profile_id=':1';");
$stmt = $db->prepare($sql['select']);
$stmt->execute($profile_id);
while ($row = $stmt->fetch_assoc()) {
$machine = $row['machine'];
$type = $_dev->determine_device_type($machine);
/**
* Clusters are special cases because they conflict with
* hostnames by not having any special defining characters
* in them. That's one of the reasons I do the cluster
* processing here.
*
* Another is because in the settings for a specific scan
* you can add and remove devices. Well, clusters are one
* of those things you can remove and to distinctly know
* which device is a cluster, I need to retain the :clu:
* prefix on the cluster name.
*/
if ($type == "cluster") {
$machine_list = array();
foreach ($cluster as $key => $cluster_id) {
$output = array();
$output = $_clu->get_cluster($cluster_id);
foreach ($output as $key2 => $val2) {
// Index 1 is the hostname as pulled from miscomp
$hostname = $val2[1];
$tmp = array();
$tmp = $_dev->get_mac_from_system($hostname);
// The first index will hold the IP address
array_push($machine_list, $tmp[0]);
}
}
$result = array_merge($result, $machine_list);
} else {
$item = $_dev->strip_device_type($machine);
if (is_ip($item)) {
$result[] = $item;
} else {
if (is_cidr($item)) {
$result[] = $item;
} else {
if (is_vhost($item)) {
$result[] = $item;
} else {
$item = gethostbyname($item);
if ($item != '') {
$result[] = $item;
}
}
}
}
}
}
return $result;
}
开发者ID:TheProjecter,项目名称:nessquik,代码行数:73,代码来源:ScanMaker.php
示例19: exit
#if($chat_lastuser == $chatuser && $chat_repeat > 4) $chat['status'] = 1;
$josn = '{chat_status:"' . $chat['status'] . '",chat_msg:[' . $josn . '],chat_new:"' . $j . '",chat_last:"' . $chatlast . '"}';
exit($josn);
break;
case 'del':
login();
$chatid or exit;
$chat = $db->get_one("SELECT * FROM {$DT_PRE}chat WHERE chatid='{$chatid}'");
if ($chat && ($chat['touser'] == $_username || $chat['fromuser'] == $chatuser)) {
$db->query("DELETE FROM {$DT_PRE}chat WHERE chatid='{$chatid}'");
}
dmsg('删除成功', 'chat.php');
break;
case 'black':
login();
if (!is_ip($username) && !check_name($username)) {
message('未指定屏蔽对象');
}
$black = $db->get_one("SELECT black FROM {$DT_PRE}member WHERE userid={$_userid}");
$black = $black['black'];
if ($black) {
$tmp = explode(' ', trim($black));
if (in_array($username, $tmp)) {
//
} else {
$black = $black . ' ' . $username;
}
} else {
$black = $username;
}
$db->query("UPDATE {$DT_PRE}member SET black='{$black}' WHERE userid={$_userid}");
开发者ID:hcd2008,项目名称:destoon,代码行数:31,代码来源:chat.inc.php
示例20: testIsIp
public function testIsIp()
{
$this->assertTrue(is_ip('127.0.0.1'));
$this->assertTrue(is_ip('192.168.0.1'));
$this->assertTrue(is_ip('1.1.1.1'));
$this->assertFalse(is_ip('1.2.3.4.5'));
$this->assertFalse(is_ip('a.b.c.d'));
$this->assertFalse(is_ip('1,2.1,3.1,4.1,5'));
$this->assertFalse(is_ip('1000.1.1.1'));
$this->assertFalse(is_ip('256.256.256.256'));
$this->assertFalse(is_ip('256.256.256.'));
$this->assertFalse(is_ip('0.0.0'));
}
开发者ID:ejz,项目名称:core,代码行数:13,代码来源:CoreTest.php
注:本文中的is_ip函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论