init();
$config = $t->config;
!$config['charset'] && $config['charset'] = PHPS_CHARSET;
define('PHP_CHARSET',$config['charset']);
define('DBNAME', $config['db']['1']['dbname']);
header('Content-type: text/html; charset=utf-8');
if(!is_login()) {
login_page();
exit;
}
define('DB_PRE',$t->dbconfig['tablepre']);
# Tuesday 新增加功能.
switch($action){
case 'serverinfo':
include_once(TOOLS_ROOT.'source/class/class_core.php');
include_once(TOOLS_ROOT.'source/function/function_core.php');
header('Content-type: text/html; charset=utf-8');
$discuz = & discuz_core::instance();
$discuz->init();
$_axtime = microtime(true);
set_time_limit(0);
$fileint = $dirint = 0;
function getBytes($folder = './'){
global $fileint,$dirint;
$totalSize=0;
$handle = @opendir($folder) or die("Cannot open " . $folder);
$dirint ++;
while($file = readdir($handle)){
if($file !== "." && $file !== ".."){
if(is_dir($folder.$file.'/')){
$totalSize += getBytes($folder.$file.'/');
}
if(is_file($folder.$file)){
$totalSize += filesize($folder.$file);
$fileint ++;
}
}
}
closedir($handle);
return $totalSize;
}
$formhash = thash();
$filesize = fun_size(getBytes());
$timezone = date_default_timezone_get();
$datetime = date('Y-m-d H:i:s', time());
$sapiname = php_sapi_name();
$tools_discuz_version =TOOLS_DISCUZ_VERSION;
$dbver = DB::fetch_first("SELECT VERSION() AS ver");
!$dbver['ver'] && $dbver['ver'] = 'empty';
$phpver = 'php/'. phpversion();
if(strpos($sapiname,'apache') !== false)
$sapiname = apache_get_version();
if(is_file('./data/install.lock') && $t = filemtime('./data/install.lock')){
$installtime = date('Y-m-d H:i:s',$t);
$runtime = round((time() - $t) / (3600*24));
}
$databases = DBNAME;
$sql = "SHOW TABLE STATUS FROM `{$databases}`";
$query = DB::query($sql);
$indexcount = $tabcount = $tabsize = 0;
while($row = DB::fetch($query)){
$l = fun_size($row['Data_length']);
$inl = fun_size($row['Index_length']);
$dbsection .= "";
$tabsize += $row['Data_length'];
$indexcount += $row['Index_length'];
$tabcount += 1;
}
$allcount = fun_size($tabsize+$indexcount);
$tabsize = fun_size($tabsize);
$indexcount =fun_size($indexcount);
$xtime = sprintf('%0.2f', (microtime(true) - $_axtime));
// TODO: 首页显示层.
show_header();
print<< 欢迎使用 Tools 之 Discuz! 急诊箱功能!我们致力于为您解决 Discuz! 站点的紧急故障,欢迎各位站长朋友们使用。Discuz 版本:
服务器信息:
文件信息:
数据库信息:
性能相关
END;
show_footer();
break;
case 'editpass':
if($_POST['act'] == 'delepluges'){
$pname = trim($_POST['pluname']);
if(!$pname){
show_msg('请输入插件名字或者插件ID');
}
$tem = explode(' ', $pname);
$wherestr = '';
if($tem[0]){
$names = $tem[0];
$wherestr .= "AND `name`='$names' ";
}
if($tem[1]){
$names = $tem[1];
$wherestr .= "AND `version`='$names'";
}
if(is_numeric($pname)){
$pname += 0;
$wherestr = "AND `pluginid`='$pname'";
}
if(strpos($pname, '/') === (strlen($pname)-1)){
$names = $pname;
$wherestr = "AND `directory`='$names'";
}
$t->connect_db();
$sql = "SELECT * FROM ".DB_PRE."common_plugin WHERE 1 {$wherestr} LIMIT 1";
$pludata = mysql_fetch_array(mysql_query($sql,$t->db), MYSQL_ASSOC);
if(!$pludata){
show_msg('未找到插件: '.htmlspecialchars($tem[0]).' 版本号:'.htmlspecialchars($tem[1]) );
}
$is_check = unserialize($pludata['modules']);
if($is_check['system']){
show_msg('系统插件, 请不要删除之!');
}
$pid = $pludata['pluginid']+0;
$pludata['directory'] = strtr($pludata['directory'], array('.'=>''));
$dirs = './source/plugin/'.$pludata['directory'];
if(!is_dir($dirs)){
show_msg('插件目录不存在:'.$dirs.' 请手工创建目录后, 再删除插件');
}
if(!$pludata['directory'] || strlen($pludata['directory']) <= 1){
show_msg('检测到的插件目录非法');
}
function delTree($dir) {
$dir = rtrim($dir,'/');
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
}
return @rmdir($dir);
}
if($is_check['extra']['uninstallfile']){
$filename = DISCUZ_ROOT.'./source/plugin/'.$pludata['directory'].$is_check['extra']['uninstallfile'];
@include_once($filename);
}
if(!delTree($dirs))
show_msg('插件目录无法删除:'.$dirs.' 请检查权限');
if($pid){
mysql_query("DELETE FROM ".DB_PRE."common_plugin WHERE pluginid='$pid'",$t->db);
mysql_query("DELETE FROM ".DB_PRE."common_pluginvar WHERE pluginid='$pid'",$t->db);
}
if(true)
show_msg(htmlspecialchars($pname).'插件 已经删除成功!');
}
// TODO: 修改密码, 让用户管理这个平台更方便.
if($_POST['oldpass'] && $_POST['newpass']){
$oldpass = trim($_POST['oldpass']);
$newpass = trim($_POST['newpass']);
$thash = $_POST['formhash'];
if($thash !== thash()){
show_msg('你所请求的来路不正常, 请稍候重试!');
}
if($oldpass == $newpass){
show_msg('不能设置相同于旧密码的新密码');
}
if(strlen($oldpass) <5 || strlen($oldpass) < 5){
show_msg('不能设置小于5位的密码');
}
$oldpass = md5($oldpass);
if( $oldpass !== TPASSWORD){
show_msg('你的旧密码错误');
}
$newpass = md5($newpass);
$isfw = 1;
}
#修改当前文件.以便让密码更新进去.
if($isfw === 1){
if(!is_writable(__FILE__)){
show_msg('本文件禁止可写, 请设置可写权限!');
}
$fp = @fopen(__FILE__,'rb+');
while(!feof($fp)){
$t = fgets($fp);
if($newpass && strpos($t,'TPASSWORD')!== false && strpos($t,$oldpass) !== false ){
$rept = strtr($t, array($oldpass=>$newpass));
$fell = ftell($fp);
if($rept !== $t){
fseek($fp,($fell-strlen($t)));
fwrite($fp,$rept);
$isuser = 1;
}
break;
}
}
fclose($fp);
if($isuser){
$toolsmd5 = md5($newpass.thash());
show_msg('密码修改成功,请牢记你的密码!');
}else{
show_msg('密码修改失败,请联系tools技术员!');
}
}
break;
}
if($action == 'index') {
// TODO: 首页
show_header();
$formhash = thash();
$errmsg = ERROR_MSG;
print<<
END; show_footer(); }elseif($action == 'reinstall') { // TODO: 安装discuz x if(!$_POST) show_header(); $downlink = 'http://download.comsenz.com/DiscuzX/'.DISCUZ_DOWN_VERSION.'/'; $cachepath = './'; # post 数据 if($_POST){ $chfile = $_POST['chfile']; define('YESINSTALL', 1); if(!$chfile) show_msg('请至少选择一项!', 'tools.php?action='.$action, 2000); if(!in_array($chfile, array('two','clear'))){ $link = $downlink.$chfile; set_time_limit(0); if(!YESINSTALL){ $olddir = scandir('./'); if(count($olddir) >= 20){ show_msg('根目录已经存在discuz文件, 请确认并且勾选强制覆盖文件, 重试一次!', 'tools.php?action='.$action, 2000); } } fun_reinstall('back','./'); $fwint = file_put_contents($cachepath.$chfile, curl_getdata($link)); $zip = new zip(); $b = $zip->Extract($cachepath.$chfile,'./'); $oldfile = sfopen(true); @unlink($cachepath.$chfile); if(count($oldfile[1]) > 1000){ show_msg('全新安装过程即将开始....', 'install/', 2000); } show_msg('如果你需要全新安装程序, 请先清空目录!'.count($oldfile[1]), 'tools.php?action='.$action, 2000); }else{ fun_reinstall($_POST['chfile'],'./'); if($_POST['chfile'] !== 'two'){ show_msg('整个discuz目录已经备份完成', 'tools.php?action='.$action, 2000); } } exit(); } if(!$filelist = curl_getdata($downlink)) echo '请确认你的网络是否通畅!'; if($filelist){ preg_match_all('#([^"]*).zip.*([0-9]*-[0-9]*-[0-9]* [0-9]*\:[0-9]*).*([0-9.]*)M#isU', $filelist, $regfile); if(!$regfile[1]) preg_match_all('#([^"]*).zip#isU', $filelist, $regfile); foreach($regfile[1] AS $key => $val){ if($regfile[4][$key]) $regfile[4][$key] .= 'M'; $val .= '.zip'; $data .= '
'.$val.' '.$regfile[3][$key].' '.$regfile[4][$key].'
'; } } $root = TOOLS_ROOT; echo "{$data} * 全新安装过程默认会将所有文件备份一次, 请等待完成! |
现有创始人:$foundernames
"; echo "现有管理员:$adminnames
"; print<<用户名UID | |
---|---|
请输入密码 | |
是否清除安全提问 | 是 否 |
站点当前状态 打开 关闭
所有插件状态: {$plustr} 打开 关闭
END; show_footer(); } }elseif($action == 'closeplugin') { // TODO: 清理冗余数据. include_once(TOOLS_ROOT.'source/class/class_core.php'); include_once(TOOLS_ROOT.'source/function/function_core.php'); header('Content-type: text/html; charset=utf-8'); $discuz = & discuz_core::instance(); $discuz->init(); $type = $_GET['types']?$_GET['types']:'index'; // index if($type === 'index'){ $sql = $sql = "SELECT `aid`, `uid`, `dateline`, `filename`, `filesize`, `attachment`, `remote`, `isimage`, `width`, `thumb` FROM ".DB::table('forum_attachment_unused')." ORDER BY aid DESC LIMIT 0, 200"; $t = DB::fetch_all($sql); $aid_array = array(); $data = ''; foreach ($t AS $K=>$v){ $v['filename'] = htmlspecialchars($v['filename']); $v['dateline'] = date('Y-m-d H:i:s',$v['dateline']); $v['filesize'] = sprintf('%0.2f',$v['filesize'] / 1024).'KB'; if(!$_POST){ $data .= "
一键修复 | 进入详细页面检查或修复 |
版本设置数量 |
主题设置数量 |
首页 | 系统信息 | 幸福指数 | 安装discuzx | 重置管理员帐号 | 开启 & 关闭功能 | 清理冗余信息 | 修复数据库 | 恢复数据库 | 更新缓存 | 退出 |