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

defined('IN_UQ') or exit('Access Denied'); class api_uqcms extends control { function __construct(){ $this->aid = $_SESSION['admin']['aid']; parent::__construct(); } function index() { if(!extension_loaded('sockets')){ $this->assign('error_status', true); } $uq0 = G('type'); if(!empty($uq0)){ $uq1 = " where type = '".$uq0."'"; }else{ $uq1 = " where type = 'storage'"; } $uq2 = $this->db->get_all("select * from ".table('api').$uq1." order by id asc"); $this->assign('data', $uq2); $this->display(); } function edit() { $uq3 = G('id', false); $uq4 = $this->db->get_one("select * from ".table('api')." where id = ".$uq3); if($uq4['id']){ $uq4['parr'] = explode(',', $uq4['param']); $uq4['pcon'] = unserialize($uq4['pcon']); $this->assign('row', $uq4); } $this->display(); } function save() { $uq5['desc'] = P('desc'); $uq5['pcon'] = serialize(P('pcon')); $uq5['status'] = P('status', '', '1'); $uq3 = P('id', '提交错误'); $uq6 = $this->db->update(table('api'), $uq5, 'id = '.$uq3); if($uq6){ right_json(); }else{ error_json('保存失败'); } } function del() { } function tpl() { $uq3 = G('id', false); if($uq3){ $uq7 = $this->db->get_one("select * from ".table('api')." where id = ".$uq3); if($uq7['id']){ $this->assign('tpl_row', $uq7); } } $uq8 = $this->module('api')->notice_name(); $this->assign('name_list', $uq8); $this->display(); } function get_tpl() { $uq0 = G('type', '提交类型不能为空'); $uq9 = G('code', '提交错误'); $uq8 = $this->module('api')->notice_name(); if($uq8){ foreach($uq8 as $uq10){ $uq11[$uq10['alias']] = $uq10['param']; } } $uq4['api_param']= $uq11[$uq9]; $uq1 = ''; if($uq0 == 'wchat' || $uq0 == 'email'){ }else{ $type2 = G('type2', '提交错误'); if($type2){ $uq1 .= " and type2 = '".$type2."' "; } } $uq7 = $this->db->get_one("select * from ".table('api_tpl')." where type = '".$uq0."' and code = '".$uq9."'".$uq1." limit 1"); if($uq7['id']){ $uq4 = array_merge($uq7, $uq4); } echo right_json($uq4); } function tpl_save() { $uq5['code'] = P('code', '请选择要设置的模板'); $uq5['type'] = P('type', '提交错误'); $type2 = P('type2', '提交错误'); if($type2 == 'wchat' || $type2 == 'email'){ }else{ $uq5['type2'] = $type2; } $uq5['name'] = P('name'); $uq5['tpl_id'] = P('tpl_id'); $uq5['param'] = P('param'); $uq5['param2'] = P('param2'); $uq5['content'] = P('content'); $uq5['status'] = P('status'); $uq3 = P('id', false); if($uq3){ $uq6 = $this->db->update(table('api_tpl'), $uq5, 'id = '.$uq3); }else{ $uq5['addtime'] = time(); $uq6 = $this->db->add(table('api_tpl'), $uq5); } if($uq6){ right_json(); }else{ error_json('保存失败'); } } public function log() { $uq0 = $_GET['type']??''; $uq1 = ''; if(!empty($uq0)){ $uq1 .= ' where type = '.$uq0; } $uq12 = [ 'wchat' =>'微信', 'sms' =>'短信', 'email' =>'邮件', ]; $uq13 = $this->db->get_all("select * from ".table('api_log').$uq1." order by id desc ".$this->limit()); if($uq13){ $uq14 = $this->module('api')->notice_name(); if($uq14){ foreach($uq14 as $uq10){ $uq15[$uq10['alias']] = $uq10['name']; } } foreach($uq13 as $uq16=>$uq10){ $uq10['addtime'] = _date($uq10['addtime']); $uq10['type_cn'] = $uq12[$uq10['type']]??''; if(isset($uq15[$uq10['tpl_name']])){ $uq10['tpl_name_cn'] = $uq15[$uq10['tpl_name']]; } $uq17[] = $uq10; } $uq2['list'] = $uq17; $uq18 = $this->db->get_one("select count(id) as total from ".table('api_log').$uq1); $uq14['total'] = $uq18['total']; $uq2['page'] = $this->page($uq14); $this->assign('data', $uq2); } $this->display(); } public function log_del() { $uq3 = P('id', '提交参数错误'); $uq6 = $this->db->delete(table('api_log'), 'id = '.$uq3); if($uq6){ right_json(); }else{ error_json('删除失败'); } } public function log_truncate() { $uq6 = $this->db->query("TRUNCATE TABLE ".table("api_log")); if($uq6){ right_json(); }else{ error_json('清除失败'); } } function test_email() { if(!extension_loaded('openssl')){ $this->assign('error_status', true); } $uq19 = P('email', '' , '邮件不能为空'); $uq20 = $this->module('api')->notice_email($uq19, 'test'); if($uq20){ $uq14['error'] = '0'; echo json_encode($uq14); }else{ error_json('发送失败【请确认是否配置正确】'); } } function test_wxtpl() { $uq21 = P('openid', '微信openid不能为空'); $uq20 = $this->module('api')->notice_wxtpl($uq21, 'test'); if($uq20){ $uq14['error'] = '0'; echo json_encode($uq14); }else{ error_json('发送失败【请确认是否配置正确】'); } } } 