install/upgrade.php
changeset 377 bb3e6c3bd4f4
parent 354 979d99a0b00e
child 411 d1a95497b68f
equal deleted inserted replaced
376:66732bd4532c 377:bb3e6c3bd4f4
    14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    15  */
    15  */
    16 
    16 
    17 define('IN_ENANO', 1);
    17 define('IN_ENANO', 1);
    18 
    18 
       
    19 // Turn on every imaginable API hack to make common load on older databases
       
    20 define('IN_ENANO_UPGRADE', 1);
       
    21 define('IN_ENANO_MIGRATION', 1);
       
    22 define('ENANO_ALLOW_LOAD_NOLANG', 1);
       
    23 @ini_set('display_errors', 'on');
       
    24 
       
    25 require('includes/sql_parse.php');
       
    26 
       
    27 require_once('includes/common.php');
       
    28 // when the installer's common is loaded, it runs chdir() to the ENANO_ROOT, thus making this Enano's common.php
    19 require_once('includes/common.php');
    29 require_once('includes/common.php');
    20 @ini_set('display_errors', 'on');
    30 @ini_set('display_errors', 'on');
    21 
    31 
    22 $ui = new Enano_Installer_UI('Enano upgrader', false);
    32 $ui = new Enano_Installer_UI('Enano upgrader', false);
    23 if ( version_compare(PHP_VERSION, '5.0.0', '<') )
    33 if ( version_compare(PHP_VERSION, '5.0.0', '<') )
    68   
    78   
    69   $ui->show_footer();
    79   $ui->show_footer();
    70   exit(0);
    80   exit(0);
    71 }
    81 }
    72 
    82 
       
    83 // Version check
       
    84 if ( enano_version() == installer_enano_version() )
       
    85 {
       
    86   $ui->show_header();
       
    87   echo '<h3>Already upgraded</h3>' . '<p>You don\'t need to migrate, you\'re already on <del>crack</del> the 1.1 platform.</p>';
       
    88   $ui->show_footer();
       
    89   exit();
       
    90 }
       
    91 
       
    92 // Start session manager
       
    93 $session->start();
       
    94 if ( !$session->user_logged_in || ( $session->user_logged_in && $session->auth_level < USER_LEVEL_ADMIN ) )
       
    95 {
       
    96   if ( isset($_POST['do_login']) )
       
    97   {
       
    98     if ( !$session->user_logged_in )
       
    99     {
       
   100       $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_MEMBER);
       
   101     }
       
   102     $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_ADMIN);
       
   103     if ( $result['success'] )
       
   104     {
       
   105       header('HTTP/1.1 302 Some kind of redirect with implied no content');
       
   106       header('Location: ' . scriptPath . '/install/' . $session->append_sid('upgrade.php'));
       
   107       exit();
       
   108     }
       
   109   }
       
   110   
       
   111   $ui->show_header();
       
   112   
       
   113   ?>
       
   114   <h3>Authentication needed</h3>
       
   115   <?php
       
   116   
       
   117   echo '<form action="upgrade.php" method="post">';
       
   118   
       
   119   if ( isset($result) )
       
   120   {
       
   121     echo '<b>Session manager returned error: ' . $result['error'] . '</b>';
       
   122   }
       
   123   
       
   124   ?>
       
   125   <p>You need an active admin session to continue.</p>
       
   126   <p>
       
   127     Username:&nbsp;&nbsp;&nbsp;<input type="text" name="username" /><br />
       
   128     Password:&nbsp;&nbsp;&nbsp;<input type="password" name="password" /><br />
       
   129     <input type="submit" name="do_login" value="Log in" />
       
   130   </p>
       
   131   <?php
       
   132   
       
   133   echo '</form>';
       
   134   
       
   135   $ui->show_footer();
       
   136   exit();
       
   137 }
       
   138 
       
   139 // The real migration code
    73 $ui->show_header();
   140 $ui->show_header();
       
   141 
       
   142 if ( isset($_GET['stage']) && @$_GET['stage'] == 'pimpmyenano' )
       
   143 {
       
   144   require('install/schemas/upgrade/migration/1.0-1.1.php');
       
   145   if ( MIGRATE() )
       
   146   {
       
   147     echo '<p>Enano survived the migration. Congratulations, you\'re one of the lucky ones, <a href="' . scriptPath . '/index.php">check out the alpha</a>.</p>';
       
   148   }
       
   149   else
       
   150   {
       
   151     echo '<p>Something went wrong, you should have gotten an error message.</p>';
       
   152   }
       
   153 }
       
   154 else
       
   155 {
       
   156   ?>
       
   157   <p>Nothing's really implemented for now except the actual migration code, which is not very smart. Just <a href="<?php echo $session->append_sid('upgrade.php?stage=pimpmyenano'); ?>">do the upgrade and get it over with</a>.</p>
       
   158   <?php
       
   159 }
       
   160 
    74 $ui->show_footer();
   161 $ui->show_footer();
    75 
   162