显示ip图片签名档

在Unix众多版友的帮助下终于搞出来一个显示ip、地理位置和系统的图片签名档了。物理地址用的是Lucian的校内在线ip库:)
我的平台:WinXP+apache2.1+PHP5(With GD2 Support)
qmd.php(测试完成后更名为qmd.png)的源码:
<?php
function getIP()
{
global $ip;
if (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else $ip = "Unknow";
return $ip;
}
function show_system(){
$so = $_SERVER[‘HTTP_USER_AGENT’];
$windowsxp = preg_match("/windows nt 5.1/i", $so);
$windowsxp2 = preg_match("/windows xp/i", $so);
$linux = preg_match("/linux/i", $so);
$windowsme = preg_match("/win 9x 4.90/i", $so);
$windowsme2 = preg_match("/windows me/i", $so);
$windows2k = preg_match("/windows nt 5.0/i", $so);
$windows2kb = preg_match("/windows 2000/i", $so);
$windowsnt = preg_match("/windows nt 3.1/i", $so);
$windowsnt2 = preg_match("/windows nt 3.5.0/i", $so);
$windowsnt3 = preg_match("/windows nt 3.5.1/i", $so);
$windowsnt4 = preg_match("/windows nt 4.0/i", $so);
$windows98 = preg_match("/windows 98/i", $so);
$windows95 = preg_match("/windows 95/i", $so);
if ($windowsxp == 1 or $windowsxp2 == 1) {
$sys = "Windows XP。推荐试试看Linux吧:)";
} else if ($linux == 1) {
$sys = "Linux,哇赞!你用的是什么发行版啊?";
} else if ($windowsme == 1 or $windowsme2 == 1) {
$sys = "Windows ME";
} else if ($windows2k == 1 or $windows2kb == 1) {
$sys = "Windows 2000";
} else if ($windowsnt == 1 or $windowsnt2 == 1 or $windowsnt3 == 1 or $windowsnt4 == 1) {
$sys = "Windows NT";
} else if ($windows98 == 1 and $windowsme != 1) {
$sys = "Windos 98?不会吧……";
} else if ($windows95 == 1) {
$sys = "Windos 95……无语了……";
} else {
$sys = "BBS Term?";
}
return($sys);
}
function show_browser(){
$b = $_SERVER[‘HTTP_USER_AGENT’];
$ie50 = preg_match("/MSIE 5.0/i", $b);
$ie55 = preg_match("/MSIE 5.5/i", $b);
$ie60 = preg_match("/MSIE 6.0/i", $b);
$opera = preg_match("/opera/i", $b);
if ($ie40 == 1) {
$browser = "微软的IE4.0";
} else if ($ie50 == 1) {
$browser = "微软的IE5.0";
} else if ($ie55 == 1) {
$browser = "微软的IE5.5";
} else if ($ie60 == 1) {
$browser = "微软的IE6.0";
} else if ($opera == 1) {
$browser = "Opera";
} else {
$browser = "FireFox或者其他浏览器,要么是BBS Term?";
}
return($browser);
}
$system = show_system();
$browser = show_browser();
$filename = ‘http://10.64.130.19:8717/?ip=’.getIP();
$file = file($filename);
$content = join("", $file);
$im = @imagecreatefrompng ("logo.png");
$black = imagecolorallocate ($im, 0, 0, 0);
$font = ‘/simsun.ttc’;
ImageTTFText ($im,12,0,0,20,$black,$font,iconv("GB2312","UTF-8",你好,我是hahaboy。你是谁呢?让我猜猜看——));
ImageTTFText ($im,12,0,0,40,$black,$font,iconv("GB2312","UTF-8",你的ip是.$ip));
ImageTTFText ($im,12,0,0,60,$black,$font,iconv("GB2312","UTF-8",那么就是说你现在的位置是:));
ImageTTFText ($im,12,0,0,80,$black,$font,iconv("GB2312","UTF-8",$content));
ImageTTFText ($im,12,0,0,100,$black,$font,iconv("GB2312","UTF-8",嗯,我一定会来tk的,娃哈哈));
ImageTTFText ($im,12,0,0,130,$black,$font,iconv("GB2312","UTF-8",让我看看还能发现什么东西,嘻嘻));
ImageTTFText ($im,12,0,0,150,$black,$font,iconv("GB2312","UTF-8",先看看你的操作系统……));
ImageTTFText ($im,12,0,0,170,$black,$font,iconv("GB2312","UTF-8",噢,原来是.$system));
ImageTTFText ($im,12,0,0,190,$black,$font,iconv("GB2312","UTF-8",你用的浏览器是.$browser));
ImageTTFText ($im,12,0,0,210,$black,$font,iconv("GB2312","UTF-8",很神奇吧,哈哈));
ImageTTFText ($im,12,0,0,270,$black,$font,iconv("GB2312","UTF-8",好了,今先到这里吧,有空来我FTP看看哦));
ImageTTFText ($im,12,0,0,290,$black,$font,iconv("GB2312","UTF-8",地址是.’10.85.52.222′));
ImageTTFText ($im,12,0,0,310,$black,$font,iconv("GB2312","UTF-8",看上什么尽管拿吧,哈哈));
header ("Content-type: image/png");
imagepng ($im);
imagedestroy ($im);
?>
.htaccess的源码:
<FilesMatch "\.(png)$">
ForceType application/x-httpd-php
</FilesMatch>