このイベントは私を非常に幸せにしました。そのようなリソースでこのようなサービスがあり、遊び心のあるペンがすぐに消えてくれることを願っています!
文字通り10分後、最も単純なIPリクエストコードが用意されましたが、議論の中で次のようになりました(curlで行われました):
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 .
コードで提示されたリクエストの結果:
コードによると、2、3語で、以下を返します。
- 「目的のIPが属する都市」、
- 「目的のIPが属する地域」、
- 「目的のIPが属するロシア連邦の連邦地区。」