PHP obtains the browser's IP address, the operating system where the browser IP is located, and the picture output. You can visit http://www.pc811.com/ip/i.php to view the demonstration effect. Requires windows font package. The font package is placed in the directory.
- header("Content-type: image/png");/*State that this is a picture*/
- $width=350;/*Picture length*/
- $height=120; /*Image height*/
- //$_GET["editname"]
- $size=11;/*Font size*/
- $angle=0;/*Rotation degree*/
- $font = "simhei.ttf"; /*Set font*/
- $useragent=$useragent=$_SERVER['HTTP_USER_AGENT'];
- $signature=$_GET["signature"];//Parameters passed from URL
- /*Set image attributes*/
- $ im = imagecreatetruecolor($width, $height);
- /*$im = imagecreatefromjpeg("logo.png");*/
- $white = imagecolorallocate($im, 255, 255, 255);/*Background color* /
- $grey = imagecolorallocate($im, 255, 0, 0);/*Font color*/
- $black = imagecolorallocate($im, 0, 0, 0);
- /*Get the client IP address and location Region*/
- function address($ip) {
- $info = json_decode(file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip='.$ip.'&format= json'), false);
- if ($info ->ret == 1) {
- if ($info ->province != $info ->city) {
- return $info ->country." ,".$info ->province."(".$info ->city.") ".$info ->district." ".$info ->desc;
- } else {
- return $info ->country.",".$info ->province." ".$info ->district." ".$info ->desc;
- }
- } else {
- return 'Earth';
- }
- }
- /*Get the client browser version*/
- function browser($ua) {
- if (stripos($ua, "Googlebot")) {
- $browser = "Google Spider";
- }
- elseif(stripos ($ua, "Baiduspider") !== false) {
- $browser = "Baiduspider";
- }
- elseif(stripos($ua, "Yahoo!") !== false) {
- $browser = "Yahoo Spider";
- }
- elseif(stripos($ua, "bingbot")) {
- $browser = "Bing Spider";
- }
- elseif(stripos($ua, "YRSpider")) {
- $browser = " Yunnan Spider";
- }
- elseif(stripos($ua, "Yeti") !== false) {
- $browser = "Naver Spider";
- }
- elseif(stripos($ua, "Maxthon")) {
- if (stripos($ua, "AppleWebKit")) {
- $browser = "訨游 browser (speed mode)";
- }
- elseif(stripos($ua, "Trident")) {
- $browser = "訨游 browser Browser (compatibility mode)";
- }
- elseif(stripos($ua, "MAXTHON 2.0")) {
- $browser = "MAXTHON 2.0";
- }
- }
- elseif(stripos($ua, "Firefox ")) {
- $browser = "Firefox";
- }
- elseif(stripos($ua, "Opera") == 0 && stripos($ua, "Presto")) {
- $browser = "Opera" ;
- }
- elseif(stripos($ua, "BIDUBrowser")) {
- if (stripos($ua, "Trident")) {
- $browser = "Baidu Browser (compatibility mode)";
- }
- elseif( stripos($ua, "AppleWebKit")) {
- $browser = "Baidu Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "Ruibin")) {
- $browser = "Ruiying Browser";
- }
- elseif(stripos($ua, "qihu theworld")) {
- if (stripos($ua, "Trident")) {
- $browser = "World Window Browser";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "World Window Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "MetaSr")) {
- if ( stripos($ua, "Trident")) {
- $browser = "Sogou high-speed browser (compatibility mode)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "Sogou high-speed browser (Extreme speed mode)";
- }
- }
- elseif(stripos($ua, "LBBROWSER")) {
- if (stripos($ua, "Trident")) {
- $browser = "Cheetah Browser (compatibility mode) )";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "Cheetah Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "YLMFBR")) {
- $browser = "115 browser";
- }
- elseif(stripos($ua, "QQBrowser")) {
- if (stripos($ua, "Trident")) {
- $browser = "QQ Browser( Compatibility mode)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "QQ Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "TencentTraveler")) {
- $browser = "Tencent TT Browser";
- }
- elseif(stripos($ua, "TaoBrowser")) {
- if (stripos($ua, "Trident")) {
- $browser = "Taobao Browser (compatibility mode)" ;
- }
- elseif(stripos($ua, "AppleWebkit")) {
- $browser = "Taobao Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "CoolNovo")) {
- $browser = "Maple Browser";
- }
- elseif(stripos($ua, "SaaYaa")) {
- $browser = "Flash Browser";
- }
- elseif(stripos($ua, "360SE" )) {
- $browser = "360 Safe Browser";
- }
- elseif(stripos($ua, "360EE")) {
- if (stripos($ua, "Trident")) {
- $browser = "360 Extremely fast browser (compatibility mode)";
- }
- elseif(stripos($ua, "AppleWebkit")) {
- $browser = "360 extremely fast browser (extremely fast mode)";
- }
- }
- elseif(stripos($ ua, "Konqueror")) {
- $browser = "Konqueror";
- }
- elseif(stripos($ua, "Chrome")) {
- $browser = "Google Chrome";
- }
- elseif(stripos($ ua, "Safari")) {
- $browser = "Safari";
- }
- elseif(stripos($ua, "MSIE")) {
- $ver = explode(";", substr($ua, stripos($ ua, "MSIE") + 5, 4));
- $ver = $ver[0];
- $browser = "IE ".$ver;
- }
- elseif(stripos($ua, "UCWEB")) {
- $browser = "UCWEB Browser";
- }
- elseif(stripos($ua, "WAP")) {
- $browser = "Mobile Browser";
- } else {
- $browser = $ua;
- }
- if ($browser == '') $browser = $ua;
- return $browser;
- }
- /*Get operating system version*/
- function os($ua) {
- $os = "";
- if (stripos ($ua, "Googlebot")) {
- $os = "Google Spider";
- }
- elseif(stripos($ua, "Baiduspider") !== false) {
- $os = "Baiduspider";
- }
- elseif(stripos($ua, "Yahoo!") !== false) {
- $os = "Yahoo Spider";
- }
- elseif(stripos($ua, "bingbot")) {
- $os = "must Ying Spider";
- }
- elseif(stripos($ua, "YRSpider")) {
- $os = "YRSpider";
- }
- elseif(stripos($ua, "Yeti") !== false) {
- $os = "Naver Spider";
- }
- elseif(stripos($ua, "Windows NT")) {
- switch (substr($ua, stripos($ua, "Windows NT") + 11, 3)) {
- case 5.0:
- {
- $os = "Windows 2000";
- break;
- }
- case 5.1:
- {
- $os = "Windows XP";
- break;
- }
- case 5.2:
- {
- $os = "Windows 2003";
- break;
- }
- case 6.0:
- {
- $os = "Windows Vista/2008";
- break;
- }
- case 6.1:
- {
- $os = "Windows 7";
- break ;
- }
- case 6.2:
- {
- $os = "Windows 8";
- break;
- }
- default:
- {
- $os = "Windows";
- break;
- }
- }
- if (stripos($ua , "WOW64")) {
- $os.= "(X64)";
- } else {
- $os.= "(X86)";
- }
- }
- elseif(stripos($ua, "Android")) {
- $os = substr($ua, stripos($ua, "Android"), 11);
- }
- elseif(stripos($ua, "Linux")) {
- if (stripos($ua, "i686" )) {
- $os = "Linux X86";
- } else {
- $os = "Linux";
- }
- if (stripos($ua, "X11")) {
- $os.= "(X Window) ";
- }
- }
- elseif(stripos($ua, "Macintosh")) {
- $os = "Mac";
- }
- elseif(stripos($ua, "IOS")) {
- $os = "iOS ";
- }
- elseif(stripos($ua, "ZTE")) {
- $os = "ZTE";
- }
- elseif(stripos($ua, "Windows 98")) {
- $os = "Windows 98 ";
- }else {
- $os = "Unknown system";
- }
- return $os;
- }
-
- imagettftext($im, $size, $angle, 10, 15, $grey, $font, "Current address:".address ($_SERVER['REMOTE_ADDR']));
- imagettftext($im, $size, $angle, 10, 35, $grey, $font, "Current IP:".$_SERVER['REMOTE_ADDR']);
- imagettftext ($im, $size, $angle, 10, 55, $grey, $font, "Current browser:".browser($useragent));
- imagettftext($im, $size, $angle, 10, 75, $grey, $font, "Current operating system:".os($useragent));
- imagettftext($im, $size, $angle, 10, 95, $grey, $font, $signature!=""?$ signature: " Computer Mutual Aid Network www.pc811.com");
-
-
- imagepng($im);
- imagedestroy($im);
- ?>
Copy code
|