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
+360
View File
@@ -0,0 +1,360 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//垃圾词
case "word":
$arrWord = $new['system']->findAll('anti_word',null,'id desc');
include template('anti_word');
break;
case "worddo":
$word = tsTrim($_POST['word']);
if($word){
$isWord = $new['system']->findCount('anti_word',array(
'word'=>$word,
));
if($isWord == 0){
$new['system']->create('anti_word',array(
'word'=>$word,
'addtime'=>date('Y-m-d H:i:s'),
));
//生成缓存
$arrWords = $new['system']->findAll('anti_word');
foreach($arrWords as $key=>$item){
$arrWord[] = $item['word'];
}
$strWord = '';
$count = 1;
if(is_array($arrWord)){
foreach ($arrWord as $item) {
if ($count==1) {
$strWord .= $item;
} else {
$strWord .= '|'.$item;
}
$count++;
}
}
fileWrite('system_anti_word.php','data',$strWord);
$tsMySqlCache->set('system_anti_word',$strWord);
}
qiMsg('敏感词添加成功!');
}else{
qiMsg('敏感词不能为空!');
}
break;
case "worddelall":
$db->query("TRUNCATE ".dbprefix."anti_word");
//生成缓存
$arrWords = $new['system']->findAll('anti_word');
foreach($arrWords as $key=>$item){
$arrWord[] = $item['word'];
}
$strWord = '';
$count = 1;
if(is_array($arrWord)){
foreach ($arrWord as $item) {
if ($count==1) {
$strWord .= $item;
} else {
$strWord .= '|'.$item;
}
$count++;
}
}
fileWrite('system_anti_word.php','data',$strWord);
$tsMySqlCache->set('system_anti_word',$strWord);
qiMsg('删除成功!');
break;
case "worddel":
$id = tsIntval($_GET['id']);
$new['system']->delete('anti_word',array(
'id'=>$id,
));
//生成缓存
$arrWords = $new['system']->findAll('anti_word');
foreach($arrWords as $key=>$item){
$arrWord[] = $item['word'];
}
$strWord = '';
$count = 1;
if(is_array($arrWord)){
foreach ($arrWord as $item) {
if ($count==1) {
$strWord .= $item;
} else {
$strWord .= '|'.$item;
}
$count++;
}
}
fileWrite('system_anti_word.php','data',$strWord);
$tsMySqlCache->set('system_anti_word',$strWord);
qiMsg('删除成功!');
break;
case "wordadd":
include template('anti_wordadd');
break;
case "wordadddo":
$word = tsTrim($_POST['word']);
if($word==''){
qiMsg('敏感词必须填写!');
}
$arrWord = explode(PHP_EOL,$word);
foreach($arrWord as $key=>$item){
$word = $item;
$isWord = $new['system']->findCount('anti_word',array(
'word'=>$word,
));
if($isWord == 0){
$new['system']->create('anti_word',array(
'word'=>$word,
'addtime'=>date('Y-m-d H:i:s'),
));
}
}
//生成缓存
$arrWords = $new['system']->findAll('anti_word');
foreach($arrWords as $key=>$item){
$arrWord2[] = $item['word'];
}
$strWord = '';
$count = 1;
if(is_array($arrWord2)){
foreach ($arrWord2 as $item) {
if ($count==1) {
$strWord .= $item;
} else {
$strWord .= '|'.$item;
}
$count++;
}
}
fileWrite('system_anti_word.php','data',$strWord);
$tsMySqlCache->set('system_anti_word',$strWord);
header('Location: '.SITE_URL.'index.php?app=system&ac=anti&ts=word');
exit();
break;
//垃圾IP
case "ip":
$arrIp = $new['system']->findAll('anti_ip',null,'addtime desc');
include template('anti_ip');
break;
case "ipdo":
$ip = tsTrim($_POST['ip']);
if($ip){
$isIp = $new['system']->findCount('anti_ip',array(
'ip'=>$ip,
));
if($isIp==0){
$new['system']->create('anti_ip',array(
'ip'=>$ip,
'addtime'=>date('Y-m-d H:i:s'),
));
//生成缓存
$arrIps = $new['system']->findAll('anti_ip');
foreach($arrIps as $key=>$item){
$arrIp[] = $item['ip'];
}
fileWrite('system_anti_ip.php','data',$arrIp);
$tsMySqlCache->set('system_anti_ip',$arrIp);
}
qiMsg('垃圾IP添加成功!');
}else{
qiMsg('垃圾IP不能为空!');
}
break;
case "ipdel":
$id = tsIntval($_GET['id']);
$new['system']->delete('anti_ip',array(
'id'=>$id,
));
//生成缓存
$arrIps = $new['system']->findAll('anti_ip');
foreach($arrIps as $key=>$item){
$arrIp[] = $item['ip'];
}
fileWrite('system_anti_ip.php','data',$arrIp);
$tsMySqlCache->set('system_anti_ip',$arrIp);
qiMsg('删除成功!');
break;
//云词
case "cloud":
include template('anti_cloud');
break;
#内容举报
case "report":
$page = tsIntval($_GET['page'],1);
$url = SITE_URL.'index.php?app=system&ac=anti&ts=report&page=';
$lstart = $page*20-20;
$arrReport = $new['system']->findAll('anti_report',null,'addtime desc',null,$lstart.',20');
$reportNum = $new['system']->findCount('anti_report');
$pageUrl = pagination($reportNum, 20, $page, $url);
include template('anti_report');
break;
#内容举报删除
case "reportdelete":
$reportid = tsIntval($_GET['reportid']);
$new['system']->delete('anti_report',array(
'reportid'=>$reportid,
));
qiMsg('删除成功!');
break;
case "email":
$page = tsIntval($_GET['page'],1);
$url = SITE_URL.'index.php?app=system&ac=anti&ts=email&page=';
$lstart = $page*100-100;
$arrEmail = $new['system']->findAll('anti_email',null,'addtime desc',null,$lstart.',100');
$emailNum = $new['system']->findCount('anti_email');
$pageUrl = pagination($emailNum, 100, $page, $url);
include template('anti_email');
break;
case "email_add":
$email = tsTrim($_POST['email']);
if($email){
$new['system']->replace('anti_email',array(
'email'=>$email,
),array(
'email'=>$email,
'addtime'=>date('Y-m-d H:i:s'),
));
qiMsg('Email添加成功!');
}else{
qiMsg('Email不能为空!');
}
break;
case "email_del":
$id = tsIntval($_GET['id']);
$new['system']->delete('anti_email',array(
'id'=>$id,
));
qiMsg('删除成功!');
break;
case "phone":
$arrPhone = $new['system']->findAll('anti_phone',null,'addtime desc');
include template('anti_phone');
break;
case "phone_add":
$phone = tsTrim($_POST['phone']);
if($phone){
$new['system']->replace('anti_phone',array(
'phone'=>$phone,
),array(
'phone'=>$phone,
'addtime'=>date('Y-m-d H:i:s'),
));
qiMsg('Phone添加成功!');
}else{
qiMsg('Phone不能为空!');
}
break;
case "phone_del":
$id = tsIntval($_GET['id']);
$new['system']->delete('anti_phone',array(
'id'=>$id,
));
qiMsg('删除成功!');
break;
}
+244
View File
@@ -0,0 +1,244 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//app列表
case "list":
$arrAppNav = $GLOBALS['TS_SITE']['appnav'];
$applists = tsScanDir('app');
foreach($applists as $key=>$item){
if(is_file('app/'.$item.'/about.php')){
$arrApps[$key]['name'] = $item;
$arrApps[$key]['about'] = require_once 'app/'.$item.'/about.php';
if($arrAppNav[$item]){
$arrApps[$key]['about']['name'] = $arrAppNav[$item];
}
if(is_file('app/'.$item.'/icon.png')){
$arrApps[$key]['icon'] = SITE_URL.'app/'.$item.'/icon.png';
}else{
$arrApps[$key]['icon'] = SITE_URL.'public/images/app.png';
}
}
}
foreach($arrApps as $item){
$arrApp[] = $item;
}
$title = 'APP管理';
include template("apps");
break;
//安装APP
/*
case "install":
$appname = tsTrim($_GET['appname']);
$appAbout = require_once 'app/'.$appname.'/about.php';
$isinstall = $appAbout['isinstall'];
$issql = $appAbout['issql'];
$issystem = $appAbout['issystem'];
if($isinstall == '0'){
if($issql == '1'){
//安装数据库
$sql = file_get_contents('app/'.$appname.'/sql/install.sql');
$sql = str_replace('ts_',dbprefix,$sql);
$array_sql = preg_split("/;[\r\n]/", $sql);
foreach($array_sql as $sql){
$sql = tsTrim($sql);
if ($sql){
if (strstr($sql, 'CREATE TABLE')){
preg_match('/CREATE TABLE ([^ ]*)/', $sql, $matches);
$ret = $db->query($sql);
} else {
$ret = $db->query($sql);
}
}
}
}
//更新about.php文件
$appAbout['isinstall'] = '1';
AppFileWrite($appAbout,$appname,'about.php');
echo '1';
}elseif($isinstall == '1'){
if($issql == '1'){
//卸载数据库
$sql = file_get_contents('app/'.$appname.'/sql/uninstall.sql');
$sql = str_replace('ts_',dbprefix,$sql);
$array_sql = preg_split("/;[\r\n]/", $sql);
foreach($array_sql as $sql){
$sql = tsTrim($sql);
if ($sql){
$ret = $db->query($sql);
}
}
}
$appAbout['isinstall'] = '0';
AppFileWrite($appAbout,$appname,'about.php');
echo '2';
}else{
echo '3';
}
break;
*/
//导航
case "appnav":
$appkey = $_POST['appkey'];
$appname = $_POST['appname'];
$arrNav = include 'data/system_appnav.php';
if(is_array($arrNav)){
$arrNav[$appkey] = $appname;
}else{
$arrNav = array(
$appkey=>$appname,
);
}
foreach($arrNav as $key=>$item){
if(!is_dir('app/'.$key)){
unset($arrNav[$key]);
}
}
fileWrite('system_appnav.php','data',$arrNav);
$GLOBALS['tsMySqlCache']->set('system_appnav',$arrNav);
echo '1';
break;
//取消导航
case "unappnav":
$appkey = $_POST['appkey'];
$arrNav = include 'data/system_appnav.php';
unset($arrNav[$appkey]);
fileWrite('system_appnav.php','data',$arrNav);
$GLOBALS['tsMySqlCache']->set('system_appnav',$arrNav);
echo '1';
break;
//我的社区导航
case "mynav":
$appkey = tsTrim($_POST['appkey']);
$appname = tsTrim($_POST['appname']);
$arrMyNav = include 'data/system_mynav.php';
if(is_array($arrMyNav)){
$arrMyNav[$appkey] = $appname;
}else{
$arrMyNav = array(
$appkey=>$appname,
);
}
foreach($arrMyNav as $key=>$item){
if(!is_dir('app/'.$key)){
unset($arrMyNav[$key]);
}
}
fileWrite('system_mynav.php','data',$arrMyNav);
$GLOBALS['tsMySqlCache']->set('system_mynav',$arrMyNav);
echo '1';
break;
case "unmynav":
$appkey = tsTrim($_POST['appkey']);
$arrMyNav = include 'data/system_mynav.php';
unset($arrMyNav[$appkey]);
fileWrite('system_mynav.php','data',$arrMyNav);
$GLOBALS['tsMySqlCache']->set('system_mynav',$arrMyNav);
echo '1';
break;
case "applist":
$arrAppNav = include 'data/system_appnav.php';
include template("apps_applist");
break;
case "applistdo":
$arrAppNav = include 'data/system_appnav.php';
$jsondata = stripslashes($_POST['jsondata']);
$arrJson = json_decode($jsondata,true);
foreach($arrJson as $key=>$item){
$arrNav[$item['id']] = $arrAppNav[$item['id']];
}
//print_r($arrNav);
fileWrite('system_appnav.php','data',$arrNav);
$GLOBALS['tsMySqlCache']->set('system_appnav',$arrNav);
break;
case "mylist":
$arrMyNav = include 'data/system_mynav.php';
include template("apps_mylist");
break;
case "mylistdo":
$arrMyNav = include 'data/system_mynav.php';
$jsondata = stripslashes($_POST['jsondata']);
$arrJson = json_decode($jsondata,true);
foreach($arrJson as $key=>$item){
$arrNav[$item['id']] = $arrMyNav[$item['id']];
}
fileWrite('system_mynav.php','data',$arrNav);
$GLOBALS['tsMySqlCache']->set('system_mynav',$arrNav);
break;
}
+45
View File
@@ -0,0 +1,45 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "":
include template('cache');
break;
//删除全部
case "delall":
rmrf('cache/template');
rmrf('cache/user');
rmrf('cache/group');
rmrf('cache/lang');
qiMsg('缓存清除完毕!');
break;
//删除temp
case "deltemp":
rmrf('cache/template');
qiMsg('缓存清除完毕!');
break;
//删除group
case "delgroup":
rmrf('cache/group');
qiMsg('缓存清除完毕!');
break;
//删除user
case "deluser":
rmrf('cache/user');
qiMsg('缓存清除完毕!');
break;
//删除语言包
case "dellang":
rmrf('cache/lang');
qiMsg('缓存清除完毕!');
break;
}
+45
View File
@@ -0,0 +1,45 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "options":
$arrData = array(
'site_title' => tsTrim($_POST['site_title']),
'site_subtitle' => tsTrim($_POST['site_subtitle']),
'site_key' => tsTrim($_POST['site_key']),
'site_desc' => tsTrim($_POST['site_desc']),
'site_url' => tsTrim($_POST['site_url']),
'site_email' => tsTrim($_POST['site_email']),
'site_icp' => tsTrim($_POST['site_icp']),
'isface' => tsIntval($_POST['isface']),
'isinvite'=> tsIntval($_POST['isinvite']),
'isgzip' => tsIntval($_POST['isgzip']),
'timezone' => $_POST['timezone'],
'isverify'=>tsIntval($_POST['isverify']),
);
foreach ($arrData as $key => $val){
$new['system']->update('system_options',array(
'optionname'=>$key,
),array(
'optionvalue'=>$val,
));
}
$arrOptions = $new['system']->findAll('system_options',null,null,'optionname,optionvalue');
foreach($arrOptions as $item){
$arrOption[$item['optionname']] = $item['optionvalue'];
}
fileWrite('system_options.php','data',$arrOption);
$tsMySqlCache->set('system_options',$arrOption);
qiMsg("系统选项更新成功,并重置了缓存文件^_^");
break;
}
+44
View File
@@ -0,0 +1,44 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "list":
$page = tsIntval($_GET['page'],1);
$url = SITE_URL.'index.php?app=system&ac=editor&ts=list&page=';
$lstart = $page*20-20;
$arrEditor = $new['system']->findAll('editor',null,'addtime desc',null,$lstart.',20');
$editorNum = $new['system']->findCount('editor');
$pageUrl = pagination($editorNum, 20, $page, $url);
include template('editor_list');
break;
case "delete":
$id = tsIntval($_GET['id']);
$strEditor = $new['system']->find('editor',array(
'id'=>$id,
));
if($strEditor['url']){
if($GLOBALS['TS_SITE']['file_upload_type']==1){
deleteAliOssFile('uploadfile/editor/'.$strEditor['url']);
}else{
unlink('uploadfile/editor/'.$strEditor['url']);
}
}
$new['system']->delete('editor',array(
'id'=>$id,
));
qiMsg('删除成功!');
break;
}
+5
View File
@@ -0,0 +1,5 @@
<?php
defined('IN_TS') or die('Access Denied.');
$title = '管理后台';
include template("admincp");
+49
View File
@@ -0,0 +1,49 @@
<?php
defined('IN_TS') or die('Access Denied.');
//登录
switch($ts){
case "":
$title = '登录后台';
include template("login");
break;
case "do":
$email = tsTrim($_POST['email']);
$pwd = tsTrim($_POST['pwd']);
$cktime = $_POST['cktime'];
if($email=='' || $pwd=='') qiMsg("所有输入项都不能为空^_^");
$countAdmin = $new['system']->findCount('user',array(
'email'=>$email,
));
if($countAdmin == 0) qiMsg('用户Email不存在!');
$strAdmin = $new['system']->find('user',array(
'email'=>$email,
));
if(md5($strAdmin['salt'].$pwd)!==$strAdmin['pwd']) tsNotice('用户密码错误!');
$strAdminInfo = $new['system']->find('user_info',array(
'email'=>$email,
),'userid,username,isadmin');
if($strAdminInfo['isadmin'] != 1) qiMsg("你无权登录后台管理!");
$_SESSION['tsadmin'] = $strAdminInfo;
header("Location: ".SITE_URL."index.php?app=system");
break;
//退出
case "out":
unset($_SESSION['tsadmin']);
header("Location: ".SITE_URL."index.php?app=system&ac=login");
break;
}
+45
View File
@@ -0,0 +1,45 @@
<?php
defined('IN_TS') or die('Access Denied.');
$dest_dir = 'uploadfile/logo';
createFolders ( $dest_dir );
$arrType = explode ( '.', strtolower ( $_FILES ['filedata'] ['name'] ) ); // 转小写一下
$type = array_pop ( $arrType );
if (in_array ( $type, array('jpg','jpeg','gif','png') )) {
$name = 'logo.' . $type;
$dest = $dest_dir . '/' . $name;
// 先删除
unlink ( $dest );
// 后上传
move_uploaded_file ( $_FILES ['filedata'] ['tmp_name'], mb_convert_encoding ( $dest, "gb2312", "UTF-8" ) );
chmod ( $dest, 0777 );
$new['system']->delete('system_options',array(
'optionname'=>'logo',
));
$new['system']->create('system_options',array(
'optionname'=>'logo',
'optionvalue'=>$name.'?v='.time(),
));
$arrOptions = $new['system']->findAll('system_options',null,null,'optionname,optionvalue');
foreach($arrOptions as $item){
$arrOption[$item['optionname']] = $item['optionvalue'];
}
fileWrite('system_options.php','data',$arrOption);
$tsMySqlCache->set('system_options',$arrOption);
echo SITE_URL.$dest.'?v='.rand();
}
+52
View File
@@ -0,0 +1,52 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "list":
$page = tsIntval($_GET['page'],1);
$url = SITE_URL.'index.php?app=system&ac=logs&ts=list&page=';
$lstart = $page*20-20;
$arrLogs = $new['system']->findAll('logs',null,'addtime desc',null,$lstart.',20');
$logsNum = $new['system']->findCount('logs');
$pageUrl = pagination($logsNum, 20, $page, $url);
include template('logs_list');
break;
case "show":
$logid = tsIntval($_GET['logid']);
$strLog = $new['system']->find('logs',array(
'logid'=>$logid,
));
include template('logs_show');
break;
case "delete":
$logid = tsIntval($_GET['logid']);
$new['system']->delete('logs',array(
'logid'=>$logid,
));
qiMsg('删除成功!');
break;
case "clean":
$db->query("TRUNCATE `".dbprefix."logs`;");
qiMsg('操作成功!');
break;
}
+24
View File
@@ -0,0 +1,24 @@
<?php
defined('IN_TS') or die('Access Denied.');
$os = explode(" ", php_uname());
if(!function_exists("gd_info")){$gd = '不支持,无法处理图像';}
if(function_exists("gd_info")) { $gd = gd_info(); $gd = $gd["GD Version"]; $gd ? '&nbsp; 版本:'.$gd : '';}
$systemInfo = array(
'server' => $_SERVER['SERVER_SOFTWARE'],
'phpos' => PHP_OS,
'phpversion' => PHP_VERSION,
'mysql' => $db->getMysqlVersion(),
'os' =>$os[0] .''.$os[1].' '.$os[3],
'gd'=>$gd,
'upload' =>'表单允许 (post_max_size) '.ini_get('post_max_size').',上传总大小 (upload_max_filesize) '.ini_get('upload_max_filesize'),
'memory'=> 'memory_limit '.ini_get('memory_limit'),
);
//获取域名
#$theAuthUrl = GetUrlToDomain($_SERVER['HTTP_HOST']);
include template("main");
+93
View File
@@ -0,0 +1,93 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "":
$arrOptions = $new['system']->findAll('system_options');
foreach($arrOptions as $item){
$strOption[$item['optionname']] = stripslashes($item['optionvalue']);
}
//时区和语言
$arrTime = getArrTimezone();
$arrTheme = tsScanDir('theme');
include template("options");
break;
//保存配置
case "do":
$strLogo = $new['system']->find('system_options',array(
'optionname'=>'logo',
));
//先清空数据
$db->query("TRUNCATE TABLE `".dbprefix."system_options`");
foreach($_POST['option'] as $key=>$item){
$optionname = $key;
$optionvalue = tsTrim($item);
$new['system']->create('system_options',array(
'optionname'=>$optionname,
'optionvalue'=>$optionvalue,
));
}
$new['system']->create('system_options',array(
'optionname'=>'logo',
'optionvalue'=>$strLogo['optionvalue'],
));
$arrOptions = $new['system']->findAll('system_options',null,null,'optionname,optionvalue');
foreach($arrOptions as $item){
$arrOption[$item['optionname']] = $item['optionvalue'];
}
fileWrite('system_options.php','data',$arrOption);
$tsMySqlCache->set('system_options',$arrOption);
//生成伪静态文件
if($_POST['option']['site_urltype'] == 3 || $_POST['option']['site_urltype'] == 4 || $_POST['option']['site_urltype'] == 5 || $_POST['option']['site_urltype'] == 6 || $_POST['option']['site_urltype'] == 7){
$scriptName = explode('index.php',$_SERVER['SCRIPT_NAME']);
//生成.htaccess文件
$fp = fopen(THINKROOT.'/.htaccess','w');
if(!is_writable(THINKROOT.'/.htaccess')) qiMsg("文件(.htaccess)不可写。如果您使用的是Unix/Linux主机,请修改该文件的权限为777。如果您使用的是Windows主机,请联系管理员,将此文件设为everyone可写");
$htaccess = "RewriteEngine On\n"
."RewriteBase ".$scriptName[0]."\n"
."RewriteRule ^index\.php$ - [L]\n"
."RewriteCond %{REQUEST_FILENAME} !-f\n"
."RewriteCond %{REQUEST_FILENAME} !-d\n"
."RewriteRule . ".$scriptName[0]."index.php [L]\n"
."RewriteCond %{REQUEST_METHOD} ^TRACE\n"
."RewriteRule .* - [F]";
$fw = fwrite($fp,$htaccess);
}
//更新皮肤
setcookie('tsTheme',$_POST['option']['site_theme']);
qiMsg("系统选项更新成功,并重置了缓存文件^_^");
break;
}
+10
View File
@@ -0,0 +1,10 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/19
* Time: 17:14
*/
defined('IN_TS') or die('Access Denied.');
phpinfo();
+114
View File
@@ -0,0 +1,114 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//插件列表
case "list":
$arrApps = tsScanDir('plugins');
foreach($arrApps as $key=>$item){
$arrAppsAbout[$item] = fileRead('app/'.$item.'/about.php');
}
//print_r($arrAppsAbout);
$apps = tsFilter($_GET['apps']);
$hook = tsTrim($_GET['hook']);
$arrPlugins = tsScanDir('plugins/'.$apps);
foreach($arrPlugins as $key=>$item){
if(is_file('plugins/'.$apps.'/'.$item.'/about.php')){
$arrPlugin1[$key]['name'] = $item;
$arrPlugin1[$key]['about'] = require_once 'plugins/'.$apps.'/'.$item.'/about.php';
}
}
if($arrPlugin1 && $hook){
foreach($arrPlugin1 as $key=>$item){
if($item['about']['hook']==$hook){
$arrPlugin[] = $item;
}
}
}else{
$arrPlugin = $arrPlugin1;
}
$app_plugins = fileRead('data/'.$apps.'_plugins.php');
if($app_plugins==''){
$app_plugins = $tsMySqlCache->get($apps.'_plugins');
}
include template("plugin_list");
break;
//插件停启用
case "do":
$apps = tsFilter($_GET['apps']);
$isused = tsIntval($_GET['isused']);
$pname = tsFilter($_GET['pname']);
$app_plugins = fileRead('data/'.$apps.'_plugins.php');
if($app_plugins==''){
$app_plugins = $tsMySqlCache->get($apps.'_plugins');
}
//0停用1启用
if($isused == '0'){
$pkey = array_search($pname,$app_plugins);
unset($app_plugins[$pkey]);
fileWrite($apps.'_plugins.php','data',$app_plugins);
$tsMySqlCache->set($apps.'_plugins',$app_plugins);
qiMsg("插件停用成功!");
}elseif($isused == '1'){
$pkey = array_search($pname,$app_plugins);
unset($app_plugins[$pkey]);
array_push($app_plugins,$pname);
if(file_exists('plugins/'.$apps.'/'.$pname.'/install.sql')){
$sql=file_get_contents('plugins/'.$apps.'/'.$pname.'/install.sql');
$sql=str_replace('ts_',''.dbprefix.'',$sql);
$ret=$db->query($sql);
if($ret=='1')
{
fileWrite($apps.'_plugins.php','data',$app_plugins);
$tsMySqlCache->set($apps.'_plugins',$app_plugins);
$msg='插件启用成功!';
}else{
$msg=$ret;
}
}else{
fileWrite($apps.'_plugins.php','data',$app_plugins);
$tsMySqlCache->set($apps.'_plugins',$app_plugins);
$msg='插件启用成功!';
}
qiMsg($msg);
}
break;
//删除插件
case "delete":
$apps = tsUrlCheck($_GET['apps']);
$pname = tsUrlCheck($_GET['pname']);
delDir('plugins/'.$apps.'/'.$pname);
qiMsg('删除成功!');
break;
}
+16
View File
@@ -0,0 +1,16 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/5/7
* Time: 14:42
*/
defined('IN_TS') or die('Access Denied.');
//实例化redis
$redis = new Redis();
//连接
$redis->connect($TS_CF['redis']['host'], $TS_CF['redis']['port']);
//检测是否连接成功
echo "Server is running: " . $redis->ping();
// 输出结果 Server is running: +PONG
+61
View File
@@ -0,0 +1,61 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "":
$title = '反垃圾';
include template('spam');
break;
case "get":
$api = file_get_contents('https://www.thinksaas.cn/index.php?app=service&ac=spam&ts=api');
$arrSpam = json_decode($api,true);
foreach($arrSpam as $key=>$item){
$isword = $new['system']->findCount('anti_word',array(
'word'=>$item,
));
if($isword==0){
$new['system']->create('anti_word',array(
'word'=>$item,
'addtime'=>date('Y-m-d H:i:s'),
));
}
}
//生成缓存
$arrWords = $new['system']->findAll('anti_word');
foreach($arrWords as $key=>$item){
$arrWord[] = $item['word'];
}
$strWord = '';
$count = 1;
if(is_array($arrWord)){
foreach ($arrWord as $item) {
if ($count==1) {
$strWord .= $item;
} else {
$strWord .= '|'.$item;
}
$count++;
}
}
fileWrite('system_anti_word.php','data',$strWord);
$tsMySqlCache->set('system_anti_word',$strWord);
header('Location: '.SITE_URL.'index.php?app=system&ac=anti&ts=word');
break;
}
+6
View File
@@ -0,0 +1,6 @@
<?php
defined('IN_TS') or die('Access Denied.');
include template('sql');
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/19
* Time: 17:14
*/
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "":
include template('test');
break;
case "do":
print_r($_FILES['file']);
break;
}
+209
View File
@@ -0,0 +1,209 @@
<?php
defined('IN_TS') or die('Access Denied.');
function file_list($path){
if ($handle = opendir($path)){
while (false !== ($file = readdir($handle))){
if ($file != "." && $file != ".."){
if (is_dir($path."/".$file)){
file_list($path."/".$file);
}else{
$upfile = $path."/".$file;
$nfile = substr($path.'/'.$file,13);
$npath = substr($path,13);
if(abcefile($npath)==='1'){
#return $npath;
getJson($npath.'目录没有可写权限,linux请给755权限',1,0);
}
if(is_file($nfile)){
if(copy($upfile,$nfile)===false){
getJson('升级文件覆盖失败',1,0);
}
}else{
if(copy($upfile,$nfile)===false){
getJson('升级文件覆盖失败',1,0);
}
}
}
}
}
}
}
function abcefile($path){
if ($handle = opendir($path)){
while (false !== ($file = readdir($handle))){
if ($file != "." && $file != ".."){
if (is_dir($path."/".$file)){
abcefile($path."/".$file);
}else{
$upfile = $path."/".$file;
//如果文件存在
if(is_file($upfile)){
//检测文件是否可写
if(is_writable($upfile)==false){
return '1';exit;//不可写就停止并返回1
}
}
}
}
}
}
}
switch($ts){
case "":
include template('update');
break;
case "iswritable":
$msg = '';
#检测php必要函数
if(function_exists('opendir')==false) $msg .= 'opendir函数不可用<br />';#opendir
if(function_exists('readdir')==false) $msg .= 'readdir函数不可用<br />';#readdir
if(function_exists('copy')==false) $msg .= 'copy函数不可用<br />';#copy
#检查php必要扩展
if(extension_loaded('Fileinfo')==false) $msg .= 'Fileinfo扩展不可用<br />';#Fileinfo
#检测upgrade目录是否可写
if(abcefile('upgrade')) $msg .= 'upgrade目录不可写<br />';
echo $msg;
break;
//手动升级检测
case "hand":
$upid = tsIntval($_GET['upid']);
include template('update_hand');
break;
//第一步检测可写权限
case "one":
include template('update_one');
break;
//第二步,升级数据库
case "two":
include template('update_two');
break;
case "twodo":
$upsql = tsTrim($_POST['upsql']);
if($upsql){
$arrSql = explode('--------------------',$upsql);
foreach($arrSql as $item){
$item = tsTrim($item);
if ($item){
$db->query($item);
}
}
//执行成功
echo '1';exit;
}else{
//无SQL可执行
echo '0';exit;
}
//echo '1';exit;
break;
//第三部,升级系统文件
case "three":
include template('update_three');
break;
case "threedo":
$upversion = tsTrim($_GET['upversion']);
if($upversion==''){
getJson('版本号有问题',1,0);
}
$filezip = $upversion.'.zip';
//先删除旧的zip升级文件
unlink('upgrade/'.$filezip);
delDir('upgrade/'.$upversion);
//拼接出要下载的远程文件
$upfile = 'https://www.thinksaas.cn/upgrade/'.$filezip;
//第一步:多线程下载zip压缩文件
$urls=array(
$upfile,
$upfile,
$upfile,
);
$save_to='upgrade/';
$mh=curl_multi_init();
foreach($urls as $i=>$url){
//$g=$save_to.basename($url);
$g = $save_to.$filezip;
if(!is_file($g)){
$conn[$i]=curl_init($url);
$fp[$i]=fopen($g,"w");
curl_setopt($conn[$i],CURLOPT_USERAGENT,"Mozilla/4.0(compatible; MSIE 7.0; Windows NT 6.0)");
curl_setopt($conn[$i],CURLOPT_FILE,$fp[$i]);
curl_setopt($conn[$i],CURLOPT_HEADER ,0);
curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,60);
curl_multi_add_handle($mh,$conn[$i]);
}
}
do{
$n=curl_multi_exec($mh,$active);
}while($active);
foreach($urls as $i=>$url){
curl_multi_remove_handle($mh,$conn[$i]);
curl_close($conn[$i]);
fclose($fp[$i]);
}
curl_multi_close($mh);
chmod('upgrade/'.$filezip,0755);
//第二步:下载完之后开始解压覆盖原有文件
include 'thinksaas/pclzip.lib.php';
$archive = new PclZip('upgrade/'.$filezip);
if ($archive->extract(PCLZIP_OPT_PATH, 'upgrade/'.$upversion,PCLZIP_OPT_REPLACE_NEWER) == 0) {
getJson('升级包解压失败',1,0);
}else{
unlink('upgrade/'.$filezip);
}
//直接循环覆盖吧
file_list('upgrade/'.$upversion);
//删除目录
delDir('upgrade/'.$upversion);
getJson('升级成功',1,1);
break;
}