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


PHP check_ip函数代码示例

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


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

示例1: check_ip

 /**
  * Validates IP
  * @param string $ip
  */
 public static function check_ip($ip)
 {
     if (check_ip($ip) == 0) {
         echo 'Error validate ip';
         exit;
     }
 }
开发者ID:konkretny,项目名称:yesframework,代码行数:11,代码来源:Validator.class.php

示例2: getTotalIpChecks

 public function getTotalIpChecks()
 {
     function check_ip()
     {
         $ipaddress = 'UNKNOWN';
         if (getenv('HTTP_CLIENT_IP')) {
             $ipaddress = getenv('HTTP_CLIENT_IP');
         } else {
             if (getenv('REMOTE_ADDR')) {
                 $ipaddress = getenv('REMOTE_ADDR');
             }
         }
         return $ipaddress;
     }
     $sql_query = "CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "admin_ip_whitelist` ( " . "  `admin_ip_whitelist_id` int(11) NOT NULL AUTO_INCREMENT, " . "  `ip` varchar(15) COLLATE utf8_bin NOT NULL, " . "  PRIMARY KEY (`admin_ip_whitelist_id`), " . "  KEY `ip` (`ip`) " . ") ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ";
     $this->db->query($sql_query);
     $sql_query = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "admin_ip_whitelist` ";
     $query = $this->db->query($sql_query);
     if ((int) $query->row['total'] > 0) {
         $ip = check_ip();
         $query = $this->db->query($sql_query . " WHERE ip = '" . $ip . "'");
         return (int) $query->row['total'];
     } else {
         return 1;
     }
 }
开发者ID:heldersepu,项目名称:secure-my-admin,代码行数:26,代码来源:login.php

示例3: main

 protected function main()
 {
     if (!is_logged_in() || !check_auth('can_see_ip')) {
         redir(Nw::$lang['users']['error_cant_see_ip'], false, './');
     }
     $this->load_lang_file('admin');
     $this->set_title(Nw::$lang['users']['check_ip']);
     $this->set_tpl('membres/check_ip.html');
     $this->add_css('forms.css');
     if (!empty($_GET['ip'])) {
         inc_lib('users/check_ip');
         $list_mbr = check_ip($_GET['ip']);
         Nw::$tpl->set('SEARCH', $_GET['ip']);
         foreach ($list_mbr as $mbr) {
             Nw::$tpl->setBlock('mbr', array('ID' => $mbr['u_id'], 'PSEUDO' => $mbr['u_pseudo'], 'IDENTIFIER' => $mbr['u_identifier'], 'LAST_IP' => long2ip($mbr['u_ip']), 'GROUP' => $mbr['g_nom'], 'ID_ADMIN' => $mbr['a_admin'], 'DATE_REGISTER' => $mbr['date_register']));
         }
     } else {
         Nw::$tpl->set('SEARCH', '');
     }
     // Fil ariane
     $this->set_filAriane(array(Nw::$lang['admin']['fa_admin'] => array('admin.html'), Nw::$lang['users']['check_ip'] => array('')));
 }
开发者ID:shiooooooookun,项目名称:Nouweo_PHP,代码行数:22,代码来源:55-view_ips.php

示例4: getip

function getip($dots = 4)
{
    $ips = array();
    $indices = array('REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP');
    foreach ($indices as $index) {
        // $_SERVER is sometimes for a windows server which can't handle getenv()
        $tip = @getenv($index);
        if (!empty($tip)) {
            $ips[] = $tip;
        }
        if (!empty($_SERVER[$index])) {
            $ips[] = $_SERVER[$index];
        }
    }
    $ips = array_unique($ips);
    foreach ($ips as $ip) {
        $found = !check_ip($ip);
        if ($found == false) {
            return ext_iptrim(trim($ip), $dots);
        }
    }
    $b = _EnvValToInt('HTTP_USER_AGENT');
    $c = _EnvValToInt('HTTP_ACCEPT');
    $d = _EnvValToInt('HTTP_ACCEPT_LANGUAGE');
    $ip = "0.{$b}.{$c}.{$d}";
    return ext_iptrim($ip, $dots);
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:27,代码来源:function.global.php

示例5: getnetaddr

function getnetaddr($ip, $mask)
{
    if (check_ip($ip) && check_mask($mask)) {
        $ip = ip2long($ip);
        $mask = ip2long($mask);
        return long2ip($ip & $mask);
    } else {
        return false;
    }
}
开发者ID:pcela,项目名称:lms,代码行数:10,代码来源:common.php

示例6: array

}
$domain = $DB->GetRow('SELECT id, name, ownerid, description, master, last_check, type, notified_serial, account, mxbackup
	FROM domains WHERE id = ?', array($id));
$layout['pagetitle'] = trans('Domain Edit: $a', $domain['name']);
if (isset($_POST['domain'])) {
    $olddomain = $domain['name'];
    $oldowner = $domain['ownerid'];
    $domain = $_POST['domain'];
    $domain['name'] = trim($domain['name']);
    $domain['description'] = trim($domain['description']);
    $domain['id'] = $id;
    if ($domain['name'] == '' && $domain['description'] == '') {
        $SESSION->redirect('?' . $SESSION->get('backto'));
    }
    if ($domain['type'] == 'SLAVE') {
        if (!check_ip($domain['master'])) {
            $error['master'] = trans('IP address of master NS is required!');
        }
    } else {
        $domain['master'] = '';
    }
    if ($domain['name'] == '') {
        $error['name'] = trans('Domain name is required!');
    } elseif (!preg_match('/^[a-z0-9._-]+$/', $domain['name'])) {
        $error['name'] = trans('Domain name contains forbidden characters!');
    } elseif ($olddomain != $domain['name'] && GetDomainIdByName($domain['name'])) {
        $error['name'] = trans('Domain with specified name exists!');
    }
    if ($domain['ownerid'] && $domain['ownerid'] != $oldowner) {
        $limits = $LMS->GetHostingLimits($domain['ownerid']);
        if ($limits['domain_limit'] !== NULL) {
开发者ID:repcio,项目名称:lms,代码行数:31,代码来源:domainedit.php

示例7: while

        if ($search) {
            while ($row = @da_sql_fetch_array($search, $config)) {
                $num = 0;
                $my_nas_name = $row['nasname'];
                if ($my_nas_name != '') {
                    $nas_list[$my_nas_name]['name'] = $my_nas_name;
                    $nas_server = $da_name_cache[$my_nas_name];
                    if (!isset($nas_server)) {
                        if (!check_ip($my_nas_name)) {
                            $nas_server = @gethostbyname($my_nas_name);
                        } else {
                            $nas_server = $my_nas_name;
                        }
                        if (!isset($da_name_cache) && $config[general_use_session] == 'yes') {
                            $da_name_cache[$my_nas_name] = $nas_server;
                            session_register('da_name_cache');
                        }
                    }
                    if ($nas_server != $my_nas_name || check_ip($nas_server)) {
                        $nas_list[$my_nas_name]['ip'] = $nas_server;
                    }
                    $nas_list[$my_nas_name]['port_num'] = $row['ports'];
                    $nas_list[$my_nas_name]['community'] = $row['community'];
                    $nas_list[$my_nas_name]['model'] = $row['description'];
                }
            }
        }
    } else {
        echo "<b>Could not connect to SQL database</b><br>\n";
    }
}
开发者ID:greendev5,项目名称:freeradius-server-wasel,代码行数:31,代码来源:nas_list.php

示例8: trans

		$error['ipaddr'] = trans('Specified IP address doesn\'t overlap with any network!');
	else {
		if (empty($nodedata['netid']))
			$nodedata['netid'] = $DB->GetOne('SELECT id FROM networks WHERE INET_ATON(?) & INET_ATON(mask) = address ORDER BY id LIMIT 1',
				array($nodedata['ipaddr']));
		if (!$LMS->IsIPInNetwork($nodedata['ipaddr'], $nodedata['netid']))
			$error['ipaddr'] = trans('Specified IP address doesn\'t belong to selected network!');
		elseif (!$LMS->IsIPFree($nodedata['ipaddr'], $nodedata['netid']))
			$error['ipaddr'] = trans('Specified IP address is in use!');
		elseif($LMS->IsIPGateway($nodedata['ipaddr']))
			$error['ipaddr'] = trans('Specified IP address is network gateway!');
	}

	if($nodedata['ipaddr_pub']!='0.0.0.0' && $nodedata['ipaddr_pub']!='')
	{
		if(!check_ip($nodedata['ipaddr_pub']))
                	$error['ipaddr_pub'] = trans('Incorrect node IP address!');
        	elseif(!$LMS->IsIPValid($nodedata['ipaddr_pub']))
                	$error['ipaddr_pub'] = trans('Specified IP address doesn\'t overlap with any network!');
		elseif(!$LMS->IsIPFree($nodedata['ipaddr_pub']))
			$error['ipaddr_pub'] = trans('Specified IP address is in use!');
		elseif($LMS->IsIPGateway($nodedata['ipaddr_pub']))
			$error['ipaddr_pub'] = trans('Specified IP address is network gateway!');
	}
	else
    		$nodedata['ipaddr_pub'] = '0.0.0.0';

	$macs = array();
	foreach($nodedata['macs'] as $key => $value)
		if(check_mac($value))
		{
开发者ID:askipl,项目名称:lms,代码行数:31,代码来源:nodeadd.php

示例9: array

if (isset($_POST['set_new_sort']) and $config['allow_change_sort']) {
    $allowed_sort = array('date', 'rating', 'news_read', 'comm_num', 'title');
    $find_sort = str_replace(".", "", totranslit($_POST['set_new_sort']));
    $direction_sort = str_replace(".", "", totranslit($_POST['set_direction_sort']));
    if (in_array($_POST['dlenewssortby'], $allowed_sort) and stripos($find_sort, "dle_sort_") === 0) {
        if ($_POST['dledirection'] == "desc" or $_POST['dledirection'] == "asc") {
            $_SESSION[$find_sort] = $_POST['dlenewssortby'];
            $_SESSION[$direction_sort] = $_POST['dledirection'];
            $_SESSION['dle_no_cache'] = "1";
        }
    }
}
if ($config['allow_registration'] == "yes") {
    include_once ENGINE_DIR . '/modules/sitelogin.php';
    if (isset($banned_info['ip'])) {
        $blockip = check_ip($banned_info['ip']);
    } else {
        $blockip = false;
    }
    if ($is_logged and $member_id['banned'] == "yes" or $blockip) {
        include_once ENGINE_DIR . '/modules/banned.php';
    }
    if ($is_logged) {
        set_cookie("dle_newpm", $member_id['pm_unread'], 365);
        if ($member_id['pm_unread'] > intval($_COOKIE['dle_newpm']) and !$smartphone_detected) {
            include_once ENGINE_DIR . '/modules/pm_alert.php';
        }
    }
    if ($is_logged and $user_group[$member_id['user_group']]['time_limit']) {
        if ($member_id['time_limit'] != "" and intval($member_id['time_limit']) < $_TIME) {
            $db->query("UPDATE " . USERPREFIX . "_users set user_group='{$user_group[$member_id['user_group']]['rid']}', time_limit='' WHERE user_id='{$member_id['user_id']}'");
开发者ID:Zzepish,项目名称:IvanShikalovWebSIte,代码行数:31,代码来源:init.php

示例10: _initialize

  /**
   * 初始化验证
   */
  function _initialize() {
	if(!$_GET['nonce_str']){
	  ajaxErrReturn('随机字符串必须');
	}

	if(!$_GET['time_stamp']){
	  ajaxErrReturn('创建时间戳必须');
	}

	if(!IS_POST){
	  ajaxErrReturn('数据必须');
	}

	//判断是否内网ip
	if(!check_ip()){
	  ajaxErrReturn('非内网IP');
	}

	//3分钟有效期
	if($_REQUEST['time_stamp']+180<time()){
	  ajaxErrReturn('签名过期');
	}
	
	$model = D('Api');
	require_once(C('INTERFACE_PATH')."Cache/config.php");
	require_once(C('INTERFACE_PATH')."Cache/lib/core.function.php");
	require_once(C('INTERFACE_PATH')."Cache/lib/md5.function.php");
	require_once(C('INTERFACE_PATH')."Cache/lib/rsa.function.php");
	
	$appid = $_GET['appid'];
	$data['py_name'] = 'cache';
	$data['appid'] = $appid;
	$vo = $model->where($data)->find();
	if(!$vo){
	  ajaxErrReturn('无此应用');
	}
	$appkey = $vo['appkey'];
	//除去待签名参数数组中的空值和签名参数
	$para = $_GET;
	$para['c'] = CONTROLLER_NAME;
	$para['a'] = ACTION_NAME;
	$para_filter = CacheParaFilter($para);
	//对待签名参数数组排序
	$para_sort = CacheArgSort($para_filter);
	$prestr = CacheCreateLinkstring($para_sort);
	$timestamp = $_GET['time_stamp'];
	$sign = $_POST['sign'];
	switch ($_POST['sign_type']) {
		case 'RSA':
			$result = CacheRsaVerify($prestr, $config['public_key_path'], $sign);	
			break;
		case 'MD5':
			$result = CacheMd5Sign($appid, $appkey, $prestr, $timestamp, $sign);	
			break;
		case 2:
			$result = CacheMd5Sign($appid, $appkey, $prestr, $timestamp, $sign);	
			break;
	}	

	//dump($result);exit;
	if(!$result){
	  ajaxErrReturn('验证失败');
	}
  }
开发者ID:8yong8,项目名称:vshop,代码行数:67,代码来源:CommonController.class.php

示例11: trans

 if ($nodeipdata['ipaddr'] == '') {
     $error['ipaddr'] = trans('IP address is required!');
 } elseif (!check_ip($nodeipdata['ipaddr'])) {
     $error['ipaddr'] = trans('Incorrect IP address!');
 } elseif (!$LMS->IsIPValid($nodeipdata['ipaddr'])) {
     $error['ipaddr'] = trans('Specified address does not belongs to any network!');
 } else {
     if (empty($nodeipdata['netid'])) {
         $nodeipdata['netid'] = $DB->GetOne('SELECT id FROM networks WHERE INET_ATON(?) & INET_ATON(mask) = address ORDER BY id LIMIT 1', array($nodeipdata['ipaddr']));
     }
     if (!$LMS->IsIPFree($nodeipdata['ipaddr'], $nodeipdata['netid']) && $LMS->GetNodeIPByID($_GET['ip']) != $nodeipdata['ipaddr']) {
         $error['ipaddr'] = trans('IP address is in use!');
     }
 }
 if ($nodeipdata['ipaddr_pub'] != '0.0.0.0' && $nodeipdata['ipaddr_pub'] != '') {
     if (check_ip($nodeipdata['ipaddr_pub'])) {
         if ($LMS->IsIPValid($nodeipdata['ipaddr_pub'])) {
             $ip = $LMS->GetNodePubIPByID($nodeipdata['id']);
             if ($ip != $nodeipdata['ipaddr_pub'] && !$LMS->IsIPFree($nodeipdata['ipaddr_pub'])) {
                 $error['ipaddr_pub'] = trans('Specified IP address is in use!');
             }
         } else {
             $error['ipaddr_pub'] = trans('Specified IP address doesn\'t overlap with any network!');
         }
     } else {
         $error['ipaddr_pub'] = trans('Incorrect IP address!');
     }
 } else {
     $nodeipdata['ipaddr_pub'] = '0.0.0.0';
 }
 $macs = array();
开发者ID:krzysztofpuchala,项目名称:lms-1,代码行数:31,代码来源:netdevedit.php

示例12: elseif

<?php

$top11picks = $_POST['top11'];
$write_in_value = $_POST['write_in_value'];
$limit = 3;
if ($write_in_value) {
    $limit = $limit - 1;
}
if (empty($top11picks)) {
    echo "<div class=\"center error\">You didn't select any songs, please <a href='top11.php'>go back</a> and try again.</div>";
} elseif (count($top11picks) > $limit) {
    echo "<div class=\"center error\">You selected more than 3 songs, please <a href='top11.php'>go back</a> and select only 3 songs.</div>";
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
    //$ip = rand(0, 1000000);
    if ($by_pass_ip_check || check_ip($ip)) {
        $count = count($top11picks);
        for ($i = 0; $i < $count; $i++) {
            add_top11_plus1($top11picks[$i]);
        }
        $firstname = mysql_real_escape_string($_POST['firstname']);
        $lastname = mysql_real_escape_string($_POST['lastname']);
        $email = mysql_real_escape_string($_POST['email']);
        $phone = mysql_real_escape_string($_POST['phone']);
        $write_in_value = mysql_real_escape_string($_POST['write_in_value']);
        $contest = $_POST['contest'];
        $newsletter = $_POST['newsletter'];
        if ($write_in_value) {
            write_in($write_in_value);
        }
        if ($contest == "yes" && ($email || $phone)) {
开发者ID:ynotradio,项目名称:site,代码行数:31,代码来源:_top11_save.php

示例13: GetUserInfo

 function GetUserInfo($id)
 {
     if ($userinfo = $this->DB->GetRow('SELECT * FROM users WHERE id = ?', array($id))) {
         $this->cache['users'][$id] = $userinfo;
         if ($userinfo['id'] == $this->AUTH->id) {
             $userinfo['lastlogindate'] = $this->AUTH->last;
             $userinfo['lastloginip'] = $this->AUTH->lastip;
         }
         if ($userinfo['accessfrom']) {
             $userinfo['accessfrom'] = date('Y/m/d', $userinfo['accessfrom']);
         } else {
             $userinfo['accessfrom'] = '';
         }
         if ($userinfo['accessto']) {
             $userinfo['accessto'] = date('Y/m/d', $userinfo['accessto']);
         } else {
             $userinfo['accessot'] = '';
         }
         if ($userinfo['lastlogindate']) {
             $userinfo['lastlogin'] = date('Y/m/d H:i', $userinfo['lastlogindate']);
         } else {
             $userinfo['lastlogin'] = '-';
         }
         if ($userinfo['failedlogindate']) {
             $userinfo['faillogin'] = date('Y/m/d H:i', $userinfo['failedlogindate']);
         } else {
             $userinfo['faillogin'] = '-';
         }
         if ($userinfo['passwdlastchange']) {
             $userinfo['passwdlastchange'] = date('Y/m/d H:i', $userinfo['passwdlastchange']);
         } else {
             $userinfo['passwdlastchange'] = '-';
         }
         if (get_conf('phpui.gethostbyaddr') && check_ip($userinfo['lastloginip'])) {
             $userinfo['lastloginhost'] = gethostbyaddr($userinfo['lastloginip']);
         } else {
             $userinfo['lastloginhost'] = '-';
             $userinfo['lastloginip'] = '-';
         }
         if (get_conf('phpui.gethostbyaddr') && check_ip($userinfo['failedloginip'])) {
             $userinfo['failedloginhost'] = gethostbyaddr($userinfo['failedloginip']);
         } else {
             $userinfo['failedloginhost'] = '-';
             $userinfo['failedloginip'] = '-';
         }
     }
     return $userinfo;
 }
开发者ID:bochniak,项目名称:lms,代码行数:48,代码来源:LMS.class.php

示例14: trans

 if ($netadd['gateway'] != '') {
     if (!check_ip($netadd['gateway'])) {
         $error['gateway'] = trans('Incorrect gateway IP address!');
     } elseif (!isipin($netadd['gateway'], getnetaddr($netadd['address'], prefix2mask($netadd['prefix'])), prefix2mask($netadd['prefix']))) {
         $error['gateway'] = trans('Specified gateway address does not match with network address!');
     }
 }
 if ($netadd['dhcpstart'] != '') {
     if (!check_ip($netadd['dhcpstart'])) {
         $error['dhcpstart'] = trans('Incorrect IP address for DHCP range start!');
     } elseif (!isipin($netadd['dhcpstart'], getnetaddr($netadd['address'], prefix2mask($netadd['prefix'])), prefix2mask($netadd['prefix'])) && $netadd['address'] != '') {
         $error['dhcpstart'] = trans('IP address for DHCP range start does not match with network address!');
     }
 }
 if ($netadd['dhcpend'] != '') {
     if (!check_ip($netadd['dhcpend'])) {
         $error['dhcpend'] = trans('Incorrect IP address for DHCP range end!');
     } elseif (!isipin($netadd['dhcpend'], getnetaddr($netadd['address'], prefix2mask($netadd['prefix'])), prefix2mask($netadd['prefix'])) && $netadd['address'] != '') {
         $error['dhcpend'] = trans('IP address for DHCP range end does not match with network address!');
     }
 }
 if (!isset($error['dhcpstart']) && !isset($error['dhcpend'])) {
     if ($netadd['dhcpstart'] != '' && $netadd['dhcpend'] == '' || $netadd['dhcpstart'] == '' && $netadd['dhcpend'] != '') {
         $error['dhcpend'] = trans('Both IP addresses for DHCP range are required!');
     }
     if ($netadd['dhcpstart'] != '' && $netadd['dhcpend'] != '' && !(ip_long($netadd['dhcpend']) >= ip_long($netadd['dhcpstart']))) {
         $error['dhcpend'] = trans('End of DHCP range has to be equal or greater than start!');
     }
 }
 if (!empty($netadd['ownerid']) && !$LMS->CustomerExists($netadd['ownerid'])) {
     $error['ownerid'] = trans('Customer with the specified ID does not exist');
开发者ID:itav,项目名称:lms,代码行数:31,代码来源:netadd.php

示例15: elseif

<?php

$top11picks = $_POST['top11'];
$write_in_value = $_POST['write_in_value'];
$limit = 3;
if ($write_in_value) {
    $limit = $limit - 1;
}
if (empty($top11picks)) {
    echo "<div class=\"center error\">You didn't select any songs, please <a href='top11.php'>go back</a> and try again.</div>";
} elseif (count($top11picks) > $limit) {
    echo "<div class=\"center error\">You selected more than 3 songs, please <a href='top11.php'>go back</a> and select only 3 songs.</div>";
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
    //$ip = rand(0, 1000000);
    if ($_SERVER['HTTP_REFERER'] == "http://ynotradio.net/addtop11vote.php" || check_ip($ip) == "true") {
        $count = count($top11picks);
        for ($i = 0; $i < $count; $i++) {
            add_top11_plus1($top11picks[$i]);
        }
        $firstname = mysql_real_escape_string($_POST['firstname']);
        $lastname = mysql_real_escape_string($_POST['lastname']);
        $email = mysql_real_escape_string($_POST['email']);
        $phone = mysql_real_escape_string($_POST['phone']);
        $write_in_value = mysql_real_escape_string($_POST['write_in_value']);
        $contest = $_POST['contest'];
        $newsletter = $_POST['newsletter'];
        if ($write_in_value) {
            write_in($write_in_value);
        }
        if ($contest == "yes" && ($email || $phone)) {
开发者ID:ynotradio,项目名称:site,代码行数:31,代码来源:_top11save.php


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