D.C.資訊交流網-[綜合論壇]-關閉註冊's Archiver

mymy 發表於 2008-11-27 20:19

讓你的簽名再次個性化

到了這個論壇還沒有發個帖子,第一次希望大家支持。
網上的很多顯示浏覽者ip、系統、浏覽器的圖片,但是都是別人的,想自己做嗎?看看下面的吧
將下面的代碼存為*.php,然後在同一個文件內放一個自己做好的mymy.png(名字可以自己改,但是需要把有一行的名字也改過來)的圖片就行了

<?  
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 = "";  
}
$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 = "  Sorry !   Your System is unclear !   ";
}
if (eregi("MSIE[[:space:]]8",getenv("HTTP_USER_AGENT"))) {
$ClientInfo = "Microsoft IE 8.0";
}
elseif (eregi("MSIE[[:space:]]7",getenv("HTTP_USER_AGENT"))) {
$ClientInfo = "Microsoft IE 7.0";
}
elseif (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 = " ^_^ Your Browser is unclear !    ";
}
$time = date("Y-m-d H+8:i+25");
$top = " Your Information:";
$line = "-----------------";
$info = "    BY: mymy";
$WebInfo = "    welcome to myhome";   //和上面的功能一樣
if(!$ip_agent){  
$wenzi="IP:";  
$ip_count=strlen($ip_real);  
$left=22;  
$width=540;  
//图像宽度
$height=160;  
//图像高度
$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("mymy.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,5,14,0,$top,$fontcolor3);
Imagestring($picture,5,14,8,$line,$fontcolor);
Imagestring($picture,5,14,20,$wenzi,$fontcolor);  
Imagestring($picture,5,14,35,$ip_real,$fontcolor);
Imagestring($picture,5,14,50,$User_Agent,$fontcolor);
Imagestring($picture,5,14,65,$ClientInfo,$fontcolor);
Imagestring($picture,5,14,80,$time,$fontcolor);  
Imagestring($picture,5,14,95,$line,$fontcolor);
Imagestring($picture,5,14,110,$info,$fontcolor2);
Imagestring($picture,5,14,125,$WebInfo,$fontcolor2);
//以上是将文字信息写到图片中去,其中的三个数字的含义为:第一个为字体大小,第二个为离图像左边的距离,第三个为离顶部的距离。
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);
$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);  
}  
?>

[[i] 本帖最後由 mymy 於 2008-11-27 20:25 編輯 [/i]]

leo5566 發表於 2009-10-26 03:04

學會了,謝謝啦。應該推廣應用。

6551417 發表於 2009-11-10 15:51

说的还不够清楚,我是门外汉。

tonyton 發表於 2010-2-20 10:45

我就下載來用看看了,真是謝謝大大的不吝分享!

xifangczy 發表於 2010-4-25 02:48

銋憭if else 憭芷獄 喲桀
嗅究witch賣 銝甇銵刻噢撘銋銝擃

mm9832 發表於 2011-3-14 11:45

看不懂,不明白

soczl 發表於 2011-5-14 22:21

就是拷贝代码贴进去就行了,,
不是很难啊。

xifangczy 發表於 2011-6-13 21:04

餈銝芸∪刻皞

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.