private function _phonecity($phone){
$url = 'http://mobsec-dianhua.baidu.com/dianhua_api/open/location?tel='.$phone;
$res = $this->_request($url, []);
$tmp = json_decode($res, true);
$city = $tmp['response'][$phone]['location'];
return $city;
}
private function _ipcity($ip){
$url = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$ip;
$res = $this->_request($url, []);
$tmp = json_decode($res, true);
$ip = $tmp['data']['region'].'-'.$tmp['data']['city'];
return $ip;
}
private function _search_word_from() {
$referer = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'';
if(strstr( $referer, 'baidu.com')){
preg_match( "|baidu.+word=([^\\&]*)|is", $referer, $tmp );
$keyword = urldecode( $tmp[1] );
$from = '百度';
}elseif(strstr( $referer, 'google.com') or strstr( $referer, 'google.cn')){ //谷歌
preg_match( "|google.+q=([^\\&]*)|is", $referer, $tmp );
$keyword = urldecode( $tmp[1] );
$from = '谷歌';
}elseif(strstr( $referer, 'so.com')){
preg_match( "|so.+q=([^\\&]*)|is", $referer, $tmp );
$keyword = urldecode( $tmp[1] );
$from = '360';
}elseif(strstr( $referer, 'sogou.com')){
preg_match( "|sogou.com.+query=([^\\&]*)|is", $referer, $tmp );
$keyword = urldecode( $tmp[1] );
$from = '搜狗';
}elseif(strstr( $referer, 'soso.com')){
preg_match( "|soso.com.+w=([^\\&]*)|is", $referer, $tmp );
$keyword = urldecode( $tmp[1] );
$from = '搜搜';
}else {
$keyword ='';
$from = '';
}
return $keyword.'-'.$from;
}
private function _getip(){
$ip=false;
if(!empty($_SERVER["HTTP_CLIENT_IP"])){
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
for ($i = 0; $i < count($ips); $i++) {
if (!eregi ("^(10│172.16│192.168).", $ips[$i])) {
$ip = $ips[$i];
break;
}
}
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
private function _request($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
return $response;
}