install/includes/stages/database_post.php
author Dan
Thu, 20 Aug 2009 20:01:55 -0400
changeset 1081 745200a9cc2a
parent 857 f3a5a276208c
child 1227 bdac73ed481e
permissions -rw-r--r--
Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     1
<?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     2
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     3
/*
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 857
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     6
 * Installation package
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     7
 * database_post.php - Database installation, stage 1
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     8
 *
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
     9
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    10
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    11
 *
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    13
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    14
 */
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    15
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    16
if ( !defined('IN_ENANO_INSTALL') )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    17
  die();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    18
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    19
// Start up the DBAL
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    20
require( ENANO_ROOT . '/includes/dbal.php' );
526
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 391
diff changeset
    21
require( ENANO_ROOT . '/includes/sql_parse.php' );
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    22
$dbal = new $driver();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    23
$db_host =& $_POST['db_host'];
857
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
    24
$db_port =& $_POST['db_port'];
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    25
$db_user =& $_POST['db_user'];
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    26
$db_pass =& $_POST['db_pass'];
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    27
$db_name =& $_POST['db_name'];
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    28
$db_prefix =& $_POST['table_prefix'];
352
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    29
$db_root_user =& $_POST['db_root_user'];
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    30
$db_root_pass =& $_POST['db_root_pass'];
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    31
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    32
if ( !preg_match('/^[a-z0-9_]*$/', $db_prefix) )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    33
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    34
  $ui->show_header();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    35
  echo '<p>That table prefix isn\'t going to work.</p>';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    36
  return true;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    37
}
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    38
857
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
    39
$result = $dbal->connect(true, $db_host, $db_user, $db_pass, $db_name, $db_port);
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    40
352
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    41
// If connection failed, we have the root login, AND we're on MySQL, try to force our way in
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    42
if ( !$result && !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) && $driver == 'mysql' )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    43
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    44
  // Allow a jump / breakout
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    45
  switch ( 'foo' ) { case 'foo':
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    46
      
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    47
    // Try to connect to the DB as root
857
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
    48
    $result_root = $dbal->connect(true, $db_host, $db_root_user, $db_root_pass, 'mysql', $db_port);
352
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    49
    if ( !$result_root )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    50
      break;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    51
    
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    52
    $q = $dbal->sql_query('CREATE DATABASE IF NOT EXISTS `' . $dbal->escape($db_name) . '`;');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    53
    if ( !$q )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    54
      break;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    55
    
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    56
    if ( $db_host == 'localhost' || $db_host == '127.0.0.1' )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    57
    {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    58
      $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'localhost\'' . "\n" .
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    59
                            '  IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    60
    }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    61
    else
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    62
    {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    63
      $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'%\'' . "\n" .
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    64
                            '  IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    65
    }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    66
    
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    67
    if ( !$q )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    68
      break;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    69
    
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    70
    $dbal->close();
857
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
    71
    $result = $dbal->connect(true, $db_host, $db_user, $db_pass, $db_name, $db_port);
352
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    72
      
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    73
    break;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    74
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    75
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    76
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    77
$ui->show_header();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    78
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    79
if ( $result )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    80
{
352
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    81
  // We're good, do table drop if requested
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    82
  if ( isset($_POST['drop_tables']) )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    83
  {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    84
    global $system_table_list;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    85
    foreach ( $system_table_list as $table )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    86
    {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    87
      $dbal->sql_query("DROP TABLE {$db_prefix}$table");
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    88
    }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    89
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents: 348
diff changeset
    90
  // Write out a config file
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    91
  $ch = @fopen( ENANO_ROOT . '/config.new.php', 'w' );
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    92
  if ( !$ch )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    93
  {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    94
    ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    95
    <form action="install.php?stage=database" method="post" name="database_info">
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    96
      <h3>Configuration file generation failed.</h3>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    97
      <p>Couldn't open the configuration file to write out database settings. Check your file permissions.</p>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
    98
      <p>
391
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
    99
        <input type="submit" name="_cont" value="<?php echo $lang->get('database_btn_go_back'); ?>" />
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   100
      </p>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   101
    </form>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   102
    <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   103
    return true;
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   104
  }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   105
  $db_host = str_replace("'", "\\'", $db_host);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   106
  $db_user = str_replace("'", "\\'", $db_user);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   107
  $db_pass = str_replace("'", "\\'", $db_pass);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   108
  $db_name = str_replace("'", "\\'", $db_name);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   109
  $db_prefix = str_replace("'", "\\'", $db_prefix);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   110
  if ( !preg_match('/^[a-z0-9_]*$/', $db_prefix) )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   111
  {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   112
    echo '<p>That table prefix isn\'t going to work.</p>';
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   113
    return true;
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   114
  }
857
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
   115
  if ( !preg_match('/^[0-9]*$/', $db_port) )
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
   116
  {
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
   117
    echo '<p>That port isn\'t going to work.</p>';
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
   118
    return true;
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
   119
  }
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   120
  fwrite($ch, "<?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   121
// Enano temporary configuration file, will be OVERWRITTEN after installation.
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   122
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   123
\$dbdriver = '$driver';
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   124
\$dbhost = '$db_host';
857
f3a5a276208c Added support for alternate port numbers on database servers. Also in install-cli, merged in new sysreqs functionality.
Dan
parents: 801
diff changeset
   125
\$dbport = $db_port;
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   126
\$dbname = '$db_name';
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   127
\$dbuser = '$db_user';
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   128
\$dbpasswd = '$db_pass';
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   129
@define('table_prefix', '$db_prefix');
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   130
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   131
@define('ENANO_INSTALL_HAVE_CONFIG', 1);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   132
");
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   133
  fclose($ch);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   134
  // Create the config table
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   135
  try
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   136
  {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   137
    $sql_parser = new SQL_Parser( ENANO_ROOT . "/install/schemas/{$driver}_stage1.sql" );
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   138
  }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   139
  catch ( Exception $e )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   140
  {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   141
    ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   142
    <h3>Can't load schema file</h3>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   143
    <p>The SQL schema file couldn't be loaded.</p>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   144
    <?php echo "<pre>$e</pre>"; ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   145
    <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   146
    return true;
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   147
  }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   148
  // Check to see if the config table already exists
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   149
  $q = $dbal->sql_query('SELECT config_name, config_value FROM ' . $db_prefix . 'config LIMIT 1;');
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   150
  if ( !$q )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   151
  {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   152
    $sql_parser->assign_vars(array(
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   153
        'TABLE_PREFIX' => $db_prefix
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   154
      ));
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   155
    $sql = $sql_parser->parse();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   156
    foreach ( $sql as $q )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   157
    {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   158
      if ( !$dbal->sql_query($q) )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   159
      {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   160
        ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   161
        <form action="install.php?stage=database" method="post" name="database_info">
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   162
          <input type="hidden" name="language" value="<?php echo $lang_id; ?>" />
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   163
          <input type="hidden" name="driver" value="<?php echo $driver; ?>" />
391
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   164
          <h3><?php echo $lang->get('database_msg_sql_fail_title'); ?></h3>
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   165
          <p><?php echo $lang->get('database_msg_sql_fail_body'); ?></p>
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   166
          <p><?php echo $lang->get('database_msg_post_fail_desc'); ?>
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   167
            <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   168
            echo $dbal->sql_error();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   169
            ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   170
          </p>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   171
          <p>
391
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   172
            <input type="submit" name="_cont" value="<?php echo $lang->get('database_btn_go_back'); ?>" />
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   173
          </p>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   174
        </form>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   175
        <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   176
        return true;
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   177
      }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   178
    }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   179
  }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   180
  else
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   181
  {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   182
    $dbal->free_result();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   183
    if ( !$dbal->sql_query('DELETE FROM ' . $db_prefix . 'config WHERE config_name = \'install_aes_key\';') )
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   184
    {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   185
      $dbal->_die('install database_post.php trying to remove old AES installer key');
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   186
    }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   187
  }
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   188
  $dbal->close();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   189
  ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   190
  <form action="install.php?stage=website" method="post" name="install_db_post" onsubmit="return verify();">
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   191
  <input type="hidden" name="language" value="<?php echo $lang_id; ?>" />
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   192
  <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   193
  ?>
391
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   194
  <h3><?php echo $lang->get('database_msg_success_title'); ?></h3>
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   195
  <p><?php echo $lang->get('database_msg_success_body'); ?></p>
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   196
  <p><input type="submit" name="_cont" value="<?php echo $lang->get('meta_btn_continue'); ?>" />  <?php echo $lang->get('database_msg_success_redirect'); ?></p>
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   197
  </form>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   198
  <script type="text/javascript">
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   199
    setTimeout(function()
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   200
      {
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   201
        var frm = document.forms.install_db_post;
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   202
        frm.submit();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   203
      }, 200);
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   204
  </script>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   205
  <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   206
}
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   207
else
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   208
{
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   209
  ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   210
  <form action="install.php?stage=database" method="post" name="database_info">
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   211
    <input type="hidden" name="language" value="<?php echo $lang_id; ?>" />
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   212
    <input type="hidden" name="driver" value="<?php echo $driver; ?>" />
391
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   213
    <h3><?php echo $lang->get('database_msg_post_fail_title'); ?></h3>
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   214
    <p><?php echo $lang->get('database_msg_post_fail_body'); ?></p>
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   215
    <p><?php echo $lang->get('database_msg_post_fail_desc'); ?>
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   216
      <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   217
      echo $dbal->sql_error();
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   218
      ?>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   219
    </p>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   220
    <p>
391
85f91037cd4f Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents: 352
diff changeset
   221
      <input type="submit" name="_cont" value="<?php echo $lang->get('database_btn_go_back'); ?>" />
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   222
    </p>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   223
  </form>
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   224
  <?php
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   225
}
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff changeset
   226