function getip($GetRIP)
{
$data = "<ipquery><fields><all/></fields><ip-list><ip>" .$GetRIP. "</ip></ip-list></ipquery>" ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://194.85.91.253:8090/geo/geo.html" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_HEADER, false );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$xml = curl_exec($ch);
curl_close($ch);
//echo $xml;
$messge= "!<message>(.*?)</message>!si" ;
preg_match($messge, $xml, $main_ar[ "message" ]);
if ($main_ar[ "message" ][1]!= "Not found" )
{
$district= "!<district>(.*?)</district>!si" ;
$region= "!<region>(.*?)</region>!si" ;
$town= "!<city>(.*?)</city>!si" ;
preg_match($district, $xml, $main_ar[ "district" ]);
preg_match($region, $xml, $main_ar[ "region" ]);
preg_match($town, $xml, $main_ar[ "city" ]);
$ArMain=array( "FIND" =>1, "DISTRICT" =>$main_ar[ "district" ][1], "REGION" =>$main_ar[ "region" ][1], "TOWN" =>$main_ar[ "city" ][1]);
return $ArMain;
}
else return array( "FIND" =>0);
}
* This source code was highlighted with Source Code Highlighter .
function getip($GetRIP)
{
$data = "<ipquery><fields><all/></fields><ip-list><ip>" .$GetRIP. "</ip></ip-list></ipquery>" ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://194.85.91.253:8090/geo/geo.html" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_HEADER, false );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$xml = curl_exec($ch);
curl_close($ch);
//echo $xml;
$messge= "!<message>(.*?)</message>!si" ;
preg_match($messge, $xml, $main_ar[ "message" ]);
if ($main_ar[ "message" ][1]!= "Not found" )
{
$district= "!<district>(.*?)</district>!si" ;
$region= "!<region>(.*?)</region>!si" ;
$town= "!<city>(.*?)</city>!si" ;
preg_match($district, $xml, $main_ar[ "district" ]);
preg_match($region, $xml, $main_ar[ "region" ]);
preg_match($town, $xml, $main_ar[ "city" ]);
$ArMain=array( "FIND" =>1, "DISTRICT" =>$main_ar[ "district" ][1], "REGION" =>$main_ar[ "region" ][1], "TOWN" =>$main_ar[ "city" ][1]);
return $ArMain;
}
else return array( "FIND" =>0);
}
* This source code was highlighted with Source Code Highlighter .
function getip($GetRIP)
{
$data = "<ipquery><fields><all/></fields><ip-list><ip>" .$GetRIP. "</ip></ip-list></ipquery>" ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://194.85.91.253:8090/geo/geo.html" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_HEADER, false );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$xml = curl_exec($ch);
curl_close($ch);
//echo $xml;
$messge= "!<message>(.*?)</message>!si" ;
preg_match($messge, $xml, $main_ar[ "message" ]);
if ($main_ar[ "message" ][1]!= "Not found" )
{
$district= "!<district>(.*?)</district>!si" ;
$region= "!<region>(.*?)</region>!si" ;
$town= "!<city>(.*?)</city>!si" ;
preg_match($district, $xml, $main_ar[ "district" ]);
preg_match($region, $xml, $main_ar[ "region" ]);
preg_match($town, $xml, $main_ar[ "city" ]);
$ArMain=array( "FIND" =>1, "DISTRICT" =>$main_ar[ "district" ][1], "REGION" =>$main_ar[ "region" ][1], "TOWN" =>$main_ar[ "city" ][1]);
return $ArMain;
}
else return array( "FIND" =>0);
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/54728/
All Articles