<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class article_uqcms extends control { public function like(){ $id = isset($_POST['id'])?$_POST['id']:exit('ID is error'); $querys = $this->db->query("update ".table('article')."  SET `like`=`like`+1 WHERE `id` = ".$id." LIMIT 1;"); if($querys){ echo '1'; }else{ echo '2'; } } public function dislike(){ $id = isset($_POST['id'])?$_POST['id']:exit('ID is error'); $query = $this->db->query("update ".table('article')."  SET `dislike`=`dislike`+1 WHERE `id` = ".$id." LIMIT 1;"); if($query){ echo '1'; }else{ echo 'error'; } } public function comment_add(){ $uid = $_SESSION['user']['uid']; sleep(1); if(!empty($uid)){ $aid = !empty($_POST['aid'])?$_POST['aid']:exit(json_encode(array('error'=>'4','msg'=>'程序错误'))); $is_comment = $this->db->get_one("select id,comment_state from ".table('article')." where id = ".$aid); if($is_comment['comment_state'] == '1'){ $data['aid'] = $aid; $data['uid'] = $uid; $data['ip'] = get_client_ip(); $data['content'] = !empty($_POST['content'])?$_POST['content']:exit(json_encode(array('error'=>'4','msg'=>'内容不能为空'))); $data['addtime'] = time(); $query = $this->db->add(table('article_comment'),$data); if($query){ $id = $this->db->insert_id(); $this->db->query("update ".table('article')." set `comment`=`comment`+1 where `id` = ".$data['aid']." limit 1"); $row = $this->db->get_one("select * from ".table('article_comment')." where id = ".$id); $user_row = $this->db->get_one("select * from ".table('user')." where uid = ".$row['uid']); $result['nick'] = $user_row['nick']; $result['avatar'] = $user_row['avatar']; $result['content'] = $row['content']; $result['addtime'] = $row['addtime']; }else{ $result = array('error'=>'4','msg'=>'添加失败'); } }else{ $result = array('error'=>'4','msg'=>'不允许留言'); } }else{ $result = array('error'=>'4','msg'=>'你还没有登录'); } exit(json_encode($result)); } }