<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class ajax_uqcms extends control { function __construct(){ $this->uid = @$_SESSION['user']['uid']; parent::__construct(); } public function check_user_status(){ if(!empty($this->uid)){ $arr['status'] = '1'; echo json_encode($arr); }else{ $arr['status'] = '0'; echo json_encode($arr); } } function get_area(){ $result = $this->module('area')->get_list(); echo json_encode($result); } public function qrcode(){ $code = isset($_GET['code'])?trim($_GET['code']):''; $size = !empty($_GET['size'])?$_GET['size']:'5'; $correctionLevel = !empty($_GET['level'])?$_GET['level']:'L'; $code = base64_decode($code); include FRAME_PATH.'class/phpqrcode.php'; QRcode::png($code, false, $correctionLevel, $size, 2); } public function vcode(){ $code = get_vcode_rand('4'); uqcms::vcode($code); $_SESSION['vcode'] = strtolower($code); } public function collect_goods(){ $gid = isset($_POST['gid'])?$_POST['gid']:error_json('提交错误'); if(empty($this->uid)){ echo json_encode(array('error'=>'0','status'=>'2')); }else{ $row = $this->db->get_one("select * from ".table('collect_goods')." where gid = ".$gid." and uid = ".$this->uid); if($row['id']){ $query = $this->db->delete(table('collect_goods'),'id = '.$row['id']); $query2 = $this->db->query("update ".table('goods')." set collect=collect-1 where id = ".$gid); if($query && $query2){ echo json_encode(array('error'=>'0','status'=>'0')); }else{ error_json('操作失败'); } }else{ $query = $this->db->add(table('collect_goods'),array('uid'=>$this->uid, 'gid'=>$gid,'addtime'=>time())); $query2 = $this->db->query("update ".table('goods')." set collect=collect+1 where id = ".$gid); if($query && $query2){ echo json_encode(array('error'=>'0','status'=>'1')); }else{ error_json('操作失败'); } } } } public function collect_shop(){ $spid = isset($_POST['spid'])?$_POST['spid']:error_json('提交错误'); if(empty($this->uid)){ echo json_encode(array('error'=>'0','status'=>'2')); }else{ $row = $this->db->get_one("select * from ".table('collect_shop')." where spid = ".$spid." and uid = ".$this->uid); if($row['id']){ $query = $this->db->delete(table('collect_shop'),'id = '.$row['id']); $query2 = $this->db->query("update ".table('shop')." set collect=collect-1 where id = ".$spid); if($query && $query2){ echo json_encode(array('error'=>'0','status'=>'0')); }else{ error_json('操作失败'); } }else{ $query = $this->db->add(table('collect_shop'),array('uid'=>$this->uid, 'spid'=>$spid,'addtime'=>time())); $query2 = $this->db->query("update ".table('shop')." set collect=collect+1 where id = ".$spid); if($query && $query2){ echo json_encode(array('error'=>'0','status'=>'1')); }else{ error_json('操作失败'); } } } } public function info(){ $module = isset($_GET['mod'])?$_GET['mod']:''; $action = isset($_GET['act'])?$_GET['act']:''; foreach($_GET as $k=>$v){ if($k == 'm' || $k=='a'||$k=='mod'||$k=='act'){ }else{ $post_arr[$k] = $v; } } if(!empty($this->uid)){ if(isset($post_arr)){ $result = $this->module($module)->$action($post_arr); }else{ $result = $this->module($module)->$action(); } if($result){ echo json_encode($result); }else{ error_json('暂时我内容'); } }else{ $result['islogin'] = '0'; echo json_encode($result); } } function express(){ $code =!empty($_GET['code'])?$_GET['code']:error_json('物流不能为空'); $number = !empty($_GET['nu'])?$_GET['nu']:error_json('物流号不能为空'); $result = $this->module('express')->so($code,$number); if($result == 'null'){ error_json('暂无物流信息'); }else{ $data['result'] = $result; right_json($data); } } function notice_run(){ $id = isset($_GET['id'])?$_GET['id']:exit('error'); $this->module('api')->notice_run($id); } } 