├── tu.png ├── img └── bg.png ├── font └── msyh.ttf ├── icon ├── ico │ ├── IP.png │ ├── bro.png │ ├── time.png │ ├── local.png │ └── system.png └── weather │ ├── sha.png │ ├── wu.png │ ├── yin.png │ ├── dyun.png │ ├── rain.png │ ├── snow.png │ ├── sunny.png │ └── unknow.png ├── README.md └── index.php /tu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/tu.png -------------------------------------------------------------------------------- /img/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/img/bg.png -------------------------------------------------------------------------------- /font/msyh.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/font/msyh.ttf -------------------------------------------------------------------------------- /icon/ico/IP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/ico/IP.png -------------------------------------------------------------------------------- /icon/ico/bro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/ico/bro.png -------------------------------------------------------------------------------- /icon/ico/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/ico/time.png -------------------------------------------------------------------------------- /icon/ico/local.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/ico/local.png -------------------------------------------------------------------------------- /icon/ico/system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/ico/system.png -------------------------------------------------------------------------------- /icon/weather/sha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/sha.png -------------------------------------------------------------------------------- /icon/weather/wu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/wu.png -------------------------------------------------------------------------------- /icon/weather/yin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/yin.png -------------------------------------------------------------------------------- /icon/weather/dyun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/dyun.png -------------------------------------------------------------------------------- /icon/weather/rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/rain.png -------------------------------------------------------------------------------- /icon/weather/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/snow.png -------------------------------------------------------------------------------- /icon/weather/sunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/sunny.png -------------------------------------------------------------------------------- /icon/weather/unknow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muzihuaner/IPCard/HEAD/icon/weather/unknow.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IPCard 2 | 3 | 一款具有显示天气的IP签名档 4 | 5 | #### 演示效果 6 | 7 | ![](tu.png) 8 | 9 | #### 使用方法 10 | 11 | 把这个项目clone下来,上传到网站目录(需要PHP环境哦!) 12 | 13 | 把IP签名档添加到网站上,访客只需要打开你的网站就可以看到自己的IP,操作系统,浏览器,当地天气。 14 | 15 | 远程调用只需要将下面代码加到想显示的地方就行!比如网站侧栏/弹窗提醒等等... 16 | 17 | ```html 18 | 19 | ``` 20 | 21 | **提醒:不要套CDN,可能会导致定位不正确** -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | browser = $this->getBrowser(); 37 | // 获取系统信息 38 | $this->os = $this->getOs(); 39 | // 访问者IP 40 | $this->ip = $_SERVER["REMOTE_ADDR"]; 41 | // $this->ip = '222.216.222.168'; 42 | // 获取访问者信息 43 | $this->getAddress(); 44 | // 绘制图片 45 | $this->picInit()->setWeather()->setIcon()->setInfo(); 46 | // 47 | return $this; 48 | } 49 | 50 | /** 51 | * 设置信息 52 | */ 53 | public function setInfo() 54 | { 55 | /*基本项文字位置*/ 56 | //标语 57 | $by_text = ""; //文字标语 58 | $by_size = "12"; //文字大小 59 | $by_angle = "0"; //角度 60 | $by_x = "60"; 61 | $by_y = "45"; 62 | $by_font = $this->path . "font/msyh.ttf"; //字体位置 63 | $by_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值 64 | //自定义文字 65 | $diy_size = "20"; //文字大小 66 | $diy_angle = "0"; //角度 67 | $diy_x = "125"; 68 | $diy_y = "45"; 69 | $diy_font = $this->path . "font/msyh.ttf"; //字体位置 70 | $diy_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值 71 | //日期 72 | $time_size = "10"; //文字大小 73 | $time_angle = "0"; //角度 74 | $time_x = "167"; 75 | $time_y = "194"; 76 | $time_font = $this->path . "font/msyh.ttf"; //字体位置 77 | $time_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值 78 | //位置 79 | $local_size = "10"; //文字大小 80 | $local_angle = "0"; //角度 81 | $local_x = "165"; 82 | $local_y = "212"; 83 | $local_font = $this->path . "font/msyh.ttf"; //字体位置 84 | $local_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值 85 | //IP 86 | $ip_size = "10"; //文字大小 87 | $ip_angle = "0"; //角度 88 | $ip_x = "165"; 89 | $ip_y = "232"; 90 | $ip_font = $this->path . "font/msyh.ttf"; //字体位置 91 | $ip_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值 92 | //系统 93 | $system_size = "10"; //文字大小 94 | $system_angle = "0"; //角度 95 | $system_x = "278"; 96 | $system_y = "212"; 97 | $system_font = $this->path . "font/msyh.ttf"; //字体位置 98 | $system_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值 99 | //浏览器 100 | $bro_size = "10"; //文字大小 101 | $bro_angle = "0"; //角度 102 | $bro_x = "278"; 103 | $bro_y = "232"; 104 | $bro_font = $this->path . "font/msyh.ttf"; //字体位置 105 | $bro_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值 106 | imagettftext($this->drawIm, $time_size, $time_angle, $time_x, $time_y, $time_color, $time_font, date('Y年n月j日') . " 星期" . $this->weekarray[date("w")]); 107 | imagettftext($this->drawIm, $local_size, $local_angle, $local_x, $local_y, $local_color, $local_font, $this->province . '-' . $this->city); 108 | imagettftext($this->drawIm, $by_size, $by_angle, $by_x, $by_y, $by_color, $by_font, $by_text); //标语添加到图片 109 | $_diy = isset($_GET["diy"]) ? $_GET["diy"] : ""; 110 | imagettftext($this->drawIm, $diy_size, $diy_angle, $diy_x, $diy_y, $diy_color, $diy_font, base64_decode($_diy)); //自定义文字添加到图片 111 | imagettftext($this->drawIm, $ip_size, $ip_angle, $ip_x, $ip_y, $ip_color, $ip_font, $this->ip); //IP添加到图片 112 | imagettftext($this->drawIm, $system_size, $system_angle, $system_x, $system_y, $system_color, $system_font, $this->os); //系统添加到图片 113 | imagettftext($this->drawIm, $bro_size, $bro_angle, $bro_x, $bro_y, $bro_color, $bro_font, $this->browser); //浏览器添加到图片 114 | 115 | return $this; 116 | } 117 | 118 | /** 119 | * 初始化画布 120 | */ 121 | public function picInit() 122 | { 123 | //背景图片名称(名称.格式,如"bg.png") 124 | $dst_path = $this->path . 'img/bg.png'; 125 | //传递背景图片 126 | $this->drawIm = imagecreatefromstring(file_get_contents($dst_path)); 127 | return $this; 128 | } 129 | 130 | /** 131 | * 绘制天气部分 132 | */ 133 | public function setWeather() 134 | { 135 | /*基本图标位置*/ 136 | //天气图标位置 137 | $weather_icon_x = "65"; 138 | $weather_icon_y = "50"; 139 | //天气图标 140 | $sunny_path = $this->path . 'icon/weather/sunny.png'; 141 | $sunny_im = imagecreatefromstring(file_get_contents($sunny_path)); 142 | list($sunny_w, $sunny_h) = getimagesize($sunny_path); 143 | $rain_path = $this->path . 'icon/weather/rain.png'; 144 | $rain_im = imagecreatefromstring(file_get_contents($rain_path)); 145 | list($rain_w, $rain_h) = getimagesize($rain_path); 146 | $snow_path = $this->path . 'icon/weather/snow.png'; 147 | $snow_im = imagecreatefromstring(file_get_contents($snow_path)); 148 | list($snow_w, $snow_h) = getimagesize($snow_path); 149 | $sha_path = $this->path . 'icon/weather/sha.png'; 150 | $sha_im = imagecreatefromstring(file_get_contents($sha_path)); 151 | list($sha_w, $sha_h) = getimagesize($sha_path); 152 | $wu_path = $this->path . 'icon/weather/wu.png'; 153 | $wu_im = imagecreatefromstring(file_get_contents($wu_path)); 154 | list($wu_w, $wu_h) = getimagesize($wu_path); 155 | $yin_path = $this->path . 'icon/weather/yin.png'; 156 | $yin_im = imagecreatefromstring(file_get_contents($yin_path)); 157 | list($yin_w, $yin_h) = getimagesize($yin_path); 158 | $dyun_path = $this->path . 'icon/weather/dyun.png'; 159 | $dyun_im = imagecreatefromstring(file_get_contents($dyun_path)); 160 | list($dyun_w, $dyun_h) = getimagesize($dyun_path); 161 | $unknow_path = $this->path . 'icon/weather/unknow.png'; 162 | $unknow_im = imagecreatefromstring(file_get_contents($unknow_path)); 163 | list($unknow_w, $unknow_h) = getimagesize($unknow_path); 164 | // 判断天气 165 | if (strpos($this->weather['weather'], '晴') !== false) { 166 | imagecopy($this->drawIm, $sunny_im, $weather_icon_x, $weather_icon_y, 0, 0, $sunny_w, $sunny_h); 167 | } elseif (strpos($this->weather['weather'], '云') !== false) { 168 | imagecopy($this->drawIm, $dyun_im, $weather_icon_x, $weather_icon_y, 0, 0, $dyun_w, $dyun_h); 169 | } elseif (strpos($this->weather['weather'], '阴') !== false) { 170 | imagecopy($this->drawIm, $yin_im, $weather_icon_x, $weather_icon_y, 0, 0, $yin_w, $yin_h); 171 | } elseif (strpos($this->weather['weather'], '雾') !== false) { 172 | imagecopy($this->drawIm, $wu_im, $weather_icon_x, $weather_icon_y, 0, 0, $wu_w, $wu_h); 173 | } elseif (strpos($this->weather['weather'], '雨') !== false) { 174 | imagecopy($this->drawIm, $rain_im, $weather_icon_x, $weather_icon_y, 0, 0, $rain_w, $rain_h); 175 | } elseif (strpos($this->weather['weather'], '雪') !== false) { 176 | imagecopy($this->drawIm, $snow_im, $weather_icon_x, $weather_icon_y, 0, 0, $snow_w, $snow_h); 177 | } elseif (strpos($this->weather['weather'], '风') !== false) { 178 | imagecopy($this->drawIm, $sha_im, $weather_icon_x, $weather_icon_y, 0, 0, $sha_w, $sha_h); 179 | } else { 180 | imagecopy($this->drawIm, $unknow_im, $weather_icon_x, $weather_icon_y, 0, 0, $unknow_w, $unknow_h); 181 | } 182 | 183 | imagettftext($this->drawIm, 14, 0, 95, 140, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", $this->weather['weather']); //今天天气添加到图片 184 | imagettftext($this->drawIm, 13, 0, 160, 90, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '温度:' . $this->weather['temp'] . '℃'); //当前温度添加到图片 185 | imagettftext($this->drawIm, 13, 0, 237, 90, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '湿度:' . $this->weather['humidity'] . '%RH'); //当前湿度添加到图片 186 | imagettftext($this->drawIm, 11, 0, 160, 115, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '风向:' . $this->weather['winddirection'] . '方'); //当前风向添加到图片 187 | imagettftext($this->drawIm, 11, 0, 237, 115, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '风力级别:' . $this->weather['windpower'] . '级'); //风力级别添加到图片 188 | imagettftext($this->drawIm, 11, 0, 160, 135, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '更新时间:' . $this->weather['reporttime']); //更新时间添加到图片 189 | 190 | return $this; 191 | } 192 | 193 | /** 194 | * 绘制ICON 195 | */ 196 | public function setIcon() 197 | { 198 | //ip图标位置 199 | $ip_icon_x = "150"; 200 | $ip_icon_y = "220"; 201 | //时间图标位置 202 | $time_icon_x = "150"; 203 | $time_icon_y = "180"; 204 | //位置图标位置 205 | $local_icon_x = "150"; 206 | $local_icon_y = "200"; 207 | //系统图标位置 208 | $system_icon_x = "260"; 209 | $system_icon_y = "200"; 210 | //浏览器图标位置 211 | $bro_icon_x = "260"; 212 | $bro_icon_y = "220"; 213 | //IP等图标 214 | $ip_path = $this->path . 'icon/ico/IP.png'; 215 | $ip_im = imagecreatefromstring(file_get_contents($ip_path)); 216 | list($ip_w, $ip_h) = getimagesize($ip_path); 217 | $time_path = $this->path . 'icon/ico/time.png'; 218 | $time_im = imagecreatefromstring(file_get_contents($time_path)); 219 | list($time_w, $time_h) = getimagesize($time_path); 220 | $local_path = $this->path . 'icon/ico/local.png'; 221 | $local_im = imagecreatefromstring(file_get_contents($local_path)); 222 | list($local_w, $local_h) = getimagesize($local_path); 223 | $system_path = $this->path . 'icon/ico/system.png'; 224 | $system_im = imagecreatefromstring(file_get_contents($system_path)); 225 | list($system_w, $system_h) = getimagesize($system_path); 226 | $bro_path = $this->path . 'icon/ico/bro.png'; 227 | $bro_im = imagecreatefromstring(file_get_contents($bro_path)); 228 | list($bro_w, $bro_h) = getimagesize($bro_path); 229 | 230 | //各图标位置 231 | imagecopy($this->drawIm, $ip_im, $ip_icon_x, $ip_icon_y, 0, 0, $ip_w, $ip_h); 232 | imagecopy($this->drawIm, $time_im, $time_icon_x, $time_icon_y, 0, 0, $time_w, $time_h); 233 | imagecopy($this->drawIm, $local_im, $local_icon_x, $local_icon_y, 0, 0, $local_w, $local_h); 234 | imagecopy($this->drawIm, $system_im, $system_icon_x, $system_icon_y, 0, 0, $system_w, $system_h); 235 | imagecopy($this->drawIm, $bro_im, $bro_icon_x, $bro_icon_y, 0, 0, $bro_w, $bro_h); 236 | 237 | return $this; 238 | } 239 | 240 | 241 | 242 | /** 243 | * 合成输出图片 244 | */ 245 | public function suture() 246 | { 247 | header("Content-type: image/JPEG"); 248 | 249 | //输出 250 | imagegif($this->drawIm); 251 | imagedestroy($this->drawIm); 252 | } 253 | 254 | /** 255 | * 获取IP及城市代码 256 | */ 257 | public function getAddress() 258 | { 259 | //获取IP及城市代码 260 | $url = "http://restapi.amap.com/v3/ip?key=" . $this->key . "&ip=" . $this->ip; 261 | $UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'; 262 | $curl = curl_init(); 263 | curl_setopt($curl, CURLOPT_URL, $url); 264 | curl_setopt($curl, CURLOPT_HEADER, 0); 265 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 266 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 267 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 268 | curl_setopt($curl, CURLOPT_ENCODING, ''); 269 | curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent); 270 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 271 | $data = curl_exec($curl); 272 | $data = json_decode($data, true); 273 | $this->province = isset($data['province']) ? $data['province'] : "未知"; //省 274 | $this->city = isset($data['city']) ? $data['city'] : "未知"; //市 275 | $this->adcode = isset($data['adcode']) ? $data['adcode'] : ""; //城市代码 276 | // 不为空获取天气信息 277 | if ($this->adcode) { 278 | $this->getWeather(); 279 | } 280 | // 281 | return $this; 282 | } 283 | 284 | /** 285 | * 获取天气信息 286 | */ 287 | public function getWeather() 288 | { 289 | //获取天气信息 290 | $tqurl = "http://restapi.amap.com/v3/weather/weatherInfo?key=" . $this->key . "&city=" . $this->adcode; 291 | $UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'; 292 | $curl = curl_init(); 293 | curl_setopt($curl, CURLOPT_URL, $tqurl); 294 | curl_setopt($curl, CURLOPT_HEADER, 0); 295 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 296 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 297 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 298 | curl_setopt($curl, CURLOPT_ENCODING, ''); 299 | curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent); 300 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 301 | $weatherinfo = curl_exec($curl); 302 | $weatherinfo = json_decode($weatherinfo, true); 303 | $this->weather['weather'] = $weatherinfo['lives']['0']['weather']; //天气 304 | $this->weather['temp'] = $weatherinfo['lives']['0']['temperature']; //温度 305 | $this->weather['humidity'] = $weatherinfo['lives']['0']['humidity']; //湿度 306 | $this->weather['winddirection'] = $weatherinfo['lives']['0']['winddirection']; //风向 307 | $this->weather['windpower'] = $weatherinfo['lives']['0']['windpower']; //风力级别 308 | $this->weather['reporttime'] = $weatherinfo['lives']['0']['reporttime']; //更新时间 309 | // 310 | return $this; 311 | } 312 | 313 | /** 314 | * 获取浏览器信息 315 | */ 316 | public function getBrowser() 317 | { 318 | $ua = $_SERVER['HTTP_USER_AGENT']; //获取用户代理字符串 319 | if (preg_match('#(Camino|Chimera)[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) { 320 | $browser = 'Camino(' . $matches[2] . ')'; 321 | } elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $ua, $matches)) { 322 | $browser = '搜狗(' . $matches[1] . ')'; 323 | } elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) { 324 | $browser = '360(' . $matches[1] . ')'; 325 | } elseif (preg_match('#QQ/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 326 | $browser = 'QQ(' . $matches[1] . ')内置'; 327 | } elseif (preg_match('#Maxthon( |\/)([a-zA-Z0-9.]+)#i', $ua, $matches)) { 328 | $browser = 'Maxthon(' . $matches[2] . ')'; 329 | } elseif (preg_match('#Chrome/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 330 | $browser = 'Chrome(' . $matches[1] . ')'; 331 | } elseif (preg_match('#Safari/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 332 | $browser = 'Safari(' . $matches[1] . ')'; 333 | } elseif (preg_match('#opera mini#i', $ua)) { 334 | $browser = 'Opera Mini(' . $matches[1] . ')'; 335 | } elseif (preg_match('#Opera.([a-zA-Z0-9.]+)#i', $ua, $matches)) { 336 | $browser = 'Opera(' . $matches[1] . ')'; 337 | } elseif (preg_match('#(j2me|midp)#i', $ua)) { 338 | $browser = "J2ME/MIDP Browser"; 339 | } elseif (preg_match('/GreenBrowser/i', $ua)) { 340 | $browser = 'GreenBrowser'; 341 | } elseif (preg_match('#TencentTraveler ([a-zA-Z0-9.]+)#i', $ua, $matches)) { 342 | $browser = '腾讯TT(' . $matches[1] . ')'; 343 | } elseif (preg_match('#UCWEB([a-zA-Z0-9.]+)#i', $ua, $matches)) { 344 | $browser = 'UCWEB(' . $matches[1]; 345 | } elseif (preg_match('#MSIE ([a-zA-Z0-9.]+)#i', $ua, $matches)) { 346 | $browser = 'Internet Explorer(' . $matches[1] . ')'; 347 | } elseif (preg_match('#avantbrowser.com#i', $ua)) { 348 | $browser = 'Avant Browser'; 349 | } elseif (preg_match('#PHP#', $ua, $matches)) { 350 | $browser = 'PHP'; 351 | } elseif (preg_match('#danger hiptop#i', $ua, $matches)) { 352 | $browser = 'Danger HipTop'; 353 | } elseif (preg_match('#Shiira[/]([a-zA-Z0-9.]+)#i', $ua, $matches)) { 354 | $browser = 'Shiira(' . $matches[1] . ')'; 355 | } elseif (preg_match('#Dillo[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) { 356 | $browser = 'Dillo(' . $matches[1] . ')'; 357 | } elseif (preg_match('#Epiphany/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 358 | $browser = 'Epiphany(' . $matches[1] . ')'; 359 | } elseif (preg_match('#UP.Browser/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 360 | $browser = 'Openwave UP.Browser (' . $matches[1] . ')'; 361 | } elseif (preg_match('#DoCoMo/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 362 | $browser = 'DoCoMo(' . $matches[1] . ')'; 363 | } elseif (preg_match('#(Firefox|Phoenix|Firebird|BonEcho|GranParadiso|Minefield|Iceweasel)/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 364 | $browser = 'Firefox(' . $matches[2] . ')'; 365 | } elseif (preg_match('#(SeaMonkey)/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 366 | $browser = 'Mozilla SeaMonkey(' . $matches[2] . ')'; 367 | } elseif (preg_match('#Kazehakase/([a-zA-Z0-9.]+)#i', $ua, $matches)) { 368 | $browser = 'Kazehakase(' . $matches[1] . ')'; 369 | } else { 370 | $browser = '未知'; 371 | } 372 | return $browser; 373 | } 374 | 375 | /** 376 | * 获取系统信息 377 | */ 378 | public function getOs() 379 | { 380 | $ua = $_SERVER['HTTP_USER_AGENT']; 381 | $os = false; 382 | if (preg_match('/Windows 95/i', $ua) || preg_match('/Win95/', $ua)) { 383 | $os = "Windows 95"; 384 | } elseif (preg_match('/Windows NT 5.0/i', $ua) || preg_match('/Windows 2000/i', $ua)) { 385 | $os = "Windows 2000"; 386 | } elseif (preg_match('/Win 9x 4.90/i', $ua) || preg_match('/Windows ME/i', $ua)) { 387 | $os = "Windows ME"; 388 | } elseif (preg_match('/Windows.98/i', $ua) || preg_match('/Win98/i', $ua)) { 389 | $os = "Windows 98"; 390 | } elseif (preg_match('/Windows NT 6.0/i', $ua)) { 391 | $os = "Windows Vista"; 392 | } elseif (preg_match('/Windows NT 6.1/i', $ua)) { 393 | $os = "Windows 7"; 394 | } elseif (preg_match('/Windows NT 5.1/i', $ua)) { 395 | $os = "Windows XP"; 396 | } elseif (preg_match('/Windows NT 5.2/i', $ua) && preg_match('/Win64/i', $ua)) { 397 | $os = "Windows XP 64 bit"; 398 | } elseif (preg_match('/Windows NT 5.2/i', $ua)) { 399 | $os = "Windows Server 2003"; 400 | } elseif (preg_match('/Mac_PowerPC/i', $ua)) { 401 | $os = "Mac OS"; 402 | } elseif (preg_match('/Windows Phone/i', $ua)) { 403 | $os = "Windows Phone7"; 404 | } elseif (preg_match('/Windows NT 6.2/i', $ua)) { 405 | $os = "Windows 8"; 406 | } elseif (preg_match('/Windows NT 10.0/i', $ua)) { 407 | $os = "Windows 10"; 408 | } elseif (preg_match('/Windows NT 4.0/i', $ua) || preg_match('/WinNT4.0/i', $ua)) { 409 | $os = "Windows NT 4.0"; 410 | } elseif (preg_match('/Windows NT/i', $ua) || preg_match('/WinNT/i', $ua)) { 411 | $os = "Windows NT"; 412 | } elseif (preg_match('/Windows CE/i', $ua)) { 413 | $os = "Windows CE"; 414 | } elseif (preg_match('/ipad/i', $ua)) { 415 | if (preg_match("/(?<=CPU OS )[\d\_]{1,}/", $ua, $version)) { 416 | $ver = str_replace('_', '.', $version[0]); 417 | $os = "IOS(" . $ver . ")"; 418 | } else { 419 | $os = "IOS"; 420 | } 421 | } elseif (preg_match('/Touch/i', $ua)) { 422 | $os = "Touchw"; 423 | } elseif (preg_match('/Symbian/i', $ua) || preg_match('/SymbOS/i', $ua)) { 424 | $os = "Symbian OS"; 425 | } elseif (preg_match('/iPhone/i', $ua)) { 426 | if (preg_match("/(?<=CPU iPhone OS )[\d\_]{1,}/", $ua, $version)) { 427 | $ver = str_replace('_', '.', $version[0]); 428 | $os = "IOS(" . $ver . ")"; 429 | } else { 430 | $os = "IOS"; 431 | } 432 | } elseif (preg_match('/PalmOS/i', $ua)) { 433 | $os = "Palm OS"; 434 | } elseif (preg_match('/QtEmbedded/i', $ua)) { 435 | $os = "Qtopia"; 436 | } elseif (preg_match('/Ubuntu/i', $ua)) { 437 | $os = "Ubuntu Linux"; 438 | } elseif (preg_match('/Gentoo/i', $ua)) { 439 | $os = "Gentoo Linux"; 440 | } elseif (preg_match('/Fedora/i', $ua)) { 441 | $os = "Fedora Linux"; 442 | } elseif (preg_match('/FreeBSD/i', $ua)) { 443 | $os = "FreeBSD"; 444 | } elseif (preg_match('/NetBSD/i', $ua)) { 445 | $os = "NetBSD"; 446 | } elseif (preg_match('/OpenBSD/i', $ua)) { 447 | $os = "OpenBSD"; 448 | } elseif (preg_match('/SunOS/i', $ua)) { 449 | $os = "SunOS"; 450 | } elseif (preg_match('/linux/i', $ua)) { 451 | $os = 'Linux'; 452 | if (preg_match('/Android.([0-9. _]+)/i', $ua, $matches)) { 453 | $os = 'Android(' . $matches[1] . ')'; 454 | } elseif (preg_match('#Ubuntu#i', $ua)) { 455 | $os = 'Ubuntu'; 456 | } elseif (preg_match('#Debian#i', $ua)) { 457 | $os = 'Debian'; 458 | } elseif (preg_match('#Fedora#i', $ua)) { 459 | $os = 'Fedora'; 460 | } 461 | } elseif (preg_match('/Mac OS X/i', $ua)) { 462 | $os = "Mac OS X"; 463 | } elseif (preg_match('/Macintosh/i', $ua)) { 464 | $os = "Mac OS"; 465 | } elseif (preg_match('/Unix/i', $ua)) { 466 | $os = "Unix"; 467 | } elseif (preg_match('#Nokia([a-zA-Z0-9.]+)#i', $ua, $matches)) { 468 | $os = "Nokia" . $matches[1]; 469 | } elseif (preg_match('/Mac OS X/i', $ua)) { 470 | $os = "Mac OS X"; 471 | } else { 472 | $os = '未知'; 473 | } 474 | return $os; 475 | } 476 | } 477 | 478 | // 执行 479 | $app = new App(); 480 | 481 | if (empty($app->referopen)) { 482 | die("配置错误!"); 483 | } else if ($app->referopen == 0) { 484 | if (empty($_SERVER['HTTP_REFERER'])) { 485 | die("请勿直接访问!"); 486 | } 487 | } else if ($app->referopen == 1) { 488 | $app->init()->suture(); 489 | } else { 490 | die("未知错误!"); 491 | } 492 | --------------------------------------------------------------------------------