/ucenter/tools.php
PHP | 3204 lines | 3074 code | 88 blank | 42 comment | 667 complexity | 903b9091aa83fcd452f7cbb1b5586e13 MD5 | raw file
Possible License(s): LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- [Discuz!] Tools (C)2001-2008 Comsenz Inc.
- This is NOT a freeware, use is subject to license terms
-
- $Id: tools.php 1193 2010-01-20 09:35:41Z songlixin $
- */
-
- /********************** ????? ??*******************************/
- $tool_password = '1qazxsw23edc'; // ?????? ???????????????????????????
- /********************** ????? ??*******************************/
- error_reporting(E_ERROR | E_PARSE); //E_ERROR | E_WARNING | E_PARSE | E_ALL
- @set_time_limit(0);
- define('TOOLS_ROOT', dirname(__FILE__)."/");
- define('VERSION', '2009');
- define('Release','100120');
- $functionall = array(
- array('all', 'all_repair', '????????', '???????????????'),
- array('all', 'all_runquery', '????(SQL)', '??????SQL???????'),
- array('all', 'all_checkcharset', '??????', '????????????????'),
- array('all', 'all_config', '??????', '????????'),
- array('all', 'all_restore', '???????', '?????????'),
- array('all', 'all_setadmin', '?????', '?????????????????????????'),
- array('dz', 'dz_filecheck', '????', '???????????Discuz!?????'),
- array('dz', 'dz_rplastpost', '??????', '?????????'),
- array('dz', 'dz_rpthreads', '??????', '???????????????????????????????'),
- array('dz', 'dz_mysqlclear', '???????', '??????????????????????'),
- array('dz', 'dz_moveattach', '??????', '???????????????????????????????'),
- array('dz_uch', 'uch_dz_replace', '??????', '??????????????????????????,??????????????'),
- array('all', 'all_updatecache', '<font color=red>????</font>', '?????'),
- );
- $toolbar = array(
- array('phpinfo','INFO'),
- array('datago','??'),
- array('all_logout','??'),
- );
- //???
- $plustitle = '';
- $lockfile = '';
- //??????????getplace()?????
- $docdir = '';
- $action = '';
- $target_fsockopen = '0';
- $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();
- require_once $cfgfile;
-
-
- 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'))) {
- $alertmsg = '';
- errorpage('<ul><li>???????Discuz!?UCenter?UCente Home?SupeSite????????????</li><li>?????????????????????????????config???????????</li>');
- }
- if(@file_exists($lockfile)) {
- $alertmsg = '';
- errorpage("<h6>??????????????? FTP ?? $lockfile ????? </h6>");
- } elseif($tool_password == '') {
- $alertmsg = '';
- errorpage('<h6>????????????????????????$tool_password?????</h6>');
- }
- if($action == 'login') {
- setcookie('toolpassword',md5($toolpassword), 0);
- echo '<meta http-equiv="refresh" content="2 url=?">';
- errorpage("<h6>??????????</h6>");
- }
- if(isset($toolpassword)) {
- if($toolpassword != md5($tool_password)) {
- $alertmsg = '';
- errorpage("login");
- }
- } else {
- $alertmsg = '';
- errorpage("login");
- }
- getdbcfg();
- $mysql = mysql_connect($dbhost, $dbuser, $dbpw);
- mysql_select_db($dbname);
- $my_version = mysql_get_server_info();
- if($my_version > '4.1') {
- $serverset = $dbcharset ? 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary' : '';
- $serverset .= $my_version > '5.0.1' ? ((empty($serverset))? '' : ',').'sql_mode=\'\'' : '';
- $serverset && mysql_query("SET $serverset");
- }
- //????
- if($action == 'all_repair') {
- $counttables = $oktables = $errortables = $rapirtables = 0;
- $doc = $docdir.'/repaireport.txt';
- if($check) {
- $tables = mysql_query("SHOW TABLES");
- if($iterations) {
- $iterations --;
- }
- while($table = mysql_fetch_row($tables)) {
- $counttables += 1;
- $answer = checktable($table[0],$iterations,$doc);
- }
- if($simple) {
- htmlheader();
- echo '<h4>???????</h4>
- <h5>????:</h5>
- <table>
- <tr><th>???(?)</th><th>???(?)</th><th>????(?)</th><th>??(?)</th></tr>
- <tr><td>'.$counttables.'</td><td>'.$oktables.'</td><td>'.$rapirtables.'</td><td>'.$errortables.'</td></tr>
- </table>
- <p>????????????????????????</p>
- <p><b><a href="tools.php?action=all_repair">????</a> <b><a href="'.$doc.'">????</a> <a href="tools.php">????</a></b></p>
- </td></tr></table>';
- specialdiv();
- }
- } else {
- htmlheader();
- @unlink($doc);
- echo "<h4>???????</h4>
- <div class='specialdiv'>
- ?????
- <ul>
- <li>??????????????????????????????????</li>
- <li>??????????????????????????????????(?? MySQL 3.23+)</li>
- </ul>
- </div>
- <h5>???</h5>
- <ul>
- <li><a href=\"?action=all_repair&check=1&simple=1\">??????????1?</a>
- <li><a href=\"?action=all_repair&check=1&iterations=5&simple=1\">??????????5?</a> (????????????????????????????)
- </ul>";
- specialdiv();
- }
- htmlfooter();
- } elseif($action == 'all_restore') {//???????
- ob_implicit_flush();
- $backdirarray = array( //??????????????????
- 'is_dz' => 'forumdata',
- 'is_uc' => 'data/backup',
- 'is_uch' => 'data',
- 'is_ss' => 'data'
- );
- if(!get_cfg_var('register_globals')) {
- @extract($HTTP_GET_VARS);
- }
- $sqldump = '';
- htmlheader();
- ?><h4>????????? </h4><?php
- echo "<div class=\"specialdiv\">?????<ul>
- <li>??????????(?????)??????,????????????,?? FTP ??</li>
- <li>??????? Discuz! ????,???????? PHP ????</li>
- <li>??????????????,?????.?????(?? 10 ??)???,???</li></ul></div>";
- if($file) {
- if(!mysql_select_db($dbname)) {
- mysql_query("CREATE DATABASE $dbname;");
- }
- if(strtolower(substr($file, 0, 7)) == "http://") {
- echo "?????????? - ??????:<br><br>";
- echo "?????????? ... ";
- $sqldump = @fread($fp, 99999999);
- @fclose($fp);
- if($sqldump) {
- echo "??<br><br>";
- } elseif(!$multivol) {
- cexit("??<br><br><b>??????</b>");
- }
- } else {
- echo "<div class=\"specialtext\">??????? - ??????:<br><br>";
- if(file_exists($file)) {
- echo "???? $file ???? ... ??<br><br>";
- } elseif(!$multivol) {
- cexit("???? $file ???? ... ??<br><br><br><b>??????</b></div>");
- }
- if(is_readable($file)) {
- echo "???? $file ???? ... ??<br><br>";
- @$fp = fopen($file, "r");
- @flock($fp, 3);
- $sqldump = @fread($fp, filesize($file));
- @fclose($fp);
- echo "??????? ... ??<br><br>";
- } elseif(!$multivol) {
- cexit("???? $file ???? ... ??<br><br><br><b>??????</b></div>");
- }
- }
- if($multivol && !$sqldump) {
- cexit("???????? ... ??<br><br><b>???,??????????!????,????????.</b></div>");
- }
- echo "???? $file ???? ... ";
- if($whereis == 'is_uc') {
-
- $identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", substr($sqldump, 0, 256))));
- $method = 'multivol';
- $volume = $identify[4];
- } else {
- @list(,,,$method, $volume) = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", preg_replace("/^(.+)/", "\\1", substr($sqldump, 0, 256)))));
- }
- if($method == 'multivol' && is_numeric($volume)) {
- echo "??<br><br>";
- } else {
- cexit("??<br><br><b>??? Discuz! ??????,????</b></div>");
- }
- if($onlysave == "yes") {
- echo "????????????? ... ";
- $filename = TOOLS_ROOT.'./'.$backdirarray[$whereis].strrchr($file, "/");
- @$filehandle = fopen($filename, "w");
- @flock($filehandle, 3);
- if(@fwrite($filehandle, $sqldump)) {
- @fclose($filehandle);
- echo "??<br><br>";
- } else {
- @fclose($filehandle);
- die("??<br><br><b>??????</b>");
- }
- echo "??<br><br><b>???,?????????????? <a href=\"".strstr($filename, "/")."\">$filename</a>.????,????????.</b></div>";
- } else {
- $sqlquery = splitsql($sqldump);
- echo "?????? ... ??<br><br>";
- unset($sqldump);
-
- echo "??????,??? ... </div>";
- foreach($sqlquery as $sql) {
- $dbversion = mysql_get_server_info();
- $sql = syntablestruct(trim($sql), $dbversion > '4.1', $dbcharset);
- if(trim($sql)) {
- @mysql_query($sql);
- }
- }
- if($auto == 'off') {
- $nextfile = str_replace("-$volume.sql", '-'.($volume + 1).'.sql', $file);
- cexit("<ul><li>???? <b>$volume#</b> ????,?????????????????</li><li>???<b><a href=\"?action=all_restore&file=$nextfile&multivol=yes\">????</a></b> ?????????????<b><a href=\"?action=all_restore&file=$nextfile&multivol=yes&auto=off\">??????????</a></b></li></ul>");
- } else {
- $nextfile = str_replace("-$volume.sql", '-'.($volume + 1).'.sql', $file);
- echo "<ul><li>???? <b>$volume#</b> ????,???????????????.</li><li><b>???????????????</b></li></ul>";
- redirect("?action=all_restore&file=$nextfile&multivol=yes");
- }
- }
- } else {
- $exportlog = array();
- if(is_dir(TOOLS_ROOT.'./'.$backdirarray[$whereis])) {
- $dir = dir(TOOLS_ROOT.'./'.$backdirarray[$whereis]);
- while($entry = $dir->read()) {
- $entry = "./".$backdirarray[$whereis]."/$entry";
- if(is_file($entry) && preg_match("/\.sql/i", $entry)) {
- $filesize = filesize($entry);
- $fp = @fopen($entry, 'rb');
- @$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
- @fclose ($fp);
- if(preg_match("/\-1.sql/i", $entry) || $identify[3] == 'shell') {
- $exportlog[$identify[0]] = array( 'version' => $identify[1],
- 'type' => $identify[2],
- 'method' => $identify[3],
- 'volume' => $identify[4],
- 'filename' => $entry,
- 'size' => $filesize);
- }
- } elseif(is_dir($entry) && preg_match("/backup\_/i", $entry)) {
- $bakdir = dir($entry);
- while($bakentry = $bakdir->read()) {
- $bakentry = "$entry/$bakentry";
- if(is_file($bakentry)) {
- @$fp = fopen($bakentry, 'rb');
- @$bakidentify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
- @fclose ($fp);
- if(preg_match("/\-1\.sql/i", $bakentry) || $bakidentify[3] == 'shell') {
- $identify['bakentry'] = $bakentry;
- }
- }
- }
- if(preg_match("/backup\_/i", $entry)) {
- $exportlog[filemtime($entry)] = array( 'version' => $bakidentify[1],
- 'type' => $bakidentify[2],
- 'method' => $bakidentify[3],
- 'volume' => $bakidentify[4],
- 'bakentry' => $identify['bakentry'],
- 'filename' => $entry);
- }
- }
- }
- $dir->close();
- } else {
- echo 'error';
- }
- krsort($exportlog);
- reset($exportlog);
-
- $title = '<h5><a href="?action=all_restore">??????</a>';
- if($dz_version >= 700 || $whereis == 'is_uc' || $whereis == 'is_uch' || $ss_version >= 70) {
- $title .= ' <a href="?action=all_backup&begin=1">??????</a></h5>';
- } else {
- $title .= '</h5>';
- }
- $exportinfo = $title.'<table><caption> ??????</caption><tr><th>????</th><th>??</th><th>??</th><th>??</th><th>??</th><th>??</th></tr>';
- foreach($exportlog as $dateline => $info) {
- $info['dateline'] = is_int($dateline) ? gmdate("Y-m-d H:i", $dateline + 8*3600) : '??';
- switch($info['type']) {
- case 'full':
- $info['type'] = '????';
- break;
- case 'standard':
- $info['type'] = '????(??)';
- break;
- case 'mini':
- $info['type'] = '????';
- break;
- case 'custom':
- $info['type'] = '?????';
- break;
- }
- $info['volume'] = $info['method'] == 'multivol' ? $info['volume'] : '';
- $info['method'] = $info['method'] == 'multivol' ? '??' : 'shell';
- $info['url'] = str_replace(".sql", '', str_replace("-$info[volume].sql", '', substr(strrchr($info['filename'], "/"), 1)));
- $exportinfo .= "<tr>\n".
- "<td>".$info['url']."</td>\n".
- "<td>$info[version]</td>\n".
- "<td>$info[dateline]</td>\n".
- "<td>$info[type]</td>\n";
- if($info['bakentry']) {
- $exportinfo .= "<td><a href=\"?action=all_restore&bakdirname=".$info['url']."\">??</a></td>\n".
- "<td><a href=\"?action=all_restore&file=$info[bakentry]&importsubmit=yes\">[????]</a></td>\n</tr>\n";
- } else {
- $exportinfo .= "<td><a href=\"?action=all_restore&filedirname=".$info['url']."\">??</a></td>\n".
- "<td><a href=\"?action=all_restore&file=$info[filename]&importsubmit=yes\">[????]</a></td>\n</tr>\n";
- }
- }
- $exportinfo .= '</table>';
- echo $exportinfo;
- unset($exportlog);
- unset($exportinfo);
- echo "<br>";
- //??????????????????
- if(!empty($filedirname)) {
- $exportlog = array();
- if(is_dir(TOOLS_ROOT.'./'.$backdirarray[$whereis])) {
- $dir = dir(TOOLS_ROOT.'./'.$backdirarray[$whereis]);
- while($entry = $dir->read()) {
- $entry = "./".$backdirarray[$whereis]."/$entry";
- if(is_file($entry) && preg_match("/\.sql/i", $entry) && preg_match("/$filedirname/i", $entry)) {
- $filesize = filesize($entry);
- @$fp = fopen($entry, 'rb');
- @$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
- @fclose ($fp);
-
- $exportlog[$identify[0]] = array( 'version' => $identify[1],
- 'type' => $identify[2],
- 'method' => $identify[3],
- 'volume' => $identify[4],
- 'filename' => $entry,
- 'size' => $filesize);
- }
- }
- $dir->close();
- }
- krsort($exportlog);
- reset($exportlog);
-
- $exportinfo = '<table>
- <caption> ???????</caption>
- <tr>
- <th>???</th><th>??</th>
- <th>??</th><th>??</thd>
- <th>??</th><td>??</th>
- <th>??</th><th>??</th></tr>';
- foreach($exportlog as $dateline => $info) {
- $info['dateline'] = is_int($dateline) ? gmdate("Y-m-d H:i", $dateline + 8*3600) : '??';
- switch($info['type']) {
- case 'full':
- $info['type'] = '????';
- break;
- case 'standard':
- $info['type'] = '????(??)';
- break;
- case 'mini':
- $info['type'] = '????';
- break;
- case 'custom':
- $info['type'] = '?????';
- break;
- }
- $info['volume'] = $info['method'] == 'multivol' ? $info['volume'] : '';
- $info['method'] = $info['method'] == 'multivol' ? '??' : 'shell';
- $exportinfo .= "<tr>\n".
- "<td><a href=\"$info[filename]\" name=\"".substr(strrchr($info['filename'], "/"), 1)."\">".substr(strrchr($info['filename'], "/"), 1)."</a></td>\n".
- "<td>$info[version]</td>\n".
- "<td>$info[dateline]</td>\n".
- "<td>$info[type]</td>\n".
- "<td>".get_real_size($info[size])."</td>\n".
- "<td>$info[method]</td>\n".
- "<td>$info[volume]</td>\n".
- "<td><a href=\"?action=all_restore&file=$info[filename]&importsubmit=yes&auto=off\">[??]</a></td>\n</tr>\n";
- }
- $exportinfo .= '</table>';
- echo $exportinfo;
- }
- // ????????????? ??????????????????
- if(!empty($bakdirname)) {
- $exportlog = array();
- $filedirname = TOOLS_ROOT.'./'.$backdirarray[$whereis].'/'.$bakdirname;
- if(is_dir($filedirname)) {
- $dir = dir($filedirname);
- while($entry = $dir->read()) {
- $entry = $filedirname.'/'.$entry;
- if(is_file($entry) && preg_match("/\.sql/i", $entry)) {
- $filesize = filesize($entry);
- @$fp = fopen($entry, 'rb');
- @$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
- @fclose ($fp);
-
- $exportlog[$identify[0]] = array(
- 'version' => $identify[1],
- 'type' => $identify[2],
- 'method' => $identify[3],
- 'volume' => $identify[4],
- 'filename' => $entry,
- 'size' => $filesize);
- }
- }
- $dir->close();
- }
- krsort($exportlog);
- reset($exportlog);
-
- $exportinfo = '<table>
- <caption> ???????</caption>
- <tr>
- <th>???</th><th>??</th>
- <th>??</th><th>??</th>
- <th>??</th><th>??</th>
- <th>??</th><th>??</th></tr>';
- foreach($exportlog as $dateline => $info) {
- $info['dateline'] = is_int($dateline) ? gmdate("Y-m-d H:i", $dateline + 8*3600) : '??';
- switch($info['type']) {
- case 'full':
- $info['type'] = '????';
- break;
- case 'standard':
- $info['type'] = '????(??)';
- break;
- case 'mini':
- $info['type'] = '????';
- break;
- case 'custom':
- $info['type'] = '?????';
- break;
- }
- $info['volume'] = $info['method'] == 'multivol' ? $info['volume'] : '';
- $info['method'] = $info['method'] == 'multivol' ? '??' : 'shell';
- $exportinfo .= "<tr>\n".
- "<td><a href=\"$info[filename]\" name=\"".substr(strrchr($info['filename'], "/"), 1)."\">".substr(strrchr($info['filename'], "/"), 1)."</a></td>\n".
- "<td>$info[version]</td>\n".
- "<td>$info[dateline]</td>\n".
- "<td>$info[type]</td>\n".
- "<td>".get_real_size($info[size])."</td>\n".
- "<td>$info[method]</td>\n".
- "<td>$info[volume]</td>\n".
- "<td><a href=\"?action=all_restore&file=$info[filename]&importsubmit=yes&auto=off\">[??]</a></td>\n</tr>\n";
- }
- $exportinfo .= '</table>';
- echo $exportinfo;
- }
- echo "<br>";
- cexit("");
- }
- } elseif($action == 'all_runquery') {//??sql
- if(!empty($_POST['sqlsubmit']) && $_POST['queries']) {
- runquery($queries);
- }
- htmlheader();
- runquery_html();
- htmlfooter();
- } elseif($action == 'all_checkcharset') {//????
- $maincharset = $dbcharset;
- $tooltip = '<h4>????</h4>'."<div class=\"specialdiv\">?????<ul>
- <li>MySQL???4.1????????????????4.1????????????</li>
- <li>????????????????????????????????????????????????</li>
- <li>??MySQL???????? <a href='http://www.discuz.net/viewthread.php?tid=1022673' target='_blank'>????</a></li>
- <li>????MySQL?????<a href='http://www.discuz.net/viewthread.php?tid=1070306' target='_blank'>??</a></li>
- <li><font color=red>??????????????????????????????????????????????????????????????????????????????????</font></li>
- <li><font color=red>??????????????????“<a href='?action=datago'>??</a>”??</font></li>
- </ul></div>";
- if($my_version > '4.1') {
- if($repairsubmit) {
- htmlheader();
- echo $tooltip;
- if(!is_array($repair)) {
- $repair=array();
- show_tools_message('????????', 'tools.php?action=all_checkcharset');
- htmlfooter();
- exit;
- }
- foreach($repair as $key=>$value) {
- $tableinfo = '';
- $tableinfo = explode('|', $value);
- $tablename = $tableinfo[0];
- $collation = $tableinfo[1];
- $maincharset = $tableinfo[2];
- $query = mysql_query("SHOW CREATE TABLE $tablename");
- while($createsql = mysql_fetch_array($query)) {
- $colationsql = explode(",\n",$createsql[1]);
- foreach($colationsql as $numkey => $collsql) {
- if(strpos($collsql,'`'.$collation.'`')) {
- if(strpos($collsql,'character set') > 0){
- $collsql = substr($collsql,0,strpos($collsql,'character set'));
- } else {
- $collsql = substr($collsql,0,strpos($collsql,'NOT NULL'));
- }
- $collsql = $collsql." character set $maincharset NOT NULL";
- $changesql = 'alter table '.$tablename.' change `'.$collation.'` '.$collsql;
- mysql_query($changesql);
- }
- }
- }
- }
- show_tools_message('????', 'tools.php?action=all_checkcharset');
- htmlfooter();
- exit;
- } else {
- $sql = "SELECT `TABLE_NAME` AS `Name`, `TABLE_COLLATION` AS `Collation` FROM `information_schema`.`TABLES` WHERE ".(strpos("php".PHP_OS,"WIN")?"":"BINARY")."`TABLE_SCHEMA` IN ('$dbname') AND TABLE_NAME like '$tablepre%'";
- $query = @mysql_query($sql);
- $dbtable = array();
- $chars = array('gbk' => 0,'big5' => 0,'utf8' => 0,'latin1' => 0);
- if(!$query) {
- htmlheader();
- errorpage('?????????????????????????????????????', '', 0, 0);
- htmlfooter();
- exit;
- }
- while($dbdetail = mysql_fetch_array($query)) {
- $dbtable[$dbdetail["Name"]]["Collation"] = pregcharset($dbdetail["Collation"],1);
- $dbtable[$dbdetail["Name"]]["tablename"] = $dbdetail["Name"];
- $tablequery = mysql_query("SHOW FULL FIELDS FROM `".$dbdetail["Name"]."`");
- while($tables= mysql_fetch_array($tablequery)) {
- if(!empty($tables["Collation"])) {
- $collcharset = pregcharset($tables["Collation"], 0);
- $tableschar[$collcharset][$dbdetail["Name"]][] = $tables["Field"];
- $chars[pregcharset($tables["Collation"], 0)]++;
- }
- }
-
- }
- }
- }
-
- htmlheader();
- echo $tooltip;
- if($my_version > '4.1') {
- echo'<div class="tabbody">
- <style>.tabbody p em { color:#09C; padding:0 10px;} .char_div { margin-top:30px; margin-bottom:30px;} .char_div h4, .notice h4 { font-weight:600; font-size:16px; margin:0; padding:0; margin-bottom:10px;}</style>
- <div class="char_div"><h5>???('.$dbname.')???????</h5>
- <table style="width:40%; margin:0; margin-bottom:20px;"><tr><th>gbk??</th><th>big5??</th><th>utf8??</th><th>latin1??</th></tr><tr><td>'.$chars[gbk].' </td><td>'.$chars[big5].' </td><td>'.$chars[utf8].' </td><td>'.$chars[latin1].' </td></tr></table>
- <div class="notice">
- <h5>???????????????</h5>';
- ?>
- <script type="text/JavaScript">
- function setrepaircheck(obj, form, table, char) {
- eval('var rem = /^' + table + '\\|.+?\\|.+?\\|' + char + '$/;');
- eval('var rechar = /latin1/;');
- for(var i = 0; i < form.elements.length; i++) {
- var e = form.elements[i];
- if(e.type == 'checkbox' && e.name == 'repair[]') {
- if(rem.exec(e.value) != null) {
- if(obj.checked) {
- if(rechar.exec(e.value) != null) {
- e.checked = true;
- } else {
- e.checked = true;
- }
- } else {
- e.checked = false;
- }
- }
- }
- }
- }
- </script>
- <?php
- foreach($chars as $char => $num) {
- if($char != $maincharset) {
- if(is_array($tableschar[$char])) {
- echo '<form name="form" action="" method="post">';
- foreach($tableschar[$char] as $tablename => $fields) {
- echo '<table style="margin-left:0; width:40%;">
- <tr>
- <th><input type="checkbox" id="tables[]" style="border-style:none;" name="chkall" onclick="setrepaircheck(this, this.form, \''.$tablename.'\', \''.$char.'\');" value="'.$tablename.'">??</th>
- <th width=60%><strong>'.$tablename.'</strong> <font color="red">??????</font></th>
- <th>??</th>
- </tr>';
- foreach($fields as $collation) {
- echo'<tr><td><input type="checkbox" style="border-style:none;"';
- echo 'id="fields['.$tablename.'][]"';
- echo 'name=repair[] value="'.$tablename.'|'.$collation.'|'.$maincharset.'|'.$char.'">';
- echo '</td><td>'.$collation.'</td><td><font color="red">'.$char.'</font></td></tr>';
- }
- echo '</table>';
- }
- }
- }
- }
- echo '<input type="submit" value="???????????'.$maincharset.'" name="repairsubmit" onclick="javascript:if(confirm(\'Tools???????????????????????????????????????????????????????????????????\'));else return false;"></form>';
- echo '<br /><br /><br /></div> </div>';
- } else {
- errorpage('MySQL??????4.1???????????????', '', 0, 0);
- }
- htmlfooter();
- } elseif($action == 'dz_filecheck') {//??????
- htmlheader();
- if($begin != 1) {
- echo '<h4>????</h4>';
- infobox('??????? Discuz! ????????????????????????????','tools.php?action=dz_filecheck&begin=1');
- htmlfooter();
- exit;
- }
-
- $md5data = array();
- if(!$dz_files = @file(TOOLS_ROOT.'./admin/discuzfiles.md5')) {
- errorpage('????md5??');
- }
- checkfiles('./', '\.php', 0, 'config.inc.php');
- checkfiles('api/', '\.php');
- checkfiles('admin/', '\.php');
- checkfiles('archiver/', '\.php');
- checkfiles('include/', '\.php|\.js|\.htm');
- checkfiles('modcp/', '\.php');
- checkfiles('plugins/', '\.php');
- checkfiles('templates/default/', '\.htm|\.php');
- checkfiles('uc_client/', '\.php',0);
- checkfiles('uc_client/control/', '\.php',0);
- checkfiles('uc_client/lib/', '\.php',0);
- checkfiles('uc_client/model/', '\.php',0);
- checkfiles('wap/', '\.php');
-
- $modifylists = $deletedfiles = $unknownfiles = array();
-
- docheckfiles($dz_files,$md5data);
- checkfilesoutput($modifylists,$deletedfiles,$unknownfiles);
- htmlfooter();
- } elseif($action == 'dz_mysqlclear') {//?????
- ob_implicit_flush();
- define('IN_DISCUZ', TRUE);
- if(@!include("./config.inc.php")) {
- if(@!include("./config.php")) {
- htmlheader();
- cexit("<h4>????config????????????????</h4>");
- }
- }
- 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) {
- ?>
- <h4>?????????</h4>
- <h5>????????</h5>
- <table>
- <tr><th width="30%">Posts????</th><td>[<a href="?action=dz_mysqlclear&step=1&stay=1">????</a>]</td></tr>
- <tr><th width="30%">Attachments????</th><td>[<a href="?action=dz_mysqlclear&step=2&stay=1">????</a>]</td></tr>
- <tr><th width="30%">Members????</th><td>[<a href="?action=dz_mysqlclear&step=3&stay=1">????</a>]</td></tr>
- <tr><th width="30%">Forums????</th><td>[<a href="?action=dz_mysqlclear&step=4&stay=1">????</a>]</td></tr>
- <tr><th width="30%">Threads????</th><td>[<a href="?action=dz_mysqlclear&step=5&stay=1">????</a>]</td></tr>
- <tr><th width="30%">??????</th><td>[<a href="?action=dz_mysqlclear&step=1&stay=0">????</a>]</td></tr>
- </table>
- <?php
- specialdiv();
- echo "<script>$('jsmenu').style.display='inline';</script>";
- } elseif($step == '1') {
- if($start == 0) {
- validid('pid','posts');
- }
- $query = "SELECT pid, tid FROM {$tablepre}posts WHERE pid >= $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 '<h4>?????????</h4><table>
- <tr><th>????????</th></tr><tr>
- <td><br>??????????. ???<font color=red>'.$allconvertedrows.'</font>???.<br><br></td></tr></table>';
- }
-
- htmlfooter();
-
- } elseif($action == 'uch_dz_replace') {//????s
- htmlheader();
- $rpp = "500"; //?????????
- $totalrows = isset($totalrows) ? $totalrows : 0;
- $convertedrows = isset($convertedrows) ? $convertedrows : 0;
- $convertedtrows = isset($convertedtrows) ? $convertedtrows : 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 "<h4>??????</h4><table>
- <tr>
- <th>????</th>
- </tr>";
- $threads_banned > 0 && print("<tr><td><br><li>".$threads_banned."?????????.</li></td></tr>");
- $threads_mod > 0 && print("<tr><td><br><li>".$threads_mod."??????????.</li></td></tr>");
- $posts_mod > 0 && print("<tr><td><br><li>".$posts_mod."??????????.</li></td></tr>");
- echo "<tr><td><li>???".$convertedrows."???</li></td></tr>";
- echo "<tr><td><a href='?action=uch_dz_replace&step=".$step."&start=".($end + 1 - $rpp * 2)."&stay=$stay&totalrows=$totalrows&convertedrows=$convertedrows&maxid=$maxid&replacesubmit=1&threads_banned=$threads_banned&threads_mod=$threads_mod&posts_mod=$posts_mod'>??</a></td></tr>";
- echo "</table>";
- htmlfooter();
- }
- ob_implicit_flush();
- if($whereis == 'is_uch') {
- $selectwords_cache = './data/selectwords_cache.php';
- } elseif($whereis == 'is_dz') {
- $selectwords_cache = './forumdata/cache/selectwords_cache.php';
- }
-
- if(isset($replacesubmit) || $start > 0) {
- if(!file_exists($selectwords_cache) || is_array($selectwords)) {
- if(count($selectwords) < 1) {
- echo "<h4>??????</h4><table><tr><th>????</th></tr><tr><td>????????????.   [<a href=tools.php?action=uch_dz_replace>??</a>]</td></tr></table>";
- htmlfooter();
- } else {
- $fp = @fopen($selectwords_cache,w);
- $content = "<?php \n";
- $selectwords = implode(',',$selectwords);
- $content .= "\$selectwords = '$selectwords';\n?>";
- if(!@fwrite($fp,$content)) {
- echo "??????$selectwords_cache ??,?????????.   [<a href=tools.php?action=uch_dz_replace>??</a>]";
- htmlfooter();
- } else {
- require_once "$selectwords_cache";
- }
- @fclose($fp);
- }
- } else {
- require_once "$selectwords_cache";
- }
- $array_find = $array_replace = $array_findmod = $array_findbanned = array();
-
- if($whereis == 'is_dz') {
- $query = mysql_query("SELECT find,replacement from {$tablepre}words where id in($selectwords)");//??????{BANNED}???? {MOD}??????
- while($row = mysql_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;
- }
- }
- } elseif($whereis == 'is_uch') {
- $query = mysql_query("SELECT datavalue FROM `uchome_data` WHERE `var` = 'censor'");
- $query = mysql_fetch_array($query);
- $censor = explode("\n",$query[datavalue]);
- foreach($censor as $key => $value) {
- if(in_array($key,explode(',',$selectwords))){
- $rows = explode('=',$value);
- $row[] = $rows;
- }
- }
- foreach($row as $value) {
- $find = preg_quote($value[0], '/');
- $replacement = $value[1];
- if($replacement == '{BANNED}') {
- $array_findbanned[] = $find;
- } else {
- $array_find[] = $find;
- $array_replace[] = $replacement;
- }
- }
- }
-
- $array_find = topattern_array($array_find);
- $array_findmod = topattern_array($array_findmod);
- $array_findbanned = topattern_array($array_findbanned);
- if($whereis == 'is_dz'){
- if($maxid == 0) {
- validid('pid','posts');
- }
- //??posts?????
- $sql = "SELECT pid, tid, first, subject, message from {$tablepre}posts where pid >= $start and pid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_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 ++;
- mysql_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(mysql_query("UPDATE {$tablepre}posts SET subject = '$subject', message = '$message' WHERE pid = $pid")) {
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //??threads?
- $sql2 = "SELECT tid,subject from {$tablepre}threads where tid >= $start and tid <= $end";
- $query2 = mysql_query($sql2);
- while($row2 = mysql_fetch_array($query2)) {
- $tid = $row2['tid'];
- $subject = $row2['subject'];
- $subject = preg_replace($array_find,$array_replace,addslashes($subject));
- if($subject != addslashes($row2['subject'])) {
- if(mysql_query("UPDATE {$tablepre}threads SET subject = '$subject' WHERE tid = $tid")) {
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- } elseif ($whereis == 'is_uch') {
- if($maxid == 0) {
- validid('blogid','blog');
- $temp = $maxid;
- validid('cid','comment');
- $temp = max($temp,$maxid);
- validid('oid','polloption');
- $temp = max($temp,$maxid);
- validid('pid','post');
- $temp = max($temp,$maxid);
- validid('doid','doing');
- $temp = max($temp,$maxid);
- $maxid = $temp;
- }
- //blog??
- $sql = "SELECT b.blogid,b.subject,f.message from {$tablepre}blog b,{$tablepre}blogfield f where b.blogid=f.blogid AND b.blogid >= $start and b.blogid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $blogid = $row['blogid'];
- $subject = $row['subject'];
- $subject = preg_replace($array_find,$array_replace,addslashes($subject));
- if($subject != addslashes($row['subject']) || $message != addslashes($row['message'])) {
- if(mysql_query("UPDATE {$tablepre}blog SET subject = '$subject' WHERE blogid = $blogid")) {
- mysql_query("UPDATE {$tablepre}blogfield SET message = '$message' WHERE blogid = $blogid");
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //comment??
- $sql = "SELECT cid,message from {$tablepre}comment where cid >= $start and cid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $cid = $row['cid'];
- $message = $row['message'];
- $message = preg_replace($array_find,$array_replace,addslashes($message));
- if($message != addslashes($row['message'])) {
- if(mysql_query("UPDATE {$tablepre}coment SET message = '$message' WHERE cid = $cid")) {
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //poll??
- $sql = "SELECT p.pid,p.subject,f.message,f.option from {$tablepre}poll p,{$tablepre}pollfield f where p.pid=f.pid AND p.pid >= $start and p.pid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $pid = $row['pid'];
- $subject = $row['subject'];
- $message = $row['message'];
- $option = unserialize($row['option']);
- $subject = preg_replace($array_find,$array_replace,addslashes($subject));
- $message = preg_replace($array_find,$array_replace,addslashes($message));
- $option = addslashes(serialize(preg_replace($array_find,$array_replace,$option)));
- if($message != addslashes($row['message']) || $subject != addslashes($row['subject']) || $option != addslashes($row['option'])) {
- if(mysql_query("UPDATE {$tablepre}poll SET subject = '$subject' WHERE pid = $pid")) {
- mysql_query("UPDATE {$tablepre}pollfield SET `message` = '$message' WHERE pid = $pid");
- mysql_query("UPDATE {$tablepre}pollfield SET `option` = '$option' WHERE pid = $pid");
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //polloption??
- $sql = "SELECT oid,option from {$tablepre}polloption where oid >= $start and oid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $oid = $row['oid'];
- $option = $row['option'];
- $option = preg_replace($array_find,$array_replace,addslashes($option));
- if($option != addslashes($row['option'])) {
- if(mysql_query("UPDATE {$tablepre}polloption SET option = '$option' WHERE oid = $oid")) {
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //polloption??
- $sql = "SELECT oid,option from {$tablepre}polloption where oid >= $start and oid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $oid = $row['oid'];
- $option = $row['option'];
- $option = preg_replace($array_find,$array_replace,addslashes($option));
- if($option != addslashes($row['option'])) {
- if(mysql_query("UPDATE {$tablepre}polloption SET option = '$option' WHERE oid = $oid")) {
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //post??
- $sql = "SELECT pid,message from {$tablepre}post where pid >= $start and pid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $pid = $row['pid'];
- $message = $row['message'];
- $message = preg_replace($array_find,$array_replace,addslashes($message));
- if($message != addslashes($row['message'])) {
- if(mysql_query("UPDATE {$tablepre}post SET message = '$message' WHERE pid = $pid")) {
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //doing??
- $sql = "SELECT doid,message from {$tablepre}doing where doid >= $start and doid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $doid = $row['doid'];
- $message = $row['message'];
- $message = preg_replace($array_find,$array_replace,addslashes($message));
- if($message != addslashes($row['message'])) {
- if(mysql_query("UPDATE {$tablepre}doing SET message = '$message' WHERE doid = $doid")) {
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- //spacefield??
- $sql = "SELECT uid,note,spacenote from {$tablepre}spacefield where uid >= $start and uid <= $end";
- $query = mysql_query($sql);
- while($row = mysql_fetch_array($query)) {
- $uid = $row['uid'];
- $note = $row['note'];
- $spacenote = $row['spacenote'];
- $note = preg_replace($array_find,$array_replace,addslashes($note));
- $spacenote = preg_replace($array_find,$array_replace,addslashes($spacenote));
- if($note != addslashes($row['note']) || $spacenote != addslashes($row['spacenote'])) {
- if(mysql_query("UPDATE {$tablepre}spacefield SET note = '$note' WHERE uid = $uid")) {
- mysql_query("UPDATE {$tablepre}spacefield SET spacenote = '$spacenote' WHERE uid = $uid");
- $convertedrows ++;
- }
- }
- $converted = 1;
- }
- }
-
- //??
- if($converted || $end < $maxid) {
- continue_redirect('uch_dz_replace',"&replacesubmit=1&threads_banned=$threads_banned&threads_mod=$threads_mod&posts_mod=$posts_mod");
- } else {
- echo "<h4>??????</h4><table>
- <tr>
- <th>????????</th>
- </tr>";
- if($threads_banned > 0) { echo "<tr><td><li>".$threads_banned."?????????.</li></td></tr>";}
- if($threads_mod > 0) {echo "<tr><td><li>".$threads_mod."??????????.</li></td></tr>";}
- if($posts_mod > 0) {echo "<tr><td><li>".$posts_mod."??????????.</li></td></tr>";}
- echo "<tr><td><li>???".$convertedrows."???</li></td></tr>";
- echo "</table>";
- @unlink($selectwords_cache);
- }
- } else {
- if(mysql_get_server_info > '4.1') {
- $serverset = 'character_set_connection=gbk, character_set_results=gbk, character_set_client=binary';
- $serverset && mysql_query("SET $serverset");
- }
- $i = 1;
- if ($whereis == 'is_dz') {
- define('IN_DISCUZ',TRUE);
- require_once "./forumdata/cache/cache_censor.php";
- $censorarray = $_DCACHE['censor'];
- $query = mysql_query("select * from {$tablepre}words");
- } elseif($whereis == 'is_uch') {
- define('IN_UCHOME',TRUE);
- require_once "./data/data_censor.php";
- $censorarray = $_SGLOBAL['censor'];
- $query = mysql_query("SELECT datavalue FROM `uchome_data` WHERE `var` = 'censor'");
- $query = mysql_fetch_array($query);
- $censor = explode("\n",$query[datavalue]);
- foreach($censor as $key => $value) {
- $rows = explode('=',$value);
- $row[] = $rows;
- }
- }
-
- if(count($censorarray) < 1) {
- echo "<h4>??????</h4><table><tr><th>????</th></tr><tr><td><br>???,?????????,???????????.<br><br></td></tr></table>";
- htmlfooter();
- }
-
- echo '<form method="post" action="tools.php?action=uch_dz_replace">
- <script language="javascript">
- function checkall(form, prefix, checkall) {
- var checkall = checkall ? checkall : \'chkall\';
- for(var i = 0; i < form.elements.length; i++) {
- var e = form.elements[i];
- if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
- e.checked = form.elements[checkall].checked;
- }
- }
- }
- </script>
- <h4>??????</h4>
- <table>
- <tr>
- <th><input class="checkbox" name="chkall" onclick="checkall(this.form)" type="checkbox" checked>??</th>
- <th>????</th>
- <th>???</th></tr>';
- if($whereis == 'is_dz') {
- while($row = mysql_fetch_array($query)) {
- echo'<tr>
- <td><input class="checkbox" name="selectwords[]" value="'.$row['id'].'" type="checkbox" checked>  '.$i++.'</td>
- <td>  '.$row['find'].'</td>
- <td>  '.stripslashes($row['replacement']).'</td>
- </tr>';
- }
- } elseif($whereis == 'is_uch') {
- foreach($row as $key => $rowvalue) {
- echo'<tr>
- <td><input class="checkbox" name="selectwords[]" value="'.$key.'" type="checkbox" checked>  '.$i++.'</td>
- <td>  '.$rowvalue[0].'</td>
- <td>  '.stripslashes($rowvalue[1]).'</td>
- </tr>';
- }
- }
-
- echo '</table>
- <input type="submit" name=replacesubmit value="????">
- </form>
- <div class="specialdiv">
- <h6>???</h6>
- <ul>
- <li>??????????????????????.?????<a href="./admincp.php?action=censor" target=\'_blank\'>?????</a>?</li>
- <li>???????????????.</li>
- </ul></div><br><br>';
- }
- htmlfooter();
- } elseif($action == 'all_updatecache') {//????
- if($whereis =='is_dz') {
- $clearmsg = dz_updatecache();
- } elseif($whereis == 'is_uch') {
- $clearmsg = uch_updatecache();
- } elseif($whereis == 'is_ss') {
- $clearmsg = ss_updatecache();
- }
- htmlheader();
- echo '<h4>????</h4><table><tr><th>????</th></tr><tr><td>';
- if($clearmsg == '') $clearmsg = '??????.';
- echo $clearmsg.'</td></tr></table>';
- htmlfooter();
- } elseif($action == 'all_setadmin') {//??????????
- $sql_findadmin = '';
- $sql_select = '';
- $sql_update = '';
- $sql_rspw = '';
- $secq = '';
- $rspw = '';
- $username = '';
- $uid = '';
- all_setadmin_set($tablepre,$whereis);
- $info = '';
- $info_uc = '';
- htmlheader();
- ?>
- <h4>?????</h4>
- <?php
- //??????????
- 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) {
- $info = '<font color="red">????????????????</font>?<a href="?action=all_setadmin">????</a> ??????.<br><br>';
- } 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($whereis == 'is_ss') {
- $sql_update1 = "UPDATE {$tablepre}members SET groupid='1' WHERE $_POST[loginfield] = '$_POST[where]' limit 1";
- $sql_update = $sql_update1;
- }
- if(mysql_query($sql_update)&& !$rspw) {
- $_POST[loginfield] = $_POST[loginfield] == $username ? '???' : 'UID??';
- $info = "??$_POST[loginfield]? $_POST[where] ??????????<br><br>";
- }
- if($rspw) {
- if($whereis == 'is_dz') {
- if($dz_version < 610) {
- $psw = md5($_POST['password']);
- mysql_query("update {$tablepre}members set password='$psw' where $_POST[loginfield] = '$_POST[where]' limit 1");
- } else {
- //???dz???????uc??????$sql_rspw????
- $salt = substr(md5(time()), 0, 6);
- $psw = md5(md5($_POST['password']).$salt);
- mysql_connect(…
Large files files are truncated, but you can click here to view the full file