b2evolution PHP Cross Reference Blogging Systems

Source: /install/index.php - 911 lines - 38039 bytes - Text - Print

Description: This is the main install menu IF YOU ARE READING THIS IN YOUR WEB BROWSER, IT MEANS THAT PHP IS NOT PROPERLY INSTALLED ON YOUR WEB SERVER. IF YOU DON'T KNOW WHAT THIS MEANS, CONTACT YOUR SERVER ADMINISTRATOR OR YOUR HOSTING COMPANY.

   1  <?php
   2  /**
   3   * This is the main install menu
   4   *
   5   * IF YOU ARE READING THIS IN YOUR WEB BROWSER, IT MEANS THAT PHP IS NOT PROPERLY INSTALLED
   6   * ON YOUR WEB SERVER. IF YOU DON'T KNOW WHAT THIS MEANS, CONTACT YOUR SERVER ADMINISTRATOR
   7   * OR YOUR HOSTING COMPANY.
   8   *
   9   * b2evolution - {@link http://b2evolution.net/}
  10   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  11   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  12   *
  13   * @package install
  14   */
  15  
  16  // Turn off the output buffering to do the correct work of the function flush()
  17  @ini_set( 'output_buffering', 'off' );
  18  
  19  /**
  20   * include config and default functions:
  21   */
  22  require_once dirname(__FILE__).'/../conf/_config.php';
  23  
  24  // Make the includes believe they are being called in the right place...
  25  define( 'EVO_MAIN_INIT', true );
  26  
  27  /**
  28   * Define that we're in the install process.
  29   */
  30  define( 'EVO_IS_INSTALLING', true );
  31  
  32  // Force to display errors during install/upgrade, even when not in debug mode
  33  $display_errors_on_production = true;
  34  
  35  $script_start_time = time();
  36  $localtimenow = $script_start_time; // used e.g. for post_datemodified (sample posts)
  37  
  38  if( ! $config_is_done )
  39  {    // Base config is not done yet, try to guess some values needed for correct display:
  40      $rsc_url = '../rsc/';
  41  }
  42  
  43  require_once $inc_path.'_core/_class'.floor(PHP_VERSION).'.funcs.php';
  44  require_once $inc_path.'_core/_misc.funcs.php';
  45  
  46  /**
  47   * Load locale related functions
  48   */
  49  require_once $inc_path.'locales/_locale.funcs.php';
  50  
  51  load_class( '_core/model/_log.class.php', 'Log');
  52  $Debuglog = new Log();
  53  load_class( '_core/model/_messages.class.php', 'Messages');
  54  $Messages = new Messages();
  55  
  56  /**
  57   * Load modules.
  58   *
  59   * This initializes table name aliases and is required before trying to connect to the DB.
  60   */
  61  load_class( '_core/model/_module.class.php', 'Module' );
  62  foreach( $modules as $module )
  63  {
  64      require_once $inc_path.$module.'/_'.$module.'.init.php';
  65  }
  66  
  67  // fp> TODO: we may want to try to get the base init into here somehow
  68  // $require_base_config = false;
  69  
  70  require_once $conf_path.'_upgrade.php';
  71  // no longer exists: require_once $inc_path.'_vars.inc.php';
  72  load_class( '/_core/model/db/_db.class.php', 'DB' );
  73  //load_funcs('collections/model/_blog.funcs.php');
  74  //load_funcs('collections/model/_category.funcs.php');
  75  //load_class( 'items/model/_item.class.php', 'Item' );
  76  //load_funcs('items/model/_item.funcs.php');
  77  //load_funcs('users/model/_user.funcs.php');
  78  //load_funcs( '_core/ui/forms/_form.funcs.php' );
  79  load_class( '_core/model/_timer.class.php', 'Timer' );
  80  //load_class( 'plugins/model/_plugins.class.php', 'Plugins' );
  81  load_funcs( '_core/_url.funcs.php' );
  82  
  83  
  84  require_once dirname(__FILE__).'/_functions_install.php';
  85  
  86  $Timer = new Timer('main');
  87  
  88  load_funcs('_core/_param.funcs.php');
  89  
  90  // Let the modules load/register what they need:
  91  modules_call_method( 'init' );
  92  
  93  
  94  param( 'action', 'string', 'default' );
  95  // check if we should try to connect to db if config is not done
  96  switch( $action )
  97  {
  98      case 'evoupgrade':
  99      case 'auto_upgrade':
 100      case 'svn_upgrade':
 101      case 'newdb':
 102      case 'cafelogupgrade':
 103      case 'deletedb':
 104      case 'menu':
 105      case 'localeinfo':
 106          $try_db_connect = true;
 107          break;
 108      case 'start':
 109      case 'conf':
 110      case 'default':
 111          $try_db_connect = false;
 112          break;
 113      default:
 114          // set a valid action
 115          $action = 'default';
 116          $try_db_connect = false;
 117          break;
 118  }
 119  
 120  $timestamp = time() - 120; // We start dates 2 minutes ago because their dates increase 1 second at a time and we want everything to be visible when the user watches the blogs right after install :P
 121  
 122  // Load all available locale defintions:
 123  locales_load_available_defs();
 124  param( 'locale', 'string' );
 125  $use_locale_from_request = false;
 126  if( preg_match( '/[a-z]{2}-[A-Z]{2}(-.{1,14})?/', $locale ) )
 127  {
 128      $default_locale = $locale;
 129      $use_locale_from_request = true;
 130  }
 131  if( ! empty( $default_locale ) && ! empty( $locales ) && isset( $locales[ $default_locale ] ) )
 132  { // Set correct charset, The main using is for DB connection
 133      $evo_charset = $locales[ $default_locale ]['charset'];
 134  }
 135  
 136  if( $config_is_done || $try_db_connect )
 137  { // Connect to DB:
 138  
 139      $tmp_evoconf_db = $db_config;
 140  
 141      // We want a friendly message if we can't connect:
 142      $tmp_evoconf_db['halt_on_error'] = false;
 143      $tmp_evoconf_db['show_errors'] = false;
 144  
 145      // Make sure we use the proper charset:
 146      $tmp_evoconf_db['connection_charset'] = $evo_charset;
 147  
 148      // CONNECT TO DB:
 149      $DB = new DB( $tmp_evoconf_db );
 150      unset($tmp_evoconf_db);
 151  
 152      if( !$DB->error )
 153      { // restart conf
 154          $DB->halt_on_error = true;  // From now on, halt on errors.
 155          $DB->show_errors = true;    // From now on, show errors (they're helpful in case of errors!).
 156  
 157          // Check MySQL version
 158          $mysql_version = $DB->get_version();
 159          foreach( $required_mysql_version as $key => $value )
 160          { // check required MySQL version for the whole application and for each module
 161              if( version_compare( $mysql_version, $value, '<' ) )
 162              {
 163                  if( $key == 'application' )
 164                  {
 165                      $error_message = sprintf( T_('The minimum requirement for this version of b2evolution is %s version %s but you are trying to use version %s!'), 'MySQL', $value, $mysql_version );
 166                  }
 167                  else
 168                  {
 169                      $error_message = sprintf( T_('The minimum requirement for %s module is %s version %s but you are trying to use version %s!'), $key, 'MySQL', $value, $mysql_version );
 170                  }
 171                  die( '<h1>Insufficient Requirements</h1><div class="error"><p class="error"><strong>'.$error_message.'</strong></p></div>');
 172              }
 173          }
 174      }
 175  }
 176  
 177  if( ! $use_locale_from_request )
 178  { // detect language
 179      // try to check if db already exists and default locale is set on it
 180      $default_locale = get_default_locale_from_db();
 181      if( empty( $default_locale ) )
 182      { // db doesn't exists yet
 183          $default_locale = locale_from_httpaccept();
 184      }
 185      // echo 'detected locale: ' . $default_locale. '<br />';
 186  }
 187  // Activate default locale:
 188  if( ! locale_activate( $default_locale ) )
 189  {    // Could not activate locale (non-existent?), fallback to en-US:
 190      $default_locale = 'en-US';
 191      locale_activate( 'en-US' );
 192  }
 193  
 194  init_charsets( $current_charset );
 195  
 196  switch( $action )
 197  {
 198      case 'evoupgrade':
 199      case 'auto_upgrade':
 200      case 'svn_upgrade':
 201          $title = T_('Upgrade from a previous version');
 202          break;
 203  
 204      case 'newdb':
 205          $title = T_('New Install');
 206          break;
 207  
 208      case 'cafelogupgrade':
 209          $title = T_('Upgrade from Cafelog/b2');
 210          break;
 211  
 212      case 'deletedb':
 213          $title = T_('Delete b2evolution tables');
 214          break;
 215  
 216      case 'start':
 217          $title = T_('Base configuration');
 218          break;
 219  
 220      case 'conf':
 221          $config_is_done = 0;
 222      case 'menu':
 223      case 'localeinfo':
 224      case 'default':
 225          $title = '';
 226          break;
 227  }
 228  
 229  // Add CSS:
 230  require_css( 'basic_styles.css', 'rsc_url' ); // the REAL basic styles
 231  require_css( 'basic.css', 'rsc_url' ); // Basic styles
 232  require_css( 'evo_distrib_2.css', 'rsc_url' );
 233  
 234  header('Content-Type: text/html; charset='.$io_charset);
 235  header('Cache-Control: no-cache'); // no request to this page should get cached!
 236  ?>
 237  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 238  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>"><!-- InstanceBegin template="/Templates/evo_distrib_2.dwt" codeOutsideHTMLIsLocked="false" -->
 239  <head>
 240      <!-- InstanceBeginEditable name="doctitle" -->
 241      <title><?php echo T_('b2evo installer').( $title ? ': '.$title : '' ) ?></title>
 242      <!-- InstanceEndEditable -->
 243      <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $io_charset; ?>" />
 244      <meta name="viewport" content="width = 750" />
 245      <meta name="robots" content="noindex, follow" />
 246      <?php include_headlines() /* Add javascript and css files included by plugins and skin */ ?>
 247      <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
 248      <!-- InstanceParam name="lang" type="text" value="&lt;?php locale_lang() ?&gt;" -->
 249  </head>
 250  
 251  <body>
 252      <!-- InstanceBeginEditable name="BodyHead" --><!-- InstanceEndEditable -->
 253  
 254      <div class="wrapper1">
 255      <div class="wrapper2">
 256          <span class="version_top"><!-- InstanceBeginEditable name="Version" --><?php echo T_('Installer for version ').' '. $app_version ?><!-- InstanceEndEditable --></span>
 257  
 258          <a href="http://b2evolution.net/" target="_blank"><img src="../rsc/img/distrib/b2evolution-logo.gif" alt="b2evolution" width="237" height="92" /></a>
 259  
 260          <div class="menu_top"><!-- InstanceBeginEditable name="MenuTop" -->
 261              <span class="floatright"><?php echo T_('After install') ?>: <a href="../index.php"><?php echo T_('Blogs') ?></a> &middot;
 262              <a href="../<?php echo $dispatcher ?>"><?php echo T_('Admin') ?></a>
 263              </span>
 264          <?php echo T_('Current installation') ?>:
 265          <a href="index.php?locale=<?php echo $default_locale ?>"><?php echo T_('Install menu') ?></a> &middot;
 266          <a href="phpinfo.php"><?php echo T_('PHP info') ?></a>
 267          <!-- InstanceEndEditable --></div>
 268  
 269          <!-- InstanceBeginEditable name="Main" -->
 270  
 271  <?php
 272  
 273  block_open();
 274  
 275  // echo $action;
 276  $date_timezone = ini_get( "date.timezone" );
 277  if( empty( $date_timezone ) && empty( $date_default_timezone ) )
 278  { // The default timezone is not set, display a warning
 279      echo '<div class="error"><p class="error">'.sprintf( T_("No default time zone is set. Please open PHP.ini and set the value of 'date.timezone' (Example: date.timezone = Europe/Paris) or open /conf/_advanced.php and set the value of %s (Example: %s)"), '$date_default_timezone', '$date_default_timezone = \'Europe/Paris\';' ).'</p></div>';
 280  }
 281  
 282  if( ( $config_is_done || $try_db_connect ) && ( $DB->error ) )
 283  { // DB connect was unsuccessful, restart conf
 284      echo '<div class="error"><p class="error">'.T_('Check your database config settings below and update them if necessary...').'</p></div>';
 285      display_base_config_recap();
 286      $action = 'start';
 287  }
 288  
 289  // Check other dependencies:
 290  // TODO: Non-install/upgrade-actions should be allowed (e.g. "deletedb")
 291  if( $req_errors = install_validate_requirements() )
 292  {
 293      echo '<div class="error">';
 294      echo '<p class="error"><strong>'.T_('b2evolution cannot be installed, because of the following errors:').'</strong></p>';
 295      echo '<ul class="error"><li>'.implode( '</li><li>', $req_errors ).'</li></ul>';
 296      echo '</div>';
 297      die;
 298  }
 299  
 300  switch( $action )
 301  {
 302      case 'conf':
 303          /*
 304           * -----------------------------------------------------------------------------------
 305           * Write conf file:
 306           * -----------------------------------------------------------------------------------
 307           */
 308          display_locale_selector();
 309  
 310          block_open();
 311  
 312          param( 'conf_db_user', 'string', true );
 313          param( 'conf_db_password', 'raw', true );
 314          param( 'conf_db_name', 'string', true );
 315          param( 'conf_db_host', 'string', true );
 316          param( 'conf_db_tableprefix', 'string', $tableprefix );
 317          param( 'conf_baseurl', 'string', true );
 318          $conf_baseurl = preg_replace( '#(/)?$#', '', $conf_baseurl ).'/'; // force trailing slash
 319          param( 'conf_admin_email', 'string', true );
 320  
 321          // Connect to DB:
 322          $DB = new DB( array(
 323              'user' => $conf_db_user,
 324              'password' => $conf_db_password,
 325              'name' => $conf_db_name,
 326              'host' => $conf_db_host,
 327              'aliases' => $db_config['aliases'],
 328              'use_transactions' => $db_config['use_transactions'],
 329              'table_options' => $db_config['table_options'],
 330              'connection_charset' => empty( $db_config['connection_charset'] ) ? DB::php_to_mysql_charmap( $evo_charset ) : $db_config['connection_charset'],
 331              'halt_on_error' => false ) );
 332          if( $DB->error )
 333          { // restart conf
 334              echo '<p class="error">'.T_('It seems that the database config settings you entered don\'t work. Please check them carefully and try again...').'</p>';
 335              $action = 'start';
 336          }
 337          else
 338          {
 339              $conf_template_filepath = $conf_path.'_basic_config.template.php';
 340              $conf_filepath = $conf_path.'_basic_config.php';
 341  
 342              // Read original:
 343              $file_loaded = @file( $conf_template_filepath );
 344  
 345              if( empty( $file_loaded ) )
 346              { // This should actually never happen, just in case...
 347                  echo '<div class="error"><p class="error">'.sprintf( T_('Could not load original conf file [%s]. Is it missing?'), $conf_filepath ).'</p></div>';
 348                  break;
 349              }
 350  
 351              // File loaded...
 352              $conf = implode( '', $file_loaded );
 353              // Update conf:
 354              $conf = preg_replace(
 355                  array(
 356                      '#\$db_config\s*=\s*array\(
 357                          \s*[\'"]user[\'"]\s*=>\s*[\'"].*?[\'"],     ([^\n\r]*\r?\n)
 358                          \s*[\'"]password[\'"]\s*=>\s*[\'"].*?[\'"], ([^\n\r]*\r?\n)
 359                          \s*[\'"]name[\'"]\s*=>\s*[\'"].*?[\'"],     ([^\n\r]*\r?\n)
 360                          \s*[\'"]host[\'"]\s*=>\s*[\'"].*?[\'"],     ([^\n\r]*\r?\n)
 361                          #ixs',
 362                      "#tableprefix\s*=\s*'.*?';#",
 363                      "#baseurl\s*=\s*'.*?';#",
 364                      "#admin_email\s*=\s*'.*?';#",
 365                      "#config_is_done\s*=.*?;#",
 366                  ),
 367                  array(
 368                      "\$db_config = array(\n"
 369                          ."\t'user'     => '".str_replace( array( "'", "\$" ), array( "\'", "\\$" ), $conf_db_user )."',\$1"
 370                          ."\t'password' => '".str_replace( array( "'", "\$" ), array( "\'", "\\$" ), $conf_db_password )."',\$2"
 371                          ."\t'name'     => '".str_replace( array( "'", "\$" ), array( "\'", "\\$" ), $conf_db_name )."',\$3"
 372                          ."\t'host'     => '".str_replace( array( "'", "\$" ), array( "\'", "\\$" ), $conf_db_host )."',\$4",
 373                      "tableprefix = '".str_replace( "'", "\'", $conf_db_tableprefix )."';",
 374                      "baseurl = '".str_replace( "'", "\'", $conf_baseurl )."';",
 375                      "admin_email = '".str_replace( "'", "\'", $conf_admin_email )."';",
 376                      'config_is_done = 1;',
 377                  ), $conf );
 378  
 379              // Write new contents:
 380              if( save_to_file( $conf, $conf_filepath, 'w' ) )
 381              {
 382                  printf( '<p>'.T_('Your configuration file [%s] has been successfully created.').'</p>', $conf_filepath );
 383  
 384                  $tableprefix = $conf_db_tableprefix;
 385                  $baseurl = $conf_baseurl;
 386                  $admin_email = $conf_admin_email;
 387                  $config_is_done = 1;
 388                  $action = 'menu';
 389              }
 390              else
 391              {
 392                  ?>
 393                  <h1><?php echo T_('Config file update') ?></h1>
 394                  <p><strong><?php printf( T_('We cannot automatically create or update your config file [%s]!'), $conf_filepath ); ?></strong></p>
 395                  <p><?php echo T_('There are two ways to deal with this:') ?></p>
 396                  <ul>
 397                      <li><strong><?php echo T_('You can allow the installer to create the config file by changing permissions for the /conf directory:') ?></strong>
 398                          <ol>
 399                              <li><?php printf( T_('Make sure there is no existing and potentially locked configuration file named <code>%s</code>. If so, please delete it.'), $conf_filepath ); ?></li>
 400                              <li><?php printf( T_('<code>chmod 777 %s</code>. If needed, see the <a %s>online manual about permissions</a>.'), $conf_path, 'href="http://manual.b2evolution.net/Directory_and_file_permissions" target="_blank"' ); ?></li>
 401                              <li><?php echo T_('Come back to this page and refresh/reload.') ?></li>
 402                          </ol>
 403                          <br />
 404                      </li>
 405                      <li><strong><?php echo T_('Alternatively, you can update the config file manually:') ?></strong>
 406                          <ol>
 407                              <li><?php echo T_('Create a new text file with a text editor.') ?></li>
 408                              <li><?php echo T_('Copy the contents from the box below.') ?></li>
 409                              <li><?php echo T_('Paste them into your local text editor. <strong>ATTENTION: make sure there is ABSOLUTELY NO WHITESPACE after the final <code>?&gt;</code> in the file.</strong> Any space, tab, newline or blank line at the end of the conf file may prevent cookies from being set when you try to log in later.') ?></li>
 410                              <li><?php echo T_('Save the file locally under the name <code>_basic_config.php</code>') ?></li>
 411                              <li><?php echo T_('Upload the file to your server, into the <code>/_conf</code> folder.') ?></li>
 412                              <li><?php printf( T_('<a %s>Call the installer from scratch</a>.'), 'href="index.php?locale='.$default_locale.'"') ?></li>
 413                          </ol>
 414                      </li>
 415                  </ul>
 416                  <p><?php echo T_('This is how your _basic_config.php should look like:') ?></p>
 417                  <blockquote>
 418                  <pre><?php
 419                      echo htmlspecialchars( $conf );
 420                  ?></pre>
 421                  </blockquote>
 422                  <?php
 423                  break;
 424              }
 425          }
 426          // ATTENTION: we continue here...
 427  
 428      case 'start':
 429      case 'default':
 430          /*
 431           * -----------------------------------------------------------------------------------
 432           * Start of install procedure:
 433           * -----------------------------------------------------------------------------------
 434           */
 435          if( $action == 'start' || !$config_is_done )
 436          {
 437              track_step( 'installer-startdb' );
 438  
 439              display_locale_selector();
 440  
 441              block_open();
 442  
 443              echo '<h1>'.T_('Base configuration').'</h1>';
 444  
 445              if( $config_is_done && $allow_evodb_reset != 1 )
 446              {
 447                  echo '<p><strong>'.T_('Resetting the base configuration is currently disabled for security reasons.').'</strong></p>';
 448                  echo '<p>'.sprintf( T_('To enable it, please go to the %s file and change: %s to %s'), '/conf/_basic_config.php', '<pre>$allow_evodb_reset = 0;</pre>', '<pre>$allow_evodb_reset = 1;</pre>' ).'</p>';
 449                  echo '<p>'.T_('Then reload this page and a reset option will appear.').'</p>';
 450                  block_close();
 451                  break;
 452              }
 453              else
 454              {
 455  
 456              // Set default params if not provided otherwise:
 457              param( 'conf_db_user', 'string', $db_config['user'] );
 458              param( 'conf_db_password', 'raw', $db_config['password'] );
 459              param( 'conf_db_name', 'string', $db_config['name'] );
 460              param( 'conf_db_host', 'string', $db_config['host'] );
 461              param( 'conf_db_tableprefix', 'string', $tableprefix );
 462              // Guess baseurl:
 463              // TODO: dh> IMHO HTTP_HOST would be a better default, because it's what the user accesses for install.
 464              //       fp, please change it, if it's ok. SERVER_NAME might get used if HTTP_HOST is not given, but that shouldn't be the case normally.
 465              // fp> ok for change and test after first 3.x-stable release
 466              $baseurl = 'http://'.( isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : 'yourserver.com' );
 467              if( isset( $_SERVER['SERVER_PORT'] ) && ( $_SERVER['SERVER_PORT'] != '80' ) )
 468                  $baseurl .= ':'.$_SERVER['SERVER_PORT'];
 469  
 470              // ############ Get ReqPath & ReqURI ##############
 471              list($ReqPath,$ReqURI) = get_ReqURI();
 472  
 473              $baseurl .= preg_replace( '#/install(/(index.php)?)?$#', '', $ReqPath ).'/';
 474  
 475              param( 'conf_baseurl', 'string', $baseurl );
 476              param( 'conf_admin_email', 'string', $admin_email );
 477  
 478              ?>
 479  
 480              <p><?php echo T_('The basic configuration file (<code>/conf/_basic_config.php</code>) has not been created yet. You can do automatically generate it by filling out the form below.') ?></p>
 481  
 482              <p><?php echo T_('This is the minimum info we need to set up b2evolution on this server:') ?></p>
 483  
 484              <form class="fform" name="form" action="index.php" method="post">
 485                  <input type="hidden" name="action" value="conf" />
 486                  <input type="hidden" name="locale" value="<?php echo $default_locale; ?>" />
 487  
 488                  <fieldset>
 489                      <legend><?php echo T_('Database you want to install into') ?></legend>
 490                      <p class="note"><?php echo T_('b2evolution stores blog posts, comments, user permissions, etc. in a MySQL database. You must create this database prior to installing b2evolution and provide the access parameters to this database below. If you are not familiar with this, you can ask your hosting provider to create the database for you.') ?></p>
 491                      <?php
 492                          form_text( 'conf_db_host', $conf_db_host, 16, T_('MySQL Host/Server'), sprintf( T_('Typically looks like "localhost" or "sql-6" or "sql-8.yourhost.net"...' ) ), 120 );
 493                          form_text( 'conf_db_name', $conf_db_name, 16, T_('MySQL Database'), sprintf( T_('Name of the MySQL database you have created on the server' ) ), 100);
 494                          form_text( 'conf_db_user', $conf_db_user, 16, T_('MySQL Username'), sprintf( T_('Used by b2evolution to access the MySQL database' ) ), 100 );
 495                          form_text( 'conf_db_password', $conf_db_password, 16, T_('MySQL Password'), sprintf( T_('Used by b2evolution to access the MySQL database' ) ), 100 ); // no need to hyde this. nobody installs b2evolution from a public place
 496                          // Too confusing for (most) newbies.    form_text( 'conf_db_tableprefix', $conf_db_tableprefix, 16, T_('MySQL tables prefix'), sprintf( T_('All DB tables will be prefixed with this. You need to change this only if you want to have multiple b2evo installations in the same DB.' ) ), 30 );
 497                      ?>
 498                  </fieldset>
 499  
 500                  <fieldset>
 501                      <legend><?php echo T_('Additional settings') ?></legend>
 502                      <?php
 503                          form_text( 'conf_baseurl', $conf_baseurl, 50, T_('Base URL'), sprintf( T_('This is where b2evo and your blogs reside by default. CHECK THIS CAREFULLY or not much will work. If you want to test b2evolution on your local machine, in order for login cookies to work, you MUST use http://<strong>localhost</strong>/path... Do NOT use your machine\'s name!' ) ), 120 );
 504  
 505                          form_text( 'conf_admin_email', $conf_admin_email, 50, T_('Your email'), sprintf( T_('This is used to create your admin account. You will receive notifications for comments on your blog, etc.' ) ), 80 );
 506                      ?>
 507                  </fieldset>
 508  
 509                  <fieldset>
 510                      <fieldset>
 511                          <div class="input">
 512                              <input type="submit" name="submit" value="<?php echo T_('Update config file') ?>" class="search" />
 513                              <input type="reset" value="<?php echo T_('Reset') ?>" class="search" />
 514                          </div>
 515                      </fieldset>
 516                  </fieldset>
 517  
 518              </form>
 519  
 520              <?php
 521              break;
 522              }
 523          }
 524          // if config was already done, move on to main menu:
 525  
 526      case 'menu':
 527          /*
 528           * -----------------------------------------------------------------------------------
 529           * Menu
 530           * -----------------------------------------------------------------------------------
 531           */
 532          track_step( 'installer-menu' );
 533  
 534          display_locale_selector();
 535  
 536          block_open();
 537          ?>
 538          <h1><?php echo T_('How would you like your b2evolution installed?') ?></h1>
 539  
 540          <?php
 541              $old_db_version = get_db_version();
 542          ?>
 543  
 544          <form action="index.php" method="get">
 545              <input type="hidden" name="locale" value="<?php echo $default_locale ?>" />
 546              <input type="hidden" name="confirmed" value="0" />
 547              <input type="hidden" name="installer_version" value="10" />
 548  
 549              <p><?php echo T_('The installation can be done in different ways. Choose one:')?></p>
 550  
 551              <p><input type="radio" name="action" id="newdb" value="newdb"
 552                  <?php
 553                      // fp> change the above to 'newdbsettings' for an additional settings screen.
 554                      if( is_null($old_db_version) )
 555                      {
 556                          echo 'checked="checked"';
 557                      }
 558                  ?>
 559                  />
 560                  <label for="newdb"><?php echo T_('<strong>New Install</strong>: Install b2evolution database tables.')?></label></p>
 561              <p style="margin-left: 2em;">
 562                  <input type="checkbox" name="create_sample_contents" id="create_sample_contents" value="1" checked="checked" />
 563                  <label for="create_sample_contents"><?php echo T_('Also install sample blogs &amp; sample contents. The sample posts explain several features of b2evolution. This is highly recommended for new users.')?></label>
 564                  <br />
 565                  <?php
 566                      // Pre-check if current installation is local
 567                      $is_local = php_sapi_name() != 'cli' && // NOT php CLI mode
 568                          ( $_SERVER['SERVER_ADDR'] == '127.0.0.1' ||
 569                              $_SERVER['SERVER_ADDR'] == '::1' || // IPv6 address of 127.0.0.1
 570                              $basehost == 'localhost' ||
 571                              $_SERVER['REMOTE_ADDR'] == '127.0.0.1' ||
 572                              $_SERVER['REMOTE_ADDR'] == '::1' );
 573                  ?>
 574                  <input type="checkbox" name="local_installation" id="local_installation" value="1"<?php echo $is_local ? ' checked="checked"' : ''; ?> />
 575                  <label for="local_installation"><?php echo T_('This is a local / test / intranet installation.')?></label>
 576                  <?php
 577                      if( $test_install_all_features )
 578                      {    // Checkbox to install all features
 579                  ?>
 580                  <br />
 581                  <input type="checkbox" name="install_all_features" id="install_all_features" value="1" />
 582                  <label for="install_all_features"><?php echo T_('Also install all test features.')?></label>
 583                  <?php } ?>
 584              </p>
 585  
 586              <p><input type="radio" name="action" id="evoupgrade" value="evoupgrade"
 587                  <?php if( !is_null($old_db_version) && $old_db_version < $new_db_version )
 588                      {
 589                          echo 'checked="checked"';
 590                      }
 591                  ?>
 592                  />
 593                  <label for="evoupgrade"><?php echo T_('<strong>Upgrade from a previous version of b2evolution</strong>: Upgrade your b2evolution database tables in order to make them compatible with the current version. <strong>WARNING:</strong> If you have modified your database, this operation may fail. Make sure you have a backup.') ?></label></p>
 594  
 595              <?php
 596                  if( $allow_evodb_reset == 1 )
 597                  {
 598                      ?>
 599                      <p><input type="radio" name="action" id="deletedb" value="deletedb" />
 600                      <label for="deletedb"><strong><?php echo T_('Delete b2evolution tables &amp; cache files')?></strong>:
 601                      <?php echo T_('If you have installed b2evolution tables before and wish to start anew, you must delete the b2evolution tables before you can start a new installation. <strong>WARNING: All your b2evolution tables and data will be lost!!!</strong> Any non-b2evolution tables will remain untouched though.')?></label></p>
 602  
 603                      <p><input type="radio" name="action" id="start" value="start" />
 604                      <label for="start"><?php echo T_('<strong>Change your base configuration</strong> (see recap below): You only want to do this in rare occasions where you may have moved your b2evolution files or database to a different location...')?></label></p>
 605                      <?php
 606                  }
 607  
 608  
 609              if( $allow_evodb_reset != 1 )
 610              {
 611                  echo '<div class="floatright"><a href="index.php?action=deletedb&amp;locale='.$default_locale.'">'.T_('Need to start anew?').' &raquo;</a></div>';
 612              }
 613              ?>
 614  
 615              <p>
 616              <input type="submit" value="&nbsp; <?php echo T_('GO!')?> &nbsp;"
 617                  onclick="var dc = document.getElementById( 'deletedb' ); if( dc && dc.checked ) { if ( confirm( '<?php
 618                      printf( /* TRANS: %s gets replaced by app name, usually "b2evolution" */ TS_( 'Are you sure you want to delete your existing %s tables?\nDo you have a backup?' ), $app_name );
 619                      ?>' ) ) { this.form.confirmed.value = 1; return true; } else return false; }" />
 620              </p>
 621              </form>
 622          <?php
 623  
 624          block_close();
 625  
 626          display_base_config_recap();
 627          break;
 628  
 629      case 'localeinfo':
 630          // Info about getting additional locales.
 631          display_locale_selector();
 632  
 633          block_open();
 634  
 635          // Note: Do NOT make these strings translatable. We are not in the desired language anyways!
 636          ?>
 637          <h2>What if your language is not in the list above?</h2>
 638          <ol>
 639              <li>Go to the <a href="http://b2evolution.net/downloads/language-packs.html" target="_blank">language packs section on b2evolution.net</a>.</li>
 640              <li>Select the version of b2evolution you're trying to install. If it's not available select the closest match (in most cases this should work).</li>
 641              <li>Find your language and click the "Download" link.</li>
 642              <li>Unzip the contents of the downloaded ZIP file.</li>
 643              <li>Upload the new folder (for example es_ES) into the /locales folder on your server. (The /locales folder already contains a few locales such as de_DE, ru_RU, etc.)</li>
 644              <li>Reload this page. The new locale should now appear in the list at the top of this screen. If it doesn't, it means the language pack you installed is not compatible with this version of b2evolution.</li>
 645          </ol>
 646  
 647          <h3>What if there is no language pack to download?</h3>
 648          <p>Nobody has contributed a language pack in your language yet. You could help by providing a translation for your language.</p>
 649          <p>For now, you will have to install b2evolution with a supported language.</p>
 650          <p>Once you get familiar with b2evolution you will be able to <a href="http://b2evolution.net/man/localization" target="_blank">create your own language pack</a> fairly easily.</p>
 651          <p><a href="index.php?locale=<?php echo $default_locale ?>">&laquo; <?php echo T_('Back to install menu') ?></a></p>
 652          <?php
 653          break;
 654  
 655      case 'newdbsettings':
 656          /*
 657           * fp> TODO: Add a screen for additionnal settings:
 658           * - create_sample_contents : to be moved away from main screen
 659           * - admin_email: to be moved out of conf file
 660           * - storage_charset: offer option to FORCE storing data in UTF-8 even if current locale doesn't require it (must be supported by MySQL) -- recommended for multilingual blogs
 661           * - evo_charset: offer option to FORCE handling data internally in UTF-8 even if current locale doesn't require it (requires mbstring) -- not recommended in most situations
 662           */
 663  
 664  
 665      case 'newdb':
 666          /*
 667           * -----------------------------------------------------------------------------------
 668           * NEW DB: install a new b2evolution database.
 669           * -----------------------------------------------------------------------------------
 670           * Note: auto installers should kick in directly at this step and provide all required params.
 671           */
 672          track_step( 'install-start' );
 673  
 674          $test_install_all_features = param( 'install_all_features', 'boolean', false );
 675  
 676          // fp> TODO: this test should probably be made more generic and applied to upgrade too.
 677          $expected_connection_charset = DB::php_to_mysql_charmap($evo_charset);
 678          if( $DB->connection_charset != $expected_connection_charset )
 679          {
 680              echo '<div class="error"><p class="error">'.sprintf( T_('In order to install b2evolution with the %s locale, your MySQL needs to support the %s connection charset.').' (SET NAMES %s)',
 681                  $current_locale, $evo_charset, $expected_connection_charset ).'</p></div>';
 682              // sam2kb> TODO: If something is not supported we can display a message saying "do this and that, enable extension X etc. etc... or switch to a better hosting".
 683              break;
 684          }
 685  
 686          if( $old_db_version = get_db_version() )
 687          {
 688              echo '<p><strong>'.T_('OOPS! It seems b2evolution is already installed!').'</strong></p>';
 689  
 690              if( $old_db_version < $new_db_version )
 691              {
 692                  echo '<p>'.sprintf( T_('Would you like to <a %s>upgrade your existing installation now</a>?'), 'href="?action=evoupgrade"' ).'</p>';
 693              }
 694  
 695              break;
 696          }
 697  
 698          echo '<h2>'.T_('Installing b2evolution...').'</h2>';
 699  
 700          echo '<h2>'.T_('Checking files...').'</h2>';
 701          evo_flush();
 702          // Check for .htaccess:
 703          if( !install_htaccess( false ) )
 704          {    // Exit installation here because the .htaccess file has the some errors
 705              break;
 706          }
 707  
 708          // Here's the meat!
 709          install_newdb();
 710          break;
 711  
 712  
 713      case 'evoupgrade':
 714      case 'auto_upgrade':
 715      case 'svn_upgrade':
 716          /*
 717           * -----------------------------------------------------------------------------------
 718           * EVO UPGRADE: Upgrade data from existing b2evolution database
 719           * -----------------------------------------------------------------------------------
 720           */
 721          track_step( 'upgrade-start' );
 722  
 723          require_once( dirname(__FILE__). '/_functions_evoupgrade.php' );
 724  
 725          echo '<h2>'.T_('Upgrading b2evolution...').'</h2>';
 726  
 727          echo '<h2>'.T_('Checking files...').'</h2>';
 728          evo_flush();
 729          // Check for .htaccess:
 730          if( !install_htaccess( true ) )
 731          {    // Exit installation here because the .htaccess file has the some errors
 732              break;
 733          }
 734  
 735          // Try to obtain some serious time to do some serious processing (5 minutes)
 736          // NOte: this must NOT be in upgrade_b2evo_tables(), otherwise it will mess with the longer setting used by the auto upgrade feature.
 737          if( set_max_execution_time(300) === false )
 738          { // max_execution_time ini setting could not be changed for this script, display a warning
 739              $manual_url = '"http://b2evolution.net/man/blank-or-partial-page" target = "_blank"';
 740              echo '<div class="orange">'.sprintf( T_('WARNING: the max_execution_time is set to %s seconds in php.ini and cannot be increased automatically. This may lead to a PHP <a href=%s>timeout causing the upgrade to fail</a>. If so please post a screenshot to the <a href=%s>forums</a>.'), ini_get( 'max_execution_time' ), $manual_url, '"http://forums.b2evolution.net/"' ).'</div>';
 741          }
 742  
 743          echo '<h2>'.T_('Upgrading data in existing b2evolution database...').'</h2>';
 744          evo_flush();
 745  
 746          $not_evoupgrade = ( $action !== 'evoupgrade' );
 747          if( upgrade_b2evo_tables( $action ) )
 748          {
 749              if( $not_evoupgrade )
 750              { // After successful auto_upgrade or svn_upgrade we must remove files/folder based on the upgrade_policy.conf
 751                  remove_after_upgrade();
 752                  // disable maintenance mode at the end of the upgrade script
 753                  switch_maintenance_mode( false, 'upgrade' );
 754              }
 755              ?>
 756              <p><?php echo T_('Upgrade completed successfully!')?></p>
 757              <p><?php printf( T_('Now you can <a %s>log in</a> with your usual %s username and password.'), 'href="'.$admin_url.'"', 'b2evolution')?></p>
 758              <?php
 759          }
 760          else
 761          {
 762              if( $not_evoupgrade )
 763              { // disable maintenance mode at the end of the upgrade script
 764                  switch_maintenance_mode( false, 'upgrade' );
 765              }
 766              ?>
 767              <p class="red"><?php echo T_('Upgrade failed!')?></p>
 768              <?php
 769          }
 770  
 771          break;
 772  
 773  
 774      case 'deletedb':
 775          /*
 776           * -----------------------------------------------------------------------------------
 777           * DELETE DB: Delete the db structure!!! (Everything will be lost)
 778           * -----------------------------------------------------------------------------------
 779           */
 780          require_once( dirname(__FILE__). '/_functions_delete.php' );
 781  
 782          echo '<h2>'.T_('Deleting b2evolution tables from the datatase...').'</h2>';
 783          evo_flush();
 784  
 785          if( $allow_evodb_reset != 1 )
 786          {
 787              echo T_('If you have installed b2evolution tables before and wish to start anew, you must delete the b2evolution tables before you can start a new installation. b2evolution can delete its own tables for you, but for obvious security reasons, this feature is disabled by default.');
 788              echo '<p>'.sprintf( T_('To enable it, please go to the %s file and change: %s to %s'), '/conf/_basic_config.php', '<pre>$allow_evodb_reset = 0;</pre>', '<pre>$allow_evodb_reset = 1;</pre>' ).'</p>';
 789              echo '<p>'.T_('Then reload this page and a reset option will appear.').'</p>';
 790              echo '<p><a href="index.php?locale='.$default_locale.'">&laquo; '.T_('Back to install menu').'</a></p>';
 791  
 792              break;
 793          }
 794  
 795          if( ! param('confirmed', 'integer', 1) )
 796          {
 797              ?>
 798              <p>
 799              <?php
 800              echo nl2br( htmlspecialchars( sprintf( /* TRANS: %s gets replaced by app name, usually "b2evolution" */ T_( "Are you sure you want to delete your existing %s tables?\nDo you have a backup?" ), $app_name ) ) );
 801              ?>
 802              </p>
 803              <p>
 804              <form class="inline" name="form" action="index.php" method="post">
 805                  <input type="hidden" name="action" value="deletedb" />
 806                  <input type="hidden" name="confirmed" value="1" />
 807                  <input type="hidden" name="locale" value="<?php echo $default_locale; ?>" />
 808                  <input type="submit" value="&nbsp; <?php echo T_('I am sure!')?> &nbsp;" />
 809              </form>
 810  
 811              <form class="inline" name="form" action="index.php" method="get">
 812                  <input type="hidden" name="locale" value="<?php echo $default_locale; ?>" />
 813                  <input type="submit" value="&nbsp; <?php echo T_('CANCEL')?> &nbsp;" />
 814              </form>
 815              </p>
 816              <?php
 817              break;
 818          }
 819  
 820          // Uninstall Plugins
 821          // TODO: fp>> I don't trust the plugins to uninstall themselves correctly. There will be tons of lousy poorly written plugins. All I trust them to do is to crash the uninstall procedure. We want a hardcore brute force uninsall! and most users "may NOT want" to even think about "ma-nu-al-ly" removing something from their DB.
 822          /*
 823                  $DB->show_errors = $DB->halt_on_error = false;
 824                  $Plugins = new Plugins();
 825                  $DB->show_errors = $DB->halt_on_error = true;
 826                  $at_least_one_failed = false;
 827                  foreach( $Plugins->get_list_by_event( 'Uninstall' ) as $l_Plugin )
 828                  {
 829                      $success = $Plugins->call_method( $l_Plugin->ID, 'Uninstall', $params = array( 'unattended' => true ) );
 830                      if( $success === false )
 831                      {
 832                          echo "Failed un-installing plugin $l_Plugin->classname (ID $l_Plugin->ID)...<br />\n";
 833                          $at_least_one_failed = false;
 834                      }
 835                      else
 836                      {
 837                          echo "Uninstalled plugin $l_Plugin->classname (ID $l_Plugin->ID)...<br />\n";
 838                      }
 839                  }
 840                  if( $at_least_one_failed )
 841                  {
 842                      echo "You may want to manually remove left files or DB tables from the failed plugin(s).<br />\n";
 843                  }
 844                  $DB->show_errors = $DB->halt_on_error = true;
 845          */
 846  
 847          /* REMOVE PAGE CACHE */
 848          load_class( '_core/model/_pagecache.class.php', 'PageCache' );
 849  
 850          // Remove general page cache
 851          $PageCache = new PageCache( NULL );
 852          $PageCache->cache_delete();
 853  
 854          // Skip if T_blogs table is already deleted. Note that db_delete() will not throw any errors on missing tables.
 855          if( $DB->query('SHOW TABLES LIKE "T_blogs"') )
 856          {    // Get all blogs
 857              $blogs_SQL = new SQL();
 858              $blogs_SQL->SELECT( 'blog_ID' );
 859              $blogs_SQL->FROM( 'T_blogs' );
 860              $blogs = $DB->get_col( $blogs_SQL->get() );
 861  
 862              foreach( $blogs as $blog_ID )
 863              {
 864                  $BlogCache = & get_BlogCache();
 865                  $Blog = $BlogCache->get_by_ID( $blog_ID );
 866  
 867                  // Remove page cache of current blog
 868                  $PageCache = new PageCache( $Blog );
 869                  $PageCache->cache_delete();
 870              }
 871          }
 872  
 873          /* REMOVE DATABASE */
 874          db_delete();
 875          ?>
 876          <p><?php echo T_('Reset done!')?></p>
 877          <p><a href="index.php?locale=<?php echo $default_locale ?>">&laquo; <?php echo T_('Back to install menu') ?></a></p>
 878          <?php
 879          break;
 880  }
 881  
 882  block_close();
 883  ?>
 884  
 885  <!-- InstanceEndEditable -->
 886      </div>
 887  
 888      <div class="body_fade_out">
 889  
 890      <div class="menu_bottom"><!-- InstanceBeginEditable name="MenuBottom" -->
 891              <?php echo T_('Online resources') ?>: <a href="http://b2evolution.net/" target="_blank"><?php echo T_('Official website') ?></a> &bull; <a href="http://b2evolution.net/about/recommended-hosting-lamp-best-choices.php" target="_blank"><?php echo T_('Find a host') ?></a> &bull; <a href="http://b2evolution.net/man/" target="_blank"><?php echo T_('Manual') ?></a> &bull; <a href="http://forums.b2evolution.net/" target="_blank"><?php echo T_('Forums') ?></a>
 892          <!-- InstanceEndEditable --></div>
 893  
 894      <div class="copyright"><!-- InstanceBeginEditable name="CopyrightTail" -->Copyright &copy; 2003-2014 by Fran&ccedil;ois Planque &amp; others &middot; <a href="http://b2evolution.net/about/license.html" target="_blank">GNU GPL license</a> &middot; <a href="http://b2evolution.net/contact/" target="_blank">Contact</a>
 895          <!-- InstanceEndEditable --></div>
 896  
 897      </div>
 898      </div>
 899  
 900      <!-- InstanceBeginEditable name="BodyFoot" -->
 901      <?php
 902          // We need to manually call debug_info since there is no shutdown function registered during the install process.
 903          // debug_info( true ); // force output of debug info
 904  
 905          // The following comments get checked in the automatic install script of demo.b2evolution.net:
 906  ?>
 907  <!-- b2evo-install-action:<?php echo $action ?> -->
 908  <!-- b2evo-install-end -->
 909      <!-- InstanceEndEditable -->
 910  </body>
 911  <!-- InstanceEnd --></html>

title

Description

title

Description

title

Description

title

title

Body