@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
//判断用户登录
|
||||
$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']){
|
||||
$lastArticle = $new['article']->find('article',array(
|
||||
'userid'=>$userid,
|
||||
),'articleid,addtime','addtime desc');
|
||||
if($lastArticle){
|
||||
if((time()-strtotime($lastArticle['addtime']))<$TS_SITE['timeblank']){
|
||||
tsNotice('不好意思,您的内容发送频率过高!请等等再发布!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//发布内容扣除积分限制
|
||||
$strScoreOption = $new['article']->find('user_score',array(
|
||||
'app'=>'article',
|
||||
'action'=>'add',
|
||||
'ts'=>'do',
|
||||
));
|
||||
if($strScoreOption && $strScoreOption['status']==1){
|
||||
#用户积分数
|
||||
$strUserScore = $new['article']->find('user_info',array(
|
||||
'userid'=>$userid,
|
||||
),'count_score');
|
||||
if($strUserScore['count_score']<$strScoreOption['score']){
|
||||
tsNotice('不好意思,您的积分不足!');
|
||||
}
|
||||
}
|
||||
|
||||
switch ($ts) {
|
||||
case "" :
|
||||
if ($TS_APP['allowpost'] == 0 && $TS_USER['isadmin'] == 0) {
|
||||
tsNotice('系统设置不允许会员发文章!');
|
||||
}
|
||||
|
||||
$cateid = tsIntval($_GET['cateid']);
|
||||
|
||||
|
||||
foreach ($arrCate as $key=>$item){
|
||||
$arrCate[$key]['two'] = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>$item['cateid'],
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
#加载草稿箱
|
||||
$strDraft = $new['article']->find('draft',array(
|
||||
'userid'=>$userid,
|
||||
'types'=>'article',
|
||||
));
|
||||
|
||||
|
||||
$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('人机验证未通过!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cateid = tsIntval($_POST['cateid']);
|
||||
$cateid2 = tsIntval($_POST['cateid2']);
|
||||
|
||||
if($cateid2) $cateid = $cateid2;
|
||||
|
||||
$title = tsTrim($_POST['title']);
|
||||
$content = tsClean($_POST['content']);
|
||||
$content2 = emptyText($_POST['content']);
|
||||
$gaiyao = tsTrim($_POST['gaiyao']);
|
||||
$tag = tsClean($_POST['tag']);
|
||||
$addtime = date('Y-m-d H:i:s');
|
||||
|
||||
$score = tsIntval($_POST ['score']);#积分
|
||||
|
||||
|
||||
//匿名用户
|
||||
$isniming = tsIntval($_POST['isniming']);
|
||||
if($TS_SITE['isniming']==1 && $isniming==1) $userid = aac('user')->getNimingId();
|
||||
|
||||
|
||||
|
||||
if (tsIntval($TS_USER['isadmin']) == 0) {
|
||||
// 过滤内容开始
|
||||
$title = antiWord($title);
|
||||
$content = antiWord($content);
|
||||
$tag = antiWord($tag);
|
||||
// 过滤内容结束
|
||||
}
|
||||
|
||||
if ($title == '' || $content2 == '' || $content=='')
|
||||
tsNotice("标题和内容都不能为空!");
|
||||
|
||||
$isTitle = $new['article']->findCount('article',array(
|
||||
'title'=>$title,
|
||||
));
|
||||
|
||||
if($isTitle){
|
||||
tsNotice("相同标题的文章已经存在!");
|
||||
}
|
||||
|
||||
if($gaiyao){
|
||||
$gaiyao = cututf8($gaiyao,0,100);
|
||||
}else{
|
||||
$gaiyao = cututf8(t(tsDecode($content)),0,100);
|
||||
}
|
||||
|
||||
if($score<0){
|
||||
tsNotice ( '积分填写有误!' );
|
||||
}
|
||||
|
||||
//1审核后显示0不审核
|
||||
if ($TS_APP['isaudit'] == 1) {
|
||||
$isaudit = 1;
|
||||
} else {
|
||||
$isaudit = 0;
|
||||
}
|
||||
|
||||
$articleid = $new['article'] -> create('article', array(
|
||||
'userid' => $userid,
|
||||
'cateid' => $cateid,
|
||||
'title' => $title,
|
||||
#'content' => $content,
|
||||
'gaiyao' => $gaiyao,
|
||||
'score'=>$score,
|
||||
'isaudit' => $isaudit,
|
||||
'addtime' => date('Y-m-d H:i:s')
|
||||
));
|
||||
|
||||
if($articleid){
|
||||
|
||||
$new['article'] -> create('article_content', array(
|
||||
'articleid' => $articleid,
|
||||
'content' => $content,
|
||||
));
|
||||
|
||||
|
||||
#清空草稿箱
|
||||
$new['article']->delete('draft',array(
|
||||
'userid'=>$userid,
|
||||
'types'=>'article',
|
||||
));
|
||||
|
||||
|
||||
// 上传图片开始
|
||||
$arrUpload = tsUpload($_FILES['photo'], $articleid, 'article', array('jpg', 'gif', 'png', 'jpeg'));
|
||||
if ($arrUpload) {
|
||||
$new['article'] -> update('article', array(
|
||||
'articleid' => $articleid
|
||||
), array(
|
||||
'path' => $arrUpload['path'],
|
||||
'photo' => $arrUpload['url']
|
||||
));
|
||||
|
||||
#生成不同尺寸的图片
|
||||
tsXimg($arrUpload['url'],'article',320,180,$arrUpload['path'],'1');
|
||||
//tsXimg($arrUpload['url'],'article',640,'',$arrUpload['path']);
|
||||
|
||||
}
|
||||
// 上传图片结束
|
||||
|
||||
// 处理标签
|
||||
aac('tag') -> addTag('article', 'articleid', $articleid, $tag);
|
||||
|
||||
|
||||
// 对积分进行处理
|
||||
if($isaudit==0){
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts']);
|
||||
}
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('article','articleid',$articleid,$userid,$title,$content,0);
|
||||
|
||||
header("Location: " . tsUrl('article', 'show', array('id' => $articleid)));
|
||||
|
||||
}else{
|
||||
|
||||
tsNotice ( '文章发布失败!' );
|
||||
|
||||
}
|
||||
|
||||
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,143 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
|
||||
case "list":
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = SITE_URL.'index.php?app=article&ac=admin&mg=article&ts=list&page=';
|
||||
$lstart = $page*20-20;
|
||||
$arrArticle = $new['article']->findAll('article',null,'addtime desc',null,$lstart.',20');
|
||||
|
||||
$articleNum = $new['article']->findCount('article');
|
||||
$pageUrl = pagination($articleNum, 20, $page, $url);
|
||||
|
||||
include template('admin/article_list');
|
||||
break;
|
||||
|
||||
//审核通过
|
||||
case "isaudit0":
|
||||
|
||||
$articleid = tsIntval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'isaudit'=>0,
|
||||
));
|
||||
|
||||
#发送系统消息
|
||||
$msg_userid = '0';
|
||||
$msg_touserid = $strArticle['userid'];
|
||||
$msg_content = '你发布的文章审核通过,快去看看吧^_^ ';
|
||||
$msg_url = tsUrl('article','show',array('id'=>$articleid));
|
||||
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_url);
|
||||
|
||||
#处理积分
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strArticle['userid']);
|
||||
|
||||
qiMsg('操作成功!');
|
||||
break;
|
||||
|
||||
#审核不通过
|
||||
case "isaudit1":
|
||||
|
||||
$articleid = tsIntval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'isaudit'=>1,
|
||||
));
|
||||
|
||||
#发送系统消息
|
||||
$msg_userid = '0';
|
||||
$msg_touserid = $strArticle['userid'];
|
||||
$msg_content = '你发布的文章审核未通过,快去看看吧^_^ ';
|
||||
$msg_url = tsUrl('article','show',array('id'=>$articleid));
|
||||
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_url);
|
||||
|
||||
#处理积分
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strArticle['userid']);
|
||||
|
||||
qiMsg('操作成功!');
|
||||
|
||||
break;
|
||||
|
||||
//删除
|
||||
case "delete":
|
||||
|
||||
$articleid = tsIntval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$new['article']->deleteArticle($strArticle);
|
||||
|
||||
#处理积分
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strArticle['userid']);
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('article','articleid',$articleid,$TS_USER['userid'],$strArticle['title'],$strArticle['content'],2);
|
||||
|
||||
qiMsg('删除成功!');
|
||||
|
||||
break;
|
||||
|
||||
//推荐
|
||||
case "isrecommend":
|
||||
|
||||
$articleid = tsIntval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
if($strArticle['isrecommend']==0){
|
||||
$isrecommend = 1;
|
||||
}else{
|
||||
$isrecommend = 0;
|
||||
}
|
||||
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'isrecommend'=>$isrecommend,
|
||||
));
|
||||
|
||||
#更新项目推荐
|
||||
aac('pubs')->upPtableRecommend('article','articleid',$articleid,$isrecommend);
|
||||
|
||||
qiMsg('操作成功!');
|
||||
break;
|
||||
|
||||
//置顶
|
||||
case "istop":
|
||||
|
||||
$articleid = tsIntval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
if($strArticle['istop']==0){
|
||||
$istop = 1;
|
||||
}else{
|
||||
$istop = 0;
|
||||
}
|
||||
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'istop'=>$istop,
|
||||
));
|
||||
|
||||
qiMsg('操作成功!');
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
//分类列表
|
||||
case "list":
|
||||
|
||||
$arrCate = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>0,
|
||||
),'orderid asc');
|
||||
|
||||
foreach($arrCate as $key=>$item){
|
||||
$arrCate[$key]['twocate'] = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>$item['cateid'],
|
||||
),'orderid asc');
|
||||
}
|
||||
|
||||
include template("admin/cate_list");
|
||||
|
||||
break;
|
||||
|
||||
//分类添加
|
||||
case "add":
|
||||
|
||||
$referid = tsIntval($_GET['referid']);
|
||||
|
||||
include template("admin/cate_add");
|
||||
|
||||
break;
|
||||
|
||||
case "add_do":
|
||||
|
||||
|
||||
|
||||
$new['article']->create('article_cate',array(
|
||||
'referid'=>tsIntval($_POST['referid']),
|
||||
'catename'=>tsTrim($_POST['catename']),
|
||||
'cateinfo'=>tsTrim($_POST['cateinfo']),
|
||||
'orderid'=>tsIntval($_POST['orderid']),
|
||||
|
||||
));
|
||||
|
||||
|
||||
header("Location: ".SITE_URL."index.php?app=article&ac=admin&mg=cate&ts=list");
|
||||
|
||||
break;
|
||||
|
||||
//分类删除
|
||||
case "del":
|
||||
|
||||
$cateid = tsIntval($_GET['cateid']);
|
||||
|
||||
|
||||
$strCate = $new['article']->find('article_cate',array(
|
||||
'cateid'=>$cateid,
|
||||
));
|
||||
|
||||
if($strCate['referid']==0){
|
||||
$arrCate = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>$strCate['cateid'],
|
||||
));
|
||||
|
||||
foreach($arrCate as $key=>$item){
|
||||
$new['article']->update('article',array(
|
||||
'cateid'=>$item['cateid']
|
||||
),array(
|
||||
'cateid'=>0,
|
||||
));
|
||||
}
|
||||
|
||||
$new['article']->delete('article_cate',array(
|
||||
'referid'=>$strCate['cateid'],
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
$new['article']->update('article',array(
|
||||
'cateid'=>$cateid
|
||||
),array(
|
||||
'cateid'=>0,
|
||||
));
|
||||
|
||||
|
||||
$new['article']->delete('article_cate',array(
|
||||
'cateid'=>$cateid,
|
||||
));
|
||||
|
||||
|
||||
|
||||
|
||||
qiMsg("分类删除成功!");
|
||||
|
||||
break;
|
||||
|
||||
//分类修改
|
||||
case "edit":
|
||||
|
||||
$cateid = tsIntval($_GET['cateid']);
|
||||
|
||||
$strCate = $new['article']->find('article_cate',array(
|
||||
'cateid'=>$cateid,
|
||||
));
|
||||
|
||||
|
||||
include template("admin/cate_edit");
|
||||
|
||||
break;
|
||||
|
||||
//分类修改执行
|
||||
case "edit_do":
|
||||
$cateid = tsIntval($_POST['cateid']);
|
||||
$catename = tsTrim($_POST['catename']);
|
||||
$cateinfo = tsTrim($_POST['cateinfo']);
|
||||
|
||||
$new['article']->update('article_cate',array(
|
||||
'cateid'=>$cateid,
|
||||
),array(
|
||||
'catename'=>$catename,
|
||||
'cateinfo'=>$cateinfo,
|
||||
'orderid'=>tsIntval($_POST['orderid']),
|
||||
));
|
||||
|
||||
header("Location: ".SITE_URL."index.php?app=article&ac=admin&mg=cate&ts=list");
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
//基本配置
|
||||
case "":
|
||||
$strOption = getAppOptions('article');
|
||||
|
||||
include template("admin/options");
|
||||
|
||||
break;
|
||||
|
||||
case "do":
|
||||
|
||||
$arrOption = $_POST['option'];
|
||||
|
||||
#更新app配置选项
|
||||
upAppOptions('article',$arrOption);
|
||||
|
||||
#更新app导航和我的导航
|
||||
upAppNav('article',$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['article']->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,'article',$arrOption);
|
||||
|
||||
qiMsg('操作成功!');
|
||||
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
|
||||
case "list":
|
||||
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = SITE_URL.'index.php?app=article&ac=admin&mg=post&ts=list&page=';
|
||||
$lstart = $page*20-20;
|
||||
$arrArticle = $new['article']->findAll('article',null,'addtime desc',null,$lstart.',20');
|
||||
|
||||
$articleNum = $new['article']->findCount('article');
|
||||
$pageUrl = pagination($articleNum, 20, $page, $url);
|
||||
|
||||
include template('admin/post_list');
|
||||
break;
|
||||
|
||||
//审核通过
|
||||
case "isaudit0":
|
||||
|
||||
$articleid = intval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'isaudit'=>0,
|
||||
));
|
||||
|
||||
#发送系统消息
|
||||
$msg_userid = '0';
|
||||
$msg_touserid = $strArticle['userid'];
|
||||
$msg_content = '你发布的文章审核通过,快去看看吧^_^ ';
|
||||
$msg_url = tsUrl('article','show',array('id'=>$articleid));
|
||||
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_url);
|
||||
|
||||
#处理积分
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'], $TS_URL['ts'],$strArticle['userid'],$TS_URL['mg']);
|
||||
|
||||
qiMsg('操作成功!');
|
||||
break;
|
||||
|
||||
#审核不通过
|
||||
case "isaudit1":
|
||||
|
||||
$articleid = intval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'isaudit'=>1,
|
||||
));
|
||||
|
||||
#发送系统消息
|
||||
$msg_userid = '0';
|
||||
$msg_touserid = $strArticle['userid'];
|
||||
$msg_content = '你发布的文章审核未通过,快去看看吧^_^ ';
|
||||
$msg_url = tsUrl('article','show',array('id'=>$articleid));
|
||||
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_url);
|
||||
|
||||
#处理积分
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'], $TS_URL['ts'],$strArticle['userid'],$TS_URL['mg']);
|
||||
|
||||
qiMsg('操作成功!');
|
||||
|
||||
break;
|
||||
|
||||
//删除
|
||||
case "delete":
|
||||
|
||||
$articleid = intval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
if($strArticle['photo']){
|
||||
unlink('uploadfile/article/'.$strArticle['photo']);
|
||||
}
|
||||
|
||||
$new['article']->delete('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$new['article']->delete('tag_article_index',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
#处理积分
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'], $TS_URL['ts'],$strArticle['userid'],$TS_URL['mg']);
|
||||
|
||||
qiMsg('删除成功!');
|
||||
|
||||
break;
|
||||
|
||||
//推荐
|
||||
case "isrecommend":
|
||||
|
||||
$articleid = intval($_GET['articleid']);
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
if($strArticle['isrecommend']==0){
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'isrecommend'=>1,
|
||||
));
|
||||
}else{
|
||||
$new['article']->update('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'isrecommend'=>0,
|
||||
));
|
||||
}
|
||||
|
||||
qiMsg('操作成功!');
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
$arrArticle = $new['news']->findAll('');
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
switch($ts){
|
||||
|
||||
/**
|
||||
* 二级分类
|
||||
*/
|
||||
case "twocate":
|
||||
|
||||
$referid = tsIntval($_GET['referid']);
|
||||
|
||||
$arrCate = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>$referid,
|
||||
));
|
||||
|
||||
echo '<select name="cateid2" class="form-control">';
|
||||
echo '<option value="0">选择二级分类</option>';
|
||||
foreach($arrCate as $key=>$item){
|
||||
echo '<option value="'.$item['cateid'].'">'.$item['catename'].'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
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,31 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
echo '<pre>
|
||||
-----------------------------------------------
|
||||
article http api list
|
||||
URL:https://demo.thinksaas.cn
|
||||
-----------------------------------------------
|
||||
/**
|
||||
* 文章列表【api接口示例】
|
||||
* index.php?app=article&ac=api&api=list
|
||||
* get
|
||||
*
|
||||
* @cateid 分类ID
|
||||
* @page
|
||||
* @limit
|
||||
*
|
||||
*/
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
-----------------------------------------------
|
||||
</pre>';
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
/**
|
||||
* 文章列表【api接口示例】
|
||||
* index.php?app=article&ac=api&api=list
|
||||
* get
|
||||
*
|
||||
* @cateid 分类ID
|
||||
* @page
|
||||
* @limit
|
||||
*
|
||||
*/
|
||||
|
||||
$arrCate1 = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>0,
|
||||
));
|
||||
foreach($arrCate1 as $key=>$item){
|
||||
$arrCate[$item['cateid']] = $item['catename'];
|
||||
}
|
||||
|
||||
$cateid = tsIntval($_GET['cateid']);
|
||||
$locationid = tsIntval($_GET['locationid']);
|
||||
|
||||
$kw = tsTrim($_GET['kw']);
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$limit = isset($_GET['limit']) ? $_GET['limit'] : '10';
|
||||
|
||||
$lstart = $limit*$page-$limit;
|
||||
|
||||
$where = "`isaudit`='0'";
|
||||
|
||||
if($cateid){
|
||||
$where .= " and `cateid`='$cateid'";
|
||||
}
|
||||
|
||||
$articleNum = $new['article']->findCount('article',$where);
|
||||
|
||||
$arrArticle = $new['article']->findAll('article',$where,'addtime desc','articleid,cateid,title,gaiyao,photo,path,count_comment,count_view,count_love,addtime',$lstart.','.$limit);
|
||||
|
||||
foreach($arrArticle as $key=>$item){
|
||||
|
||||
$arrArticle[$key]['title'] = tsTitle($item['title']);
|
||||
$arrArticle[$key]['gaiyao'] = tsTitle($item['gaiyao']);
|
||||
|
||||
if($item['photo']){
|
||||
$arrArticle[$key]['photourl'] = tsXimg($item['photo'],'article',320,180,$item['path'],'1');
|
||||
}else{
|
||||
$arrArticle[$key]['photourl'] = '';
|
||||
}
|
||||
|
||||
if($item['cateid']){
|
||||
$arrArticle[$key]['catename'] = $arrCate[$item['cateid']];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$jsonData = json_encode(array(
|
||||
|
||||
'status'=> 1,
|
||||
'msg'=> 'success',
|
||||
'data'=> array(
|
||||
|
||||
'previous'=>tsIntval($page-1),
|
||||
'page'=>tsIntval($page),
|
||||
'next'=>tsIntval($page+1),
|
||||
'total'=>tsIntval(ceil($articleNum/$limit)),
|
||||
'list'=>$arrArticle,
|
||||
|
||||
),
|
||||
|
||||
));
|
||||
|
||||
if($_GET['callback']){
|
||||
echo $_GET['callback'].'('.$jsonData.')';
|
||||
exit;
|
||||
}else{
|
||||
echo $jsonData;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
$cateid = tsIntval ( $_GET ['id'] );
|
||||
|
||||
if($cateid==0){
|
||||
ts404();
|
||||
}
|
||||
|
||||
//分类
|
||||
$strCate = $new ['article']->find ( 'article_cate', array (
|
||||
'cateid' => $cateid
|
||||
));
|
||||
|
||||
if($strCate==''){
|
||||
ts404();
|
||||
}
|
||||
|
||||
if($strCate['referid']==0){
|
||||
$arrTwoCate = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>$strCate['cateid'],
|
||||
),'orderid asc');
|
||||
|
||||
if($arrTwoCate){
|
||||
|
||||
foreach($arrTwoCate as $key=>$item){
|
||||
$arrCateId[] = $item['cateid'];
|
||||
}
|
||||
|
||||
$cateids = $cateid.','.arr2str($arrCateId);
|
||||
|
||||
$where = "`cateid` in ($cateids) and `isaudit`=0";
|
||||
|
||||
}else{
|
||||
|
||||
$where = array(
|
||||
'cateid'=>$cateid,
|
||||
'isaudit'=>0,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$arrTwoCate = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>$strCate['referid'],
|
||||
),'orderid asc');
|
||||
|
||||
$where = array(
|
||||
'cateid'=>$cateid,
|
||||
'isaudit'=>0,
|
||||
);
|
||||
}
|
||||
|
||||
// 列表
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = tsUrl ( 'article', 'cate', array ('id' => $cateid, 'page' => ''));
|
||||
$lstart = $page * 10 - 10;
|
||||
|
||||
$arrArticle = $new ['article']->findAll ( 'article',$where, 'addtime desc', 'articleid,userid,cateid,title,gaiyao,score,path,photo,count_comment,count_love,count_view,addtime', $lstart . ',10' );
|
||||
|
||||
$articleNum = $new ['article']->findCount ( 'article',$where);
|
||||
|
||||
$pageUrl = pagination ( $articleNum, 10, $page, $url );
|
||||
|
||||
foreach ( $arrArticle as $key => $item ) {
|
||||
$arrArticle [$key]['title'] = tsTitle($item['title']);
|
||||
$arrArticle [$key]['gaiyao'] = tsTitle($item['gaiyao']);
|
||||
$arrArticle [$key] ['user'] = aac ( 'user' )->getSimpleUser ( $item ['userid'] );
|
||||
$arrArticle [$key] ['cate'] = array(
|
||||
'cateid'=>$strCate['cateid'],
|
||||
'catename'=>$strCate['catename'],
|
||||
);
|
||||
|
||||
|
||||
#封面图
|
||||
if($item['photo']){
|
||||
$arrArticle[$key]['photo_url'] = $new['article']->getArticlePhoto($item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 推荐阅读
|
||||
$arrRecommend = $new ['article']->getRecommendArticle ();
|
||||
|
||||
// 一周热门
|
||||
$arrHot7 = $new ['article']->getHotArticle ( 7);
|
||||
// 一月热门
|
||||
$arrHot30 = $new ['article']->getHotArticle ( 30 );
|
||||
|
||||
$title = $strCate ['catename'];
|
||||
|
||||
// SEO优化
|
||||
$sitekey = $strCate ['catename'];
|
||||
$sitedesc = $strCate ['catename'] . ' - 文章';
|
||||
|
||||
include template ( 'index' );
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
// 用户是否登录
|
||||
$userid = aac ( 'user' )->isLogin ();
|
||||
|
||||
switch ($ts) {
|
||||
|
||||
case "do" :
|
||||
|
||||
$articleid = intval ( $_POST ['articleid'] );
|
||||
$content = tsClean ( $_POST ['content'] );
|
||||
$content2 = emptyText( $_POST ['content'] );
|
||||
|
||||
if ($content2 == '') tsNotice ( "内容不能为空!" );
|
||||
|
||||
// 过滤内容开始
|
||||
aac ( 'system' )->antiWord ( $content );
|
||||
// 过滤内容结束
|
||||
|
||||
$new ['article']->create ( 'article_comment', array (
|
||||
'articleid' => $articleid,
|
||||
'userid' => $userid,
|
||||
'content' => $content,
|
||||
'addtime' => time ()
|
||||
)
|
||||
);
|
||||
|
||||
// 统计
|
||||
$count_comment = $new ['article']->findCount ( 'article_comment', array (
|
||||
'articleid' => $articleid
|
||||
) );
|
||||
|
||||
$new ['article']->update ( 'article', array (
|
||||
'articleid' => $articleid
|
||||
), array (
|
||||
'count_comment' => $count_comment
|
||||
) );
|
||||
|
||||
header ( "Location: " . tsUrl ( 'article', 'show', array (
|
||||
'id' => $articleid
|
||||
) ) );
|
||||
|
||||
break;
|
||||
|
||||
case "delete" :
|
||||
|
||||
$commentid = intval ( $_GET ['commentid'] );
|
||||
|
||||
$strComment = $new ['article']->find ( 'article_comment', array (
|
||||
'commentid' => $commentid
|
||||
) );
|
||||
|
||||
$strArticle = $new ['article']->find ( 'article', array (
|
||||
'articleid' => $strComment ['articleid']
|
||||
) );
|
||||
|
||||
if ($userid == $strArticle ['userid'] || $TS_USER ['isadmin'] == 1) {
|
||||
|
||||
$new ['article']->delete ( 'article_comment', array (
|
||||
'commentid' => $commentid
|
||||
));
|
||||
|
||||
//处理积分
|
||||
aac('user')->doScore($GLOBALS['TS_URL']['app'], $GLOBALS['TS_URL']['ac'], $GLOBALS['TS_URL']['ts'],$strComment['userid']);
|
||||
|
||||
tsNotice ( '删除成功' );
|
||||
} else {
|
||||
|
||||
tsNotice ( '非法操作' );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
// 分类
|
||||
$arrCate = $new ['article']->findAll ( 'article_cate',array(
|
||||
'referid'=>0,
|
||||
),'orderid asc');
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
$userid = aac ( 'user' )->isLogin ();
|
||||
|
||||
$articleid = tsIntval ( $_GET ['articleid'] );
|
||||
|
||||
$strArticle = $new ['article']->find ( 'article', array (
|
||||
'articleid' => $articleid
|
||||
) );
|
||||
|
||||
//普通用户不允许删除内容
|
||||
if($TS_SITE['isallowdelete'] && $TS_USER ['isadmin'] == 0) tsNotice('系统不允许用户删除内容,请联系管理员删除!');
|
||||
|
||||
if ($strArticle ['userid'] == $userid || $TS_USER ['isadmin'] == 1) {
|
||||
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('article','articleid',$articleid,$userid,$strArticle['title'],$strArticle['content'],2);
|
||||
|
||||
|
||||
#删除文章
|
||||
$new['article']->deleteArticle($strArticle);
|
||||
|
||||
if($strArticle['isaudit']==0){
|
||||
#对积分进行处理
|
||||
aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strArticle ['userid']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tsNotice('删除成功','点击返回文章首页',tsUrl ( 'article' ));
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
// 用户是否登录
|
||||
$userid = aac ( 'user' )->isLogin ();
|
||||
|
||||
//普通不用不允许编辑内容
|
||||
if($TS_SITE['isallowedit'] && $TS_USER ['isadmin'] == 0) tsNotice('系统不允许用户编辑内容,请联系管理员编辑!');
|
||||
|
||||
switch ($ts) {
|
||||
|
||||
case "" :
|
||||
|
||||
$articleid = tsIntval ( $_GET ['articleid'] );
|
||||
|
||||
$cateid = tsIntval ( $_GET ['cateid'] );
|
||||
|
||||
$strArticle = $new ['article']->find ( 'article', array (
|
||||
'articleid' => $articleid
|
||||
) );
|
||||
|
||||
if ($strArticle ['userid'] == $userid || $TS_USER ['isadmin'] == 1) {
|
||||
|
||||
$strArticle['title'] = tsTitle($strArticle['title']);
|
||||
|
||||
$articleContent = $new['article']->find('article_content',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$strArticle['content'] = $articleContent['content'];
|
||||
|
||||
//$strArticle['content'] = tsDecode($strArticle['content']); //为有效防止xss攻击,如果前端通过textarea标签加载的编辑器,请注释掉本行;如果编辑器有其他的加载方式,请视情况解除本行注释。
|
||||
$strArticle['gaiyao'] = tsTitle($strArticle['gaiyao']);
|
||||
|
||||
#封面图
|
||||
$strArticle['photo_url'] = $new['article']->getArticlePhoto($strArticle);
|
||||
|
||||
// 找出TAG
|
||||
$arrTags = aac ( 'tag' )->getObjTagByObjid ( 'article', 'articleid', $articleid );
|
||||
foreach ( $arrTags as $key => $item ) {
|
||||
$arrTag [] = $item ['tagname'];
|
||||
}
|
||||
$strArticle ['tag'] = arr2str ( $arrTag );
|
||||
|
||||
foreach ($arrCate as $key=>$item){
|
||||
$arrCate[$key]['two'] = $new['article']->findAll('article_cate',array(
|
||||
'referid'=>$item['cateid'],
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$title = '修改文章';
|
||||
include template ( 'edit' );
|
||||
} else {
|
||||
|
||||
tsNotice ( '非法操作!' );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "do" :
|
||||
|
||||
$articleid = tsIntval ( $_POST ['articleid'] );
|
||||
|
||||
$strArticle = $new ['article']->find ( 'article', array (
|
||||
'articleid' => $articleid
|
||||
) );
|
||||
|
||||
if($strArticle['userid']!=$userid && $TS_USER['isadmin']==0){
|
||||
tsNotice('非法操作!');
|
||||
}
|
||||
|
||||
$cateid = tsIntval ( $_POST ['cateid'] );
|
||||
$cateid2 = tsIntval ( $_POST ['cateid2'] );
|
||||
|
||||
if($cateid2) $cateid = $cateid2;
|
||||
|
||||
$title = trim ( $_POST ['title'] );
|
||||
$content = tsClean ( $_POST ['content'] );
|
||||
$content2 = emptyText ( $_POST ['content'] );
|
||||
$gaiyao = trim ( $_POST ['gaiyao'] );
|
||||
|
||||
$re_gaiyao = tsIntval ( $_POST ['re_gaiyao'] );
|
||||
|
||||
$score = tsIntval($_POST ['score']);#积分
|
||||
|
||||
if ($TS_USER ['isadmin'] == 0) {
|
||||
// 过滤内容开始
|
||||
$title = antiWord ( $title );
|
||||
$content = antiWord ( $content );
|
||||
// 过滤内容结束
|
||||
}
|
||||
|
||||
if ($title == '' || $content2 == '' || $content=='')
|
||||
qiMsg ( "标题和内容都不能为空!" );
|
||||
|
||||
if($score<0){
|
||||
tsNotice ( '积分填写有误!' );
|
||||
}
|
||||
|
||||
if($re_gaiyao==1){
|
||||
$gaiyao = cututf8(t(tsDecode($content)),0,100);
|
||||
}
|
||||
|
||||
$new ['article']->update ( 'article', array (
|
||||
'articleid' => $articleid,
|
||||
), array (
|
||||
'title' => $title,
|
||||
'gaiyao' => $gaiyao,
|
||||
'score'=>$score,
|
||||
));
|
||||
|
||||
$new['article']->replace('article_content',array(
|
||||
'articleid'=>$articleid,
|
||||
),array(
|
||||
'articleid'=>$articleid,
|
||||
'content'=>$content,
|
||||
));
|
||||
|
||||
#更新分类
|
||||
if($cateid){
|
||||
$new['article']->update('article',array(
|
||||
'articleid' => $articleid,
|
||||
),array(
|
||||
'cateid' => $cateid,
|
||||
));
|
||||
}
|
||||
|
||||
// 处理标签
|
||||
$tag = trim ( $_POST ['tag'] );
|
||||
if ($tag) {
|
||||
aac ( 'tag' )->delIndextag ( 'article', 'articleid', $articleid );
|
||||
aac ( 'tag' )->addTag ( 'article', 'articleid', $articleid, $tag );
|
||||
}
|
||||
|
||||
$pjson = '';
|
||||
if($strArticle['photo']){
|
||||
$pjson = json_encode(array(
|
||||
tsXimg($strArticle['photo'],'article',320,180,$strArticle['path'],1)
|
||||
));
|
||||
}
|
||||
|
||||
// 上传封面图片
|
||||
$arrUpload = tsUpload ( $_FILES ['photo'], $articleid, 'article', array ('jpg','gif','png','jpeg' ) );
|
||||
if ($arrUpload) {
|
||||
$new ['article']->update ( 'article', array (
|
||||
'articleid' => $articleid
|
||||
), array (
|
||||
'path' => $arrUpload ['path'],
|
||||
'photo' => $arrUpload ['url'],
|
||||
'uptime'=>time(),
|
||||
) );
|
||||
|
||||
#生成不同尺寸的图片
|
||||
tsDimg ($arrUpload ['url'], 'article', '320', '180', $arrUpload ['path']);
|
||||
|
||||
$pjson = json_encode(array(
|
||||
tsXimg($arrUpload['url'],'article',320,180,$arrUpload['path'],1)
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
#更新ptable
|
||||
aac('pubs')->editPtable('article','articleid',$articleid,$pjson,$title,$gaiyao);
|
||||
|
||||
|
||||
#用户记录
|
||||
aac('pubs')->addLogs('article','articleid',$articleid,$userid,$title,$content,1);
|
||||
|
||||
|
||||
header ("Location: " . tsUrl ( 'article', 'show', array ('id' => $articleid)));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
$cateid = 0;
|
||||
|
||||
// 列表
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = tsUrl ( 'article', 'index', array ('page' => '') );
|
||||
$lstart = $page * 10 - 10;
|
||||
|
||||
$arrArticle = $new ['article']->findAll ( 'article', array (
|
||||
'isaudit' => '0'
|
||||
), 'istop desc,addtime desc', 'articleid,userid,cateid,title,gaiyao,score,path,photo,count_comment,count_love,count_view,istop,addtime,uptime', $lstart . ',10' );
|
||||
|
||||
$articleNum = $new ['article']->findCount ( 'article', array (
|
||||
'isaudit' => '0'
|
||||
) );
|
||||
|
||||
$pageUrl = pagination ( $articleNum, 10, $page, $url );
|
||||
|
||||
foreach ( $arrArticle as $key => $item ) {
|
||||
$arrArticle [$key]['title'] = tsTitle($item['title']);
|
||||
$arrArticle [$key]['gaiyao'] = tsTitle($item['gaiyao']);
|
||||
$arrArticle [$key] ['user'] = aac ( 'user' )->getSimpleUser( $item ['userid'] );
|
||||
$arrArticle [$key] ['cate'] = $new ['article']->find( 'article_cate', array (
|
||||
'cateid' => $item ['cateid']
|
||||
) );
|
||||
|
||||
#封面图
|
||||
if($item['photo']){
|
||||
$arrArticle[$key]['photo_url'] = $new['article']->getArticlePhoto($item);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 推荐阅读
|
||||
$arrRecommend = $new ['article']->getRecommendArticle ();
|
||||
|
||||
// 一周热门
|
||||
$arrHot7 = $new ['article']->getHotArticle ( 7 );
|
||||
// 一月热门
|
||||
$arrHot30 = $new ['article']->getHotArticle ( 30 );
|
||||
|
||||
|
||||
$sitekey = $TS_APP['appkey'];
|
||||
$sitedesc = $TS_APP['appdesc'];
|
||||
$title = '文章';
|
||||
|
||||
include template ( 'index' );
|
||||
@@ -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,6 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
$userid = aac('user')->isLogin();
|
||||
|
||||
$strUser = aac('user')->getOneUser($userid);
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = tsUrl ( 'article', 'my', array ('my'=>'index','page' => '' ) );
|
||||
$lstart = $page * 20 - 20;
|
||||
|
||||
$arrArticle = $new ['article']->findAll ( 'article', array (
|
||||
'userid' => $strUser['userid'],
|
||||
), 'addtime desc', null, $lstart . ',20' );
|
||||
|
||||
$articleNum = $new ['article']->findCount ( 'article', array (
|
||||
'userid' => $strUser['userid'],
|
||||
) );
|
||||
|
||||
$pageUrl = pagination ( $articleNum, 20, $page, $url );
|
||||
|
||||
|
||||
|
||||
$title = '我的文章';
|
||||
include template('my/index');
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
$userid = intval ( $TS_USER ['userid'] );
|
||||
|
||||
if ($userid == 0) {
|
||||
echo 0;
|
||||
exit ();
|
||||
}
|
||||
|
||||
$articleid = intval ( $_POST ['articleid'] );
|
||||
|
||||
$isRecommend = $new ['article']->findCount ( 'article_recommend', array (
|
||||
'articleid' => $articleid,
|
||||
'userid' => $userid
|
||||
) );
|
||||
|
||||
if ($isRecommend > 0) {
|
||||
echo 1;
|
||||
exit ();
|
||||
}
|
||||
|
||||
$new ['article']->create ( 'article_recommend', array (
|
||||
'articleid' => $articleid,
|
||||
'userid' => $userid
|
||||
) );
|
||||
|
||||
$count_recommend = $new ['article']->findCount ( 'article_recommend', array (
|
||||
'articleid' => $articleid
|
||||
) );
|
||||
|
||||
$new ['article']->update ( 'article', array (
|
||||
'articleid' => $articleid
|
||||
), array (
|
||||
'count_recommend' => $count_recommend
|
||||
) );
|
||||
|
||||
echo 2;
|
||||
exit ();
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2019/6/15
|
||||
* Time: 23:28
|
||||
*/
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch ($ts){
|
||||
|
||||
case "pay":
|
||||
|
||||
$userid = tsIntval($TS_USER['userid']);
|
||||
|
||||
if($userid==0){
|
||||
getJson('请登录后再支付!',1,0);
|
||||
}
|
||||
|
||||
$articleid = tsIntval($_POST['articleid']);
|
||||
|
||||
if($articleid==0){
|
||||
getJson('文章不存在!',1,0);
|
||||
}
|
||||
|
||||
$strArticle = $new['article']->find('article',array(
|
||||
'articleid'=>$articleid,
|
||||
),'articleid,userid,score');
|
||||
|
||||
if($strArticle==''){
|
||||
getJson('文章不存在!',1,0);
|
||||
}
|
||||
|
||||
if($strArticle['userid']==$userid){
|
||||
getJson('自己无需支付阅读自己的文章!',1,0);
|
||||
}
|
||||
|
||||
$isArticleUser = $new['article']->findCount('article_user',array(
|
||||
'articleid'=>$articleid,
|
||||
'userid'=>$userid,
|
||||
));
|
||||
|
||||
if($isArticleUser>0){
|
||||
getJson('你已经支付过,无需再次支付!',1,0);
|
||||
}
|
||||
|
||||
$strUserScore = $new['article']->find('user_info',array(
|
||||
'userid'=>$userid,
|
||||
),'userid,count_score');
|
||||
|
||||
if($strUserScore['count_score']<$strArticle['score']){
|
||||
getJson('积分不足!',1,0);
|
||||
}
|
||||
|
||||
aac('user')->addScore($strArticle['userid'],'文章收入'.$strArticle['articleid'],$strArticle['score'],1);
|
||||
aac('user')->delScore($userid,'查看文章'.$strArticle['articleid'],$strArticle['score']);
|
||||
|
||||
$new['article']->create('article_user',array(
|
||||
'articleid'=>$articleid,
|
||||
'userid'=>$userid,
|
||||
'addtime'=>time(),
|
||||
));
|
||||
|
||||
|
||||
getJson('积分支付成功!',1,2,tsUrl('article','show',array('id'=>$articleid)));
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
$articleid = tsIntval($_GET ['id']);
|
||||
|
||||
$strArticle = $new ['article']->find ( 'article', array (
|
||||
'articleid' => $articleid
|
||||
));
|
||||
|
||||
if ($strArticle == '') {
|
||||
ts404();
|
||||
}
|
||||
|
||||
// 是否审核
|
||||
if ($strArticle ['isaudit'] == 1 && $TS_USER['isadmin']==0 && $TS_USER['userid']!=$strArticle['userid']) {
|
||||
tsNotice ( '内容审核中...' );
|
||||
}
|
||||
|
||||
$cateid = $strArticle['cateid'];
|
||||
|
||||
$strArticle['title'] = tsTitle($strArticle['title']);
|
||||
|
||||
$articleContent = $new['article']->find('article_content',array(
|
||||
'articleid'=>$articleid,
|
||||
));
|
||||
|
||||
$strArticle['content'] = tsDecode($articleContent['content']);
|
||||
|
||||
$strArticle ['tags'] = aac ( 'tag' )->getObjTagByObjid ( 'article', 'articleid', $articleid );
|
||||
$strArticle ['user'] = aac ( 'user' )->getSimpleUser ( $strArticle ['userid'] );
|
||||
$strArticle ['cate'] = $new ['article']->find ( 'article_cate', array (
|
||||
'cateid' => $strArticle ['cateid']
|
||||
) );
|
||||
|
||||
|
||||
// 上一篇
|
||||
$strUp = $new['article']->find('article', "`articleid`< '$articleid' and `isaudit`='0'", 'articleid,title','articleid desc');
|
||||
if($strUp) $strUp['title'] = tsTitle($strUp['title']);
|
||||
// 下一篇
|
||||
$strNext = $new['article']->find('article', "`articleid`> '$articleid' and `isaudit`='0'", 'articleid,title','articleid asc');
|
||||
if($strNext) $strNext['title'] = tsTitle($strNext['title']);
|
||||
|
||||
|
||||
|
||||
// 获取评论
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
$url = tsUrl ('article','show', array ('id' => $articleid,'page'=>''));
|
||||
$lstart = $page * 15 - 15;
|
||||
$arrComment = aac('comment')->getCommentList('article','articleid',$strArticle['articleid'],$page,$lstart,$strArticle['userid']);
|
||||
$commentNum = aac('comment')->getCommentNum('article','articleid',$strArticle['articleid']);
|
||||
$pageUrl = pagination ( $commentNum, 15, $page, $url );
|
||||
|
||||
// 标签
|
||||
$strArticle ['tags'] = aac ( 'tag' )->getObjTagByObjid ( 'article', 'articleid', $strArticle ['articleid'] );
|
||||
|
||||
//最新文章
|
||||
$arrArticle = $new ['article']->findAll ( 'article', array(
|
||||
'isaudit'=>0,
|
||||
), 'addtime desc', 'articleid,title', 10 );
|
||||
|
||||
// 推荐阅读
|
||||
$arrRecommend = $new ['article']->getRecommendArticle ();
|
||||
|
||||
// 一周热门
|
||||
$arrHot7 = $new ['article']->getHotArticle ( 7);
|
||||
// 一月热门
|
||||
$arrHot30 = $new ['article']->getHotArticle ( 30);
|
||||
|
||||
|
||||
|
||||
//判断用户可阅读文章:0可读1不可读
|
||||
$isread = 0;
|
||||
if($strArticle['score']>0) $isread = 1;
|
||||
if($TS_USER['userid'] && $strArticle['userid']==$TS_USER['userid']) $isread=0;
|
||||
if($TS_USER['userid'] && $strArticle['userid']!=$TS_USER['userid'] && $strArticle['score']>0){
|
||||
$isArticleUser = $new['article']->findCount('article_user',array(
|
||||
'articleid'=>$articleid,
|
||||
'userid'=>$TS_USER['userid'],
|
||||
));
|
||||
if($isArticleUser>0) $isread=0;
|
||||
}
|
||||
if($TS_USER['isadmin']==1) $isread=0;
|
||||
|
||||
|
||||
|
||||
|
||||
//把标签作为关键词
|
||||
if($strArticle['tags']){
|
||||
foreach($strArticle['tags'] as $key=>$item){
|
||||
$arrTag[] = $item['tagname'];
|
||||
}
|
||||
$sitekey = arr2str($arrTag);
|
||||
}else{
|
||||
$sitekey = $strArticle['title'];
|
||||
}
|
||||
|
||||
$sitedesc = cututf8(t($strArticle['content']),0,100);
|
||||
|
||||
$title = $strArticle ['title'];
|
||||
|
||||
include template ( 'show' );
|
||||
|
||||
// 统计查看次数
|
||||
$count_view = $strArticle ['count_view'] + 1;
|
||||
$new ['article']->update ('article', array(
|
||||
'articleid' => $strArticle ['articleid']
|
||||
), array (
|
||||
'count_view' => $count_view,
|
||||
));
|
||||
|
||||
#更新ptable
|
||||
aac('pubs')->upPtableView('article','articleid',$articleid,$count_view);
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
|
||||
$name = urldecode(tsUrlCheck($_GET['id']));
|
||||
|
||||
$strTag = aac('tag')->getTagByName($name);
|
||||
|
||||
$strTag ['tagname'] = htmlspecialchars ( $strTag ['tagname'] );
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
|
||||
$url = tsUrl ( 'article', 'tag', array (
|
||||
'id' => urlencode ( $name ),
|
||||
'page' => ''
|
||||
) );
|
||||
|
||||
$lstart = $page * 30 - 30;
|
||||
|
||||
$tagid = $strTag['tagid'];
|
||||
|
||||
$arrTagId = $new ['article']->findAll ( 'tag_article_index', array (
|
||||
'tagid' => $tagid
|
||||
), null, null, $lstart . ',30' );
|
||||
|
||||
foreach ( $arrTagId as $item ) {
|
||||
$strArticle = $new ['article']->find ( 'article', array (
|
||||
'articleid' => $item ['articleid']
|
||||
) );
|
||||
if ($strArticle == '') {
|
||||
$new ['article']->delete ( 'tag_article_index', array (
|
||||
'articleid' => $item ['articleid'],
|
||||
'tagid' => $item ['tagid']
|
||||
) );
|
||||
}
|
||||
|
||||
if ($strArticle && $strArticle['isaudit']==0) {
|
||||
$arrArticle [] = $strArticle;
|
||||
}
|
||||
}
|
||||
|
||||
aac ( 'tag' )->countObjTag ( 'article', $tagid );
|
||||
|
||||
$articleNum = $new ['article']->findCount ( 'tag_article_index', array (
|
||||
'tagid' => $tagid
|
||||
) );
|
||||
|
||||
$pageUrl = pagination ( $articleNum, 30, $page, $url );
|
||||
|
||||
foreach ( $arrArticle as $key => $item ) {
|
||||
$arrArticle [$key] ['title'] = htmlspecialchars ( $item ['title'] );
|
||||
$arrArticle [$key] ['content'] = cututf8 ( t ( $item ['content'] ), 0, 150 );
|
||||
$arrArticle [$key] ['user'] = aac ( 'user' )->getSimpleUser ( $item ['userid'] );
|
||||
$arrArticle [$key] ['cate'] = $new ['article']->find ( 'article_cate', array (
|
||||
'cateid' => $item ['cateid']
|
||||
) );
|
||||
}
|
||||
|
||||
// 热门tag
|
||||
$arrTag = $new ['article']->findAll ( 'tag', "`count_article`>'0' and `isaudit`=0", 'count_article desc', null, 30 );
|
||||
|
||||
$sitekey = $strTag ['tagname'];
|
||||
$title = $strTag ['tagname'];
|
||||
|
||||
include template ( "tag" );
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
|
||||
$url = tsUrl ( 'article', 'tags', array (
|
||||
'page' => ''
|
||||
) );
|
||||
|
||||
$lstart = $page * 200 - 200;
|
||||
|
||||
$arrTag = $new ['article']->findAll ( 'tag', "`count_article`>'0' and `isaudit`=0", null, null, $lstart . ',200' );
|
||||
|
||||
$tagNum = $new ['article']->findCount ( 'tag', "`count_article`>'0' and `isaudit`=0" );
|
||||
|
||||
$pageUrl = pagination ( $tagNum, 200, $page, $url );
|
||||
|
||||
$title = '标签';
|
||||
include template ( 'tags' );
|
||||
Reference in New Issue
Block a user