3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2010 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * @license http://nucleuscms.org/license.txt GNU General Public License
14 * @copyright Copyright (C) 2002-2010 The Nucleus Group
16 * $NucleusJP: upgrade1.0.php,v 1.3.2.1 2007/10/24 05:39:15 kimitake Exp $
20 function upgrade_do100() {
22 if (upgrade_checkinstall(100))
25 // 1. add extra indices to tables
26 if (!upgrade_checkIfIndexExists('item', array('iblog', 'itime'))) {
27 $query = 'ALTER TABLE '.sql_table('item').' ADD INDEX(iblog, itime);';
28 upgrade_query("Adding extra index to nucleus_item",$query);
30 if (!upgrade_checkIfIndexExists('comment', array('citem'))) {
31 $query = 'ALTER TABLE '.sql_table('comment').' ADD INDEX(citem);';
32 upgrade_query("Adding extra index to nucleus_comment",$query);
35 // 2. add DisableJsTools to config
36 if (!upgrade_checkIfCVExists('DisableJsTools')) {
37 $query = 'INSERT INTO '.sql_table('config')." VALUES ('DisableJsTools', '0');";
38 upgrade_query("Adding setting DisableJsTools",$query);
41 // 3. Drop primary key in nucleus_actionlog
42 $query = 'ALTER TABLE '.sql_table('actionlog').' DROP PRIMARY KEY;';
43 upgrade_query("Dropping primary key for actionlog table",$query);
45 // 4. add mcookiekey to nucleus_member
46 if(0==$upgrade_failures && !upgrade_checkIfColumnExists('member', 'mcookiekey')){
47 $query = 'ALTER TABLE '.sql_table('member')
48 . " ADD mcookiekey varchar(40) ";
49 $res = upgrade_query("Adding cookiekey attribute to members",$query);
51 // only do this when the previous query succeeds
52 //A more efficent query might be 'UPDATE '.sql_table('member')." SET mpassword=MD5(mpassword)"
54 // 5. for all members: hash their password and also copy it to mcookiekey
55 $query = 'SELECT * FROM '.sql_table('member');
56 $res = mysql_query($query);
57 while ($current = mysql_fetch_object($res)) {
58 $hashedpw = md5($current->mpassword);
59 $updquery = 'UPDATE '.sql_table('member')." SET mpassword='$hashedpw' WHERE mnumber=" . $current->mnumber;
60 upgrade_query("Encrypting password for member " . $current->mnumber,$updquery);
64 echo "<li>Adding cookiekey attribute to members ... <span class=\"warning\">NOT EXECUTED</span>\n<blockquote>Errors occurred during upgrade process.</blockquote>";