includes/payload.php
author Dan
Tue, 29 Jan 2008 17:29:08 -0500
changeset 390 9bcc185dc151
parent 352 9d7225c0db6d
permissions -rw-r--r--
Fixed JSON parser error in installer (caused by magic_quotes_gpc, wouldn't you know) and re-enabled server-side l10n debugging
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
352
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     1
<?php
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     2
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     3
/*
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     5
 * Version 1.1.1
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     6
 * Copyright (C) 2006-2007 Dan Fuhry
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     7
 * Installation package
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     8
 * payload.php - Installer payload (the installation logic)
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
     9
 *
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    10
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    11
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    12
 *
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    14
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    15
 */
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    16
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    17
if ( !defined('IN_ENANO_INSTALL') )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    18
  die();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    19
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    20
return true;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    21
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    22
function stg_sim_good()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    23
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    24
  return true;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    25
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    26
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    27
function stg_sim_bad()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    28
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    29
  return true;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    30
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    31
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    32
function stg_password_decode()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    33
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    34
  global $db;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    35
  static $pass = false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    36
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    37
  if ( $pass )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    38
    return $pass;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    39
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    40
  if ( !isset($_POST['crypt_data']) && !empty($_POST['password']) && $_POST['password'] === $_POST['password_confirm'] )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    41
    $pass = $_POST['password'];
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    42
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    43
  $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    44
  // retrieve encryption key
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    45
  $q = $db->sql_query('SELECT config_value FROM ' . table_prefix . 'config WHERE config_name=\'install_aes_key\';');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    46
  if ( !$q )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    47
    $db->_die();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    48
  if ( $db->numrows() < 1 )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    49
    return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    50
  list($aes_key) = $db->fetchrow_num();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    51
  $aes_key = $aes->hextostring($aes_key);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    52
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    53
  $pass = $aes->decrypt($_POST['crypt_data'], $aes_key, ENC_HEX);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    54
  if ( !$pass )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    55
    return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    56
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    57
  return $pass; // Will be true if the password isn't crapped
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    58
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    59
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    60
function stg_make_private_key()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    61
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    62
  global $db;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    63
  static $site_key = false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    64
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    65
  if ( $site_key )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    66
    return $site_key;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    67
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    68
  // Is there already a key cached in the database?
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    69
  $q = $db->sql_query('SELECT config_value FROM ' . table_prefix . 'config WHERE config_name=\'site_aes_key\';');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    70
  if ( !$q )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    71
    $db->_die();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    72
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    73
  if ( $db->numrows() > 0 )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    74
  {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    75
    list($site_key) = $db->fetchrow_num();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    76
    $db->free_result();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    77
    return $site_key;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    78
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    79
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    80
  $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    81
  // This will use /dev/urandom if possible
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    82
  $site_key = $aes->gen_readymade_key();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    83
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    84
  // Stash it in the database, don't check for errors though because we can always regenerate it
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    85
  $db->sql_query('INSERT INTO ' . table_prefix . 'config ( config_name, config_value ) VALUES ( \'site_aes_key\', \'' . $site_key . '\' );');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    86
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    87
  return $site_key;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    88
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    89
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    90
function stg_load_schema()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    91
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    92
  global $db, $dbdriver, $installer_version;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    93
  static $sql_parser = false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    94
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    95
  if ( is_object($sql_parser) )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    96
    return $sql_parser->parse();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    97
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    98
  $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
    99
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   100
  $site_key = stg_make_private_key();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   101
  $site_key = $aes->hextostring($site_key);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   102
  $admin_pass_clean = stg_password_decode();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   103
  $admin_pass = $aes->encrypt($admin_pass_clean, $site_key, ENC_HEX);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   104
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   105
  unset($admin_pass_clean); // Security
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   106
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   107
  try
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   108
  {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   109
    $sql_parser = new SQL_Parser( ENANO_ROOT . "/install/schemas/{$dbdriver}_stage2.sql" );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   110
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   111
  catch ( Exception $e )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   112
  {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   113
    echo "<pre>$e</pre>";
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   114
    return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   115
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   116
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   117
  $vars = array(
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   118
      'TABLE_PREFIX'         => $_POST['table_prefix'],
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   119
      'SITE_NAME'            => $db->escape($_POST['site_name']),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   120
      'SITE_DESC'            => $db->escape($_POST['site_desc']),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   121
      'COPYRIGHT'            => $db->escape($_POST['copyright']),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   122
      // FIXME: update form
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   123
      'WIKI_MODE'            => ( isset($_POST['wiki_mode']) ? '1' : '0' ),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   124
      'ENABLE_CACHE'         => ( is_writable( ENANO_ROOT . '/cache/' ) ? '1' : '0' ),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   125
      'VERSION'              => $installer_version['version'],
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   126
      'ADMIN_USER'           => $db->escape($_POST['username']),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   127
      'ADMIN_PASS'           => $admin_pass,
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   128
      'ADMIN_EMAIL'          => $db->escape($_POST['email']),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   129
      'REAL_NAME'            => '', // This has always been stubbed.
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   130
      'ADMIN_EMBED_PHP'      => strval(AUTH_DISALLOW),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   131
      'UNIX_TIME'            => strval(time())
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   132
    );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   133
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   134
  $sql_parser->assign_vars($vars);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   135
  return $sql_parser->parse();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   136
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   137
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   138
function stg_deliver_payload()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   139
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   140
  global $db;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   141
  $schema = stg_load_schema();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   142
  foreach ( $schema as $sql )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   143
  {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   144
    if ( !$db->sql_query($sql) )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   145
    {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   146
      echo $db->get_error();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   147
      return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   148
    }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   149
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   150
  return true;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   151
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   152
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   153
function stg_write_config()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   154
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   155
  global $dbhost, $dbuser, $dbpasswd, $dbname, $dbdriver;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   156
  $db_data = array(
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   157
      'host' => str_replace("'", "\\'", $dbhost),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   158
      'user' => str_replace("'", "\\'", $dbuser),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   159
      'pass' => str_replace("'", "\\'", $dbpasswd),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   160
      'name' => str_replace("'", "\\'", $dbname),
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   161
      'tp' => table_prefix,
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   162
      'drv' => $dbdriver
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   163
    );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   164
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   165
  // Retrieves the existing key
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   166
  $site_key = stg_make_private_key();
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   167
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   168
  // Determine contentPath
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   169
  switch ( @$_POST['url_scheme'] )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   170
  {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   171
    case 'standard':
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   172
    default:
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   173
      $sp_append = 'index.php?title=';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   174
      break;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   175
    case 'shortened':
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   176
      $sp_append = 'index.php/';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   177
      break;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   178
    case 'rewrite':
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   179
      $sp_append = '/';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   180
      break;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   181
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   182
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   183
  $scriptpath = scriptPath;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   184
  $contentpath = $scriptpath . $sp_append;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   185
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   186
  $config_file = <<<EOF
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   187
<?php
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   188
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   189
/**
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   190
 * Enano site configuration
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   191
 * NOTE ON EDITING: You should almost never need to change anything in this
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   192
 * file. The only exceptions are when your DB password/other info is changed
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   193
 * or if you are moving your Enano installation to another directory.
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   194
 */
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   195
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   196
//
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   197
// DATABASE INFO
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   198
//
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   199
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   200
// Database type to use, currently mysql and postgresql are supported
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   201
\$dbdriver = '{$db_data['drv']}';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   202
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   203
// Hostname of your database server, probably localhost
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   204
\$dbhost = '{$db_data['host']}';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   205
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   206
// Username used to connect to the database
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   207
\$dbuser = '{$db_data['user']}';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   208
// Database password
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   209
\$dbpasswd = '{$db_data['pass']}';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   210
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   211
// Name of the database
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   212
\$dbname = '{$db_data['name']}';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   213
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   214
//
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   215
// CONSTANTS
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   216
//
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   217
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   218
// if they're already defined, no use re-defining them
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   219
if ( !defined('ENANO_CONSTANTS') )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   220
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   221
  // The prefix for the tables in the database. Useful for holding more than
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   222
  // one Enano installation in the same database.
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   223
  define('table_prefix', '{$db_data['tp']}');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   224
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   225
  // The path to Enano's files on your server, from the document root. If
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   226
  // Enano is installed in your document root this will be blank; installing
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   227
  // Enano in /enano/ will result in "/enano" here, etc.
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   228
  define('scriptPath', '$scriptpath');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   229
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   230
  // The authoritative prefix for pages. This should be very literal: to
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   231
  // generate a URL on the site, the format is basically
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   232
  // contentPath . \$page_name. This is based off of scriptPath and the URL
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   233
  // scheme selected during installation. Pattern:
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   234
  //
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   235
  //    * Standard URLs:  scriptPath . '/index.php?title='
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   236
  //    * Shortened URLs: scriptPath . '/index.php/'
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   237
  //    * mod_rewrite:    scriptPath . '/'
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   238
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   239
  define('contentPath', '$contentpath');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   240
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   241
  // Tell the Enano API that we're installed and that this file is complete
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   242
  define('ENANO_INSTALLED', 'You bet!');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   243
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   244
  define('ENANO_CONSTANTS', '');
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   245
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   246
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   247
// The AES encryption key used to store passwords. We have a very specific
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   248
// reason for doing this; see the rationale at:
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   249
//   http://docs.enanocms.org/Help:Appendix_B
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   250
\$crypto_key = '$site_key';
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   251
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   252
EOF;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   253
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   254
  // Write config file
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   255
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   256
  $ch = @fopen ( ENANO_ROOT . '/config.new.php', 'w' );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   257
  if ( !$ch )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   258
    return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   259
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   260
  fwrite($ch, $config_file);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   261
  fclose($ch);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   262
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   263
  // If we are using mod_rewrite, also append any existing .htaccess
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   264
  if ( @$_POST['url_scheme'] === 'rewrite' )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   265
  {
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   266
    $hh = @fopen ( ENANO_ROOT . '/.htaccess.new', 'w' );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   267
    if ( !$hh )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   268
      return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   269
    $hhc = <<<EOF
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   270
#
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   271
# START ENANO RULES
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   272
#
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   273
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   274
# Enable mod_rewrite
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   275
RewriteEngine on
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   276
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   277
# Don't rewrite if the user requested a real directory or file
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   278
RewriteCond %{REQUEST_FILENAME} !-f
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   279
RewriteCond %{REQUEST_FILENAME} !-d
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   280
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   281
# Main rule - short and sweet
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   282
RewriteRule (.*) index.php?title=\$1 [L,QSA]
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   283
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   284
EOF;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   285
    fwrite($hh, $hhc);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   286
    fclose($hh);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   287
  }
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   288
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   289
  return true;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   290
}
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   291
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   292
function stg_language_setup()
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   293
{
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   294
  global $languages, $db;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   295
  global $lang_id;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   296
  $lang_info =& $languages[$lang_id];
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   297
  if ( !is_array($lang_info) )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   298
    return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   299
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   300
  // Install the language
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   301
  // ($lang_code, $lang_name_neutral, $lang_name_local, $lang_file = false)
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   302
  $result = install_language($lang_id, $lang_info['name_eng'], $lang_info['name'], ENANO_ROOT . "/language/{$lang_info['dir']}/core.json");
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   303
  if ( !$result )
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   304
    return false;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   305
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   306
  $lang_local = new Language($lang_id);
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   307
  $lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/user.json" );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   308
  $lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/tools.json" );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   309
  $lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/admin.json" );
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   310
  
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   311
  return true;
9d7225c0db6d Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
parents:
diff changeset
   312
}