begin of thinksaas 3.68

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2023-06-22 13:33:25 +08:00
commit 963ec1b2ea
2746 changed files with 331806 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
<?php
defined('IN_TS') or die('Access Denied.');
return array(
'name' => '公共',
'version' => '1.2',
'desc' => '辅助性APP',
'url' => 'http://www.thinksaas.cn',
'email' => 'thinksaas@qq.com',
'author' => '邱君',
'author_url' => 'http://www.thinksaas.cn',
'isoption' => '1',
'isinstall' => '1',
'issql' => '1',
'issystem' => '1',
'isappnav' => '0',
'ismy'=>'0',
);
+10
View File
@@ -0,0 +1,10 @@
<?php
defined('IN_TS') or die('Access Denied.');
//管理入口
if(is_file('app/'.$app.'/action/admin/'.$mg.'.php')){
include_once 'app/'.$app.'/action/admin/'.$mg.'.php';
}else{
qiMsg('sorry:no index!');
}
+23
View File
@@ -0,0 +1,23 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//基本配置
case "":
$strOption = getAppOptions('pubs');
include template("admin/options");
break;
case "do":
$arrOption = $_POST['option'];
#更新app配置选项
upAppOptions('pubs',$arrOption);
qiMsg('修改成功!');
break;
}
+83
View File
@@ -0,0 +1,83 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
/**
* 阿里云oss直传回调
*/
case "callback":
// 1.获取OSS的签名header和公钥url header
$authorizationBase64 = "";
$pubKeyUrlBase64 = "";
/*
* 注意:如果要使用HTTP_AUTHORIZATION头,你需要先在apache或者nginx中设置rewrite,以apache为例,修改
* 配置文件/etc/httpd/conf/httpd.conf(以你的apache安装路径为准),在DirectoryIndex index.php这行下面增加以下两行
RewriteEngine On
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
* */
if (isset($_SERVER['HTTP_AUTHORIZATION']))
{
$authorizationBase64 = $_SERVER['HTTP_AUTHORIZATION'];
}
if (isset($_SERVER['HTTP_X_OSS_PUB_KEY_URL']))
{
$pubKeyUrlBase64 = $_SERVER['HTTP_X_OSS_PUB_KEY_URL'];
}
if ($authorizationBase64 == '' || $pubKeyUrlBase64 == '')
{
header("http/1.1 403 Forbidden");
exit();
}
// 2.获取OSS的签名
$authorization = base64_decode($authorizationBase64);
// 3.获取公钥
$pubKeyUrl = base64_decode($pubKeyUrlBase64);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $pubKeyUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$pubKey = curl_exec($ch);
if ($pubKey == "")
{
//header("http/1.1 403 Forbidden");
exit();
}
// 4.获取回调body
$body = file_get_contents('php://input');
// 5.拼接待签名字符串
$authStr = '';
$path = $_SERVER['REQUEST_URI'];
$pos = strpos($path, '?');
if ($pos === false)
{
$authStr = urldecode($path)."\n".$body;
}
else
{
$authStr = urldecode(substr($path, 0, $pos)).substr($path, $pos, strlen($path) - $pos)."\n".$body;
}
// 6.验证签名
$ok = openssl_verify($authStr, $authorization, $pubKey, OPENSSL_ALGO_MD5);
if ($ok == 1)
{
header("Content-Type: application/json");
$data = array("Status"=>"Ok");
echo json_encode($data);
}
else
{
//header("http/1.1 403 Forbidden");
exit();
}
break;
}
+9
View File
@@ -0,0 +1,9 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
// api入口
if (is_file ( 'app/' . $TS_URL['app'] . '/action/api/' . $TS_URL['api'] . '.php' )) {
include_once 'app/' . $TS_URL['app'] . '/action/api/' . $TS_URL['api'] . '.php';
} else {
qiMsg ( 'sorry:no api!' );
}
+12
View File
@@ -0,0 +1,12 @@
<?php
defined('IN_TS') or die('Access Denied.');
/**
* 图形验证码
*/
require_once('thinksaas/Image.class.php');
$Image = new Image();
echo $Image->buildImageVerify($width=65,$height=30,$randval=NULL,$verifyName='verify');
+113
View File
@@ -0,0 +1,113 @@
<?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);
}
}
if($ts=='')
{
echo "gun!";
exit;
}
if($ts=='-1')
{
echo "erro";
exit;
}
$userid = aac('user')->isLogin();
$ts=tsUrlCheck($ts);
if(aac('user')->isPublisher()==false) {tsNotice('你可能被限制或没有验证邮箱,检查邮箱是否认证。','->点击认证<-',tsUrl('user','verify'));}
$userme=aac('user')->getOneUser($userid);
$the_file=$new['pubs']->find('editor',array(
'pwd'=>$ts,
));
if($the_file)
{
$file_dir = "uploadfile/editor/".$the_file['url'];
if (!file_exists($file_dir)) { //检查文件是否存在
echo "文件已删除";
exit;
}else{
if($the_file['userid']==$userid)
{
download($file_dir,$the_file['title']);
exit;
}else
{
if(aac('user')->delScore($userid,"download file:" . $the_file['title'],2))
{
download($file_dir,$the_file['title']);
aac('user')->addScore($the_file['userid'],$userme['username']."download:" . $the_file['title'],1,1);
exit;
}else
{
tsNotice('下载文件需要2积分,你似乎不够!');
}
}
}
}else
{
echo "文件已删除";
exit;
}
/*
$file_name = "187.doc";
$file_dir = "uploadfile/editor/0/0/";
if (!file_exists($file_dir . $file_name)) { //检查文件是否存在
echo "文件已删除";
exit;
}else{
$file = fopen($file_dir . $file_name,"r"); // 打开文件
// 输入文件标签
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($file_dir . $file_name));
Header("Content-Disposition: attachment; filename=" . $file_name);
// 输出文件内容
echo fread($file,filesize($file_dir . $file_name));
fclose($file);
exit;
}
*/
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
defined('IN_TS') or die('Access Denied.');
/**
* 存草稿箱
*/
$userid = tsIntval($TS_USER['userid']);
if($userid==0){
getJson('非法操作!',1,0);
}
$types = tsTrim($_POST['types']);
$title = tsTrim($_POST['title']);
$content = tsClean($_POST['content']);
if($types && $title && $content){
if(!in_array($types,array('topic','article'))){
getJson('非法操作!',1,0);
}
$new['pubs']->replace('draft',array(
'userid'=>$userid,
'types'=>$types,
),array(
'userid'=>$userid,
'types'=>$types,
'title'=>$title,
'content'=>$content,
'addtime'=>time(),
));
getJson('已自动保存内容到草稿箱!',1);
}
+126
View File
@@ -0,0 +1,126 @@
<?php
defined('IN_TS') or die('Access Denied.');
/**
* 编辑器上传控制
*/
switch($ts){
#图片上传
case "photo":
$js = tsIntval($_GET['js']);
$userid = aac('user')->isLogin();
$id = $new['pubs']->create('editor',array(
'userid'=>$userid,
'type'=>'photo',
'addtime'=>time(),
));
$arrUpload = tsUpload($_FILES['photo'], $id, 'editor', array('jpg', 'gif', 'png', 'jpeg'),'sy.png');
if ($arrUpload) {
$new['pubs'] -> update('editor', array(
'id' => $id
), array(
'title'=>$arrUpload['name'],
'path' => $arrUpload['path'],
'url' => $arrUpload['url']
));
if($TS_SITE['file_upload_type']==1){
#阿里云(对象云存储OSS)数据
$url = $TS_SITE['alioss_bucket_url'].'/'.'uploadfile/editor/'.$arrUpload['url'].'?x-oss-process=image/resize,w_800';
}else{
#本地数据
$url = SITE_URL.'uploadfile/editor/'.$arrUpload['url'];
}
if($js==1){
echo json_encode(array(
'errno'=>0,
'data'=>array(
0=>$url,
//0=>tsXimg($arrUpload['url'],'editor','640','',$arrUpload['path']),
),
));
exit();
}else{
echo $url;
//echo tsXimg($arrUpload['url'],'editor','640','',$arrUpload['path']);
exit();
}
}else{
$new['pubs']->delete('editor',array(
'id'=>$id,
));
}
break;
//针对editor.md编辑器的图片上传
case "markdown":
//var_dump($_FILES['editormd-image-file']);
$userid = aac('user')->isLogin();
$id = $new['pubs']->create('editor',array(
'userid'=>$userid,
'type'=>'photo',
'addtime'=>time(),
));
$arrUpload = tsUpload($_FILES['editormd-image-file'], $id, 'editor', array('jpg', 'gif', 'png', 'jpeg'),'sy.png');
if ($arrUpload) {
$new['pubs'] -> update('editor', array(
'id' => $id
), array(
'title'=>$arrUpload['name'],
'path' => $arrUpload['path'],
'url' => $arrUpload['url']
));
if($TS_SITE['file_upload_type']==1){
#阿里云(对象云存储OSS)数据
$url = $TS_SITE['alioss_bucket_url'].'/'.'uploadfile/editor/'.$arrUpload['url'].'?x-oss-process=image/resize,w_800';
}else{
#本地数据
$url = SITE_URL.'uploadfile/editor/'.$arrUpload['url'];
}
echo json_encode(array(
'success'=>1,
'message'=>'图片上传成功!',
'url'=>$url,
));
}else{
$new['pubs']->delete('editor',array(
'id'=>$id,
));
echo json_encode(array(
'success'=>0,
'message'=>'图片上传失败!',
'url'=>'',
));
}
break;
}
+103
View File
@@ -0,0 +1,103 @@
<?php
defined('IN_TS') or die('Access Denied.');
/**
* 发送Email验证码
*/
$email = tsTrim($_POST['email']);
$typeid = tsIntval($_POST['typeid']); //判断Email是否存在:0不判断、1判断存在、2判断不存在
#人机验证
$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) {
getJson('人机验证未通过!',1,0);
}
}
if(valid_email($email) == false){
getJson('Email输入有误',1,0);
}
#过滤Email
$is_anti_email = $new['pubs']->find('anti_email',array(
'email'=>$email,
));
if($is_anti_email>0){
getJson('非法操作!',1,0);
}
if($typeid==1){
$strUserEmail = $new['pubs']->find('user',array(
'email'=>$email,
));
if($strUserEmail){
getJson('Email已经存在!',1,0);
}
}elseif($typeid==2){
$strUserEmail = $new['pubs']->find('user',array(
'email'=>$email,
));
if($strUserEmail==''){
getJson('Email不存在!',1,0);
}
}
$strEmail = $new['pubs']->find('email_code',array(
'email'=>$email,
));
$code = random(4,1);
if($strEmail){
$time = time();
$ptime = strtotime($strEmail['addtime']);
$ntime = $time-$ptime;
#短信发送间隔时间
$email_code_send_time = tsIntval($TS_APP['email_code_send_time']);
if($email_code_send_time==0) $email_code_send_time = 30;
$time30 = 60*$email_code_send_time;
if($ntime<$time30){
//echo 1;exit;//30分钟内只能发送一次短信验证码
getJson('30分钟内只能发送一次Email验证码!',1,0);
}else{
$new['pubs']->update('email_code',array(
'email'=>$email,
),array(
'code'=>$code,
'nums'=>0,
'addtime'=>date('Y-m-d H:i:s'),
));
$result = aac('mail')->postMail($email,$TS_SITE['site_title'].' Email验证码:'.$code,$TS_SITE['site_title'].' Email验证码:'.$code);
getJson('发送成功!',1,1);
}
}else{
$new['pubs']->create('email_code',array(
'email'=>$email,
'code'=>$code,
'nums'=>0,
'addtime'=>date('Y-m-d H:i:s'),
));
$result = aac('mail')->postMail($email,$TS_SITE['site_title'].' Email验证码:'.$code,$TS_SITE['site_title'].' Email验证码:'.$code);
getJson('发送成功!',1,1);
}
+30
View File
@@ -0,0 +1,30 @@
<?php
defined('IN_TS') or die('Access Denied.');
//临时上传
$userid = aac('user')->isLogin();
$dest_dir = 'cache/upload';
createFolders ( $dest_dir );
$arrType = explode ( '.', strtolower ( $_FILES ['filedata'] ['name'] ) );
$type = array_pop ( $arrType );
if (in_array ( $type, array('doc','pdf','ppt','xls','txt') )) {
$name = $userid .'.'. $type;
$dest = $dest_dir . '/' . $name;
unlink ( $dest );
move_uploaded_file ( $_FILES ['filedata'] ['tmp_name'], mb_convert_encoding ( $dest, "gb2312", "UTF-8" ) );
chmod ( $dest, 0777 );
echo SITE_URL.$dest;
}
+10
View File
@@ -0,0 +1,10 @@
<?php
defined('IN_TS') or die('Access Denied.');
if($TS_USER){
header('Location: '.SITE_URL);
exit();
}
$title = $TS_SITE['site_subtitle'];
include template('home');
+3
View File
@@ -0,0 +1,3 @@
<?php
defined('IN_TS') or die('Access Denied.');
echo '11111';
+121
View File
@@ -0,0 +1,121 @@
<?php
defined('IN_TS') or die('Access Denied.');
/**
* 发送手机验证码
*/
$phone = tsTrim($_POST['phone']);
$authcode = strtolower($_POST['authcode']);
$typeid = tsIntval($_POST['typeid']); //判断手机号是否存在0不判断1判断存在2判断不存在
#人机验证
$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) {
getJson('人机验证未通过!',1,0);
}
}
if(isPhone($phone)==false){
//echo 0;exit;//手机号码输入有误
getJson('手机号码输入有误',1,0);
}
if ($authcode != $_SESSION['verify']) {
//echo 5;exit;//图片验证码输入有误
getJson('图片验证码输入有误!',1,0);
}
#过滤手机号
$is_anti_phone = $new['pubs']->find('anti_phone',array(
'phone'=>$phone,
));
if($is_anti_phone>0){
getJson('非法操作!',1,0);
}
if($typeid==1){
$strUserPhone = $new['pubs']->find('user',array(
'phone'=>$phone,
));
if($strUserPhone){
//echo 3;exit;//手机号已经存在
getJson('手机号已经存在!',1,0);
}
}elseif($typeid==2){
$strUserPhone = $new['pubs']->find('user',array(
'phone'=>$phone,
));
if($strUserPhone==''){
//echo 4;exit;//手机号不存在
getJson('手机号不存在!',1,0);
}
}
$strPhone = $new['pubs']->find('phone_code',array(
'phone'=>$phone,
));
$code = random(4,1);
if($strPhone){
$time = time();
$ptime = strtotime($strPhone['addtime']);
$ntime = $time-$ptime;
#短信发送间隔时间
$phone_code_send_time = tsIntval($TS_APP['phone_code_send_time']);
if($phone_code_send_time==0) $phone_code_send_time = 30;
$time30 = 60*$phone_code_send_time;
if($ntime<$time30){
//echo 1;exit;//30分钟内只能发送一次短信验证码
getJson($phone_code_send_time.'分钟内只能发送一次短信验证码!',1,0);
}else{
$new['pubs']->update('phone_code',array(
'phone'=>$phone,
),array(
'code'=>$code,
'nums'=>0,
'addtime'=>date('Y-m-d H:i:s'),
));
$response = aac('mail')->sendSms($phone,$code);
#var_dump($response);
//echo 2;exit;//发送成功
getJson('发送成功!',1,1);
}
}else{
$new['pubs']->create('phone_code',array(
'phone'=>$phone,
'code'=>$code,
'nums'=>0,
'addtime'=>date('Y-m-d H:i:s'),
));
$response = aac('mail')->sendSms($phone,$code);
#var_dump($response);
//echo 2;exit;//发送成功
getJson('发送成功!',1,1);
}
+51
View File
@@ -0,0 +1,51 @@
<?php
defined('IN_TS') or die('Access Denied.');
/*
<script type="text/javascript" src="{SITE_URL}public/js/jquery.upload.v2.js"></script>
<script>
$(function(){
$("#upload").upload({
action: "{SITE_URL}index.php?app=pubs&ac=photo", //上传地址
fileName: "filedata", //文件名称。用于后台接收
params: {}, //参数
accept: ".jpg", //文件类型
complete: function (rs) { //上传完成
$("#photo img").attr("src",rs);
},
submit: function () { //提交之前
//alert("submit");
}
});
})
</script>
*/
//集合JS的临时上传
$userid = aac('user')->isLogin();
$dest_dir = 'cache/upload';
createFolders ( $dest_dir );
$arrType = explode ( '.', strtolower ( $_FILES ['filedata'] ['name'] ) );
$type = array_pop ( $arrType );
if (in_array ( $type, array('jpg','jpeg','gif','png') )) {
$name = $userid .'.'. $type;
$dest = $dest_dir . '/' . $name;
unlink ( $dest );
move_uploaded_file ( $_FILES ['filedata'] ['tmp_name'], mb_convert_encoding ( $dest, "gb2312", "UTF-8" ) );
chmod ( $dest, 0777 );
echo SITE_URL.$dest.'?v='.rand();
}
+11
View File
@@ -0,0 +1,11 @@
<?php
defined('IN_TS') or die('Access Denied.');
//插件条件入口
if(is_file('plugins/'.$app.'/'.$plugin.'/'.$in.'.php')){
require_once('plugins/'.$app.'/'.$plugin.'/'.$in.'.php');
}else{
qiMsg('sorry:no plugin!');
}
//形如这样
//index.php?app=group&ac=plugin&plugin=qq&in=do
+17
View File
@@ -0,0 +1,17 @@
<?php
if($ts=='')
{
echo "WDNMD";
exit;
}
if($ts=='signin')
{
$js = intval($_GET['js']);
getJson('签到啊',$js);
}
?>
+56
View File
@@ -0,0 +1,56 @@
<?php
defined('IN_TS') or die('Access Denied.');
if($ts=='')
{
echo "gun!";
exit;
}
$userid = aac('user')->isLogin();
$ts=tsFilter($ts);
$url=str_replace("/uploadfile/editor/","",$ts);
if($url=='')
{
echo "erro";
exit;
}
$the_file=$new['pubs']->find('editor',array(
'url'=>$url,
));
if($the_file)
{
echo $the_file['id'];
}else
{
echo "-1";
}
/*
$file_name = "187.doc";
$file_dir = "uploadfile/editor/0/0/";
if (!file_exists($file_dir . $file_name)) { //检查文件是否存在
echo "文件已删除";
exit;
}else{
$file = fopen($file_dir . $file_name,"r"); // 打开文件
// 输入文件标签
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($file_dir . $file_name));
Header("Content-Disposition: attachment; filename=" . $file_name);
// 输出文件内容
echo fread($file,filesize($file_dir . $file_name));
fclose($file);
exit;
}
*/
?>
+556
View File
@@ -0,0 +1,556 @@
<?php
defined('IN_TS') or die('Access Denied.');
class pubs extends tsApp{
//构造函数
public function __construct($db){
$tsAppDb = array();
include 'app/pubs/config.php';
//判断APP是否采用独立数据库
if($tsAppDb){
$db = new MySql($tsAppDb);
}
parent::__construct($db);
}
/**
* 解密userkey,加验证userid
* @param $userkey
* @return string
*/
public function getUserId($userkey){
include 'thinksaas/class.crypt.php';
$crypt= new crypt();
$userid = $crypt->decrypt($userkey,$GLOBALS['TS_SITE']['site_pkey']);
$isUser = $this->findCount('user',array(
'userid'=>$userid,
));
if($isUser == 0){
echo json_encode(array(
'status'=> 0,
'msg'=> '非法操作',
'data'=> '',
));
exit;
}else{
return $userid;
}
}
/**
* @param $string
* @param string $action
* @return string
*/
public function strCode($string, $action = 'ENCODE'){
$action != 'ENCODE' && $string = base64_decode($string);
$code = '';
$key = $GLOBALS['TS_SITE']['site_pkey'];
$keyLen = strlen($key);
$strLen = strlen($string);
for ($i = 0; $i < $strLen; $i++) {
$k = $i % $keyLen;
$code .= $string[$i] ^ $key[$k];
}
return ($action != 'DECODE' ? base64_encode($code) : $code);
}
/**
* @param $phone
* @param $code
* @return bool
*/
public function verifyPhoneCode($phone, $code){
$strPhoneCode = $this->find('phone_code',array(
'phone'=>$phone,
));
#空数据
if($strPhoneCode==''){
return false;exit;
}
#空验证码
if($strPhoneCode['code']==''){
return false;exit;
}
#手机验证码错误次数>=2
if($strPhoneCode['nums']>=2){
$this->update('phone_code',array(
'phone'=>$phone,
),array(
'code'=>'',
'nums'=>0,
));
return false;exit;
}
#手机验证码错误
if($strPhoneCode['code']!=$code){
$this->update('phone_code',array(
'phone'=>$phone,
),array(
'nums'=>$strPhoneCode['nums']+1,
));
return false;exit;
}
return true;
}
/**
* 验证Email验证码
*/
public function verifyEmailCode($email, $code){
$strEmailCode = $this->find('email_code',array(
'email'=>$email,
));
#空数据
if($strEmailCode==''){
return false;exit;
}
#空验证码
if($strEmailCode['code']==''){
return false;exit;
}
#验证码错误次数>=2
if($strEmailCode['nums']>=2){
$this->update('email_code',array(
'email'=>$email,
),array(
'code'=>'',
'nums'=>0,
));
return false;exit;
}
#验证码错误
if($strEmailCode['code']!=$code){
$this->update('email_code',array(
'email'=>$email,
),array(
'nums'=>$strEmailCode['nums']+1,
));
return false;exit;
}
return true;
}
/**
* 删除点赞
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param integer $userid
* @return void
*/
public function delLove($ptable,$pkey,$pid,$userid=0){
if($userid){
$this->delete('love',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
'userid'=>$userid,
));
}else{
$this->delete('love',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
));
}
return true;
}
/**
* 添加项目数据到ts_topic表
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param string $pjson
* @param [type] $groupid
* @param [type] $userid
* @param [type] $title
* @param [type] $gaiyao
* @return void
*/
public function addPtable($ptable,$pkey,$pid,$pjson,$groupid,$userid,$title,$gaiyao){
$topicid = $this->create('topic',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
'pjson'=>$pjson,
'groupid'=>$groupid,
'userid'=>$userid,
'title'=>$title,
'gaiyao'=>$gaiyao,
'isaudit'=>0,
'addtime'=>time(),
'uptime'=>time(),
));
return $topicid;
}
/**
* 更新项目数据到ts_topic表
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param string $pjson
* @param [type] $title
* @param [type] $gaiyao
* @return void
*/
public function editPtable($ptable,$pkey,$pid,$pjson,$title,$gaiyao){
$this->update('topic',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
),array(
'pjson'=>$pjson,
'title'=>$title,
'gaiyao'=>$gaiyao,
));
}
/**
* 更新项目浏览数到ts_topic表
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param [type] $count_view
* @return void
*/
public function upPtableView($ptable,$pkey,$pid,$count_view){
$this->update('topic',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
),array(
'count_view'=>$count_view,
));
}
/**
* 更新项目评论数到ts_topic表
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param [type] $count_comment
* @return void
*/
public function upPtableComment($ptable,$pkey,$pid,$count_comment){
if($ptable!='topic'){
$this->update('topic',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
),array(
'count_comment'=>$count_comment,
'uptime'=>time(),
));
}
}
/**
* 更新项目点赞数到ts_topic表
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param [type] $count_love
* @return void
*/
public function upPtableLove($ptable,$pkey,$pid,$count_love){
if($ptable!='topic'){
$this->update('topic',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
),array(
'count_love'=>$count_love,
));
}
}
/**
* 从ts_topic表删除项目数据
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @return void
*/
public function delPtable($ptable,$pkey,$pid){
$this->delete('topic',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
));
}
/**
* 用户内容添加、修改、删除记录
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param [type] $userid
* @param [type] $title
* @param [type] $content
* @param [type] $status
* @return void
*/
public function addLogs($ptable,$pkey,$pid,$userid,$title,$content,$status){
$this->create('logs',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
'userid'=>$userid,
'title'=>$title,
'content'=>$content,
'status'=>$status,
'addtime'=>time(),
));
}
/**
* 更新项目推荐
*
* @param [type] $ptable
* @param [type] $pkey
* @param [type] $pid
* @param integer $isrecommend 1推荐0不推荐
* @return void
*/
public function upPtableRecommend($ptable,$pkey,$pid,$isrecommend=1){
if($ptable!='topic'){
$this->update('topic',array(
'ptable'=>$ptable,
'pkey'=>$pkey,
'pid'=>$pid,
),array(
'isrecommend'=>$isrecommend,
));
}
}
/**
* ThinkSAAS分块上传文件
* upsize和upcount为空的情况下就是单个文件,并且该文件比设定的大小要小
*
* @param [type] $userid 用户ID
* @param [type] $upsize 总共分几段上传
* @param [type] $upcount 每次分段的size
* @param array $uptype 上传文件类型
* @return void
*/
public function chunkUpload($userid,$files,$upsize,$upcount,$uptype=array()){
$upid = $this->create('upload',array(
'userid'=>$userid,
'addtime'=>date('Y-m-d H:i:s'),
));
#分块上传到本地服务器
$arrUpload = tsUploadLocal($files,$upid,'upload',$uptype);
if($arrUpload['size']){
$this->update('upload',array(
'upid'=>$upid,
),array(
'fileurl'=>$arrUpload['url'],
'filename'=>$arrUpload['name'],
'filesize'=>$arrUpload['size'],
'filetype'=>$arrUpload['type'],
));
if($arrUpload['size']<$upsize || $upsize==''){
$arrUp = $this->findAll('upload',array(
'userid'=>$userid,
),'upid asc');
if(count($arrUp)==$upcount || ($arrUp && $upcount=='')){
return $arrUp;
}else{
return 1;
}
}else{
return 1;
}
}else{
return 0;
}
}
/**
* 合并上传文件
*
* @param [type] $userid
* @param [type] $projectid
* @param [type] $dir
* @param array $arrUp
* @return void
*/
public function mergeUpload($projectid,$dir,$arrUp=array()){
$path = getDirPath($projectid);
$dest_dir = 'uploadfile/' . $dir . '/' . $path;
createFolders($dest_dir);
$name = $projectid . '.' . $arrUp[0]['filetype'];
$dest = $dest_dir . '/' . $name;
#删除原文件
unlink($dest);
$fp = fopen($dest, "ab");
$filesize = 0;
foreach($arrUp as $key=>$item){
$upfile = 'uploadfile/upload/'.$item['fileurl'];
$handle = fopen($upfile,"rb");
fwrite($fp, fread($handle,$item['filesize']));
fclose($handle);
unset($handle);
unlink($upfile);//合并完毕的文件就删除
$filesize = $item['filesize'];
$filesize++;
#删除ts_upload
$this->delete('upload',array(
'upid'=>$item['upid'],
));
}
return array(
'name' => $arrUp[0]['filename'],
'path' => $path,
'url' => $path . '/' . $name,
'type' => $arrUp[0]['filetype'],
'size' => $filesize,
);
}
/**
* 删除用户分段上传的文件ts_upload
*
* @param [type] $userid
* @return void
*/
public function delUpload($userid){
$arrUp = $this->findAll('upload',array(
'userid'=>$userid,
),'upid asc');
foreach($arrUp as $key=>$item){
$upfile = 'uploadfile/upload/'.$item['fileurl'];
unlink($upfile);
}
#删除ts_upload
$this->delete('upload',array(
'userid'=>$userid,
));
}
/**
* 更新APP用户组权限
*
* 权限参数说明,app,action必须,其他参数可选
* app-action-ts
* app-action-mg-ts 当action=admin
* app-action-api-ts 当action=api
*
*/
public function upAppPermissions($ugid,$app,array $arrOption){
foreach($arrOption as $key=>$item){
$status = $item;
if($ugid==1) $status=1;
$arrKey = explode('_',$key);
$key_app = $arrKey[0];
$key_ac = $arrKey[1];
$key_mg = '';
$key_api = '';
$key_ts = '';
if($key_ac=='admin'){
$key_mg = $arrKey[2];
$key_ts = $arrKey[3];
}elseif($key_ac=='api'){
$key_api = $arrKey[2];
$key_ts = $arrKey[3];
}else{
$key_ts = $arrKey[2];
}
if($key_ts==null) $key_ts='';
$this->replace('permissions',array(
'ugid'=>$ugid,
'app'=>$key_app,
'action'=>$key_ac,
'mg'=>$key_mg,
'api'=>$key_api,
'ts'=>$key_ts,
),array(
'ugid'=>$ugid,
'app'=>$key_app,
'action'=>$key_ac,
'mg'=>$key_mg,
'api'=>$key_api,
'ts'=>$key_ts,
'status'=>$status,
));
}
//存储permissions到本地文件
$arrPermissions = $this->findAll('permissions',array(
'app'=>$app,
));
foreach($arrPermissions as $key=>$item){
$option = $item['app'].'_'.$item['action'];
if($item['mg']) $option .= '_'.$item['mg'];
if($item['api']) $option .= '_'.$item['api'];
if($item['ts']) $option .= '_'.$item['ts'];
$arrData[$item['ugid']][$option] = $item['status'];
}
fileWrite($app.'_permissions.php','data',$arrData);
$GLOBALS['tsMySqlCache']->set($app.'_permissions',$arrData);
}
}
+6
View File
@@ -0,0 +1,6 @@
<?php
defined('IN_TS') or die('Access Denied.');
$TS_APP['appname'] = '公共';
$skin = 'default';
+9
View File
@@ -0,0 +1,9 @@
<div class="tabnav">
<h6>公共管理</h6>
<ul>
<li {if $mg=='options'}class="select"{/if}><a href="{SITE_URL}index.php?app=pubs&ac=admin&mg=options">基础配置</a></li>
</ul>
</div>
<div style="height: 100px;"></div>
+25
View File
@@ -0,0 +1,25 @@
{php include pubTemplate("header_admin")}
<div class="midder">
{php include template("admin/menu");}
<form method="POST" action="index.php?app=pubs&ac=admin&mg=options&ts=do">
<table class="table table-hover">
<tr><td width="200">手机验证码发送间隔时间:</td><td><input type="number" name="option[phone_code_send_time]" value="{$strOption['phone_code_send_time']}" /> 分钟</td></tr>
<tr><td>Email验证码发送间隔时间:</td><td><input type="number" name="option[email_code_send_time]" value="{$strOption['email_code_send_time']}" /> 分钟</td></tr>
<tr><td></td><td>
<input class="btn btn-primary" type="submit" value="提交修改" /></td>
</tr>
</table>
</form>
</div>
{php include pubTemplate("footer_admin")}
+5
View File
@@ -0,0 +1,5 @@
<div class="tabnav">
<ul>
<li><a href="{SITE_URL}index.php?app=system&ac=plugin&ts=list&apps=pubs">返回插件首页</a></li>
</ul>
</div>
+228
View File
@@ -0,0 +1,228 @@
<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-language" content="zh-CN" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="applicable-device" content="pc,mobile">
<meta name="robots" content="all" />
<meta name="save" content="history" />
<title>{$GLOBALS['TS_SITE']['site_title']} - {$title}</title>
<meta name="keywords" content="{$GLOBALS['TS_SITE'][site_key]}" />
<meta name="description" content="{$GLOBALS['TS_SITE'][site_desc]}" />
<link rel="shortcut icon" href="{SITE_URL}favicon.ico" />
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="{SITE_URL}public/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{SITE_URL}theme/sample/base.css" />
<script>var siteUrl = '{SITE_URL}'; //</script>
<script src="{SITE_URL}public/js/jquery.min.js" type="text/javascript"></script>
<!--jquery向下兼容-->
<script src="{SITE_URL}public/js/jquery-migrate.js" type="text/javascript"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="{SITE_URL}public/bootstrap/js/bootstrap.min.js"></script>
<!--bootstrap 前端验证-->
<script type="text/javascript" src="{SITE_URL}public/js/bootstrap3-validation.js"></script>
{if $GLOBALS['TS_CF']['urllock']}
<script type="text/javascript">
var urllock="$GLOBALS['TS_CF']['urllock']";if(document.domain!=urllock){top.location.href=siteUrl;}
</script>
{/if}
</head>
<body class="pubs_home">
<div class="container">
<div class="row">
<div class="col-md-8">
<h1 class="h2 mt-5 fw300">{$GLOBALS['TS_SITE']['site_title']}</h1>
<div class="h1 fw300">{$title}</div>
</div>
<div class="col-md-4">
<div class="pubs_home_login">
<div class="pubs_home_login_bg"></div>
<div class="pubs_home_login_form">
<div class="form-group">
<label class="text-light">账号</label>
<input name="email" type="text" class="form-control" placeholder="Email/手机号">
</div>
<div class="form-group">
<label class="text-light">密码</label>
<input name="pwd" type="password" class="form-control" placeholder="Password">
</div>
<input type="hidden" name="cktime" value="31536000">
<input type="hidden" name="token" value="{$_SESSION['token']}" />
<button type="submit" id="comm-submit" class="btn btn-info btn-block">登 录</button>
<a class="btn btn-link text-light" href="{tsUrl('user','register')}">注册帐号</a>
<a class="btn btn-link text-light" href="{tsUrl('user','forgetpwd')}">忘记密码</a>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="pubs_home_footer">
<p>
<a href="{tsUrl('home','info',array('id'=>'1'))}">关于我们</a> |
<a href="{tsUrl('home','info',array('id'=>'2'))}">联系我们</a> |
<a href="{tsUrl('home','info',array('id'=>'3'))}">用户条款</a> |
<a href="{tsUrl('home','info',array('id'=>'4'))}">隐私申明</a> |
<a href="{tsUrl('home','info',array('id'=>'5'))}">加入我们</a>
</p>
<p>Copyright © {php echo date('Y')} <a target="_blank" href="{SITE_URL}">{$TS_SITE[site_title]}</a> {$TS_SITE[site_icp]}</p>
<p>
Powered by <a target="_blank" class="softname" title="开源社区" href="{$GLOBALS['TS_CF'][info][url]}">{$GLOBALS['TS_CF'][info][name]}</a> {$GLOBALS['TS_CF'][info][version]}
</p>
<p><span style="font-size:0.83em;">Processed in {$GLOBALS['TS_CF']['runTime']} second(s)</span></p>
</div>
</div>
<script src="{SITE_URL}public/js/common.js" type="text/javascript"></script>
{php doAction('pub_footer')}
<!--{if $TS_SITE['is_vaptcha']}-->
<script src="https://v-cn.vaptcha.com/v3.js"></script>
<script>
vaptcha({
vid: '{$TS_SITE[vaptcha_vid]}',// 验证单元id
mode: 'invisible',// 显示类型 隐藏式
scene: 0,// 场景值 默认0
area: 'auto' //验证节点区域,默认 auto,可选值 auto,sea,na,cn
}).then(function (vaptchaObj) {
obj = vaptchaObj; //将VAPTCHA验证实例保存到局部变量中
vaptchaObj.listen("pass", function () {
// 验证成功进行后续操作
var email = $("input[name='email']").val();
var pwd = $("input[name='pwd']").val();
var cktime = $("input[name='cktime']").val();
var jump = $("input[name='jump']").val();
var token = $("input[name='token']").val();
serverToken = vaptchaObj.getServerToken()
var data = {
email:email,
pwd:pwd,
cktime:cktime,
jump:jump,
token:token,
vaptcha_token: serverToken.token,
vaptcha_server: serverToken.server,
};
tsPost('index.php?app=user&ac=login&ts=do&js=1',data)
vaptchaObj.reset(); //重置验证码
});
//关闭验证弹窗时触发
vaptchaObj.listen("close", function () {
//验证弹窗关闭触发
});
})
$("#comm-submit").on("click", function () {
var email = $("input[name='email']").val();
var pwd = $("input[name='pwd']").val();
if(email && pwd){
//人机验证
obj.validate();
}else{
tsNotice('账号和密码必须输入!');
}
});
</script>
<!--{else}-->
<script>
$("#comm-submit").on("click", function () {
var email = $("input[name='email']").val();
var pwd = $("input[name='pwd']").val();
var cktime = $("input[name='cktime']").val();
var jump = $("input[name='jump']").val();
var token = $("input[name='token']").val();
if(email && pwd){
var data = {
email:email,
pwd:pwd,
cktime:cktime,
jump:jump,
token:token,
};
tsPost('index.php?app=user&ac=login&ts=do&js=1',data)
}else{
tsNotice('账号和密码必须输入!');
}
});
</script>
<!--{/if}-->
</body>
</html>
View File
View File
View File