发新话题
打印

[经验分享]dz6.0正式版降级转回dz5.5正式版的方法

[经验分享]dz6.0正式版降级转回dz5.5正式版的方法

由于升级到dz6.0后,所有google adsense广告都不能显示、编辑器不好用、用户在线时间不增加、用户发帖积分不增长等等,很多问题,所以比较后悔升级到6.0版本了,下面是某些人的降级过程和注意事项:

1.非常重要,
请一定先备份数据库

2.运行下面的程序
<?php
// Downgrade Discuz! Board to 5.5.0 from 6.0.0 Final
error_reporting(E_ERROR | E_WARNING | E_PARSE);
@set_magic_quotes_runtime(0);
@set_time_limit(1000);
define('IN_DISCUZ', TRUE);
define('DISCUZ_ROOT', './');
$version_old = 'Discuz! 6.0.0 正式版';
$version_new = 'Discuz! 5.5.0';
$timestamp = time();
@include(DISCUZ_ROOT."./config.inc.php");
@include(DISCUZ_ROOT."./include/db_mysql.class.php");
header("Content-Type: text/html; charset=$charset");
showheader();
if(empty($dbcharset) && in_array(strtolower($charset), array('gbk', 'big5', 'utf-8'))) {
$dbcharset = str_replace('-', '', $charset);
}
if(PHP_VERSION < '4.1.0') {
$_GET = &$HTTP_GET_VARS;
$_POST = &$HTTP_POST_VARS;
$_COOKIE = &$HTTP_COOKIE_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
$_ENV = &$HTTP_ENV_VARS;
$_FILES = &$HTTP_POST_FILES;
}
$action = ($_POST['action']) ? $_POST['action'] : $_GET['action'];
$step = $_GET['step'];
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$downgrade1 = <<<EOT
DELETE FROM cdb_settings WHERE variable='tagstatus';
DELETE FROM cdb_settings WHERE variable='hottags';
DELETE FROM cdb_settings WHERE variable='viewthreadtags';
UPDATE cdb_settings SET value=value/12 WHERE variable='maxsigrows';
DELETE FROM cdb_settings WHERE variable='mail';
DELETE FROM cdb_settings WHERE variable='watermarktext';
DELETE FROM cdb_settings WHERE variable='watermarkminwidth';
DELETE FROM cdb_settings WHERE variable='watermarkminheight';
REPLACE INTO cdb_settings VALUES ('ec_id','');
REPLACE INTO cdb_settings VALUES ('ec_securitycode','');
REPLACE INTO cdb_settings VALUES ('ec_commision','0');
DELETE FROM cdb_settings WHERE variable='inviteconfig';
DELETE FROM cdb_settings WHERE variable='rewritecompatible';
DELETE FROM cdb_settings WHERE variable='userdateformat';
DELETE FROM cdb_settings WHERE variable='regname';
DELETE FROM cdb_settings WHERE variable='reglinkname';
DELETE FROM cdb_settings WHERE variable='activitytype';
DELETE FROM cdb_settings WHERE variable='tradeimagewidth';
DELETE FROM cdb_settings WHERE variable='tradeimageheight';
DELETE FROM cdb_settings WHERE variable='customauthorinfo';
DELETE FROM cdb_settings WHERE variable='ec_credit';
DELETE FROM cdb_settings WHERE variable='imagelib';
DELETE FROM cdb_settings WHERE variable='imageimpath';
DELETE FROM cdb_settings WHERE variable='historyposts';
DELETE FROM cdb_settings WHERE variable='zoomstatus';
DELETE FROM cdb_settings WHERE variable='postno';
DELETE FROM cdb_settings WHERE variable='postnocustom';
DELETE FROM cdb_settings WHERE variable='maxbiotradesize';
DELETE FROM cdb_settings WHERE variable='tradetypes';
DELETE FROM cdb_settings WHERE variable='baidusitemap';
DELETE FROM cdb_settings WHERE variable='baidusitemap_life';
DELETE FROM cdb_settings WHERE variable='google';
REPLACE INTO cdb_crons VALUES ('','1','system','每周主题更新','pushthreads_weekly.inc.php','0','1170600452','7','-1','7','0');
EOT;
$downgradetable = array(
array('forums', 'DROP', 'allowmediacode', ""),
array('forums', 'MODIFY', 'allowpostspecial', "tinyint(1) NOT NULL DEFAULT '15'"),
array('forumfields', 'DROP', 'keywords', ""),
array('forumfields', 'DROP', 'formulaperm', ""),
array('forumfields', 'DROP', 'modrecommend', ""),
array('forumfields', 'DROP', 'tradetypes', ""),
array('forumfields', 'DROP', 'typemodels', ""),
array('myposts', 'DROP', 'special', ""),
array('mythreads', 'DROP', 'special', ""),
array('threadtypes', 'DROP', 'special', ""),
array('threadtypes', 'DROP', 'template', ""),
array('smilies', 'CHANGE', 'displayorder', "displayorder tinyint(1) NOT NULL DEFAULT '0'"),
array('smilies', 'DROP', 'typeid', ""),
array('usergroups', 'DROP', 'allowpostdebate', ""),
array('usergroups', 'DROP', 'tradestick', ""),
array('usergroups', 'DROP', 'allowinvite', ""),
array('usergroups', 'DROP', 'allowmailinvite', ""),
array('usergroups', 'DROP', 'maxinvitenum', ""),
array('usergroups', 'DROP', 'maxinviteday', ""),
array('usergroups', 'DROP', 'inviteprice', ""),
array('usergroups', 'DROP', 'allowpostvideo', ""),
array('usergroups', 'ADD', 'tradetaxtype', "tinyint(1) NOT NULL DEFAULT '1'"),
array('usergroups', 'ADD', 'tradetaxs', "smallint(6) unsigned NOT NULL DEFAULT '0'"),
array('trades', 'DROP', 'pid', ""),
array('trades', 'DROP', 'typeid', ""),
array('trades', 'DROP', 'aid', ""),
array('trades', 'DROP', 'displayorder', ""),
array('trades', 'DROP', 'costprice', ""),
array('trades', 'MODIFY', 'price', "decimal(6,2) NOT NULL"),
array('trades', 'INDEX', '', "DROP PRIMARY KEY"),
array('trades', 'INDEX', '', "ADD PRIMARY KEY (tid)"),
array('trades', 'INDEX', '', "DROP INDEX displayorder"),
array('trades', 'INDEX', '', "DROP INDEX sellertrades"),
array('trades', 'INDEX', '', "DROP INDEX typeid"),
array('tradelog', 'DROP', 'pid', "INT(10) UNSIGNED NOT NULL AFTER tid"),
array('tradelog', 'DROP', 'offline', "TINYINT(1) NOT NULL default '0'"),
array('tradelog', 'DROP', 'buyername', "CHAR(50) NOT NULL"),
array('tradelog', 'DROP', 'buyerzip', "CHAR(10) NOT NULL"),
array('tradelog', 'DROP', 'buyerphone', "CHAR(20) NOT NULL"),
array('tradelog', 'DROP', 'buyermobile', "CHAR(20) NOT NULL"),
array('tradelog', 'DROP', 'transport', "TINYINT(1) NOT NULL default '0'"),
array('tradelog', 'DROP', 'transportfee', "smallint(6) unsigned NOT NULL"),
array('tradelog', 'DROP', 'baseprice', "decimal(8,2) NOT NULL"),
array('tradelog', 'DROP', 'discount', "TINYINT(1) NOT NULL default '0'"),
array('tradelog', 'DROP', 'ratestatus', "TINYINT(1) NOT NULL default '0'"),
array('tradelog', 'MODIFY', 'price', "decimal(6,2) NOT NULL DEFAULT '0.00'"),
array('tradelog', 'INDEX', '', "DROP INDEX tid"),
array('tradelog', 'INDEX', '', "ADD INDEX tid (tid)"),
array('tradelog', 'INDEX', '', "DROP INDEX pid"),
array('memberfields', 'DROP', 'buyercredit', ""),
array('memberfields', 'DROP', 'sellercredit', ""),
array('profilefields', 'INDEX', '', "DROP INDEX available"),
array('posts', 'DROP', 'status', ""),
array('admingroups', 'DROP', 'allowbanpost', ""),
array('members', 'MODIFY', 'extgroupids', "char(60) NOT NULL DEFAULT ''"),
array('members', 'MODIFY', 'email', "char(50) NOT NULL DEFAULT ''"),
array('members', 'MODIFY', 'dateformat', "char(10) NOT NULL DEFAULT ''"),
array('members', 'INDEX', '', "DROP INDEX groupid"),
array('promotions', 'CHANGE', 'uid', "uid mediumint(8) NOT NULL DEFAULT '0'"),
array('relatedthreads', 'DROP', 'type', ""),
array('relatedthreads', 'INDEX', '', "DROP PRIMARY KEY , ADD PRIMARY KEY ( tid )"),
array('threadtypes', 'DROP', 'modelid', ""),
array('threadtypes', 'DROP', 'expiration', ""),
array('tradelog', 'DROP', 'buyername', ""),
array('tradelog', 'DROP', 'buyerzip', ""),
array('tradelog', 'DROP', 'buyerphone', ""),
array('tradelog', 'DROP', 'buyermobile', ""),
array('tradelog', 'DROP', 'message', ""),
array('tradelog', 'DROP', 'transportfee', ""),
);
$downgrade3 = <<<EOT
DROP TABLE IF EXISTS cdb_blogcaches;
CREATE TABLE cdb_blogcaches (
  uid mediumint(8) unsigned NOT NULL DEFAULT '0',
  variable varchar(10) NOT NULL DEFAULT '',
  `value` text NOT NULL,
  PRIMARY KEY (uid,variable)
) TYPE=MyISAM;
DROP TABLE IF EXISTS cdb_imagetypes;
DROP TABLE IF EXISTS cdb_threadtags;
DROP TABLE IF EXISTS cdb_tags;
DROP TABLE IF EXISTS cdb_debates;
DROP TABLE IF EXISTS cdb_debateposts;
DROP TABLE IF EXISTS cdb_typeoptions;
DROP TABLE IF EXISTS cdb_typeoptionvars;
DROP TABLE IF EXISTS cdb_tradeoptionvars;
DROP TABLE IF EXISTS cdb_typevars;
DROP TABLE IF EXISTS cdb_tradecomments;
DROP TABLE IF EXISTS cdb_invites;
DROP TABLE IF EXISTS cdb_forumrecommend;
DROP TABLE IF EXISTS cdb_caches;
DROP TABLE IF EXISTS cdb_videos;
DROP TABLE IF EXISTS cdb_videotags;
EOT;
$downgrade4 = <<<EOT
DROP TABLE IF EXISTS cdb_searchindex;
DROP TABLE IF EXISTS cdb_typemodels;
DELETE FROM cdb_crons WHERE filename='tags_daily.inc.php';
UPDATE cdb_members SET dateformat='';
EOT;
$downgrade5 = <<<EOT
DELETE FROM cdb_settings WHERE variable='mail';
DELETE FROM cdb_settings WHERE variable='spacedata';
REPLACE INTO cdb_settings VALUES ('spacecachelife','900');
REPLACE INTO cdb_settings VALUES ('spacelimitmythreads','5');
REPLACE INTO cdb_settings VALUES ('spacelimitmyreplies','5');
REPLACE INTO cdb_settings VALUES ('spacelimitmyrewards','5');
REPLACE INTO cdb_settings VALUES ('spacelimitmytrades','5');
REPLACE INTO cdb_settings VALUES ('spacelimitmyblogs','8');
REPLACE INTO cdb_settings VALUES ('spacelimitmyfriends','0');
REPLACE INTO cdb_settings VALUES ('spacelimitmyfavforums','5');
REPLACE INTO cdb_settings VALUES ('spacelimitmyfavthreads','0');
REPLACE INTO cdb_settings VALUES ('spacetextlength','300');
REPLACE INTO cdb_settings (variable, value) VALUES ('seccodedata', 'a:5:{s:16:\"loginfailedcount\";i:0;s:8:\"animator\";i:0;s:10:\"background\";i:1;s:5:\"width\";i:93;s:6:\"height\";i:31;}');
EOT;
$downgrade6 = <<<EOT
DROP TABLE IF EXISTS cdb_styles;
CREATE TABLE cdb_styles (
  styleid smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL DEFAULT '',
  available tinyint(1) NOT NULL DEFAULT '1',
  templateid smallint(6) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (styleid)
) TYPE=MyISAM AUTO_INCREMENT=2;
INSERT INTO cdb_styles VALUES ('1','默认风格','1','1');
DROP TABLE IF EXISTS cdb_stylevars;
CREATE TABLE cdb_stylevars (
  stylevarid smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  styleid smallint(6) unsigned NOT NULL DEFAULT '0',
  variable text NOT NULL,
  substitute text NOT NULL,
  PRIMARY KEY (stylevarid),
  KEY styleid (styleid)
) TYPE=MyISAM AUTO_INCREMENT=52;
INSERT INTO cdb_stylevars VALUES ('1','1','boardimg','logo.gif');
INSERT INTO cdb_stylevars VALUES ('2','1','nobold','0');
INSERT INTO cdb_stylevars VALUES ('3','1','msgfontsize','12px');
INSERT INTO cdb_stylevars VALUES ('4','1','fontsize','12px');
INSERT INTO cdb_stylevars VALUES ('5','1','font','Tahoma, Verdana');
INSERT INTO cdb_stylevars VALUES ('6','1','tablespace','4');
INSERT INTO cdb_stylevars VALUES ('7','1','tablewidth','98%');
INSERT INTO cdb_stylevars VALUES ('8','1','borderwidth','1');
INSERT INTO cdb_stylevars VALUES ('9','1','text','#333333');
INSERT INTO cdb_stylevars VALUES ('10','1','tabletext','#333333');
INSERT INTO cdb_stylevars VALUES ('11','1','catcolor','#FFFFD9');
INSERT INTO cdb_stylevars VALUES ('12','1','headertext','#154BA0');
INSERT INTO cdb_stylevars VALUES ('13','1','headercolor','header_bg.gif');
INSERT INTO cdb_stylevars VALUES ('14','1','bordercolor','#86B9D6');
INSERT INTO cdb_stylevars VALUES ('15','1','link','#154BA0');
INSERT INTO cdb_stylevars VALUES ('16','1','altbg2','#FFFFFF');
INSERT INTO cdb_stylevars VALUES ('17','1','altbg1','#F5FBFF');
INSERT INTO cdb_stylevars VALUES ('18','1','bgcolor','#FFFFFF');
INSERT INTO cdb_stylevars VALUES ('19','1','imgdir','images/default');
INSERT INTO cdb_stylevars VALUES ('20','1','smdir','images/smilies');
INSERT INTO cdb_stylevars VALUES ('21','1','cattext','#92A05A');
INSERT INTO cdb_stylevars VALUES ('22','1','smfontsize','11px');
INSERT INTO cdb_stylevars VALUES ('23','1','smfont','Arial, Tahoma');
INSERT INTO cdb_stylevars VALUES ('24','1','maintablewidth','98%');
INSERT INTO cdb_stylevars VALUES ('25','1','maintablecolor','#FFFFFF');
INSERT INTO cdb_stylevars VALUES ('26','1','innerborderwidth','0');
INSERT INTO cdb_stylevars VALUES ('27','1','innerbordercolor','#D6E0EF');
INSERT INTO cdb_stylevars VALUES ('28','1','bgborder','#BBE9FF');
INSERT INTO cdb_stylevars VALUES ('29','1','inputborder','#7AC4EA');
INSERT INTO cdb_stylevars VALUES ('30','1','mainborder','#154BA0');
INSERT INTO cdb_stylevars VALUES ('31','1','catborder','#DEDEB8');
INSERT INTO cdb_stylevars VALUES ('32','1','lighttext','#666666');
INSERT INTO cdb_stylevars VALUES ('33','1','headermenu','menu_bg.gif');
INSERT INTO cdb_stylevars VALUES ('34','1','postnoticebg','#FDFFF2');
INSERT INTO cdb_stylevars VALUES ('35','1','msgheader','#F3F8D7');
INSERT INTO cdb_stylevars VALUES ('36','1','msgheadertext','#000000');
INSERT INTO cdb_stylevars VALUES ('37','1','msgtext','#FDFFF2');
INSERT INTO cdb_stylevars VALUES ('38','1','headermenutext','#154BA0');
INSERT INTO cdb_stylevars VALUES ('39','1','navtext','#154BA0');
INSERT INTO cdb_stylevars VALUES ('40','1','menubg','#D9EEF9');
INSERT INTO cdb_stylevars VALUES ('41','1','menutext','#154BA0');
INSERT INTO cdb_stylevars VALUES ('42','1','menuhltext','#FFFFFF');
INSERT INTO cdb_stylevars VALUES ('43','1','menuhlbg','#7AC4EA');
INSERT INTO cdb_stylevars VALUES ('44','1','calendartext','#000000');
INSERT INTO cdb_stylevars VALUES ('45','1','calendarexpire','#999999');
INSERT INTO cdb_stylevars VALUES ('46','1','calendarchecked','#FF0000');
INSERT INTO cdb_stylevars VALUES ('47','1','calendartoday','#00BB00');
INSERT INTO cdb_stylevars VALUES ('48','1','msgbigsize','');
INSERT INTO cdb_stylevars VALUES ('49','1','msgsmallsize','');
INSERT INTO cdb_stylevars VALUES ('50','1','frameswitch','frame_switch.gif');
INSERT INTO cdb_stylevars VALUES ('51','1','framebg','frame_bg.gif');
INSERT INTO cdb_stylevars VALUES ('52','1','framebgcolor','#E8F2F7');
DROP TABLE IF EXISTS cdb_templates;
CREATE TABLE cdb_templates (
  templateid smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL DEFAULT '',
  `directory` varchar(100) NOT NULL DEFAULT '',
  copyright varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (templateid)
) TYPE=MyISAM AUTO_INCREMENT=2;
INSERT INTO cdb_templates VALUES ('1','默认模板套系','./templates/default','康盛创想(北京)科技有限公司');
REPLACE INTO cdb_settings (variable, value) VALUES ('styleid','1');
DELETE FROM cdb_bbcodes WHERE tag='sup';
DELETE FROM cdb_bbcodes WHERE tag='sub';
EOT;
$downgrade7 = <<<EOT
DROP TABLE IF EXISTS cdb_pushedthreads;
CREATE TABLE cdb_pushedthreads (
  id mediumint(8) unsigned NOT NULL,
  tid mediumint(8) unsigned NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '0',
  dateline int(10) unsigned NOT NULL DEFAULT '0',
  `subject` varchar(80) NOT NULL,
  message text NOT NULL,
  PRIMARY KEY (id),
  KEY displayorder (`status`,dateline)
) TYPE=MyISAM;
DROP TABLE IF EXISTS cdb_campaigns;
DELETE FROM cdb_settings WHERE variable='insenz';
EOT;
$downgrade7 = <<<EOT
DELETE FROM cdb_settings WHERE variable='videoinfo';
DELETE FROM cdb_settings WHERE variable='qihoo';
REPLACE INTO cdb_settings VALUES ('qihoo_adminemail','');
REPLACE INTO cdb_settings VALUES ('qihoo_jammer','1');
REPLACE INTO cdb_settings VALUES ('qihoo_keywords','');
REPLACE INTO cdb_settings VALUES ('qihoo_location','1');
REPLACE INTO cdb_settings VALUES ('qihoo_maxtopics','10');
REPLACE INTO cdb_settings VALUES ('qihoo_relatedthreads','5');
REPLACE INTO cdb_settings VALUES ('qihoo_relatedsort','1');
REPLACE INTO cdb_settings VALUES ('qihoo_searchbox','6');
REPLACE INTO cdb_settings VALUES ('qihoo_status','0');
REPLACE INTO cdb_settings VALUES ('qihoo_summary','1');
REPLACE INTO cdb_settings VALUES ('qihoo_topics','');
REPLACE INTO cdb_settings VALUES ('qihoo_validity','1');
REPLACE INTO cdb_settings (variable, value) VALUES ('rewritestatus', '0');
EOT;
$downgrademsg = array(
1 => '论坛降级第 1 步: 删除基本设置<br /><br />',
2 => '论坛降级第 2 步: 调整论坛数据表结构<br /><br />',
3 => '论坛降级第 3 步: 删除数据表<br /><br />',
4 => '论坛降级第 4 步: 更新部分数据<br /><br />',
5 => '论坛降级第 5 步: 降级邮件设置<br /><br />',
6 => '论坛降级第 6 步: 降级论坛风格<br /><br />',
7 => '论坛降级第 7 步: Insenz相关数据降级<br /><br />',
8 => '论坛降级第 8 步: 其他相关数据降级<br /><br />',
9 => '论坛降级第 9 步: 降级全部完毕<br /><br />',
);
$errormsg = '';
if(!isset($dbhost)) {
showerror("<span class=error>没有找到 config.inc.php 文件!</span><br />请确认您已经上传了所有 $version_new 文件");
} elseif(!$dblink = @mysql_connect($dbhost, $dbuser, $dbpw)) {
showerror("<span class=error>config.inc.php 配置错误!</span><br />请修改 config.inc.php 当中关于数据库的设置,然后上传到论坛目录,重新开始降级");
}
@mysql_close($dblink);
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
if(!$action) {
if(!$tableinfo = loadtable('threads')) {
  showerror("<span class=error>无法找到 Discuz! 论坛数据表!</span><br />请修改 config.inc.php 当中关于数据库的设置,然后上传到论坛目录,重新开始降级");
} elseif($db->version() > '4.1') {
  $old_dbcharset = substr($tableinfo['subject']['Collation'], 0, strpos($tableinfo['subject']['Collation'], '_'));
  if($old_dbcharset <> $dbcharset) {
   showerror("<span class=error>config.inc.php 数据库字符集设置错误!</span><br />".
    "<li>原来的字符集设置为:$old_dbcharset".
    "<li>当前使用的字符集为:$dbcharset".
    "<li>建议:修改 config.inc.php, 将其中的 <b>\$dbcharset = ''</b> 或者 <b>\$dbcharset = '$dbcharset'</b> 修改为: <b>\$dbcharset = '$old_dbcharset'</b>".
    "<li>修改完毕后上传 config.inc.php,然后重新进行降级"
   );
  }
}
echo <<< EOT
<span class="red">
降级前请打开浏览器 JavaScript 支持,整个过程是自动完成的,不需人工点击和干预.<br />
降级之前务必备份数据库资料,否则降级失败无法恢复<br /></span><br />
正确的降级方法为:
<ol>
<li>关闭原有论坛,上传 $version_new 的全部文件和目录, 覆盖服务器上的 $version_old
<li>上传降级程序到论坛目录中,<b>重新配置好 config.inc.php</b>
<li>运行本程序,直到出现降级完成的提示
<li>如果中途失败,请使用Discuz!工具箱(./utilities/tools.php)里面的数据恢复工具恢复备份, 去除错误后重新运行本程序
</ol>
<a href="$PHP_SELF?action=downgrade&step=1"><font size="2" color="red"><b>&gt;&gt; 如果您已确认完成上面的步骤,请点这里降级</b></font></a>
<br /><br />
EOT;
showfooter();
} else {
$step = intval($step);
echo '&gt;&gt;'.$downgrademsg[$step];
flush();
if($step == 1) {
  dir_clear('./forumdata/cache');
  dir_clear('./forumdata/templates');
  runquery($downgrade1);
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} elseif($step == 2) {
  if(isset($downgradetable[$start]) && $downgradetable[$start][0]) {
   echo "降级数据表 [ $start ] {$tablepre}{$downgradetable[$start][0]} {$downgradetable[$start][3]}:";
   $successed = downgradetable($downgradetable[$start]);
   if($successed === TRUE) {
    echo ' <font color=green>OK</font><br />';
   } elseif($successed === FALSE) {
    //echo ' <font color=red>ERROR</font><br />';
   } elseif($successed == 'TABLE NOT EXISTS') {
    showerror('<span class=red>数据表不存在</span>降级无法继续,请确认您的论坛版本是否正确!</font><br />');
   }
  }
  $start ++;
  if(isset($downgradetable[$start]) && $downgradetable[$start][0]) {
   redirect("?action=downgrade&step=$step&start=$start");
  }
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} elseif($step == 3) {
  runquery($downgrade3);
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} elseif($step == 4) {
  runquery($downgrade4);
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} elseif($step == 5) {
  runquery($downgrade5);
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} elseif($step == 6) {
  runquery($downgrade6);
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} elseif($step == 7) {
  runquery($downgrade7);
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} elseif($step == 8) {
  runquery($downgrade7);
  echo "第 $step 步降级成功<br /><br />";
  redirect("?action=downgrade&step=".($step+1));
} else {
  dir_clear('./forumdata/cache');
  dir_clear('./forumdata/templates');
  $authkey = substr(md5($_SERVER['SERVER_ADDR'].$_SERVER['HTTP_USER_AGENT'].$dbhost.$dbuser.$dbpw.$dbname.$username.$password.$pconnect.substr($timestamp, 0, 6)), 8, 6).random(10);
  $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
  $siteuniqueid = $chars[date('y')%60].$chars[date('n')].$chars[date('j')].$chars[date('G')].$chars[date('i')].$chars[date('s')].substr(md5($onlineip.$timestamp), 0, 4).random(6);
  $db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('authkey', '$authkey')");
  $db->query("DELETE FROM {$tablepre}settings WHERE variable='siteuniqueid'");
  $query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='insenz'");
  $insenz = unserialize($db->result($query, 0));
  echo '<br />恭喜您论坛数据降级成功,接下来请您:<ol><li><b>必删除本程序</b>'.
  '<li>使用管理员身份登录论坛,进入后台,更新缓存'.
  '<li>进行论坛注册、登录、发贴等常规测试,看看运行是否正常'.
  '<li>如果您希望启用 <b>'.$version_new.'</b> 提供的新功能,你还需要对于论坛基本设置、栏目、会员组等等进行重新设置</ol><br />'.
  '<b>感谢您选用我们的产品!</b><a href="index.php" target="_blank">您现在可以访问论坛,查看降级情况</a><iframe width="0" height="0" src="index.php"></iframe>';
  showfooter();
}
}
instfooter();
function createtable($sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "[url=file://\\2]\\2[/url]", $sql));
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "[url=file://\\1]\\1[/url]", $sql).
(mysql_get_server_info() > '4.1' ? " ENGINE=$type default CHARSET=$dbcharset" : " TYPE=$type");
}
function dir_clear($dir) {
$directory = dir($dir);
while($entry = $directory->read()) {
  $filename = $dir.'/'.$entry;
  if(is_file($filename)) {
   @unlink($filename);
  }
}
@touch($dir.'/index.htm');
$directory->close();
}
function dir_writeable($dir) {
if(!is_dir($dir)) {
  @mkdir($dir, 0777);
}
if(is_dir($dir)) {
  if($fp = @fopen("$dir/test.txt", 'w')) {
   @fclose($fp);
   @unlink("$dir/test.txt");
   $writeable = 1;
  } else {
   $writeable = 0;
  }
}
return $writeable;
}
function daddslashes($string) {
if(is_array($string)) {
  foreach($string as $key => $val) {
   $string[$key] = daddslashes($val, $force);
  }
} else {
  $string = addslashes($string);
}
return $string;
}
function instfooter() {
echo '</table></body></html>';
}
function random($length, $numeric = 0) {
PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
if($numeric) {
  $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
} else {
  $hash = '';
  $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
  $max = strlen($chars) - 1;
  for($i = 0; $i < $length; $i++) {
   $hash .= $chars[mt_rand(0, $max)];
  }
}
return $hash;
}
function runquery($query) {
global $db, $tablepre, $dbcharset;
$query = str_replace("\r", "\n", str_replace(' cdb_', ' '.$tablepre, $query));
$expquery = explode(";\n", $query);
foreach($expquery as $sql) {
  $sql = trim($sql);
  if($sql == '' || $sql[0] == '#') continue;
  if(strtoupper(substr($sql, 0, 12)) == 'CREATE TABLE') {
   $db->query(createtable($sql, $dbcharset));
  } else {
   $db->query($sql);
  }
}
}
function loadtable($table, $force = 0) {
global $db, $tablepre, $dbcharset;
static $tables = array();
if(!isset($tables[$table]) || $force) {
  if($db->version() > '4.1') {
   $query = $db->query("SHOW FULL COLUMNS FROM {$tablepre}$table", 'SILENT');
  } else {
   $query = $db->query("SHOW COLUMNS FROM {$tablepre}$table", 'SILENT');
  }
  while($field = @$db->fetch_array($query)) {
   $tables[$table][$field['Field']] = $field;
  }
}
return $tables[$table];
}
function downgradetable($updatesql) {
global $db, $tablepre, $dbcharset;
$successed = TRUE;
if(is_array($updatesql) && !empty($updatesql[0])) {
  list($table, $action, $field, $sql) = $updatesql;
  if(empty($field) && !empty($sql)) {
   $query = "ALTER TABLE {$tablepre}{$table} ";
   if($action == 'INDEX') {
    $successed = $db->query("$query $sql", "SILENT");
   } elseif ($action == 'UPDATE') {
    $successed = $db->query("UPDATE {$tablepre}{$table} SET $sql", 'SILENT');
   }
  } elseif($tableinfo = loadtable($table)) {
   $fieldexist = isset($tableinfo[$field]) ? 1 : 0;
   $query = "ALTER TABLE {$tablepre}{$table} ";
   if($action == 'MODIFY') {
    $query .= $fieldexist ? "MODIFY $field $sql" : "ADD $field $sql";
    $successed = $db->query($query, 'SILENT');
   } elseif($action == 'CHANGE') {
    $field2 = trim(substr($sql, 0, strpos($sql, ' ')));
    $field2exist = isset($tableinfo[$field2]);
    if($fieldexist && ($field == $field2 || !$field2exist)) {
     $query .= "CHANGE $field $sql";
    } elseif($fieldexist && $field2exist) {
     $db->query('ALTER TABLE {$tablepre}{$table} DROP $field2', 'SILENT');
     $query .= "CHANGE $field $sql";
    } elseif(!$fieldexist && $fieldexist2) {
     $db->query('ALTER TABLE {$tablepre}{$table} DROP $field2', 'SILENT');
     $query .= "ADD $sql";
    } elseif(!$fieldexist && !$field2exist) {
     $query .= "ADD $sql";
    }
    $successed = $db->query($query);
   } elseif($action == 'ADD') {
    $query .= $fieldexist ? "CHANGE $field $field $sql" :  "ADD $field $sql";
    $successed = $db->query($query);
   } elseif($action == 'DROP') {
    if($fieldexist) {
     $successed = $db->query("$query DROP $field", "SILENT");
    }
    $successed = TRUE;
   }
  } else {
   $successed = 'TABLE NOT EXISTS';
  }
}
return $successed;
}
function showheader() {
global $version_old, $version_new;
print <<< EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Discuz! 降级程序( $version_old &gt;&gt; $version_new)</title>
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="MSThemeCompatible" content="Yes">
<style>
a:visited {color: #FF0000; text-decoration: none}
a:link  {color: #FF0000; text-decoration: none}
a:hover  {color: #FF0000; text-decoration: underline}
body,table,td {color: #3a4273; font-family: Tahoma, verdana, arial; font-size: 12px; line-height: 20px; scrollbar-base-color: #e3e3ea; scrollbar-arrow-color: #5c5c8d}
input  {color: #085878; font-family: Tahoma, verdana, arial; font-size: 12px; background-color: #3a4273; color: #ffffff; scrollbar-base-color: #e3e3ea; scrollbar-arrow-color: #5c5c8d}
.install {font-family: Arial, Verdana; font-size: 14px; font-weight: bold; color: #000000}
.header  {font: 12px Tahoma, Verdana; font-weight: bold; background-color: #3a4273 }
.header td {color: #ffffff}
.red  {color: red; font-weight: bold}
.bg1  {background-color: #e3e3ea}
.bg2  {background-color: #eeeef6}
</style>
</head>
<body bgcolor="#3A4273" text="#000000">
<table width="95%" height="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">
<tr>
<td>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="install" height="30" valign="bottom"><font color="#FF0000">&gt;&gt;</font>
Discuz! 降级程序( $version_old &gt;&gt; $version_new)</td>
</tr>
<tr>
<td>
<hr noshade align="center" width="100%" size="1">
</td>
</tr>
<tr>
<td align="center">
<b>本降级程序只能从 $version_old 降级到 $version_new ,运行之前,请确认已经上传所有文件,并做好数据备份<br />
降级当中有任何问题请访问技术支持站点 <a href="http://www.discuz.net" target="_blank">http://www.discuz.net</a></b>
</td>
</tr>
<tr>
<td>
<hr noshade align="center" width="100%" size="1">
</td>
</tr>
<tr><td>
EOT;
}
function showfooter() {
echo <<< EOT
</td></tr></table></td></tr>
<tr><td height="100%"> </td></tr>
</table>
</body>
</html>
EOT;
exit();
}
function showerror($message, $break = 1) {
echo '<br /><br />'.$message.'<br /><br />';
if($break) showfooter();
}
function redirect($url) {
$url = $url.(strstr($url, '&') ? '&' : '?').'t='.time();
echo <<< EOT
<hr size=1>
<script language="JavaScript">
function redirect() {
  window.location.replace('$url');
}
setTimeout('redirect();', 1000);
</script>
<br /><br />
&gt;&gt;<a href="$url">浏览器会自动跳转页面,无需人工干预。除非当您的浏览器长时间没有自动跳转时,请点击这里</a>
<br /><br />
EOT;
showfooter();
}
?>

TOP

3.运行程序后还要去后台
数据库校验 》修复一下
4.导一下以下数据
-- phpMyAdmin SQL Dump
-- version 2.11.4
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2008 年 08 月 20 日 16:44
-- 服务器版本: 5.0.51
-- PHP 版本: 5.2.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- 数据库: `dz1`
--

-- --------------------------------------------------------

--
-- 表的结构 `cdb_pushedthreads`
--

CREATE TABLE IF NOT EXISTS `cdb_pushedthreads` (
  `id` mediumint(8) unsigned NOT NULL,
  `tid` mediumint(8) unsigned NOT NULL default '0',
  `status` tinyint(1) NOT NULL default '0',
  `dateline` int(10) unsigned NOT NULL default '0',
  `subject` varchar(80) NOT NULL,
  `message` text NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `displayorder` (`status`,`dateline`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;

--
-- 导出表中的数据 `cdb_pushedthreads`
--


-- --------------------------------------------------------

CREATE TABLE IF NOT EXISTS `cdb_searchindex` (
  `searchid` int(10) unsigned NOT NULL auto_increment,
  `keywords` varchar(255) NOT NULL default '',
  `searchstring` varchar(255) NOT NULL default '',
  `useip` varchar(15) NOT NULL default '',
  `uid` mediumint(10) unsigned NOT NULL default '0',
  `dateline` int(10) unsigned NOT NULL default '0',
  `expiration` int(10) unsigned NOT NULL default '0',
  `threads` smallint(6) unsigned NOT NULL default '0',
  `tids` text NOT NULL,
  PRIMARY KEY  (`searchid`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;

TOP

发新话题