You are on page 1of 3

<?

php $ip = $_SERVER['REMOTE_ADDR']; $ua = $_SERVER["HTTP_USER_AGENT"]; $timestamp = time(); $zaman = gmdate("d F Y H:i:s", $timestamp); $zaman = Zaman(); $yer=yer($ip); $sonuc = "$ip : $zaman : $yer : $ua"; echo $sonuc; $veri_dosyasi = "./giren.dat"; $veriokunan = file_get_contents($veri_dosyasi, true); $veri= "$sonuc\n$veriokunan"; //$veri_dosyasi = 'ftp://animeblogspot.eu5.org:5263215@animeblogspot.eu5.org/gir en.txt'; //$c = stream_context_create(array("ftp" => array("overwrite"=>true))); //var_dump(file_put_contents("ftp://animeblogspot.eu5.org:5263215@animeblogspot. eu5.org/giren.txt", $veri, 0, $c)); file_put_contents($veri_dosyasi, $veri); function Zaman(){ date_default_timezone_set('Europe/Istanbul'); $zamann=date("d F Y l H:i:s"); return trye($zamann); } function trye($tr){ $trye=str_replace("January", "Ocak",$tr); $trye=str_replace("February", "ubat",$trye); $trye=str_replace("March", "Mart",$trye); $trye=str_replace("April", "Nisan",$trye); $trye=str_replace("May", "Mays",$trye); $trye=str_replace("June", "Haziran",$trye); $trye=str_replace("July", "Temmuz",$trye); $trye=str_replace("August", "Austos",$trye); $trye=str_replace("September", "Eyll",$trye); $trye=str_replace("October", "Ekim",$trye); $trye=str_replace("November", "Kasm",$trye); $trye=str_replace("December", "Aralk",$trye); $trye=str_replace("Monday", "Pazartesi",$trye); $trye=str_replace("Tuesday", "Sal",$trye); $trye=str_replace("Wednesday", "aramba",$trye); $trye=str_replace("Thursday", "Perembe",$trye); $trye=str_replace("Friday", "Cuma",$trye); $trye=str_replace("Saturday", "Cumartesi",$trye); $trye=str_replace("Sunday", "Pazar",$trye); return $trye; }

function yer($ip)

{ //check, if the provided ip is valid if(!filter_var($ip, FILTER_VALIDATE_IP)) { throw new InvalidArgumentException("IP is not valid"); } //contact ip-server $response=@file_get_contents('http://www.netip.de/search?query='.$ip); if (empty($response)) { throw new InvalidArgumentException("Error contacting Geo-IP-Server"); } //Array containing all regex-patterns necessary to extract ip-geoinfo from page $patterns=array(); $patterns["domain"] = '#Domain: (.*?)&nbsp;#i'; $patterns["country"] = '#Country: (.*?)&nbsp;#i'; $patterns["state"] = '#State/Region: (.*?)<br#i'; $patterns["town"] = '#City: (.*?)<br#i'; //Array where results will be stored $ipInfo=array(); //check response from ipserver for above patterns foreach ($patterns as $key => $pattern) { //store the result in array $ipInfo[$key] = preg_match($pattern,$response,$value) && !empty($value[1]) ? $va lue[1] : 'not found'; } /*I've included the substr function for Country to exclude the abbreviation (UK, US, etc..) To use the country abbreviation, simply modify the substr statement to: substr($ipInfo["country"], 0, 3) */ $ipdata = $ipInfo["town"]. ", ".substr($ipInfo["country"], 4);

return $ipdata; } ?>

You might also like