Home  >  Article  >  Backend Development  >  IP signature probe_PHP tutorial

IP signature probe_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:08:411392browse


可以用做签名,论坛头像

PHP代码:--------------------------------------------------------------------------------
/*****************************************************
Canfeng made an IP signature probe---stormor@163.com
If there is any incorrect display, please send me an email for correction!
**************************************************** ******/
Header("Content-type: image/png");

if(getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
$ip_agent = getenv("REMOTE_ADDR");
} elseif(getenv("HTTP_X_FORWARDED_FOR")) {
$ip_real = getenv("HTTP_X_FORWARDED_FOR");
$ip_agent = getenv("REMOTE_ADDR");
} else {
$ip_real = getenv("REMOTE_ADDR");
$ip_agent = "";
}

if(!$ip_agent){
$wenzi="IP:";
$ip_count=strlen($ip_real);
$left=22;
$width=$ip_count*6+$left+5;
$height=14;
$picture=Imagecreate($width,$height);
$bgcolor=ImageColorAllocate($picture,225,250,225);
$bordercolor=ImageColorAllocate($picture,0,0,0);
$fontcolor=ImageColorAllocate($picture,0,0,0);
Imageline($picture,0,0,$width-1,0,$bordercolor);
Imageline($picture,0,0,0,$height-1,$bordercolor);
Imageline($picture,$width-1,$height-1,$width-1,0,$bordercolor);
Imageline($picture,$width-1,$height-1,0,$height-1,$bordercolor);
Imagestring($picture,2,2,0,$wenzi,$fontcolor);
Imagestring($picture,2,$left+2,0,$ip_real,$fontcolor);
Imagepng($picture);
ImageDestroy($picture);
}else{
$wenzi1="IP1:";
$wenzi2="IP2:";
$ip_count1=strlen($ip_real);
$ip_count2=strlen($ip_agent);
$left=26;
if($ip_count1>=$ip_count2){$width=$ip_count1*6+$left+5;}else{$width=$ip_count2*6+$left+5;}
$height=29;
$middle=$height/2+1;
$picture=Imagecreate($width,$height);
$bgcolor=ImageColorAllocate($picture,225,250,225);
$bordercolor=ImageColorAllocate($picture,0,0,0);
$fontcolor=ImageColorAllocate($picture,0,0,0);
Imageline($picture,0,0,$width-1,0,$bordercolor);
Imageline($picture,0,0,0,$height-1,$bordercolor);
Imageline($picture,$width-1,$height-1,$width-1,0,$bordercolor);
Imageline($picture,$width-1,$height-1,0,$height-1,$bordercolor);
Imageline($picture,$width-1,$middle-1,0,$middle-1,$bordercolor);
Imagestring($picture,2,2,0,$wenzi1,$fontcolor);
Imagestring($picture,2,$left+2,0,$ip_real,$fontcolor);
Imagestring($picture,2,2,$middle,$wenzi2,$fontcolor);
Imagestring($picture,2,$left+2,$middle,$ip_agent,$fontcolor);
Imagepng($picture);
ImageDestroy($picture);
}

?>

--------------------------------------------------------------------------------

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/314703.htmlTechArticle可以用做签名,论坛头像 PHP代码:-------------------------------------------------------------------------------- ?php /***************************************************...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn