获取用户IP的函数

 function getIp(){

$onlineip = "";

if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {

   $onlineip = getenv('HTTP_CLIENT_IP');

} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {

   $onlineip = getenv('HTTP_X_FORWARDED_FOR');

} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {

   $onlineip = getenv('REMOTE_ADDR');

} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {

   $onlineip = $_SERVER['REMOTE_ADDR'];

}

return $onlineip;

}

猜你喜欢

去除PHP及ASP特征码

2019-08-05

function phpasp2($str){if($str!=){$str=trim($str);$huanti=array(?=lt;?,?=?gt;,'=#039;);$str=strtr($str,$huanti);return $str;}}

PHP中用strpos函数过滤关键字

2019-08-01

// 关键字过滤函数function keyWordCheck($content){// 去除空白$content = trim($content);// 读取关键字文本$content = @file_get_contents('keyWords.txt');// 转换成数组$arr = explode(n, $content);// 遍

截取一定长度的完整的中文字符

2019-06-10

function cnsubstr($str,$strlen=10) {if(empty($str)||!is_numeric($strlen)){return false;}if(strlen($str)=$strlen){ return $str; }//得到第$length个字符 并判断是否为非中文 若为非中文//直接返回$lengt

字符串加密和解密

2019-02-28

function mymd5($string,$action=EN){ //字符串加密和解密global $webdb,$onlineip;//$webdb系统的一些配置信息,$onlineip 客户端ip 这个函数好像没有用到$secret_string = $webdb[mymd5].'5*j,.^;?.%#@!'; //绝密字

php验证码类

2018-10-24

//验证码class Captcha{private $width;private $height;private $codeNum;private $code;private $im;function __construct($width=80, $height=20, $codeNum=4){$this-width = $width;$this-height = $height;$thi

X
返回
顶部