<?php
$ip = $_GET['ip'];
$type = $_GET['type'];
$data = $_GET['data'];
if((!isset($ip) || ($ip == ''))) {
$ip = $_SERVER["REMOTE_ADDR"];
}
if(!filter_var($ip, FILTER_VALIDATE_IP)) {
$reinfo = array(
"status" => 0,
"msg" => 'IP格式不对'
);
echo json_encode($reinfo);
exit;
}
$addr = json_decode($addr);
$addr = $addr->address;
if($addr == null){
$addr = json_decode($addr);
$addr = $addr->address;
}
switch ( $data )
{
case 'ip':
$addr = '';
break;
case 'addr':
$ip = '';
break;
default:
$ip = $ip;
$addr = $addr;
break;
}
switch ( $type )
{
case 'text':
echo $ip." ".$addr;
break;
case 'json':
$info = array(
"status" => 1,
"ip" => $ip,
"addr" => $addr
);
echo json_encode($info);
exit;
default:
echo $ip." ".$addr."\n";
break;
}