@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
if($TS_APP['allowpost']==1 && $TS_USER['isadmin']==0){
|
||||
tsNotice('APP设置不允许会员发布帖子!');
|
||||
}
|
||||
|
||||
// 用户是否登录
|
||||
$userid = aac ( 'user' )->isLogin ();
|
||||
|
||||
//判断用户是否存在
|
||||
if(aac('user')->isUser($userid)==false) tsNotice('不好意思,用户不存在!');
|
||||
|
||||
//判断发布者状态
|
||||
if(aac('user')->isPublisher()==false) tsNotice('不好意思,你还没有权限发布内容!');
|
||||
|
||||
//发布时间限制
|
||||
if(aac('system')->pubTime()==false) tsNotice('不好意思,当前时间不允许发布内容!');
|
||||
|
||||
//发布时间间隔限制
|
||||
if($TS_SITE['timeblank']){
|
||||
$lastTopic = $new['topic']->find('topic',array(
|
||||
'userid'=>$userid,
|
||||
),'topicid,addtime','addtime desc');
|
||||
if($lastTopic){
|
||||
if((time()-$lastTopic['addtime'])<$TS_SITE['timeblank']){
|
||||
tsNotice('不好意思,您的内容发送频率过高!请等等再发布!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//发布内容扣除积分限制
|
||||
$strScoreOption = $new['topic']->find('user_score',array(
|
||||
'app'=>'topic',
|
||||
'action'=>'add',
|
||||
'ts'=>'do',
|
||||
));
|
||||
if($strScoreOption && $strScoreOption['status']==1){
|
||||
#用户积分数
|
||||
$strUserScore = $new['topic']->find('user_info',array(
|
||||
'userid'=>$userid,
|
||||
),'count_score');
|
||||
if($strUserScore['count_score']<$strScoreOption['score']){
|
||||
tsNotice('不好意思,您的积分不足!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$groupid = tsIntval($_GET ['groupid']);
|
||||
|
||||
// 小组数目
|
||||
$groupNum = $new ['topic']->findCount ( 'group', array (
|
||||
'groupid' => $groupid
|
||||
) );
|
||||
|
||||
if ($groupNum == 0) {
|
||||
header ( "Location: " . SITE_URL );
|
||||
exit ();
|
||||
}
|
||||
|
||||
// 小组会员
|
||||
$isGroupUser = $new ['topic']->findCount ( 'group_user', array (
|
||||
'userid' => $userid,
|
||||
'groupid' => $groupid
|
||||
) );
|
||||
|
||||
//小组信息
|
||||
$strGroup = $new ['topic']->find ( 'group', array (
|
||||
'groupid' => $groupid
|
||||
));
|
||||
$strGroup ['groupname'] = tsTitle( $strGroup ['groupname'] );
|
||||
$strGroup ['groupdesc'] = tsTitle( $strGroup ['groupdesc'] );
|
||||
|
||||
if ($strGroup ['isaudit'] == 1) {
|
||||
tsNotice ( '小组还未审核通过,不允许发帖!' );
|
||||
}
|
||||
|
||||
// 允许小组成员发帖
|
||||
if ($strGroup ['ispost'] == 0 && $isGroupUser == 0 && $userid != $strGroup ['userid']) {
|
||||
tsNotice ( "本小组只允许小组成员发贴,请加入小组后再发帖!" );
|
||||
}
|
||||
// 不允许小组成员发帖
|
||||
if ($strGroup ['ispost'] == 1 && $userid != $strGroup ['userid']) {
|
||||
tsNotice ( "本小组只允许小组组长发帖!" );
|
||||
}
|
||||
|
||||
switch ($ts) {
|
||||
|
||||
// 发布帖子
|
||||
case "" :
|
||||
|
||||
// 帖子类型
|
||||
$arrGroupType = $new ['topic']->findAll ( 'topic_type', array (
|
||||
'groupid' => $strGroup ['groupid']
|
||||
) );
|
||||
|
||||
#加载草稿箱
|
||||
$strDraft = $new['topic']->find('draft',array(
|
||||
'userid'=>$userid,
|
||||
'types'=>'topic',
|
||||
));
|
||||
|
||||
$title = '发布帖子';
|
||||
// 包含模版
|
||||
include template ( "add" );
|
||||
|
||||
break;
|
||||
|
||||
// 执行发布帖子
|
||||
case "do" :
|
||||
|
||||
#验证码验证
|
||||
$authcode = strtolower ( $_POST ['authcode'] );
|
||||
if ($TS_SITE['isauthcode']) {
|
||||
if ($authcode != $_SESSION ['verify']) {
|
||||
tsNotice ( "验证码输入有误,请重新输入!" );
|
||||
}
|
||||
}
|
||||
|
||||
#人机验证
|
||||
$vaptcha_token = tsTrim($_POST ['vaptcha_token']);
|
||||
$vaptcha_server = tsTrim($_POST['vaptcha_server']);
|
||||
if ($TS_SITE['is_vaptcha']) {
|
||||
$strVt = vaptcha($vaptcha_token,0,$vaptcha_server);
|
||||
if($strVt['success']==0) {
|
||||
tsNotice('人机验证未通过!');
|
||||
}
|
||||
}
|
||||
|
||||
$title = tsTrim( $_POST ['title'] );
|
||||
|
||||
$content = tsClean( $_POST ['content'] );
|
||||
$content2 = emptyText($_POST ['content']);
|
||||
|
||||
$typeid = tsIntval ( $_POST ['typeid'] );
|
||||
$tag = $_POST ['tag'];
|
||||
|
||||
$score = tsIntval($_POST ['score']);#积分
|
||||
|
||||
|
||||
//匿名用户
|
||||
$isniming = tsIntval($_POST['isniming']);
|
||||
if($TS_SITE['isniming']==1 && $isniming==1) $userid = aac('user')->getNimingId();
|
||||
|
||||
|
||||
// 判断一下Title是否重复
|
||||
$isTitle = $new ['topic']->findCount ( 'topic', array (
|
||||
'title' => $title
|
||||
) );
|
||||
|
||||
if ($isTitle > 0) {
|
||||
tsNotice ( '有重复标题出现哦^_^' );
|
||||
}
|
||||
|
||||
if ($TS_USER ['isadmin'] == 0) {
|
||||
$title = antiWord ( $title );
|
||||
$content = antiWord ( $content );
|
||||
$tag = antiWord ( $tag );
|
||||
}
|
||||
|
||||
$iscomment = tsIntval ( $_POST ['iscomment'] );
|
||||
$iscommentshow = tsIntval ( $_POST ['iscommentshow'] );
|
||||
|
||||
// 帖子是否需要审核
|
||||
if ($strGroup ['ispostaudit'] == 1) {
|
||||
$isaudit = 1;
|
||||
} else {
|
||||
$isaudit = 0;
|
||||
}
|
||||
|
||||
#应用后台设置发帖是否需要审核,只针对普通用户
|
||||
if($TS_APP['isaudit']==1 && $TS_USER['isadmin']==0){
|
||||
$isaudit = 1;
|
||||
}
|
||||
|
||||
|
||||
if ($title == '' || $content2 == '' || $content=='') {
|
||||
tsNotice ( '没有任何内容是不允许你通过滴^_^' );
|
||||
}
|
||||
|
||||
if($score<0){
|
||||
tsNotice ( '积分填写有误!' );
|
||||
}
|
||||
|
||||
/**
|
||||
* ******************
|
||||
*/
|
||||
// 防止用户发布重复内容,调出用户上一次发表的内容
|
||||
$strPreTopic = $new ['topic']->find ( 'topic', array (
|
||||
'userid' => $userid
|
||||
), 'topicid,title,addtime', 'addtime desc' );
|
||||
|
||||
// print_r($strPreTopic);exit;
|
||||
|
||||
|
||||
// 发帖间隔时间
|
||||
/*
|
||||
$IntervalTime = time () - $strPreTopic ['addtime'];
|
||||
// if($strPreTopic && $IntervalTime<3600){
|
||||
if ($strPreTopic) {
|
||||
similar_text ( $strPreTopic ['title'], $title, $percent );
|
||||
if ($percent >= 90) {
|
||||
$new ['topic']->update ( 'topic', array (
|
||||
'topicid' => $strPreTopic ['topicid']
|
||||
), array (
|
||||
'isaudit' => 1
|
||||
) );
|
||||
$isaudit = 1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* *****************
|
||||
*/
|
||||
|
||||
$gaiyao = cututf8(t(tsDecode($content)),0,100);
|
||||
|
||||
|
||||
$topicid = $new ['topic']->create ( 'topic', array (
|
||||
'groupid' => $groupid,
|
||||
'typeid' => $typeid,
|
||||
'userid' => $userid,
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'gaiyao'=>$gaiyao,
|
||||
'score'=>$score,
|
||||
'iscomment' => $iscomment,
|
||||
'iscommentshow' => $iscommentshow,
|
||||
'isaudit' => $isaudit,
|
||||
'addtime' => time (),
|
||||
'uptime' => time ()
|
||||
) );
|
||||
|
||||
|
||||
#清空草稿箱
|
||||
$new['topic']->delete('draft',array(
|
||||
'userid'=>$userid,
|
||||
'types'=>'topic',
|
||||
));
|
||||
|
||||
|
||||
// 统计用户发帖数
|
||||
$countUserTopic = $new ['topic']->findCount ( 'topic', array (
|
||||
'userid' => $userid
|
||||
) );
|
||||
|
||||
$new ['topic']->update ( 'user_info', array (
|
||||
'userid' => $userid
|
||||
), array (
|
||||
'count_topic' => $countUserTopic
|
||||
) );
|
||||
|
||||
// 处理@用户名
|
||||
/*
|
||||
if (preg_match_all ( '/@/', $content, $at )) {
|
||||
preg_match_all ( "/@(.+?)([\s|:]|$)/is", $content, $matches );
|
||||
|
||||
$unames = $matches [1];
|
||||
|
||||
$ns = "'" . implode ( "','", $unames ) . "'";
|
||||
|
||||
$csql = "username IN($ns)";
|
||||
|
||||
if ($unames) {
|
||||
|
||||
$query = $db->fetch_all_assoc ( "select userid,username from " . dbprefix . "user_info where $csql" );
|
||||
|
||||
foreach ( $query as $v ) {
|
||||
$content = str_replace ( '@' . $v ['username'] . '', '[@' . $v ['username'] . ':' . $v ['userid'] . ']', $content );
|
||||
$msg_content = '我在帖子中提到了你<br />去看看:' . tsUrl ( 'group', 'topic', array (
|
||||
'id' => $topicid
|
||||
) );
|
||||
aac ( 'message' )->sendmsg ( $userid, $v ['userid'], $msg_content );
|
||||
}
|
||||
$new ['topic']->update ( 'topic', array (
|
||||
'topicid' => $topicid
|
||||
), array (
|
||||
'content' => $content
|
||||
) );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// 统计帖子类型
|
||||
if ($typeid) {
|
||||
$topicTypeNum = $new ['topic']->findCount ( 'topic', array (
|
||||
'typeid' => $typeid
|
||||
) );
|
||||
|
||||
$new ['topic']->update ( 'topic_type', array (
|
||||
'typeid' => $typeid
|
||||
), array (
|
||||
'count_topic' => $topicTypeNum
|
||||
) );
|
||||
}
|
||||
// 处理标签
|
||||
aac ( 'tag' )->addTag ( 'topic', 'topicid', $topicid, $tag );
|
||||
|
||||
// 统计需要审核的帖子
|
||||
$count_topic_audit = $new ['topic']->findCount ( 'topic', array (
|
||||
'groupid' => $groupid,
|
||||
'isaudit' => '1'
|
||||
) );
|
||||
|
||||
// 统计小组下帖子数并更新
|
||||
$count_topic = $new ['topic']->findCount ( 'topic', array (
|
||||
'groupid' => $groupid
|
||||
) );
|
||||
|
||||
// 统计今天发布帖子数
|
||||
$today_start = strtotime ( date ( 'Y-m-d 00:00:00' ) );
|
||||
$today_end = strtotime ( date ( 'Y-m-d 23:59:59' ) );
|
||||
|
||||
$count_topic_today = $new ['topic']->findCount ( 'topic', "`groupid`='$groupid' and `addtime`>'$today_start' and `addtime`<'$today_end'" );
|
||||
|
||||
$new ['topic']->update ( 'group', array (
|
||||
'groupid' => $groupid
|
||||
), array (
|
||||
'count_topic' => $count_topic,
|
||||
'count_topic_audit' => $count_topic_audit,
|
||||
'count_topic_today' => $count_topic_today,
|
||||
'uptime' => time ()
|
||||
) );
|
||||
|
||||
// 对积分进行处理
|
||||
aac ( 'user' )->doScore ( $TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts'] );
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('topic','topicid',$topicid,$userid,$title,$content,0);
|
||||
|
||||
|
||||
header ( "Location: " . tsUrl('topic', 'show', array ('id' => $topicid)));
|
||||
break;
|
||||
}
|
||||
@@ -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!');
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
//基本配置
|
||||
case "":
|
||||
$strOption = getAppOptions('topic');
|
||||
|
||||
include template("admin/options");
|
||||
|
||||
break;
|
||||
|
||||
case "do":
|
||||
|
||||
$arrOption = $_POST['option'];
|
||||
|
||||
#更新app配置选项
|
||||
upAppOptions('topic',$arrOption);
|
||||
|
||||
#更新app导航和我的导航
|
||||
upAppNav('topic',$arrOption['appname']);
|
||||
|
||||
qiMsg('修改成功!');
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
|
||||
case "":
|
||||
|
||||
$ugid = tsIntval($_GET['ugid'],1);
|
||||
|
||||
$arrUg = $new['topic']->findAll('user_group',null,'ugid asc');
|
||||
|
||||
|
||||
|
||||
|
||||
include template('admin/permissions');
|
||||
|
||||
break;
|
||||
|
||||
case "do":
|
||||
|
||||
/**
|
||||
* 权限参数说明,app,action必须,其他参数可选
|
||||
* app-action-ts
|
||||
* app-action-mg-ts 当action=admin
|
||||
* app-action-api-ts 当action=api
|
||||
*/
|
||||
|
||||
$ugid = tsIntval($_POST['ugid']);
|
||||
|
||||
$arrOption = $_POST['option'];
|
||||
|
||||
aac('pubs')->upAppPermissions($ugid,'topic',$arrOption);
|
||||
|
||||
qiMsg('操作成功!');
|
||||
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
|
||||
case "list":
|
||||
|
||||
$isrecommend = tsIntval($_GET['isrecommend']);
|
||||
$istop = tsIntval($_GET['istop']);
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
$kw=tsFilter($_GET['kw']);
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = SITE_URL.'index.php?app=topic&ac=admin&mg=topic&ts=list&page=';
|
||||
$lstart = $page*10-10;
|
||||
|
||||
|
||||
$where = null;
|
||||
|
||||
if($isrecommend==1){
|
||||
$where = array(
|
||||
'isrecommend'=>1,
|
||||
);
|
||||
}
|
||||
|
||||
if($istop==1){
|
||||
$where = array(
|
||||
'istop'=>1,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if($topicid){
|
||||
$where = array(
|
||||
'topicid'=>$topicid,
|
||||
);
|
||||
}
|
||||
|
||||
if($kw){
|
||||
$where = "`title` like '%$kw%'";
|
||||
}
|
||||
|
||||
$arrTopic = $new['topic']->findAll('topic',$where,'addtime desc',null,$lstart.',10');
|
||||
|
||||
$topicNum = $new['topic']->findCount('topic',$where);
|
||||
|
||||
$pageUrl = pagination($topicNum, 10, $page, $url);
|
||||
|
||||
include template("admin/topic_list");
|
||||
|
||||
break;
|
||||
|
||||
/**
|
||||
* 删除帖子
|
||||
*/
|
||||
case "delete":
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
$strTopic = $new['topic']->getOneTopic($topicid);
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('topic','topicid',$topicid,$TS_USER['userid'],$strTopic['title'],$strTopic['content'],2);
|
||||
|
||||
$new['topic']->deleteTopic($strTopic);
|
||||
qiMsg('删除成功');
|
||||
break;
|
||||
|
||||
//帖子审核
|
||||
case "isaudit":
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($strTopic['isaudit']==0){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isaudit'=>1,
|
||||
));
|
||||
}
|
||||
|
||||
if($strTopic['isaudit']==1){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isaudit'=>0,
|
||||
));
|
||||
}
|
||||
|
||||
qiMsg('操作成功!');
|
||||
|
||||
break;
|
||||
|
||||
|
||||
//推荐
|
||||
case "isrecommend":
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($strTopic['isrecommend']==0){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isrecommend'=>1,
|
||||
));
|
||||
}
|
||||
|
||||
if($strTopic['isrecommend']==1){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isrecommend'=>0,
|
||||
));
|
||||
}
|
||||
|
||||
qiMsg('操作成功!');
|
||||
|
||||
break;
|
||||
|
||||
//置顶
|
||||
case "istop":
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($strTopic['istop']==0){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'istop'=>1,
|
||||
));
|
||||
}
|
||||
|
||||
if($strTopic['istop']==1){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'istop'=>0,
|
||||
));
|
||||
}
|
||||
|
||||
qiMsg('操作成功!');
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
//删除的帖子
|
||||
case "deletetopic":
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = SITE_URL.'index.php?app=topic&ac=admin&mg=topic&ts=deletetopic&page=';
|
||||
$lstart = $page*10-10;
|
||||
|
||||
$arrTopic = $new['topic']->findAll('topic',array('isdelete'=>'1'),'addtime desc',null,$lstart.',10');
|
||||
|
||||
$topicNum = $new['topic']->findCount('topic',array(
|
||||
'isdelete'=>'1',
|
||||
));
|
||||
|
||||
$pageUrl = pagination($topicNum, 10, $page, $url);
|
||||
|
||||
include template("admin/topic_delete");
|
||||
|
||||
break;
|
||||
|
||||
//编辑的帖子
|
||||
case "edittopic":
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = SITE_URL.'index.php?app=topic&ac=admin&mg=topic&ts=edittopic&page=';
|
||||
$lstart = $page*10-10;
|
||||
|
||||
$arrTopic = $new['topic']->findAll('topic_edit',null,'addtime desc',null,$lstart.',10');
|
||||
|
||||
$topicNum = $new['topic']->findCount('topic_edit');
|
||||
|
||||
$pageUrl = pagination($topicNum, 10, $page, $url);
|
||||
|
||||
include template("admin/topic_edit");
|
||||
|
||||
break;
|
||||
|
||||
//执行更新帖子
|
||||
case "update":
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic_edit',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'title'=>$strTopic['title'],
|
||||
'content'=>$strTopic['content'],
|
||||
));
|
||||
|
||||
$new['topic']->update('topic_edit',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isupdate'=>1,
|
||||
));
|
||||
|
||||
qiMsg('更新成功!');
|
||||
|
||||
break;
|
||||
|
||||
//查看单独某个修改的帖子
|
||||
case "editview":
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic_edit',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
include template('admin/topic_edit_view');
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
|
||||
//帖子审核
|
||||
case "topicaudit":
|
||||
|
||||
$topicid = tsIntval($_POST['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($strTopic['isaudit']==0){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isaudit'=>1,
|
||||
));
|
||||
|
||||
echo 0;exit;
|
||||
|
||||
}
|
||||
|
||||
if($strTopic['isaudit']==1){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isaudit'=>0,
|
||||
));
|
||||
|
||||
echo 1;exit;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
//帖子推荐
|
||||
case "isrecommend":
|
||||
|
||||
$userid = aac('user')->isLogin();
|
||||
|
||||
$js = tsIntval($_GET['js']);
|
||||
|
||||
$topicid = tsIntval($_POST['topicid']);
|
||||
|
||||
if($TS_USER['isadmin']==1 && $topicid){
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($strTopic['isrecommend']==1){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isrecommend'=>0,
|
||||
));
|
||||
|
||||
getJson('取消推荐成功!',$js);
|
||||
|
||||
}
|
||||
|
||||
if($strTopic['isrecommend']==0){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isrecommend'=>1,
|
||||
));
|
||||
|
||||
getJson('推荐成功!',$js);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
getJson('非法操作',$js);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* 帖子加标注
|
||||
*/
|
||||
case "book":
|
||||
|
||||
$userid = aac('user')->isLogin();
|
||||
$topicid = tsIntval($_POST['topicid']);
|
||||
$book = tsTrim($_POST['book']);
|
||||
|
||||
//if($topicid==0 || $book==''){
|
||||
if($topicid==0){
|
||||
echo 0;exit;
|
||||
}
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),'userid');
|
||||
|
||||
if($strTopic['userid']!=$userid && $TS_USER['isadmin']==0){
|
||||
echo 0;exit;
|
||||
}
|
||||
|
||||
if($TS_USER['isadmin']==1){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'label'=>$book,
|
||||
));
|
||||
}else{
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
'userid'=>$userid,
|
||||
),array(
|
||||
'label'=>$book,
|
||||
));
|
||||
}
|
||||
|
||||
echo 1;exit;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
//置顶帖子
|
||||
case "topic_istop":
|
||||
|
||||
$userid = aac('user')->isLogin();
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
$istop = $strTopic['istop'];
|
||||
|
||||
$istop == 0 ? $istop = 1 : $istop = 0;
|
||||
|
||||
$strGroup = $new['topic']->find('group',array(
|
||||
'groupid'=>$strTopic['groupid'],
|
||||
));
|
||||
|
||||
if($userid==$strGroup['userid'] || $TS_USER['isadmin']==1){
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'istop'=>$istop,
|
||||
));
|
||||
|
||||
|
||||
tsNotice("操作成功!");
|
||||
|
||||
|
||||
}else{
|
||||
tsNotice("非法操作!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//精华帖子
|
||||
case "isposts":
|
||||
|
||||
$userid = aac('user')->isLogin();
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
if($userid == 0 || $topicid == 0) tsNotice("非法操作");
|
||||
|
||||
$strTopic = $db->once_fetch_assoc("select userid,groupid,title,isposts from ".dbprefix."topic where topicid='$topicid'");
|
||||
|
||||
$strGroup = $db->once_fetch_assoc("select userid from ".dbprefix."group where groupid='".$strTopic['groupid']."'");
|
||||
|
||||
if($userid == $strGroup['userid'] || tsIntval($TS_USER['isadmin']) == 1){
|
||||
if($strTopic['isposts']==0){
|
||||
$db->query("update ".dbprefix."topic set `isposts`='1' where `topicid`='$topicid'");
|
||||
|
||||
//msg start
|
||||
$msg_userid = '0';
|
||||
$msg_touserid = $strTopic['userid'];
|
||||
$msg_content = '恭喜,你的帖子:《'.$strTopic['title'].'》被评为精华帖啦^_^ ';
|
||||
$msg_tourl = tsUrl('topic','show',array('id'=>$topicid));
|
||||
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);
|
||||
//msg end
|
||||
|
||||
}else{
|
||||
$db->query("update ".dbprefix."topic set `isposts`='0' where `topicid`='$topicid'");
|
||||
}
|
||||
|
||||
tsNotice("操作成功!");
|
||||
}else{
|
||||
tsNotice("非法操作!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -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!' );
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
echo '<pre>
|
||||
-----------------------------------------------
|
||||
Topic Http Api List
|
||||
URL:https://demo.thinksaas.cn
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
</pre>';
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
//用户是否登录
|
||||
$userid = aac('user')->isLogin();
|
||||
|
||||
//普通用户不允许删除内容
|
||||
if($TS_SITE['isallowdelete'] && $TS_USER ['isadmin'] == 0) tsNotice('系统不允许用户删除内容,请联系管理员删除!');
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
$strTopic = $new['topic']->getOneTopic($topicid);
|
||||
$strGroup = aac('group')->getOneGroup($strTopic['groupid']);
|
||||
$strGroupUser = $new['topic']->find('group_user',array(
|
||||
'userid'=>$userid,
|
||||
'groupid'=>$groupid,
|
||||
));
|
||||
|
||||
//系统管理员删除
|
||||
if($TS_USER['isadmin'] == '1'){
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('topic','topicid',$topicid,$userid,$strTopic['title'],$strTopic['content'],2);
|
||||
|
||||
$new['topic']->deleteTopic($strTopic);
|
||||
tsNotice('帖子删除成功!','点击返回小组首页',tsUrl('group'));
|
||||
}
|
||||
|
||||
//其他人员删除
|
||||
if($userid == $strTopic['userid'] || $userid == $strGroup['userid'] || $strGroupUser['isadmin']=='1'){
|
||||
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'isdelete'=>1,
|
||||
));
|
||||
|
||||
//处理积分
|
||||
aac('user')->doScore($TS_URL['app'],$TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strTopic['userid']);
|
||||
|
||||
tsNotice('你的删除帖子申请已经提交!');
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
//用户是否登录
|
||||
$userid = aac('user')->isLogin();
|
||||
|
||||
//普通不用不允许编辑内容
|
||||
if($TS_SITE['isallowedit'] && $TS_USER ['isadmin'] == 0) tsNotice('系统不允许用户编辑内容,请联系管理员编辑!');
|
||||
|
||||
switch($ts){
|
||||
|
||||
//编辑帖子
|
||||
case "":
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
if($topicid == 0){
|
||||
header("Location: ".SITE_URL);
|
||||
exit;
|
||||
}
|
||||
|
||||
$topicNum = $new['topic']->findCount('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($topicNum==0){
|
||||
header("Location: ".SITE_URL);
|
||||
exit;
|
||||
}
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
$strTopic['title'] = tsTitle($strTopic['title']);
|
||||
//$strTopic['content'] = tsDecode($strTopic['content']); //为有效防止xss攻击,如果前端通过textarea标签加载的编辑器,请注释掉本行;如果编辑器有其他的加载方式,请视情况解除本行注释。
|
||||
|
||||
$strGroup = $new['topic']->find('group',array(
|
||||
'groupid'=>$strTopic['groupid'],
|
||||
));
|
||||
|
||||
$strGroupUser = $new['topic']->find('group_user',array(
|
||||
'userid'=>$userid,
|
||||
'groupid'=>$strTopic['groupid'],
|
||||
));
|
||||
|
||||
//print_r($strGroupUser);exit;
|
||||
|
||||
if($strTopic['userid'] == $userid || $strGroup['userid']==$userid || $TS_USER['isadmin']==1 || $strGroupUser['isadmin']==1){
|
||||
$arrGroupType = $new['topic']->findAll('topic_type',array(
|
||||
'groupid'=>$strGroup['groupid'],
|
||||
));
|
||||
|
||||
//找出TAG
|
||||
$arrTags = aac('tag')->getObjTagByObjid('topic', 'topicid', $topicid);
|
||||
foreach($arrTags as $key=>$item){
|
||||
$arrTag[] = $item['tagname'];
|
||||
}
|
||||
$strTopic['tag'] = arr2str($arrTag);
|
||||
|
||||
$title = '编辑帖子';
|
||||
include template("edit");
|
||||
|
||||
}else{
|
||||
|
||||
header("Location: ".SITE_URL);
|
||||
exit;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
//编辑帖子执行
|
||||
case "do":
|
||||
|
||||
|
||||
$authcode = strtolower ( $_POST ['authcode'] );
|
||||
|
||||
if ($TS_SITE['isauthcode']) {
|
||||
if ($authcode != $_SESSION ['verify']) {
|
||||
tsNotice ( "验证码输入有误,请重新输入!" );
|
||||
}
|
||||
}
|
||||
|
||||
$topicid = tsIntval($_POST['topicid']);
|
||||
$typeid = tsIntval($_POST['typeid']);
|
||||
|
||||
$title = tsTrim($_POST['title']);
|
||||
|
||||
//echo br2nl($_POST['content']);exit;
|
||||
|
||||
$content = tsClean($_POST['content']);
|
||||
$content2 = emptyText($_POST['content']);
|
||||
|
||||
$score = tsIntval($_POST ['score']);#积分
|
||||
|
||||
$iscomment = tsIntval($_POST['iscomment']);
|
||||
$iscommentshow = tsIntval($_POST['iscommentshow']);
|
||||
|
||||
if($topicid == '' || $title=='' || $content2=='' || $content=='') tsNotice("都不能为空的哦!");
|
||||
|
||||
if($score<0){
|
||||
tsNotice ( '积分填写有误!' );
|
||||
}
|
||||
|
||||
if($TS_USER['isadmin']==0){
|
||||
|
||||
//过滤内容开始
|
||||
$title = antiWord($title);
|
||||
$content = antiWord($content);
|
||||
//过滤内容结束
|
||||
|
||||
}
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
$strGroup = $new['topic']->find('group',array(
|
||||
'groupid'=>$strTopic['groupid'],
|
||||
));
|
||||
|
||||
$strGroupUser = $new['topic']->find('group_user',array(
|
||||
'userid'=>$userid,
|
||||
'groupid'=>$strTopic['groupid'],
|
||||
));
|
||||
|
||||
if($strTopic['userid']==$userid || $strGroup['userid']==$userid || $TS_USER['isadmin']==1 || $strGroupUser['isadmin']==1){
|
||||
|
||||
$gaiyao = cututf8(t(tsDecode($content)),0,100);
|
||||
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'typeid' => $typeid,
|
||||
'title'=>$title,
|
||||
'content'=>$content,
|
||||
'gaiyao'=>$gaiyao,
|
||||
'score'=>$score,
|
||||
'iscomment' => $iscomment,
|
||||
'iscommentshow' => $iscommentshow,
|
||||
));
|
||||
|
||||
|
||||
|
||||
//处理标签
|
||||
$tag = tsTrim($_POST['tag']);
|
||||
if($tag){
|
||||
aac('tag')->delIndextag('topic','topicid',$topicid);
|
||||
aac('tag') -> addTag('topic', 'topicid', $topicid, $tag);
|
||||
}
|
||||
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('topic','topicid',$topicid,$userid,$title,$content,1);
|
||||
|
||||
|
||||
header("Location: ".tsUrl('topic','show',array('id'=>$topicid)));
|
||||
|
||||
}else{
|
||||
header("Location: ".SITE_URL);
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
$userid = aac ( 'user' )->isLogin ();
|
||||
|
||||
$arrGroupUser = $new['topic']->findAll('group_user',array(
|
||||
'userid'=>$userid,
|
||||
));
|
||||
|
||||
if($arrGroupUser==''){
|
||||
tsNotice('请加入小组后再发帖!','点击去加入小组',tsUrl('group'));
|
||||
}
|
||||
|
||||
foreach($arrGroupUser as $key=>$item){
|
||||
$arrGroup[$key] = aac('group')->getOneGroup($item['groupid']);
|
||||
}
|
||||
|
||||
$title = '选择发帖小组';
|
||||
|
||||
include template('group');
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
#最新话题
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = tsUrl ( 'topic', 'index', array ('page' => '') );
|
||||
$lstart = $page * 20 - 20;
|
||||
|
||||
$arrTopic = $new['topic']->findAll('topic',array(
|
||||
'isaudit'=>0,
|
||||
),'istop desc,uptime desc','topicid,ptable,pkey,pid,pjson,userid,groupid,title,gaiyao,score,label,count_comment,count_view,iscommentshow,istop,uptime',$lstart.',20');
|
||||
|
||||
foreach($arrTopic as $key=>$item){
|
||||
$arrTopic[$key]['title']=tsTitle($item['title']);
|
||||
$arrTopic[$key]['gaiyao']=tsTitle($item['gaiyao']);
|
||||
$arrTopic[$key]['user'] = aac('user')->getSimpleUser($item['userid']);
|
||||
$arrTopic[$key]['group'] = aac('group')->getOneGroup($item['groupid']);
|
||||
#应用扩展
|
||||
if($item['pjson']){
|
||||
$arrTopic[$key]['pjson'] = json_decode($item['pjson'],true);
|
||||
}
|
||||
}
|
||||
|
||||
$topicNum = $new ['topic']->findCount ( 'topic', array (
|
||||
'isaudit' => '0'
|
||||
) );
|
||||
|
||||
$pageUrl = pagination ( $topicNum, 20, $page, $url );
|
||||
|
||||
#推荐话题
|
||||
$arrRecommendTopic = $new['topic']->findAll('topic',array(
|
||||
'isrecommend'=>1,
|
||||
'isaudit'=>0,
|
||||
),'topicid desc','topicid,title',10);
|
||||
|
||||
#热门话题
|
||||
$arrHotTopic = $new['topic']->findAll('topic',array(
|
||||
'isaudit'=>0,
|
||||
),'count_comment desc','topicid,title',10);
|
||||
|
||||
include template('index');
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
//用户是否登录
|
||||
$userid = aac('user')->isLogin();
|
||||
|
||||
switch($ts){
|
||||
|
||||
//移动帖子
|
||||
case "":
|
||||
|
||||
$topicid = tsIntval($_GET['topicid']);
|
||||
|
||||
if($topicid == 0) tsNotice("非法操作!");
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($strTopic){
|
||||
|
||||
$strGroup = $new['topic']->find('group',array(
|
||||
'groupid'=>$strTopic['groupid'],
|
||||
));
|
||||
|
||||
if($strTopic['userid']==$userid || $strGroup['userid']==$userid || $TS_USER['isadmin']==1){
|
||||
|
||||
|
||||
if($TS_USER['isadmin']==1){
|
||||
#如果是系统管理员,就调出所有的群组
|
||||
$arrGroup = $new['topic']->findAll('group',array(
|
||||
'isaudit'=>0
|
||||
),'groupid desc','groupid,groupname');
|
||||
|
||||
}else{
|
||||
$arrGroups = $new['topic']->findAll('group_user',array(
|
||||
'userid'=>$strTopic['userid'],
|
||||
));
|
||||
foreach($arrGroups as $item){
|
||||
if($item['groupid'] != $strGroup['groupid']){
|
||||
|
||||
$arrGroup[] = $new['topic']->find('group',array(
|
||||
'groupid'=>$item['groupid'],
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$title = '移动帖子';
|
||||
include template("move");
|
||||
|
||||
}else{
|
||||
|
||||
tsNotice('非法操作!');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
tsNotice('非法操作!');
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
//执行移动
|
||||
case "do":
|
||||
|
||||
$groupid = tsIntval($_POST['groupid']);
|
||||
$topicid = tsIntval($_POST['topicid']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
if($strTopicid['userid']==$userid || $TS_USER['isadmin']==1){
|
||||
|
||||
$new['topic']->update('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),array(
|
||||
'groupid'=>$groupid,
|
||||
'typeid'=>'0',
|
||||
));
|
||||
|
||||
|
||||
header("Location: ".tsUrl('topic','show',array('id'=>$topicid)));
|
||||
}else{
|
||||
tsNotice('非法操作!');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -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!' );
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = tsUrl ( 'topic', 'my', array ('my'=>'index','page' => '' ) );
|
||||
$lstart = $page * 20 - 20;
|
||||
|
||||
$arrTopic = $new['topic']->findAll('topic',array(
|
||||
'userid'=>$strUser['userid'],
|
||||
),'addtime desc',null,$lstart.',20');
|
||||
|
||||
$topicNum = $new ['topic']->findCount ( 'topic', array (
|
||||
'userid' => $strUser['userid'],
|
||||
) );
|
||||
|
||||
$pageUrl = pagination ( $topicNum, 20, $page, $url );
|
||||
|
||||
$title = '我的帖子';
|
||||
include template('my/index');
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch ($ts){
|
||||
|
||||
case "pay":
|
||||
|
||||
$userid = tsIntval($TS_USER['userid']);
|
||||
|
||||
if($userid==0){
|
||||
getJson('请登录后再支付!',1,0);
|
||||
}
|
||||
|
||||
$topicid = tsIntval($_POST['topicid']);
|
||||
|
||||
if($topicid==0){
|
||||
getJson('帖子不存在!',1,0);
|
||||
}
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
),'topicid,userid,score');
|
||||
|
||||
if($strTopic==''){
|
||||
getJson('帖子不存在!',1,0);
|
||||
}
|
||||
|
||||
if($strTopic['userid']==$userid){
|
||||
getJson('自己无需支付阅读自己的帖子!',1,0);
|
||||
}
|
||||
|
||||
$isTopicUser = $new['topic']->findCount('topic_user',array(
|
||||
'topicid'=>$topicid,
|
||||
'userid'=>$userid,
|
||||
));
|
||||
|
||||
if($isTopicUser>0){
|
||||
getJson('你已经支付过,无需再次支付!',1,0);
|
||||
}
|
||||
|
||||
$strUserScore = $new['topic']->find('user_info',array(
|
||||
'userid'=>$userid,
|
||||
),'userid,count_score');
|
||||
|
||||
if($strUserScore['count_score']<$strTopic['score']){
|
||||
getJson('积分不足!',1,0);
|
||||
}
|
||||
|
||||
aac('user')->addScore($strTopic['userid'],'帖子收入'.$strTopic['topicid'],$strTopic['score'],1);
|
||||
aac('user')->delScore($userid,'查看帖子'.$strTopic['topicid'],$strTopic['score']);
|
||||
|
||||
$new['topic']->create('topic_user',array(
|
||||
'topicid'=>$topicid,
|
||||
'userid'=>$userid,
|
||||
'addtime'=>time(),
|
||||
));
|
||||
|
||||
|
||||
getJson('积分支付成功!',1,2,tsUrl('topic','show',array('id'=>$topicid)));
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
$topicid = tsIntval($_GET['id']);
|
||||
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$topicid,
|
||||
));
|
||||
|
||||
|
||||
if($strTopic==''){
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
header("Status: 404 Not Found");
|
||||
$title = '404';
|
||||
include pubTemplate("404");
|
||||
exit;
|
||||
}
|
||||
|
||||
#永久性跳转到其他项目
|
||||
if($strTopic['ptable'] && $strTopic['pid']){
|
||||
Header("HTTP/1.1 301 Moved Permanently");
|
||||
header('Location: '.getProjectUrl($strTopic['ptable'],$strTopic['pid']));
|
||||
exit();
|
||||
}
|
||||
|
||||
//帖子审核
|
||||
if($strTopic['isaudit']==1 && $GLOBALS['TS_USER']['isadmin']==0){
|
||||
tsNotice('内容审核中......');
|
||||
}
|
||||
|
||||
|
||||
//小组信息
|
||||
if($strTopic['groupid']){
|
||||
$strGroup = aac('group')->getOneGroup($strTopic['groupid']);
|
||||
// 判断会员是否加入该小组
|
||||
$strGroupUser = array();
|
||||
if(tsIntval($TS_USER['userid'])){
|
||||
$strGroupUser = $new['topic']->find('group_user',array(
|
||||
'userid'=>tsIntval($TS_USER['userid']),
|
||||
'groupid'=>$strTopic['groupid'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// 浏览方式
|
||||
if ($strGroup['isopen'] == '1' && $strGroupUser == '') {
|
||||
$title = $strTopic['title'];
|
||||
include template("topic_isopen");exit;
|
||||
}elseif($strGroup['isopen'] == '1' && $strGroupUser && $TS_APP['ispayjoin']==1 && $strGroupUser['endtime']!='0000-00-00' && $strGroupUser['endtime']!='1970-01-01' && $strGroupUser['endtime'] <date('Y-m-d')){
|
||||
$title = $strTopic['title'];
|
||||
include template("topic_xuqi");exit;
|
||||
}
|
||||
|
||||
$strTopic['title'] = tsTitle($strTopic['title']);
|
||||
|
||||
$tpUrl = tpPage($strTopic['content'],'topic','show',array('id'=>$topicid));
|
||||
|
||||
$strTopic['content'] = tsDecode($strTopic['content'],$tp);
|
||||
|
||||
//判断是否评论后显示帖子内容
|
||||
$isComment = $new['topic']->findCount('comment', array(
|
||||
'ptable'=>'topic',
|
||||
'pkey'=>'topicid',
|
||||
'pid' => $strTopic['topicid'],
|
||||
'userid' => tsIntval($TS_USER['userid']),
|
||||
));
|
||||
|
||||
if($strTopic['iscommentshow']==1 && $isComment==0 && $strTopic['userid']!=tsIntval($TS_USER['userid'])){
|
||||
$strTopic['content'] = '<div class="alert alert-info">你需要回复后才可以浏览帖子内容!</div>';
|
||||
}
|
||||
|
||||
|
||||
//编辑的数据
|
||||
if($strTopic['userid']==$TS_USER['userid']){
|
||||
|
||||
if($strTopic['isdelete']=='1'){
|
||||
tsNotice('你的帖子删除中...');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 帖子分类
|
||||
if ($strTopic['typeid'] != '0'){
|
||||
$strTopic['type'] = $new['topic']->find('topic_type', array(
|
||||
'typeid' => $strTopic['typeid'],
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$strTopic['content'] = @preg_replace("/\[@(.*)\:(.*)]/U","<a href='".tsUrl('user','space',array('id'=>'$2'))." ' rel=\"face\" uid=\"$2\"'>@$1</a>",$strTopic['content']);
|
||||
|
||||
|
||||
|
||||
//处理通过小程序或者客户端发的图片
|
||||
$strTopic['photos'] = $new['topic']->getTopicPhoto($topicid);
|
||||
|
||||
|
||||
|
||||
#应用扩展
|
||||
$strProject = $new['topic']->getProject($strTopic['ptable'],$strTopic['pkey'],$strTopic['pid']);
|
||||
$strTopic['video'] = $strProject['video'];
|
||||
|
||||
|
||||
|
||||
// 帖子标签
|
||||
$strTopic['tags'] = aac('tag')->getObjTagByObjid('topic', 'topicid', $topicid);
|
||||
$strTopic['user'] = aac('user')->getSimpleUser($strTopic['userid']);
|
||||
|
||||
//把标签作为关键词
|
||||
if($strTopic['tags']){
|
||||
foreach($strTopic['tags'] as $key=>$item){
|
||||
$arrTag[] = $item['tagname'];
|
||||
}
|
||||
$sitekey = arr2str($arrTag);
|
||||
}else{
|
||||
$sitekey = $strTopic['title'];
|
||||
}
|
||||
//标题
|
||||
$title = $strTopic['title'];
|
||||
|
||||
|
||||
// 评论列表开始
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = tsUrl('topic', 'show', array('id' => $topicid, 'page' => ''));
|
||||
$lstart = $page * 15-15;
|
||||
$arrComment = aac('comment')->getCommentList('topic','topicid',$strTopic['topicid'],$page,$lstart,$strTopic['userid']);
|
||||
$commentNum = aac('comment')->getCommentNum('topic','topicid',$strTopic['topicid']);
|
||||
$pageUrl = pagination($commentNum, 15, $page, $url);
|
||||
// 评论列表结束
|
||||
|
||||
|
||||
//7天内的热门帖子
|
||||
$arrHotTopic = $new['topic']->getHotTopic(7);
|
||||
|
||||
//推荐帖子
|
||||
$arrRecommendTopic = $new['topic']->getRecommendTopic();
|
||||
|
||||
|
||||
//本组热门帖子
|
||||
$arrGroupHotTopic = $new['topic']->findAll('topic',array(
|
||||
'groupid'=>$strGroup['groupid'],
|
||||
'isaudit'=>0,
|
||||
),'count_view desc','topicid,title',10);
|
||||
|
||||
// 最新帖子
|
||||
$newTopic = $new['topic']->findAll('topic',array(
|
||||
'isaudit'=>'0',
|
||||
),'addtime desc','topicid,title',10);
|
||||
|
||||
|
||||
|
||||
//判断用户可阅读帖子:0可读1不可读
|
||||
$isread = 0;
|
||||
if($strTopic['score']>0) $isread = 1;
|
||||
if($TS_USER['userid'] && $strTopic['userid']==$TS_USER['userid']) $isread=0;
|
||||
if($TS_USER['userid'] && $strTopic['userid']!=$TS_USER['userid'] && $strTopic['score']>0){
|
||||
$isTopicUser = $new['topic']->findCount('topic_user',array(
|
||||
'topicid'=>$topicid,
|
||||
'userid'=>$TS_USER['userid'],
|
||||
));
|
||||
if($isTopicUser>0) $isread=0;
|
||||
}
|
||||
if($TS_USER['isadmin']==1) $isread=0;
|
||||
|
||||
|
||||
|
||||
|
||||
$sitedesc = cututf8(t($strTopic['content']),0,100);
|
||||
|
||||
$content = $strTopic['content'];
|
||||
#钩子
|
||||
doAction('topic',$content);
|
||||
|
||||
include template('show');
|
||||
|
||||
// 增加浏览次数
|
||||
|
||||
$new['topic']->update('topic', array(
|
||||
'topicid' => $strTopic['topicid'],
|
||||
), array(
|
||||
'count_view' => $strTopic['count_view'] + 1,
|
||||
));
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
$name = urldecode(tsUrlCheck($_GET['id']));
|
||||
|
||||
//$name=mb_convert_encoding($name,'UTF-8', 'GB2312'); //针对IIS环境可能出现的问题请取消此行注释
|
||||
|
||||
$strTag = aac('tag')->getTagByName($name);
|
||||
|
||||
$strTag['tagname'] = htmlspecialchars($strTag['tagname']);
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
|
||||
$url = tsUrl('group','tag',array('id'=>urlencode($name),'page'=>''));
|
||||
|
||||
$lstart = $page*30-30;
|
||||
|
||||
$tagid = $strTag['tagid'];
|
||||
|
||||
$arrTagId = $new['topic']->findAll('tag_topic_index',array(
|
||||
'tagid'=>$tagid,
|
||||
),null,null,$lstart.',30');
|
||||
|
||||
foreach($arrTagId as $item){
|
||||
$strTopic = $new['topic']->find('topic',array(
|
||||
'topicid'=>$item['topicid'],
|
||||
));
|
||||
if($strTopic==''){
|
||||
$new['topic']->delete('tag_topic_index',array(
|
||||
'topicid'=>$item['topicid'],
|
||||
'tagid'=>$item['tagid'],
|
||||
));
|
||||
}else{
|
||||
$arrTopic[] = $strTopic;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
aac('tag')->countObjTag('topic',$tagid);
|
||||
|
||||
$topicNum = $new['topic']->findCount('tag_topic_index',array(
|
||||
'tagid'=>$tagid,
|
||||
));
|
||||
|
||||
$pageUrl = pagination($topicNum, 30, $page, $url);
|
||||
|
||||
foreach($arrTopic as $key=>$item){
|
||||
$arrTopic[$key]['title'] = htmlspecialchars($item['title']);
|
||||
$arrTopic[$key]['user'] = aac('user')->getSimpleUser($item['userid']);
|
||||
$arrTopic[$key]['group'] = aac('group')->getOneGroup($item['groupid']);
|
||||
}
|
||||
|
||||
//热门tag
|
||||
$arrTag = $new['topic']->findAll('tag',"`count_topic`>'0' and `isaudit`=0",'uptime desc',null,30);
|
||||
|
||||
$sitekey = $strTag['tagname'];
|
||||
$title = $strTag['tagname'];
|
||||
|
||||
include template("tag");
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
|
||||
$url = tsUrl('topic','tags',array('page'=>''));
|
||||
|
||||
$lstart = $page*200-200;
|
||||
|
||||
$arrTag = $new['topic']->findAll('tag',"`count_topic`>'0' and `isaudit`=0",'uptime desc',null,$lstart.',200');
|
||||
|
||||
$tagNum = $new['topic']->findCount('tag',"`count_topic`>'0' and `isaudit`=0");
|
||||
|
||||
$pageUrl = pagination($tagNum, 200, $page, $url);
|
||||
|
||||
$title = '标签';
|
||||
include template('tags');
|
||||
Reference in New Issue
Block a user