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

defined('IN_UQ') or exit('Access Denied'); class help_uqcms extends control { function __construct() { $this->aid = $_SESSION['admin']['aid']; parent::__construct(); } function index() { $uq0 = $this->cats_arr(); $uq1 = $this->db->get_all("select * from ".table('help')." order by id desc ".$this->limit()); if($uq1){ foreach($uq1 as $uq2){ $uq2['cats_cn'] = $uq0[$uq2['cid']]??'暂无分类'; $uq2['addtime'] = _date($uq2['addtime']); $uq3[] = $uq2; } $uq4['list'] = $uq3; $uq5 = $this->db->get_one("select count(id) as total from ".table('help')); $this->assign('data', $uq4); } $this->display(); } function edit() { $uq6 = $_GET['id']??false; if($uq6){ $uq7 = $this->db->get_one("select * from ".table('help')." where id = ".$uq6); $this->assign('row', $uq7); } $this->assign('cats', $this->cats_arr()); $this->display(); } function save() { if($_POST){ $uq4['cid'] = P('cid','分类不能为空'); $uq4['title'] = P('title','标题不能为空'); $uq4['content'] = P('content', '内容不能为空'); $uq4['status'] = P('status', '', '1'); $uq4['link_status'] = P('link_status', '', '0'); $uq4['link'] = P('link', ''); $uq4['alias'] = P('alias'); $uq4['status'] = P('status', '', '1'); $uq4['addtime'] = time(); $uq6 = P('id', 0); if($uq6){ $uq1 = $this->db->update(table('help'), $uq4, 'id = '.$uq6); }else{ $uq1 = $this->db->add(table('help'), $uq4); } if($uq1){ right_json(); }else{ error_json('保存失败'); } }else{ error_json('操作错误'); } } function del() { $uq6 = P('id', '提交错误'); $uq1 = $this->db->delete(table('help'), 'id = '.$uq6); if($uq1){ right_json(); }else{ error_json('删除失败'); } } public function cats() { $this->assign('cats', $this->cats_list()); $this->display(); } function cats_edit() { $uq8 = $_GET['cid']??false; if($uq8){ $uq7 = $this->db->get_one("select * from ".table('help_cats')." where cid = ".$uq8); $this->assign('row', $uq7); } $this->display(); } function cats_save() { if($_POST){ $uq9['name'] = P('name','名称不能为空'); $uq9['alias'] = P('alias'); $uq9['px'] = P('px','','0'); $uq9['status'] = P('status','','0'); $uq9['addtime'] = time(); $uq8 = P('cid', false); if($uq8){ $uq1 = $this->db->update(table('help_cats'), $uq9, 'cid = '.$uq8); }else{ $uq1 = $this->db->add(table('help_cats'), $uq9); } if($uq1){ right_json(); }else{ error_json('修改失败'); } }else{ error_json('提交错误'); } } function cats_del() { if($_POST){ $uq8 = P('id', '提交编号错误'); $uq10 = $this->db->delete(table('help_cats'), 'cid = '.$uq8); if($uq10){ right_json(); }else{ error_json('删除失败'); } }else{ error_json('删除失败'); } } function cats_list() { $uq1 = $this->db->get_all("select * from ".table('help_cats')); if($uq1){ foreach($uq1 as $uq2){ $uq2['addtime'] = _date($uq2['addtime']); $uq11[] = $uq2; } return $uq11; }else{ return false; } } function cats_arr() { $uq1 = $this->db->get_all("select * from ".table('help_cats')); if($uq1){ foreach($uq1 as $uq2){ $uq12[$uq2['cid']] = $uq2['name']; } return $uq12; }else{ return false; } } } 