反馈建议', '您对Tools工具箱的建议和意见,以及使用过程中遇到的问题,可以及时的反馈给我们。')
);
//初始化
$lockfile = ''; //tools锁存放位置
$action = '';
$target_fsockopen = '0'; //使用何种方式进行连接服务器 0=域名, 1=IP (使用IP方式需要保证IP地址可以正常访问到您的站点)
$alertmsg = ' onclick="alert(\'点击确定开始运行,可能需要一段时间,请稍候\');"';
//释放变量到全局
foreach(array('_COOKIE', '_POST', '_GET') as $_request) {
foreach($$_request as $_key => $_value) {
($_key{0} != '_' && $_key != 'tool_password' && $_key != 'lockfile') && $$_key = taddslashes($_value);
}
}
//判断文件位置
$whereis = getplace();
if($whereis == 'is_dz' && !defined('DISCUZ_ROOT')) {
define('DISCUZ_ROOT', TOOLS_ROOT);
}
if(!$whereis && !in_array($whereis, array('is_dz', 'is_uc', 'is_uch', 'is_ss', 'is_ec', 'is_ecm'))) {
$alertmsg = '';
errorpage('工具箱必须放在Discuz!、UCenter、UCente Home、SupeSite、ECShop或者ECmall的根目录下才能正常使用.');
}
//工具箱是否锁定
if(@file_exists($lockfile)) {
$alertmsg = '';
errorpage("
数据库('.$dbname.')的字符集统计:
gbk字段 | big5字段 | utf8字段 | latin1字段 |
---|
'.$chars[gbk].' | '.$chars[big5].' | '.$chars[utf8].' | '.$chars[latin1].' |
下列字段可能存在编码设置异常:
';
?>
$num) {
if ($char != $maincharset) {
if(is_array($tableschar[$char])) {
echo '
';
echo'
';
}else {
errorpage('MySQL数据库版本在4.1以下,没有字符集设定,无需检测', '', 0, 0);
}
htmlfooter();
} elseif ($action == 'dz_doctor') {//论坛医生
//论坛医生功能
htmlheader();
//检测DZ的目录
if($whereis != 'is_dz') {
cexit("
Tools放在论坛的目录中才可以使用本功能
");
}
echo "";
function create_checkfile() {
global $dir;
$fp = @fopen('./forumdata/checkfile.php',w);
$includedir = $dir != './' ? str_replace('forumdata/','./',$dir) : '../';
$content = "";
fwrite($fp, $content);
fclose($fp);
}
function http_fopen($host, $path, $port="80") {
global $target_fsockopen;
$conn_host = $target_fsockopen == 1 ? gethostbyname($host) : $host;
$conn_port = $port;
$abs_url = "http://$host:$port$path";
$query="GET $abs_url HTTP/1.0\r\n".
"HOST:$host:$port\r\n".
"User-agent:PHP/class http 0.1\r\n".
"\r\n";
$fp=fsockopen($conn_host, $conn_port);
if(!$fp){
return false;
}
fputs($fp,$query);
//得到返回的结果
$contents = "";
while (!feof($fp)) {
$contents .= fread($fp, 1024);
}
fclose($fp);
$array = split("\n\r", $contents, "2");
return trim($array[1]);
}
//论坛模式样式代码变量
$ok_style_s = '[color=RoyalBlue][b]';
$error_style_s = '[color=Red][b]';
$style_e = '[/b][/color]';
$title_style_s = '[b]';
$title_style_e = '[/b]';
$phpfile_array = array('discuzroot', 'templates', 'cache');//文件错误检查中的目录及对应名称($dir_array)
$dir_array = array('论坛根目录', '模板缓存目录(forumdata/templates)', '其它缓存目录(forumdata/cache)');
$doctor_top = count($phpfile_array) - 1;
//$doctor_step = isset($_REQUEST['doctor_step']) ? intval($_REQUEST['doctor_step']) : '';
if(@!include("./config.inc.php")) {
if(@!include("./config.php")) {
cexit("
请先上传config文件以保证您的数据库能正常链接!
");
}
}
if($doctor_step == $doctor_top) {
//检查Config.inc.php文件配置
$carray = $clang = $comment = array();
$doctor_config = $doctor_config_db = '';
$configfilename = file_exists('./config.inc.php') ? './config.inc.php' : './config.php';
$fp = @fopen($configfilename, 'r');
$configfile = @fread($fp, @filesize($configfilename));
@fclose($fp);
preg_match_all("/[$]([\w\[\]\']+)\s*\=\s*[\"']?(.*?)[\"']?;/is", $configfile, $cmatch);
foreach($cmatch[1] as $key => $var) {
if(!in_array($var, array('database','adminemail','admincp'))) {
$carray[$var] = $cmatch[2][$key];
}
}
$clang = array(
'dbhost' => '数据库服务器',
'dbuser' => '数据库用户名',
'dbpw' => '数据库密码',
'dbname' => '数据库名',
'pconnect' => '数据库是否持久连接',
'cookiepre' => 'cookie 前缀',
'cookiedomain' => 'cookie 作用域',
'cookiepath' => 'cookie 作用路径',
'tablepre' => '表名前缀',
'dbcharset' => 'MySQL链接字符集',
'charset' => '论坛字符集',
'headercharset' => '强制论坛页面使用默认字符集',
'tplrefresh' => '论坛风格模板自动刷新开关',
'forumfounders' => '论坛创始人uid',
'dbreport' => '是否发送错误报告给管理员',
'errorreport' => '是否屏蔽程序错误信息',
'attackevasive' => '论坛防御级别',
'admincp[\'forcesecques\']' => '管理人员是否必须设置安全提问才能进入系统设置',
'admincp[\'checkip\']' => '后台管理操作是否验证管理员的 IP',
'admincp[\'tpledit\']' => '是否允许在线编辑论坛模板',
'admincp[\'runquery\']' => '是否允许后台运行 SQL 语句',
'admincp[\'dbimport\']' => '是否允许后台恢复论坛数据',
);
$comment = array(
'pconnect' => '非持久连接',
'cookiepre' => '不检测',
'cookiepath' => '不检测',
'charset' => '不检测',
'adminemail' => '不检测',
'admincp' => '非设置项',
);
@mysql_connect($carray['dbhost'], $carray['dbuser'], $carray['dbpw']) or $mysql_errno = mysql_errno();
!$mysql_errno && @mysql_select_db($carray['dbname']) or $mysql_errno = mysql_errno();
$comment_error = "{$error_style_s}出错{$style_e}";
if ($mysql_errno == '2003') {
$comment['dbhost'] = "{$error_style_s}端口设置出错{$style_e}";
} elseif ($mysql_errno == '2005') {
$comment['dbhost'] = $comment_error;
} elseif ($mysql_errno == '1045') {
$comment['dbuser'] = $comment_error;
$comment['dbpw'] = $comment_error;
} elseif ($mysql_errno == '1049') {
$comment['dbname'] = $comment_error;
} elseif (!empty($mysql_errno)) {
$comment['dbhost'] = $comment_error;
$comment['dbuser'] = $comment_error;
$comment['dbpw'] = $comment_error;
$comment['dbname'] = $comment_error;
}
$comment['pconnect'] = '非持久链接';
$carray['pconnect'] == 1 && $comment['pconnect'] = '持久连接';
if ($carray['cookiedomain'] && substr($carray['cookiedomain'], 0, 1) != '.') {
$comment['cookiedomain'] = "{$error_style_s}请以 . 开头,不然同步登录会出错{$style_e}";
}
(!$mysql_errno && !mysql_num_rows(mysql_query('SHOW TABLES LIKE \''.$carray['tablepre'].'posts\''))) && $comment['tablepre'] = $comment_error;
if (!$comment['tablepre'] && !$mysql_errno && @mysql_get_server_info() > '4.1') {
$tableinfo = loadtable('threads');
$dzdbcharset = substr($tableinfo['subject']['Collation'], 0, strpos($tableinfo['subject']['Collation'], '_'));
if(!$carray['dbcharset'] && in_array(strtolower($carray['charset']), array('gbk', 'big5', 'utf-8'))) {
$ckdbcharset = str_replace('-', '', $carray['charset']);
} else {
$ckdbcharset = $carray['dbcharset'];
}
if ($dzdbcharset != $ckdbcharset && $ckdbcharset != '') {
$carray['dbcharset'] .= $error_style_s.'出错,您的论坛数据库字符集为 '.$dzdbcharset.' ,请将本项设置成 '.$dzdbcharset.$style_e;
}
}
if(!in_array($carray['charset'],array('gbk', 'big5', 'utf-8'))) {
$carray['charset'] .= $error_style_s." 出错,目前字符集只支持'gbk', 'big5', 'utf-8'".$style_e;
}
if ($carray['headercharset'] == 0) {
$comment['headercharset'] = $title_style_s.'未开启'.$title_style_e;
} else {
$comment['headercharset'] = $ok_style_s.'开启'.$style_e;
}
if ($carray['tplrefresh'] == 0) {
$comment['tplrefresh'] = $title_style_s.'关闭'.$title_style_e;
} else {
$comment['tplrefresh'] = $ok_style_s.'开启'.$style_e;
}
if (preg_match('/[^\d,]/i', str_replace(' ', '', $carray['forumfounders']))) {
$comment['forumfounders'] = $error_style_s.'出错:含有非法字符,该项设置只能含有数字和半角逗号 ,'.$style_e;
} elseif(!$comment['tablepre'] && !$mysql_errno) {
if ($carray['forumfounders']) {
$founderarray = explode(',', str_replace(' ', '', $carray['forumfounders']));
$adminids = $notadminids = '';
$notadmin = 0;
foreach($founderarray as $fdkey) {
if (@mysql_result(@mysql_query("SELECT adminid FROM {$carray[tablepre]}members WHERE uid = '$fdkey' LIMIT 1"), 0) == 1) {
$isadmin ++;
$iscomma = $isadmin > 1 ? ',' : '';
$adminids .= $iscomma.$fdkey;
} else {
$notadmin ++;
$notcomma = $notadmin > 1 ? ',' : '';
$notadminids .= $notcomma.$fdkey;
}
}
if (!$isadmin) {
$comment['forumfounders'] = $error_style_s.'出错:创始人中无管理员'.$style_e;
} elseif ($notadmin) {
$comment['forumfounders'] = $error_style_s.'警告:创始人中有非管理员,uid如下:'.$notadminids.$style_e;
}
} else {
$comment['forumfounders'] = $error_style_s.'警告:创始人设置为空,多个管理员将可能有安全问题'.$style_e;
}
}
$comment['dbreport'] = $carray['dbreport'] == 0 ? '不发送错误报告' : '发送错误报告';
$comment['errorreport'] = $carray['errorreport'] == 1 ? '屏蔽程序错误' : '不屏蔽程序错误';
if (preg_match('/[^\d|]/i', str_replace(' ', '', $carray['attackevasive']))) {
$carray['attackevasive'] .= $error_style_s.'出错:含有非法字符,该项设置只能含有数字和半角逗号,'.$style_e;
} else {
if (preg_match('/[8]/i', $carray['attackevasive']) && @mysql_result(@mysql_query("SELECT COUNT(*) FROM {$carray[tablepre]}members")) < 1) {
$carray['attackevasive'] .= $error_style_s.'出错:您设置了回答问题(8),但未添加验证问题和答案 ,'.$style_e;
}
}
$comment_admincp_error = "否 > {$error_style_s}警告:有安全隐患{$style_e}";
$comment_admincp_ok = "是 > {$error_style_s}警告:有安全隐患{$style_e}";
if ($carray['admincp[\'forcesecques\']'] == 1) {
$comment['admincp[\'forcesecques\']'] = "{$ok_style_s}是{$style_e}";
} else {
$comment['admincp[\'forcesecques\']'] = $comment_admincp_error;
}
if ($carray['admincp[\'checkip\']'] == 0) {
$comment['admincp[\'checkip\']'] = $comment_admincp_error;
} else {
$comment['admincp[\'checkip\']'] = "{$ok_style_s}是{$style_e}";
}
if ($carray['admincp[\'tpledit\']'] == 1) {
$comment['admincp[\'tpledit\']'] = $comment_admincp_ok;
} else {
$comment['admincp[\'tpledit\']'] = "{$title_style_s}否{$title_style_e}";
}
if ($carray['admincp[\'runquery\']'] == 1) {
$comment['admincp[\'runquery\']'] = $comment_admincp_ok;
} else {
$comment['admincp[\'runquery\']'] = "{$title_style_s}否{$title_style_e}";
}
if ($carray['admincp[\'dbimport\']'] == 1) {
$comment['admincp[\'dbimport\']'] = $comment_admincp_ok;
} else {
$comment['admincp[\'dbimport\']'] = "{$title_style_s}否{$title_style_e}";
}
foreach($carray as $key => $keyfield) {
$clang[$key] == '' && $clang[$key] = ' ';
strpos('comma'.$comment[$key], '警告') && $comment[$key] = $comment[$key];
strpos('comma'.$comment[$key], '出错') && $comment[$key] = $comment[$key];
$comment[$key] == '' && $comment[$key] = "{$ok_style_s}正常{$style_e}";
if(in_array($key, array('dbuser', 'dbpw'))) {
$keyfield = '**隐藏**';
}
$keyfield == '' && $keyfield = '空';
if(!in_array($key, array('dbhost','dbuser','dbpw','dbname'))) {
if(in_array($key, array('pconnect', 'headercharset', 'tplrefresh', 'dbreport', 'errorreport', 'admincp[\'forcesecques\']', 'admincp[\'checkip\']', 'admincp[\'tpledit\']', 'admincp[\'runquery\']', 'admincp[\'dbimport\']'))) {
$doctor_config .= "\n\t{$title_style_s}$key{$title_style_e} ---> $clang[$key] ---> $comment[$key]\n";
} elseif(in_array($key, array('cookiepre', 'cookiepath', 'cookiedomain', 'charset', 'dbcharset', 'attackevasive'))) {
$doctor_config .= "\n\t{$title_style_s}$key{$title_style_e} ---> $clang[$key] ---> $keyfield\n";
} else {
$doctor_config .= "\n\t{$title_style_s}$key{$title_style_e} ---> $clang[$key] ---> $keyfield ---> $comment[$key]\n";
}
} else {
if(strstr($comment[$key], '出错')) {
strstr($doctor_config_db, '正常') && $doctor_config_db = '';
$doctor_config_db .= "{$title_style_s}$key{$title_style_e} ---> $clang[$key] ---> $comment[$key]";
} else {
if(empty($doctor_config_db)) {
$doctor_config_db ="\n\t{$ok_style_s}数据库正常链接.{$style_e}";
}
}
}
}
$doctor_config = "\n".$doctor_config_db.$doctor_config;
//校验环境是否支持DZ/SS,查看数据库和表的字符集,敏感信息 charset,dbcharset, php,mysql,zend,php 短标记
$msg = '';
$curr_os = PHP_OS;
if(!function_exists('mysql_connect')) {
$curr_mysql = $error_style_s.'不支持'.$style_e;
$msg .= "您的服务器不支持MySql数据库,无法安装论坛程序";
$quit = TRUE;
} else {
if(@mysql_connect($dbhost, $dbuser, $dbpw)) {
$curr_mysql = mysql_get_server_info();
} else {
$curr_mysql = $ok_style_s.'支持'.$style_e;
}
}
if(function_exists('mysql_connect')) {
$authkeylink = @mysql_connect($dbhost, $dbuser, $dbpw);
mysql_select_db($dbname, $authkeylink);
$authkeyresult = mysql_result(mysql_query("SELECT `value` FROM {$tablepre}settings WHERE `variable`='authkey'", $authkeylink), 0);
if($authkeyresult) {
$authkeyexist = $ok_style_s.'存在'.$style_e;
} else {
$authkeyexist = $error_style_s.'不存在'.$style_e;
}
}
$curr_php_version = PHP_VERSION;
if($curr_php_version < '4.0.6') {
$msg .= "您的 PHP 版本小于 4.0.6, 无法使用 Discuz! / SuperSite。";
}
if(ini_get('allow_url_fopen')) {
$allow_url_fopen = $ok_style_s.'允许'.$style_e;
} else {
$allow_url_fopen = $title_style_s.'不允许'.$title_style_e;
}
$max_execution_time = get_cfg_var('max_execution_time');
$max_execution_time == 0 && $max_execution_time = '不限制';
$memory_limit = get_cfg_var('memory_limit');
$curr_server_software = $_SERVER['SERVER_SOFTWARE'];
if(function_exists('ini_get')) {
if(!@ini_get('short_open_tag')) {
$curr_short_tag = $title_style_s.'不允许'.$title_style_e;
$msg .='请将 php.ini 中的 short_open_tag 设置为 On,否则无法使用论坛。';
} else {
$curr_short_tag = $ok_style_s.'允许'.$style_e;
}
if(@ini_get(file_uploads)) {
$max_size = @ini_get(upload_max_filesize);
$curr_upload_status = '您可以上传附件的最大尺寸: '.$max_size;
} else {
$msg .= "附件上传或相关操作被服务器禁止。";
}
} else {
$msg .= 'php.ini中禁用了ini_get()函数.部分环境参数无法检测.';
}
if(!defined('OPTIMIZER_VERSION')) define('OPTIMIZER_VERSION','没有安装或版本较低');
if(OPTIMIZER_VERSION < 3.0) {
$msg .="您的ZEND版本低于3.0,将无法使用SuperSite.";
}
//临时目录的检查
if(@is_writable(@ini_get('upload_tmp_dir'))){
$tmpwritable = $ok_style_s.'可写'.$style_e;
} elseif(!@ini_get('upload_tmp_dir') & @is_writable($_ENV[TEMP])) {
$tmpwritable = $ok_style_s.'可写'.$style_e;
} else {
$tmpwritable = $title_style_s.'不可写'.$title_style_e;
}
if(@ini_get('safe_mode') == 1) {
$curr_safe_mode = $ok_style_s.'开启'.$style_e;
} else {
$curr_safe_mode = $title_style_s.'关闭'.$title_style_e;
}
if(@diskfreespace('.')) {
$curr_disk_space = intval(diskfreespace('.') / (1024 * 1024)).'M';
} else {
$curr_disk_space = '无法检测';
}
if(function_exists('xml_parser_create')) {
$curr_xml = $ok_style_s.'可用'.$style_e;
} else {
$curr_xml = $title_style_s.'不可用'.$title_style_e;
}
if(function_exists('file')) {
$funcexistfile = $ok_style_s.'存在'.$style_e;
} else {
$funcexistfile = $title_style_s.'不存在'.$title_style_e;
}
if(function_exists('fopen')) {
$funcexistfopen = $ok_style_s.'存在'.$style_e;
} else {
$funcexistfopen = $title_style_s.'不存在'.$title_style_e;
}
if(@ini_get('display_errors')) {
$curr_display_errors = $ok_style_s.'开启'.$style_e;
} else {
$curr_display_errors = $title_style_s.'关闭'.$title_style_e;
}
if(!function_exists('ini_get')) {
$curr_display_errors = $tmpwritable = $curr_safe_mode = $curr_upload_status = $curr_short_tag = '无法检测';
}
//目录权限检查
$envlogs = array();
$entryarray = array (
'attachments',
'forumdata',
'forumdata/threadcaches',
'forumdata/logs',
'forumdata/templates',
'forumdata/cache',
'customavatars',
'forumdata/viewcount.log',
'forumdata/dberror.log',
'forumdata/errorlog.php',
'forumdata/ratelog.php',
'forumdata/cplog.php',
'forumdata/modslog.php',
'forumdata/illegallog.php'
);
foreach(array('templates', 'forumdata/logs', 'forumdata/cache', 'forumdata/templates') as $directory) {
getdirentry($directory);
}
$fault = 0;
foreach($entryarray as $entry) {
$fullentry = './'.$entry;
if(!is_dir($fullentry) && !file_exists($fullentry)) {
continue;
} else {
if(!is_writeable($fullentry)) {
$dir_perm .= "\n\t\t".(is_dir($fullentry) ? '目录' : '文件')." ./$entry {$error_style_s}无法写入.{$style_e}";
$msg .= "\n\t\t".(is_dir($fullentry) ? '目录' : '文件')." ./$entry {$error_style_s}无法写入.{$style_e}";
$fault = 1;
}
}
}
$dir_perm .= $fault ? '' : $ok_style_s.'文件及目录属性全部正确'.$style_e;
/**
* gd库所需函数的检查
*/
$gd_check = '';
if(!extension_loaded('gd')) {
$gd_check .= '您的php.ini未开启extension=php_gd2.dll(windows)或者未编译gd库(linux).';
} elseif(!function_exists('gd_info') && phpversion() < '4.3') {
$gd_check .= 'php版本低于4.3.0,不支持高版本的gd库,请升级您的php版本.';
} else {
$ver_info = gd_info();
preg_match('/([0-9\.]+)/', $ver_info['GD Version'], $match);
if($match[0] < '2.0') {
$gd_check .= "\n\t\tgd版本低于2.0,请升级您的gd版本以支持gd的验证码和水印.";
} elseif(!(function_exists('imagecreatefromjpeg') && function_exists('imagejpeg')) ) {
$gd_check .= "\n\t\tgd版本不支持jpeg的验证码和水印.";
} elseif(!(function_exists('imagecreatefromgif') && function_exists('imagegif')) ) {
$gd_check .= "\n\t\tgd版本不支持gif的验证码和水印.";
} elseif(!(function_exists('imagecreatefrompng') && function_exists('imagepng')) ) {
$gd_check .= "\n\t\tgd版本不支持png的验证码和水印.";
} else {
$gd_check .= '正常开启';
}
}
if($gd_check != '正常开启') {
$gd_check = $error_style_s.$gd_check.$style_e;
} else {
$gd_check = $ok_style_s.$gd_check.$style_e;
}
/**
* 检查ming库,目的为检查是否支持flash验证码
*/
$ming_check = '';
if(extension_loaded('ming')) {
if(substr($curr_os,0,3) == 'WIN') {
$ming_check .= '您的php.ini未开启extension=php_ming.dll,所以无法支持flash验证码';
} else {
$ming_check .= '您未编译ming库,所以无法支持flash验证码';
}
} else {
$ming_check .= '您的系统支持flash验证码,如果还无法使用flash验证码的话,有可能是您的php版本太低';
}
/**
*检查系统是否可以执行ImageMagick的命令
*/
$imagemagick_check = '';
if(!function_exists('exec')) {
$imagemagick_check .='您的php.ini里或者空间商禁止了使用exec函数,无法使用ImageMagick';
} else {
$imagemagick_check .='您现在只需安装好ImageMagick,然后配置好相关参数就可以使用ImageMagick(使用之前请先使用后台的预览功能来检查您的ImageMagick是否安装好)';
}
if($msg == '') {
$msg = "{$ok_style_s}没有发现系统环境问题.{$style_e}";
} else {
$msg = $error_style_s.$msg.$style_e;
}
$doctor_env = "
操作系统--->$curr_os
WEB 引擎 --->$curr_server_software
PHP 版本--->$curr_php_version
MySQL 版本--->$curr_mysql
Zend 版本--->".OPTIMIZER_VERSION."
程序最长运行时间(max_execution_time)--->{$max_execution_time}秒
内存大小(memory_limit)--->$memory_limit
是否允许打开远程文件(allow_url_fopen)--->$allow_url_fopen
是否允许使用短标记(short_open_tag)--->$curr_short_tag
安全模式(safe_mode)--->$curr_safe_mode
错误提示(display_errors)--->$curr_display_errors
XML 解析器--->$curr_xml
authkey 是否存在--->$authkeyexist
系统临时目录--->$tmpwritable
磁盘空间--->$curr_disk_space
附件上传--->$curr_upload_status
函数 file()--->$funcexistfile
函数 fopen()--->$funcexistfopen
目录权限---$dir_perm
GD 库--->$gd_check
ming 库--->$ming_check
ImageMagick --->$imagemagick_check
系统环境错误提示\r\n\t$msg";
}
if(!$doctor_step) {
$doctor_step = '0';
@unlink('./forumdata/doctor_cache.cache');
}
//php错误检查
$dberrnomsg = array (
'1008' => '数据库不存在,删除数据库失败',
'1016' => '无法打开数据文件',
'1041' => '系统内存不足',
'1045' => '连接数据库失败,用户名或密码错误',
'1046' => '选择数据库失败,请正确配置数据库名称',
'1044' => '当前用户没有访问数据库的权限',
'1048' => '字段不能为空',
'1049' => '数据库不存在',
'1051' => '数据表不存在',
'1054' => '字段不存在',
'1062' => '字段值重复,入库失败',//不中断
'1064' => '可能原因:1.数据超长或类型不匹配;2.数据库记录重复',//不中断
'1065' => '无效的SQL语句,SQL语句为空',//不中断
'1081' => '不能建立Socket连接',
'1129' => '数据库出现异常,请重启数据库',
'1130' => '连接数据库失败,没有连接数据库的权限',
'1133' => '数据库用户不存在',
'1141' => '当前用户无权访问数据库',
'1142' => '当前用户无权访问数据表',
'1143' => '当前用户无权访问数据表中的字段',
'1146' => '数据表不存在',
'1149' => 'SQL语句语法错误',
'1169' => '字段值重复,更新记录失败',//不中断
'2003' => '请检查数据库服务器端口设置是否正确,默认端口为 3306',
'2005' => '数据库服务器不存在',
'1114' => 'Forum onlines reached the upper limit',
);
$display_errorall = '';
$tempdir = $phpfile_array[$doctor_step];
$dirname = $dir_array[$doctor_step];
//foreach($phpfile_array as $tempdir=>$dirname) {
$display_error = '';
$mtime = explode(' ', microtime());
$time_start = $mtime[1] + $mtime[0];
if(!in_array($tempdir, array('templates', 'cache', 'discuzroot'))) exit('参数错误');
$tempdir == 'discuzroot' ? $dir = './' : $dir = 'forumdata/'.$tempdir.'/';
create_checkfile();
if (is_dir($dir)) {
if ($dh = dir($dir)) {
$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$BASESCRIPT = basename($PHP_SELF);
$host = htmlspecialchars($_SERVER['HTTP_HOST']);
$boardurl = preg_replace("/\/+(api|archiver|wap)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/';
while (($file = $dh->read()) !== false) {
if ($file != '.' && $file != '..' && $file != 'index.htm' && $file != 'checkfile.php' && $file != 'tools.php' && !is_dir($file)) {
$extnum = strrpos($file, '.') + 1;
$exts = strtolower(substr($file, $extnum));
if($exts == 'php') {
$content = '';
if($dir == './') {
$content = http_fopen($host, "{$boardurl}{$file}");
} else {
$content = http_fopen($host, "{$boardurl}/forumdata/checkfile.php?file=$file");
}
$content = str_replace(': Call to undefined function: ','',$content);
$content = str_replace(': Call to undefined function ','',$content);
$out = $out_mysql = array();
if(preg_match_all("/
.+<\/b>:.* on line \d+<\/b>/",$content,$out) || preg_match_all("/Error<\/b>:.+
\nErrno.<\/b>:\s{2}([1-9][0-9]+)/",$content,$out_mysql)) {
$display_error .= "\t{$error_style_s}$file ---错误:{$style_e}";
foreach ($out[0] as $value) {
$display_error .= "\n\t\t".$value."\n";
}
foreach ($out_mysql[0] as $key =>$value) {
$display_error .= "\n\t\t{$error_style_s}".$dberrnomsg[$out_mysql[1][$key]].$style_e;
$display_error .= "\n\t\t".str_replace("\n", '', $value);
}
}
}
}
}
$dh->close();
} else {
echo "$dir目录不存在或不可读取.";
}
}
@unlink('./forumdata/checkfile.php');
if($display_error == '') {
$dot = '缓存文件';
$dir == './' && $dot = 'php文件';
$display_errorall .= "\n---------{$ok_style_s}{$dirname}{$style_e}下没有检测到有错误的$dot.\n";
} else {
$display_errorall .= "\n---------{$error_style_s}{$dirname}{$style_e}\n".$display_error;
}
$fp = @fopen('./forumdata/doctor_cache.cache', 'ab');
@fwrite($fp, $display_errorall);
@fclose($fp);
if($doctor_step < $doctor_top) {
$doctor_step ++;
continue_redirect('dz_doctor', "&doctor_step=$doctor_step");
htmlfooter();
}
$fp = @fopen('./forumdata/doctor_cache.cache','rb');
$display_errorall = @fread($fp, @filesize('./forumdata/doctor_cache.cache'));
@fclose($fp);
@unlink('./forumdata/doctor_cache.cache');
//}
$display_errorall = str_replace('', '', $display_errorall);
$display_errorall = str_replace('', '', $display_errorall);
$display_errorall = str_replace('
', '', $display_errorall);
$records_style = "\n\n==={$title_style_s}配置文件检查{$title_style_e}=================================================$doctor_config\n==={$title_style_s}系统环境检查{$title_style_e}=================================================\n$doctor_env\n==={$title_style_s}文件错误检查{$title_style_e}=================================================\n$display_errorall\n==={$title_style_s}检查完毕{$title_style_e}=====================================================";
$search_style_all = array($error_style_s, $style_e, $ok_style_s, $title_style_s, $title_style_e);
$replace_style_all = array('', '', '', '', '');
$records = str_replace($search_style_all, '', $records_style);
echo "论坛医生诊断结果
";
htmlfooter();
} elseif ($action == 'dz_filecheck') {//搜索未知文件
//搜索未知文件功能
if(!file_exists("./config.inc.php") && !file_exists("config.php")) {
htmlheader();
cexit("
请先上传config文件以保证您的数据库能正常链接!
");
}
$do = isset($_GET['do']) ? $_GET['do'] : 'advance';
$lang = array(
'filecheck_fullcheck' => '搜索未知文件',
'filecheck_fullcheck_select' => '搜索未知文件 - 选择需要搜索的目录',
'filecheck_fullcheck_selectall' => '[搜索全部目录]',
'filecheck_fullcheck_start' => '开始时间:',
'filecheck_fullcheck_current' => '当前时间:',
'filecheck_fullcheck_end' => '结束时间:',
'filecheck_fullcheck_file' => '当前文件:',
'filecheck_fullcheck_foundfile' => '发现未知文件数: ',
'filecheck_fullcheck_nofound' => '没有发现任何未知文件'
);
if(!$discuzfiles = @file('./admin/discuzfiles.md5')) {
show_tools_message('没有找到文件的MD5值');
}
htmlheader();
if($do == 'advance') {
$dirlist = array();
$starttime = date('Y-m-d H:i:s');
$cachelist = $templatelist = array();
if(empty($checkdir)) {
checkdirs('./');
} elseif($checkdir == 'all') {
echo "\n";
} else {
$checkdir = str_replace('..', '', $checkdir);
$checkdir = $checkdir{0} == '/' ? '.'.$checkdir : $checkdir;
checkdirs($checkdir.'/');
echo "\n";
}
echo '
搜索未知文件
'.(empty($checkdir) ? ''.$lang['filecheck_fullcheck_selectall'].'' : $lang['filecheck_fullcheck'].($checkdir != 'all' ? ' - '.$checkdir : '')).' |
';
if(empty($checkdir)) {
echo '
';
foreach($dirlist as $dir) {
$subcount = count(explode('/', $dir));
echo '- '.str_repeat('-', ($subcount - 2) * 4);
echo ''.basename($dir).'
';
}
echo ' |
';
} else {
echo '
'.$lang['filecheck_fullcheck_start'].' '.$starttime.'
|
';
echo "";
}
htmlfooter();
} elseif($do == 'advancenext') {
$nopass = 0;
foreach($discuzfiles as $line) {
$md5files[] = trim(substr($line, 34));
}
$foundfile = checkfullfiles($dir);
echo "";
exit;
}
} elseif ($action == 'dz_mysqlclear') {//数据库清理
ob_implicit_flush();
define('IN_DISCUZ', TRUE);
if(@!include("./config.inc.php")) {
if(@!include("./config.php")) {
htmlheader();
cexit("
请先上传config文件以保证您的数据库能正常链接!
");
}
}
require './include/db_'.$database.'.class.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$db->select_db($dbname);
if(!get_cfg_var('register_globals')) {
@extract($_GET, EXTR_SKIP);
}
$rpp = "1000"; //每次处理多少条数据
$totalrows = isset($totalrows) ? $totalrows : 0;
$convertedrows = isset($convertedrows) ? $convertedrows : 0;
$start = isset($start) && $start > 0 ? $start : 0;
$sqlstart = isset($start) && $start > $convertedrows ? $start - $convertedrows : 0;
$end = $start + $rpp - 1;
$stay = isset($stay) ? $stay : 0;
$converted = 0;
$step = isset($step) ? $step : 0;
$info = isset($info) ? $info : '';
$action = array(
'1'=>'冗余回复数据清理',
'2'=>'冗余附件数据清理',
'3'=>'冗余会员数据清理',
'4'=>'冗余板块数据清理',
'5'=>'主题信息清理',
'6'=>'完成数据冗余清理'
);
$steps = count($action);
$actionnow = isset($action[$step]) ? $action[$step] : '结束';
$maxid = isset($maxid) ? $maxid : 0;
$tableid = isset($tableid) ? $tableid : 1;
htmlheader();
if($step==0){
?>
数据库冗余数据清理
清理项目详细信息
= $start AND pid <= $end";
$posts=$db->query($query);
while ($post = $db->fetch_array($posts)){
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE tid='".$post['tid']."'");
if ($db->result($query, 0)) {
} else {
$convertedrows ++;
$db->query("DELETE FROM {$tablepre}posts WHERE pid='".$post['pid']."'");
}
$converted = 1;
$totalrows ++;
}
if($converted || $end < $maxid) {
continue_redirect();
} else {
stay_redirect();
}
} elseif ($step == '2'){
if($start == 0) {
validid('aid','attachments');
}
$query = "SELECT aid,pid,attachment FROM {$tablepre}attachments WHERE aid >= $start AND aid <= $end";
$posts=$db->query($query);
while ($post = $db->fetch_array($posts)){
$query = $db->query("SELECT pid FROM {$tablepre}posts WHERE pid='".$post['pid']."'");
if ($db->result($query, 0)) {
} else {
$convertedrows ++;
$db->query("DELETE FROM {$tablepre}attachments WHERE aid='".$post['aid']."'");
$attachmentdir = TOOLS_ROOT.'./attachments/';
@unlink($attachmentdir.$post['attachment']);
}
$converted = 1;
$totalrows ++;
}
if($converted || $end < $maxid) {
continue_redirect();
} else {
stay_redirect();
}
} elseif ($step == '3'){
if($start == 0) {
validid('uid','memberfields');
}
$query = "SELECT uid FROM {$tablepre}memberfields WHERE uid >= $start AND uid <= $end";
$posts=$db->query($query);
while ($post = $db->fetch_array($posts)){
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE uid='".$post['uid']."'");
if ($db->result($query, 0)) {
} else {
$convertedrows ++;
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid='".$post['uid']."'");
}
$converted = 1;
$totalrows ++;
}
if($converted || $end < $maxid) {
continue_redirect();
} else {
stay_redirect();
}
} elseif ($step == '4'){
if($start == 0) {
validid('fid','forumfields');
}
$query = "SELECT fid FROM {$tablepre}forumfields WHERE fid >= $start AND fid <= $end";
$posts=$db->query($query);
while ($post = $db->fetch_array($posts)){
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE fid='".$post['fid']."'");
if ($db->result($query, 0)) {
} else {
$convertedrows ++;
$db->query("DELETE FROM {$tablepre}forumfields WHERE fid='".$post['fid']."'");
}
$converted = 1;
$totalrows ++;
}
if($converted || $end < $maxid) {
continue_redirect();
} else {
stay_redirect();
}
} elseif ($step == '5'){
if($start == 0) {
validid('tid','threads');
}
$query = "SELECT tid, subject FROM {$tablepre}threads WHERE tid >= $start AND tid <= $end";
$posts=$db->query($query);
while ($threads = $db->fetch_array($posts)){
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='".$threads['tid']."' AND invisible='0'");
$replynum = $db->result($query, 0) - 1;
if ($replynum < 0) {
$db->query("DELETE FROM {$tablepre}threads WHERE tid='".$threads['tid']."'");
} else {
$query = $db->query("SELECT a.aid FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='".$threads['tid']."' AND a.pid=p.pid AND p.invisible='0' LIMIT 1");
$attachment = $db->num_rows($query) ? 1 : 0;//修复附件
$query = $db->query("SELECT pid, subject, rate FROM {$tablepre}posts WHERE tid='".$threads['tid']."' AND invisible='0' ORDER BY dateline LIMIT 1");
$firstpost = $db->fetch_array($query);
$firstpost['subject'] = trim($firstpost['subject']) ? $firstpost['subject'] : $threads['subject']; //针对某些转换过来的论坛的处理
$firstpost['subject'] = addslashes($firstpost['subject']);
@$firstpost['rate'] = $firstpost['rate'] / abs($firstpost['rate']);//修复发帖
$query = $db->query("SELECT author, dateline FROM {$tablepre}posts WHERE tid='".$threads['tid']."' AND invisible='0' ORDER BY dateline DESC LIMIT 1");
$lastpost = $db->fetch_array($query);//修复最后发帖
$db->query("UPDATE {$tablepre}threads SET subject='".$firstpost['subject']."', replies='$replynum', lastpost='".$lastpost['dateline']."', lastposter='".addslashes($lastpost['author'])."', rate='".$firstpost['rate']."', attachment='$attachment' WHERE tid='".$threads['tid']."'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}posts SET first='1', subject='".$firstpost['subject']."' WHERE pid='".$firstpost['pid']."'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}posts SET first='0' WHERE tid='".$threads['tid']."' AND pid<>'".$firstpost['pid']."'", 'UNBUFFERED');
$convertedrows ++;
}
$converted = 1;
$totalrows ++;
}
if($converted || $end < $maxid) {
continue_redirect();
} else {
stay_redirect();
}
} elseif ($step=='6'){
echo '
数据库冗余数据清理
完成冗余数据清理 |
---|
所有数据清理操作完毕. 共处理'.$allconvertedrows.'条数据.
|
';
}
htmlfooter();
} elseif ($action == 'dz_repair_auto') {//修复自增长ID
//初始化数据库连接帐号
getdbcfg();
mysql_connect($dbhost, $dbuser, $dbpw);
mysql_select_db($dbname);
@set_time_limit(0);
htmlheader();
echo '
Discuz! 自增长字段修复
';
$querysql = array(
'activityapplies' => 'applyid',
'adminnotes' => 'id',
'advertisements' => 'advid',
'announcements' => 'id',
'attachments' => 'aid',
'attachtypes' => 'id',
'banned' => 'id',
'bbcodes' => 'id',
'crons' => 'cronid',
'faqs' => 'id',
'forumlinks' => 'id',
'forums' => 'fid',
'itempool' => 'id',
'magicmarket' => 'mid',
'magics' => 'magicid',
'medals' => 'medalid',
'members' => 'uid',
'pluginhooks' => 'pluginhookid',
'plugins' => 'pluginid',
'pluginvars' => 'pluginvarid',
'pms' => 'pmid',
'pmsearchindex' => 'searchid',
'polloptions' => 'polloptionid',
'posts' => 'pid',
'profilefields' => 'fieldid',
'projects' => 'id',
'ranks' => 'rankid',
'searchindex' => 'searchid',
'smilies' => 'id',
'styles' => 'styleid',
'stylevars' => 'stylevarid',
'templates' => 'templateid',
'threads' => 'tid',
'threadtypes' => 'typeid',
'words' => 'id'
);
$sqladd = array(
'imagetypes' => 'typeid',
'tradecomments' => 'id',
'typemodels' => 'id',
'typeoptions' => 'optionid'
);
define('IN_DISCUZ', TRUE);
if(@include TOOLS_ROOT.'./discuz_version.php') {
if(substr(DISCUZ_VERSION, 0, 1) == 6) {
$querysql = array_merge($querysql, $sqladd);
}else if(substr(DISCUZ_VERSION, 0, 3) != '5.5') {
errorpage("
很抱歉,该功能目前只支持Discuz!5.5版本和Discuz!6.0版本。
",'',0);
}
}else {
errorpage("./discuz_version.php文件不存在,请确定该文件的存在。",'',0);
}
echo '
检查结果
数据表名 | 字段名 | 自增长状态 |
';
foreach($querysql as $key => $keyfield) {
$tablestate = '正常';
echo ''.$tablepre.$key.' | '.$keyfield.' | ';
if($query = @mysql_query("Describe $tablepre$key $keyfield")) {
if(@mysql_num_rows($query) > 0) {
$field = @mysql_fetch_array($query);
if($field[3] != 'PRI') {
@mysql_query("ALTER TABLE $tablepre$key ADD PRIMARY KEY ($keyfield)");
$tablestate = '已经修复';
}
if(empty($field[5])) {
mysql_query("ALTER TABLE $tablepre$key CHANGE $keyfield $keyfield $field[1] NOT NULL AUTO_INCREMENT");
$tablestate = '已经修复';
}
} else {
$tablestate = '字段不存在';
}
} else {
$tablestate = '表不存在';
}
echo ''.$tablestate.' |
';
}
echo '
';
specialdiv();
echo '
';
htmlfooter();
} elseif ($action == 'dz_replace') {//内容替换
htmlheader();
$rpp = "500"; //每次处理多少条数据
$totalrows = isset($totalrows) ? $totalrows : 0;
$convertedrows = isset($convertedrows) ? $convertedrows : 0;
$start = isset($start) && $start > 0 ? $start : 0;
$end = $start + $rpp - 1;
$converted = 0;
$maxid = isset($maxid) ? $maxid : 0;
$threads_mod = isset($threads_mod) ? $threads_mod : 0;
$threads_banned = isset($threads_banned) ? $threads_banned : 0;
$posts_mod = isset($posts_mod) ? $posts_mod : 0;
if($stop == 1) {
echo "
帖子内容批量替换
暂停替换 |
";
$threads_banned > 0 && print(" ".$threads_banned."个主题被放入回收站.
|
");
$threads_mod > 0 && print(" ".$threads_mod."个主题被放入审核列表.
|
");
$posts_mod > 0 && print(" ".$posts_mod."个回复被放入审核列表.
|
");
echo " 替换了".$convertedrows."个帖子
|
";
echo " 继续
|
";
echo "
";
htmlfooter();
}
ob_implicit_flush();
define('IN_DISCUZ', TRUE);
if(@!include("./config.inc.php")) {
if(@!include("./config.php")) {
cexit("
请先上传config文件以保证您的数据库能正常链接!
");
}
}
require './include/db_'.$database.'.class.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$db->select_db($dbname);
$selectwords_cache = './forumdata/cache/selectwords_cache.php';
if(isset($replacesubmit) || $start > 0) {
if($maxid ==0) {
validid('pid','posts');
}
if(!file_exists($selectwords_cache) || is_array($selectwords)){
if(count($selectwords) < 1) {
echo "
帖子内容批量替换
提示信息 |
---|
您还没有选择要过滤的词语.   [返回] |
";
htmlfooter();
} else {
$fp = @fopen($selectwords_cache,w);
$content = "";
if(!@fwrite($fp,$content)) {
echo "写入缓存文件$selectwords_cache 错误,请确认路径是否可写.   [
返回]";
htmlfooter();
} else {
require_once "$selectwords_cache";
}
@fclose($fp);
}
} else {
require_once "$selectwords_cache";
}
$array_find = $array_replace = $array_findmod = $array_findbanned = array();
$query = $db->query("SELECT find,replacement from {$tablepre}words where id in($selectwords)");//获得现有规则{BANNED}放回收站 {MOD}放进审核列表
while($row = $db->fetch_array($query)) {
$find = preg_quote($row['find'], '/');
$replacement = $row['replacement'];
if($replacement == '{BANNED}') {
$array_findbanned[] = $find;
} elseif($replacement == '{MOD}') {
$array_findmod[] = $find;
} else {
$array_find[] = $find;
$array_replace[] = $replacement;
}
}
function topattern_array($source_array) { //将数组正则化
$source_array = preg_replace("/\{(\d+)\}/",".{0,\\1}",$source_array);
foreach($source_array as $key => $value) {
$source_array[$key] = '/'.$value.'/i';
}
return $source_array;
}
$array_find = topattern_array($array_find);
$array_findmod = topattern_array($array_findmod);
$array_findbanned = topattern_array($array_findbanned);
//查询posts表准备替换
$sql = "SELECT pid, tid, first, subject, message from {$tablepre}posts where pid >= $start and pid <= $end";
$query = $db->query($sql);
while($row = $db->fetch_array($query)) {
$pid = $row['pid'];
$tid = $row['tid'];
$subject = $row['subject'];
$message = $row['message'];
$first = $row['first'];
$displayorder = 0;// -2审核 -1回收站
if(count($array_findmod) > 0) {
foreach($array_findmod as $value){
if(preg_match($value,$subject.$message)){
$displayorder = '-2';
break;
}
}
}
if(count($array_findbanned) > 0) {
foreach($array_findbanned as $value){
if(preg_match($value,$subject.$message)){
$displayorder = '-1';
break;
}
}
}
if($displayorder < 0) {
if($displayorder == '-2' && $first == 0) {//如成立就移到审核回复
$posts_mod ++;
$db->query("UPDATE {$tablepre}posts SET invisible = '$displayorder' WHERE pid = $pid");
} else {
if($db->affected_rows($db->query("UPDATE {$tablepre}threads SET displayorder = '$displayorder' WHERE tid = $tid and displayorder >= 0")) > 0) {
$displayorder == '-2' && $threads_mod ++;
$displayorder == '-1' && $threads_banned ++;
}
}
}
$subject = preg_replace($array_find,$array_replace,addslashes($subject));
$message = preg_replace($array_find,$array_replace,addslashes($message));
if($subject != addslashes($row['subject']) || $message != addslashes($row['message'])) {
if($db->query("UPDATE {$tablepre}posts SET subject = '$subject', message = '$message' WHERE pid = $pid")) {
$convertedrows ++;
}
}
$converted = 1;
}
if($converted || $end < $maxid) {
continue_redirect('dz_replace',"&replacesubmit=1&threads_banned=$threads_banned&threads_mod=$threads_mod&posts_mod=$posts_mod");
} else {
echo "
帖子内容批量替换
批量替换完毕 |
";
$threads_banned > 0 && print(" ".$threads_banned."个主题被放入回收站.
|
");
$threads_mod > 0 && print(" ".$threads_mod."个主题被放入审核列表.
|
");
$posts_mod > 0 && print(" ".$posts_mod."个回复被放入审核列表.
|
");
echo " 替换了".$convertedrows."个帖子
|
";
echo "
";
@unlink($selectwords_cache);
}
} else {
if($db->version > '4.1'){
$serverset = 'character_set_connection=gbk, character_set_results=gbk, character_set_client=binary';
$serverset && $db->query("SET $serverset");
}
$query = $db->query("select * from {$tablepre}words");
$i = 1;
if($db->num_rows($query) < 1) {
echo "
帖子内容批量替换
";
htmlfooter();
}
?>
注意:
- 本程序会按照论坛现有过滤规则操作所有帖子内容.如需修改请进论坛后台。
- 上表列出了您论坛当前的过滤词语.
}
htmlfooter();
} elseif ($action == 'dz_updatecache') {//更新缓存
$cachedir = array('cache','templates');
$clearmsg = '';
foreach($cachedir as $dir) {
if($dh = dir('./forumdata/'.$dir)) {
while (($file = $dh->read()) !== false) {
if ($file != "." && $file != ".." && $file != "index.htm" && !is_dir($file)) {
unlink('./forumdata/'.$dir.'/'.$file);
}
}
} else {
$clearmsg .= './forumdata/'.$dir.'清除失败.
';
}
}
htmlheader();
echo '
更新缓存
提示信息 |
---|
';
if($clearmsg == '') $clearmsg = '更新缓存完毕.';
echo $clearmsg.' |
';
htmlfooter();
} elseif ($action == 'all_setadmin') {//重置管理员帐号密码,
if($whereis == 'is_dz') {
$sql_findadmin = "SELECT * FROM {$tablepre}members WHERE adminid=1";
$sql_select = "SELECT uid FROM {$tablepre}members WHERE $_POST[loginfield] = '$_POST[where]'";
//$sql_update = "UPDATE {$tablepre}members SET adminid='1', groupid='1' WHERE $_POST[loginfield] = '$_POST[where]' limit 1";
$username = 'username';
$uid = 'uid';
$secq = 1;
if(UC_CONNECT == 'mysql') {//判断连接ucenter的方式,如果是mysql方式,可以修改密码,否则提示去uc后台修改密码
$rspw = 1;
} else {
$rspw = 0;
}
} elseif($whereis == 'is_uc') {
$secq = 0;
$rspw = 1;
} elseif($whereis == 'is_ec') {
$sql_findadmin = "SELECT * FROM {$tablepre}admin_user";
$sql_select = "SELECT user_id FROM {$tablepre}admin_user WHERE $_POST[loginfield] = '$_POST[where]'";
$sql_update = "";
$sql_rspw = "UPDATE {$tablepre}admin_user SET password='".md5($_POST['password'])."' WHERE $_POST[loginfield] = '$_POST[where]' limit 1";
$username = 'user_name';
$uid = 'user_id';
$secq = 0;
$rspw = 1;
} elseif($whereis == 'is_uch') {
$sql_findadmin = "SELECT * FROM {$tablepre}space WHERE groupid = 1";
$sql_select = "SELECT uid FROM {$tablepre}space WHERE $_POST[loginfield] = '$_POST[where]'";
$sql_update = "UPDATE {$tablepre}space SET groupid='1' WHERE $_POST[loginfield] = '$_POST[where]'";
$username = 'username';
$uid = 'uid';
$secq = 0;
if(UC_CONNECT == 'mysql') {
$rspw = 1;
} else {
$rspw = 0;
}
}
$info = "";
$info_uc = "";
htmlheader();
?>
找回管理员
'4.1'){
$serverset = 'character_set_connection=gbk, character_set_results=gbk, character_set_client=binary';
$serverset .=$my_version > '5.0.1' ? ((empty($serverset))? '' : ',').'sql_mode=\'\'' : '';
$serverset && mysql_query("SET $serverset");
}
//查询已经存在的管理员
if($whereis != 'is_uc') {
$findadmin_query = mysql_query($sql_findadmin);
$admins = '';
while($findadmins = mysql_fetch_array($findadmin_query)) {
$admins .= ' '.$findadmins[$username];
}
}
if(!empty($_POST['loginsubmit'])) {
if($whereis == 'is_uc') {
define(ROOT_DIR,dirname(__FILE__)."/");
$configfile = ROOT_DIR."./data/config.inc.php";
$uc_password = $_POST["password"];
$salt = substr(uniqid(rand()), 0, 6);
if(!$uc_password){
$info = "密码不能为空";
}else{
$md5_uc_password = md5(md5($uc_password).$salt);
$config = file_get_contents($configfile);
$config = preg_replace("/define\('UC_FOUNDERSALT',\s*'.*?'\);/i", "define('UC_FOUNDERSALT', '$salt');", $config);
$config = preg_replace("/define\('UC_FOUNDERPW',\s*'.*?'\);/i", "define('UC_FOUNDERPW', '$md5_uc_password');", $config);
$fp = @fopen($configfile, 'w');
@fwrite($fp, $config);
@fclose($fp);
$info = "UCenter创始人密码更改成功为:$uc_password";
}
}else {
if(@mysql_num_rows(mysql_query($sql_select)) < 1) {
if($whereis == 'is_ec') {
$info = '
无此管理员用户!请检查用户名是否正确。请
重新输入 管理员帐号.
';
} else {
$info = '
无此用户!请检查用户名是否正确。请
重新输入 或者重新注册.
';
}
} else {
if($whereis == 'is_dz') {
$sql_update1 = "UPDATE {$tablepre}members SET adminid='1', groupid='1' WHERE $_POST[loginfield] = '$_POST[where]' limit 1";
$sql_update2 = "UPDATE {$tablepre}members SET adminid='1', groupid='1',secques='' WHERE $_POST[loginfield] = '$_POST[where]' limit 1";
$sql_update = $_POST['issecques'] ? $sql_update2 : $sql_update1;
}
if(mysql_query($sql_update)) {
$_POST[loginfield] = $_POST[loginfield] == $username ? '用户名' : 'UID号码';
$info = "已将$_POST[loginfield]为 $_POST[where] 的用户设置成管理员。
";
}
if($rspw) {
if($whereis == 'is_ec') {
if(mysql_query($sql_rspw)) {
$mysql_affected_rows = mysql_affected_rows();
$_POST[loginfield] = $_POST[loginfield] == $username ? '用户名' : 'UID号码';
$info .= "已将$_POST[loginfield]为 $_POST[where] 的管理员密码设置为:$_POST[password]
";
} else {
$info = '
失败请检查Mysql设置config.inc.php';
}
} elseif($whereis == 'is_dz') {
//如果是dz,首先要连接到uc里面然后执行$sql_rspw修改密码
$salt = substr(md5(time()), 0, 6);
$psw = md5(md5($_POST['password']).$salt);
mysql_connect(UC_DBHOST, UC_DBUSER, UC_DBPW);
$sql_rspw = "UPDATE ".UC_DBTABLEPRE."members SET password='".$psw."',salt='".$salt."' WHERE username = '$_POST[where]' limit 1";
mysql_query($sql_rspw);
$info .= "已将$_POST[loginfield]为 $_POST[where] 的管理员密码设置为:$_POST[password]
";
} elseif($whereis == 'is_uch') {
$salt = substr(md5(time()), 0, 6);
$psw = md5(md5($_POST['password']).$salt);
mysql_connect(UC_DBHOST, UC_DBUSER, UC_DBPW);
$sql_rspw = "UPDATE ".UC_DBTABLEPRE."members SET password='".$psw."',salt='".$salt."' WHERE username = '$_POST[where]' limit 1";
mysql_query($sql_rspw);
$info .="已将$_POST[loginfield]为 $_POST[where] 的管理员密码设置为:$_POST[password]
";
}
} else {
$info_rspw = "管理员密码请登录UC后台去改。
点击进入UC后台";
}
}
}
errorpage($info,'重置管理员帐号',0,0);
} else {
?>
';
errorpage("
成功关闭工具箱!强烈建议您在不需要本程序的时候及时进行删除
",'锁定工具箱');
} else {
errorpage('注意您的目录没有写入权限,我们无法给您提供安全保障,请删除论坛根目录下的tool.php文件!','锁定工具箱');
}
} elseif ($action == 'dz_moveattach') {//移动附件存放方式
//初始化数据库连接帐号
getdbcfg();
//连接数据库
define('IN_DISCUZ', TRUE);
require_once TOOLS_ROOT."./config.inc.php";
require_once TOOLS_ROOT."./include/db_mysql.class.php";
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
$dbuser = $dbpw = $dbname = $pconnect = NULL;
htmlheader();
echo "
附件保存方式
";
$atoption = array(
'0' => '标准(全部存入同一目录)',
'1' => '按论坛存入不同目录',
'2' => '按文件类型存入不同目录',
'3' => '按月份存入不同目录',
'4' => '按天存入不同目录',
);
if (!empty($_POST['moveattsubmit']) || $step == 1) {
$rpp = "500"; //每次处理多少条数据
$totalrows = isset($totalrows) ? $totalrows : 0;
$convertedrows = isset($convertedrows) ? $convertedrows : 0;
$start = isset($start) && $start > 0 ? $start : 0;
$end = $start + $rpp - 1;
$converted = 0;
$maxid = isset($maxid) ? $maxid : 0;
$newattachsave = isset($newattachsave) ? $newattachsave : 0;
$step = 1;
if ($start <= 1) {
$db->query("UPDATE {$tablepre}settings SET value = '$newattachsave' WHERE variable = 'attachsave'");
$cattachdir = $db->result($db->query("SELECT value FROM {$tablepre}settings WHERE variable = 'attachdir'"), 0);
validid('aid', 'attachments');
}
$attachpath = isset($cattachdir) ? TOOLS_ROOT.$cattachdir : TOOLS_ROOT.'./attachments';
$query = $db->query("SELECT aid, tid, dateline, filename, filetype, attachment FROM {$tablepre}attachments WHERE aid >= $start AND aid <= $end");
while ($a = $db->fetch_array($query)) {
$aid = $a['aid'];
$tid = $a['tid'];
$dateline = $a['dateline'];
$filename = $a['filename'];
$filetype = $a['filetype'];
$attachment = $a['attachment'];
$oldpath = $attachpath.'/'.$attachment;
if (file_exists($oldpath)) {
$realname = substr(strrchr('/'.$attachment, '/'), 1);
if ($newattachsave == 1) {
$fid = $db->result($db->query("SELECT fid FROM {$tablepre}threads WHERE tid = '$tid' LIMIT 1"), 0);
$fid = $fid ? $fid : 0;
} elseif ($newattachsave == 2) {
$extension = strtolower(fileext($filename));
}
if ($newattachsave) {
switch($newattachsave) {
case 1: $attach_subdir = 'forumid_'.$fid; break;
case 2: $attach_subdir = 'ext_'.$extension; break;
case 3: $attach_subdir = 'month_'.gmdate('ym', $dateline); break;
case 4: $attach_subdir = 'day_'.gmdate('ymd', $dateline); break;
}
$attach_dir = $attachpath.'/'.$attach_subdir;
if(!is_dir($attach_dir)) {
mkdir($attach_dir, 0777);
@fclose(fopen($attach_dir.'/index.htm', 'w'));
}
$newattachment = $attach_subdir.'/'.$realname;
} else {
$newattachment = $realname;
}
$newpath = $attachpath.'/'.$newattachment;
$asql1 = "UPDATE {$tablepre}attachments SET attachment = '$newattachment' WHERE aid = '$aid'";
$asql2 = "UPDATE {$tablepre}attachments SET attachment = '$attachment' WHERE aid = '$aid'";
if ($db->query($asql1)) {
if (rename($oldpath, $newpath)) {
$convertedrows ++;
} else {
$db->query($asql2);
}
}
$totalrows ++;
}
}
if($converted || $end < $maxid) {
continue_redirect('moveattach', '&newattachsave='.$newattachsave.'&cattachdir='.$cattachdir);
} else {
$msg = "$atoption[$newattachsave] 移动附件完毕
共有".$totalrows."个附件数据移动了".$convertedrows."个附件";
errorpage($msg,'',0,0);
}
} else {
$attachsave = $db->result($db->query("SELECT value FROM {$tablepre}settings WHERE variable = 'attachsave' LIMIT 1"), 0);
$checked[$attachsave] = 'checked';
echo "
";
specialdiv();
}
htmlfooter();
}elseif($action == 'dz_rplastpost'){//修复版块的最后回复
//初始化数据库连接帐号
getdbcfg();
//连接数据库
define('IN_DISCUZ', TRUE);
require_once TOOLS_ROOT."./config.inc.php";
require_once TOOLS_ROOT."./include/db_mysql.class.php";
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
$dbuser = $dbpw = $dbname = $pconnect = NULL;
if($db->version > '4.1'){
$serverset = 'character_set_connection=gbk, character_set_results=gbk, character_set_client=binary';
$serverset && $db->query("SET $serverset");
}
$selectfid = $_POST['fid'];
if($selectfid) {
$i = 0;
foreach($selectfid as $fid) {//存在要更新的FID 执行更新
$sql = "select t.tid, t.subject, p.subject AS psubject, p.dateline, p.author from {$tablepre}threads t, {$tablepre}posts p where t.fid=$fid and p.tid=t.tid and t.displayorder>=0 and p.invisible=0 and p.status=0 order by p.dateline DESC limit 1";
$query = $db->query($sql);
$lastarray = array();
if($lastarray = $db->fetch_array($query)){
$lastarray['subject'] = $lastarray['psubject']?$lastarray['psubject']:$lastarray['subject'];
$lastpoststr = $lastarray['tid']."\t".$lastarray['subject']."\t".$lastarray['dateline']."\t".$lastarray['author'];
$db->query("update {$tablepre}forums set lastpost='$lastpoststr' where fid=$fid");
}
}
htmlheader();
show_tools_message("重置成功", 'tools.php?action=dz_rplastpost');
htmlfooter();
}else {//不存在更新的FID 进入选择界面
htmlheader();
?>
修复版块最后回复
操作提示:
- 可以指定需要修复的版块,提交后程序会重新查询出版块的最后回复信息并且修复
";
?>