/** * 获取并设置区域信息 */ protected function regionInfo() { if (empty($key)) { // 采用行政区域参数 if (!empty($_GET['region'])) { $_region = Tools::convertToUtf8(urldecode($_GET['region'])); $city = explode('市', $_region); if (!empty($city[0])) { $key = explode('省', $city[0]); } else { $key = $_region; } } elseif (!empty($_GET['area'])) { $_area = Tools::convertToUtf8(urldecode($_GET['area'])); $key = explode(',', $_area); } elseif (!empty($_GET['prov']) || !empty($_GET['city'])) { $key[] = Tools::convertToUtf8(trim($_GET['prov'])); // 关键词——2 $key[] = empty($_GET['city']) ? '' : Tools::convertToUtf8(trim($_GET['city'])); // 关键词2——2 } // 采用ip参数 if (empty($key[1]) && empty($key[0])) { if (!empty($_GET['geoip'])) { $ip = trim($_GET['geoip']); } else { $ip = !empty($_COOKIE['geoip']) ? trim($_COOKIE['geoip']) : ''; } preg_match('/[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/', $ip, $matches); $ip = $matches[0]; $key = !$ip ? null : GeoTool::getAreaNameByIp($ip); } } // 市 if (empty($key[1])) { // $key [1] = $key [0]; // unset ( $key [0] ); } else { $this->region['city'] = Tools::convertToUtf8($key[1]); } // 省 if (empty($key[0])) { // unset ( $key [0] ); } else { $this->region['prov'] = Tools::convertToUtf8($key[0]); } debugLog(__CLASS__ . ':region', $this->region); }