传送至最新源码 PHP让图片显示IP地址信息(源码)更新显示windows8系统

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
//获取用户IP地址
function getIP(){
if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]) {
$ip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
}elseif ($HTTP_SERVER_VARS["HTTP_CLIENT_IP"]) {
$ip = $HTTP_SERVER_VARS["HTTP_CLIENT_IP"];
}elseif ($HTTP_SERVER_VARS["REMOTE_ADDR"]) {
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
}elseif (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
}elseif (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
}elseif (getenv("REMOTE_ADDR")){
$ip = getenv("REMOTE_ADDR");
} else {
$ip = "Unknown";
}
return $ip;
}
$ip=getIP();
//获取地区信息
function getAdress($a){
$url = "http://ip.chinaz.com/?IP=".$a;
$fp = @fopen($url, "r") or die("超时");
$fcontents = file_get_contents($url);
preg_match_all("/==>> d+ ==>> (.*)</strong><br />
/", $fcontents, $regs);
return $regs[1][0];
}
$adress = getAdress($ip);
//获取浏览器型号及版本号
function getBrowser() {
$sys = $_SERVER[’HTTP_USER_AGENT’]; //获取用户代理字符串
if (stripos($sys, "Firefox/") > 0) {
preg_match("/Firefox/([^;)]+)+/i", $sys, $b);
$exp[0] = "火狐浏览器";
$exp[1] = $b[1]; //获取火狐浏览器的版本号
} elseif (stripos($sys, "Maxthon") > 0) {
preg_match("/Maxthon/([d.]+)/", $sys, $aoyou);
$exp[0] = "傲游浏览器";
$exp[1] = $aoyou[1];
} elseif (stripos($sys, "MSIE") > 0) {
preg_match("/MSIEs+([^;)]+)+/i", $sys, $ie);
//$exp = "Internet Explorer ".$ie[1];
$exp[0] = "IE浏览器";
$exp[1] = $ie[1]; //获取IE的版本号
} elseif (stripos($sys, "OPR") > 0) {
preg_match("/OPR/([d.]+)/", $sys, $opera);
$exp[0] = "Opera浏览器";
$exp[1] = $opera[1]; //获取opera浏览器版本号,今天下载一个opera浏览器做测试,发现opera竟然也换成谷歌的内核了,?
}elseif (stripos($sys, "Chrome") > 0 && stripos($sys, "SE") > 0) {
$exp[0] = "搜狗浏览器";
$exp[1] = "";
}elseif (stripos($sys, "Chrome") > 0) {
preg_match("/Chrome/([d.]+)/", $sys, $google);
$exp[0] = "Chrome浏览器";
$exp[1] = $google[1]; //获取google chrome的版本号
}else {
$exp = "未知浏览器";
$exp[1] = ""; //其余的浏览器大家可以根据输出的$_SERVER[’HTTP_USER_AGENT’]信息来自行获取浏览器名称和版本号
}
return $exp;
}
$exp=getBrowser();
$browser=$exp[0];

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//获取用户操作系统信息
function getSystem(){
$sys = $_SERVER[’HTTP_USER_AGENT’];
if(stripos($sys, "NT 6.1"))
$os = "Windows 7";
elseif(stripos($sys, "NT 6.0"))
$os = "Windows Vista";
elseif(stripos($sys, "NT 5.1"))
$os = "Windows XP";
elseif(stripos($sys, "NT 5.2"))
$os = "Windows Server 2003";
elseif(stripos($sys, "NT 5"))
$os = "Windows 2000";
elseif(stripos($sys, "NT 4.9"))
$os = "Windows ME";
elseif(stripos($sys, "NT 4"))
$os = "Windows NT 4.0";
elseif(stripos($sys, "98"))
$os = "Windows 98";
elseif(stripos($sys, "95"))
$os = "Windows 95";
elseif(stripos($sys, "Mac"))
$os = "Mac";
elseif(stripos($sys, "Linux"))
$os = "Linux";
elseif(stripos($sys, "Unix"))
$os = "Unix";
elseif(stripos($sys, "FreeBSD"))
$os = "FreeBSD";
elseif(stripos($sys, "BeOS"))
$os = "BeOS";
else
$os = "未知操作系统";
return $os;
}
$system = getSystem();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//获取时间
function getShijian(){
date_default_timezone_set(’PRC’);
$week = date("D");
switch($week){
case "Mon":
$week = "星期一";break;
case "Tue":
$week = "星期二";break;
case "Wed":
$week = "星期三";break;
case "Thu":
$week = "星期四";break;
case "Fri":
$week = "星期五";break;
case "Sat":
$week = "星期六";break;
case "Sun":
$week = "星期日";break;
}
$date = date("Y年m月d日 ").$week;
return $date;
}
$date = getShijian();
//创建画布
$img = imagecreatefrompng(’bg.png’);
//设置颜色
$blue = imagecolorallocate($img,0,0,200);
$red = imagecolorallocate($img,255,0,0);
$black = imagecolorallocate($img,0,0,0);
//输出文字
imagettftext($img, 12, 0, 10, 20, $red, "simkai.ttf", "IP:".$ip." 来自:".$adress);
imagettftext($img, 12, 0, 10, 40, $red, "simkai.ttf", "你的操作系统为:".$system);
imagettftext($img, 12, 0, 10, 60, $red, "simkai.ttf", "你的浏览器为:".$exp[0].$exp[1]);
imagettftext($img, 12, 0, 10, 80, $red, "simkai.ttf", "今天是:".$date);
imagettftext($img, 12, 0, 30, 100, $blue, "simkai.ttf", "NNBBXX");
//输出图像
header("Content-type:image/png");
imagepng($img);
//销毁图像
imagedestroy($img);
?>