显IP签名源代码

<?Header("Content-type: image/png");
//注意以下内容都不支持中文,除非你用utf-8来写
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 = "";
}
//以上为提取浏览者的真实IP
$User = getenv("HTTP_USER_AGENT");
if(eregi("Windows[[:space:]]98",$User)) {
$User_Agent = "Windows 98";
}
elseif (eregi("Win[[:space:]]9x[[:space:]]4.90",$User)) {
$User_Agent = " Windows ME ";
}
elseif (eregi("Windows[[:space:]]NT[[:space:]]5.0",getenv("HTTP_USER_AGENT"))) {
$User_Agent = "Windows 2000";
}
elseif (eregi("Windows[[:space:]]NT[[:space:]]5.1",getenv("HTTP_USER_AGENT"))) {
$User_Agent = " Windows XP ";
}
elseif (eregi("Windows[[:space:]]NT[[:space:]]5.2",getenv("HTTP_USER_AGENT"))) {
$User_Agent = "Windows 2003";
}
elseif (eregi("Windows[[:space:]]NT",getenv("HTTP_USER_AGENT"))) {
$User_Agent = " Windows NT ";
}
elseif (eregi("unix",getenv("HTTP_USER_AGENT"))) {
$User_Agent =  "    Unix   ";
}
elseif (eregi("Linux",getenv("HTTP_USER_AGENT"))) {  
$User_Agent = "    Linux   ";
}
elseif (eregi("SunOS",getenv("HTTP_USER_AGENT"))) {   
$User_Agent = "    SunOS   ";
}
elseif (eregi("BSD",getenv("HTTP_USER_AGENT"))) {
$User_Agent = "     BSD    ";
}
else {
$User_Agent = "    Other   ";
}
//以上为获取浏览者操作系统信息
if (eregi("MSIE[[:space:]]6",getenv("HTTP_USER_AGENT"))) {
$ClientInfo = "Microsoft IE 6.0";
}
elseif (eregi("MSIE[[:space:]]5",getenv("HTTP_USER_AGENT"))) {
$ClientInfo = "Microsoft IE 5.0";
}
elseif (eregi("MSIE[[:space:]]4",getenv("HTTP_USER_AGENT"))) {
$ClientInfo = "Microsoft IE 4.0";
}
elseif (eregi("Netscape",getenv("HTTP_USER_AGENT"))) {
$ClientInfo = "     Netscape   ";
}
elseif (eregi("Opera",getenv("HTTP_USER_AGENT"))) {
$ClientInfo = "      Opera      ";
}
else {
$ClientInfo = "      Other      ";
}
//以上为获取浏览者IE信息
$time = date("Y-m-d H:i");
//以上为获取系统时间,如果要加个秒,里面的写成Y-m-d H:i:s这个你英语知道的,一看便知道怎么回事了。
$top = "Your Information:";
//顶部文字
$line = "-----------------";
$info = "Power: SBKCSTUDIO";
$WebInfo = "SBKC.CHXN.COM";
//上面两个为版权信息,随便你改,我不介意的
if(!$ip_agent){
$wenzi="IP:";
$ip_count=strlen($ip_real);
$left=22;
$width=105;
//图像宽度
$height=100;
//图像高度
$picture=Imagecreate($width,$height);
$bgcolor=ImageColorAllocate($picture,225,250,225);
//背景颜色,第一个225表示的是红色,250代表绿色,225代表黄色[三色原理],弄在一起就搭配出一种颜色来,这个可以自己调,范围0-255
$bordercolor=ImageColorAllocate($picture,0,0,0);
//边框颜色,原理同上
$fontcolor=ImageColorAllocate($picture,0,0,0);
//第一种字体颜色
$fontcolor2=ImageColorAllocate($picture,100,0,255);
//第二种字体颜色
$fontcolor3=ImageColorAllocate($picture,255,100,100);
//第三种字体颜色
$origImg = ImageCreateFromPNG("test.png");
//背景图像,要求必须用png格式。
ImageCopyResized($picture,$origImg,0,0,0,0,$width,$height,ImageSX($origImg),ImageSY($origImg));
//将背景图像和原图片合成代码
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,$top,$fontcolor3);
Imagestring($picture,2,2,10,$line,$fontcolor);
Imagestring($picture,2,2,20,$wenzi,$fontcolor);
Imagestring($picture,2,$left+2,20,$ip_real,$fontcolor);
Imagestring($picture,2,14,32,$User_Agent,$fontcolor);
Imagestring($picture,2,4,44,$ClientInfo,$fontcolor);
Imagestring($picture,2,4,54,$time,$fontcolor);
Imagestring($picture,2,2,62,$line,$fontcolor);
Imagestring($picture,2,2,72,$info,$fontcolor2);
Imagestring($picture,2,14,84,$WebInfo,$fontcolor2);
//以上是将文字信息写到图片中去,其中的三个数字的含义为:第一个为字体大小,第二个为离图像左边的距离,第三个为离顶部的距离。
Imagepng($picture);
//合成图像
ImageDestroy($picture);
//破坏图像流,释放内存
}
//以上为获取单个IP时的代码
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);
$fontcolor2=ImageColorAllocate($picture,100,0,255);
$fontcolor3=ImageColorAllocate($picture,255,100,100);
$origImg = ImageCreateFromPNG("test.png");
ImageCopyResized($picture,$origImg,0,0,0,0,$width,$height,ImageSX($origImg),ImageSY($origImg));
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,$top,$fontcolor3);
Imagestring($picture,2,2,10,$line,$fontcolor);  
Imagestring($picture,2,2,20,$wenzi1,$fontcolor);
Imagestring($picture,2,$left+2,20,$ip_real,$fontcolor);
Imagestring($picture,2,2,32,$wenzi2,$fontcolor);
Imagestring($picture,2,$left+2,32,$ip_agent,$fontcolor);
Imagestring($picture,2,14,44,$User_Agent,$fontcolor);
Imagestring($picture,2,4,54,$ClientInfo,$fontcolor);
Imagestring($picture,2,4,62,$time,$fontcolor);
Imagestring($picture,2,2,72,$line,$fontcolor);
Imagestring($picture,2,2,84,$info,$fontcolor2);
Imagepng($picture);
ImageDestroy($picture);
}
//以上为多个IP地址的代码,原理同单个IP的
>

还需要一个test.png的背景图片

你可能感兴趣的:(职场,休闲,显IP签名源代码)