From b709bcb1f2338e35d7d1b980757a24529c99adfa Mon Sep 17 00:00:00 2001
From: kimitake
èªåã§ã§ããã¢ããã°ã¬ã¼ãã¯ããã¾ããããã¼ã¿ãã¼ã¹ã¯æ¢ã«ææ°ã® Nucleus ç¨ã«ã¢ãããã¼ãããã¦ãã¾ãã
- -ãããã¯ãªãã¯ãã¦ãã¼ã¿ãã¼ã¹ã Nucleus v3.3 ç¨ã«ã¢ããã°ã¬ã¼ããã¾ã
- +èªåã§ã§ããã¢ããã°ã¬ã¼ãã¯ããã¾ããããã¼ã¿ãã¼ã¹ã¯æ¢ã«ææ°ã® Nucleus ç¨ã«ã¢ãããã¼ãããã¦ãã¾ãã
+ +ãããã¯ãªãã¯ãã¦ãã¼ã¿ãã¼ã¹ã Nucleus v3.3 ç¨ã«ã¢ããã°ã¬ã¼ããã¾ã
+æåå¤æ´ã¯å¿ è¦ããã¾ãããä»æ¥ã¯ã©ããã¼ãªæ¥ã§ãã!
"; + echo "æåå¤æ´ã¯å¿ è¦ããã¾ãããä»æ¥ã¯ã©ããã¼ãªæ¥ã§ãã!
"; @@ -100,7 +106,7 @@ function upgrade_todo($ver) { function upgrade_manual_96() { global $DIR_NUCLEUS; - + $guess = str_replace("/nucleus/","/media/",$DIR_NUCLEUS); ?>ã¾ãããã£ã¬ã¯ããªãããªãèªèº«ã®æã§ä½ãå¿ è¦ãããã¾ãããããã¡ã¤ã«ã®ã¢ãããã¼ããå¯è½ã«ãããã®ã§ããã°ãmedia/ ãã£ã¬ã¯ããªã®ãã¼ããã·ã§ã³ã777ã«ãã¾ããï¼Nucleus 0.96+ ã®ããã®ãã¼ããã·ã§ã³ã®è¨å®ã«é¢ããã¯ã¤ãã¯ã¬ã¤ãã documentation/tips.html ã«ããã¾ãï¼
- +ã¾ãããã£ã¬ã¯ããªãããªãèªèº«ã®æã§ä½ãå¿ è¦ãããã¾ããããã§ãã¦ã³ãã¼ãããã¹ãã³ãä¸è¨ãã£ã¬ã¯ããªã«å±éããããNucleus 管çç»é¢ããåãè¾¼ãã ãã§ããããã«ãªãã¾ãã
- +Nucleus 2.0 ãæ°è¦ã«ã¤ã³ã¹ãã¼ã«ããã¨ããRSD(Really Simple Discovery) ç¨ã®ã¹ãã³ã®ä»ã«ãRSS 2.0(Really Simple Syndication)ç¨ã®ã¹ãã³ãã¾ãã¤ã³ã¹ãã¼ã«ããã¾ããxml-rss2.php
㨠rsd.php
ã®ä¸¡ãã¡ã¤ã«ã¯ã¢ããã°ã¬ã¼ãããã¾ãããã¹ãã³ã«é¢ãã¦ã¯æåã§ã¤ã³ã¹ãã¼ã«ããå¿
è¦ãããã¾ããupgrade-files
ã®ä¸èº«ãã¢ãããã¼ããããã¨ã管çè
ç»é¢ãéãã管çãã¼ã ã«ããã¹ãã³ã®ãèªè¾¼/æ¸åºããéãã¾ãããããã両ã¹ãã³ãã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ãï¼ããã¤ã³ã¹ãã¼ã«ããã¤ããããªããã°ãããªãã¦ãçµæ§ã§ãï¼ã
+if (in_array($actionlc, $this->actions) || $this->norestrictions ) { - $this->call_using_array($action, $this->handler, $params); + $this->call_using_array($action, $this->handler, $params); } else { - // redirect to plugin action if possible - if (in_array('plugin', $this->actions) - && $manager->pluginInstalled('NP_'.$action)) - $this->doAction('plugin('.$action. - $this->pdelim.implode($this->pdelim,$params).')'); - else - echo '<b>DISALLOWED (' , $action , ')</b>'; + // redirect to plugin action if possible + if (in_array('plugin', $this->actions) + && $manager->pluginInstalled('NP_'.$action)) + $this->doAction('plugin('.$action. + $this->pdelim.implode($this->pdelim,$params).')'); + else + echo '<b>DISALLOWED (' , $action , ')</b>'; } } --
++
// $params = array_map('trim',$params); foreach ($params as $key => $value) { $params[$key] = trim($value); } --
ä¸è¨ã®æ å ±ãå ¥åãã¦ä¸ãã:
- + @@ -132,8 +147,10 @@ã¡ãã»ã¼ã¸ã¯ä»¥ä¸ã®éã:
- +@@ -167,48 +185,48 @@ upgrade_foot(); exit; } - - + + function upgrade_start() { global $upgrade_failures; $upgrade_failures = 0; - + upgrade_head(); ?>
ã¢ããã°ã¬ã¼ãæåã®ãã¼ã¸ã«ãã©ã
$friendly ... "; - $res = sql_query($query); + $res = mysql_query($query); if (!$res) { echo "失æ\n"; echo "失æã®çç±: " . mysql_error() . ""; @@ -219,16 +237,32 @@ echo ""; return $res; } - + + /** + * Tries to update database version, gives a message when failed + * + * @param $version + * Schema version the database has been upgraded to + */ + function update_version($version) { + global $upgrade_failures; + $message='Updating DatabaseVersion in config table to '.$version; + if(0==$upgrade_failures){ + $query = 'UPDATE ' . sql_table('config') . ' set value=\''.$version.'\' where name=\'DatabaseVersion\''; + upgrade_query($message, $query); + }else + echo '
Errors occurred during upgrade process.'; + } + /** - * @param $table + * @param $table * table to check (without prefix) * @param $aColumns * array of column names included */ function upgrade_checkIfIndexExists($table, $aColumns) { // get info for indices from database - + $aIndices = array(); $query = 'show index from ' . sql_table($table); $res = mysql_query($query); @@ -244,11 +278,52 @@ $aDiff = array_diff($aIndexColumns, $aColumns); if (count($aDiff) == 0) return 1; } - + return 0; } + /** + * Checks to see if a given table exists + * + * @param $table + * Name of table to check for existance of + * Uses sql_table internally + * @return true if table exists, false otherwise. + */ + function upgrade_checkIfTableExists($table){ + $query = 'SHOW TABLES LIKE \''.sql_table($table).'\''; + $res = mysql_query($query); + return ($res != 0) && (mysql_num_rows($res) == 1); + } + /** + * Checks to see if a given configuration value exists + * + * @param $value + * Config value to check for existance of. + * Paramater must be MySQL escaped + * @return true if configuration value exists, false otherwise. + */ + function upgrade_checkIfCVExists($value){ + $query = 'SELECT name from '.sql_table('config').' WHERE name = \''.$value.'\''; + $res = mysql_query($query); + return ($res != 0) && (mysql_num_rows($res) == 1); + } + /** + * Checks to see if a given column exists + * + * @param $table + * Name of table to check for column in + * Uses sql_table internally + * @param $col + * Name of column to check for existance of + * @return true if column exists, false otherwise. + */ + function upgrade_checkIfColumnExists($table, $col){ + $query = 'DESC `'.sql_table($table).'` `'.$col.'`'; + $res = mysql_query($query); + return ($res != 0) && (mysql_num_rows($res) == 1); + } ?> diff --git a/utf8/nucleus/upgrades/upgrade.php b/utf8/nucleus/upgrades/upgrade.php index c5e444d..13b0638 100755 --- a/utf8/nucleus/upgrades/upgrade.php +++ b/utf8/nucleus/upgrades/upgrade.php @@ -1,20 +1,23 @@ isLoggedIn()) { upgrade_showLogin('upgrade.php?from=' . intGetVar('from')); @@ -60,6 +63,7 @@ switch($from) { upgrade_do31(); case 31: upgrade_do32(); + break; case 32: upgrade_do33(); break; @@ -72,4 +76,4 @@ switch($from) { upgrade_end("ã¢ããã°ã¬ã¼ãæå"); -?> +?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade0.95.php b/utf8/nucleus/upgrades/upgrade0.95.php index b854121..1aa9e8c 100755 --- a/utf8/nucleus/upgrades/upgrade0.95.php +++ b/utf8/nucleus/upgrades/upgrade0.95.php @@ -1,14 +1,17 @@ Adding 'send ping' and convert linebreaks options ... NOT EXECUTED\n
Errors occurred during upgrade process."; + } } ?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade0.96.php b/utf8/nucleus/upgrades/upgrade0.96.php index 3d85bdd..adc7987 100755 --- a/utf8/nucleus/upgrades/upgrade0.96.php +++ b/utf8/nucleus/upgrades/upgrade0.96.php @@ -4,70 +4,89 @@ function upgrade_do96() { if (upgrade_checkinstall(96)) return "already installed"; -// 1. create nucleus_actionlog -$query = 'CREATE TABLE '.sql_table('actionlog')." (timestamp datetime NOT NULL default '0000-00-00 00:00:00', message varchar(255) NOT NULL default '', PRIMARY KEY (timestamp)) TYPE=MyISAM;"; -upgrade_query("Creating nucleus_actionlog table",$query); - -// 2. create nucleus_ban -$query = 'CREATE TABLE '.sql_table('ban')." ( iprange varchar(15) NOT NULL default '', reason varchar(255) NOT NULL default '', blogid int(11) NOT NULL default '0') TYPE=MyISAM;"; -upgrade_query("Creating nucleus_ban table",$query); - -// 4. add ikarma to nucleus_item -$query = 'ALTER TABLE '.sql_table('item') - . " ADD ikarma int(11) NOT NULL default '0'"; -upgrade_query("Adding karma-votes to items",$query); - -// 5. create nucleus_karma -$query = 'CREATE TABLE '.sql_table('karma')." (" - ." itemid int(11) NOT NULL default '0'," - ." ip char(15) NOT NULL default ''" - .") TYPE=MyISAM;"; -upgrade_query("Creating nucleus_karma table",$query); - - -// 6. nucleus_config: add MediaURL, AllowedTypes, AllowLoginEdit, AllowUpload - -// create MediaURL out of IndexURL -$mediaURL = $CONF['IndexURL'] . "media/"; - -$query = 'INSERT INTO '.sql_table('config')." VALUES ('MediaURL', '$mediaURL');"; -$query2 = 'INSERT INTO '.sql_table('config')." VALUES ('AllowedTypes', 'jpg,jpeg,gif,mpg,mpeg,avi,mov,mp3,swf,png');"; -$query3 = 'INSERT INTO '.sql_table('config')." VALUES ('AllowLoginEdit', '0');"; -$query4 = 'INSERT INTO '.sql_table('config')." VALUES ('AllowUpload', '1');"; -upgrade_query("New setting MediaURL",$query); -upgrade_query("New setting AllowedTypes",$query2); -upgrade_query("New setting AllowLoginEdit",$query3); -upgrade_query("New setting AllowUpload",$query4); - -// 7. add 'imagepopup' skincontents in skin 'default' - -$query = 'SELECT sdnumber FROM '.sql_table('skin_desc')." WHERE sdname='default'"; -$res = sql_query($query); -$obj = mysql_fetch_object($res); -$skinid = $obj->sdnumber; -$query = 'INSERT INTO '.sql_table('skin')." VALUES (" . $skinid . ", 'imagepopup', '\r\n\r\n
Errors occurred during upgrade process."; + } } diff --git a/utf8/nucleus/upgrades/upgrade1.0.php b/utf8/nucleus/upgrades/upgrade1.0.php index a28c739..5287181 100755 --- a/utf8/nucleus/upgrades/upgrade1.0.php +++ b/utf8/nucleus/upgrades/upgrade1.0.php @@ -1,40 +1,50 @@ mpassword); - $updquery = 'UPDATE '.sql_table('member')." SET mpassword='$hashedpw' WHERE mnumber=" . $current->mnumber; - upgrade_query("Encrypting password for member " . $current->mnumber,$updquery); + if (upgrade_checkinstall(10)) + return "already installed"; + + // 1. add extra indices to tables + if (!upgrade_checkIfIndexExists('item', array('iblog', 'itime'))) { + $query = 'ALTER TABLE '.sql_table('item').' ADD INDEX(iblog, itime);'; + upgrade_query("Adding extra index to nucleus_item",$query); + } + if (!upgrade_checkIfIndexExists('comment', array('citem'))) { + $query = 'ALTER TABLE '.sql_table('comment').' ADD INDEX(citem);'; + upgrade_query("Adding extra index to nucleus_comment",$query); + } + + // 2. add DisableJsTools to config + if (!upgrade_checkIfCVExists('DisableJsTools')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('DisableJsTools', '0');"; + upgrade_query("Adding setting DisableJsTools",$query); + } + + // 3. Drop primary key in nucleus_actionlog + $query = 'ALTER TABLE '.sql_table('actionlog').' DROP PRIMARY KEY;'; + upgrade_query("Dropping primary key for actionlog table",$query); + + // 4. add mcookiekey to nucleus_member + if(0==$upgrade_failures && !upgrade_checkIfColumnExists('member', 'mcookiekey')){ + $query = 'ALTER TABLE '.sql_table('member') + . " ADD mcookiekey varchar(40) "; + $res = upgrade_query("Adding cookiekey attribute to members",$query); + + // only do this when the previous query succeeds + //A more efficent query might be 'UPDATE '.sql_table('member')." SET mpassword=MD5(mpassword)" + if ($res) { + // 5. for all members: hash their password and also copy it to mcookiekey + $query = 'SELECT * FROM '.sql_table('member'); + $res = mysql_query($query); + while ($current = mysql_fetch_object($res)) { + $hashedpw = md5($current->mpassword); + $updquery = 'UPDATE '.sql_table('member')." SET mpassword='$hashedpw' WHERE mnumber=" . $current->mnumber; + upgrade_query("Encrypting password for member " . $current->mnumber,$updquery); + } + } + }else{ + echo "
Errors occurred during upgrade process."; } -} - -// 3. add extra indices to tables -$query = 'ALTER TABLE '.sql_table('item').' ADD INDEX(iblog, itime);'; -upgrade_query("Adding extra index to nucleus_item",$query); -$query = 'ALTER TABLE '.sql_table('comment').' ADD INDEX(citem);'; -upgrade_query("Adding extra index to nucleus_comment",$query); - -// 4. add DisableJsTools to config -$query = 'INSERT INTO '.sql_table('config')." VALUES ('DisableJsTools', '0');"; -upgrade_query("Adding setting DisableJsTools",$query); - -// 5. Drop primary key in nucleus_actionlog -$query = 'ALTER TABLE '.sql_table('actionlog').' DROP PRIMARY KEY;'; -upgrade_query("Dropping primary key for actionlog table",$query); - } diff --git a/utf8/nucleus/upgrades/upgrade1.1.php b/utf8/nucleus/upgrades/upgrade1.1.php index 763e6fb..b518232 100755 --- a/utf8/nucleus/upgrades/upgrade1.1.php +++ b/utf8/nucleus/upgrades/upgrade1.1.php @@ -1,89 +1,111 @@ bnumber; + if (upgrade_checkinstall(11)) + return "already installed"; - $query = 'INSERT INTO '.sql_table('category')." (catid, cblog, cname, cdesc) VALUES ($catid, $blogid, 'General', 'Items that do not fit in other categories')"; - $r = upgrade_query("Adding category 'general' for blog " . $blogid, $query); - - // only perform next actions when insert went ok - if ($r) { - $query = 'UPDATE '.sql_table('blog')." SET bdefcat=$catid WHERE bnumber=$blogid"; - upgrade_query("Setting the default category for blog $blogid to the 'General' category", $query); + // 1. add some options to nucleus_config + if (!upgrade_checkIfCVExists('CookiePath')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookiePath', '/');"; + upgrade_query('CookiePath setting',$query); + } + if (!upgrade_checkIfCVExists('CookieDomain')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookieDomain', '');"; + upgrade_query('CookieDomain setting',$query); + } + if (!upgrade_checkIfCVExists('CookieSecure')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookieSecure', '0');"; + upgrade_query('CookieSecure setting',$query); + } + if (!upgrade_checkIfCVExists('MediaPrefix')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('MediaPrefix', '1');"; + upgrade_query('MediaPrefix setting',$query); + } - $query = 'UPDATE '.sql_table('item')." SET icat=$catid WHERE iblog=$blogid"; - upgrade_query("Assigning all existing items of blog $blogid to the 'General' category",$query); + // 2. add language field to member table + if(!upgrade_checkIfColumnExists('member', 'deflang')){ + upgrade_query("Language setting (member)", + 'ALTER TABLE '.sql_table('member')." ADD deflang varchar(20) NOT NULL default '';"); } - $catid++; -} - -// 5. add content type field to skins -$query = 'ALTER TABLE '.sql_table('skin_desc')." ADD sdtype VARCHAR(40) NOT NULL DEFAULT 'text/html'"; -upgrade_query("Adding content type field to skins (text/html)", $query); - -// 6. try to set content type for xml-rss skin to text/xml -$query = 'UPDATE '.sql_table('skin_desc')." SET sdtype='text/xml' WHERE sdname='xmlrss'"; -upgrade_query("Setting content type for xmlrss skin to text/xml", $query); - -// 7. add template parts for category lists to all templates -$query = 'SELECT tdnumber FROM '.sql_table('template_desc'); -$res = sql_query($query); // get all template ids -while ($obj = mysql_fetch_object($res)) { - $tid = $obj->tdnumber; // template id - - $query = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'CATLIST_HEADER', '
Errors occurred during upgrade process."; + } } - -// 8. add bnotifytype column to blog tables -upgrade_query("Notify Type Setting", - 'ALTER TABLE '.sql_table('blog')." ADD bnotifytype INT(11) NOT NULL default '15';"); - - -} - ?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade1.5.php b/utf8/nucleus/upgrades/upgrade1.5.php index 637cf67..b148561 100755 --- a/utf8/nucleus/upgrades/upgrade1.5.php +++ b/utf8/nucleus/upgrades/upgrade1.5.php @@ -3,32 +3,37 @@ function upgrade_do15() { if (upgrade_checkinstall(15)) return "already installed"; - - // first two queries are needed for people running the development version - global $nucleus; - if (strstr($nucleus['version'],'dev')) { - upgrade_query('Renaming table nucleus_plugins_events','RENAME TABLE '.sql_table('plugins_events').' TO '.sql_table('plugin_event')); - upgrade_query('Renaming table nucleus_plugins','RENAME TABLE '.sql_table('plugins').' TO '.sql_table('plugin')); - } // create nucleus_plugin_event - $query = 'CREATE TABLE '.sql_table('plugin_event').' (pid int(11) NOT NULL, event varchar(40)) TYPE=MyISAM;'; - upgrade_query("Creating nucleus_plugin_event table",$query); + if (upgrade_checkIfTableExists('plugin_events')) {//present in dev version + upgrade_query('Renaming table nucleus_plugins_events','RENAME TABLE '.sql_table('plugins_events').' TO '.sql_table('plugin_event')); + }elseif (!upgrade_checkIfTableExists('plugin_event')) { + $query = 'CREATE TABLE '.sql_table('plugin_event').' (pid int(11) NOT NULL, event varchar(40)) TYPE=MyISAM;'; + upgrade_query("Creating nucleus_plugin_event table",$query); + } // create nucleus_plugin - $query = 'CREATE TABLE '.sql_table('plugin')." (pid int(11) NOT NULL auto_increment, pfile varchar(40) NOT NULL, porder int(11) not null, PRIMARY KEY(pid)) TYPE=MyISAM;"; - upgrade_query("Creating nucleus_plugin table",$query); + if (upgrade_checkIfTableExists('plugins')) {//present in dev version + upgrade_query('Renaming table nucleus_plugins','RENAME TABLE '.sql_table('plugins').' TO '.sql_table('plugin')); + }elseif (!upgrade_checkIfTableExists('plugin')) { + $query = 'CREATE TABLE '.sql_table('plugin')." (pid int(11) NOT NULL auto_increment, pfile varchar(40) NOT NULL, porder int(11) not null, PRIMARY KEY(pid)) TYPE=MyISAM;"; + upgrade_query("Creating nucleus_plugin table",$query); + } // add MaxUploadSize to config - $query = 'INSERT INTO '.sql_table('config')." VALUES ('MaxUploadSize','1048576')"; - upgrade_query('MaxUploadSize setting',$query); + if (!upgrade_checkIfCVExists('MaxUploadSize')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('MaxUploadSize','1048576')"; + upgrade_query('MaxUploadSize setting',$query); + } // try to add cblog column when it does not exists yet - $query = 'SELECT * FROM '.sql_table('comment').' WHERE cblog=0 LIMIT 1'; - $res = mysql_query($query); - if (!$res || (mysql_num_rows($res) > 0)) { - + //The logic on the old code seems off, but my replacement may not be correct either--AWB + //$query = 'SELECT * FROM '.sql_table('comment').' WHERE cblog=0 LIMIT 1'; + //$res = mysql_query($query); + //if (!$res || (mysql_num_rows($res) > 0)) { + + if(!upgrade_checkIfColumnExists('comment', 'cblog')){ $query = 'ALTER TABLE '.sql_table('comment')." ADD cblog int(11) NOT NULL default '0'"; upgrade_query('Adding cblog column in table nucleus_comment',$query); @@ -43,9 +48,11 @@ function upgrade_do15() { // add 'pluginURL' to config global $CONF; - $pluginURL = $CONF['AdminURL'] . "plugins/"; - $query = 'INSERT INTO '.sql_table('config')." VALUES ('PluginURL', '$pluginURL');"; - upgrade_query('PluginURL setting', $query); + if (!upgrade_checkIfCVExists('PluginURL')) { + $pluginURL = $CONF['AdminURL'] . "plugins/"; + $query = 'INSERT INTO '.sql_table('config')." VALUES ('PluginURL', '$pluginURL');"; + upgrade_query('PluginURL setting', $query); + } // add 'EDITLINK' to all templates $query = 'SELECT tdnumber FROM '.sql_table('template_desc'); @@ -77,16 +84,25 @@ function upgrade_do15() { } // new setting: NonmemberMail - upgrade_query('NonmemberMail setting', 'INSERT INTO '.sql_table('config')." VALUES ('NonmemberMail', '0');"); + if (!upgrade_checkIfCVExists('NonmemberMail')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('NonmemberMail', '0');"; + upgrade_query("Adding setting NonmemberMail",$query); + } // new setting: ProtectMemNames - upgrade_query('ProtectMemNames setting', 'INSERT INTO '.sql_table('config')." VALUES ('ProtectMemNames', '1');"); + if (!upgrade_checkIfCVExists('ProtectMemNames')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('ProtectMemNames', '1');"; + upgrade_query("Adding setting ProtectMemNames",$query); + } // create new table: nucleus_plugin_option - $query = 'CREATE TABLE '.sql_table('plugin_option')." (opid int(11) NOT NULL, oname varchar(20) NOT NULL, ovalue varchar(128) not null, odesc varchar(255), otype varchar(8), PRIMARY KEY(opid, oname)) TYPE=MyISAM;"; - upgrade_query("Creating nucleus_plugin_option table",$query); - - + global $upgrade_failures; + if (0==$upgrade_failures && !upgrade_checkIfTableExists('plugin_option')) { + $query = 'CREATE TABLE '.sql_table('plugin_option')." (opid int(11) NOT NULL, oname varchar(20) NOT NULL, ovalue varchar(128) not null, odesc varchar(255), otype varchar(8), PRIMARY KEY(opid, oname)) TYPE=MyISAM;"; + upgrade_query("Creating nucleus_plugin_option table",$query); + }else{ + echo "
Errors occurred during upgrade process."; + } } ?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade2.0.php b/utf8/nucleus/upgrades/upgrade2.0.php index c5e4a9e..f239689 100755 --- a/utf8/nucleus/upgrades/upgrade2.0.php +++ b/utf8/nucleus/upgrades/upgrade2.0.php @@ -7,14 +7,18 @@ function upgrade_do20() { // queries come here // add ikarmaneg - $query = 'ALTER TABLE '.sql_table('item') - . " ADD ikarmaneg int(11) NOT NULL default '0'"; - upgrade_query("Adding ikarmaneg column to items",$query); + if (!upgrade_checkIfColumnExists('item','ikarmaneg')) { + $query = 'ALTER TABLE '.sql_table('item') + . " ADD ikarmaneg int(11) NOT NULL default '0'"; + upgrade_query("Adding ikarmaneg column to items",$query); + } // rename ikarma to ikarmapos - $query = 'ALTER TABLE '.sql_table('item') - . " CHANGE ikarma ikarmapos int(11) NOT NULL default '0'"; - upgrade_query("Renaming ikarma column for items to ikarmapos",$query); + if (!upgrade_checkIfColumnExists('item','ikarmapos')) { + $query = 'ALTER TABLE '.sql_table('item') + . " CHANGE ikarma ikarmapos int(11) NOT NULL default '0'"; + upgrade_query("Renaming ikarma column for items to ikarmapos",$query); + } // drop key in actionlog $query = 'ALTER TABLE '.sql_table('actionlog').' DROP PRIMARY KEY'; @@ -25,44 +29,58 @@ function upgrade_do20() { upgrade_query("changing max email/url length of guest comments to 100",$query); // create default skin option - $skinid = SKIN::getIdFromName('default'); - $query = 'INSERT INTO '.sql_table('config')." VALUES ('BaseSkin', '$skinid');"; - upgrade_query("Adding setting BaseSkin",$query); + if (!upgrade_checkIfCVExists('BaseSkin')) { + $skinid = SKIN::getIdFromName('default'); + $query = 'INSERT INTO '.sql_table('config')." VALUES ('BaseSkin', '$skinid');"; + upgrade_query("Adding setting BaseSkin",$query); + } - // add SkinsURL setting global $CONF; - $skinsurl = str_replace('/media/','/skins/',$CONF['MediaURL']); - $query = 'INSERT INTO '.sql_table('config')." VALUES ('SkinsURL', '".addslashes($skinsurl)."');"; - upgrade_query("Adding setting SkinsURL",$query); + // add SkinsURL setting + if (!upgrade_checkIfCVExists('SkinsURL')) { + $skinsurl = str_replace('/media/','/skins/',$CONF['MediaURL']); + $query = 'INSERT INTO '.sql_table('config')." VALUES ('SkinsURL', '".addslashes($skinsurl)."');"; + upgrade_query("Adding setting SkinsURL",$query); + } // add ActionURL setting - $actionurl = str_replace('/media/','/action.php',$CONF['MediaURL']); - $query = 'INSERT INTO '.sql_table('config')." VALUES ('ActionURL', '".addslashes($actionurl)."');"; - upgrade_query("Adding setting ActionURL",$query); + if (!upgrade_checkIfCVExists('ActionURL')) { + $actionurl = str_replace('/media/','/action.php',$CONF['MediaURL']); + $query = 'INSERT INTO '.sql_table('config')." VALUES ('ActionURL', '".addslashes($actionurl)."');"; + upgrade_query("Adding setting ActionURL",$query); + } // time offset can also be decimal (for half time zones like GMT+3:30) - upgrade_query('Changing time offset column type to decimal','ALTER TABLE '.sql_table('blog')." CHANGE btimeoffset btimeoffset DECIMAL( 3, 1 ) DEFAULT '0' NOT NULL"); - - // add sdincmode and sdincpref to skins - $query = 'ALTER TABLE '.sql_table('skin_desc') - . " ADD sdincmode varchar(10) NOT NULL default 'normal'"; - upgrade_query('Adding IncludeMode property to skins',$query); - $query = 'ALTER TABLE '.sql_table('skin_desc') - . " ADD sdincpref varchar(50) NOT NULL default ''"; - upgrade_query('Adding IncludePrefix property to skins',$query); + $query = 'ALTER TABLE '.sql_table('blog')." CHANGE btimeoffset btimeoffset DECIMAL( 3, 1 ) DEFAULT '0' NOT NULL"; + upgrade_query('Changing time offset column type to decimal',$query); // add ballowpast option to nucleus_blog - $query = 'ALTER TABLE '.sql_table('blog')." ADD ballowpast tinyint(2) NOT NULL default '0'"; - upgrade_query("Adding 'Allow posting to the past' option to blogs",$query); + if (!upgrade_checkIfColumnExists('blog','ballowpast')) { + $query = 'ALTER TABLE '.sql_table('blog')." ADD ballowpast tinyint(2) NOT NULL default '0'"; + upgrade_query("Adding 'Allow posting to the past' option to blogs",$query); + } // URLMode - $query = 'INSERT INTO '.sql_table('config')." VALUES ('URLMode', 'normal');"; - upgrade_query("Adding setting URLMode",$query); + if (!upgrade_checkIfCVExists('URLMode')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('URLMode', 'normal');"; + upgrade_query("Adding setting URLMode",$query); + } // add id to nucleus_plugin_option (allows for ordening) - $query = 'ALTER TABLE '.sql_table('plugin_option').' ADD oid int(11) NOT NULL auto_increment UNIQUE '; - upgrade_query("Adding id attribute to plugin options table",$query); - -} + if (!upgrade_checkIfColumnExists('plugin_option','oid')) { + $query = 'ALTER TABLE '.sql_table('plugin_option').' ADD oid int(11) NOT NULL auto_increment UNIQUE '; + upgrade_query("Adding id attribute to plugin options table",$query); + } + // add sdincmode and sdincpref to skins + global $upgrade_failures; + if (0 == $upgrade_failures && !upgrade_checkIfColumnExists('skin_desc','sdincpref')) { + $query = 'ALTER TABLE '.sql_table('skin_desc') + . " ADD sdincmode varchar(10) NOT NULL default 'normal'," + . " ADD sdincpref varchar(50) NOT NULL default ''"; + upgrade_query('Adding IncludeMode and IncludePrefix properties to skins',$query); + }else{ + echo "
Errors occurred during upgrade process."; + } +} ?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade2.5.php b/utf8/nucleus/upgrades/upgrade2.5.php index 9e4860a..4467f6c 100755 --- a/utf8/nucleus/upgrades/upgrade2.5.php +++ b/utf8/nucleus/upgrades/upgrade2.5.php @@ -1,5 +1,7 @@ opid)."'," - ."'".addslashes($o->oname) ."'," - ."'global'," - ."'".addslashes($o->odesc) ."'," - ."'".addslashes($o->otype) ."')"; - upgrade_query('Moving option description for '.htmlspecialchars($o->oname).' to ' . sql_table('plugin_option_desc'), $query); - - // store new id - $aValues[] = array ( - 'id' => mysql_insert_id(), - 'value' => $o->ovalue - ); - + if (0 == $upgrade_failures){ + $query = 'DELETE FROM ' . sql_table('plugin_option_desc'); + upgrade_query('Flushing plugin option descriptions', $query); + $query = 'SELECT * FROM ' . sql_table('plugin_option') .' ORDER BY oid ASC'; + $res = sql_query($query); + $aValues = array(); + while ($o = mysql_fetch_object($res)) { + $query = 'INSERT INTO ' . sql_table('plugin_option_desc') + .' (opid, oname, ocontext, odesc, otype)' + ." VALUES (" + ."'".addslashes($o->opid)."'," + ."'".addslashes($o->oname) ."'," + ."'global'," + ."'".addslashes($o->odesc) ."'," + ."'".addslashes($o->otype) ."')"; + upgrade_query('Moving option description for '.htmlspecialchars($o->oname).' to ' . sql_table('plugin_option_desc'), $query); + + // store new id + $aValues[] = array ( + 'id' => mysql_insert_id(), + 'value' => $o->ovalue + ); + } } // 3. alter plugin_options table - $query = 'ALTER TABLE ' . sql_table('plugin_option') - .' DROP PRIMARY KEY,' - .' DROP KEY oid,' - .' DROP COLUMN opid,' - .' DROP COLUMN oname,' - .' DROP COLUMN odesc,' - .' DROP COLUMN otype,' - .' ADD ocontextid INT(11) NOT NULL,' - .' ADD PRIMARY KEY (oid, ocontextid)'; - upgrade_query('Altering ' . sql_table('plugin_option') . ' table', $query); - - // 4. delete from plugin_options - $query = 'DELETE FROM ' . sql_table('plugin_option'); - upgrade_query('Cleaning ' . sql_table('plugin_option'), $query); - - // 5. refill plugin_options - foreach ($aValues as $aInfo) { - $query = 'INSERT INTO ' . sql_table('plugin_option') - .' (oid, ocontextid, ovalue)' - ." VALUES (".$aInfo['id'].",'0','".addslashes($aInfo['value'])."')"; - upgrade_query('Re-filling ' . sql_table('plugin_option') . ' ('.$aInfo['id'].')', $query); - } + if (0 == $upgrade_failures && !upgrade_checkIfColumnExists('plugin_option','ocontextid')) { + $query = 'ALTER TABLE ' . sql_table('plugin_option') + .' DROP PRIMARY KEY,' + .' DROP KEY oid,' + .' DROP COLUMN opid,' + .' DROP COLUMN oname,' + .' DROP COLUMN odesc,' + .' DROP COLUMN otype,' + .' ADD ocontextid INT(11) NOT NULL,' + .' ADD PRIMARY KEY (oid, ocontextid)'; + upgrade_query('Altering ' . sql_table('plugin_option') . ' table', $query); + + if(0 == $upgrade_failures){ + // 4. delete from plugin_options + $query = 'DELETE FROM ' . sql_table('plugin_option'); + upgrade_query('Cleaning ' . sql_table('plugin_option'), $query); + + // 5. refill plugin_options + foreach ($aValues as $aInfo) { + $query = 'INSERT INTO ' . sql_table('plugin_option') + .' (oid, ocontextid, ovalue)' + ." VALUES (".$aInfo['id'].",'0','".addslashes($aInfo['value'])."')"; + upgrade_query('Re-filling ' . sql_table('plugin_option') . ' ('.$aInfo['id'].')', $query); + } + } + } } // -------------------- 2.0 -> 2.5 -------------------- @@ -95,13 +106,20 @@ function upgrade_do25() { $query = 'ALTER TABLE ' . sql_table('plugin_option') . ' MODIFY ovalue TEXT NOT NULL default \'\''; upgrade_query('Modifying plugin options column type', $query); - // insert database version (allows us to do better version checking in v3.0 upgrades) - $query = 'INSERT INTO ' . sql_table('config') . ' (name,value) VALUES (\'DatabaseVersion\',\'250\')'; - upgrade_query('Adding DatabaseVersion to config table', $query); - // insert External Authentication global option - $query = 'INSERT INTO ' . sql_table('config') . ' (name,value) VALUES (\'ExtAuth\',\'0\')'; - upgrade_query('Adding External Authentication option to config table', $query); + if (!upgrade_checkIfCVExists('ExtAuth')) { + $query = 'INSERT INTO ' . sql_table('config') . ' (name,value) VALUES (\'ExtAuth\',\'0\')'; + upgrade_query('Adding External Authentication option to config table', $query); + } + + // insert database version (allows us to do better version checking in v3.0 upgrades) + // But only if no errors in upgrade + if (0 == $upgrade_failures && !upgrade_checkIfCVExists('DatabaseVersion')) { + $query = 'INSERT INTO ' . sql_table('config') . ' (name,value) VALUES (\'DatabaseVersion\',\'250\')'; + upgrade_query('Adding DatabaseVersion to config table', $query); + }else{ + echo "
Errors occurred during upgrade process."; + } } -?> +?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade3.0.php b/utf8/nucleus/upgrades/upgrade3.0.php index d4126a2..b8846a3 100755 --- a/utf8/nucleus/upgrades/upgrade3.0.php +++ b/utf8/nucleus/upgrades/upgrade3.0.php @@ -6,10 +6,8 @@ function upgrade_do30() { // 2.5(beta/RC/...) -> 3.0 // update database version - $query = 'UPDATE ' . sql_table('config') . ' set value=\'300\' where name=\'DatabaseVersion\''; - upgrade_query('Updating DatabaseVersion in config table to 300', $query); - + update_version('300'); // nothing! } -?> +?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade3.1.php b/utf8/nucleus/upgrades/upgrade3.1.php index 828b575..f42642f 100755 --- a/utf8/nucleus/upgrades/upgrade3.1.php +++ b/utf8/nucleus/upgrades/upgrade3.1.php @@ -6,10 +6,8 @@ function upgrade_do31() { // 3.0 -> 3.1 // update database version - $query = 'UPDATE ' . sql_table('config') . ' set value=\'310\' where name=\'DatabaseVersion\''; - upgrade_query('Updating DatabaseVersion in config table to 310', $query); - + update_version('310'); // nothing! } -?> +?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade3.2.php b/utf8/nucleus/upgrades/upgrade3.2.php index 27ebf94..aa029ee 100755 --- a/utf8/nucleus/upgrades/upgrade3.2.php +++ b/utf8/nucleus/upgrades/upgrade3.2.php @@ -4,53 +4,41 @@ function upgrade_do32() { if (upgrade_checkinstall(32)) return 'already installed'; - // The version number of 3.20 and 3.21 are wrong, - // so this upgrade function will be called. - // But database already exists, should update db version only. - $query = 'SELECT * FROM ' . sql_table('activation'); - $res = mysql_query($query); - $installed = ($res != 0) && (mysql_num_rows($res) >= 0); - if ($installed) - { - // 3.1 -> 3.1+ - // update database version - $query = 'UPDATE ' . sql_table('config') . ' set value=\'323\' where name=\'DatabaseVersion\''; - upgrade_query('Updating DatabaseVersion in config table to 323', $query); - - return; - } - - // create nucleus_activation table - $query = 'CREATE TABLE ' . sql_table('activation') . ' (' - . ' vkey varchar(40) NOT NULL default \'\',' - . ' vtime datetime NOT NULL default \'0000-00-00 00:00:00\',' - . ' vmember int(11) NOT NULL default \'0\',' - . ' vtype varchar(15) NOT NULL default \'\',' - . ' vextra varchar(128) NOT NULL default \'\',' - . ' PRIMARY KEY (vkey) ' - . ' )'; - upgrade_query('Creating account activation table', $query); - + if (!upgrade_checkIfTableExists('tickets')) { + $query = 'CREATE TABLE ' . sql_table('activation') . ' (' + . ' vkey varchar(40) NOT NULL default \'\',' + . ' vtime datetime NOT NULL default \'0000-00-00 00:00:00\',' + . ' vmember int(11) NOT NULL default \'0\',' + . ' vtype varchar(15) NOT NULL default \'\',' + . ' vextra varchar(128) NOT NULL default \'\',' + . ' PRIMARY KEY (vkey) ' + . ' )'; + upgrade_query('Creating account activation table', $query); + } + // create CookiePrefix setting - $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookiePrefix','')"; - upgrade_query('Creating CookiePrefix config value',$query); - - // create nucleus_tickets table - $query = 'CREATE TABLE ' . sql_table('tickets') . ' (' - . ' ticket varchar(40) NOT NULL default \'\',' - . ' ctime datetime NOT NULL default \'0000-00-00 00:00:00\',' - . ' member int(11) NOT NULL default \'0\', ' - . ' PRIMARY KEY (ticket, member) ' - . ' )'; - upgrade_query('Creating ticket table', $query); + if (!upgrade_checkIfCVExists('CookiePrefix')) { + $query = 'INSERT INTO '.sql_table('config')." VALUES ('CookiePrefix','')"; + upgrade_query('Creating CookiePrefix config value',$query); + } - // 3.1 -> 3.1+ + // create nucleus_tickets table + if (!upgrade_checkIfTableExists('tickets')) { + $query = 'CREATE TABLE ' . sql_table('tickets') . ' (' + . ' ticket varchar(40) NOT NULL default \'\',' + . ' ctime datetime NOT NULL default \'0000-00-00 00:00:00\',' + . ' member int(11) NOT NULL default \'0\', ' + . ' PRIMARY KEY (ticket, member) ' + . ' )'; + upgrade_query('Creating ticket table', $query); + } + + // 3.1 -> 3.2 // update database version - $query = 'UPDATE ' . sql_table('config') . ' set value=\'323\' where name=\'DatabaseVersion\''; - upgrade_query('Updating DatabaseVersion in config table to 323', $query); + update_version('320'); // nothing! } -?> +?> \ No newline at end of file diff --git a/utf8/nucleus/upgrades/upgrade3.3.php b/utf8/nucleus/upgrades/upgrade3.3.php index 5385dc7..3be5dd5 100644 --- a/utf8/nucleus/upgrades/upgrade3.3.php +++ b/utf8/nucleus/upgrades/upgrade3.3.php @@ -4,55 +4,38 @@ function upgrade_do33() { if (upgrade_checkinstall(33)) return 'already installed'; - // alter nucleus_blog table - $query = 'ALTER TABLE ' . sql_table('blog') - . ' ADD breqemail TINYINT(2) DEFAULT \'0\' NOT NULL'; - upgrade_query('Altering ' . sql_table('blog') . ' table', $query); - - // insert breqemail default value - $query = 'UPDATE ' . sql_table('blog') - . ' SET breqemail=0'; - upgrade_query('Filling breqemail column of ' . sql_table('blog') . ' table', $query); - - // store cname from nucleus_category - $query = 'SELECT catid, cname FROM ' . sql_table('category') . ' ORDER By catid ASC'; - $res = sql_query($query); - $aValues = array(); - while ($o = mysql_fetch_object($res)) { - $aValues[] = array( - 'catid' => $o->catid, - 'cname' => $o->cname - ); + if (!upgrade_checkIfColumnExists('comment','cemail')) { + $query = " ALTER TABLE `" . sql_table('comment') . "` + ADD `cemail` VARCHAR( 100 ) AFTER `cmail` ;"; + + upgrade_query('Altering ' . sql_table('comment') . ' table', $query); } - // alter nucleus_category - $query = 'ALTER TABLE ' . sql_table('category') - . ' DROP COLUMN cname,' - . ' ADD cname varchar(200) default NULL AFTER cblog'; - upgrade_query('Altering ' . sql_table('category') . ' table', $query); - - // refill cname to nucleus_category - foreach ($aValues as $aInfo) { - $query = 'UPDATE ' . sql_table('category') - . ' SET cname=' - . " '" . addslashes($aInfo['cname']) . "'" - . " WHERE catid=" . $aInfo['catid']; - upgrade_query('Re-filling ' . sql_table('category') - . ' (' . $aInfo['catid'] . ')', $query); + if (!upgrade_checkIfColumnExists('blog','breqemail')) { + $query = " ALTER TABLE `" . sql_table('blog') . "` + ADD `breqemail` TINYINT( 2 ) DEFAULT '0' NOT NULL ;"; + + upgrade_query('Altering ' . sql_table('blog') . ' table', $query); + } + + if (!upgrade_checkIfColumnExists('item','posted')) { + $query = " ALTER TABLE `" . sql_table('item') . "` + ADD `iposted` TINYINT(2) DEFAULT 1 NOT NULL ;"; + + upgrade_query('Altering ' . sql_table('item') . ' table', $query); } - // alter nucleus_comment - $query = 'ALTER TABLE ' . sql_table('comment') - . ' ADD cemail varchar(100)' - . ' AFTER cmail'; - upgrade_query('Altering ' . sql_table('comment') . ' table', $query); - - // 3.2 -> 3.2+ - // update database version - $query = 'UPDATE ' . sql_table('config') . ' set value=\'330\' where name=\'DatabaseVersion\''; - upgrade_query('Updating DatabaseVersion in config table to 330', $query); - - // nothing! + if (!upgrade_checkIfColumnExists('blog','bfuturepost')) { + $query = " ALTER TABLE `" . sql_table('blog') . "` + ADD `bfuturepost` TINYINT(2) DEFAULT 0 NOT NULL ;"; + + upgrade_query('Altering ' . sql_table('blog') . ' table', $query); + } + + // 3.2 -> 3.3 + // update database version + update_version('330'); + } ?> -- 2.11.0