kgbonme Posted July 22, 2011 Report Posted July 22, 2011 Salut,e un fisier php :<?phperror_reporting(0); $ip = getenv("REMOTE_ADDR");$adddate=date("D M d, Y g:i a"); $comment = $_POST["comment"];$comment1 = $_POST["comment1"];$fp = fopen("log.txt","a");$data = "comment: $commentcomment1: $comment1Date: $adddateIp: $ip\n";fputs($fp,$data);fclose($fp);?>vreau in loc de ip sa-mi introduca in fisierul txt State si Orasul multumesc Quote
devianc3 Posted July 22, 2011 Report Posted July 22, 2011 Cauta un script de geolocation. Vad ca ai vrea sa adaptezi tu, asa ca ai putea cauta un serviciu care ofera geolocation si un API, de genul: IP location XML API :: IPInfoDB . Quote
em Posted July 22, 2011 Report Posted July 22, 2011 Uploadoadezi scriptul ?sta pe server ?i îl folose?ti<?php $ip='94.219.40.96'; print_r(geoCheckIP($ip)); //Array ( [domain] => dslb-094-219-040-096.pools.arcor-ip.net [country] => DE - Germany [state] => Hessen [town] => Erzhausen ) //Get an array with geoip-infodata function geoCheckIP($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: (.*?) #i'; $patterns["country"] = '#Country: (.*?) #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]) ? $value[1] : 'not found'; } return $ipInfo; }?> 1 Quote
kgbonme Posted July 22, 2011 Author Report Posted July 22, 2011 am ceva de genul asta dar nu stiu cum sa introduc in fisierul txt datele extrase (state, Orasul) <?phpfunction get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len);}$ip = getenv("REMOTE_ADDR")$fullstring = file_get_contents("http://www.dnsstuff.com/tools/ipall/?tool_id=67&token=&toolhandler_redirect=0&ip=".$ip);$stat = get_string_between($fullstring, "City (per outside source): ", "Country (per outside source):");$oras = get_string_between($fullstring, "Country (per IP registrar): ", "Country Currency:");echo $stat." ".$oras; Quote
devianc3 Posted July 22, 2011 Report Posted July 22, 2011 Deci, astea doua fisiere ce le-ai pus tu, sa fie in acelasi fisier.. de exemplu:<?phpfunction get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len);}$ip = getenv("REMOTE_ADDR");$fullstring = file_get_contents("http://www.dnsstuff.com/tools/ipall/?tool_id=67&token=&toolhandler_redirect=0&ip=".$ip);$stat = get_string_between($fullstring, "City (per outside source): ", "Country (per outside source):");$oras = get_string_between($fullstring, "Country (per IP registrar): ", "Country Currency:");error_reporting(0); //$ip = getenv("REMOTE_ADDR");$adddate=date("D M d, Y g:i a"); $comment = $_POST["comment"];$comment1 = $_POST["comment1"];$fp = fopen("log.txt","a");$data = "comment: $commentcomment1: $comment1Date: $adddateIp: $ipStat: $statOras: $oras\n";fputs($fp,$data);fclose($fp);?>Teoretic ar trebui sa mearga, presupunand ca ambele scripturi isi faceau treaba si inainte. Quote
kgbonme Posted July 22, 2011 Author Report Posted July 22, 2011 imi da eroare Parse error: syntax error, unexpected T_VARIABLE in test/prb.php on line 12 Quote
ROFL Posted July 22, 2011 Report Posted July 22, 2011 Cel mai simplu mod:<?php$tags = get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress='.$_SERVER["REMOTE_ADDR"]);$x = fopen("log.txt", "a");fwrite($x, "Country: ".$tags['country']."\nCity: ".$tags['city']."\n\n");fclose($x);?> Quote
em Posted July 22, 2011 Report Posted July 22, 2011 Trebuie ; aici$ip = getenv("REMOTE_ADDR")[b];[/b] Quote
devianc3 Posted July 22, 2011 Report Posted July 22, 2011 Am editat si eu codul pus de mine anterior, multumita lui em. Poti sa il incerci din nou. Stupid ";" Quote
merlin21 Posted February 2, 2014 Report Posted February 2, 2014 poti incerca si asta, daca ai nevoie de toate fisierele lasa un PM sau pentru ceilalti daca nu fisierele pot fi gasite si pe site'ul oficial ip2location.com , curl ia adresa in baza coordonatelor de pe googlemaps!sper sa iti foloseasca!<html dir="ltr"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><?phprequire_once('IP2Location.php');// Standard lookup with no cache$loc = new IP2Location('IP2LOCATION-LITE-DB11.BIN');$x =$_GET['ip'];if (empty($x)){$ip = $_SERVER['REMOTE_ADDR'];}else{$ip = $x;}$record = $loc->lookup($ip, IP2Location::ALL);echo 'IP Address: ' . $record->ipAddress . '<br />';echo 'IP Number: ' . $record->ipNumber . '<br />';echo 'ISO Country Code: ' . $record->countryCode . '<br />';echo 'Country Name: ' . $record->countryName . '<br />';echo 'Region Name: ' . $record->regionName . '<br />';echo 'City Name: ' . $record->cityName . '<br />';echo 'Latitude & Longitude : +' . $record->latitude . ',+'. $record->longitude . '<br />';echo 'ZIP Code: ' . $record->zipCode . '<br />';echo 'Time Zone: ' . $record->timeZone . '<br />';$address = '+' . $record->latitude . ',+'. $record->longitude ;$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false";$ch22 = curl_init();curl_setopt($ch22, CURLOPT_URL, $url);curl_setopt($ch22, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch22, CURLOPT_PROXYPORT, 3128);curl_setopt($ch22, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($ch22, CURLOPT_SSL_VERIFYPEER, 0);$response = curl_exec($ch22);curl_close($ch22);$response_a = json_decode($response);echo 'FullAdress: ' . $response_a->results[0]->formatted_address . '<br />';?></html>o sa ai nevoie de urmatoarele IP2LOCATION-LITE-DB11.BINIP2Location.phpiar un result ar arata ceva de genulIP Address: 109.96.96.175IP Number: 1835032751ISO Country Code: ROCountry Name: ROMANIARegion Name: BUCURESTICity Name: BUCHARESTLatitude & Longitude : +44.4322509766,+26.1062602997ZIP Code: -Time Zone: +03:00FullAdress: Calea Mo?ilor, Bucharest, Romania Quote