OSDN Git Service

MERGE: revision 1685 and 1690 from original repository
authorsakamocchi <o-takashi@sakamocchi.jp>
Sat, 10 Mar 2012 11:32:12 +0000 (20:32 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sat, 10 Mar 2012 11:32:12 +0000 (20:32 +0900)
Revision 1685:FIX: some easy bugs.
http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1685

Revision 1690: Work in upgrades folder to prepare for 4.0. I realize
it is being reworked, but wanted to keep this current version
up-to-date.
http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1690

nucleus/upgrades/index.php
nucleus/upgrades/upgrade.functions.php
nucleus/upgrades/upgrade.php
nucleus/upgrades/upgrade2.5.php
nucleus/upgrades/upgrade4.0.php

index f1d2318..74720cc 100644 (file)
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: index.php 1678 2012-02-26 07:31:36Z sakamocchi $
+ * @version $Id: index.php 1690 2012-03-08 22:45:08Z ftruscot $
  *
  */
 
-include('./upgrade.functions.php');
-
-// begin if: make sure user is logged in
-if ( !$member->isLoggedIn() )
-{
-       upgrade_showLogin('index.php');
-}
-
-// begin if: make sure user is an admin
-if ( !$member->isAdmin() )
-{
-       upgrade_error('Only super administrators are allowed to perform upgrades');
-}
-
-upgrade_head();
-
-echo "<h1>Upgrade Nucleus</h1>\n";
-echo "<div class=\"note\">\n";
-echo "<p><strong>Note:</strong> If you just installed Nucleus for the first time and are not upgrading from an earlier version, you will not need these files.</p>\n";
-echo "</div>\n";
-echo "<p>Database updates may be required when upgrading from an earlier version of Nucleus. This tool allows you to automate these updates.</p>\n";
-
-// calculate current version
-if ( !upgrade_checkinstall(96) )
-{
-       $current = 95;
-}
-else if ( !upgrade_checkinstall(100) )
-{
-       $current = 96;
-}
-else if ( !upgrade_checkinstall(110) )
-{
-       $current = 100;
-}
-else if ( !upgrade_checkinstall(150) )
-{
-       $current = 110;
-}
-else if ( !upgrade_checkinstall(200) )
-{
-       $current = 150;
-}
-else if ( !upgrade_checkinstall(250) )
-{
-       $current = 200;
-}
-else if ( !upgrade_checkinstall(300) )
-{
-       $current = 250;
-}
-else if ( !upgrade_checkinstall(310) )
-{
-       $current = 300;
-}
-else if ( !upgrade_checkinstall(320) )
-{
-       $current = 310;
-}
-else if ( !upgrade_checkinstall(330) )
-{
-       $current = 320;
-}
-else if ( !upgrade_checkinstall(340) )
-{
-       $current = 330;
-}
-else if ( !upgrade_checkinstall(350) )
-{
-       $current = 340;
-}
-else if ( !upgrade_checkinstall(360) )
-{
-       $current = 350;
-}
-else if ( !upgrade_checkinstall(400)  )
-{
-       $current = 360;
-}
-else
-{
-       $current = 400;
-}
-
-if ( $current == 400 )
-{
-       echo "<p class=\"ok\"> No database updates required! The database has already been updated to the latest version of Nucleus.</p>\n";
-}
-else
-{
-       echo "<p class=\"warning\"><a href=\"upgrade.php?from={$current}\">Click here to upgrade the database to Nucleus v3.6</a>.</p>\n";
-}
-
-echo "<div class=\"note\">\n";
-echo "<p><strong>Note:</strong> It is strongly recommended that you create a database backup <em>before</em> performing upgrades. </p>\n";
-echo "</div>\n";
-
-echo "<h1>Manual Updates</h1>\n";
-echo "<p>Some updates need to be performed manually. Instructions are given below (if any).</p>\n";
-
-$from = intGetVar('from');
-
-if ( !$from )
-{
-       $from = $current;
-}
-
-$sth = 0;
-
-if ( !$DIR_MEDIA )
-{
-       upgrade_manual_96();
-       $sth = 1;
-}
-
-if ( !$DIR_SKINS )
-{
-       upgrade_manual_200();
-       $sth = 1;
-}
-
-// upgrades from pre-340 version need to be told of recommended .htaccess files for the media and skins folders. these .htaccess files are included in new installs of 340 or higher
-if ( in_array($from, array(95, 96)) || $from < 340 )
-{
-       upgrade_manual_340();
-       $sth = 1;
-}
-
-// upgrades from pre-350 version need to be told of deprecation of PHP4 support and two new plugins included with 3.5 and higher
-if ( in_array($from, array(95, 96)) || $from < 350 )
-{
-       upgrade_manual_350();
-       $sth = 1;
-}
-
-if ( $sth == 0 )
-{
-       echo "<p class=\"ok\"> No manual changes needed. This must be your lucky day! </p>\n";
-}
-
-upgrade_foot();
+       include('upgrade.functions.php');
 
-/**
- * 
- * @param int $version
- */
-function upgrade_todo($version)
-{
-       return upgrade_checkinstall($version) ? "(<span class='ok'>installed</span>)" : "(<span class='warning'>not yet installed</span>)";
-}
+       // begin if: make sure user is logged in
+       if ( !$member->isLoggedIn() )
+       {
+               upgrade_showLogin('index.php');
+       } // end if
 
-/**
- * Manual update instructions for version 0.96
- */
-function upgrade_manual_96()
-{
-       global $DIR_NUCLEUS;
-       
-       $guess = str_replace('/nucleus/', '/media/', $DIR_NUCLEUS);
-       echo "<h2>Changes needed for Nucleus 0.96</h2>\n";
-       echo "<p>A manual addition needs to be made to <em>config.php</em>, in order to get the media functions to work. Here's what to add:</p>\n";
-       echo "<pre>\n";
-       echo "// path to media dir\n";
-       echo "$DIR_MEDIA = '<strong><?php echo i18n;;hsc($guess)?></strong>';\n";
-       echo "</pre>\n";
-       echo "<p>Also, it will be necessary to create that directory yourself. If you want to make file upload possible, you should set the permissions of the media/ directory to 777 (see the documentation/tips.html in Nucleus 0.96+ for a quick guide on setting permissions).</p>\n";
-       return;
-}
+       // begin if: make sure user is an admin
+       if ( !$member->isAdmin() )
+       {
+               upgrade_error('Only super administrators are allowed to perform upgrades');
+       } // end if
 
-/**
- * Manual update instructions for version 2.0 and before
- */
-function upgrade_manual_200()
-{
-       global $DIR_NUCLEUS;
-       
-       $guess = str_replace("/nucleus/", "/skins/", $DIR_NUCLEUS);
-       
-       echo "<h2>Changes needed for Nucleus 2.0</h2>\n";
-       echo "<p> A manual addition needs to be made to <i>config.php</i>, in order to get imported skins to work correctly. Here's what to add: </p>\n";
-       echo "<pre>\n";
-       echo "// extra skin files for imported skins\n";
-       echo "$DIR_SKINS = '<strong>" . i18n::hsc($guess) . "</strong>';\n";
-       echo "</pre>\n";
-       echo "<p> Also, it will be necessary to create this directory yourself. Downloaded skins can then be expanded into that directory and be imported from inside the Nucleus admin area. </p>\n";
-       
-       echo "<h3> RSS 2.0 and RSD skin </h3>\n";
-       echo "<p> When a fresh version of Nucleus 2.0 is installed, an RSS 2.0 (Really Simple Syndication) syndication skin is also installed, as well as an RSD skin (Really Simple Discovery). The files <code>xml-rss2.php</code> and <code>rsd.php</code> are available in the upgrade, however the skin itself needs to be installed manually. After you've uploaded the contents of the <code>upgrade-files</code>, open <code>admin area &gt; nucleus management &gt; skin import</code>. From there, you can install both skins. (Unless you don't want them installed, that is) </p>\n";
-       return;
-}
+       upgrade_head();
+?>
 
-/**
- * Manual update instructions for version 3.4 and before
- */
-function upgrade_manual_340()
-{
-       global $DIR_NUCLEUS;
-       echo "<h2> Changes needed for Nucleus 3.4 </h2>\n";
-       echo "<p> It is recommended that you apply some restrictions to what you allow the web server to do with files in the <i>media</i> and <i>skins</i> folders. These restrictions are not necessary to the functioning of the software, nor to the security of the software. However, they can be an important help under the security principle of denying any access that is not required. </p>\n";
-       
-       echo "<p> Instructions for applying the restrictions are found in the following two files on your server: </p>\n";
-       echo "<ul>\n";
-       echo "<li><a href=\"../../extra/media/readme.txt\">extra/media/readme.txt</a></li>\n";
-       echo "<li><a href=\"../../extra/skins/readme.txt\">extra/skins/readme.txt</a></li>\n";
-       echo "</ul>\n";
-       
-       return;
-}
+       <h1> Upgrade Nucleus </h1>
 
-/**
- * Manual update instructions for version 3.5 and before
- */
-function upgrade_manual_350()
-{
-       global $DIR_NUCLEUS;
-       echo "<h2>Important Notices for Nucleus 3.5</h2>\n";
+       <div class="note">
+               <p> <strong>Note:</strong> If you just installed Nucleus for the first time and are not upgrading from an earlier version, you will not need these files. </p>
+       </div>
+
+       <p> Database updates may be required when upgrading from an earlier version of Nucleus. This tool allows you to automate these updates. </p>
+
+<?php
+       // calculate current version
+       if ( !upgrade_checkinstall(96) )
+       {
+               $current = 95;
+       }
+       else if ( !upgrade_checkinstall(100) )
+       {
+               $current = 96;
+       }
+       else if ( !upgrade_checkinstall(110) )
+       {
+               $current = 100;
+       }
+       else if ( !upgrade_checkinstall(150) )
+       {
+               $current = 110;
+       }
+       else if ( !upgrade_checkinstall(200) )
+       {
+               $current = 150;
+       }
+       else if ( !upgrade_checkinstall(250) )
+       {
+               $current = 200;
+       }
+       else if ( !upgrade_checkinstall(300) )
+       {
+               $current = 250;
+       }
+       else if ( !upgrade_checkinstall(310) )
+       {
+               $current = 300;
+       }
+       else if ( !upgrade_checkinstall(320) )
+       {
+               $current = 310;
+       }
+       else if ( !upgrade_checkinstall(330) )
+       {
+               $current = 320;
+       }
+       else if ( !upgrade_checkinstall(340) )
+       {
+               $current = 330;
+       }
+       else if ( !upgrade_checkinstall(350) )
+       {
+               $current = 340;
+       }
+       else if ( !upgrade_checkinstall(360) )
+       {
+               $current = 350;
+       }
+       else if ( !upgrade_checkinstall(400)  )
+       {
+               $current = 360;
+       }
+       else
+       {
+               $current = 400;
+       }
        
+       if ( $current == 400 )
+       {
+?>
+       <p class="ok"> No database updates required! The database has already been updated to the latest version of Nucleus. </p>
+<?php
+       }
+       else
+       {
+?>
+       <p class="warning"> <a href="upgrade.php?from=<?php echo $current?>">Click here to upgrade the database to Nucleus v4.0</a>. </p>
+<?php
+       }
+?>
+
+       <div class="note">
+               <p> <strong>Note:</strong> It is strongly recommended that you create a database backup <em>before</em> performing upgrades. </p>
+       </div>
+
+       <h1> Manual Updates </h1>
+       <p> Some updates need to be performed manually. Instructions are given below (if any). </p>
+
+<?php
+       $from = intGetVar('from');
+
+       if ( !$from )
+       {
+               $from = $current;
+       }
+
+       $sth = 0;
+
+       if ( !$DIR_MEDIA )
+       {
+               upgrade_manual_96();
+               $sth = 1;
+       }
+
+       if ( !$DIR_SKINS )
+       {
+               upgrade_manual_200();
+               $sth = 1;
+       }
+
+       // upgrades from pre-340 version need to be told of recommended .htaccess files for the media and skins folders. these .htaccess files are included in new installs of 340 or higher
+       if ( in_array($from, array(95, 96)) || $from < 340 )
+       {
+               upgrade_manual_340();
+               $sth = 1;
+       }
+
+       // upgrades from pre-350 version need to be told of deprecation of PHP4 support and two new plugins included with 3.5 and higher
+       if ( in_array($from, array(95, 96)) || $from < 350 )
+       {
+               upgrade_manual_350();
+               $sth = 1;
+       }
+
+       // upgrades from pre-400 version need to be warned of possible plugin incompatibility in general and specifically where known.
+       // may also need to do some things for db encoding?
+       if ( in_array($from, array(95, 96)) || $from < 400 )
+       {
+               upgrade_manual_400();
+               $sth = 1;
+       }
+
+
+       if ( $sth == 0 )
+       {
+               echo '<p class="ok"> No manual changes needed. This must be your lucky day! </p>';
+       }
+
+       upgrade_foot();
+
+
+       /**
+        * 
+        * @param int $version
+        */
+       function upgrade_todo($version)
+       {
+               return upgrade_checkinstall($version) ? "(<span class='ok'>installed</span>)" : "(<span class='warning'>not yet installed</span>)";
+       }
+
+
+       /**
+        * Manual update instructions for version 0.96
+        */
+       function upgrade_manual_96()
+       {
+               global $DIR_NUCLEUS;
+
+               $guess = str_replace('/nucleus/', '/media/', $DIR_NUCLEUS);
+?>
+       <h2> Changes needed for Nucleus 0.96 </h2>
+       <p> A manual addition needs to be made to <em>config.php</em>, in order to get the media functions to work. Here's what to add: </p>
+       <pre>
+       // path to media dir
+       $DIR_MEDIA = '<strong><?php echo i18n;;hsc($guess)?></strong>';
+       </pre>
+
+       <p> Also, it will be necessary to create that directory yourself. If you want to make file upload possible, you should set the permissions of the media/ directory to 777 (see the documentation/tips.html in Nucleus 0.96+ for a quick guide on setting permissions). </p>
+
+<?php
+       } // end function upgrade_manual_96()
+
+
+       /**
+        * Manual update instructions for version 2.0 and before
+        */
+       function upgrade_manual_200()
+       {
+               global $DIR_NUCLEUS;
+
+               $guess = str_replace("/nucleus/", "/skins/", $DIR_NUCLEUS);
+?>
+       <h2> Changes needed for Nucleus 2.0 </h2>
+       <p> A manual addition needs to be made to <i>config.php</i>, in order to get imported skins to work correctly. Here's what to add: </p>
+       <pre>
+       // extra skin files for imported skins
+       $DIR_SKINS = '<strong><?php echo i18n;;hsc($guess)?></strong>';
+       </pre>
+
+       <p> Also, it will be necessary to create this directory yourself. Downloaded skins can then be expanded into that directory and be imported from inside the Nucleus admin area. </p>
+
+       <h3> RSS 2.0 and RSD skin </h3>
+
+       <p> When a fresh version of Nucleus 2.0 is installed, an RSS 2.0 (Really Simple Syndication) syndication skin is also installed, as well as an RSD skin (Really Simple Discovery). The files <code>xml-rss2.php</code> and <code>rsd.php</code> are available in the upgrade, however the skin itself needs to be installed manually. After you've uploaded the contents of the <code>upgrade-files</code>, open <code>admin area &gt; nucleus management &gt; skin import</code>. From there, you can install both skins. (Unless you don't want them installed, that is) </p>
+
+<?php
+       } // end function upgrade_manual_200()
+
+
+       /**
+        * Manual update instructions for version 3.4 and before
+        */
+       function upgrade_manual_340()
+       {
+               global $DIR_NUCLEUS;
+?>
+       <h2> Changes needed for Nucleus 3.4 </h2>
+       <p> It is recommended that you apply some restrictions to what you allow the web server to do with files in the <i>media</i> and <i>skins</i> folders. These restrictions are not necessary to the functioning of the software, nor to the security of the software. However, they can be an important help under the security principle of denying any access that is not required. </p>
+
+       <p> Instructions for applying the restrictions are found in the following two files on your server: </p>
+       <ul>
+               <li> <a href="../../extra/media/readme.txt">extra/media/readme.txt</a> </li>
+               <li> <a href="../../extra/skins/readme.txt">extra/skins/readme.txt</a> </li>
+       </ul>
+
+<?php
+       } // end function upgrade_manual_340()
+
+
+       /**
+        * Manual update instructions for version 3.5 and before
+        */
+       function upgrade_manual_350()
+       {
+               global $DIR_NUCLEUS;
+?>
+       <h2> Important Notices for Nucleus 3.5 </h2>
+
+<?php
+       // Give user warning if they are running old version of PHP
+       if ( phpversion() < '5' )
+       {
+               echo '<p> WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5! </p>';
+       }
+?>
+
+       <p> Two new plugins have been included with version 3.5. You may want to consider installing them from the Plugins page of the admin area. </p>
+       <ul>
+               <li> <strong>NP_Text</strong>: Allows you to use internationalized skins to simplify translation. </li>
+               <li> <strong>NP_SecurityEnforcer</strong>: Enforces some security properties like password complexity and maximum failed login attempts. Note that it is disabled by default and must be enabled after installation. </li>
+       </ul>
+
+<?php
+       } // end function upgrade_manual_350()
+
+
+       /**
+        * Manual update instructions for version 4.0 and before
+        */
+       function upgrade_manual_400()
+       {
+               global $DIR_NUCLEUS, $manager;
+?>
+       <h2> Important Notices for Nucleus 4.0 </h2>
+
+<?php
        // Give user warning if they are running old version of PHP
        if ( phpversion() < '5' )
        {
                echo '<p> WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5! </p>';
        }
        
-       echo "<p> Two new plugins have been included with version 3.5. You may want to consider installing them from the Plugins page of the admin area. </p>\n";
-       echo "<ul>\n";
-       echo "<li> <strong>NP_Text</strong>: Allows you to use internationalized skins to simplify translation. </li>\n";
-       echo "<li> <strong>NP_SecurityEnforcer</strong>: Enforces some security properties like password complexity and maximum failed login attempts. Note that it is disabled by default and must be enabled after installation. </li>\n";
-       echo "</ul>\n";
-}
+       // find if any of the known plugin incompatibilities are installed.
+       $pluginsToCheck = array(
+                                                       array("NP_ShowComments","Not installed","1.30"),
+                                                       array("NP_MultiLanguage","Not installed","1.10")
+                                               );
+       foreach ( $pluginsToCheck as $plug )
+       {
+               if ( $manager->pluginInstalled($plug[0]) )
+               {
+                       $plug[1] = $manager->getPlugin($plug[0])->getVersion();
+               }
+       }
+?>
+
+       <p> Nucleus CMS 4.0 represents a lot of fundamental code changes behind the scenes to make use of PHP5 features, to establish a single multi-byte code base, and to generally improve some of the structure to comply with contempary coding standards.
+           As such, despite the best efforts of the development team to maintain backward compatibility with plugins, there are areas where compatibility could not be maintained due to the nature of the 3rd-party plugin system. 
+               The following table shows the list of known plugin incompatibilities, please review it and upgrade your plugins as needed. If you experience compatibility issues with any plugins, 
+               please request help at our <a href="http://forum.nucleuscms.org">support forum</a>.</p>
+       <table>
+       <tr><th>Plugin Name</th><th>Installed Version</th><th>4.0-compatible version</th></tr>
+<?php
+       foreach ( $pluginsToCheck as $plug )
+       {
+               echo '<tr><td>'.$plug[0].'</td><td>'.$plug[1].'</td><td>'.$plug[2].'</td></tr>';
+       }
+?>
+       </table>
+
+<?php
+       } // end function upgrade_manual_350()
index fa1c2a6..d91c859 100644 (file)
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: upgrade.functions.php 1592 2011-10-29 22:24:24Z gregorlove $
+ * @version $Id: upgrade.functions.php 1690 2012-03-08 22:45:08Z ftruscot $
  */
 
-/*************************************************************
- *     NOTE: With upgrade to 3.6, need to set this to use sql_* API
**************************************************************/
+       /**
+        * Some functions common to all upgrade scripts
       */
 
-include('../../config.php');
+       /*************************************************************
+        *     NOTE: With upgrade to 3.6, need to set this to use sql_* API
+        **************************************************************/
 
-// sql_table function did not exists in nucleus <= 2.0
-if ( !function_exists('sql_table') )
-{
-       function sql_table($name)
+       include('../../config.php');
+
+       // sql_table function did not exists in nucleus <= 2.0
+       if ( !function_exists('sql_table') )
        {
-               return 'nucleus_' . $name;
+               function sql_table($name)
+               {
+                       return 'nucleus_' . $name;
+               }
        }
-}
 
-//intGetVar did not exist in very early versions
-if ( !function_exists('intGetVar') )
-{
-       function intGetVar($name)
+       //intGetVar did not exist in very early versions
+       if ( !function_exists('intGetVar') )
        {
-               if ( defined($_GET) )
+               function intGetVar($name)
                {
-                       return intval($_GET[$name]);
+                       if ( defined($_GET) )
+                       {
+                               return intval($_GET[$name]);
+                       }
+                       else
+                       {
+                               global $HTTP_GET_VARS;
+                               return intval($HTTP_GET_VARS[$name]);
+                       }
                }
-               else
+       }
+
+
+       function upgrade_checkinstall($version)
+       {
+               $installed = 0;
+
+               switch( $version )
                {
-                       global $HTTP_GET_VARS;
-                       return intval($HTTP_GET_VARS[$name]);
+                       case '95':
+                               $query = 'SELECT bconvertbreaks FROM ' . sql_table('blog') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       case '96':
+                               $query = 'SELECT cip FROM ' . sql_table('comment') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       case '100':
+                               $query = 'SELECT mcookiekey FROM ' . sql_table('member') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       case '110':
+                               $query = 'SELECT bnotifytype FROM ' . sql_table('blog') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       case '150':
+                               $query = 'SELECT * FROM ' . sql_table('plugin_option') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       case '200':
+                               $query = 'SELECT sdincpref FROM ' . sql_table('skin_desc') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       // dev only (v2.2)
+                       case '220':
+                               $query = 'SELECT oid FROM ' . sql_table('plugin_option_desc') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       // v2.5 beta
+                       case '240':
+                               $query = 'SELECT bincludesearch FROM ' . sql_table('blog') . ' LIMIT 1';
+                               $minrows = -1;
+                       break;
+
+                       case '250':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 250 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '300':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 300 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '310':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 310 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '320':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 320 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '330':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 330 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '340':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 340 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '350':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 350 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '360':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 360 LIMIT 1';
+                               $minrows = 1;
+                       break;
+
+                       case '400':
+                               $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 400 LIMIT 1';
+                               $minrows = 1;
+                       break;
                }
+
+               $result = mysql_query($query);
+               $installed = ( $result != 0 ) && (mysql_num_rows($result) >= $minrows);
+
+               return $installed;
        }
-}
 
-function upgrade_checkinstall($version)
-{
-       $installed = 0;
-       
-       switch( $version )
+
+       /**
+        * Get the Nucleus version. If getNucleusVersion() doesn't exist, default to version 0.96
+        * @return int
+        */
+       function upgrade_getNucleusVersion()
        {
-               case '95':
-                       $query = 'SELECT bconvertbreaks FROM ' . sql_table('blog') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               case '96':
-                       $query = 'SELECT cip FROM ' . sql_table('comment') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               case '100':
-                       $query = 'SELECT mcookiekey FROM ' . sql_table('member') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               case '110':
-                       $query = 'SELECT bnotifytype FROM ' . sql_table('blog') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               case '150':
-                       $query = 'SELECT * FROM ' . sql_table('plugin_option') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               case '200':
-                       $query = 'SELECT sdincpref FROM ' . sql_table('skin_desc') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               // dev only (v2.2)
-               case '220':
-                       $query = 'SELECT oid FROM ' . sql_table('plugin_option_desc') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               // v2.5 beta
-               case '240':
-                       $query = 'SELECT bincludesearch FROM ' . sql_table('blog') . ' LIMIT 1';
-                       $minrows = -1;
-               break;
-               
-               case '250':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 250 LIMIT 1';
-                       $minrows = 1;
-               break;
-               
-               case '300':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 300 LIMIT 1';
-                       $minrows = 1;
-               break;
-               
-               case '310':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 310 LIMIT 1';
-                       $minrows = 1;
-               break;
-               
-               case '320':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 320 LIMIT 1';
-                       $minrows = 1;
-               break;
-               
-               case '330':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 330 LIMIT 1';
-                       $minrows = 1;
-               break;
-               
-               case '340':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 340 LIMIT 1';
-                       $minrows = 1;
-               break;
-               
-               case '350':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 350 LIMIT 1';
-                       $minrows = 1;
-               break;
+               if ( !function_exists('getNucleusVersion') )
+               {
+                       return 96;
+               }
+
+               return getNucleusVersion();
+       }
+
+       /**
+        * Show the login form
+        * @param string $action
+        */
+       function upgrade_showLogin($action)
+       {
+               upgrade_head();
                
-               case '360':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 360 LIMIT 1';
-                       $minrows = 1;
-               break;
+               echo "<h1> Log In </h1>\n";
+               echo "<p>Please enter your login name and password. </p>\n";
+       
+               echo "<form method=\"POST\" action=\"{$action}\">\n";
+               echo "<ul>\n";
+               echo "<li><label for=\"i_login\">Name:</label> <input type=\"text\" name=\"login\" id=\"i_login\" size=\"20\" /></li>\n";
+               echo "<li><label for=\"i_password\">Password:</label> <input type=\"password\" name=\"password\" id=\"i_password\" size=\"20\" /></li>\n";
+               echo "</ul>\n";
+               echo "<p><input type=\"submit\" value=\"Log In\" /></p>\n";
+               echo "<input name=\"action\" value=\"login\" type=\"hidden\" />\n";
+               echo "</form>\n";
                
-               case '400':
-                       $query = 'SELECT * FROM ' . sql_table('config') . ' WHERE name=\'DatabaseVersion\' and value >= 400 LIMIT 1';
-                       $minrows = 1;
-               break;
+               upgrade_foot();
+               exit;
        }
-       
-       $result = mysql_query($query);
-       $installed = ( $result != 0 ) && (mysql_num_rows($result) >= $minrows);
-       return $installed;
-}
 
-/**
- * Get the Nucleus version. If getNucleusVersion() doesn't exist, default to version 0.96
- * @return int
- */
-function upgrade_getNucleusVersion()
-{
-       if ( !function_exists('getNucleusVersion') )
+       /**
+        * Display the HTML header
+        */
+       function upgrade_head()
        {
-               return 96;
+               echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
+               echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
+               echo "<head>\n";
+               echo "<title> Nucleus Upgrade </title>\n";
+               
+               if ( file_exists('../styles/manual.css') )
+               {
+                       echo "<link rel=\"stylesheet\" href=\"../styles/manual.css\" type=\"text/css\" />\n";
+               }
+               else
+               {
+                       echo "<style type=\"text/css\">\n";
+                       echo ".warning { color: red; }\n";
+                       echo ".ok { color: green; }\n";
+                       echo "</style>\n";
+               }
+               
+               echo "</head>\n";
+               echo "<body>\n";
        }
-       return getNucleusVersion();
-}
 
-/**
- * Show the login form
- * @param string $action
- */
-function upgrade_showLogin($action)
-{
-       upgrade_head();
-       echo "<h1>Log In</h1>\n";
-       echo "<p>Please enter your login name and password.</p>\n";
-       echo "<form method=\"POST\" action=\"{$action}\">\n";
-       echo "<ul>\n";
-       echo '<li><label for="i_login">Name:</label> <input type="text" name="login" id="i_login" size="20" /></li>' . "\n";
-       echo '<li><label for="i_password">Password:</label> <input type="password" name="password" id="i_password" size="20" /></li>' . "\n";
-       echo "</ul>\n";
-       echo '<p><input type="submit" value="Log In" /></p>' . "\n";
-       echo '<input name="action" value="login" type="hidden" />' . "\n";
-       echo "</form>\n";
-       upgrade_foot();
-       exit;
-}
 
-/**
- * Display the HTML header
- */
-function upgrade_head()
-{
-       echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
-       echo '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
-       echo '<head>' . "\n";
-       echo '<title>Nucleus Upgrade</title>' . "\n";
-       
-       /* begin if: manual.css exists - <link> it */
-       if ( file_exists('../styles/manual.css') )
+       /**
+        * Display the HTML footer
+        */
+       function upgrade_foot()
        {
-               echo '<link rel="stylesheet" href="../styles/manual.css" type="text/css" />' . "\n";
+               echo '</body></html>';
        }
-       else
+
+
+       /**
+        * Display an error page
+        * @param string $message
+        */
+       function upgrade_error($message)
        {
-               echo '<style type="text/css">' . "\n";
-               echo '.warning { color: red; }' . "\n";
-               echo '.ok { color: green; }' . "\n";
-               echo '</style>' . "\n";
-       }
-       upgrade_foot();
-       return;
-}
+               upgrade_head();
+?>
+               <h1> Error </h1>
 
-/**
- * Display the HTML footer
- */
-function upgrade_foot()
-{
-       echo "</body>\n";
-       echo "</html>\n";
-}
+               <p> The following message was returned: </p>
+               <p> <?php echo $message?> </p>
+               <p> <a href="index.php" onclick="history.back(); return false;">Go Back</a> </p>
 
-/**
- * Display an error page
- * @param string $message
- */
-function upgrade_error($message)
-{
-       upgrade_head();
-       
-       echo "<h1> Error </h1>\n";
-       echo "<p>The following message was returned:</p>\n";
-       echo "<p>{$message}</p>\n";
-       echo "<p><a href=\"index.php\" onclick=\"history.back(); return false;\">Go Back</a></p>\n";
-       
-       upgrade_foot();
-       exit;
-}
-
-function upgrade_start()
-{
-       global $upgrade_failures;
-       $upgrade_failures = 0;
-       
-       upgrade_head();
-       
-       echo "<h1>Executing Upgrades</h1>\n";
-       echo "<ul>\n";
-}
+<?php
+               upgrade_foot();
+               exit;
+       }
 
-function upgrade_end($message = '')
-{
-       global $upgrade_failures;
-       
-       $from = intGetVar('from');
-       
-       if ( $upgrade_failures > 0 )
+
+       function upgrade_start()
        {
-               $message = 'Some queries have failed. Try reverting to a backup or reparing things manually, then re-run this script.';
+               global $upgrade_failures;
+               $upgrade_failures = 0;
+
+               upgrade_head();
+?>
+               <h1> Executing Upgrades </h1>
+
+               <ul>
+<?php
        }
-       
-       echo "</ul>\n";
-       echo "<h1>Upgrade Completed!</h1>\n";
-       echo "<p>{$message}</p>\n";
-       echo "<p> Back to the <a href=\"index.php?from={$from}\">Upgrades Overview</a></p>\n";
-       
-       upgrade_foot();
-       exit;
-}
 
-/**
- * Executes a query, displaying the user-friendly explanation and a success / fail message. Query errors are displayed, too.
- *
- * @param string $friendly
- * @param string $query
- * @return resource (is this return necessary?)
- */
-function upgrade_query($friendly, $query)
-{
-       global $upgrade_failures;
-       
-       // output the friendly message
-       echo "<li>{$friendly} &mdash; ";
-       
-       // execute the query
-       $result = @mysql_query($query);
-       
-       // begin if: error executing query
-       if ( $result === FALSE )
+
+       function upgrade_end($message = '')
        {
-               echo '<span class="warning"> FAILED </span> <br />';
-               echo 'Error: <code>', mysql_error(), '</code>';
-               $upgrade_failures++;
+               global $upgrade_failures;
+
+               $from = intGetVar('from');
+
+               if ( $upgrade_failures > 0 )
+               {
+                       $message = 'Some queries have failed. Try reverting to a backup or reparing things manually, then re-run this script.';
+               }
+?>
+               </ul>
+
+               <h1> Upgrade Completed! </h1>
+
+               <p> <?php echo $message?> </p>
+
+               <p> Back to the <a href="index.php?from=<?php echo $from; ?>">Upgrades Overview</a> </p>
+
+<?php
+               upgrade_foot();
+               exit;
        }
-       else
+
+
+       /**
+        * Executes a query, displaying the user-friendly explanation and a success / fail message. Query errors are displayed, too.
+        *
+        * @param string $friendly
+        * @param string $query
+        * @return resource (is this return necessary?)
+        */
+       function upgrade_query($friendly, $query)
        {
-               echo '<span class="ok"> SUCCESS! </span>';
+               global $upgrade_failures;
+
+               # output the friendly message
+               echo "<li> $friendly &mdash; ";
+
+               # execute the query
+               $result = @mysql_query($query);
+
+               // begin if: error executing query
+               if ( $result === FALSE )
+               {
+                       echo '<span class="warning"> FAILED </span> <br />';
+                       echo 'Error: <code>', mysql_error(), '</code>';
+                       $upgrade_failures++;
+               }
+               // else: query was successful
+               else
+               {
+                       echo '<span class="ok"> SUCCESS! </span>';
+               } // end if
+
+               echo '</li>', "\n";
+               return $result;
        }
-       
-       echo '</li>', "\n";
-       return $result;
-}
 
 
-/**
- * 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;
-       
-       // begin if: no upgrade failures; update the database version in the config table
-       if ( $upgrade_failures == 0 )
+       /**
+         * Tries to update database version, gives a message when failed
+         *
+         * @param $version
+         *     Schema version the database has been upgraded to
+         */
+       function update_version($version)
        {
-               $query = 'UPDATE `%s` ' .
-                       'SET `value` = "%s" ' .
-                       'WHERE `name` = "DatabaseVersion"';
-               
-               $query = sprintf($query, sql_table('config'), $version);
-               upgrade_query($message, $query);
+               global $upgrade_failures;
+
+               $message = 'Updating DatabaseVersion in config table to ' . $version;
+
+               // begin if: no upgrade failures; update the database version in the config table
+               if ( $upgrade_failures == 0 )
+               {
+                       $query = 'UPDATE `%s` ' .
+                               'SET `value` = "%s" ' .
+                               'WHERE `name` = "DatabaseVersion"';
+
+                       $query = sprintf($query, sql_table('config'), $version);
+                       upgrade_query($message, $query);
+               }
+               // else: display 'not executed' message
+               else
+               {
+                       echo '<li>', $message, ' &mdash; <span class="warning">NOT EXECUTED</span> Errors occurred during upgrade process. </li>';
+               } // end if
+
        }
-       else
+
+
+       /**
+        * 
+        *
+        * @param string $table table to check (without prefix)
+        * @param array $columns array of column names included
+        * @return int
+        */
+       function upgrade_checkIfIndexExists($table, $columns)
        {
-               echo '<li>', $message, ' &mdash; <span class="warning">NOT EXECUTED</span> Errors occurred during upgrade process. </li>';
+               // get info for indices from database
+               $indices = array();
+
+               $query = 'SHOW INDEX FROM `' . sql_table($table) . '`';
+               $result = @mysql_query($query);
+
+               // begin loop: each result object
+               while ( $object = mysql_fetch_object($result) )
+               {
+
+                       // begin if: key has not been added to the indeces array yet
+                       if ( !isset($indices[$object->Key_name]) )
+                       {
+                               $indices[$object->Key_name] = array();
+                       } // end if
+
+                       array_push($indices[$object->Key_name], $object->Column_name);
+               }
+
+               // compare each index with parameter
+               foreach ( $indices as $key_name => $index_columns )
+               {
+                       $diff = array_diff($index_columns, $columns);
+
+                       if ( count($diff) == 0 )
+                       {
+                               return 1;
+                       } // end if
+
+               } // end loop
+
+               return 0;
        }
-}
 
-/**
- * 
- *
- * @param string $table table to check (without prefix)
- * @param array $columns array of column names included
- * @return int
- */
-function upgrade_checkIfIndexExists($table, $columns)
-{
-       // get info for indices from database
-       $indices = array();
-       
-       $query = 'SHOW INDEX FROM `' . sql_table($table) . '`';
-       $result = @mysql_query($query);
-       
-       // begin loop: each result object
-       while ( $object = mysql_fetch_object($result) )
+
+       /**
+        * Checks to see if a given table exists
+        *
+        * @param string $table name of table to check existence of
+        * @return bool TRUE if table exists, FALSE otherwise.
+        */
+       function upgrade_checkIfTableExists($table)
        {
-               // begin if: key has not been added to the indeces array yet
-               if ( !isset($indices[$object->Key_name]) )
+               $query = 'SHOW TABLES LIKE `' . sql_table($table) . '`';
+               $result = @mysql_query($query);
+
+               // begin if: query executed successfully and one row was returned
+               if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) )
                {
-                       $indices[$object->Key_name] = array();
+                       return TRUE;
                }
-               
-               array_push($indices[$object->Key_name], $object->Column_name);
+               // else: query error or no results returned
+               else
+               {
+                       return FALSE;
+               } // end if
+
        }
-       
-       // compare each index with parameter
-       foreach ( $indices as $key_name => $index_columns )
+
+
+       /**
+         * Checks to see if a given configuration value exists
+         *
+         * @param string $value config value to check for existance of (paramater must be MySQL escaped already)
+         * @return bool TRUE if configuration value exists, FALSE otherwise.
+         */
+       function upgrade_checkIfCVExists($value)
        {
-               $diff = array_diff($index_columns, $columns);
-               
-               if ( count($diff) == 0 )
+               $query = 'SELECT `name` FROM `' . sql_table('config') . '` WHERE `name` = "' . $value . '"';
+               $result = @mysql_query($query);
+
+               // begin if: query executed successfully and one row was returned
+               if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) )
                {
-                       return 1;
+                       return TRUE;
                }
+               // else: query error or no results returned
+               else
+               {
+                       return FALSE;
+               } // end if
+
        }
-       return 0;
-}
 
-/**
- * Checks to see if a given table exists
- *
- * @param string $table name of table to check existence of
- * @return bool TRUE if table exists, FALSE otherwise.
- */
-function upgrade_checkIfTableExists($table)
-{
-       $query = 'SHOW TABLES LIKE `' . sql_table($table) . '`';
-       $result = @mysql_query($query);
-       
-       // begin if: query executed successfully and one row was returned
-       return ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) );
-}
 
-/**
- * Checks to see if a given configuration value exists
- *
- * @param string $value config value to check for existance of (paramater must be MySQL escaped already)
- * @return bool TRUE if configuration value exists, FALSE otherwise.
- */
-function upgrade_checkIfCVExists($value)
-{
-       $query = 'SELECT `name` FROM `' . sql_table('config') . '` WHERE `name` = "' . $value . '"';
-       $result = @mysql_query($query);
-       
-       // begin if: query executed successfully and one row was returned
-       return ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) );
-}
+       /**
+         * Checks to see if a given column exists
+         *
+         * @param string $table name of table to check for column in
+         * @param string $column name of column to check for existance of
+         * @return bool TRUE if column exists, FALSE otherwise.
+         */
+       function upgrade_checkIfColumnExists($table, $column)
+       {
+               $query = 'DESC `' . sql_table($table) . '` `' . $column . '`';
+               $result = @mysql_query($query);
 
-/**
- * Checks to see if a given column exists
- *
- * @param string $table name of table to check for column in
- * @param string $column name of column to check for existance of
- * @return bool TRUE if column exists, FALSE otherwise.
- */
-function upgrade_checkIfColumnExists($table, $column)
-{
-       $query = 'DESC `' . sql_table($table) . '` `' . $column . '`';
-       $result = @mysql_query($query);
-       
-       return ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) );
-}
+               // begin if: query executed successfully and one row was returned
+               if ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) )
+               {
+                       return TRUE;
+               }
+               // else: query error or no results returned
+               else
+               {
+                       return FALSE;
+               } // end if
+
+       }
index 52e1f2e..12d39bd 100644 (file)
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: upgrade.php 1447 2010-07-26 18:20:53Z ftruscot $
+ * @version $Id: upgrade.php 1690 2012-03-08 22:45:08Z ftruscot $
  */
 
-include('./upgrade.functions.php');
+include('upgrade.functions.php');
 
 // check if logged in etc
-if ( !$member->isLoggedIn() )
-{
+if (!$member->isLoggedIn()) {
        upgrade_showLogin('upgrade.php?from=' . intGetVar('from'));
 }
 
-if ( !$member->isAdmin() )
-{
+if (!$member->isAdmin()) {
        upgrade_error('Only Super-Admins are allowed to perform upgrades');
 }
 
@@ -42,6 +40,7 @@ include('upgrade3.3.php');
 include('upgrade3.4.php');
 include('upgrade3.5.php');
 include('upgrade3.6.php');
+include('upgrade4.0.php');
 
 $from = intGetVar('from');
 
@@ -79,10 +78,17 @@ switch($from) {
                //break;
        case 350:
                upgrade_do360();
+               //break;
+       case 360:
+               upgrade_do400();
                break;
        default:
                echo "<li>Error! No updates to execute</li>";
                break;
 }
 
+
+
 upgrade_end("Upgrade Completed");
+
+?>
\ No newline at end of file
index 10eac7b..3bad44f 100644 (file)
@@ -12,7 +12,7 @@
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: upgrade2.5.php 1624 2012-01-09 11:36:20Z sakamocchi $
+ * @version $Id: upgrade2.5.php 1685 2012-03-01 15:28:00Z sakamocchi $
  */
 
 function upgrade_do250() {
index 8253da4..41dd003 100644 (file)
@@ -22,39 +22,29 @@ function upgrade_do400()
                return "already installed";
        }
        
-       /* in config table, 'Language' is renamed 'Locale' and the value is changed */
+       /* config.Language to config.Locale  */
        if ( !upgrade_checkIfColumnExists('config','Locale') )
        {
-               $query = "SELECT * FROM %s WHERE name='Language'";
-               $query = sprintf($query, sql_table('config'));
-               $res = sql_query($query);
+               $res = sql_query("SELECT * FROM " . sql_table('config') . " WHERE name='Language'");
                while ( $o = mysql_fetch_object($res) )
                {
-                       $language = $o->Language;
-                       break;
+                       $locale = $o->Language;
                }
-               $locale = i18n::convert_old_language_file_name_to_locale($language);
-               
-               $query = "INSERT INTO %s (name, value) VALUE('Locale', '%s');";
-               $query = sprintf($query, sql_table('config'), $locale);
+               $query = 'INSERT INTO ' . sql_table('config') . " (name, value) VALUE('Locale', '{$locale}');";
                upgrade_query("Renaming Language for configs to Locale", $query);
-               
-               $query = "DELETE * FROM %s WHERE name='Language';";
-               $query = sprintf($query, sql_table('config'));
+       }
+       
+       if ( !upgrade_checkIfColumnExists('config','Language') )
+       {
+               $query = "DELETE * FROM " . sql_table('config') . " WHERE name='Language'";
                upgrade_query("Renaming Language for configs to Locale", $query);
        }
        
-       /* in member table, deflang field is renamed  as mlocale */
+       /* member.deflang to member.mlocale   */
        if ( !upgrade_checkIfColumnExists('member','mlocale') )
        {
-               $query = "ALTER TABLE %s CHANGE deflang mlocale varchar(10) NOT NULL default '';";
-               $query = sprintf($query, sql_table('member'));
+               $query =  'ALTER TABLE '.sql_table('member') . " CHANGE deflang mlocale varchar(10) NOT NULL default ''";
                upgrade_query("Renaming deflang column for members to mlocale", $query);
        }
-       
-       /* update database version */
-       update_version('400');
-       
-       return;
 }