upgrade.php
changeset 21 663fcf528726
parent 16 64e0d3d4cf14
child 31 dc8741857bde
equal deleted inserted replaced
20:40105681f495 21:663fcf528726
     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 release candidate 3 (Druid)
     5  * Version 1.0 (Banshee)
     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.
    28 }
    28 }
    29 
    29 
    30 global $_starttime, $this_page, $sideinfo;
    30 global $_starttime, $this_page, $sideinfo;
    31 $_starttime = microtime(true);
    31 $_starttime = microtime(true);
    32 
    32 
    33 define('ENANO_ROOT', dirname(__FILE__));
    33 // Determine directory (special case for development servers)
       
    34 if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') )
       
    35 {
       
    36   $filename = str_replace('/repo/', '/', __FILE__);
       
    37 }
       
    38 else
       
    39 {
       
    40   $filename = __FILE__;
       
    41 }
       
    42 
       
    43 define('ENANO_ROOT', dirname($filename));
       
    44 
    34 require(ENANO_ROOT.'/includes/constants.php');
    45 require(ENANO_ROOT.'/includes/constants.php');
    35 
    46 
    36 if(defined('ENANO_DEBUG'))
    47 if(defined('ENANO_DEBUG'))
    37 {
    48 {
    38   require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php');
    49   require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php');
    48 
    59 
    49 // SCRIPT CONFIGURATION
    60 // SCRIPT CONFIGURATION
    50 // Everything related to versions goes here!
    61 // Everything related to versions goes here!
    51 
    62 
    52 // Valid versions to upgrade from
    63 // Valid versions to upgrade from
    53 $valid_versions = Array('1.0b1', '1.0b2', '1.0b3', '1.0b4', '1.0RC1', '1.0RC2');
    64 $valid_versions = Array('1.0b1', '1.0b2', '1.0b3', '1.0b4', '1.0RC1', '1.0RC2', '1.0RC3');
    54 
    65 
    55 // Basically a list of dependencies, which should be resolved automatically
    66 // Basically a list of dependencies, which should be resolved automatically
    56 // If, for example, if 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
    57 // 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'.
    58 $deps_list = Array(
    69 $deps_list = Array(
    59     '1.0b1' => Array('1.0b2'),
    70     '1.0b1' => Array('1.0b2'),
    60     '1.0b2' => Array('1.0b3'),
    71     '1.0b2' => Array('1.0b3'),
    61     '1.0b3' => Array('1.0b4'),
    72     '1.0b3' => Array('1.0b4'),
    62     '1.0b4' => Array('1.0RC1'),
    73     '1.0b4' => Array('1.0RC1'),
    63     '1.0RC1' => Array('1.0RC2')
    74     '1.0RC1' => Array('1.0RC2'),
       
    75     '1.0RC2' => Array('1.0RC3')
    64   );
    76   );
    65 $this_version   = '1.0RC3';
    77 $this_version   = '1.0';
    66 $func_list = Array(
    78 $func_list = Array(
    67     '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') // ,
    79     '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') // ,
    68     // '1.0RC2' => Array('u_1_0_populate_userpage_comments')
    80     // '1.0RC2' => Array('u_1_0_populate_userpage_comments')
    69   );
    81   );
    70 
    82 
   337   }
   349   }
   338 }
   350 }
   339 
   351 
   340 function u_1_0_populate_userpage_comments()
   352 function u_1_0_populate_userpage_comments()
   341 {
   353 {
       
   354   //
       
   355   // UNFINISHED...
       
   356   //
       
   357   
   342   /*
   358   /*
   343   global $db;
   359   global $db;
   344   $q = $db->sql_query('SELECT COUNT(c.comment_id) AS num_comments...');
   360   $q = $db->sql_query('SELECT COUNT(c.comment_id) AS num_comments...');
   345   if ( !$q )
   361   if ( !$q )
   346     $db->_die();
   362     $db->_die();
   474       $template->header();
   490       $template->header();
   475       ?>
   491       ?>
   476       <p>Your version of Enano (<?php echo $v; ?>) can't be upgraded to this version (<?php echo $this_version; ?>).</p>
   492       <p>Your version of Enano (<?php echo $v; ?>) can't be upgraded to this version (<?php echo $this_version; ?>).</p>
   477       <?php
   493       <?php
   478       break;
   494       break;
   479     } elseif($v == '') {
   495     } 
       
   496     else if($v == '')
       
   497     {
   480       // OK, we don't know which version he's running. So we'll cheat ;-)
   498       // OK, we don't know which version he's running. So we'll cheat ;-)
   481       $template->header();
   499       $template->header();
   482       echo "<form action='upgrade.php?mode=confirm&amp;auth={$session->sid_super}' method='post'>";
   500       echo "<form action='upgrade.php?mode=confirm&amp;auth={$session->sid_super}' method='post'>";
   483       ?>
   501       ?>
   484       <p>Sorry, we couldn't detect which version of Enano you're running on your server. Please select which version of Enano you have below, and make absolutely sure that you're correct.</p>
   502       <p>Sorry, we couldn't detect which version of Enano you're running on your server. Please select which version of Enano you have below, and make absolutely sure that you're correct.</p>
   492         <input type="submit" value="Continue" />
   510         <input type="submit" value="Continue" />
   493       </p>
   511       </p>
   494       <?php
   512       <?php
   495       echo `</form>`;
   513       echo `</form>`;
   496       break;
   514       break;
   497     } else {
   515     }
       
   516     else
       
   517     {
   498       header('Location: upgrade.php?mode=confirm&auth='.$session->sid_super);
   518       header('Location: upgrade.php?mode=confirm&auth='.$session->sid_super);
   499     }
   519     }
   500     break;
   520     break;
   501   case "confirm":
   521   case "confirm":
   502     $enano_version = ( isset($_POST['version']) ) ? $_POST['version'] : enano_version();
   522     $enano_version = ( isset($_POST['version']) ) ? $_POST['version'] : enano_version();