install/upgrade.php
changeset 568 3700f7124c2b
parent 536 218a627eb53e
child 626 be0e904eec17
equal deleted inserted replaced
567:7f196509bf78 568:3700f7124c2b
    31 require_once('../includes/sql_parse.php');
    31 require_once('../includes/sql_parse.php');
    32 require_once('includes/common.php');
    32 require_once('includes/common.php');
    33 require_once('includes/libenanoinstall.php');
    33 require_once('includes/libenanoinstall.php');
    34 
    34 
    35 // when the installer's common is loaded, it runs chdir() to the ENANO_ROOT, thus making this Enano's common.php
    35 // when the installer's common is loaded, it runs chdir() to the ENANO_ROOT, thus making this Enano's common.php
       
    36 // PHP5 notice removed in 1.1.4 since the existing common is loaded and that loads lang and json2, which will
       
    37 // give syntax errors on PHP4. So much for that. The installer will warn about this anyway.
    36 require_once('includes/common.php');
    38 require_once('includes/common.php');
    37 @ini_set('display_errors', 'on');
    39 @ini_set('display_errors', 'on');
    38 
    40 
    39 $ui = new Enano_Installer_UI('Enano upgrader', false);
    41 $ui = new Enano_Installer_UI('Enano upgrader', false);
    40 if ( version_compare(PHP_VERSION, '5.0.0', '<') )
    42 
    41 {
       
    42   $ui->__construct('Enano upgrader', false);
       
    43 }
       
    44 $stg_welcome = $ui->add_stage('Welcome', true);
    43 $stg_welcome = $ui->add_stage('Welcome', true);
    45 $stg_confirm = $ui->add_stage('Confirmation', true);
    44 $stg_confirm = $ui->add_stage('Confirmation', true);
    46 $stg_upgrade = $ui->add_stage('Perform upgrade', true);
    45 $stg_upgrade = $ui->add_stage('Perform upgrade', true);
    47 $stg_finish  = $ui->add_stage('Finish', true);
    46 $stg_finish  = $ui->add_stage('Finish', true);
    48 $stg_php4 = $ui->add_stage('PHP4 compatibility notice', false);
    47 
    49 
    48 // init languages
    50 if ( version_compare(PHP_VERSION, '5.0.0', '<') || isset($_GET['debug_warn_php4']) )
    49 $lang_id_list = array_keys($languages);
    51 {
    50 $lang_id = $lang_id_list[0];
    52   $ui->set_visible_stage($stg_php4);
    51 $language_dir = $languages[$lang_id]['dir'];
    53   $ui->step = '';
    52 
    54   
    53 // load the language file
    55   $ui->show_header();
    54 $lang = new Language($lang_id);
    56   
    55 $lang->load_file(ENANO_ROOT . '/language/' . $language_dir . '/install.json');
    57   // This isn't localized because all localization code is dependent on
    56 $lang->load_file(ENANO_ROOT . '/language/' . $language_dir . '/user.json');
    58   // PHP 5 (loading lang.php will throw a parser error under PHP4). This
       
    59   // one message probably doesn't need to be localized anyway.
       
    60   
       
    61   ?>
       
    62   <h2 class="heading-error">
       
    63     Your server doesn't have support for PHP 5.
       
    64   </h2>
       
    65   <p>
       
    66     PHP 5 is the latest version of the language on which Enano was built. Its many new features have been available since early 2004, yet
       
    67     many web hosts have not migrated to it because of the work involved. In 2007, Zend Corporation announced that support for the aging
       
    68     PHP 4.x would be discontinued at the end of the year. An initiative called <a href="http://gophp5.org/">GoPHP5</a> was started to
       
    69     encourage web hosts to migrate to PHP 5.
       
    70   </p>
       
    71   <p>
       
    72     Because of the industry's decision to not support PHP 4 any longer, the Enano team decided that it was time to begin using the powerful
       
    73     features of PHP 5 at the expense of PHP 4 compatibility. Therefore, this version of Enano cannot be installed on your server until it
       
    74     is upgraded to at least PHP 5.0.0, and preferably the latest available version.
       
    75     <!-- No, not even removing the check in this installer script will help. As soon as the PHP4 check is passed, the installer shows the
       
    76          language selection page, after which the language code is loaded. The language code and libjson2 will trigger parse errors under
       
    77          PHP <5.0.0. -->
       
    78   </p>
       
    79   <p>
       
    80     If you need to use Enano but can't upgrade your PHP because you're on a shared or reseller hosting service, you can use the
       
    81     <a href="http://enanocms.org/download?series=1.0">1.0.x series of Enano</a> on your site. While the Enano team attempts to make this
       
    82     older series work on PHP 4, official support is not provided for installations of Enano on PHP 4.
       
    83   </p>
       
    84   <?php
       
    85   
       
    86   $ui->show_footer();
       
    87   exit(0);
       
    88 }
       
    89 
    57 
    90 // Version check
    58 // Version check
    91 if ( enano_version() == installer_enano_version() )
    59 if ( enano_version() == installer_enano_version() )
    92 {
    60 {
    93   $ui->show_header();
    61   $ui->show_header();
   104   {
    72   {
   105     if ( !$session->user_logged_in )
    73     if ( !$session->user_logged_in )
   106     {
    74     {
   107       $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_MEMBER);
    75       $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_MEMBER);
   108     }
    76     }
   109     $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_ADMIN);
    77     if ( !isset($result) || ( isset($result) && $result['success']) )
   110     if ( $result['success'] )
       
   111     {
    78     {
   112       header('HTTP/1.1 302 Some kind of redirect with implied no content');
    79       $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_ADMIN);
   113       header('Location: ' . scriptPath . '/install/' . $session->append_sid('upgrade.php'));
    80       if ( $result['success'] )
   114       exit();
    81       {
       
    82         header('HTTP/1.1 302 Some kind of redirect with implied no content');
       
    83         header('Location: ' . scriptPath . '/install/' . $session->append_sid('upgrade.php'));
       
    84         exit();
       
    85       }
   115     }
    86     }
   116   }
    87   }
   117   
    88   
   118   $ui->show_header();
    89   $ui->show_header();
   119   
    90   
   120   ?>
    91   ?>
   121   <h3>Authentication needed</h3>
    92   <h3><?php echo $lang->get('upgrade_login_msg_auth_needed_title'); ?></h3>
   122   <?php
    93   <?php
   123   
    94   
   124   echo '<form action="upgrade.php" method="post">';
    95   echo '<form action="upgrade.php" method="post">';
   125   
    96   
   126   if ( isset($result) )
    97   if ( isset($result) )
   127   {
    98   {
   128     echo '<b>Session manager returned error:</b>' . '<pre>' . print_r($result, true) . '</pre>';
    99     echo '<b>' . $lang->get('upgrade_login_err_failed', array('error_code' => $result['error'])) . '</b>';
   129   }
   100   }
   130   
   101   
   131   ?>
   102   ?>
   132   <p>You need <?php if ( !$session->user_logged_in ) echo 'to be logged in and have '; ?>an active admin session to continue.</p>
   103   <p><?php
   133   <p>
   104   if ( $session->user_logged_in )
   134     Username:&nbsp;&nbsp;&nbsp;<input type="text" name="username" /><br />
   105   {
   135     Password:&nbsp;&nbsp;&nbsp;<input type="password" name="password" /><br />
   106     echo $lang->get('upgrade_login_msg_auth_needed_body_level2');
   136     <input type="submit" name="do_login" value="Log in" />
   107   }
   137   </p>
   108   else
       
   109   {
       
   110     echo $lang->get('upgrade_login_msg_auth_needed_body_level1');
       
   111   }
       
   112   ?></p>
       
   113   <table border="0" cellspacing="0" cellpadding="5" style="margin: 0 auto;">
       
   114   <tr>
       
   115     <td><?php echo $lang->get('user_login_field_username'); ?>:</td>
       
   116     <td><input type="text" name="username" tabindex="1" /></td>
       
   117   </tr>
       
   118   <tr>
       
   119     <td><?php echo $lang->get('user_login_field_password'); ?>:</td>
       
   120     <td><input type="password" name="password" tabindex="2" /></td>
       
   121   </tr>
       
   122   <tr>
       
   123     <td colspan="2" style="text-align: center;">
       
   124       <input type="submit" name="do_login" value="<?php echo $lang->get('upgrade_login_btn_login'); ?>" tabindex="3" />
       
   125     </td>
       
   126   </tr>
       
   127   </table>
   138   <?php
   128   <?php
   139   
   129   
   140   echo '</form>';
   130   echo '</form>';
   141   
   131   
   142   $ui->show_footer();
   132   $ui->show_footer();
   211   echo '<p><b>It is important that you run a language string re-import and then clear your browser cache.</b> Otherwise you may see bits of the interface that appear to not be localized. This process will be automatic and non-destructive in later versions.</p>';
   201   echo '<p><b>It is important that you run a language string re-import and then clear your browser cache.</b> Otherwise you may see bits of the interface that appear to not be localized. This process will be automatic and non-destructive in later versions.</p>';
   212 }
   202 }
   213 else
   203 else
   214 {
   204 {
   215   ?>
   205   ?>
   216   <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>
   206   <h3><?php echo $lang->get('upgrade_confirm_title'); ?></h3>
       
   207   <p><?php echo $lang->get('upgrade_confirm_body', array('enano_version' => installer_enano_version())); ?></p>
       
   208   <ul>
       
   209     <li><?php echo $lang->get('upgrade_confirm_objective_backup_fs', array('dir' => ENANO_ROOT)); ?></li>
       
   210     <li><?php echo $lang->get('upgrade_confirm_objective_backup_db', array('dbname' => $dbname)); ?></li>
       
   211   </ul>
       
   212   <form method="get" action="upgrade.php" style="text-align: center;">
       
   213     <input type="hidden" name="auth" value="<?php echo $session->sid_super; ?>" />
       
   214     <button name="stage" value="pimpmyenano" class="submit">
       
   215       <img src="images/icons/pimp.png" />
       
   216       <?php echo $lang->get('upgrade_confirm_btn_upgrade'); ?>
       
   217     </button>
       
   218   </form>
   217   <?php
   219   <?php
   218 }
   220 }
   219 
   221 
   220 $ui->show_footer();
   222 $ui->show_footer();
   221 
   223