<?php
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 = " 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 ";
}
$time = date("Y-m-d H:i"); $top = "Your Information:";
$line = "-----------------";
$info = iconv("GB2312","UTF-8","你好啊");
$WebInfo = "欢迎";
if(!$ip_agent){
$wenzi="IP:";
$ip_count=strlen($ip_real);
$fnt="wr.ttf";
$left=22;
$width=190;
$height=361; $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)); 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,$fnt,2,72,$info,$fontcolor2);
Imagestring($picture,2,14,84,$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);
} ?>我没多少分的,希望大家能给我讲解详细一下.我现在是一点办法都没有了...
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 = " 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 ";
}
$time = date("Y-m-d H:i"); $top = "Your Information:";
$line = "-----------------";
$info = iconv("GB2312","UTF-8","你好啊");
$WebInfo = "欢迎";
if(!$ip_agent){
$wenzi="IP:";
$ip_count=strlen($ip_real);
$fnt="wr.ttf";
$left=22;
$width=190;
$height=361; $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)); 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,$fnt,2,72,$info,$fontcolor2);
Imagestring($picture,2,14,84,$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);
} ?>我没多少分的,希望大家能给我讲解详细一下.我现在是一点办法都没有了...
=======================================================
imagettftext
(PHP 3, PHP 4, PHP 5)imagettftext -- 用 TrueType 字体向图像写入文本