<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class address_mod extends module { function __construct(){ $this->uid = @$_SESSION['user']['uid']; parent::__construct(); } function get_one($id){ if(!empty($this->uid)){ if($id){ $row = $this->db->get_one("select * from ".table('member_address')." where uid = ".$this->uid." and id = ".$id); if($row['id']){ if($row['prov']){ $prov_cn = $row['prov_cn']; }else{ $prov_cn = ''; } if($row['city']){ $city_cn = '/'.$row['city_cn']; }else{ $city_cn = ''; } if($row['dist']){ $dist_cn = '/'.$row['dist_cn']; }else{ $dist_cn = ''; } $row['area'] = $prov_cn.$city_cn.$dist_cn; return $row; }else{ return false; } }else{ return false; } }else{ return false; } } public function get_all(){ if(!empty($this->uid)){ $list = $this->db->get_all("select * from ".table('member_address')." where uid = ".$this->uid." order by is_default desc"); if($list){ foreach($list as $k=>$v){ if($v['prov']){ $prov_cn = $v['prov_cn']; }else{ $prov_cn == ''; } if($v['city']){ $city_cn = ', '.$v['city_cn']; }else{ $city_cn == ''; } if($v['dist']){ $dist_cn = ', '.$v['dist_cn']; }else{ $dist_cn == ''; } $v['area'] = $prov_cn.$city_cn.$dist_cn; $data[] = $v; } return $data; }else{ return false; } }else{ return false; } } public function get_session_address(){ $addr_ch = isset($_SESSION['settle_address'])?$_SESSION['settle_address']:''; if($addr_ch){ $data = $this->db->get_one("select * from ".table('member_address')." where uid = ".$this->uid." and id = ".$addr_ch); if($data['id']){ return $data; }else{ return false; } }else{ return false; } } function get_cn($addrArr){ $addrArr = array_filter($addrArr); $addrcn_in = implode(',', $addrArr); if($addrcn_in){ $all = $this->db->get_all("select * from ".table('area')." where id in(".$addrcn_in.") order by level desc"); if($all){ foreach($all as $k=>$v){ $data[$v['id']] = $v; } return $data; }else{ return false; } }else{ return false; } } }