<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class category_uqcms extends control { function __construct(){ $this->aid = $_SESSION['admin']['aid']; parent::__construct(); } public function index() { $uq0 = $_GET['cid']??'0'; $uq1 = $this->db->get_all("select * from ".table('category')." where pcid = ".$uq0." order by px_asc asc"); if($uq1){ foreach($uq1 as $uq2){ $uq2['addtime'] = _date($uq2['addtime']); $uq3[] = $uq2; } $this->assign('data',$uq3); } $this->display(); } public function edit() { $uq0 = @$_GET['cid']?$_GET['cid']:false; if($uq0){ $this->assign('row',$this->module('category')->get_one(['cid'=>$uq0])); } $this->display('category/edit'); } public function save() { if($_POST){ $uq3['pcid'] = P('pcid','','0'); $uq4 = P('name','分类名称不能为空'); $uq3['sname'] = P('sname'); $uq3['keywords'] = P('keywords'); $uq3['describe'] = P('describe'); $uq3['images'] = P('images'); $uq3['px_index'] = P('px_index','','0'); $uq3['px_recommend'] = P('px_recommend','','0'); $uq3['px_hot'] = P('px_hot','','0'); $uq3['px_asc'] = P('px_asc','','0'); $uq3['status'] = P('status','','0'); $uq3['addtime'] = time(); $uq0 = P('cid', false); if($uq0){ $uq3['name'] = $uq4; $uq1 = $this->db->update(table('category'), $uq3, 'cid ='.$uq0); }else{ $uq5 = explode(',', $uq4); $uq6 = 0; $uq7 = 0; $this->db->autocommit(); foreach($uq5 as $uq2){ $uq3['name'] = $uq2; $uq1 = $this->db->add(table('category'), $uq3); if($uq1){ $uq6 ++; } $uq7++; } if(($uq6 == $uq7) && ($uq6 > '0')){ $this->db->commit(); $uq1 = true; }else{ $this->db->rollback(); $uq1 = false; } } if($uq1){ right_json(); }else{ error_json('保存失败'); } }else{ error_json('提交错误'); } } public function del() { $uq0 = P('id', '提交参数错误'); $uq8 = $this->db->get_one("select cid,pcid from ".table('category')." where pcid = ".$uq0." limit 1"); if($uq8){ if($uq8['cid']){ error_json('该分类下还有数据'); }else{ $uq1 = $this->db->delete(table('category'), 'cid = '.$uq0); if($uq1){ right_json(); }else{ error_json('删除失败'); } } }else{ error_json('操作失败'); } } public function px_status() { $uq0 = P('cid', '编号不能为空'); $uq9 = $_POST['type']; $this->db->query("update ".table('category')." set $uq9 = ($uq9 + 1)%2 where cid = ".$uq0." limit 1"); $uq8 = $this->db->get_one("select * from ".table('category')." where cid = ".$uq0); echo $uq8[$uq9]; } public function px_update() { $uq0 = P('cid', '提交编号不能为空'); $uq10 = P('px', '排序不能为空'); $uq1 = $this->db->update(table('category'),array('px_asc'=>$uq10),'cid = '.$uq0); if($uq1){ right_json(); }else{ error_json('更新失败'); } } public function ajax_get_next_list() { $uq11 = P('pcid', '', '0'); $uq1 = $this->db->get_all("select cid,pcid,name from ".table('category')." where pcid = ".$uq11); if($uq1){ foreach($uq1 as $uq12=>$uq2){ $uq13[] = $uq2; } if(isset($uq13)){ $uq3['error'] = '0'; $uq3['last'] = '0'; $uq3['category'] = $uq13; echo json_encode($uq3); }else{ $uq3['error'] = '0'; $uq3['last'] = '1'; echo json_encode($uq3); } }else{ $uq3['error'] = '0'; $uq3['last'] = '1'; echo json_encode($uq3); } } public function ajax_get_parents_list() { $uq0 = P('cid', '提交错误'); $uq14 = $this->module('category')->get_parents_cid($uq0); $uq15 = $this->module('category')->get_parents_list($uq14); if($uq15){ echo json_encode($uq15); }else{ error_json('获取失败'); } } } 