還有PHP顯示IP簽名圖片的代碼。
代碼如下:
& lt?頭(" Content-type:image/png ");
//註意,下面的內容沒有壹個支持中文的,除非妳用utf-8寫。
if(getenv(" HTTP _ CLIENT _ IP "){
$ IP = getenv(" HTTP _ CLIENT _ IP ");
$ip_agent = getenv("遠程_ ADDR ");
} else if(getenv(" HTTP _ X _ FORWARDED _ FOR "){
$ IP _ real = getenv(" HTTP _ X _ FORWARDED _ FOR ");
$ip_agent = getenv("遠程_ ADDR ");
}否則{
$ip_real = getenv("遠程_ ADDR ");
$ ip _ agent =
}
//以上是提取瀏覽器的真實IP。
$ User = getenv(" HTTP _ User _ AGENT ");
if(eregi("Windows[[:space:]]98 ",$User)) {
$ User _ Agent = " Windows 98
}
else if(eregi(" Win[[:space:]]9x[[:space:]]4.90 ",$User)) {
$ User _ Agent = " Windows ME
}
else if(eregi(" Windows[[:space:]]NT[[:space:]]5.0 ",getenv(" HTTP _ USER _ AGENT ")){
$ User _ Agent = " Windows 2000
}
else if(eregi(" Windows[[:space:]]NT[[:space:]]5.1 ",getenv(" HTTP _ USER _ AGENT ")){
$ User _ Agent = " Windows XP
}
else if(eregi(" Windows[[:space:]]NT[[:space:]]5.2 ",getenv(" HTTP _ USER _ AGENT ")){
$ User _ Agent = " Windows 2003
}
else if(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
}
否則{
$ User _ Agent = " Other
}
//以上是獲取瀏覽器的操作系統的信息。
if (eregi("MSIE[[:space:]]6 ",getenv(" HTTP _ USER _ AGENT ")){
$ClientInfo = "微軟IE 6.0 ";
}
elseif (eregi("MSIE[[:space:]]5 ",getenv(" HTTP _ USER _ AGENT ")){
$ClientInfo = "微軟IE 5.0 ";
}
elseif (eregi("MSIE[[:space:]]4 ",getenv(" HTTP _ USER _ AGENT ")){
$ClientInfo = "微軟IE 4.0 ";
}
elseif (eregi("Netscape ",getenv(" HTTP _ USER _ AGENT ")){
$ ClientInfo = " Netscape
}
elseif (eregi("Opera ",getenv(" HTTP _ USER _ AGENT ")){
$ ClientInfo = " Opera
}
否則{
$ ClientInfo = " Other
}
//以上是獲取瀏覽器的IE信息。
$ time = date(" Y-m-d H:I ");
//以上是獲取系統時間。如果要加壹秒的話,就寫成Y-m-d H:i:s,妳懂的英文,壹看就知道是怎麽回事了。
$top = "您的信息:";
//頂部文本
$ line = "-";
$ info = " Power:SBKCSTUDIO ";
$WebInfo = "SBKC。CHXN . COM ";
//以上兩個是版權信息。妳可以隨意改變它們。我不介意。
如果(!$ip_agent){
$文子= " IP:";
$ IP _ count = strlen($ IP _ real);
$ left = 22
$ width = 105;
//圖像寬度
$ height = 100;
//圖像高度
$picture=Imagecreate($width,$ height);
$ bgcolor = imagecolorlallocate($ picture,225,250,225);
//背景色,前225代表紅色,250代表綠色,225代表黃色【三色原理】。湊在壹起可以搭配壹個顏色。這個可以自己調整,從0到255不等。
$ border color = imagecolorlallocate($ picture,0,0,0);
//邊框顏色,原理同上
$ f($圖片,0,0,0);
//第壹種字體顏色
$ font color 2 = imagecolorlallocate($ picture,100,0,255);
//第二種字體顏色
$ font color 3 = imagecolorloculate($圖片,255,100,100);
//第三種字體顏色
$ orig img = ImageCreateFromPNG(" test . png ");
//背景圖像必須是png格式。
imagecopyrefized($ picture,$origImg,0,0,0,$width,$height,ImageSX($origImg),ImageSY($ origImg));
//將背景圖和原圖合成代碼。
Imageline($picture,0,0,$width-1,0,$ border color);
Imageline($picture,0,0,0,$height-1,$ border color);
imageline($圖片,$width-1,$height-1,$width-1,0,$ border color);
imageline($圖片,$width-1,$height-1,0,$height-1,$ border color);
//以上是邊框設置。
Imagestring($picture,2,2,0,$top,$ font color 3);
Imagestring($picture,2,2,10,$line,$ font color);
image string($圖片,2,2,20,$文子,$ font color);
Imagestring($picture,2,$left+2,20,$ip_real,$ font color);
Imagestring($picture,2,14,32,$User_Agent,$ font color);
Imagestring($picture,2,4,44,$ClientInfo,$ font color);
Imagestring($picture,2,4,54,$time,$ font color);
Imagestring($picture,2,2,62,$line,$ font color);
Imagestring($picture,2,2,72,$info,$ font color 2);
Imagestring($picture,2,14,84,$WebInfo,$ font color 2);
//以上是將文字信息寫入圖片,其中三個數字的意思是:第壹個是字號,第二個是距圖片左側的距離,第三個是距頂部的距離。
imagepng($圖片);
//合成圖像
image destroy($圖片);
//銷毀圖像流,釋放內存。
}
//以上是獲取單個IP時的代碼。
否則{
$ wenzi 1 = " IP1:";
$ wenzi 2 = " IP2:";
$ IP _ count 1 = strlen($ IP _ real);
$ IP _ count 2 = strlen($ IP _ agent);
$ left = 26
if($ IP _ count 1 & gt;= $ IP _ count 2){ $ width = $ IP _ count 1 * 6+$ left+5;} else { $ width = $ IP _ count 2 * 6+$ left+5;}
$ height = 29
$ middle = $ height/2+1;
$picture=Imagecreate($width,$ height);
$ bgcolor = imagecolorlallocate($ picture,225,250,225);
$ border color = imagecolorlallocate($ picture,0,0,0);
$ f($圖片,0,0,0);
$ font color 2 = imagecolorlallocate($ picture,100,0,255);
$ font color 3 = imagecolorloculate($圖片,255,100,100);
$ orig img = ImageCreateFromPNG(" test . png ");
imagecopyrefized($ picture,$origImg,0,0,0,$width,$height,ImageSX($origImg),ImageSY($ origImg));
Imageline($picture,0,0,$width-1,0,$ border color);
Imageline($picture,0,0,0,$height-1,$ border color);
imageline($圖片,$width-1,$height-1,$width-1,0,$ border color);
imageline($圖片,$width-1,$height-1,0,$height-1,$ border color);
imageline($圖片,$width-1,$middle-1,0,$middle-1,$ border color);
Imagestring($picture,2,2,0,$top,$ font color 3);
Imagestring($picture,2,2,10,$line,$ font color);
Imagestring($picture,2,2,20,$wenzi1,$ font color);
Imagestring($picture,2,$left+2,20,$ip_real,$ font color);
Imagestring($picture,2,2,32,$wenzi2,$ font color);
Imagestring($picture,2,$left+2,32,$ip_agent,$ font color);
Imagestring($picture,2,14,44,$User_Agent,$ font color);
Imagestring($picture,2,4,54,$ClientInfo,$ font color);
Imagestring($picture,2,4,62,$time,$ font color);
Imagestring($picture,2,2,72,$line,$ font color);
Imagestring($picture,2,2,84,$info,$ font color 2);
imagepng($圖片);
image destroy($圖片);
}
//以上代碼是針對多個IP地址的,原理和單個IP的壹樣。
& gt
妳還需要壹張test.png的背景圖片。