begin of thinksaas 3.68

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2023-06-22 13:33:25 +08:00
commit 963ec1b2ea
2746 changed files with 331806 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
<?php
defined('IN_TS') or die('Access Denied.');
return array(
'name' => '评论',
'version' => '1.2',
'desc' => '评论管理',
'url' => 'http://www.thinksaas.cn',
'email' => 'thinksaas@qq.com',
'author' => '邱君',
'author_url' => 'http://www.thinksaas.cn',
'isoption' => '1',
'isinstall' => '1',
'issql' => '1',
'issystem' => '1',
'isappnav' => '0',
'ismy'=>'1'
);
+145
View File
@@ -0,0 +1,145 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户是否登录
$userid = aac('user')->isLogin($js,$userkey);
$authcode = strtolower((string) $_POST['authcode']);
if ($TS_SITE ['isauthcode'] && $authcode) {
if ($authcode != $_SESSION ['verify']) {
getJson ( "验证码输入有误,请重新输入!" ,$js,0);
}
}
$ptable = tsTrim($_POST['ptable']);
if(!preg_match("/^[a-z_]*$/i", $ptable)){
getJson('非法操作!',$js);
}
$pkey = tsTrim($_POST['pkey']);
if(!preg_match("/^[a-z_]*$/i", $pkey)){
getJson('非法操作!',$js);
}
$pid = tsIntval($_POST['pid']);
$referid = tsIntval($_POST['referid']);
$touserid = tsIntval($_POST['touserid']);
$content = tsClean($_POST['content'],$js);
$content2 = emptyText($_POST['content']);//测试空内容
$ispublic = tsIntval($_POST['ispublic']);
//匿名用户
$isniming = tsIntval($_POST['isniming']);
if($TS_SITE['isniming']==1 && $isniming==1) $userid = aac('user')->getNimingId();
//过滤内容开始
if($TS_USER['isadmin']==0){
$content = antiWord($content);
}
//过滤内容结束
if($ptable=='' || $pkey=='' || $pid=='' || $content2=='' || $content==''){
getJson('没有任何内容是不允许你通过滴^_^',$js);
}else{
$isaudit = 0;
if($TS_APP['comment_isaudit']==1 && $TS_USER['isadmin']==0) $isaudit=1;
$commentid = $new['comment']->create('comment',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
'referid'=>$referid,
'userid'=>$userid,
'touserid'=>$touserid,
'content' => $content,
'ispublic'=>$ispublic,
'isaudit'=>$isaudit,
'addtime'=> time(),
));
//统计评论数
$count_comment = $new['comment']->findCount('comment',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
));
//更新项目最后回应时间和评论数
$new['comment']->update($ptable,array(
$pkey=>$pid,
),array(
'count_comment'=>$count_comment,
'uptime'=>time(),
));
#更新ptable评论数
aac('pubs')->upPtableComment($ptable,$pkey,$pid,$count_comment);
//发送系统消息(通知楼主有人回复他的帖子啦)
$strProject = $new['comment']->find($ptable,array(
$pkey=>$pid,
));
if($referid){
$strComment = $new['comment']->find('comment',array(
'commentid'=>$referid,
));
//创建消息
if($strComment['userid'] != $userid){
$msg_userid = $userid;
$msg_touserid = $strComment['userid'];
$msg_content = '回复了你:'.t($content);
$msg_tourl = getProjectUrl($ptable,$pid);
$msg_extend = json_encode(array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
));
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl,$msg_extend);
}
#上级评论用户加分
aac ( 'user' )->doScore ( $TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts'],$strComment['userid']);
}else{
//创建消息
if($strProject['userid'] != $userid){
$msg_userid = $userid;
$msg_touserid = $strProject['userid'];
$msg_content = '评论了你发布的:《'.$strProject['title'].'》';
$msg_tourl = getProjectUrl($ptable,$pid);
$msg_extend = json_encode(array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
));
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl,$msg_extend);
}
}
$daytime = strtotime(date('Y-m-d 00:00:01'));
$count_comment = $new['comment']->findCount('comment',"`userid`='$userid' and `addtime`>'$daytime'");
#每日前1条给积分
if($count_comment<2){
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts']);
}
getJson('评论成功',$js,2,getProjectUrl($ptable,$pid));
}
+9
View File
@@ -0,0 +1,9 @@
<?php
defined('IN_TS') or die('Access Denied.');
// 管理入口
if (is_file('app/' . $TS_URL['app'] . '/action/admin/' . $mg . '.php')) {
include_once 'app/' . $TS_URL['app'] . '/action/admin/' . $mg . '.php';
} else {
qiMsg('sorry:no index!');
}
+91
View File
@@ -0,0 +1,91 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch ($ts){
case "list":
$userid = tsIntval($_GET['userid']);
$ptable = isset($_GET['ptable']) ? tsTrim($_GET['ptable']) : '';
$pid = tsIntval($_GET['pid']);
$page = tsIntval($_GET['page'],1);
$url = SITE_URL.'index.php?app=comment&ac=admin&mg=comment&ts=list&ptable='.$ptable.'&userid='.$userid.'&page=';
$lstart = $page*10-10;
$where = null;
if($ptable){
$where = "`ptable`='$ptable'";
}
if($userid){
$where .= " and `userid`='$userid'";
}
if($pid){
$where .= "`pid`='$pid'";
}
$arrComment = $new['comment']->findAll('comment',$where,'addtime desc',null,$lstart.',10');
$commentNum = $new['comment']->findCount('comment',$where);
$pageUrl = pagination($commentNum, 10, $page, $url);
include template("admin/comment_list");
break;
case "delete":
$commentid = tsIntval($_GET['commentid']);
$strComment = $new['comment']->find('comment',array(
'commentid'=>$commentid,
));
$ptable = $strComment['ptable'];
$pkey = $strComment['pkey'];
$pid = $strComment['pid'];
$new['comment']->delete('comment',array(
'commentid'=>$commentid,
));
$new['comment']->delComment($ptable,$pkey,$pid,$commentid);
#处理积分
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts'],$strComment['userid']);
qiMsg('删除成功');
break;
case "isaudit":
$commentid = tsIntval($_GET['commentid']);
$strComment = $new['comment']->find('comment',array(
'commentid'=>$commentid,
));
if($strComment['isaudit']==1){
$isaudit = 0;
}else{
$isaudit = 1;
}
$new['comment']->update('comment',array(
'commentid'=>$commentid,
),array(
'isaudit'=>$isaudit,
));
qiMsg('操作成功!');
break;
}
+26
View File
@@ -0,0 +1,26 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//基本配置
case "":
$strOption = getAppOptions('comment');
include template("admin/options");
break;
case "do":
$arrOption = $_POST['option'];
#更新app配置选项
upAppOptions('comment',$arrOption);
#更新app导航和我的导航
upAppNav('comment',$arrOption['appname']);
qiMsg('修改成功!');
break;
}
+9
View File
@@ -0,0 +1,9 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
// api入口
if (is_file ( 'app/' . $TS_URL['app'] . '/action/api/' . $TS_URL['api'] . '.php' )) {
include_once 'app/' . $TS_URL['app'] . '/action/api/' . $TS_URL['api'] . '.php';
} else {
qiMsg ( 'sorry:no api!' );
}
+26
View File
@@ -0,0 +1,26 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户是否登录
$userid = aac('user')->isLogin($js,$userkey);
$commentid = tsIntval($_GET['commentid']);
$strComment = $new['comment']->find('comment',array(
'commentid'=>$commentid,
));
$ptable = $strComment['ptable'];
$pkey = $strComment['pkey'];
$pid = $strComment['pid'];
if($TS_USER['isadmin']==1 || $strComment['userid']==$userid){
$new['comment']->delComment($ptable,$pkey,$pid,$commentid);
//处理积分
aac('user')->doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts'],$strComment['userid']);
}
//跳转回到详情页
header("Location: ".getProjectUrl($ptable,$pid));
+11
View File
@@ -0,0 +1,11 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
// 我的入口
if (is_file ( 'app/' . $TS_URL['app'] . '/action/my/' . $TS_URL['my'] . '.php' )) {
$userid = aac('user')->isLogin();
$strUser = aac('user')->getOneUser($userid);
include_once 'app/' . $TS_URL['app'] . '/action/my/' . $TS_URL['my'] . '.php';
} else {
qiMsg ( 'sorry:no index!' );
}
+22
View File
@@ -0,0 +1,22 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
$page = tsIntval($_GET['page'],1);
$url = tsUrl ( 'comment', 'my', array ('my'=>'index','page' => '' ) );
$lstart = $page * 20 - 20;
$arrComment = $new ['comment']->findAll ( 'comment', array (
'userid' => $strUser['userid'],
), 'addtime desc', null, $lstart . ',20' );
$commentNum = $new ['comment']->findCount ( 'comment', array (
'userid' => $strUser['userid'],
) );
$pageUrl = pagination ( $commentNum, 20, $page, $url );
$title = '我的评论';
include template('my/index');
+9
View File
@@ -0,0 +1,9 @@
<?php
defined('IN_TS') or die('Access Denied.');
$referid = tsIntval($_GET['referid']);
$userid = tsIntval($_GET['userid']);
$arrRecomment = $new['comment']->recomment($referid,$userid);
include template('recomment');
+207
View File
@@ -0,0 +1,207 @@
<?php
defined('IN_TS') or die('Access Denied.');
class comment extends tsApp {
//构造函数
public function __construct($db) {
$tsAppDb = array();
include 'app/comment/config.php';
//判断APP是否采用独立数据库
if ($tsAppDb) {
$db = new MySql($tsAppDb);
}
parent::__construct($db);
}
/**
* 获取评论列表
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param [type] $page 当前页码
* @param [type] $lstart 每页显示条数
* @param [type] $puid 当前项目的用户ID
* @param integer $uid 当前登录的用户ID
* @param integer $ismb 是否手机浏览
* @return void
*/
public function getCommentList($ptable,$pkey,$pid,$page,$lstart,$puid,$uid=0,$ismb=0){
$arrComment = $this->findAll('comment',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
'referid'=>0,
),'addtime desc',null,$lstart.',15');
foreach($arrComment as $key => $item){
$arrComment[$key]['l'] = (($page-1) * 15) + $key + 1;
//$arrComment[$key]['l'] = (($page-1) * 15) - $key + $commentNum;//盖楼
$arrComment[$key]['user'] = aac('user')->getSimpleUser($item['userid']);
$arrComment[$key]['content'] = tsDecode($item['content']);
if($ismb){
$arrComment[$key]['content'] = mobileHtml($arrComment[$key]['content']);
}
$arrComment[$key]['recomment'] = $this->recomment($item['commentid'],$puid,3,$uid,$ismb);
$arrComment[$key]['recomment_num'] = $this->recommentNum($item['commentid']);
$arrComment[$key]['zzuid'] = $puid;//作者ID
$arrComment[$key]['iszz'] = 0;#作者1是0否
if($item['userid']==$puid){
$arrComment[$key]['iszz'] = 1;#作者1是0否
}
$arrComment[$key]['isdelete'] = 0;#删除权限1有0无
if($uid && $uid==$item['userid']){
$arrComment[$key]['isdelete'] = 1;#删除权限1有0无
}
$arrComment[$key]['iscomment'] = 0;#回复权限1有0无
if($uid && $uid!=$item['userid']){
$arrComment[$key]['iscomment'] = 1;#回复权限1有0无
}
$arrComment[$key]['datetime'] = date('m-d H:i',$item['addtime']);
}
return $arrComment;
}
/**
* 获取评论数
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @return void
*/
public function getCommentNum($ptable,$pkey,$pid){
$commentNum = $this->findCount('comment',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
'referid'=>0,
));
return $commentNum;
}
/**
* 获取评论下的回复列表
*
* @param [type] $referid 上级评论ID
* @param [type] $puid 当前项目用户ID
* @param integer $num 调用条数
* @param integer $uid 当前登录的用户ID
* @param integer $ismb 是否手机浏览
* @return void
*/
function recomment($referid,$puid,$num=0,$uid=0,$ismb=0){
if($num){
$limit = $num;
}else{
$limit = null;
}
$arrComment = $this->findAll('comment',array(
'referid'=>$referid,
),'addtime desc',null,$limit);
foreach($arrComment as $key=>$item){
$html = tsDecode($item['content']);
if($ismb==1){
$html = mobileHtml($html);
}
$arrComment[$key]['content'] = $html;
$arrComment[$key]['user'] = aac('user')->getSimpleUser($item['userid']);
$arrComment[$key]['datetime'] = date('m-d H:i',$item['addtime']);
if($item['touserid']){
$arrComment[$key]['touser'] = aac('user')->getSimpleUser($item['touserid']);
}
$arrComment[$key]['iszz'] = 0;#作者1是0否
if($item['userid']==$puid){
$arrComment[$key]['iszz'] = 1;#作者1是0否
}
$arrComment[$key]['isdelete'] = 0;#删除权限1有0无
if($uid && $uid==$item['userid']){
$arrComment[$key]['isdelete'] = 1;#删除权限1有0无
}
$arrComment[$key]['iscomment'] = 0;#回复权限1有0无
if($uid && $uid!=$item['userid']){
$arrComment[$key]['iscomment'] = 1;#回复权限1有0无
}
}
return $arrComment;
}
function recommentNum($referid){
$num = $this->findCount('comment',array(
'referid'=>$referid,
));
return $num;
}
/**
* 删除评论
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param integer $commentid
* @return void
*/
public function delComment($ptable,$pkey,$pid,$commentid=0){
if($commentid){
$this->delete('comment',array(
'commentid'=>$commentid,
));
#删除回复
$this->delete('comment',array(
'referid'=>$commentid,
));
}else{
$this->delete('comment',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
));
}
#统计评论数
$count_comment = $this->findCount('comment',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
));
//更新评论数
$this->update($ptable,array(
$pkey=>$pid,
),array(
'count_comment'=>$count_comment,
));
return true;
}
}
+4
View File
@@ -0,0 +1,4 @@
<?php
defined('IN_TS') or die('Access Denied.');
$TS_APP['appname'] = '评论';
+116
View File
@@ -0,0 +1,116 @@
{php include pubTemplate("header_admin")}
<!--main-->
<div class="midder">
{php include template("admin/menu");}
<div class="page">{$pageUrl}</div>
<div class="mb-3">
<form method="get" action="index.php">
<input type="hidden" name="app" value="comment">
<input type="hidden" name="ac" value="admin">
<input type="hidden" name="mg" value="comment">
<input type="hidden" name="ts" value="list">
<select name="ptable">
<option value="" {if $ptable==''}selected{/if}>全部</option>
<option value="topic" {if $ptable=='topic'}selected{/if}>帖子</option>
<option value="article" {if $ptable=='article'}selected{/if}>文章</option>
<option value="photo" {if $ptable=='photo'}selected{/if}>图片</option>
<option value="weibo" {if $ptable=='weibo'}selected{/if}>唠叨</option>
<option value="video" {if $ptable=='video'}selected{/if}>视频</option>
<option value="audio" {if $ptable=='audio'}selected{/if}>音频</option>
<option value="event" {if $ptable=='event'}selected{/if}>活动</option>
<option value="vote" {if $ptable=='vote'}selected{/if}>投票</option>
<option value="study_lesson" {if $ptable=='study_lesson'}selected{/if}>课时</option>
<option value="goods" {if $ptable=='goods'}selected{/if}>商品</option>
</select>
<input type="number" name="pid" placeholder="PID">
<input type="number" name="userid" placeholder="用户ID">
<input type="submit" value="搜索">
<a class="btn btn-sm btn-outline-secondary" href="index.php?app=comment&ac=admin&mg=comment&ts=list&ptable={$ptable}">全部</a>
</form>
</div>
<table class="table table-hover">
<thead class="thead-light fs14">
<tr><th>ID</th>
<th>UserID</th>
<th>PID</th>
<th>内容</th>
<th>时间</th>
<th>操作</th></tr>
</thead>
<tbody class="fs12">
{loop $arrComment $key $item}
<tr>
<td>{$item['commentid']}</td>
<td>{$item['userid']}</td>
<td>{$item['pid']} <a target="_blank" href="{php echo getProjectUrl($item['ptable'],$item['pid']);}">[查看内容]</a></td>
<td>
<div style="width: 600px;">{php echo tsDecode($item['content'])}</div>
</td>
<td>{php echo date('Y-m-d H:i:s',$item['addtime'])}</td>
<td>
<a class="btn btn-sm btn-outline-secondary" href="{SITE_URL}index.php?app=comment&ac=admin&mg=comment&ts=isaudit&commentid={$item['commentid']}">
{if $item['isaudit']==1}
审核
{else}
取消审核
{/if}
</a>
<a class="btn btn-sm btn-outline-secondary" onclick="return confirm('确定删除?')" href="{SITE_URL}index.php?app=comment&ac=admin&mg=comment&ts=delete&commentid={$item['commentid']}">删除</a>
</td></tr>
{/loop}
</tbody>
</table>
</div>
{php include pubTemplate("footer_admin")}
+11
View File
@@ -0,0 +1,11 @@
<div class="tabnav">
<h6>评论管理</h6>
<ul>
<li {if $mg=='options'}class="select"{/if}><a href="{SITE_URL}index.php?app=comment&ac=admin&mg=options">基础配置</a></li>
<li {if $mg=='comment'}class="select"{/if}><a href="{SITE_URL}index.php?app=comment&ac=admin&mg=comment&ts=list">评论列表</a></li>
</ul>
</div>
<div style="height: 100px;"></div>
+38
View File
@@ -0,0 +1,38 @@
{php include pubTemplate("header_admin")}
<div class="midder">
{php include template("admin/menu");}
<form method="POST" action="index.php?app=comment&ac=admin&mg=options&ts=do">
<table class="table table-hover">
<tr><td width="200">APP名称:</td><td><input style="width:300px;" name="option[appname]" value="{$strOption[appname]}" /></td></tr>
<tr><td>APP介绍:</td><td><textarea style="width:300px;" name="option[appdesc]">{$strOption[appdesc]}</textarea></td></tr>
<tr><td>APP关键词:</td><td><input style="width:300px;" name="option[appkey]" value="{$strOption[appkey]}" /></td></tr>
<tr><td>评论是否审核后显示:</td>
<td>
<input type="radio" name="option[comment_isaudit]" value="0" {if $strOption['comment_isaudit']=='0'}checked="select"{/if} />不审核
<input type="radio" name="option[comment_isaudit]" value="1" {if $strOption['comment_isaudit']=='1'}checked="select"{/if} />审核
</td>
</tr>
<tr><td></td><td>
<input class="btn btn-primary" type="submit" value="提交修改" /></td>
</tr>
</table>
</form>
</div>
{php include pubTemplate("footer_admin")}
+72
View File
@@ -0,0 +1,72 @@
{php include pubTemplate("header")}
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="my_left">
{php include pubTemplate("my")}
</div>
</div>
<div class="col-md-9">
<div class="card">
<div class="card-header">我的评论</div>
<div class="card-body">
<table class="table mt-3">
<thead class="thead-light">
<tr><th>评论内容</th><th>时间</th><th>操作</th></tr>
</thead>
<tbody>
{loop $arrComment $key $item}
<tr>
<td>
<a target="_blank" href="{php echo getProjectUrl($item['ptable'],$item['pid']);}">{php echo tsDecode($item['content'])}</a></td>
<td class="text-black-50 fs12">{php echo date('Y-m-d H:i:s',$item['addtime'])}</td>
<td>
<a class="fs12 text-black-50" href="{SITE_URL}index.php?app=comment&ac=delete&commentid={$item['commentid']}">删除</a>
</td></tr>
{/loop}
<tbody>
</table>
<div class="clear"></div>
<div class="page">{$pageUrl}</div>
</div>
</div>
</div>
</div>
</div>
{php include pubTemplate("footer")}
+55
View File
@@ -0,0 +1,55 @@
{loop $arrRecomment $rkey $ritem}
<div class="recomment">
<div>
<a href="{tsUrl('user','space',array('id'=>$ritem[user][userid]))}"><img src="{$ritem[user][face]}" width="24" height="24" class="rounded-circle" align="absmiddle"></a>
<a class="c9" href="{tsUrl('user','space',array('id'=>$ritem[user][userid]))}">{$ritem[user][username]}</a>
{if $ritem['iszz']}
<span class="text-danger">作者</span>
{/if}
<span class="c9 ml-3">{$ritem['datetime']}</span>
<span class="float-right">
{if $TS_USER['userid'] && $ritem['userid']!=$TS_USER['userid']}
<a href="javascript:void('0');" onclick="commentOpen({$ritem[commentid]})">回复</a>
{/if}
{if $TS_USER['userid'] && $ritem['userid']==$TS_USER['userid']}
<a class="fs12 ml-2" href="{SITE_URL}index.php?app=comment&ac=delete&commentid={$ritem[commentid]}" onClick="return confirm('确定删除吗?')">删除</a>
{/if}
</span>
</div>
<div style="padding-left:30px;">
{if $ritem['touserid']}
<span class="text-black-50">回复 <a target="_blank" class="text-info" href="{tsUrl('user','space',array('id'=>$ritem['touserid']))}">@{$ritem['touser']['username']}</a> </span>
{/if}
{$ritem[content]}
</div>
<!----回复的回复---->
<div class="mb-2" id="rcomment_{$ritem[commentid]}" style="padding-left:30px;display:none">
<textarea class="form-control-sm w-100 border border-secondary" id="recontent_{$ritem[commentid]}" type="text" ></textarea>
<div class="mt-1">
<a class="btn btn-sm btn-outline-info" href="javascript:void(0);" onClick="recomment({$ritem[commentid]},'topic','topicid',{$ritem[pid]},'{$ritem[userid]}')" id="recomm_btn_$ritem[commentid]">提交</a>
<a class="btn btn-sm btn-outline-secondary" href="javascript:void('0');" onclick="commentOpen({$ritem['commentid']}})">取消</a>
</div>
</div>
</div>
{/loop}