upgrade.php
changeset 229 97ae8e9d5e29
parent 228 b0a4d179be85
child 279 8acd77a6c19d
equal deleted inserted replaced
147:d8156d18ac58 229:97ae8e9d5e29
     1 <?php
     1 <?php
     2 
     2 
     3 /*
     3 /*
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     5  * Version 1.0.2 (Coblynau)
     5  * Version 1.1.1
     6  * upgrade.php - upgrade script
     6  * upgrade.php - upgrade script
     7  * Copyright (C) 2006-2007 Dan Fuhry
     7  * Copyright (C) 2006-2007 Dan Fuhry
     8  *
     8  *
     9  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
     9  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    10  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    10  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    59 
    59 
    60 // SCRIPT CONFIGURATION
    60 // SCRIPT CONFIGURATION
    61 // Everything related to versions goes here!
    61 // Everything related to versions goes here!
    62 
    62 
    63 // Valid versions to upgrade from
    63 // Valid versions to upgrade from
    64 $valid_versions = Array('1.0b1', '1.0b2', '1.0b3', '1.0b4', '1.0RC1', '1.0RC2', '1.0RC3', '1.0', '1.0.1', '1.0.1.1');
    64 $valid_versions = Array('1.0b1', '1.0b2', '1.0b3', '1.0b4', '1.0RC1', '1.0RC2', '1.0RC3', '1.0', '1.0.1', '1.0.1.1', '1.0.2b1', '1.0.2', 'Stable1.0ToUnstable1.1');
    65 
    65 
    66 // Basically a list of dependencies, which should be resolved automatically
    66 // Basically a list of dependencies, which should be resolved automatically
    67 // If, for example, upgrading from 1.0b1 to 1.0RC1 requires one extra query that would not
    67 // If, for example, upgrading from 1.0b1 to 1.0RC1 requires one extra query that would not
    68 // normally be required (for whatever reason) then you would add a custom version number to the array under key '1.0b1'.
    68 // normally be required (for whatever reason) then you would add a custom version number to the array under key '1.0b1'.
    69 $deps_list = Array(
    69 $deps_list = Array(
    73     '1.0b4' => Array('1.0RC1'),
    73     '1.0b4' => Array('1.0RC1'),
    74     '1.0RC1' => Array('1.0RC2'),
    74     '1.0RC1' => Array('1.0RC2'),
    75     '1.0RC2' => Array('1.0RC3'),
    75     '1.0RC2' => Array('1.0RC3'),
    76     '1.0RC3' => Array('1.0'),
    76     '1.0RC3' => Array('1.0'),
    77     '1.0' => Array('1.0.1'),
    77     '1.0' => Array('1.0.1'),
    78     '1.0.1' => Array('1.0.1.1')
    78     '1.0.1' => Array('1.0.1.1'),
       
    79     '1.0.1.1' => Array('1.0.2b1'),
       
    80     '1.0.2b1' => Array('Stable1.0ToUnstable1.1'),
       
    81     'Stable1.0ToUnstable1.1' => Array('1.1.1')
    79   );
    82   );
    80 $this_version   = '1.0.2b1';
    83 $this_version   = '1.1.1';
    81 $func_list = Array(
    84 $func_list = Array(
    82     '1.0' => Array('u_1_0_1_update_del_votes'),
    85     '1.0' => Array('u_1_0_1_update_del_votes'),
    83     '1.0b4' => Array('u_1_0_RC1_update_user_ids', 'u_1_0_RC1_add_admins_to_group', 'u_1_0_RC1_alter_files_table', 'u_1_0_RC1_destroy_session_cookie', 'u_1_0_RC1_set_contact_email', 'u_1_0_RC1_update_page_text'), // ,
    86     '1.0b4' => Array('u_1_0_RC1_update_user_ids', 'u_1_0_RC1_add_admins_to_group', 'u_1_0_RC1_alter_files_table', 'u_1_0_RC1_destroy_session_cookie', 'u_1_0_RC1_set_contact_email', 'u_1_0_RC1_update_page_text'), // ,
    84     // '1.0RC2' => Array('u_1_0_populate_userpage_comments')
    87     // '1.0RC2' => Array('u_1_0_populate_userpage_comments')
    85     '1.0RC3' => Array('u_1_0_RC3_make_users_extra')
    88     '1.0RC3' => Array('u_1_0_RC3_make_users_extra')
   155 $session = new sessionManager();
   158 $session = new sessionManager();
   156 $paths = new pathManager();
   159 $paths = new pathManager();
   157 $session->start();
   160 $session->start();
   158 
   161 
   159 $template = new template_nodb();
   162 $template = new template_nodb();
   160 $template->load_theme('stpatty', 'shamrock', false);
   163 $template->load_theme('oxygen', 'bleu', false);
   161 
   164 
   162 $modestrings = Array(
   165 $modestrings = Array(
   163               'login'      => 'Administrative login',
   166               'login'      => 'Administrative login',
   164               'welcome'    => 'Welcome',
   167               'welcome'    => 'Welcome',
   165               'setversion' => 'Select Enano version',
   168               'setversion' => 'Select Enano version',
   442     }
   445     }
   443     if($session->user_logged_in && $session->user_level >= $ul_admin)
   446     if($session->user_logged_in && $session->user_level >= $ul_admin)
   444     {
   447     {
   445       if(isset($_POST['login']))
   448       if(isset($_POST['login']))
   446       {
   449       {
   447         $session->login_without_crypto($_POST['username'], $_POST['password'], false, $ul_admin);
   450         $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, $ul_admin);
   448         if($session->sid_super)
   451         if($session->sid_super)
   449         {
   452         {
   450           header('Location: upgrade.php?mode=welcome&auth='.$session->sid_super);
   453           header('Location: upgrade.php?mode=welcome&auth='.$session->sid_super);
   451           exit;
   454           exit;
   452         }
   455         }
   459           <th colspan="2">You must re-authenticate to perform this upgrade.</th>
   462           <th colspan="2">You must re-authenticate to perform this upgrade.</th>
   460         </tr>
   463         </tr>
   461         <?php
   464         <?php
   462         if(isset($_POST['login']))
   465         if(isset($_POST['login']))
   463         {
   466         {
   464           echo '<tr><td colspan="2"><p style="color: red;">Login failed. Bad password?</p></td></tr>';
   467           echo '<tr><td colspan="2"><p style="color: red;">Login failed: '. $result['error'] . '</p></td></tr>';
   465         }
   468         }
   466         ?>
   469         ?>
   467         <tr>
   470         <tr>
   468           <td>Username:</td><td><input type="text" name="username" size="30" /></td>
   471           <td>Username:</td><td><input type="text" name="username" size="30" /></td>
   469         </tr>
   472         </tr>
   523     require('config.php');
   526     require('config.php');
   524     
   527     
   525     ?>
   528     ?>
   526     
   529     
   527     <div style="text-align: center; margin-top: 10px;">
   530     <div style="text-align: center; margin-top: 10px;">
   528       <img alt="[ Enano CMS Project logo ]" src="images/enano-artwork/installer-greeting-green.png" style="display: block; margin: 0 auto; padding-left: 134px;" />
   531       <img alt="[ Enano CMS Project logo ]" src="images/enano-artwork/installer-greeting-blue.png" style="display: block; margin: 0 auto; padding-left: 134px;" />
   529       <h2>Welcome to the Enano upgrade wizard</h2>
   532       <h2>Welcome to the Enano upgrade wizard</h2>
   530       <?php
   533       <?php
   531       if ( file_exists('./_nightly.php') )
   534       if ( file_exists('./_nightly.php') )
   532       {
   535       {
   533         echo '<div class="warning-box" style="text-align: left; margin: 10px auto; display: table; width: 60%;"><b>You are about to upgrade to a NIGHTLY BUILD of Enano.</b><br />Nightly builds CANNOT be re-upgraded to the final release. They may also contain serious flaws, security problems, or extraneous debugging information. Continuing this process on a production site is NOT recommended.</div>';
   536         echo '<div class="warning-box" style="text-align: left; margin: 10px auto; display: table; width: 60%;"><b>You are about to upgrade to a NIGHTLY BUILD of Enano.</b><br />Nightly builds CANNOT be re-upgraded to the final release. They may also contain serious flaws, security problems, or extraneous debugging information. Continuing this process on a production site is NOT recommended.</div>';
   617     echo '<p>Preparing for schema execution...';
   620     echo '<p>Preparing for schema execution...';
   618       // Build an array of queries
   621       // Build an array of queries
   619       $schema = file_get_contents('upgrade.sql');
   622       $schema = file_get_contents('upgrade.sql');
   620       
   623       
   621       // Strip out and process version blocks
   624       // Strip out and process version blocks
   622       preg_match_all('#---BEGIN ([0-9A-z\.\-]*?)---'."\n".'(.*?)'."\n".'---END \\1---#is', $schema, $matches);
   625       preg_match_all('#---BEGIN ([0-9A-z\.\-]*?)---'."\n".'((.*?)'."\n)?".'---END \\1---#is', $schema, $matches);
   623       
   626       
   624       $from_list  =& $matches[1];
   627       $from_list  =& $matches[1];
   625       $query_list =& $matches[2];
   628       $query_list =& $matches[3];
   626       
   629       
   627       foreach($matches[0] as $m)
   630       foreach($matches[0] as $m)
   628       {
   631       {
   629         $schema = str_replace($m, '', $schema);
   632         $schema = str_replace($m, '', $schema);
   630       }
   633       }