<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; class LBSUtil { public static function distance($f0Fdi, $YWJM1, $XMNqR, $lP8PA) { goto R7vWS; PSg33: $URN1T = deg2rad($XMNqR); goto ytVfE; gbWpw: $xOl7n = pow(sin($DlRbG / 2), 2) + cos($TRWPr) * cos($pQCqc) * pow(sin($cqRw2 / 2), 2); goto Q2K4n; VKAau: $cqRw2 = abs($Yz0P3 - $URN1T); goto gbWpw; wtcck: $DlRbG = abs($TRWPr - $pQCqc); goto VKAau; CCWxo: $pQCqc = deg2rad($lP8PA); goto wtcck; dWpxD: $Yz0P3 = deg2rad($f0Fdi); goto PSg33; ytVfE: $TRWPr = deg2rad($YWJM1); goto CCWxo; R7vWS: $i9GpY = 6378137; goto dWpxD; Q2K4n: return intval($i9GpY * 2 * asin(sqrt($xOl7n)) + 0.5); goto j0ux6; j0ux6: } public static function formatDistance($R1KlN) { if ($R1KlN > 1000) { return round($R1KlN / 1000.0, 1) . 'KM'; } else { return intval($R1KlN) . 'M'; } } public static function locationByIP($fPvYj, $BTuN4 = null) { goto fI7id; Hd5pT: $tzAUI = null; goto SpaUB; YAqJQ: shuffle($eYPY0); goto Hd5pT; fI7id: if (null === $BTuN4) { $eYPY0 = array(1, 2, 3); } else { $eYPY0 = array($BTuN4); } goto YAqJQ; SpaUB: foreach ($eYPY0 as $BTuN4) { $tzAUI = self::locationByIPRandom($BTuN4, $fPvYj); if ($tzAUI) { return $tzAUI; } } goto TK5Vf; TK5Vf: return null; goto Z48ws; Z48ws: } private static function locationByIPRandom($BTuN4, $fPvYj) { switch ($BTuN4) { case 1: goto D4sEZ; K7n42: break; goto tKflx; D4sEZ: $pwv63 = CurlUtil::getJSONData('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=' . urlencode($fPvYj)); goto H4qJc; H4qJc: if (!empty($pwv63)) { goto jxsT9; Qq7N7: $Xq8pj = empty($pwv63['province']) ? '' : $pwv63['province']; goto zzYDW; jxsT9: $O3dhs = empty($pwv63['country']) ? '' : $pwv63['country']; goto Qq7N7; CA_03: if ($O3dhs || $Xq8pj || $vI1L5) { $FH0Jg = array('country' => $O3dhs, 'province' => $Xq8pj, 'city' => $vI1L5); return $FH0Jg; } goto XD3jb; zzYDW: $vI1L5 = empty($pwv63['city']) ? '' : $pwv63['city']; goto CA_03; XD3jb: } goto K7n42; tKflx: case 2: goto jBmDY; jBmDY: $pwv63 = CurlUtil::getJSONData('http://ip.taobao.com/service/getIpInfo.php?ip=' . urlencode($fPvYj)); goto TZbJA; KFVOV: break; goto jbJAS; TZbJA: if (isset($pwv63['code']) && $pwv63['code'] == 0) { goto vWmJv; ek0uE: $vI1L5 = empty($pwv63['data']['city']) ? '' : $pwv63['data']['city']; goto B9b4h; YhmOV: $Xq8pj = empty($pwv63['data']['region']) ? '' : $pwv63['data']['region']; goto ek0uE; B9b4h: if ($O3dhs || $Xq8pj || $vI1L5) { $FH0Jg = array('country' => $O3dhs, 'province' => $Xq8pj, 'city' => $vI1L5); return $FH0Jg; } goto ddPFG; vWmJv: $O3dhs = empty($pwv63['data']['country']) ? '' : $pwv63['data']['country']; goto YhmOV; ddPFG: } goto KFVOV; jbJAS: case 3: goto bMDbJ; cV_YF: break; goto moPXK; bMDbJ: $pwv63 = CurlUtil::getJSONData('http://freeapi.ipip.net/' . urlencode($fPvYj)); goto eAmo7; eAmo7: if (isset($pwv63[0])) { goto N6S4Q; YRJns: $Xq8pj = empty($pwv63[1]) ? '' : $pwv63[1]; goto CCRty; CCRty: $vI1L5 = empty($pwv63[2]) ? '' : $pwv63[2]; goto azNlB; azNlB: if ($O3dhs || $Xq8pj || $vI1L5) { $FH0Jg = array('country' => $O3dhs, 'province' => $Xq8pj, 'city' => $vI1L5); return $FH0Jg; } goto krQCs; N6S4Q: $O3dhs = empty($pwv63[0]) ? '' : $pwv63[0]; goto YRJns; krQCs: } goto cV_YF; moPXK: } return null; } }