|
楼主 |
发表于 2005 年 10 月 20 日 21:54:31
|
显示全部楼层
DZ2.5升级4.0.0 成功方法
转自落伍,自己稍加修改.
本方法仅供本地测试用 数据升级有风险
请购买正式商业版 会有升级服务保证数据安全
好多人升级到3.1.2的时候把 3.1.2的文件传上去覆盖原来的2.5
这样就出问题了
为什么呢?
因为3.1.2也是商业版 传一个商业版 没破解的上去 升级的时候 就出现了 没有授权的提示
所以 升级的时候 什么都不要上传 就把2.5to3.1.2<upgrade312.php>的文件传上去
- <?php
- // Upgrade Discuz! Board from 2.5F to 3.1.2
- header("Content-Type: text/html; charset=gb2312");
- set_time_limit(1000);
- define('IN_DISCUZ', TRUE);
- if(file_exists('./config.php')) {
- require "./config.php";
- } else {
- require "./config.inc.php";
- }
- require "./include/db_mysql.php";
- error_reporting(E_ERROR | E_WARNING | E_PARSE);
- @set_magic_quotes_runtime(0);
- $action = ($HTTP_POST_VARS[action]) ? $HTTP_POST_VARS[action] : $HTTP_GET_VARS[action];
- $step = $HTTP_GET_VARS[step];
- $start = $HTTP_GET_VARS[start];
- $upgrade1 = <<<EOT
- DROP TABLE cdb_caches;
- DROP TABLE cdb_plugins;
- DROP TABLE cdb_plugins_settings;
- DELETE FROM cdb_settings WHERE variable = 'attachimgcheck' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'attachsoftdownload' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'attach_max' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'attach_newpost' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'attach_editpost' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'attach_replypost' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'statcacherefresh' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'delayeditpost' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'delaykarma' LIMIT 1;
- DELETE FROM cdb_settings WHERE variable = 'useimagemessage' LIMIT 1;
- UPDATE cdb_settings SET value = '3.1' WHERE variable = 'version' LIMIT 1 ;
- INSERT INTO cdb_settings ( variable , value ) VALUES ('dotfolders', '0');
- ALTER TABLE cdb_settings ORDER BY variable;
- ALTER TABLE cdb_adminsessions CHANGE uid sid CHAR( 6 ) BINARY DEFAULT '' NOT NULL,DROP ip,DROP PRIMARY KEY;
- ALTER TABLE cdb_admingroups CHANGE admingid admingid TINYINT( 1 ) UNSIGNED DEFAULT '0',DROP admintitle,DROP adminglobal,DROP allowhighlight,DROP allowdigest,DROP allowclose,DROP allowmove,DROP allowtop,DROP allowmerge,DROP allowsplit;
- ALTER TABLE cdb_announcements DROP posturl;
- ALTER TABLE cdb_karmalog DROP kid,CHANGE score score TINYINT( 3 ) UNSIGNED DEFAULT '0' NOT NULL,DROP INDEX pid,DROP INDEX dateline;
- DROP TABLE IF EXISTS cdb_profilefields;
- CREATE TABLE cdb_profilefields (
- fieldid smallint(6) unsigned NOT NULL auto_increment,
- available tinyint(1) NOT NULL default '0',
- invisible tinyint(1) NOT NULL default '0',
- title varchar(50) NOT NULL default '',
- description varchar(255) NOT NULL default '',
- size tinyint(3) unsigned NOT NULL default '0',
- displayorder smallint(6) NOT NULL default '0',
- required tinyint(1) NOT NULL default '0',
- showinthread tinyint(1) NOT NULL default '0',
- selective tinyint(1) NOT NULL default '0',
- choices text NOT NULL,
- PRIMARY KEY (fieldid)
- ) TYPE=MyISAM;
- ALTER TABLE cdb_attachments DROP uid,DROP dateline,DROP INDEX tid,DROP INDEX pid,CHANGE downloads downloads SMALLINT( 6 ) DEFAULT '0' NOT NULL;
- EOT;
- $upgrade2 = <<<EOT
- ALTER TABLE cdb_members CHANGE adminid adminid TINYINT( 1 ) DEFAULT '0' NOT NULL;
- EOT;
- $upgrade3 = <<<EOT
- ALTER TABLE cdb_posts CHANGE aid aid MEDIUMINT( 8 ) UNSIGNED DEFAULT '0' NOT NULL,ADD INDEX dotfolder ( tid , authorid );
- EOT;
- if(!$action) {
- echo"<title>Discuz!升级程序: 2.5F 到 3.12(共六步)</title>";
- echo"本程序用于升级 Discuz! 2.5F 到 Discuz! 3.12,请确认之前已经顺利安装 Discuz! 2.5F<br><br><br>";
- echo"<b><font color=\"red\">本升级程序只能从 2.5F 升级到 3.1.2,运行之前,请确认已经上传 3.1.2 的全部文件和目录</font></b><br>";
- echo"<b><font color=\"red\">升级前请打开浏览器 JavaScript 支持,整个过程是自动完成的,不需人工点击和干预.<br><b>升级之前务必备份数据库资料,否则可能产生无法恢复的后果!</b><br><br>本次升级可能需要耗时很多,并可能占用大量CPU资源,根据您的数据量有关,请在服务器空闲时进行.<br>请确保服务器上 PHP 没有在安全模式,或没有脚本运行时间的硬性限制,否则请在本地机器升级后上传数据库。</font></b><br><br>";
- echo"正确的升级方法为:<br>1. 关闭原有论坛,上传 Discuz! 3.1.2 版的全部文件和目录,覆盖服务器上的 2.5F<br>2. 根据安装说明,设置目录announcement、customavatars、forumdata/accesslogs属性777<br>3. 上传本程序到 Discuz! 目录中;<br>4. 运行本程序,直到出现升级完成的提示;<br><br>";
- echo"<a href=\"$PHP_SELF?action=upgrade&step=1\">如果您已确认完成上面的步骤,请点这里升级</a>";
- } else {
- $tables = array('attachments', 'announcements', 'banned', 'caches', 'favorites', 'forumlinks', 'forums', 'karmalog', 'members', 'memo',
- 'news', 'polls', 'posts', 'searchindex', 'sessions', 'settings', 'styles', 'smilies', 'stats', 'subscriptions', 'templates', 'themes',
- 'threads', 'pm', 'pms', 'usergroups', 'words', 'buddys', 'stylevars');
- foreach($tables as $tablename) {
- ${"table_".$tablename} = $tablepre.$tablename;
- }
- unset($tablename);
- $db = new dbstuff;
- $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
- $db->select_db($dbname);
- unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
- if($step == 1) {
- $query = $db->query("SELECT value FROM ".$tablepre."settings WHERE variable='version'");
- if(($db->result($query, 0)) != '2.5') {
- echo"<title>发生错误!</title>";
- exit('您当前数据库数据版本不是2.5,无法升级<br><a href="javascript:history.go(-1)">返回</a>'); //debug
- }
- echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>";
- runquery($upgrade1);
- echo "第 $step 步升级成功<br>";
- redirect("$PHP_SELF?action=upgrade&step=".($step + 1));
- } elseif($step == 2) {
- echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>";
- runquery($upgrade2);
- echo "第 $step 步升级成功<br>";
- redirect("$PHP_SELF?action=upgrade&step=".($step + 1));
- } elseif($step == 3) {
- echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>";
- runquery($upgrade3);
- echo "第 $step 步升级成功<br>";
- redirect("$PHP_SELF?action=upgrade&step=".($step + 1));
- } elseif($step == 4) {
- echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>";
- $tagArray = array(
- 'fly'=>'\'\', 0, \'fly\', \'<marquee width="90%" behavior="alternate" scrollamount="3">{1}</marquee>\', \'[fly]This is sample text[/fly]\', \'Make text move horizontal, the same effect as html tag <marquee>. NOTE: Only Internet Explorer supports this feature\', 1, 1',
- 'wmv'=>'\'\', 0, \'wmv\', \'<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" class="OBJECT" id="MediaPlayer" width="500" height="350" >\r\n<param name="ShowStatusBar" value="-1">\r\n<param name="Filename" value="{1}">\r\n<embed type="application/x-oleobject" codebase="[url]http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5[/url],1,52,701" flename="wmv" src="{1}" width="500" height="350">\r\n</embed></object>\', \'[wmv]mms://your.com/example.wmv[/wmv]\', \'Embed Windows media file in thread page\', 1, 1',
- 'rm'=>'\'\', 0, \'rm\', \'<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="500" height="300" id="Player" viewastext>\r\n<param name="_ExtentX" value="12726">\r\n<param name="_ExtentY" value="8520">\r\n<param name="AUTOSTART" value="0">\r\n<param name="SHUFFLE" value="0">\r\n<param name="PREFETCH" value="0">\r\n<param name="NOLABELS" value="0">\r\n<param name="CONTROLS" value="ImageWindow">\r\n<param name="CONSOLE" value="_master">\r\n<param name="LOOP" value="0">\r\n<param name="NUMLOOP" value="0">\r\n<param name="CENTER" value="0">\r\n<param name="MAINTAINASPECT" value="{1}">\r\n<param name="BACKGROUNDCOLOR" value="#000000">\r\n</object><br><object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="500" height="50" id="Player" viewastext>\r\n<param name="_ExtentX" value="18256">\r\n<param name="_ExtentY" value="794">\r\n<param name="AUTOSTART" value="-1">\r\n<param name="SHUFFLE" value="0">\r\n<param name="PREFETCH" value="0">\r\n<param name="NOLABELS" value="0">\r\n<param name="CONTROLS" value="controlpanel">\r\n<param name="CONSOLE" value="_master">\r\n<param name="LOOP" value="0">\r\n<param name="NUMLOOP" value="0">\r\n<param name="CENTER" value="0">\r\n<param name="MAINTAINASPECT" value="0">\r\n<param name="BACKGROUNDCOLOR" value="#000000">\r\n<param name="SRC" value="{1}"></object>\', \'[rm]rtsp://your.com/example.rm[/rm]\', \'Embed Real Movie in thread page\', 1, 1'
- );
- foreach ($tagArray AS $value=>$content) {
- $query = $db->query("SELECT * FROM ".$tablepre."bbcodes WHERE tag='$value'");
- $exists = mysql_num_rows($query);
- if ($exists == 0) {
- $InsertQuery = $db->query("INSERT INTO ".$tablepre."bbcodes (id, available, tag, replacement, example, explanation, params, nest) VALUES ($content);");
- }
- }
- echo "第 $step 步升级成功<br>";
- redirect("$PHP_SELF?action=upgrade&step=".($step + 1));
- } elseif($step == 5) {
- $many = 2000;
- $start = intval($start);
- $start = $start < 1 ? 0 : $start;
- $end = $start + $many;
- $continue = 0;
- echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>";
- echo "正在进行第 $step 步(转换POSTS表):<br>";
- echo "如果您的附件很多本步可能需要时间较长<br>";
- echo "当前影响第 $start 行到 $end 行数据。<br>";
- $query = $db->query("SELECT * FROM ".$tablepre."attachments LIMIT $start,$many;");
- while($a = $db->fetch_array($query)) {
- $query2 = $db->query("UPDATE ".$tablepre."posts SET aid='$a[aid]' WHERE pid='$a[pid]';");
- $continue = 1;
- }
- if ($continue) {
- echo "操作继续。<br>";
- redirect("$PHP_SELF?action=upgrade&step=$step&start=$end");
- } else {
- echo "第 $step 步升级成功<br>";
- redirect("$PHP_SELF?action=upgrade&step=".($step + 1));
- }
- } elseif($step == 6) {
- @unlink('./forumdata/cache/cache_settings.php');
- echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>";
- echo "恭喜您升级成功,请删除本程序。<a href='./index.php' target=_blank>点击这里进入您的论坛</a>";
- }
- }
- function runquery($query) {
- global $db, $tablepre;
- $expquery = explode(";", $query);
- foreach($expquery as $sql) {
- $sql = trim($sql);
- if($sql != "" && $sql[0] != "#") {
- $db->query(str_replace("cdb_", $tablepre, $sql));
- }
- }
- }
- function redirect($url) {
- echo"<script>";
- echo"function redirect() {window.location.replace('$url');}\n";
- echo"setTimeout('redirect();', 2000);\n";
- echo"</script>";
- echo"<br><br><a href=\"$url\">如果您的浏览器没有自动跳转,请点击这里</a>";
- }
- ?>
复制代码
升级之后
再把破解的4.0.0传上去覆盖 再用DZ4.0里带的升级程序upgrade5.php升级
升级过程中 可能因为 你的论坛装过一些插件 跟升级程序中的表重复
你可以删除个别表 然后继续升级
如果最后有数据库错误,那试试用下面的导入<我的就是用了这部才成功>
- DROP TABLE IF EXISTS cdb_plugins;
- CREATE TABLE cdb_plugins (
- pluginid smallint(6) unsigned NOT NULL auto_increment,
- available tinyint(1) NOT NULL default '0',
- adminid tinyint(1) unsigned NOT NULL default '0',
- name varchar(40) NOT NULL default '',
- identifier varchar(40) NOT NULL default '',
- description varchar(255) NOT NULL default '',
- datatables varchar(255) NOT NULL default '',
- `directory` varchar(100) NOT NULL default '',
- copyright varchar(100) NOT NULL default '',
- modules text NOT NULL,
- PRIMARY KEY (pluginid),
- UNIQUE KEY identifier (identifier)
- ) Type=MyISAM;
复制代码
演示:http://huanghua.mireene.com/bbs/ |
|