Thực sự không biết đặt cái title như thế nào cả, đành đặt tạm như vậy.
Bạn thấy gì khi nhìn thấy hình bên dưới:
Highslide JS
Chắc nhiều bạn sẽ ngạc nhiên vì sao tôi có thể biết nhiều về bạn như vậy ?
nhưng thật dễ dàng làm được điều đó vì đã có PHP làm giúp chúng ta.
Bạn tạo 1 file PHP có nội dung như sau:
PHP Code:
Bạn thấy gì khi nhìn thấy hình bên dưới:
Highslide JS
Chắc nhiều bạn sẽ ngạc nhiên vì sao tôi có thể biết nhiều về bạn như vậy ?
nhưng thật dễ dàng làm được điều đó vì đã có PHP làm giúp chúng ta.
Bạn tạo 1 file PHP có nội dung như sau:
PHP Code:
Code:
<?php
header("Content-type: image/png; charset=utf-8");
$im = @imagecreatetruecolor(500, 130) or die('DB unsupport');
$background_color = imagecolorallocate($im, 0, 0, 0);
$font = "Tahoma.ttf";
$white = imagecolorallocate($im, 0, 255, 18);
$browser = new system;
imagettftext($im, 15, 0, 15, 30, $white, $font, 'IP của bạn là '.$_SERVER***91;'REMOTE_ADDR'***93;." (".date('d-m-Y H:i:s',time()+11*3600).")");
imagettftext($im, 10, 0, 15, 50, $white, $font, 'Bạn sử dụng trình duyệt '.$browser->Name.' '.$browser->Version);
imagettftext($im, 10, 0, 15, 70, $white, $font, 'Bạn đang dùng hệ điều hành '.$browser->get_os());
if ($_SERVER***91;'HTTP_REFERER'***93;)
imagettftext($im, 10, 0, 15, 90, $white, $font, 'Bạn đang xem '.$_SERVER***91;'HTTP_REFERER'***93;);
imagettftext($im, 10, 0, 330, 120, $white, $font, 'Copyleft 2010 Phongdatgl');
imagepng($im);
imagedestroy($im);
class system
{
private $props = array("Version" => "0.0.0",
"Name" => "unknown",
"Agent" => "unknown") ;
public function __Construct()
{
$browsers = array("firefox", "msie", "opera", "chrome", "safari",
"mozilla", "seamonkey", "konqueror", "netscape",
"gecko", "navigator", "mosaic", "lynx", "amaya",
"omniweb", "avant", "camino", "flock", "aol");
$this->Agent = strtolower($_SERVER***91;'HTTP_USER_AGENT'***93;);
foreach($browsers as $browser)
{
if (preg_match("#($browser)***91;/ ***93;?(***91;0-9.***93;*)#", $this->Agent, $match))
{
$this->Name = ucwords($match***91;1***93;) ;
$this->Version = $match***91;2***93; ;
break ;
}
}
}
public function __Get($name)
{
if (!array_key_exists($name, $this->props))
{
die("No such property or function $name");
}
return $this->props***91;$name***93; ;
}
public function __Set($name, $val)
{
if (!array_key_exists($name, $this->props))
{
SimpleError("No such property or function.", "Failed to set $name", $this->props) ;
die ;
}
$this->props***91;$name***93; = $val ;
}
function get_os()
{
$user_agent = $_SERVER***91;'HTTP_USER_AGENT'***93;;
$oses = array (
'Windows 3.11' => 'Win16',
'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)',
'Windows 98' => '(Windows 98)|(Win98)',
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
'Windows 2003' => '(Windows NT 5.2)',
'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
'Windows ME' => 'Windows ME',
'Open BSD'=>'OpenBSD',
'Sun OS'=>'SunOS',
'Linux'=>'(Linux)|(X11)',
'Macintosh'=>'(Mac_PowerPC)|(Macintosh)',
'QNX'=>'QNX',
'BeOS'=>'BeOS',
'OS/2'=>'OS/2',
'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)'
);
foreach($oses as $os=>$pattern)
{
if (eregi($pattern, $user_agent))
return $os;
}
return 'Unknown';
}
}
?>