OSDN Git Service

アップグレードスクリプトのコード修正。ショートオープンタグの除外。
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 27 Feb 2012 05:19:29 +0000 (14:19 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 27 Feb 2012 05:19:29 +0000 (14:19 +0900)
nucleus/upgrades/index.php
nucleus/upgrades/upgrade.functions.php
nucleus/upgrades/upgrade.php
nucleus/upgrades/upgrade3.4.php
nucleus/upgrades/upgrade3.5.php
nucleus/upgrades/upgrade3.6.php
nucleus/upgrades/upgrade4.0.php

index f0f706d..f1d2318 100644 (file)
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: index.php 1624 2012-01-09 11:36:20Z sakamocchi $
+ * @version $Id: index.php 1678 2012-02-26 07:31:36Z sakamocchi $
  *
  */
 
-       include('upgrade.functions.php');
+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();
 
-       // begin if: make sure user is logged in
-       if ( !$member->isLoggedIn() )
-       {
-               upgrade_showLogin('index.php');
-       } // end if
-
-       // begin if: make sure user is an admin
-       if ( !$member->isAdmin() )
-       {
-               upgrade_error('Only super administrators are allowed to perform upgrades');
-       } // end if
-
-       upgrade_head();
-?>
-
-       <h1> Upgrade Nucleus </h1>
-
-       <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>
+/**
+ * 
+ * @param int $version
+ */
+function upgrade_todo($version)
+{
+       return upgrade_checkinstall($version) ? "(<span class='ok'>installed</span>)" : "(<span class='warning'>not yet installed</span>)";
+}
 
-<?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
-       }
+/**
+ * Manual update instructions for version 0.96
+ */
+function upgrade_manual_96()
+{
+       global $DIR_NUCLEUS;
        
-       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 v3.6</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;
-       }
-
-       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()
+       $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;
+}
 
+/**
+ * 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;
+}
 
-       /**
-        * Manual update instructions for version 3.5 and before
-        */
-       function upgrade_manual_350()
-       {
-               global $DIR_NUCLEUS;
-?>
-       <h2> Important Notices for Nucleus 3.5 </h2>
+/**
+ * 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;
+}
 
-<?php
+/**
+ * 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";
+       
        // 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()
+       
+       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";
+}
index 6ea18c3..fa1c2a6 100644 (file)
  * @version $Id: upgrade.functions.php 1592 2011-10-29 22:24:24Z gregorlove $
  */
 
-       /**
-        * Some functions common to all upgrade scripts
       */
+/*************************************************************
+ *     NOTE: With upgrade to 3.6, need to set this to use sql_* API
**************************************************************/
 
-       /*************************************************************
-        *     NOTE: With upgrade to 3.6, need to set this to use sql_* API
-        **************************************************************/
+include('../../config.php');
 
-       include('../../config.php');
-
-       // sql_table function did not exists in nucleus <= 2.0
-       if ( !function_exists('sql_table') )
+// sql_table function did not exists in nucleus <= 2.0
+if ( !function_exists('sql_table') )
+{
+       function sql_table($name)
        {
-               function sql_table($name)
-               {
-                       return 'nucleus_' . $name;
-               }
+               return 'nucleus_' . $name;
        }
+}
 
-       //intGetVar did not exist in very early versions
-       if ( !function_exists('intGetVar') )
+//intGetVar did not exist in very early versions
+if ( !function_exists('intGetVar') )
+{
+       function intGetVar($name)
        {
-               function intGetVar($name)
+               if ( defined($_GET) )
                {
-                       if ( defined($_GET) )
-                       {
-                               return intval($_GET[$name]);
-                       }
-                       else
-                       {
-                               global $HTTP_GET_VARS;
-                               return intval($HTTP_GET_VARS[$name]);
-                       }
+                       return intval($_GET[$name]);
                }
-       }
-
-
-       function upgrade_checkinstall($version)
-       {
-               $installed = 0;
-
-               switch( $version )
+               else
                {
-                       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;
+                       global $HTTP_GET_VARS;
+                       return intval($HTTP_GET_VARS[$name]);
                }
-
-               $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()
+function upgrade_checkinstall($version)
+{
+       $installed = 0;
+       
+       switch( $version )
        {
-               if ( !function_exists('getNucleusVersion') )
-               {
-                       return 96;
-               }
-
-               return 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;
+               
+               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;
+}
 
-
-       /**
-        * Show the login form
-        * @param string $action
-        */
-       function upgrade_showLogin($action)
+/**
+ * Get the Nucleus version. If getNucleusVersion() doesn't exist, default to version 0.96
+ * @return int
+ */
+function upgrade_getNucleusVersion()
+{
+       if ( !function_exists('getNucleusVersion') )
        {
-               upgrade_head();
-?>
-       <h1> Log In </h1>
-       <p> Please enter your login name and password. </p>
-
-       <form method="POST" action="<?php echo $action; ?>">
-       <ul>
-               <li> <label for="i_login">Name:</label> <input type="text" name="login" id="i_login" size="20" /> </li>
-               <li> <label for="i_password">Password:</label> <input type="password" name="password" id="i_password" size="20" /> </li>
-       </ul>
-       <p> <input type="submit" value="Log In" /> </p>
-       <input name="action" value="login" type="hidden" />
-       </form>
-
-<?php
-               upgrade_foot();
-               exit;
-       } // end function upgrade_showLogin()
+               return 96;
+       }
+       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()
-       {
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-       <head>
-               <title> Nucleus Upgrade </title>
-<?php
-       // begin if: manual.css exists - <link> it
+/**
+ * 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') )
        {
-?>
-               <link rel="stylesheet" href="../styles/manual.css" type="text/css" />
-<?php
+               echo '<link rel="stylesheet" href="../styles/manual.css" type="text/css" />' . "\n";
        }
-       // else: include some CSS
        else
        {
-?>
-               <style type="text/css">
-                       .warning { color: red; }
-                       .ok { color: green; }
-               </style>
-<?php
-       } // end if
-?>
-       </head>
-       <body>
-
-<?php
-       } // end function upgrade_head()
-
-
-       /**
-        * Display the HTML footer
-        */
-       function upgrade_foot()
-       {
-               echo '</body></html>';
+               echo '<style type="text/css">' . "\n";
+               echo '.warning { color: red; }' . "\n";
+               echo '.ok { color: green; }' . "\n";
+               echo '</style>' . "\n";
        }
+       upgrade_foot();
+       return;
+}
 
+/**
+ * Display the HTML footer
+ */
+function upgrade_foot()
+{
+       echo "</body>\n";
+       echo "</html>\n";
+}
 
-       /**
-        * Display an error page
-        * @param string $message
-        */
-       function upgrade_error($message)
+/**
+ * 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";
+}
+
+function upgrade_end($message = '')
+{
+       global $upgrade_failures;
+       
+       $from = intGetVar('from');
+       
+       if ( $upgrade_failures > 0 )
        {
-               upgrade_head();
-?>
-               <h1> Error </h1>
-
-               <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>
-
-<?php
-               upgrade_foot();
-               exit;
+               $message = 'Some queries have failed. Try reverting to a backup or reparing things manually, then re-run this script.';
        }
+       
+       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;
+}
 
-
-       function upgrade_start()
+/**
+ * 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 )
        {
-               global $upgrade_failures;
-               $upgrade_failures = 0;
-
-               upgrade_head();
-?>
-               <h1> Executing Upgrades </h1>
-
-               <ul>
-<?php
+               echo '<span class="warning"> FAILED </span> <br />';
+               echo 'Error: <code>', mysql_error(), '</code>';
+               $upgrade_failures++;
        }
-
-
-       function upgrade_end($message = '')
-       {
-               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;
-       }
-
-
-       /**
-        * 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)
+       else
        {
-               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 '<span class="ok"> SUCCESS! </span>';
        }
+       
+       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)
+/**
+ * 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 )
        {
-               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
-
+               $query = 'UPDATE `%s` ' .
+                       'SET `value` = "%s" ' .
+                       'WHERE `name` = "DatabaseVersion"';
+               
+               $query = sprintf($query, sql_table('config'), $version);
+               upgrade_query($message, $query);
        }
-
-
-       /**
-        * 
-        *
-        * @param string $table table to check (without prefix)
-        * @param array $columns array of column names included
-        * @return int
-        */
-       function upgrade_checkIfIndexExists($table, $columns)
+       else
        {
-               // 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;
+               echo '<li>', $message, ' &mdash; <span class="warning">NOT EXECUTED</span> Errors occurred during upgrade process. </li>';
        }
+}
 
-
-       /**
-        * 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)
+/**
+ * 
+ *
+ * @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) )
        {
-               $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) )
+               // begin if: key has not been added to the indeces array yet
+               if ( !isset($indices[$object->Key_name]) )
                {
-                       return TRUE;
+                       $indices[$object->Key_name] = array();
                }
-               // else: query error or no results returned
-               else
-               {
-                       return FALSE;
-               } // end if
-
+               
+               array_push($indices[$object->Key_name], $object->Column_name);
        }
-
-
-       /**
-         * 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)
+       
+       // compare each index with parameter
+       foreach ( $indices as $key_name => $index_columns )
        {
-               $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) )
+               $diff = array_diff($index_columns, $columns);
+               
+               if ( count($diff) == 0 )
                {
-                       return TRUE;
+                       return 1;
                }
-               // 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 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);
-
-               // 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
+/**
+ * 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);
+       
+       return ( ($result !== FALSE) && (@mysql_num_rows($result) == 1) );
+}
index befd28f..52e1f2e 100644 (file)
  * @version $Id: upgrade.php 1447 2010-07-26 18:20:53Z 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');
 }
 
@@ -83,8 +85,4 @@ switch($from) {
                break;
 }
 
-
-
 upgrade_end("Upgrade Completed");
-
-?>
\ No newline at end of file
index bc4896f..0497c3c 100644 (file)
@@ -1,64 +1,64 @@
-<?php\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2009 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- */\r
-/**\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
- * @version $Id: upgrade3.4.php 1416 2009-09-24 15:58:08Z ftruscot $\r
- */\r
-\r
-function upgrade_do340() {\r
-\r
-       if (upgrade_checkinstall(340))\r
-               return 'already installed';\r
-       \r
-       // Give user warning if they are running old version of PHP\r
-        if (phpversion() < '5') {\r
-                echo 'WARNING: You are running NucleusCMS on a older version of PHP. PHP4 support will be depreciated in the next release, please consider upgrade to PHP5!';\r
-        }\r
-\r
-       // lengthen tpartname column of nucleus_template\r
-       $query = "      ALTER TABLE `" . sql_table('template') . "`\r
-                                       MODIFY `tpartname` varchar(64) NOT NULL default '' ;";\r
-\r
-       upgrade_query('Altering ' . sql_table('template') . ' table', $query);\r
-       \r
-       // lengthen tdname column of nucleus_template_desc\r
-       $query = "      ALTER TABLE `" . sql_table('template_desc') . "`\r
-                                       MODIFY `tdname` varchar(64) NOT NULL default '' ;";\r
-\r
-       upgrade_query('Altering ' . sql_table('template_desc') . ' table', $query);\r
-       \r
-       // create DebugVars setting\r
-       if (!upgrade_checkIfCVExists('DebugVars')) {\r
-               $query = 'INSERT INTO '.sql_table('config')." VALUES ('DebugVars',0)";\r
-               upgrade_query('Creating DebugVars config value',$query);        \r
-       }\r
-       \r
-       // create DefaultListSize setting\r
-       if (!upgrade_checkIfCVExists('DefaultListSize')) {\r
-               $query = 'INSERT INTO '.sql_table('config')." VALUES ('DefaultListSize',10)";\r
-               upgrade_query('Creating DefaultListSize config value',$query);  \r
-       }\r
-       \r
-       // changing the member table\r
-       if (!upgrade_checkIfColumnExists('member', 'mautosave')) {\r
-               $query = ' ALTER TABLE ' . sql_table('member') . ' ADD mautosave TINYINT(2) DEFAULT 1';\r
-               upgrade_query('Adding a new row for the autosave member option', $query);\r
-       }\r
-\r
-       // 3.3 -> 3.4\r
-       // update database version\r
-       update_version('340');\r
-       \r
-}\r
-\r
-?>\r
+<?php
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2009 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: upgrade3.4.php 1665 2012-02-13 16:50:35Z ftruscot $
+ */
+
+function upgrade_do340() {
+
+       if (upgrade_checkinstall(340))
+               return 'already installed';
+       
+       // Give user warning if they are running old version of PHP
+        if (phpversion() < '5') {
+                echo 'WARNING: You are running NucleusCMS on a older version of PHP. PHP4 support will be depreciated in the next release, please consider upgrade to PHP5!';
+        }
+
+       // lengthen tpartname column of nucleus_template
+       $query = "      ALTER TABLE `" . sql_table('template') . "`
+                                       MODIFY `tpartname` varchar(64) NOT NULL default '' ;";
+
+       upgrade_query('Altering ' . sql_table('template') . ' table', $query);
+       
+       // lengthen tdname column of nucleus_template_desc
+       $query = "      ALTER TABLE `" . sql_table('template_desc') . "`
+                                       MODIFY `tdname` varchar(64) NOT NULL default '' ;";
+
+       upgrade_query('Altering ' . sql_table('template_desc') . ' table', $query);
+       
+       // create DebugVars setting
+       if (!upgrade_checkIfCVExists('DebugVars')) {
+               $query = 'INSERT INTO '.sql_table('config')." VALUES ('DebugVars',0)";
+               upgrade_query('Creating DebugVars config value',$query);        
+       }
+       
+       // create DefaultListSize setting
+       if (!upgrade_checkIfCVExists('DefaultListSize')) {
+               $query = 'INSERT INTO '.sql_table('config')." VALUES ('DefaultListSize',10)";
+               upgrade_query('Creating DefaultListSize config value',$query);  
+       }
+       
+       // changing the member table
+       if (!upgrade_checkIfColumnExists('member', 'mautosave')) {
+               $query = ' ALTER TABLE ' . sql_table('member') . ' ADD mautosave TINYINT(2) DEFAULT 1';
+               upgrade_query('Adding a new row for the autosave member option', $query);
+       }
+
+       // 3.3 -> 3.4
+       // update database version
+       update_version('340');
+       
+}
+
+?>
index ad669d4..bfed694 100644 (file)
@@ -1,50 +1,50 @@
-<?php\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2009 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- */\r
-/**\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
- * @version $Id: upgrade3.5.php 1416 2009-09-24 15:58:08Z ftruscot $\r
- */\r
-\r
-function upgrade_do350() {\r
-\r
-       if (upgrade_checkinstall(350))\r
-               return 'already installed';\r
-       \r
-       // Give user warning if they are running old version of PHP\r
-        if (phpversion() < '5') {\r
-                echo 'WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5!';\r
-        }\r
-       \r
-       // changing the member table to lengthen display name (mname)\r
-    $query = " ALTER TABLE `" . sql_table('member') . "`\r
-                                       MODIFY `mname` varchar(32) NOT NULL default '' ;";\r
-\r
-       upgrade_query('Altering ' . sql_table('member') . ' table', $query);\r
-\r
-       // changing the blog table to remove bsendping flag\r
-    if (upgrade_checkIfColumnExists('blog', 'bsendping')) {\r
-               $query = "      ALTER TABLE `" . sql_table('blog') . "`\r
-                                       DROP `bsendping`;";\r
-       \r
-               upgrade_query('Altering ' . sql_table('blog') . ' table', $query);\r
-       }\r
-\r
-       // 3.4 -> 3.5\r
-       // update database version\r
-       update_version('350');\r
-\r
-       // Remind user to re-install NP_Ping \r
-       echo '<p>Note: There are new changes to NP_Ping in v3.50. If it is already installed, please go to Admin Panel uninstall and re-install the plugin</p>';\r
-       \r
-}\r
-?>\r
+<?php
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2009 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: upgrade3.5.php 1665 2012-02-13 16:50:35Z ftruscot $
+ */
+
+function upgrade_do350() {
+
+       if (upgrade_checkinstall(350))
+               return 'already installed';
+       
+       // Give user warning if they are running old version of PHP
+        if (phpversion() < '5') {
+                echo 'WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5!';
+        }
+       
+       // changing the member table to lengthen display name (mname)
+    $query = " ALTER TABLE `" . sql_table('member') . "`
+                                       MODIFY `mname` varchar(32) NOT NULL default '' ;";
+
+       upgrade_query('Altering ' . sql_table('member') . ' table', $query);
+
+       // changing the blog table to remove bsendping flag
+    if (upgrade_checkIfColumnExists('blog', 'bsendping')) {
+               $query = "      ALTER TABLE `" . sql_table('blog') . "`
+                                       DROP `bsendping`;";
+       
+               upgrade_query('Altering ' . sql_table('blog') . ' table', $query);
+       }
+
+       // 3.4 -> 3.5
+       // update database version
+       update_version('350');
+
+       // Remind user to re-install NP_Ping 
+       echo '<p>Note: There are new changes to NP_Ping in v3.50. If it is already installed, please go to Admin Panel uninstall and re-install the plugin</p>';
+       
+}
+?>
index d641404..e4ea314 100644 (file)
@@ -1,42 +1,42 @@
-<?php\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2009 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- */\r
-/**\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
- * @version $Id: upgrade3.5.php 1416 2009-09-24 15:58:08Z ftruscot $\r
- */\r
-\r
-function upgrade_do360() {\r
-\r
-       if (upgrade_checkinstall(360))\r
-               return 'already installed';\r
-       \r
-       // Give user warning if they are running old version of PHP\r
-        if (phpversion() < '5') {\r
-                echo 'WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5!';\r
-        }\r
-       \r
-       // changing the blog table to lengthen bnotify field \r
-    $query = " ALTER TABLE `" . sql_table('blog') . "`\r
-                                       MODIFY `bnotify` varchar(128) default NULL ;";\r
-\r
-       upgrade_query('Altering ' . sql_table('blog') . ' table', $query);\r
-\r
-       // 3.4 -> 3.5\r
-       // update database version\r
-       update_version('360');\r
-\r
-       // Remind user to re-install NP_Ping \r
-       echo '<p></p>';\r
-       \r
-}\r
-?>\r
+<?php
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2009 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: upgrade3.6.php 1665 2012-02-13 16:50:35Z ftruscot $
+ */
+
+function upgrade_do360() {
+
+       if (upgrade_checkinstall(360))
+               return 'already installed';
+       
+       // Give user warning if they are running old version of PHP
+        if (phpversion() < '5') {
+                echo 'WARNING: You are running NucleusCMS on a older version of PHP that is no longer supported by NucleusCMS. Please upgrade to PHP5!';
+        }
+       
+       // changing the blog table to lengthen bnotify field 
+    $query = " ALTER TABLE `" . sql_table('blog') . "`
+                                       MODIFY `bnotify` varchar(128) default NULL ;";
+
+       upgrade_query('Altering ' . sql_table('blog') . ' table', $query);
+
+       // 3.4 -> 3.5
+       // update database version
+       update_version('360');
+
+       // Remind user to re-install NP_Ping 
+       echo '<p></p>';
+       
+}
+?>
index 41dd003..8253da4 100644 (file)
@@ -22,29 +22,39 @@ function upgrade_do400()
                return "already installed";
        }
        
-       /* config.Language to config.Locale  */
+       /* in config table, 'Language' is renamed 'Locale' and the value is changed */
        if ( !upgrade_checkIfColumnExists('config','Locale') )
        {
-               $res = sql_query("SELECT * FROM " . sql_table('config') . " WHERE name='Language'");
+               $query = "SELECT * FROM %s WHERE name='Language'";
+               $query = sprintf($query, sql_table('config'));
+               $res = sql_query($query);
                while ( $o = mysql_fetch_object($res) )
                {
-                       $locale = $o->Language;
+                       $language = $o->Language;
+                       break;
                }
-               $query = 'INSERT INTO ' . sql_table('config') . " (name, value) VALUE('Locale', '{$locale}');";
+               $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);
                upgrade_query("Renaming Language for configs to Locale", $query);
-       }
-       
-       if ( !upgrade_checkIfColumnExists('config','Language') )
-       {
-               $query = "DELETE * FROM " . sql_table('config') . " WHERE name='Language'";
+               
+               $query = "DELETE * FROM %s WHERE name='Language';";
+               $query = sprintf($query, sql_table('config'));
                upgrade_query("Renaming Language for configs to Locale", $query);
        }
        
-       /* member.deflang to member.mlocale   */
+       /* in member table, deflang field is renamed  as mlocale */
        if ( !upgrade_checkIfColumnExists('member','mlocale') )
        {
-               $query =  'ALTER TABLE '.sql_table('member') . " CHANGE deflang mlocale varchar(10) NOT NULL default ''";
+               $query = "ALTER TABLE %s CHANGE deflang mlocale varchar(10) NOT NULL default '';";
+               $query = sprintf($query, sql_table('member'));
                upgrade_query("Renaming deflang column for members to mlocale", $query);
        }
+       
+       /* update database version */
+       update_version('400');
+       
+       return;
 }