Jump to content
kgbonme

Script aflare tzara state

Recommended Posts

Salut,

e un fisier php :

<?php
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: $comment
comment1: $comment1
Date: $adddate
Ip: $ip
\n";
fputs($fp,$data);
fclose($fp);
?>

vreau in loc de ip sa-mi introduca in fisierul txt State si Orasul

multumesc

Link to comment
Share on other sites

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;
}

?>

  • Downvote 1
Link to comment
Share on other sites

am ceva de genul asta dar nu stiu cum sa introduc in fisierul txt datele extrase (state, Orasul)

<?php

function 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;

Link to comment
Share on other sites

Deci, astea doua fisiere ce le-ai pus tu, sa fie in acelasi fisier.. de exemplu:


<?php
function 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: $comment
comment1: $comment1
Date: $adddate
Ip: $ip
Stat: $stat
Oras: $oras
\n";
fputs($fp,$data);
fclose($fp);
?>

Teoretic ar trebui sa mearga, presupunand ca ambele scripturi isi faceau treaba si inainte.

Link to comment
Share on other sites

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);

?>

Link to comment
Share on other sites

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>
<?php
require_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.BIN

IP2Location.php

iar un result ar arata ceva de genul


IP Address: 109.96.96.175
IP Number: 1835032751
ISO Country Code: RO
Country Name: ROMANIA
Region Name: BUCURESTI
City Name: BUCHAREST
Latitude & Longitude : +44.4322509766,+26.1062602997
ZIP Code: -
Time Zone: +03:00
FullAdress: Calea Mo?ilor, Bucharest, Romania

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...