www.gusucode.com > mcms手机网站系统 v3.1源码程序 > mcms_v3.1.0/upload/app/comment/index.php
<?php require_once(dirname(__FILE__) . "/../../init.php"); //公用引导启动文件 $time_start = H :: getmicrotime(); //开始时间 $cid=0; $topid=0; // 动作处理 call_mfunc(); require_once(assign_tpl(basename(__FILE__), 'message')); // 评论列表 function m__list() { global $dbm, $C, $p,$result; if(isset($_POST['comment_id'])) $_GET['comment_id'] = intval($_POST['comment_id']); $comment_id = isset($_GET['comment_id']) ? intval($_GET['comment_id']) : 0; $p = isset($_GET['p'])?intval($_GET['p']):1; //分页页码 if ($p==0) $p = 1; if($comment_id > 0 ) { die($C->get_comments($comment_id, $p) . $C->getcomment_form($comment_id)); } else { die('{"code":"1","msg":"评论ID参数出错"}'); } } // 添加评论 function m__commentadd() { global $dbm, $C; $user_dev = H::user_dev(); $fields = array(); if(isset($_SESSION['postdata']['comment']) && (time()-$_SESSION['postdata']['comment']<60)) die('{"code":"101","msg":"歇会再评论吧"}'); if (trim($_POST['comment']) == '') { die('{"code":"1","msg":"发表内容不能为空"}'); } if($user_dev == 'pc') { $code = md5(strtoupper($_POST['code'])); if ($code != $_SESSION['feedback']) { die('{"code":"140","msg":"验证码错误"}'); } } if (!isset($_POST['comment_id']) || !is_numeric($_POST['comment_id'])) die('{"code":"202","msg":"id号出错"}'); if (!isset($_POST['parent_id']) || !is_numeric($_POST['parent_id'])) die('{"code","203","msg":"上级ID出错"}'); $content = isset($_POST['comment']) ? H::sqlxss($_POST['comment']) : ''; $fields['info_id'] = intval($_POST['comment_id']); $fields['parent_id'] = intval($_POST['parent_id']); $fields['content'] = H :: utf8_substr($content, 0, 300); $fields['uid'] = isset($_SESSION['user']['uid']) ? intval($_SESSION['user']['uid']) : 0; $fields['uname'] = isset($_SESSION['user']['login_name']) ? H::sqlxss($_SESSION['user']['login_name']) : ''; if($fields['uname']=='') { $fields['uname'] = isset($_POST['user']) ? H::sqlxss($_POST['user']) : ''; } $fields['date_add'] = time(); $fields['is_check'] = 0; $fields['ip'] = H :: getip(); if ($fields['parent_id'] != 0) { $ress = $dbm -> query_update("UPDATE " . TB_PRE . "comment SET son = son + 1 WHERE comment_id = '{$fields['parent_id']}'"); } $res = $dbm -> single_insert(TB_PRE . 'comment', $fields); if (empty($res['error']) && empty($ress['error'])) { $_SESSION['postdata']['comment']=time(); die('{"code":"0","msg":"发表成功"}'); } die('{"code":"1","msg":"发表失败:' . $ress['error'] . '"}'); } // ajax请求评论顶一下 function m__cgood() { global $dbm, $C; $fields = array(); $comment_id = $_POST['comment_id']; if (is_numeric($comment_id)) { $dbm -> query_update("UPDATE " . TB_PRE . "comment SET good = good + 1 WHERE comment_id = '$comment_id'"); $rs = $dbm -> query("SELECT * from " . TB_PRE . "comment WHERE comment_id = '$comment_id'"); if (count($rs['list']) > 0) { die($rs['list'][0]['good']); } else { die('0'); } } die(); } // ajax请求评论采一下 function m__cbad() { global $dbm, $C; $fields = array(); $comment_id = $_POST['comment_id']; if (is_numeric($comment_id)) { $dbm -> query_update("UPDATE " . TB_PRE . "comment SET bad = bad + 1 WHERE comment_id = '$comment_id'"); $rs = $dbm -> query("SELECT * from " . TB_PRE . "comment WHERE comment_id = '$comment_id'"); if (count($rs['list']) > 0) { die($rs['list'][0]['bad']); } else { die('0'); } } die(); } ?>