<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class area_mod extends module { function get_list(){ $content = cache::get("config/area"); if(!$content){ $all = $this->db->get_all("select id,pid,name from ".table('area')." order by id asc"); if($all){ foreach($all as $k=>$v){ if($v['pid'] == '0'){ $prov_cn[$v['id']] = $v['name']; $prov[] = $v; } } foreach($prov as $k=>$v){ foreach($all as $kk=>$vv){ if($v['id'] == $vv['pid']){ $city_cn[$v['id']][$vv['id']] = $vv['name']; $city[$v['id']][] = $vv; $city_next[] = $vv; } } } foreach($city_next as $k=>$v){ foreach($all as $kk=>$vv){ if($v['id'] == $vv['pid']){ $dist_cn[$v['id']][$vv['id']] = $vv['name']; $dist[$v['id']][] = $vv; } } } $area['prov'] = $prov_cn; $area['city'] = $city_cn; $area['dist'] = $dist_cn; cache::add("config/area", $area); return $area; }else{ return false; } }else{ return $content; } } function get_city(){ for($i=65;$i<91;$i++){ $frist_letter = chr($i); $row['name'] = $frist_letter; $pquery = $this->db->query("select * from ".table('area')." where level = 2 and letter = '".$frist_letter."'"); while($prow = $this->db->fetch_array($pquery)){ $row['parent'][] = $prow; } if(count($row['parent']) != '0'){ $data[] = $row; } unset($row['parent']); } return $data; } public function letter(){ for($i=65;$i<91;$i++){ $data[] = chr($i); } return $data; } public function get_cn($arr){ $prov = isset($arr['prov'])?$arr['prov']:'0'; $city = isset($arr['city'])?$arr['city']:'0'; $dist = isset($arr['dist'])?$arr['dist']:'0'; $list = $this->db->get_all("select * from ".table('area')." where id in(".$prov.",".$city.",".$dist.") order by id asc; "); if($list){ $data['prov'] = $list[0]['id']; $data['prov_cn'] = $list[0]['name']; $data['city'] = $list[1]['id']; $data['city_cn'] = $list[1]['name']; $data['dist'] = $list[2]['id']; $data['dist_cn'] = $list[2]['name']; return $data; } } } 