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
+192
View File
@@ -0,0 +1,192 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//某一个attach
case "":
$albumid = isset($_GET['id']) ? intval($_GET['id']) : '0';
$strAlbum = $new['attach']->find('attach_album',array(
'albumid'=>$albumid,
));
//404
if($albumid!=0)
{
if($strAlbum==''){
header("HTTP/1.1 404 Not Found");
header("Status: 404 Not Found");
$title = '404';
include pubTemplate("404");
exit;
if($strAlbum['isaudit']==1){
tsNotice('内容审核中...');
}
}
}
$strAlbum['albumname'] = tsTitle($strAlbum['albumname']);
$strAlbum['albumdesc'] = tsTitle($strAlbum['albumdesc']);
$page = isset($_GET['page']) ? intval($_GET['page']) : '1';
$url = tsUrl('attach','album',array('id'=>$albumid,'page'=>''));
$lstart = $page*24-24;
$strUser = aac('user')->getSimpleUser($strAlbum['userid']);
if($albumid!=0)
{
$arrattach = $new['attach']->findAll('attach',array(
'albumid'=>$albumid,
),'attachid desc',null,$lstart.',24');
$attachNum = $new['attach']->findCount('attach',array(
'albumid'=>$albumid,
));
}else
{
$userid = aac('user')->isLogin();
$arrattach = $new['attach']->findAll('attach',array(
'userid'=>$userid,
'albumid'=>0,
),'attachid desc',null,$lstart.',24');
$attachNum = $new['attach']->findCount('attach',array(
'userid'=>$userid,
));
$strAlbum['albumname']="个人附件库";
$strAlbum['userid']=$userid;
}
foreach($arrattach as $key=>$item){
$arrattach[$key]['attachdesc'] = tsTitle($item['attachdesc']);
}
$pageUrl = pagination($attachNum, 24, $page, $url);
$title = $strAlbum['albumname'];
include template("album");
$new['attach']->update('attach_album',array(
'albumid'=>$strAlbum['albumid'],
),array(
'count_view'=>$strAlbum['count_view']+1,
));
break;
//修改attach
case "edit":
//用户是否登录
$userid = aac('user')->isLogin();
$albumid = intval($_GET['albumid']);
$strAlbum = $new['attach']->find('attach_album',array(
'albumid'=>$albumid,
));
if($strAlbum['userid'] == $userid || $TS_USER['isadmin']==1) {
$strAlbum['albumname'] = tsTitle($strAlbum['albumname']);
$strAlbum['albumdesc'] = tsTitle($strAlbum['albumdesc']);
$title = '修改attach属性-'.$strAlbum['albumname'];
include template("album_edit");
}else{
tsNotice('非法操作!');
}
break;
case "editdo":
//用户是否登录
$userid = aac('user')->isLogin();
$albumid = intval($_POST['albumid']);
$strAlbum = $new['attach']->find('attach_album',array(
'albumid'=>$albumid,
));
if($strAlbum['userid']==$userid || $TS_USER['isadmin']==1){
$albumname = trim($_POST['albumname']);
if($albumname == '') qiMsg("attach名称不能为空!");
$albumdesc = trim($_POST['albumdesc']);
if($TS_USER['isadmin']==0){
//过滤内容开始
aac('system')->antiWord($albumname);
aac('system')->antiWord($albumdesc);
//过滤内容结束
}
$new['attach']->update('attach_album',array(
'userid'=>$strAlbum['userid'],
'albumid'=>$strAlbum['albumid'],
),array(
'albumname'=>$albumname,
'albumdesc'=>$albumdesc,
));
header("Location: ".tsUrl('attach','album',array('id'=>$albumid)));
}else{
tsNotice('非法操作!');
}
break;
//删除attach
case "del":
//用户是否登录
$userid = aac('user')->isLogin();
$albumid = intval($_GET['albumid']);
$strAlbum = $new['attach']->find('attach_album',array(
'albumid'=>$albumid,
));
if($strAlbum['userid'] == $userid || $TS_USER['isadmin'] == 1) {
$new['attach']->delete('attach_album',array(
'albumid'=>$albumid,
));
$new['attach']->delete('attach',array(
'albumid'=>$albumid,
));
}
header("Location: ".tsUrl('attach'));
break;
}
+92
View File
@@ -0,0 +1,92 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户是否登录
$userid = aac('user')->isLogin($js,$userkey);
switch($ts){
case "do":
$authcode = strtolower($_POST['authcode']);
if ($TS_SITE ['isauthcode']) {
if ($authcode != $_SESSION ['verify']) {
getJson ( "验证码输入有误,请重新输入!" ,$js,0);
}
}
$attachid = intval($_POST['attachid']);
$content = tsClean($_POST['content'],$js);
$content2 = emptyText($_POST['content']);//测试空内容
$ispublic = intval($_POST['ispublic']);
//过滤内容开始
if($TS_USER['isadmin']==0){
aac('system')->antiWord($content,$js);
}
//过滤内容结束
if($content2==''){
getJson('没有任何内容是不允许你通过滴^_^',$js);
}else{
$commentid = $new['attach']->create('attach_comment',array(
'attachid' => $attachid,
'userid' => $userid,
'content' => $content,
'addtime'=> time(),
));
//发送系统消息(通知楼主有人回复他的帖子啦)
$strattach = $new['attach']->find('attach',array(
'attachid'=>$attachid,
));
if($strattach['userid'] != $TS_USER['userid']){
$msg_userid = '0';
$msg_touserid = $strattach['userid'];
$msg_content = '你的附件:《'.$strattach['attachname'].'》新增一条评论,快去看看给个回复吧^_^ ';
$msg_tourl = tsUrl('attach','show',array('id'=>$attachid));
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);
}
header("Location: ".tsUrl('attach','show',array('id'=>$attachid)));
}
break;
//删除评论
case "delete":
$commentid = intval($_GET['commentid']);
$strComment = $new['attach']->find('attach_comment',array(
'commentid'=>$commentid,
));
$strattach = $new['attach']->find('attach',array(
'attachid'=>$strComment['attachid'],
));
if($strattach['userid']==$userid || $TS_USER['isadmin']==1 || $strComment['userid']==$userid){
$new['attach']->delete('attach_comment',array(
'commentid'=>$commentid,
));
}
//跳转回到帖子页
header("Location: ".tsUrl('attach','show',array('id'=>$strComment['attachid'])));
break;
}
+103
View File
@@ -0,0 +1,103 @@
<?php
defined('IN_TS') or die('Access Denied.');
function download($dir,$name)
{
$arr=explode('.', $dir);
$ext=end($arr); //end()返回数组的最后一个元素
if($ext=='pdf')
{
$file = fopen($dir,"r"); // 打开文件
// 输入文件标签
Header("Content-type: application/pdf");
Header("filename:" . $name);
// 输出文件内容
echo fread($file,filesize($dir));
fclose($file);
}else
{
$file = fopen($dir,"r"); // 打开文件
// 输入文件标签
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($dir));
Header("Content-Disposition: attachment; filename=" . $name);
// 输出文件内容
echo fread($file,filesize($dir));
fclose($file);
}
}
//***********************************************
$userid = aac('user')->isLogin();
if(aac('user')->isPublisher()==false) {tsNotice('你可能被限制或没有验证邮箱,检查邮箱是否认证。','->点击认证<-',tsUrl('user','verify'));}
$attachid=intval($_GET['id']);
$the_file=$new['attach']->find('attach',array(
'attachid'=>$attachid,
));
if($the_file) //检查数据表
{
$file_dir = "uploadfile/attach/".$the_file['attachurl'];
if (!file_exists($file_dir)) { //检查文件是否存在
echo "文件已删除";
exit;
}else{
if($the_file['userid']==$userid)
{
$new['attach']->update('attach',array(
'attachid'=>$attachid,
),array(
'count_view'=>$the_file['count_view']+1,
));
download($file_dir,$the_file['attachname']);
exit;
}else
{
if($the_file['pay']==0)//免费的
{
$new['attach']->update('attach',array(
'attachid'=>$attachid,
),array(
'count_view'=>$the_file['count_view']+1,
));
download($file_dir,$the_file['attachname']);
exit;
}else
{
if(aac('user')->delScore($userid,"download file:" . $the_file['attachname'],$the_file['pay']))
{
$new['attach']->update('attach',array(
'attachid'=>$attachid,
),array(
'count_view'=>$the_file['count_view']+1,
));
download($file_dir,$the_file['attachname']);
aac('user')->addScore($the_file['userid'],$userme['username']."download:" . $the_file['attachname'],$the_file['pay'],1);
exit;
}else
{
tsNotice('下载文件需要支付'.$the_file['pay'].'积分,你似乎不够!');
}
}
}
}
}else
{
echo "文件已删除";
exit;
}
+24
View File
@@ -0,0 +1,24 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
$userid = aac('user')->isLogin();
$attachid = intval ( $_GET ['id'] );
$stredit = $new ['attach']->find ( 'attach', array ('attachid' => $attachid ) );
$stredit['content'] = tsDecode($stredit['content']);
if($stredit=='')
{
tsNotice('NO!');
}
if($userid!=$stredit['userid'])
{
tsNotice('NO');
}
include template ( "edit" );
?>
+31
View File
@@ -0,0 +1,31 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
$userid = aac('user')->isLogin();
$attachid = intval ( $_POST ['attachid'] );
$stredit = $new ['attach']->find ( 'attach', array ('attachid' => $attachid ) );
if($stredit=='')
{
tsNotice('NO!');
}
if($userid!=$stredit['userid'])
{
tsNotice('NO');
}
$attachname = trim($_POST['attachname']);
$pay=intval($_POST['pay']);
$new['attach'] -> update('attach', array('attachid' => $attachid), array(
'attachname' => $attachname,
'pay' => $pay,
));
header("Location: " . tsUrl('attach', 'show', array('id' => $attachid)));
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
defined('IN_TS') or die('Access Denied.');
$userid = aac('user')->isLogin();
switch($ts){
case "list":
$kw=urldecode(tsFilter($_GET['kw']));
$page = isset($_GET['page']) ? intval($_GET['page']) : '1';
$url = tsUrl('attach','editor',array('ts'=>'list','page'=>''));
$lstart = $page*10-10;
if($kw=='')
{
$attachlist = $new['attach']->findAll('attach',array('userid'=>$userid),'addtime desc',null,$lstart.',10');
$albumNum = $new['attach']->findCount('attach');
}else
{
$kw = t($kw);
$attachlist = $db->fetch_all_assoc("select * from ".dbprefix."attach WHERE `userid` = '$userid' AND `attachname` like '%$kw%' order by addtime desc limit $lstart,10");
$albumNum = $db->once_num_rows("select * from ".dbprefix."attach WHERE `userid` = '$userid' AND attachname like '%$kw%'");
}
$pageUrl = pagination($albumNum, 10, $page, $url);
include template("editor");
break;
case "upload":
$albumid=0;
include template("upload");
break;
}
+25
View File
@@ -0,0 +1,25 @@
<?php
defined('IN_TS') or die('Access Denied.');
$page = isset($_GET['page']) ? intval($_GET['page']) : '1';
$url = tsUrl('attach','index',array('page'=>''));
$lstart = $page*30-30;
$arrAlbum = $new['attach']->findAll('attach_album',"`isaudit`=0",'albumid desc',null,$lstart.',30');
foreach($arrAlbum as $key=>$item){
$arrAlbum[$key]['albumname'] = tstitle($item['albumname']);
$arrAlbum[$key]['albumdesc'] = tstitle($item['albumdesc']);
}
$albumNum = $new['attach']->findCount('attach_album');
$pageUrl = pagination($albumNum, 30, $page, $url);
$title = '最新专辑';
$sitekey = $TS_APP['appkey'];
$sitedesc = $TS_APP['appdesc'];
include template("index");
+65
View File
@@ -0,0 +1,65 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户是否登录
$userid = aac('user')->isLogin();
//判断发布者状态
if(aac('user')->isPublisher()==false) tsNotice('不好意思,你还没有权限发布内容!');
//发布时间限制
if(aac('system')->pubTime()==false) tsNotice('不好意思,当前时间不允许发布内容!');
switch($ts){
case "":
$title = '新建库';
include template("create");
break;
case "do":
$albumname = trim($_POST['albumname']);
$albumdesc = trim($_POST['albumdesc']);
if($albumname == '') {
tsNotice("库名称不能为空!");
}
//1审核后显示0不审核
if ($TS_APP['isaudit']==1) {
$isaudit = 1;
} else {
$isaudit = 0;
}
if($TS_USER['isadmin']==0){
//过滤内容开始
aac('system')->antiWord($albumname);
aac('system')->antiWord($albumdesc);
//过滤内容结束
}
$albumid = $new['attach']->create('attach_album',array(
'userid'=>$userid,
'albumname'=>$albumname,
'albumdesc'=>$albumdesc,
'isaudit'=>$isaudit,
'addtime'=>date('Y-m-d H:i:s'),
'uptime'=>date('Y-m-d H:i:s'),
));
header("Location: ".tsUrl('attach','album',array('id'=>$albumid)));
break;
}
+76
View File
@@ -0,0 +1,76 @@
<?php
defined('IN_TS') or die('Access Denied.');
$attachid=intval($_GET['id']);
$strattach = $new['attach']->find('attach',array(
'attachid'=>$attachid,
));
if ($strattach == '') {
header ( "HTTP/1.1 404 Not Found" );
header ( "Status: 404 Not Found" );
$title = '404';
include pubTemplate ( "404" );
exit ();
}
$arrattachuser = aac ( 'user' )->getSimpleUser ( $strattach ['userid'] );
//是否关注
if($TS_USER['userid'] != '' && $TS_USER['userid'] != $arrattachuser['userid']){
$userid=$arrattachuser['userid'];
$followNum = $db->once_num_rows("select * from ".dbprefix."user_follow where userid='".$TS_USER['userid']."' and userid_follow='$userid'");
if($followNum > '0'){
$arrattachuser['isfollow'] = true;
}else{
$arrattachuser['isfollow'] = false;
}
}else{
$arrattachuser['isfollow'] = false;
}
// 是否审核
if ($strattach ['isaudit'] == 1 && $TS_USER['isadmin']==0 && $TS_USER['userid']!=$strattach['userid']) {
tsNotice ( '内容审核中...' );
}
$file_dir = "uploadfile/attach/".$strattach['attachurl'];
$filemd5=md5_file($file_dir);
if($filemd5)
{
}else
{
$filemd5="File_Erro!";
}
// 获取评论
$page = isset ( $_GET ['page'] ) ? intval ( $_GET ['page'] ) : 1;
$url = tsUrl ( 'attach', 'show', array (
'id' => $attachid,
'page' => ''
) );
$lstart = $page * 10 - 10;
$arrComments = $new ['attach']->findAll ( 'attach_comment', array (
'attachid' => $attachid
), 'addtime desc', null, $lstart . ',10' );
foreach ( $arrComments as $key => $item ) {
$arrComment [] = $item;
$arrComment[$key]['content'] = tsDecode($item['content']);
$arrComment [$key] ['user'] = aac ( 'user' )->getSimpleUser ( $item ['userid'] );
}
$commentNum = $new ['attach']->findCount ( 'attach_comment', array (
'attachid' => $attachid
) );
$pageUrl = pagination ( $commentNum, 10, $page, $url );
// 标签
//$strattach ['tags'] = aac ( 'tag' )->getObjTagByObjid ( 'attach', 'attachid', $strattach ['attachid'] );
$title = $strattach['attachname'];
include template ( "show" );
+69
View File
@@ -0,0 +1,69 @@
<?php
defined('IN_TS') or die('Access Denied.');
$userid = aac('user')->isLogin();
switch($ts){
case "":
$albumid=intval($_GET['albumid']);
include template("upload");
break;
case "add":
$albumid=intval($_GET['albumid']);
include template("add");
break;
case "do":
$albumid = intval($_POST['albumid']);
$strAlbum = $new['attach']->find('attach_album',array(
'albumid'=>$albumid,
));
if($strAlbum!=''){
if($strAlbum['userid']!=$userid){
getJson('非法操作3');
}
}
if($_FILES['file']==''){ts404();}
//上传
$attachid = $new['attach']->create('attach',array(
'userid'=>$userid,
'albumid'=>$albumid,
'locationid'=>aac('user')->getLocationId($userid),
'addtime' => date('Y-m-d H:i:s',time()),
));
//上传
$arrUpload = tsUpload($_FILES['file'],$attachid,'attach',array('zip','rar','doc','txt','ppt','pdf','docx','mp4'));
if($arrUpload && $arrUpload['path'] && $arrUpload['url']){
$new['attach']->update('attach',array(
'attachid'=>$attachid,
),array(
'attachname'=>$arrUpload['name'],
'attachtype'=>$arrUpload['type'],
'path'=>$arrUpload['path'],
'attachurl'=>$arrUpload['url'],
'attachsize'=>$arrUpload['size'],
));
}
$count_attach = $new['attach']->findCount('attach',array(
'albumid'=>$albumid,
));
$new['attach']->update('attach_album',array(
'albumid'=>$albumid,
),array(
'count_attach'=>$count_attach
));
break;
}