web detect IP

Tạo file: info.txt rỗng trên host, cấp permission ghi

Sử dụng:
- Gửi link cho user qua email or chat. Nếu gửi cho nhiều user thì thêm thông tin về tên để phân biệt:
Vd host đăng ký là: http://andysoon.com, gửi link: http://andysoon.com/?x=VNDL

- Xem thông tin: http://andysoon.com/info.txt

Nếu user dùng webmail như yahoo có thể dùng Outlook gửi email, trong đó kèm thẻ:IMG vd: . User mở email sẽ tự động lấy được IP mà không cần nhấn vào link. (Cách này giống như readnotify.com dùng)

$ip=$_SERVER['REMOTE_ADDR'];

$ten = $_GET['ten'];

$today = date('d/m/Y H:i:s');


$agent = $_SERVER['HTTP_USER_AGENT'];

// initialize properties
$bd['platform'] = "Unknown";
$bd['browser'] = "Unknown";
$bd['version'] = "Unknown";


// find operating system
if (eregi("win", $agent))
$bd['platform'] = "Windows";
elseif (eregi("mac", $agent))
$bd['platform'] = "MacIntosh";
elseif (eregi("linux", $agent))
$bd['platform'] = "Linux";
elseif (eregi("OS/2", $agent))
$bd['platform'] = "OS/2";
elseif (eregi("BeOS", $agent))
$bd['platform'] = "BeOS";

// test for Opera
if (eregi("opera",$agent)){
$val = stristr($agent, "opera");
if (eregi("/", $val)){
$val = explode("/",$val);
$bd['browser'] = $val[0];
$val = explode(" ",$val[1]);
$bd['version'] = $val[0];
}else{
$val = explode(" ",stristr($val,"opera"));
$bd['browser'] = $val[0];
$bd['version'] = $val[1];
}

// test for WebTV
}elseif(eregi("webtv",$agent)){
$val = explode("/",stristr($agent,"webtv"));
$bd['browser'] = $val[0];
$bd['version'] = $val[1];

// test for MS Internet Explorer version 1
}elseif(eregi("microsoft internet explorer", $agent)){
$bd['browser'] = "MSIE";
$bd['version'] = "1.0";
$var = stristr($agent, "/");
if (ereg("308|425|426|474|0b1", $var)){
$bd['version'] = "1.5";
}

// test for NetPositive
}elseif(eregi("NetPositive", $agent)){
$val = explode("/",stristr($agent,"NetPositive"));
$bd['platform'] = "BeOS";
$bd['browser'] = $val[0];
$bd['version'] = $val[1];

// test for MS Internet Explorer
}elseif(eregi("msie",$agent) && !eregi("opera",$agent)){
$val = explode(" ",stristr($agent,"msie"));
$bd['browser'] = $val[0];
$bd['version'] = $val[1];

// test for MS Pocket Internet Explorer
}elseif(eregi("mspie",$agent) || eregi('pocket', $agent)){
$val = explode(" ",stristr($agent,"mspie"));
$bd['browser'] = "MSPIE";
$bd['platform'] = "WindowsCE";
if (eregi("mspie", $agent))
$bd['version'] = $val[1];
else {
$val = explode("/",$agent);
$bd['version'] = $val[1];
}

// test for Galeon
}elseif(eregi("galeon",$agent)){
$val = explode(" ",stristr($agent,"galeon"));
$val = explode("/",$val[0]);
$bd['browser'] = $val[0];
$bd['version'] = $val[1];

// test for Konqueror
}elseif(eregi("Konqueror",$agent)){
$val = explode(" ",stristr($agent,"Konqueror"));
$val = explode("/",$val[0]);
$bd['browser'] = $val[0];
$bd['version'] = $val[1];

// test for iCab
}elseif(eregi("icab",$agent)){
$val = explode(" ",stristr($agent,"icab"));
$bd['browser'] = $val[0];
$bd['version'] = $val[1];

// test for OmniWeb
}elseif(eregi("omniweb",$agent)){
$val = explode("/",stristr($agent,"omniweb"));
$bd['browser'] = $val[0];
$bd['version'] = $val[1];

// test for Phoenix
}elseif(eregi("Phoenix", $agent)){
$bd['browser'] = "Phoenix";
$val = explode("/", stristr($agent,"Phoenix/"));
$bd['version'] = $val[1];

// test for Firebird
}elseif(eregi("firebird", $agent)){
$bd['browser']="Firebird";
$val = stristr($agent, "Firebird");
$val = explode("/",$val);
$bd['version'] = $val[1];

// test for Firefox
}elseif(eregi("Firefox", $agent)){
$bd['browser']="Firefox";
$val = stristr($agent, "Firefox");
$val = explode("/",$val);
$bd['version'] = $val[1];

// test for Mozilla Alpha/Beta Versions
}elseif(eregi("mozilla",$agent) &&
eregi("rv:[0-9].[0-9][a-b]",$agent) && !eregi("netscape",$agent)){
$bd['browser'] = "Mozilla";
$val = explode(" ",stristr($agent,"rv:"));
eregi("rv:[0-9].[0-9][a-b]",$agent,$val);
$bd['version'] = str_replace("rv:","",$val[0]);

// test for Mozilla Stable Versions
}elseif(eregi("mozilla",$agent) &&
eregi("rv:[0-9]\.[0-9]",$agent) && !eregi("netscape",$agent)){
$bd['browser'] = "Mozilla";
$val = explode(" ",stristr($agent,"rv:"));
eregi("rv:[0-9]\.[0-9]\.[0-9]",$agent,$val);
$bd['version'] = str_replace("rv:","",$val[0]);

// test for Lynx & Amaya
}elseif(eregi("libwww", $agent)){
if (eregi("amaya", $agent)){
$val = explode("/",stristr($agent,"amaya"));
$bd['browser'] = "Amaya";
$val = explode(" ", $val[1]);
$bd['version'] = $val[0];
} else {
$val = explode("/",$agent);
$bd['browser'] = "Lynx";
$bd['version'] = $val[1];
}

// test for Safari
}elseif(eregi("safari", $agent)){
$bd['browser'] = "Safari";
$bd['version'] = "";

// remaining two tests are for Netscape
}elseif(eregi("netscape",$agent)){
$val = explode(" ",stristr($agent,"netscape"));
$val = explode("/",$val[0]);
$bd['browser'] = $val[0];
$bd['version'] = $val[1];
}elseif(eregi("mozilla",$agent) && !eregi("rv:[0-9]\.[0-9]\.[0-9]",$agent)){
$val = explode(" ",stristr($agent,"mozilla"));
$val = explode("/",$val[0]);
$bd['browser'] = "Netscape";
$bd['version'] = $val[1];
}

$HDH = $bd['platform'];
$trinhduyet=$bd['browser'];
$phienban=$bd['version'];


$f=fopen("info.txt","a");
fwrite($f,"*** Ten: $ten *** \n - Thoi gian ghi nhan: $today \n - Dia chi ip : $ip \n - He dieu hanh: $HDH \n - $trinhduyet - $phienban \n - ( User-Agent: $agent \n\n" );
fclose($f);
?>

Nhận xét

Bài đăng phổ biến từ blog này

dung lượng RAM lớn nhất mà HĐH cấu trúc 32-bit nhận được

Ký tự viết tắt trong chat & email

Ubuntu LAMP Server