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
801
eb8b23f11744
Two big commits in one day I know, but redid password storage to use HMAC-SHA1. Consolidated much AES processing to three core methods in session that should handle everything automagically. Installation works; upgrades should. Rebranded as 1.1.6.
Dan
diff
changeset
+ − 5
* Version 1.1.6 (Caoineag beta 1)
536
+ − 6
* Copyright (C) 2006-2008 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
+ − 7
* Installation package
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 8
* payload.php - Installer payload (the installation logic)
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 9
*
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
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
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
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.
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 12
*
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
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
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 14
* 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
+ − 15
*/
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 16
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 17
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
+ − 18
die();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 19
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 20
return true;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 21
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 22
function stg_sim_good()
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 23
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 24
return true;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 25
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 26
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 27
function stg_sim_bad()
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 28
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 29
return true;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 30
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 31
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 32
function stg_password_decode()
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 33
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 34
global $db;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 35
static $pass = false;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 36
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 37
if ( $pass )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 38
return $pass;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 39
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 40
if ( !isset($_POST['crypt_data']) && !empty($_POST['password']) && $_POST['password'] === $_POST['password_confirm'] )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 41
$pass = $_POST['password'];
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 42
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 43
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 44
// retrieve encryption key
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 45
$q = $db->sql_query('SELECT config_value FROM ' . table_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
+ − 46
if ( !$q )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 47
$db->_die();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 48
if ( $db->numrows() < 1 )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 49
return false;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 50
list($aes_key) = $db->fetchrow_num();
616
e311f5e6f904
Got the installer working. Fixed a few bugs including a nasty-to-debug issue where the lang_id was being hardcoded during installation, resulting in strings being inserted with the wrong lang_id causing an infinfinite loop with fetch() throwing a "no strings" error and using template (which calls fetch()) to complain
Dan
diff
changeset
+ − 51
$aes_key = hexdecode($aes_key);
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 52
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 53
$pass = $aes->decrypt($_POST['crypt_data'], $aes_key, ENC_HEX);
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 54
if ( !$pass )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 55
return false;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 56
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 57
return $pass; // Will be true if the password isn't crapped
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 58
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 59
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 60
function stg_make_private_key()
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 61
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 62
global $db;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 63
static $site_key = false;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 64
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 65
if ( $site_key )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 66
return $site_key;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 67
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 68
// Is there already a key cached in the database?
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 69
$q = $db->sql_query('SELECT config_value FROM ' . table_prefix . 'config WHERE config_name=\'site_aes_key\';');
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 70
if ( !$q )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 71
$db->_die();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 72
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 73
if ( $db->numrows() > 0 )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 74
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 75
list($site_key) = $db->fetchrow_num();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 76
$db->free_result();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 77
return $site_key;
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
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 80
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 81
// This will use /dev/urandom if possible
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 82
$site_key = $aes->gen_readymade_key();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 83
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 84
// Stash it in the database, don't check for errors though because we can always regenerate it
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 85
$db->sql_query('INSERT INTO ' . table_prefix . 'config ( config_name, config_value ) VALUES ( \'site_aes_key\', \'' . $site_key . '\' );');
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 86
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 87
return $site_key;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 88
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 89
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 90
function stg_load_schema()
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 91
{
351
+ − 92
global $db, $dbdriver, $installer_version, $lang_id, $languages;
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 93
static $sql_parser = false;
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
if ( is_object($sql_parser) )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 96
return $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
+ − 97
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 98
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
801
eb8b23f11744
Two big commits in one day I know, but redid password storage to use HMAC-SHA1. Consolidated much AES processing to three core methods in session that should handle everything automagically. Installation works; upgrades should. Rebranded as 1.1.6.
Dan
diff
changeset
+ − 99
$hmac_secret = hexencode(AESCrypt::randkey(20), '', '');
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 100
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 101
$site_key = stg_make_private_key();
616
e311f5e6f904
Got the installer working. Fixed a few bugs including a nasty-to-debug issue where the lang_id was being hardcoded during installation, resulting in strings being inserted with the wrong lang_id causing an infinfinite loop with fetch() throwing a "no strings" error and using template (which calls fetch()) to complain
Dan
diff
changeset
+ − 102
$site_key = hexdecode($site_key);
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 103
$admin_pass_clean = stg_password_decode();
801
eb8b23f11744
Two big commits in one day I know, but redid password storage to use HMAC-SHA1. Consolidated much AES processing to three core methods in session that should handle everything automagically. Installation works; upgrades should. Rebranded as 1.1.6.
Dan
diff
changeset
+ − 104
$admin_pass = hmac_sha1($admin_pass_clean, $hmac_secret);
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 105
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 106
unset($admin_pass_clean); // Security
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 107
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 108
try
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 109
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 110
$sql_parser = new SQL_Parser( ENANO_ROOT . "/install/schemas/{$dbdriver}_stage2.sql" );
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
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
+ − 113
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 114
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
+ − 115
return false;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 116
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 117
351
+ − 118
$wkt = ENANO_ROOT . "/language/{$languages[$lang_id]['dir']}/install/mainpage-default.wkt";
+ − 119
if ( !file_exists( $wkt ) )
+ − 120
{
+ − 121
echo '<div class="error-box">Error: could not locate wikitext for main page (' . $wkt . ')</div>';
+ − 122
return false;
+ − 123
}
+ − 124
$wkt = @file_get_contents($wkt);
+ − 125
if ( empty($wkt) )
+ − 126
return false;
+ − 127
+ − 128
$wkt = $db->escape($wkt);
+ − 129
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 130
$vars = array(
383
1030864dc319
Fixed SYSMSG tag in templates causing problems; commented out ENANO_DEBUG; fixed bad table prefix in installer payload logic
Dan
diff
changeset
+ − 131
'TABLE_PREFIX' => table_prefix,
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 132
'SITE_NAME' => $db->escape($_POST['site_name']),
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 133
'SITE_DESC' => $db->escape($_POST['site_desc']),
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 134
'COPYRIGHT' => $db->escape($_POST['copyright']),
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 135
// FIXME: update form
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 136
'WIKI_MODE' => ( isset($_POST['wiki_mode']) ? '1' : '0' ),
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 137
'ENABLE_CACHE' => ( is_writable( ENANO_ROOT . '/cache/' ) ? '1' : '0' ),
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 138
'VERSION' => $installer_version['version'],
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 139
'ADMIN_USER' => $db->escape($_POST['username']),
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 140
'ADMIN_PASS' => $admin_pass,
801
eb8b23f11744
Two big commits in one day I know, but redid password storage to use HMAC-SHA1. Consolidated much AES processing to three core methods in session that should handle everything automagically. Installation works; upgrades should. Rebranded as 1.1.6.
Dan
diff
changeset
+ − 141
'ADMIN_PASS_SALT' => $hmac_secret,
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 142
'ADMIN_EMAIL' => $db->escape($_POST['email']),
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 143
'REAL_NAME' => '', // This has always been stubbed.
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 144
'ADMIN_EMBED_PHP' => strval(AUTH_DISALLOW),
351
+ − 145
'UNIX_TIME' => strval(time()),
359
+ − 146
'MAIN_PAGE_CONTENT' => $wkt,
+ − 147
'IP_ADDRESS' => $db->escape($_SERVER['REMOTE_ADDR'])
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 148
);
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 149
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 150
$sql_parser->assign_vars($vars);
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 151
return $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
+ − 152
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 153
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 154
function stg_deliver_payload()
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 155
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 156
global $db;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 157
$schema = stg_load_schema();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 158
foreach ( $schema as $sql )
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
if ( !$db->sql_query($sql) )
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 161
{
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 162
echo $db->get_error();
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 163
return false;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 164
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 165
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 166
return true;
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 167
}
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
+ − 168
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 169
function stg_write_config()
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 170
{
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 171
global $dbhost, $dbuser, $dbpasswd, $dbname, $dbdriver;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 172
$db_data = array(
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 173
'host' => str_replace("'", "\\'", $dbhost),
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 174
'user' => str_replace("'", "\\'", $dbuser),
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 175
'pass' => str_replace("'", "\\'", $dbpasswd),
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 176
'name' => str_replace("'", "\\'", $dbname),
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 177
'tp' => table_prefix,
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 178
'drv' => $dbdriver
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 179
);
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 180
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 181
// Retrieves the existing key
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 182
$site_key = stg_make_private_key();
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 183
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 184
// Determine contentPath
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 185
switch ( @$_POST['url_scheme'] )
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 186
{
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 187
case 'standard':
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 188
default:
386
+ − 189
$sp_append = '/index.php?title=';
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 190
break;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 191
case 'shortened':
386
+ − 192
$sp_append = '/index.php/';
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 193
break;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 194
case 'rewrite':
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 195
$sp_append = '/';
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 196
break;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 197
}
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 198
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 199
$scriptpath = scriptPath;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 200
$contentpath = $scriptpath . $sp_append;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 201
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 202
$config_file = <<<EOF
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 203
<?php
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 204
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 205
/**
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 206
* Enano site configuration
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 207
* NOTE ON EDITING: You should almost never need to change anything in this
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 208
* file. The only exceptions are when your DB password/other info is changed
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 209
* or if you are moving your Enano installation to another directory.
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 210
*/
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 211
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 212
//
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 213
// DATABASE INFO
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 214
//
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 215
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 216
// Database type to use, currently mysql and postgresql are supported
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 217
\$dbdriver = '{$db_data['drv']}';
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 218
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 219
// Hostname of your database server, probably localhost
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 220
\$dbhost = '{$db_data['host']}';
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 221
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 222
// Username used to connect to the database
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 223
\$dbuser = '{$db_data['user']}';
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 224
// Database password
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 225
\$dbpasswd = '{$db_data['pass']}';
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 226
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 227
// Name of the database
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 228
\$dbname = '{$db_data['name']}';
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 229
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 230
//
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 231
// CONSTANTS
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 232
//
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 233
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 234
// if they're already defined, no use re-defining them
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 235
if ( !defined('ENANO_CONSTANTS') )
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 236
{
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 237
// The prefix for the tables in the database. Useful for holding more than
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 238
// one Enano installation in the same database.
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 239
define('table_prefix', '{$db_data['tp']}');
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 240
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 241
// The path to Enano's files on your server, from the document root. If
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 242
// Enano is installed in your document root this will be blank; installing
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 243
// Enano in /enano/ will result in "/enano" here, etc.
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 244
define('scriptPath', '$scriptpath');
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 245
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 246
// The authoritative prefix for pages. This should be very literal: to
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 247
// generate a URL on the site, the format is basically
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 248
// contentPath . \$page_name. This is based off of scriptPath and the URL
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 249
// scheme selected during installation. Pattern:
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 250
//
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 251
// * Standard URLs: scriptPath . '/index.php?title='
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 252
// * Shortened URLs: scriptPath . '/index.php/'
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 253
// * mod_rewrite: scriptPath . '/'
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 254
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 255
define('contentPath', '$contentpath');
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 256
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 257
// Tell the Enano API that we're installed and that this file is complete
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 258
define('ENANO_INSTALLED', 'You bet!');
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 259
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 260
define('ENANO_CONSTANTS', '');
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 261
}
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 262
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 263
// The AES encryption key used to store passwords. We have a very specific
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 264
// reason for doing this; see the rationale at:
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 265
// http://docs.enanocms.org/Help:Appendix_B
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 266
\$crypto_key = '$site_key';
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 267
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 268
EOF;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 269
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 270
// Write config file
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 271
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 272
$ch = @fopen ( ENANO_ROOT . '/config.new.php', 'w' );
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 273
if ( !$ch )
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 274
return false;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 275
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 276
fwrite($ch, $config_file);
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 277
fclose($ch);
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 278
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 279
// If we are using mod_rewrite, also append any existing .htaccess
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 280
if ( @$_POST['url_scheme'] === 'rewrite' )
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 281
{
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 282
$hh = @fopen ( ENANO_ROOT . '/.htaccess.new', 'w' );
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 283
if ( !$hh )
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 284
return false;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 285
$hhc = <<<EOF
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 286
#
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 287
# START ENANO RULES
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 288
#
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 289
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 290
# Enable mod_rewrite
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 291
RewriteEngine on
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 292
819
7ef806a90d44
Installer: add RewriteBase to .htaccess to work properly under aliased Apache setups (generated 404s in QA)
Dan
diff
changeset
+ − 293
# Required under some aliased setups
7ef806a90d44
Installer: add RewriteBase to .htaccess to work properly under aliased Apache setups (generated 404s in QA)
Dan
diff
changeset
+ − 294
RewriteBase $scriptpath
7ef806a90d44
Installer: add RewriteBase to .htaccess to work properly under aliased Apache setups (generated 404s in QA)
Dan
diff
changeset
+ − 295
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 296
# Don't rewrite if the user requested a real directory or file
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 297
RewriteCond %{REQUEST_FILENAME} !-f
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 298
RewriteCond %{REQUEST_FILENAME} !-d
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 299
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 300
# Main rule - short and sweet
351
+ − 301
RewriteRule (.*) index.php?title=\$1 [L,QSA]
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 302
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 303
EOF;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 304
fwrite($hh, $hhc);
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 305
fclose($hh);
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 306
}
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 307
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 308
return true;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 309
}
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 310
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 311
function stg_language_setup()
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 312
{
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 313
global $languages, $db;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 314
global $lang_id;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 315
$lang_info =& $languages[$lang_id];
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 316
if ( !is_array($lang_info) )
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 317
return false;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 318
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 319
// Install the language
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 320
// ($lang_code, $lang_name_neutral, $lang_name_local, $lang_file = false)
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 321
$result = install_language($lang_id, $lang_info['name_eng'], $lang_info['name'], ENANO_ROOT . "/language/{$lang_info['dir']}/core.json");
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 322
if ( !$result )
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 323
return false;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 324
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 325
$lang_local = new Language($lang_id);
616
e311f5e6f904
Got the installer working. Fixed a few bugs including a nasty-to-debug issue where the lang_id was being hardcoded during installation, resulting in strings being inserted with the wrong lang_id causing an infinfinite loop with fetch() throwing a "no strings" error and using template (which calls fetch()) to complain
Dan
diff
changeset
+ − 326
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 327
$lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/user.json" );
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 328
$lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/tools.json" );
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 329
$lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/admin.json" );
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 330
385
+ − 331
$q = $db->sql_query('SELECT lang_id FROM ' . table_prefix . 'language ORDER BY lang_id DESC LIMIT 1;');
+ − 332
if ( !$q )
+ − 333
$db->_die();
+ − 334
+ − 335
list($lang_id_int) = $db->fetchrow_num();
+ − 336
$db->free_result();
+ − 337
setConfig('default_language', $lang_id_int);
+ − 338
349
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 339
return true;
fdaf9070566c
More progress on the installer. At this point it can install and import the language, but does not rename config files. Still much work to be done, most notably localization and creation of MySQL users and databases.
Dan
diff
changeset
+ − 340
}
351
+ − 341
+ − 342
function stg_init_logs()
+ − 343
{
+ − 344
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 345
global $installer_version;
+ − 346
+ − 347
$q = $db->sql_query('INSERT INTO ' . table_prefix . 'logs(log_type,action,time_id,date_string,author,page_text,edit_summary) VALUES(\'security\', \'install_enano\', ' . time() . ', \'' . enano_date('d M Y h:i a') . '\', \'' . $db->escape($_POST['admin_user']) . '\', \'' . $db->escape(enano_version()) . '\', \'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\');');
+ − 348
if ( !$q )
+ − 349
{
+ − 350
echo '<p><tt>MySQL return: ' . $db->sql_error() . '</tt></p>';
+ − 351
return false;
+ − 352
}
+ − 353
+ − 354
return true;
+ − 355
}
+ − 356
352
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 357
function stg_aes_cleanup()
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 358
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 359
global $db, $session, $paths, $template, $plugins; // Common objects
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 360
$q = $db->sql_query('DELETE FROM ' . table_prefix . 'config WHERE config_name = \'install_aes_key\' OR config_name = \'site_aes_key\';');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 361
if ( !$q )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 362
$db->_die();
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 363
return true;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 364
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 365
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 366
function _stg_rename_config_revert()
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 367
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 368
if ( file_exists('./config.php') )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 369
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 370
@rename('./config.php', './config.new.php');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 371
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 372
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 373
$handle = @fopen('./config.php.new', 'w');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 374
if ( !$handle )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 375
return false;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 376
$contents = '<?php $cryptkey = \'' . _INSTRESUME_AES_KEYBACKUP . '\'; ?>';
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 377
fwrite($handle, $contents);
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 378
fclose($handle);
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 379
return true;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 380
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 381
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 382
function stg_build_index()
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 383
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 384
global $db, $session, $paths, $template, $plugins; // Common objects
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 385
if ( $paths->rebuild_search_index() )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 386
return true;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 387
return false;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 388
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 389
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 390
function stg_rename_config()
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 391
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 392
if ( !@rename(ENANO_ROOT . '/config.new.php', ENANO_ROOT . '/config.php') )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 393
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 394
echo '<p>Can\'t rename config.php</p>';
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 395
_stg_rename_config_revert();
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 396
return false;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 397
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 398
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 399
if ( filesize(ENANO_ROOT . '/.htaccess.new') > 1 )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 400
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 401
// rename/possibly concatenate .htaccess.new
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 402
$htaccess_base = '';
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 403
if ( file_exists(ENANO_ROOT . '/.htaccess') )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 404
$htaccess_base .= @file_get_contents(ENANO_ROOT . '/.htaccess');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 405
if ( strlen($htaccess_base) > 0 && !preg_match("/\n$/", $htaccess_base) )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 406
$htaccess_base .= "\n\n";
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 407
$htaccess_base .= @file_get_contents(ENANO_ROOT . '/.htaccess.new');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 408
if ( file_exists(ENANO_ROOT . '/.htaccess') )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 409
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 410
$hh = @fopen(ENANO_ROOT . '/.htaccess', 'w');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 411
if ( !$hh )
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 412
return false;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 413
fwrite($hh, $htaccess_base);
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 414
fclose($hh);
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 415
@unlink(ENANO_ROOT . '/.htaccess.new');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 416
return true;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 417
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 418
else
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 419
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 420
return @rename(ENANO_ROOT . '/.htaccess.new', ENANO_ROOT . '/.htaccess');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 421
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 422
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 423
else
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 424
{
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 425
@unlink(ENANO_ROOT . '/.htaccess.new');
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 426
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 427
return true;
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 428
}
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
+ − 429
626
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 430
/**
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 431
* UPGRADE STAGES
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 432
*/
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 433
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 434
function stg_lang_import()
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 435
{
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 436
global $db, $languages;
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 437
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 438
define('IN_ENANO_UPGRADE_POST', 1);
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 439
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 440
//
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 441
// IMPORT NEW STRINGS
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 442
//
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 443
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 444
// for each installed language, look for the json files in the filesystem and if they're ok, import new strings from them
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 445
$q = $db->sql_query('SELECT lang_id, lang_code FROM ' . table_prefix . "language;");
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 446
if ( !$q )
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 447
$db->_die();
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 448
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 449
while ( $row = $db->fetchrow($q) )
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 450
{
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 451
if ( isset($languages[$row['lang_code']]) )
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 452
{
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 453
// found a language and it's good on the filesystem; load it and call a reimport
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 454
$lang_local = new Language($row['lang_id']);
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 455
// call fetch to make sure we're up to date
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 456
$lang_local->fetch();
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 457
// import
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 458
foreach ( array('core', 'admin', 'user', 'tools') as $language_file )
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 459
{
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 460
// generate full path
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 461
$language_file = ENANO_ROOT . "/language/{$languages[$row['lang_code']]['dir']}/$language_file.json";
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 462
// setting the second parameter to bool(true) causes it to skip existing strings
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 463
if ( !$lang_local->import($language_file, true) )
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 464
// on failure, report failure to libenanoinstall
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 465
return false;
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 466
}
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 467
// unload this lang_local object to save memory
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 468
unset($lang_local);
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 469
}
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 470
}
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 471
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 472
return true;
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 473
}
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 474
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 475
function stg_flush_cache()
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 476
{
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 477
return purge_all_caches();
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 478
}
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 479
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 480
function stg_set_version()
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 481
{
627
+ − 482
global $db, $session, $paths, $template, $plugins; // Common objects
626
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 483
// log the upgrade
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 484
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,page_text,edit_summary) VALUES'
627
+ − 485
. '(\'security\', \'upgrade_enano\', ' . time() . ', \'[DEPRECATED]\', \'' . $db->escape($session->username) . '\', \'' . $db->escape(installer_enano_version()) . '\', \'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\');');
626
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 486
if ( !$q )
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 487
{
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 488
$db->_die();
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 489
return false;
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 490
}
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 491
setConfig('enano_version', installer_enano_version());
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 492
return true;
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
+ − 493
}