256
+ − 1
<?php
+ − 2
+ − 3
/*
+ − 4
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 5
* Version 1.1.1
256
+ − 6
* Copyright (C) 2006-2007 Dan Fuhry
+ − 7
* install.php - handles everything related to installation and initial configuration
+ − 8
*
+ − 9
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
+ − 10
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 11
*
+ − 12
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 13
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 14
*/
+ − 15
+ − 16
@include('config.php');
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 17
if( ( defined('ENANO_INSTALLED') || defined('MIDGET_INSTALLED') ) && ((isset($_GET['mode']) && ($_GET['mode']!='finish' && $_GET['mode']!='css') && $_GET['mode']!='showlicense') || !isset($_GET['mode'])))
256
+ − 18
{
+ − 19
$_GET['title'] = 'Enano:Installation_locked';
+ − 20
require('includes/common.php');
+ − 21
die_friendly('Installation locked', '<p>The Enano installer has found a Enano installation in this directory. You MUST delete config.php if you want to re-install Enano.</p><p>If you wish to upgrade an older Enano installation to this version, please use the <a href="upgrade.php">upgrade script</a>.</p>');
+ − 22
exit;
+ − 23
}
+ − 24
+ − 25
define('IN_ENANO_INSTALL', 'true');
+ − 26
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 27
define('ENANO_VERSION', '1.1.1');
243
+ − 28
define('ENANO_CODE_NAME', 'Germination');
256
+ − 29
// In beta versions, define ENANO_BETA_VERSION here
+ − 30
240
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 31
// This is required to make installation work right
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 32
define("ENANO_ALLOW_LOAD_NOLANG", 1);
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 33
256
+ − 34
if(!defined('scriptPath')) {
+ − 35
$sp = dirname($_SERVER['REQUEST_URI']);
+ − 36
if($sp == '/' || $sp == '\\') $sp = '';
+ − 37
define('scriptPath', $sp);
+ − 38
}
+ − 39
+ − 40
if(!defined('contentPath')) {
+ − 41
$sp = dirname($_SERVER['REQUEST_URI']);
+ − 42
if($sp == '/' || $sp == '\\') $sp = '';
+ − 43
define('contentPath', $sp);
+ − 44
}
+ − 45
global $_starttime, $this_page, $sideinfo;
+ − 46
$_starttime = microtime(true);
+ − 47
322
+ − 48
global $db;
+ − 49
256
+ − 50
// Determine directory (special case for development servers)
+ − 51
if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') )
+ − 52
{
+ − 53
$filename = str_replace('/repo/', '/', __FILE__);
+ − 54
}
+ − 55
else
+ − 56
{
+ − 57
$filename = __FILE__;
+ − 58
}
+ − 59
+ − 60
define('ENANO_ROOT', dirname($filename));
+ − 61
+ − 62
function is_page($p)
+ − 63
{
+ − 64
return true;
+ − 65
}
+ − 66
+ − 67
require('includes/wikiformat.php');
+ − 68
require('includes/constants.php');
+ − 69
require('includes/rijndael.php');
+ − 70
require('includes/functions.php');
243
+ − 71
require('includes/dbal.php');
+ − 72
require('includes/lang.php');
+ − 73
require('includes/json.php');
256
+ − 74
+ − 75
strip_magic_quotes_gpc();
+ − 76
+ − 77
//
+ − 78
// INSTALLER LIBRARY
+ − 79
//
+ − 80
243
+ − 81
$neutral_color = 'C';
+ − 82
256
+ − 83
function run_installer_stage($stage_id, $stage_name, $function, $failure_explanation, $allow_skip = true)
+ − 84
{
+ − 85
static $resumed = false;
+ − 86
static $resume_stack = array();
+ − 87
+ − 88
if ( empty($resume_stack) && isset($_POST['resume_stack']) && preg_match('/[a-z_]+((\|[a-z_]+)+)/', $_POST['resume_stack']) )
+ − 89
{
+ − 90
$resume_stack = explode('|', $_POST['resume_stack']);
+ − 91
}
+ − 92
+ − 93
$already_run = false;
+ − 94
if ( in_array($stage_id, $resume_stack) )
+ − 95
{
+ − 96
$already_run = true;
+ − 97
}
+ − 98
+ − 99
if ( !$resumed )
+ − 100
{
+ − 101
if ( !isset($_GET['stage']) )
+ − 102
$resumed = true;
+ − 103
if ( isset($_GET['stage']) && $_GET['stage'] == $stage_id )
+ − 104
{
+ − 105
$resumed = true;
+ − 106
}
+ − 107
}
+ − 108
if ( !$resumed && $allow_skip )
+ − 109
{
267
+ − 110
echo_stage_success($stage_id, $stage_name);
256
+ − 111
return false;
+ − 112
}
+ − 113
if ( !function_exists($function) )
+ − 114
die('libenanoinstall: CRITICAL: function "' . $function . '" for ' . $stage_id . ' doesn\'t exist');
+ − 115
$result = @call_user_func($function, false, $already_run);
+ − 116
if ( $result )
+ − 117
{
+ − 118
echo_stage_success($stage_id, $stage_name);
+ − 119
$resume_stack[] = $stage_id;
+ − 120
return true;
+ − 121
}
+ − 122
else
+ − 123
{
+ − 124
echo_stage_failure($stage_id, $stage_name, $failure_explanation, $resume_stack);
+ − 125
return false;
+ − 126
}
+ − 127
}
+ − 128
+ − 129
function start_install_table()
+ − 130
{
254
+ − 131
echo '<table border="0" cellspacing="0" cellpadding="0" style="margin-top: 10px;">' . "\n";
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 132
ob_start();
256
+ − 133
}
+ − 134
+ − 135
function close_install_table()
+ − 136
{
+ − 137
echo '</table>' . "\n\n";
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 138
ob_end_flush();
256
+ − 139
}
+ − 140
+ − 141
function echo_stage_success($stage_id, $stage_name)
+ − 142
{
+ − 143
global $neutral_color;
+ − 144
$neutral_color = ( $neutral_color == 'A' ) ? 'C' : 'A';
+ − 145
echo '<tr><td style="width: 500px; background-color: #' . "{$neutral_color}{$neutral_color}FF{$neutral_color}{$neutral_color}" . '; padding: 0 5px;">' . htmlspecialchars($stage_name) . '</td><td style="padding: 0 5px;"><img alt="Done" src="images/good.gif" /></td></tr>' . "\n";
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 146
ob_flush();
256
+ − 147
}
+ − 148
+ − 149
function echo_stage_failure($stage_id, $stage_name, $failure_explanation, $resume_stack)
+ − 150
{
+ − 151
global $neutral_color;
254
+ − 152
global $lang;
256
+ − 153
+ − 154
$neutral_color = ( $neutral_color == 'A' ) ? 'C' : 'A';
+ − 155
echo '<tr><td style="width: 500px; background-color: #' . "FF{$neutral_color}{$neutral_color}{$neutral_color}{$neutral_color}" . '; padding: 0 5px;">' . htmlspecialchars($stage_name) . '</td><td style="padding: 0 5px;"><img alt="Failed" src="images/bad.gif" /></td></tr>' . "\n";
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 156
ob_flush();
256
+ − 157
close_install_table();
+ − 158
$post_data = '';
+ − 159
$mysql_error = mysql_error();
+ − 160
foreach ( $_POST as $key => $value )
+ − 161
{
269
+ − 162
// FIXME: These should really also be sanitized for double quotes
256
+ − 163
$value = htmlspecialchars($value);
+ − 164
$key = htmlspecialchars($key);
+ − 165
$post_data .= " <input type=\"hidden\" name=\"$key\" value=\"$value\" />\n";
+ − 166
}
+ − 167
echo '<form action="install.php?mode=install&stage=' . $stage_id . '" method="post">
+ − 168
' . $post_data . '
+ − 169
<input type="hidden" name="resume_stack" value="' . htmlspecialchars(implode('|', $resume_stack)) . '" />
254
+ − 170
<h3>' . $lang->get('meta_msg_err_stagefailed_title') . '</h3>
256
+ − 171
<p>' . $failure_explanation . '</p>
254
+ − 172
' . ( !empty($mysql_error) ? "<p>" . $lang->get('meta_msg_err_stagefailed_mysqlerror') . " $mysql_error</p>" : '' ) . '
+ − 173
<p>' . $lang->get('meta_msg_err_stagefailed_body') . '</p>
+ − 174
<p style="text-align: center;"><input type="submit" value="' . $lang->get('meta_btn_retry_installation') . '" /></p>
256
+ − 175
</form>';
+ − 176
global $template, $template_bak;
+ − 177
if ( is_object($template_bak) )
+ − 178
$template_bak->footer();
+ − 179
else
+ − 180
$template->footer();
+ − 181
exit;
+ − 182
}
+ − 183
+ − 184
//
+ − 185
// INSTALLER STAGES
+ − 186
//
+ − 187
+ − 188
function stg_mysql_connect($act_get = false)
+ − 189
{
322
+ − 190
global $db;
+ − 191
$db = new mysql();
+ − 192
256
+ − 193
static $conn = false;
+ − 194
if ( $act_get )
+ − 195
return $conn;
+ − 196
258
+ − 197
$db_user =& $_POST['db_user'];
+ − 198
$db_pass =& $_POST['db_pass'];
+ − 199
$db_name =& $_POST['db_name'];
256
+ − 200
258
+ − 201
if ( !preg_match('/^[a-z0-9_-]+$/', $db_name) )
+ − 202
{
+ − 203
$db_name = htmlspecialchars($db_name);
+ − 204
die("<p>SECURITY: malformed database name \"$db_name\"</p>");
+ − 205
}
256
+ − 206
+ − 207
// First, try to connect using the normal credentials
+ − 208
$conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']);
+ − 209
if ( !$conn )
+ − 210
{
+ − 211
// Connection failed. Do we have the root username and password?
+ − 212
if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) )
+ − 213
{
+ − 214
$conn_root = @mysql_connect($_POST['db_host'], $_POST['db_root_user'], $_POST['db_root_pass']);
+ − 215
if ( !$conn_root )
+ − 216
{
+ − 217
// Couldn't connect using either set of credentials. Bail out.
+ − 218
return false;
+ − 219
}
258
+ − 220
unset($db_user, $db_pass);
+ − 221
$db_user = mysql_real_escape_string($_POST['db_user']);
+ − 222
$db_pass = mysql_real_escape_string($_POST['db_pass']);
256
+ − 223
// Create the user account
+ − 224
$q = @mysql_query("GRANT ALL PRIVILEGES ON test.* TO '{$db_user}'@'localhost' IDENTIFIED BY '$db_pass' WITH GRANT OPTION;", $conn_root);
+ − 225
if ( !$q )
+ − 226
{
+ − 227
return false;
+ − 228
}
+ − 229
// Revoke privileges from test, we don't need them
+ − 230
$q = @mysql_query("REVOKE ALL PRIVILEGES ON test.* FROM '{$db_user}'@'localhost';", $conn_root);
+ − 231
if ( !$q )
+ − 232
{
+ − 233
return false;
+ − 234
}
+ − 235
if ( $_POST['db_host'] != 'localhost' && $_POST['db_host'] != '127.0.0.1' && $_POST['db_host'] != '::1' )
+ − 236
{
+ − 237
// If not connecting to a server running on localhost, allow from any host
+ − 238
// this is safer than trying to detect the hostname of the webserver, but less secure
+ − 239
$q = @mysql_query("GRANT ALL PRIVILEGES ON test.* TO '{$db_user}'@'%' IDENTIFIED BY '$db_pass' WITH GRANT OPTION;", $conn_root);
+ − 240
if ( !$q )
+ − 241
{
+ − 242
return false;
+ − 243
}
+ − 244
// Revoke privileges from test, we don't need them
+ − 245
$q = @mysql_query("REVOKE ALL PRIVILEGES ON test.* FROM '{$db_user}'@'%';", $conn_root);
+ − 246
if ( !$q )
+ − 247
{
+ − 248
return false;
+ − 249
}
+ − 250
}
258
+ − 251
mysql_close($conn_root);
+ − 252
$conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']);
+ − 253
if ( !$conn )
+ − 254
{
+ − 255
// This should honestly never happen.
+ − 256
return false;
+ − 257
}
256
+ − 258
}
+ − 259
}
258
+ − 260
$q = @mysql_query("USE `$db_name`;", $conn);
256
+ − 261
if ( !$q )
+ − 262
{
+ − 263
// access denied to the database; try the whole root schenanegan again
+ − 264
if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) )
+ − 265
{
+ − 266
$conn_root = @mysql_connect($_POST['db_host'], $_POST['db_root_user'], $_POST['db_root_pass']);
+ − 267
if ( !$conn_root )
+ − 268
{
+ − 269
// Couldn't connect as root; bail out
+ − 270
return false;
+ − 271
}
+ − 272
// create the database, if it doesn't exist
258
+ − 273
$q = @mysql_query("CREATE DATABASE IF NOT EXISTS `$db_name`;", $conn_root);
256
+ − 274
if ( !$q )
+ − 275
{
+ − 276
// this really should never fail, so don't give any tolerance to it
+ − 277
return false;
+ − 278
}
258
+ − 279
unset($db_user, $db_pass);
+ − 280
$db_user = mysql_real_escape_string($_POST['db_user']);
+ − 281
$db_pass = mysql_real_escape_string($_POST['db_pass']);
256
+ − 282
// we're in with root rights; grant access to the database
258
+ − 283
$q = @mysql_query("GRANT ALL PRIVILEGES ON `$db_name`.* TO '{$db_user}'@'localhost';", $conn_root);
256
+ − 284
if ( !$q )
+ − 285
{
+ − 286
return false;
+ − 287
}
+ − 288
if ( $_POST['db_host'] != 'localhost' && $_POST['db_host'] != '127.0.0.1' && $_POST['db_host'] != '::1' )
+ − 289
{
258
+ − 290
$q = @mysql_query("GRANT ALL PRIVILEGES ON `$db_name`.* TO '{$db_user}'@'%';", $conn_root);
256
+ − 291
if ( !$q )
+ − 292
{
+ − 293
return false;
+ − 294
}
+ − 295
}
258
+ − 296
mysql_close($conn_root);
+ − 297
// grant tables have hopefully been flushed, kill and reconnect our regular user connection
+ − 298
mysql_close($conn);
+ − 299
$conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']);
+ − 300
if ( !$conn )
+ − 301
{
+ − 302
return false;
+ − 303
}
256
+ − 304
}
+ − 305
else
+ − 306
{
+ − 307
return false;
+ − 308
}
+ − 309
// try again
258
+ − 310
$q = @mysql_query("USE `$db_name`;", $conn);
256
+ − 311
if ( !$q )
+ − 312
{
+ − 313
// really failed this time; bail out
+ − 314
return false;
+ − 315
}
+ − 316
}
322
+ − 317
// initialize DBAL
+ − 318
$db->connect(true, $_POST['db_host'], $db_user, $db_pass, $db_name);
+ − 319
// connected and database exists
+ − 320
return true;
+ − 321
}
+ − 322
+ − 323
function stg_pgsql_connect($act_get = false)
+ − 324
{
+ − 325
global $db;
+ − 326
$db = new postgresql();
+ − 327
+ − 328
static $conn = false;
+ − 329
if ( $act_get )
+ − 330
return $conn;
+ − 331
+ − 332
$db_user =& $_POST['db_user'];
+ − 333
$db_pass =& $_POST['db_pass'];
+ − 334
$db_name =& $_POST['db_name'];
+ − 335
+ − 336
if ( !preg_match('/^[a-z0-9_-]+$/', $db_name) )
+ − 337
{
+ − 338
$db_name = htmlspecialchars($db_name);
+ − 339
die("<p>SECURITY: malformed database name \"$db_name\"</p>");
+ − 340
}
+ − 341
+ − 342
// First, try to connect using the normal credentials
+ − 343
$conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}");
+ − 344
if ( !$conn )
+ − 345
{
+ − 346
// Connection failed. Do we have the root username and password?
+ − 347
if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) )
+ − 348
{
+ − 349
$conn_root = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_root_user']} password={$_POST['db_root_pass']}");
+ − 350
if ( !$conn_root )
+ − 351
{
+ − 352
// Couldn't connect using either set of credentials. Bail out.
+ − 353
return false;
+ − 354
}
+ − 355
unset($db_user, $db_pass);
+ − 356
$db_user = pg_escape_string($_POST['db_user']);
+ − 357
$db_pass = pg_escape_string($_POST['db_pass']);
+ − 358
// Create the user account
+ − 359
$q = @pg_query("CREATE ROLE '$db_user' WITH NOSUPERUSER UNENCRYPTED PASSWORD '$db_pass';", $conn_root);
+ − 360
if ( !$q )
+ − 361
{
+ − 362
return false;
+ − 363
}
+ − 364
pg_close($conn_root);
+ − 365
$conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}");
+ − 366
if ( !$conn )
+ − 367
{
+ − 368
// This should honestly never happen.
+ − 369
return false;
+ − 370
}
+ − 371
}
+ − 372
}
+ − 373
if ( !$q )
+ − 374
{
+ − 375
// access denied to the database; try the whole root schenanegan again
+ − 376
if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) )
+ − 377
{
+ − 378
$conn_root = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_root_user']} password={$_POST['db_root_pass']}");
+ − 379
if ( !$conn_root )
+ − 380
{
+ − 381
// Couldn't connect as root; bail out
+ − 382
return false;
+ − 383
}
+ − 384
unset($db_user, $db_pass);
+ − 385
$db_user = pg_escape_string($_POST['db_user']);
+ − 386
$db_pass = pg_escape_string($_POST['db_pass']);
+ − 387
// create the database, if it doesn't exist
+ − 388
$q = @mysql_query("CREATE DATABASE $db_name WITH OWNER $db_user;", $conn_root);
+ − 389
if ( !$q )
+ − 390
{
+ − 391
// this really should never fail, so don't give any tolerance to it
+ − 392
return false;
+ − 393
}
+ − 394
// Setting the owner to $db_user should grant all the rights we need
+ − 395
pg_close($conn_root);
+ − 396
// grant tables have hopefully been flushed, kill and reconnect our regular user connection
+ − 397
pg_close($conn);
+ − 398
$conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}");
+ − 399
if ( !$conn )
+ − 400
{
+ − 401
return false;
+ − 402
}
+ − 403
}
+ − 404
else
+ − 405
{
+ − 406
return false;
+ − 407
}
+ − 408
// try again
+ − 409
$q = @mysql_query("USE `$db_name`;", $conn);
+ − 410
if ( !$q )
+ − 411
{
+ − 412
// really failed this time; bail out
+ − 413
return false;
+ − 414
}
+ − 415
}
+ − 416
// initialize DBAL
+ − 417
$db->connect(true, $_POST['db_host'], $db_user, $db_pass, $db_name);
256
+ − 418
// connected and database exists
+ − 419
return true;
+ − 420
}
+ − 421
+ − 422
function stg_drop_tables()
+ − 423
{
322
+ − 424
global $db;
256
+ − 425
// Our list of tables included in Enano
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 426
$tables = Array( 'categories', 'comments', 'config', 'logs', 'page_text', 'session_keys', 'pages', 'users', 'users_extra', 'themes', 'buddies', 'banlist', 'files', 'privmsgs', 'sidebar', 'hits', 'search_index', 'groups', 'group_members', 'acl', 'tags', 'page_groups', 'page_group_members' );
256
+ − 427
+ − 428
// Drop each table individually; if it fails, it probably means we're trying to drop a
+ − 429
// table that didn't exist in the Enano version we're deleting the database for.
+ − 430
foreach ( $tables as $table )
+ − 431
{
+ − 432
// Remember that table_prefix is sanitized.
+ − 433
$table = "{$_POST['table_prefix']}$table";
322
+ − 434
$db->sql_query("DROP TABLE $table;", $conn);
256
+ − 435
}
+ − 436
return true;
+ − 437
}
+ − 438
+ − 439
function stg_decrypt_admin_pass($act_get = false)
+ − 440
{
+ − 441
static $decrypted_pass = false;
+ − 442
if ( $act_get )
+ − 443
return $decrypted_pass;
+ − 444
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
diff
changeset
+ − 445
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
256
+ − 446
+ − 447
if ( !empty($_POST['crypt_data']) )
+ − 448
{
+ − 449
require('config.new.php');
+ − 450
if ( !isset($cryptkey) )
+ − 451
{
+ − 452
return false;
+ − 453
}
+ − 454
define('_INSTRESUME_AES_KEYBACKUP', $key);
+ − 455
$key = hexdecode($cryptkey);
+ − 456
+ − 457
$decrypted_pass = $aes->decrypt($_POST['crypt_data'], $key, ENC_HEX);
+ − 458
+ − 459
}
+ − 460
else
+ − 461
{
+ − 462
$decrypted_pass = $_POST['admin_pass'];
+ − 463
}
+ − 464
if ( empty($decrypted_pass) )
+ − 465
return false;
+ − 466
return true;
+ − 467
}
+ − 468
+ − 469
function stg_generate_aes_key($act_get = false)
+ − 470
{
+ − 471
static $key = false;
+ − 472
if ( $act_get )
+ − 473
return $key;
+ − 474
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
diff
changeset
+ − 475
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
256
+ − 476
$key = $aes->gen_readymade_key();
+ − 477
return true;
+ − 478
}
+ − 479
+ − 480
function stg_parse_schema($act_get = false)
+ − 481
{
+ − 482
static $schema;
+ − 483
if ( $act_get )
+ − 484
return $schema;
+ − 485
322
+ − 486
global $db;
+ − 487
256
+ − 488
$admin_pass = stg_decrypt_admin_pass(true);
+ − 489
$key = stg_generate_aes_key(true);
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
diff
changeset
+ − 490
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
256
+ − 491
$key = $aes->hextostring($key);
+ − 492
$admin_pass = $aes->encrypt($admin_pass, $key, ENC_HEX);
+ − 493
+ − 494
$cacheonoff = is_writable(ENANO_ROOT.'/cache/') ? '1' : '0';
+ − 495
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 496
$admin_user = $_POST['admin_user'];
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 497
$admin_user = str_replace('_', ' ', $admin_user);
322
+ − 498
$admin_user = $db->escape($admin_user);
+ − 499
+ − 500
switch ( $_POST['db_driver'] )
+ − 501
{
+ − 502
case 'mysql':
+ − 503
$schema_file = 'schema.sql';
+ − 504
break;
+ − 505
case 'postgresql':
+ − 506
$schema_file = 'schema-pg.sql';
+ − 507
break;
+ − 508
}
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 509
322
+ − 510
if ( !isset($schema_file) )
+ − 511
die('insanity');
+ − 512
+ − 513
$schema = file_get_contents($schema_file);
+ − 514
$schema = str_replace('{{SITE_NAME}}', $db->escape($_POST['sitename'] ), $schema);
+ − 515
$schema = str_replace('{{SITE_DESC}}', $db->escape($_POST['sitedesc'] ), $schema);
+ − 516
$schema = str_replace('{{COPYRIGHT}}', $db->escape($_POST['copyright'] ), $schema);
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 517
$schema = str_replace('{{ADMIN_USER}}', $admin_user , $schema);
322
+ − 518
$schema = str_replace('{{ADMIN_PASS}}', $db->escape($admin_pass ), $schema);
+ − 519
$schema = str_replace('{{ADMIN_EMAIL}}', $db->escape($_POST['admin_email']), $schema);
+ − 520
$schema = str_replace('{{ENABLE_CACHE}}', $db->escape($cacheonoff ), $schema);
256
+ − 521
$schema = str_replace('{{REAL_NAME}}', '', $schema);
+ − 522
$schema = str_replace('{{TABLE_PREFIX}}', $_POST['table_prefix'], $schema);
+ − 523
$schema = str_replace('{{VERSION}}', ENANO_VERSION, $schema);
+ − 524
$schema = str_replace('{{ADMIN_EMBED_PHP}}', $_POST['admin_embed_php'], $schema);
+ − 525
// Not anymore!! :-D
+ − 526
// $schema = str_replace('{{BETA_VERSION}}', ENANO_BETA_VERSION, $schema);
+ − 527
+ − 528
if(isset($_POST['wiki_mode']))
+ − 529
{
+ − 530
$schema = str_replace('{{WIKI_MODE}}', '1', $schema);
+ − 531
}
+ − 532
else
+ − 533
{
+ − 534
$schema = str_replace('{{WIKI_MODE}}', '0', $schema);
+ − 535
}
+ − 536
+ − 537
// Build an array of queries
+ − 538
$schema = explode("\n", $schema);
+ − 539
+ − 540
foreach ( $schema as $i => $sql )
+ − 541
{
+ − 542
$query =& $schema[$i];
+ − 543
$t = trim($query);
+ − 544
if ( empty($t) || preg_match('/^(\#|--)/i', $t) )
+ − 545
{
+ − 546
unset($schema[$i]);
+ − 547
unset($query);
+ − 548
}
+ − 549
}
+ − 550
+ − 551
$schema = array_values($schema);
+ − 552
$schema = implode("\n", $schema);
+ − 553
$schema = explode(";\n", $schema);
+ − 554
+ − 555
foreach ( $schema as $i => $sql )
+ − 556
{
+ − 557
$query =& $schema[$i];
+ − 558
if ( substr($query, ( strlen($query) - 1 ), 1 ) != ';' )
+ − 559
{
+ − 560
$query .= ';';
+ − 561
}
+ − 562
}
+ − 563
+ − 564
return true;
+ − 565
}
+ − 566
+ − 567
function stg_install($_unused, $already_run)
+ − 568
{
+ − 569
// This one's pretty easy.
+ − 570
$conn = stg_mysql_connect(true);
+ − 571
if ( !is_resource($conn) )
+ − 572
return false;
+ − 573
$schema = stg_parse_schema(true);
+ − 574
if ( !is_array($schema) )
+ − 575
return false;
+ − 576
+ − 577
// If we're resuming installation, the encryption key was regenerated.
+ − 578
// This means we'll have to update the encrypted password in the database.
+ − 579
if ( $already_run )
+ − 580
{
+ − 581
$admin_pass = stg_decrypt_admin_pass(true);
+ − 582
$key = stg_generate_aes_key(true);
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
diff
changeset
+ − 583
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
256
+ − 584
$key = $aes->hextostring($key);
+ − 585
$admin_pass = $aes->encrypt($admin_pass, $key, ENC_HEX);
+ − 586
$admin_user = mysql_real_escape_string($_POST['admin_user']);
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 587
$admin_user = str_replace('_', ' ', $admin_user);
256
+ − 588
+ − 589
$q = @mysql_query("UPDATE {$_POST['table_prefix']}users SET password='$admin_pass' WHERE username='$admin_user';");
+ − 590
if ( !$q )
+ − 591
{
+ − 592
echo '<p><tt>MySQL return: ' . mysql_error() . '</tt></p>';
+ − 593
return false;
+ − 594
}
+ − 595
+ − 596
return true;
+ − 597
}
+ − 598
+ − 599
// OK, do the loop, baby!!!
+ − 600
foreach($schema as $q)
+ − 601
{
+ − 602
$r = mysql_query($q, $conn);
+ − 603
if ( !$r )
+ − 604
{
+ − 605
echo '<p><tt>MySQL return: ' . mysql_error() . '</tt></p>';
+ − 606
return false;
+ − 607
}
+ − 608
}
+ − 609
+ − 610
return true;
+ − 611
}
+ − 612
+ − 613
function stg_write_config()
+ − 614
{
+ − 615
$privkey = stg_generate_aes_key(true);
+ − 616
+ − 617
switch($_POST['urlscheme'])
+ − 618
{
+ − 619
case "ugly":
+ − 620
default:
+ − 621
$cp = scriptPath.'/index.php?title=';
+ − 622
break;
+ − 623
case "short":
+ − 624
$cp = scriptPath.'/index.php/';
+ − 625
break;
+ − 626
case "tiny":
+ − 627
$cp = scriptPath.'/';
+ − 628
break;
+ − 629
}
+ − 630
+ − 631
if ( $_POST['urlscheme'] == 'tiny' )
+ − 632
{
+ − 633
$contents = '# Begin Enano rules
+ − 634
RewriteEngine on
+ − 635
RewriteCond %{REQUEST_FILENAME} !-d
+ − 636
RewriteCond %{REQUEST_FILENAME} !-f
+ − 637
RewriteRule ^(.+) '.scriptPath.'/index.php?title=$1 [L,QSA]
+ − 638
RewriteRule \.(php|html|gif|jpg|png|css|js)$ - [L]
+ − 639
# End Enano rules
+ − 640
';
+ − 641
if ( file_exists('./.htaccess') )
+ − 642
$ht = fopen(ENANO_ROOT.'/.htaccess', 'a+');
+ − 643
else
+ − 644
$ht = fopen(ENANO_ROOT.'/.htaccess.new', 'w');
+ − 645
if ( !$ht )
+ − 646
return false;
+ − 647
fwrite($ht, $contents);
+ − 648
fclose($ht);
+ − 649
}
+ − 650
+ − 651
$config_file = '<?php
+ − 652
/* Enano auto-generated configuration file - editing not recommended! */
+ − 653
$dbhost = \''.addslashes($_POST['db_host']).'\';
+ − 654
$dbname = \''.addslashes($_POST['db_name']).'\';
+ − 655
$dbuser = \''.addslashes($_POST['db_user']).'\';
+ − 656
$dbpasswd = \''.addslashes($_POST['db_pass']).'\';
+ − 657
if ( !defined(\'ENANO_CONSTANTS\') )
+ − 658
{
+ − 659
define(\'ENANO_CONSTANTS\', \'\');
+ − 660
define(\'table_prefix\', \''.addslashes($_POST['table_prefix']).'\');
+ − 661
define(\'scriptPath\', \''.scriptPath.'\');
+ − 662
define(\'contentPath\', \''.$cp.'\');
+ − 663
define(\'ENANO_INSTALLED\', \'true\');
+ − 664
}
+ − 665
$crypto_key = \''.$privkey.'\';
+ − 666
?>';
+ − 667
+ − 668
$cf_handle = fopen(ENANO_ROOT.'/config.new.php', 'w');
+ − 669
if ( !$cf_handle )
+ − 670
return false;
+ − 671
fwrite($cf_handle, $config_file);
+ − 672
+ − 673
fclose($cf_handle);
+ − 674
+ − 675
return true;
+ − 676
}
+ − 677
+ − 678
function _stg_rename_config_revert()
+ − 679
{
+ − 680
if ( file_exists('./config.php') )
+ − 681
{
+ − 682
@rename('./config.php', './config.new.php');
+ − 683
}
+ − 684
+ − 685
$handle = @fopen('./config.php.new', 'w');
+ − 686
if ( !$handle )
+ − 687
return false;
+ − 688
$contents = '<?php $cryptkey = \'' . _INSTRESUME_AES_KEYBACKUP . '\'; ?>';
+ − 689
fwrite($handle, $contents);
+ − 690
fclose($handle);
+ − 691
return true;
+ − 692
}
+ − 693
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 694
function stg_build_index()
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 695
{
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 696
global $db, $session, $paths, $template, $plugins; // Common objects;
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 697
if ( $paths->rebuild_search_index() )
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 698
return true;
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 699
return false;
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 700
}
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 701
256
+ − 702
function stg_rename_config()
+ − 703
{
+ − 704
if ( !@rename('./config.new.php', './config.php') )
+ − 705
{
+ − 706
echo '<p>Can\'t rename config.php</p>';
+ − 707
_stg_rename_config_revert();
+ − 708
return false;
+ − 709
}
+ − 710
+ − 711
if ( $_POST['urlscheme'] == 'tiny' && !file_exists('./.htaccess') )
+ − 712
{
+ − 713
if ( !@rename('./.htaccess.new', './.htaccess') )
+ − 714
{
+ − 715
echo '<p>Can\'t rename .htaccess</p>';
+ − 716
_stg_rename_config_revert();
+ − 717
return false;
+ − 718
}
+ − 719
}
+ − 720
return true;
+ − 721
}
+ − 722
+ − 723
function stg_start_api_success()
+ − 724
{
+ − 725
return true;
+ − 726
}
+ − 727
+ − 728
function stg_start_api_failure()
+ − 729
{
+ − 730
return false;
+ − 731
}
+ − 732
240
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 733
function stg_import_language()
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 734
{
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 735
global $db, $session, $paths, $template, $plugins; // Common objects
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 736
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 737
$lang_file = ENANO_ROOT . "/language/english/enano.json";
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 738
install_language("eng", "English", "English", $lang_file);
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 739
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 740
return true;
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 741
}
f0149a27df5f
Localized default sidebar; installer should work now including the lang import; l10n in installer to follow
Dan
diff
changeset
+ − 742
256
+ − 743
function stg_init_logs()
+ − 744
{
+ − 745
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 746
+ − 747
$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() . ', \'' . date('d M Y h:i a') . '\', \'' . mysql_real_escape_string($_POST['admin_user']) . '\', \'' . mysql_real_escape_string(ENANO_VERSION) . '\', \'' . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . '\');');
+ − 748
if ( !$q )
+ − 749
{
+ − 750
echo '<p><tt>MySQL return: ' . mysql_error() . '</tt></p>';
+ − 751
return false;
+ − 752
}
+ − 753
+ − 754
if ( !$session->get_permissions('clear_logs') )
+ − 755
{
+ − 756
echo '<p><tt>$session: denied clear_logs</tt></p>';
+ − 757
return false;
+ − 758
}
+ − 759
+ − 760
PageUtils::flushlogs('Main_Page', 'Article');
+ − 761
+ − 762
return true;
+ − 763
}
+ − 764
+ − 765
//die('Key size: ' . AES_BITS . '<br />Block size: ' . AES_BLOCKSIZE);
+ − 766
+ − 767
if(!function_exists('wikiFormat'))
+ − 768
{
+ − 769
function wikiFormat($message, $filter_links = true)
+ − 770
{
+ − 771
$wiki = & Text_Wiki::singleton('Mediawiki');
+ − 772
$wiki->setRenderConf('Xhtml', 'code', 'css_filename', 'codefilename');
+ − 773
$wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
+ − 774
$result = $wiki->transform($message, 'Xhtml');
+ − 775
+ − 776
// HTML fixes
+ − 777
$result = preg_replace('#<tr>([\s]*?)<\/tr>#is', '', $result);
+ − 778
$result = preg_replace('#<p>([\s]*?)<\/p>#is', '', $result);
+ − 779
$result = preg_replace('#<br />([\s]*?)<table#is', '<table', $result);
+ − 780
+ − 781
return $result;
+ − 782
}
+ − 783
}
+ − 784
+ − 785
global $failed, $warned;
+ − 786
+ − 787
$failed = false;
+ − 788
$warned = false;
+ − 789
+ − 790
function not($var)
+ − 791
{
+ − 792
if($var)
+ − 793
{
+ − 794
return false;
+ − 795
}
+ − 796
else
+ − 797
{
+ − 798
return true;
+ − 799
}
+ − 800
}
+ − 801
+ − 802
function run_test($code, $desc, $extended_desc, $warn = false)
+ − 803
{
+ − 804
global $failed, $warned;
+ − 805
static $cv = true;
+ − 806
$cv = not($cv);
+ − 807
$val = eval($code);
+ − 808
if($val)
+ − 809
{
+ − 810
if($cv) $color='CCFFCC'; else $color='AAFFAA';
322
+ − 811
echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc</td><td style='padding-left: 10px;'><img alt='Test passed' src='images/good.gif' /></td></tr>";
256
+ − 812
} elseif(!$val && $warn) {
+ − 813
if($cv) $color='FFFFCC'; else $color='FFFFAA';
322
+ − 814
echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test passed with warning' src='images/unknown.gif' /></td></tr>";
256
+ − 815
$warned = true;
+ − 816
} else {
+ − 817
if($cv) $color='FFCCCC'; else $color='FFAAAA';
322
+ − 818
echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test failed' src='images/bad.gif' /></td></tr>";
256
+ − 819
$failed = true;
+ − 820
}
+ − 821
}
+ − 822
function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; }
+ − 823
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 824
function show_license($fb = false)
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 825
{
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 826
?>
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 827
<div style="height: 500px; clip: rect(0px,auto,500px,auto); overflow: auto; padding: 10px; border: 1px dashed #456798; margin: 1em;">
279
+ − 828
<?php
+ − 829
if ( !file_exists('./GPL') || !file_exists('./language/english/install/license-deed.html') )
+ − 830
{
+ − 831
echo 'Cannot find the license files.';
+ − 832
}
+ − 833
echo file_get_contents('./language/english/install/license-deed.html');
+ − 834
if ( defined('ENANO_BETA_VERSION') || $branch == 'unstable' )
+ − 835
{
+ − 836
?>
+ − 837
<h3><?php echo $lang->get('license_info_unstable_title'); ?></h3>
+ − 838
<p><?php echo $lang->get('license_info_unstable_body'); ?></p>
+ − 839
<?php
+ − 840
}
+ − 841
?>
+ − 842
<h3><?php echo $lang->get('license_section_gpl_heading'); ?></h3>
+ − 843
<?php if ( $lang->lang_code != 'eng' ): ?>
+ − 844
<p><i><?php echo $lang->get('license_gpl_blurb_inenglish'); ?></i></p>
+ − 845
<?php endif; ?>
+ − 846
<?php echo wikiFormat(file_get_contents(ENANO_ROOT . '/GPL')); ?>
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 847
<?php
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 848
global $template;
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 849
if ( $fb )
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 850
{
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 851
echo '<p style="text-align: center;">Because I could never find the Create a Page button in PHP-Nuke.</p>';
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 852
echo '<p>' . str_replace('http://enanocms.org/', 'http://www.2robots.com/2003/10/15/web-portals-suck/', $template->fading_button) . '</p>';
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 853
echo '<p style="text-align: center;">It\'s not a portal, my friends.</p>';
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 854
}
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 855
?>
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 856
</div>
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 857
<?php
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 858
}
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 859
256
+ − 860
require_once('includes/template.php');
+ − 861
279
+ − 862
if(!isset($_GET['mode']))
+ − 863
{
243
+ − 864
$_GET['mode'] = 'welcome';
279
+ − 865
}
256
+ − 866
switch($_GET['mode'])
+ − 867
{
+ − 868
case 'mysql_test':
+ − 869
error_reporting(0);
+ − 870
$dbhost = rawurldecode($_POST['host']);
+ − 871
$dbname = rawurldecode($_POST['name']);
+ − 872
$dbuser = rawurldecode($_POST['user']);
+ − 873
$dbpass = rawurldecode($_POST['pass']);
+ − 874
$dbrootuser = rawurldecode($_POST['root_user']);
+ − 875
$dbrootpass = rawurldecode($_POST['root_pass']);
+ − 876
if($dbrootuser != '')
+ − 877
{
+ − 878
$conn = mysql_connect($dbhost, $dbrootuser, $dbrootpass);
+ − 879
if(!$conn)
+ − 880
{
+ − 881
$e = mysql_error();
+ − 882
if(strstr($e, "Lost connection"))
+ − 883
die('host'.$e);
+ − 884
else
+ − 885
die('root'.$e);
+ − 886
}
+ − 887
$rsp = 'good';
257
+ − 888
$q = mysql_query('USE `' . mysql_real_escape_string($dbname) . '`;', $conn);
256
+ − 889
if(!$q)
+ − 890
{
+ − 891
$e = mysql_error();
+ − 892
if(strstr($e, 'Unknown database'))
+ − 893
{
+ − 894
$rsp .= '_creating_db';
+ − 895
}
+ − 896
}
+ − 897
mysql_close($conn);
+ − 898
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
+ − 899
if(!$conn)
+ − 900
{
+ − 901
$e = mysql_error();
+ − 902
if(strstr($e, "Lost connection"))
+ − 903
die('host'.$e);
+ − 904
else
+ − 905
$rsp .= '_creating_user';
+ − 906
}
+ − 907
mysql_close($conn);
+ − 908
die($rsp);
+ − 909
}
+ − 910
else
+ − 911
{
+ − 912
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
+ − 913
if(!$conn)
+ − 914
{
+ − 915
$e = mysql_error();
+ − 916
if(strstr($e, "Lost connection"))
+ − 917
die('host'.$e);
+ − 918
else
+ − 919
die('auth'.$e);
+ − 920
}
257
+ − 921
$q = mysql_query('USE `' . mysql_real_escape_string($dbname) . '`;', $conn);
256
+ − 922
if(!$q)
+ − 923
{
+ − 924
$e = mysql_error();
+ − 925
if(strstr($e, 'Unknown database'))
+ − 926
{
+ − 927
die('name'.$e);
+ − 928
}
+ − 929
else
+ − 930
{
+ − 931
die('perm'.$e);
+ − 932
}
+ − 933
}
+ − 934
}
+ − 935
$v = mysql_get_server_info();
+ − 936
if(version_compare($v, '4.1.17', '<')) die('vers'.$v);
+ − 937
mysql_close($conn);
+ − 938
die('good');
+ − 939
break;
322
+ − 940
case 'pgsql_test':
+ − 941
error_reporting(0);
+ − 942
$dbhost = rawurldecode($_POST['host']);
+ − 943
$dbname = rawurldecode($_POST['name']);
+ − 944
$dbuser = rawurldecode($_POST['user']);
+ − 945
$dbpass = rawurldecode($_POST['pass']);
+ − 946
$dbrootuser = rawurldecode($_POST['root_user']);
+ − 947
$dbrootpass = rawurldecode($_POST['root_pass']);
+ − 948
if($dbrootuser != '')
+ − 949
{
+ − 950
$conn = @pg_connect("host=$dbhost port=5432 user=$dbuser password=$dbpass dbname=$dbname");
+ − 951
if(!$conn)
+ − 952
{
+ − 953
$e = pg_last_error();
+ − 954
if(strstr($e, "Lost connection"))
+ − 955
die('host'.$e);
+ − 956
else
+ − 957
die('root'.$e);
+ − 958
}
+ − 959
$rsp = 'good';
+ − 960
$q = mysql_query('USE `' . mysql_real_escape_string($dbname) . '`;', $conn);
+ − 961
if(!$q)
+ − 962
{
+ − 963
$e = mysql_error();
+ − 964
if(strstr($e, 'Unknown database'))
+ − 965
{
+ − 966
$rsp .= '_creating_db';
+ − 967
}
+ − 968
}
+ − 969
mysql_close($conn);
+ − 970
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
+ − 971
if(!$conn)
+ − 972
{
+ − 973
$e = mysql_error();
+ − 974
if(strstr($e, "Lost connection"))
+ − 975
die('host'.$e);
+ − 976
else
+ − 977
$rsp .= '_creating_user';
+ − 978
}
+ − 979
mysql_close($conn);
+ − 980
die($rsp);
+ − 981
}
+ − 982
else
+ − 983
{
+ − 984
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
+ − 985
if(!$conn)
+ − 986
{
+ − 987
$e = mysql_error();
+ − 988
if(strstr($e, "Lost connection"))
+ − 989
die('host'.$e);
+ − 990
else
+ − 991
die('auth'.$e);
+ − 992
}
+ − 993
$q = mysql_query('USE `' . mysql_real_escape_string($dbname) . '`;', $conn);
+ − 994
if(!$q)
+ − 995
{
+ − 996
$e = mysql_error();
+ − 997
if(strstr($e, 'Unknown database'))
+ − 998
{
+ − 999
die('name'.$e);
+ − 1000
}
+ − 1001
else
+ − 1002
{
+ − 1003
die('perm'.$e);
+ − 1004
}
+ − 1005
}
+ − 1006
}
+ − 1007
$v = mysql_get_server_info();
+ − 1008
if(version_compare($v, '4.1.17', '<')) die('vers'.$v);
+ − 1009
mysql_close($conn);
+ − 1010
die('good');
+ − 1011
break;
256
+ − 1012
case 'pophelp':
+ − 1013
$topic = ( isset($_GET['topic']) ) ? $_GET['topic'] : 'invalid';
+ − 1014
switch($topic)
+ − 1015
{
+ − 1016
case 'admin_embed_php':
249
+ − 1017
$title = $lang->get('pophelp_admin_embed_php_title');
+ − 1018
$content = $lang->get('pophelp_admin_embed_php_body');
256
+ − 1019
break;
300
c9e192a059c1
Add installer pop-help topic for URL scheme, in response to http://forum.enanocms.org/viewtopic.php?f=5&t=19
Dan
diff
changeset
+ − 1020
case 'url_schemes':
304
+ − 1021
$title = $lang->get('pophelp_url_schemes_title');
+ − 1022
$content = $lang->get('pophelp_url_schemes_body');
300
c9e192a059c1
Add installer pop-help topic for URL scheme, in response to http://forum.enanocms.org/viewtopic.php?f=5&t=19
Dan
diff
changeset
+ − 1023
break;
256
+ − 1024
default:
+ − 1025
$title = 'Invalid topic';
+ − 1026
$content = 'Invalid help topic.';
+ − 1027
break;
+ − 1028
}
249
+ − 1029
$close_window = $lang->get('pophelp_btn_close_window');
256
+ − 1030
echo <<<EOF
+ − 1031
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+ − 1032
<html>
+ − 1033
<head>
+ − 1034
<title>Enano installation quick help • {$title}</title>
+ − 1035
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ − 1036
<style type="text/css">
+ − 1037
body {
+ − 1038
font-family: trebuchet ms, verdana, arial, helvetica, sans-serif;
+ − 1039
font-size: 9pt;
+ − 1040
}
+ − 1041
h2 { border-bottom: 1px solid #90B0D0; margin-bottom: 0; }
+ − 1042
h3 { font-size: 11pt; font-weight: bold; }
+ − 1043
li { list-style: url(../images/bullet.gif); }
+ − 1044
p { margin: 1.0em; }
+ − 1045
blockquote { background-color: #F4F4F4; border: 1px dotted #406080; margin: 1em; padding: 10px; max-height: 250px; overflow: auto; }
+ − 1046
a { color: #7090B0; }
+ − 1047
a:hover { color: #90B0D0; }
+ − 1048
</style>
+ − 1049
</head>
+ − 1050
<body>
+ − 1051
<h2>{$title}</h2>
+ − 1052
{$content}
+ − 1053
<p style="text-align: right;">
249
+ − 1054
<a href="#" onclick="window.close(); return false;">{$close_window}</a>
256
+ − 1055
</p>
+ − 1056
</body>
+ − 1057
</html>
+ − 1058
EOF;
+ − 1059
exit;
+ − 1060
break;
243
+ − 1061
case 'langjs':
+ − 1062
header('Content-type: text/javascript');
+ − 1063
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
+ − 1064
$lang_js = $json->encode($lang->strings);
+ − 1065
// use EEOF here because jEdit misinterprets "typ'eof'"
+ − 1066
echo <<<EEOF
+ − 1067
if ( typeof(enano_lang) != 'object' )
+ − 1068
var enano_lang = new Object();
+ − 1069
+ − 1070
enano_lang[1] = $lang_js;
+ − 1071
+ − 1072
EEOF;
+ − 1073
exit;
+ − 1074
break;
256
+ − 1075
default:
+ − 1076
break;
+ − 1077
}
+ − 1078
330
c94af5b5c40f
A minor installer fix to get the installer to run again. TODO: fix bad call to $lang->get() in preinstallation environment set up by index.php
Dan
diff
changeset
+ − 1079
// Initialize language support
c94af5b5c40f
A minor installer fix to get the installer to run again. TODO: fix bad call to $lang->get() in preinstallation environment set up by index.php
Dan
diff
changeset
+ − 1080
$lang = new Language('eng');
c94af5b5c40f
A minor installer fix to get the installer to run again. TODO: fix bad call to $lang->get() in preinstallation environment set up by index.php
Dan
diff
changeset
+ − 1081
$lang->load_file('./language/english/install.json');
c94af5b5c40f
A minor installer fix to get the installer to run again. TODO: fix bad call to $lang->get() in preinstallation environment set up by index.php
Dan
diff
changeset
+ − 1082
256
+ − 1083
$template = new template_nodb();
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 1084
$template->load_theme('stpatty', 'shamrock', false);
256
+ − 1085
+ − 1086
$modestrings = Array(
243
+ − 1087
'welcome' => $lang->get('welcome_modetitle'),
+ − 1088
'license' => $lang->get('license_modetitle'),
+ − 1089
'sysreqs' => $lang->get('sysreqs_modetitle'),
326
+ − 1090
'database' => $lang->get('database_modetitle'),
+ − 1091
'database_mysql'=> $lang->get('database_mysql_modetitle'),
+ − 1092
'database_pgsql'=> $lang->get('database_pgsql_modetitle'),
+ − 1093
'website' => $lang->get('website_modetitle'),
243
+ − 1094
'login' => $lang->get('login_modetitle'),
+ − 1095
'confirm' => $lang->get('confirm_modetitle'),
+ − 1096
'install' => $lang->get('install_modetitle'),
280
+ − 1097
'finish' => $lang->get('finish_modetitle'),
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1098
'_hiddenstages' => '...', // all stages below this line are hidden
279
+ − 1099
'showlicense' => $lang->get('license_modetitle')
256
+ − 1100
);
+ − 1101
+ − 1102
$sideinfo = '';
+ − 1103
$vars = $template->extract_vars('elements.tpl');
+ − 1104
$p = $template->makeParserText($vars['sidebar_button']);
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1105
$hidden = false;
256
+ − 1106
foreach ( $modestrings as $id => $str )
+ − 1107
{
+ − 1108
if ( $_GET['mode'] == $id )
+ − 1109
{
+ − 1110
$flags = 'style="font-weight: bold; text-decoration: underline;"';
+ − 1111
$this_page = $str;
+ − 1112
}
+ − 1113
else
+ − 1114
{
+ − 1115
$flags = '';
+ − 1116
}
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1117
if ( $id == '_hiddenstages' )
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1118
$hidden = true;
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1119
if ( !$hidden )
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1120
{
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1121
$p->assign_vars(Array(
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1122
'HREF' => '#',
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1123
'FLAGS' => $flags . ' onclick="return false;"',
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1124
'TEXT' => $str
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1125
));
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1126
$sideinfo .= $p->run();
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1127
}
256
+ − 1128
}
+ − 1129
+ − 1130
$template->init_vars();
+ − 1131
+ − 1132
if(isset($_GET['mode']) && $_GET['mode'] == 'css')
+ − 1133
{
+ − 1134
header('Content-type: text/css');
+ − 1135
echo $template->get_css();
+ − 1136
exit;
+ − 1137
}
+ − 1138
243
+ − 1139
if ( defined('ENANO_IS_STABLE') )
+ − 1140
$branch = 'stable';
+ − 1141
else if ( defined('ENANO_IS_UNSTABLE') )
+ − 1142
$branch = 'unstable';
+ − 1143
else
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1144
{
243
+ − 1145
$version = explode('.', ENANO_VERSION);
+ − 1146
if ( !isset($version[1]) )
+ − 1147
// unknown branch, really
+ − 1148
$branch = 'unstable';
+ − 1149
else
+ − 1150
{
+ − 1151
$version[1] = intval($version[1]);
+ − 1152
if ( $version[1] % 2 == 1 )
+ − 1153
$branch = 'unstable';
+ − 1154
else
+ − 1155
$branch = 'stable';
+ − 1156
}
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1157
}
243
+ − 1158
330
c94af5b5c40f
A minor installer fix to get the installer to run again. TODO: fix bad call to $lang->get() in preinstallation environment set up by index.php
Dan
diff
changeset
+ − 1159
$template->header();
c94af5b5c40f
A minor installer fix to get the installer to run again. TODO: fix bad call to $lang->get() in preinstallation environment set up by index.php
Dan
diff
changeset
+ − 1160
256
+ − 1161
switch($_GET['mode'])
+ − 1162
{
+ − 1163
default:
+ − 1164
case 'welcome':
+ − 1165
?>
+ − 1166
<div style="text-align: center; margin-top: 10px;">
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 1167
<img alt="[ Enano CMS Project logo ]" src="images/enano-artwork/installer-greeting-green.png" style="display: block; margin: 0 auto; padding-left: 100px;" />
243
+ − 1168
<h2><?php echo $lang->get('welcome_heading'); ?></h2>
+ − 1169
<h3>
+ − 1170
<?php
+ − 1171
$branch_l = $lang->get("welcome_branch_$branch");
+ − 1172
+ − 1173
$v_string = sprintf('%s %s – %s', $lang->get('welcome_version'), ENANO_VERSION, $branch_l);
+ − 1174
echo $v_string;
+ − 1175
?>
+ − 1176
</h3>
256
+ − 1177
<?php
243
+ − 1178
if ( defined('ENANO_CODE_NAME') )
+ − 1179
{
+ − 1180
echo '<p>';
+ − 1181
echo $lang->get('welcome_aka', array(
+ − 1182
'codename' => strtolower(ENANO_CODE_NAME)
+ − 1183
));
+ − 1184
echo '</p>';
+ − 1185
}
256
+ − 1186
?>
+ − 1187
<form action="install.php?mode=license" method="post">
243
+ − 1188
<input type="submit" value="<?php echo $lang->get('welcome_btn_start'); ?>" />
256
+ − 1189
</form>
+ − 1190
</div>
+ − 1191
<?php
+ − 1192
break;
+ − 1193
case "license":
+ − 1194
?>
243
+ − 1195
<h3><?php echo $lang->get('license_heading'); ?></h3>
+ − 1196
<p><?php echo $lang->get('license_blurb_thankyou'); ?></p>
+ − 1197
<p><?php echo $lang->get('license_blurb_pleaseread'); ?></p>
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 1198
<?php show_license(); ?>
256
+ − 1199
<div class="pagenav">
+ − 1200
<form action="install.php?mode=sysreqs" method="post">
+ − 1201
<table border="0">
+ − 1202
<tr>
243
+ − 1203
<td>
+ − 1204
<input type="submit" value="<?php echo $lang->get('license_btn_i_agree'); ?>" />
+ − 1205
</td>
+ − 1206
<td>
+ − 1207
<p>
+ − 1208
<span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
+ − 1209
• <?php echo $lang->get('license_objective_ensure_agree'); ?><br />
+ − 1210
• <?php echo $lang->get('license_objective_have_db_info'); ?>
+ − 1211
</p>
+ − 1212
</td>
256
+ − 1213
</tr>
+ − 1214
</table>
+ − 1215
</form>
+ − 1216
</div>
+ − 1217
<?php
+ − 1218
break;
+ − 1219
case "sysreqs":
+ − 1220
error_reporting(E_ALL);
+ − 1221
?>
243
+ − 1222
<h3><?php echo $lang->get('sysreqs_heading'); ?></h3>
+ − 1223
<p><?php echo $lang->get('sysreqs_blurb'); ?></p>
256
+ − 1224
<table border="0" cellspacing="0" cellpadding="0">
+ − 1225
<?php
243
+ − 1226
run_test('return version_compare(\'4.3.0\', PHP_VERSION, \'<\');', $lang->get('sysreqs_req_php'), $lang->get('sysreqs_req_desc_php') );
304
+ − 1227
run_test('return version_compare(\'5.2.0\', PHP_VERSION, \'<\');', $lang->get('sysreqs_req_php5'), $lang->get('sysreqs_req_desc_php5'), true);
243
+ − 1228
run_test('return function_exists(\'mysql_connect\');', $lang->get('sysreqs_req_mysql'), $lang->get('sysreqs_req_desc_mysql') );
322
+ − 1229
run_test('return function_exists(\'pg_connect\');', 'PostgreSQL extension for PHP', 'It seems that your PHP installation does not have the PostgreSQL extension enabled. Because of this, you won\'t be able to use the PostgreSQL database driver. This is OK in the majority of cases. If you want to use PostgreSQL support, you\'ll need to either compile the PHP extension for Postgres or install the extension with your distribution\'s package manager. Windows administrators will need enable php_pgsql.dll in their php.ini.', true);
243
+ − 1230
run_test('return @ini_get(\'file_uploads\');', $lang->get('sysreqs_req_uploads'), $lang->get('sysreqs_req_desc_uploads') );
+ − 1231
run_test('return is_apache();', $lang->get('sysreqs_req_apache'), $lang->get('sysreqs_req_desc_apache'), true);
+ − 1232
run_test('return is_writable(ENANO_ROOT.\'/config.new.php\');', $lang->get('sysreqs_req_config'), $lang->get('sysreqs_req_desc_config') );
+ − 1233
run_test('return file_exists(\'/usr/bin/convert\');', $lang->get('sysreqs_req_magick'), $lang->get('sysreqs_req_desc_magick'), true);
+ − 1234
run_test('return is_writable(ENANO_ROOT.\'/cache/\');', $lang->get('sysreqs_req_cachewriteable'), $lang->get('sysreqs_req_desc_cachewriteable'), true);
+ − 1235
run_test('return is_writable(ENANO_ROOT.\'/files/\');', $lang->get('sysreqs_req_fileswriteable'), $lang->get('sysreqs_req_desc_fileswriteable'), true);
322
+ − 1236
if ( !function_exists('mysql_connect') && !function_exists('pg_connect') )
+ − 1237
{
+ − 1238
run_test('return false;', 'No database drivers are available.', 'You need to have at least one database driver working to install Enano. See the warnings on MySQL and PostgreSQL above for more information on installing these database drivers.', false);
+ − 1239
}
256
+ − 1240
echo '</table>';
+ − 1241
if(!$failed)
+ − 1242
{
+ − 1243
?>
+ − 1244
+ − 1245
<div class="pagenav">
+ − 1246
<?php
+ − 1247
if($warned) {
+ − 1248
echo '<table border="0" cellspacing="0" cellpadding="0">';
243
+ − 1249
run_test('return false;', $lang->get('sysreqs_summary_warn_title'), $lang->get('sysreqs_summary_warn_body'), true);
256
+ − 1250
echo '</table>';
+ − 1251
} else {
+ − 1252
echo '<table border="0" cellspacing="0" cellpadding="0">';
243
+ − 1253
run_test('return true;', '<b>' . $lang->get('sysreqs_summary_success_title') . '</b><br />' . $lang->get('sysreqs_summary_success_body'), 'You should never see this text. Congratulations for being an Enano hacker!');
256
+ − 1254
echo '</table>';
+ − 1255
}
+ − 1256
?>
244
+ − 1257
<form action="install.php?mode=database" method="post">
+ − 1258
<table border="0">
+ − 1259
<tr>
+ − 1260
<td>
+ − 1261
<input type="submit" value="<?php echo $lang->get('meta_btn_continue'); ?>" />
+ − 1262
</td>
+ − 1263
<td>
+ − 1264
<p>
+ − 1265
<span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
+ − 1266
• <?php echo $lang->get('sysreqs_objective_scalebacks'); ?><br />
+ − 1267
• <?php echo $lang->get('license_objective_have_db_info'); ?>
+ − 1268
</p>
+ − 1269
</td>
+ − 1270
</tr>
+ − 1271
</table>
+ − 1272
</form>
+ − 1273
</div>
+ − 1274
<?php
+ − 1275
}
+ − 1276
else
+ − 1277
{
+ − 1278
if ( $failed )
+ − 1279
{
256
+ − 1280
echo '<div class="pagenav"><table border="0" cellspacing="0" cellpadding="0">';
243
+ − 1281
run_test('return false;', $lang->get('sysreqs_summary_fail_title'), $lang->get('sysreqs_summary_fail_body'));
256
+ − 1282
echo '</table></div>';
+ − 1283
}
+ − 1284
}
+ − 1285
?>
+ − 1286
<?php
+ − 1287
break;
+ − 1288
case "database":
322
+ − 1289
echo '<h3>Choose a database driver</h3>';
+ − 1290
echo '<p>The next step is to choose the database driver that Enano will use. In most cases this is MySQL, but there are certain
+ − 1291
advantages to PostgreSQL, which is made available only experimentally.</p>';
+ − 1292
if ( @file_exists('/etc/enano-is-virt-appliance') )
+ − 1293
{
+ − 1294
echo '<p><b>You\'re using the Enano virtual appliance.</b><br />Unless you configured the appliance manually, PostgreSQL support is not available. In 99% of cases you\'ll want to click MySQL below.</p>';
+ − 1295
}
+ − 1296
+ − 1297
$mysql_disable_reason = '';
+ − 1298
$pgsql_disable_reason = '';
+ − 1299
$mysql_disable = '';
+ − 1300
$pgsql_disable = '';
+ − 1301
if ( !function_exists('mysql_connect') )
+ − 1302
{
+ − 1303
$mysql_disable = ' disabled="disabled"';
+ − 1304
$mysql_disable_reason = 'You don\'t have the MySQL PHP extension installed.';
+ − 1305
}
+ − 1306
if ( !function_exists('pg_connect') )
+ − 1307
{
+ − 1308
$pgsql_disable = ' disabled="disabled"';
+ − 1309
$pgsql_disable_reason = 'You don\'t have the PostgreSQL PHP extensnion installed.';
+ − 1310
}
+ − 1311
if ( function_exists('pg_connect') && version_compare(PHP_VERSION, '5.0.0', '<') )
+ − 1312
{
+ − 1313
$pgsql_disable = ' disabled="disabled"';
+ − 1314
$pgsql_disable_reason = 'You need to have at least PHP 5 to use the PostgreSQL database driver.';
+ − 1315
}
+ − 1316
+ − 1317
echo '<form action="install.php" method="get">';
+ − 1318
?>
+ − 1319
<table border="0" cellspacing="5">
+ − 1320
<tr>
+ − 1321
<td>
+ − 1322
<input type="image" name="mode" value="database_mysql" src="images/about-powered-mysql.png"<?php echo $mysql_disable; ?>/>
+ − 1323
</td>
+ − 1324
<td<?php if ( $mysql_disable ) echo ' style="opacity: 0.5; filter: alpha(opacity=50);"'; ?>>
+ − 1325
<b>MySQL</b><br />
+ − 1326
Click this button to use MySQL as the database backend for your site. Most web hosts support MySQL, and if you have
+ − 1327
administrative access to your MySQL server, you can create a new database and user during this installation process if you
+ − 1328
haven't done so already.
+ − 1329
<?php
+ − 1330
if ( $mysql_disable )
+ − 1331
{
+ − 1332
echo "<br /><br /><b>$mysql_disable_reason</b>";
+ − 1333
}
+ − 1334
?>
+ − 1335
</td>
+ − 1336
</tr>
+ − 1337
<tr>
+ − 1338
<td>
+ − 1339
<input type="image" name="mode" value="database_pgsql" src="images/about-powered-pgsql.png"<?php echo $pgsql_disable; ?> />
+ − 1340
</td>
+ − 1341
<td<?php if ( $pgsql_disable ) echo ' style="opacity: 0.5; filter: alpha(opacity=50);"'; ?>>
+ − 1342
<b>PostgreSQL</b><br />
+ − 1343
Click this button to use PostgreSQL as the database backend for your site. While not as widely supported, PostgreSQL has more
+ − 1344
liberal licensing conditions and when properly configured is faster than MySQL. Some plugins may not work with the PostgreSQL
+ − 1345
driver.
+ − 1346
<?php
+ − 1347
if ( $pgsql_disable )
+ − 1348
{
+ − 1349
echo "<br /><br /><b>$pgsql_disable_reason</b>";
+ − 1350
}
+ − 1351
?>
+ − 1352
</td>
+ − 1353
</tr>
+ − 1354
</table>
+ − 1355
<?php
+ − 1356
echo '</form>';
+ − 1357
break;
+ − 1358
case "database_mysql":
256
+ − 1359
?>
+ − 1360
<script type="text/javascript">
+ − 1361
function ajaxGet(uri, f) {
+ − 1362
if (window.XMLHttpRequest) {
+ − 1363
ajax = new XMLHttpRequest();
+ − 1364
} else {
+ − 1365
if (window.ActiveXObject) {
+ − 1366
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 1367
} else {
+ − 1368
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 1369
return;
+ − 1370
}
+ − 1371
}
+ − 1372
ajax.onreadystatechange = f;
+ − 1373
ajax.open('GET', uri, true);
+ − 1374
ajax.send(null);
+ − 1375
}
+ − 1376
+ − 1377
function ajaxPost(uri, parms, f) {
+ − 1378
if (window.XMLHttpRequest) {
+ − 1379
ajax = new XMLHttpRequest();
+ − 1380
} else {
+ − 1381
if (window.ActiveXObject) {
+ − 1382
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 1383
} else {
+ − 1384
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 1385
return;
+ − 1386
}
+ − 1387
}
+ − 1388
ajax.onreadystatechange = f;
+ − 1389
ajax.open('POST', uri, true);
+ − 1390
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ − 1391
ajax.setRequestHeader("Content-length", parms.length);
+ − 1392
ajax.setRequestHeader("Connection", "close");
+ − 1393
ajax.send(parms);
+ − 1394
}
+ − 1395
function ajaxTestConnection()
+ − 1396
{
+ − 1397
v = verify();
+ − 1398
if(!v)
+ − 1399
{
244
+ − 1400
alert($lang.get('meta_msg_err_verification'));
256
+ − 1401
return false;
+ − 1402
}
+ − 1403
var frm = document.forms.dbinfo;
+ − 1404
db_host = escape(frm.db_host.value.replace('+', '%2B'));
+ − 1405
db_name = escape(frm.db_name.value.replace('+', '%2B'));
+ − 1406
db_user = escape(frm.db_user.value.replace('+', '%2B'));
+ − 1407
db_pass = escape(frm.db_pass.value.replace('+', '%2B'));
+ − 1408
db_root_user = escape(frm.db_root_user.value.replace('+', '%2B'));
+ − 1409
db_root_pass = escape(frm.db_root_pass.value.replace('+', '%2B'));
+ − 1410
+ − 1411
parms = 'host='+db_host+'&name='+db_name+'&user='+db_user+'&pass='+db_pass+'&root_user='+db_root_user+'&root_pass='+db_root_pass;
+ − 1412
ajaxPost('<?php echo scriptPath; ?>/install.php?mode=mysql_test', parms, function() {
+ − 1413
if(ajax.readyState==4)
+ − 1414
{
+ − 1415
s = ajax.responseText.substr(0, 4);
+ − 1416
t = ajax.responseText.substr(4, ajax.responseText.length);
+ − 1417
if(s.substr(0, 4)=='good')
+ − 1418
{
+ − 1419
document.getElementById('s_db_host').src='images/good.gif';
+ − 1420
document.getElementById('s_db_name').src='images/good.gif';
+ − 1421
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1422
document.getElementById('s_db_root').src='images/good.gif';
244
+ − 1423
if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_warn_creating_db');
+ − 1424
if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = $lang.get('database_msg_warn_creating_user');
256
+ − 1425
document.getElementById('s_mysql_version').src='images/good.gif';
244
+ − 1426
document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_info_mysql_good');
256
+ − 1427
}
+ − 1428
else
+ − 1429
{
+ − 1430
switch(s)
+ − 1431
{
+ − 1432
case 'host':
+ − 1433
document.getElementById('s_db_host').src='images/bad.gif';
+ − 1434
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1435
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 1436
document.getElementById('s_db_root').src='images/unknown.gif';
244
+ − 1437
document.getElementById('e_db_host').innerHTML = $lang.get('database_msg_err_mysql_connect', { db_host: document.forms.dbinfo.db_host.value, mysql_error: t });
+ − 1438
document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
256
+ − 1439
break;
+ − 1440
case 'auth':
+ − 1441
document.getElementById('s_db_host').src='images/good.gif';
+ − 1442
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1443
document.getElementById('s_db_auth').src='images/bad.gif';
+ − 1444
document.getElementById('s_db_root').src='images/unknown.gif';
244
+ − 1445
document.getElementById('e_db_auth').innerHTML = $lang.get('database_msg_err_mysql_auth', { mysql_error: t });
+ − 1446
document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
256
+ − 1447
break;
+ − 1448
case 'perm':
+ − 1449
document.getElementById('s_db_host').src='images/good.gif';
+ − 1450
document.getElementById('s_db_name').src='images/bad.gif';
+ − 1451
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1452
document.getElementById('s_db_root').src='images/unknown.gif';
244
+ − 1453
document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_err_mysql_dbperm', { mysql_error: t });
+ − 1454
document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
256
+ − 1455
break;
+ − 1456
case 'name':
+ − 1457
document.getElementById('s_db_host').src='images/good.gif';
+ − 1458
document.getElementById('s_db_name').src='images/bad.gif';
+ − 1459
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1460
document.getElementById('s_db_root').src='images/unknown.gif';
244
+ − 1461
document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_err_mysql_dbexist', { mysql_error: t });
+ − 1462
document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
256
+ − 1463
break;
+ − 1464
case 'root':
+ − 1465
document.getElementById('s_db_host').src='images/good.gif';
+ − 1466
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1467
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 1468
document.getElementById('s_db_root').src='images/bad.gif';
244
+ − 1469
document.getElementById('e_db_root').innerHTML = $lang.get('database_msg_err_mysql_auth', { mysql_error: t });
+ − 1470
document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_warn_mysql_version');
256
+ − 1471
break;
+ − 1472
case 'vers':
+ − 1473
document.getElementById('s_db_host').src='images/good.gif';
+ − 1474
document.getElementById('s_db_name').src='images/good.gif';
+ − 1475
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1476
document.getElementById('s_db_root').src='images/good.gif';
244
+ − 1477
if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = $lang.get('database_msg_warn_creating_db');
+ − 1478
if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = $lang.get('database_msg_warn_creating_user');
256
+ − 1479
244
+ − 1480
document.getElementById('e_mysql_version').innerHTML = $lang.get('database_msg_err_mysql_version', { mysql_version: t });
256
+ − 1481
document.getElementById('s_mysql_version').src='images/bad.gif';
+ − 1482
default:
+ − 1483
alert(t);
+ − 1484
break;
+ − 1485
}
+ − 1486
}
+ − 1487
}
+ − 1488
});
+ − 1489
}
+ − 1490
function verify()
+ − 1491
{
+ − 1492
document.getElementById('e_db_host').innerHTML = '';
+ − 1493
document.getElementById('e_db_auth').innerHTML = '';
+ − 1494
document.getElementById('e_db_name').innerHTML = '';
+ − 1495
document.getElementById('e_db_root').innerHTML = '';
+ − 1496
var frm = document.forms.dbinfo;
+ − 1497
ret = true;
+ − 1498
if(frm.db_host.value != '')
+ − 1499
{
+ − 1500
document.getElementById('s_db_host').src='images/unknown.gif';
+ − 1501
}
+ − 1502
else
+ − 1503
{
+ − 1504
document.getElementById('s_db_host').src='images/bad.gif';
+ − 1505
ret = false;
+ − 1506
}
262
+ − 1507
if(frm.db_name.value.match(/^([a-z0-9_-]+)$/g))
256
+ − 1508
{
+ − 1509
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1510
}
+ − 1511
else
+ − 1512
{
+ − 1513
document.getElementById('s_db_name').src='images/bad.gif';
+ − 1514
ret = false;
+ − 1515
}
+ − 1516
if(frm.db_user.value != '')
+ − 1517
{
+ − 1518
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 1519
}
+ − 1520
else
+ − 1521
{
+ − 1522
document.getElementById('s_db_auth').src='images/bad.gif';
+ − 1523
ret = false;
+ − 1524
}
+ − 1525
if(frm.table_prefix.value.match(/^([a-z0-9_]*)$/g))
+ − 1526
{
+ − 1527
document.getElementById('s_table_prefix').src='images/good.gif';
+ − 1528
}
+ − 1529
else
+ − 1530
{
+ − 1531
document.getElementById('s_table_prefix').src='images/bad.gif';
+ − 1532
ret = false;
+ − 1533
}
+ − 1534
if(frm.db_root_user.value == '')
+ − 1535
{
+ − 1536
document.getElementById('s_db_root').src='images/good.gif';
+ − 1537
}
+ − 1538
else if(frm.db_root_user.value != '' && frm.db_root_pass.value == '')
+ − 1539
{
+ − 1540
document.getElementById('s_db_root').src='images/bad.gif';
+ − 1541
ret = false;
+ − 1542
}
+ − 1543
else
+ − 1544
{
+ − 1545
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 1546
}
+ − 1547
if(ret) frm._cont.disabled = false;
+ − 1548
else frm._cont.disabled = true;
+ − 1549
return ret;
+ − 1550
}
+ − 1551
window.onload = verify;
+ − 1552
</script>
244
+ − 1553
<p><?php echo $lang->get('database_blurb_needdb'); ?></p>
+ − 1554
<p><?php echo $lang->get('database_blurb_howtomysql'); ?></p>
256
+ − 1555
<?php
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 1556
if ( file_exists('/etc/enano-is-virt-appliance') )
256
+ − 1557
{
244
+ − 1558
echo '<p>
+ − 1559
' . $lang->get('database_vm_login_info', array( 'host' => 'localhost', 'user' => 'enano', 'pass' => 'clurichaun', 'name' => 'enano_www1' )) . '
+ − 1560
</p>';
256
+ − 1561
}
+ − 1562
?>
+ − 1563
<form name="dbinfo" action="install.php?mode=website" method="post">
322
+ − 1564
<input type="hidden" name="db_driver" value="mysql" />
256
+ − 1565
<table border="0">
244
+ − 1566
<tr>
+ − 1567
<td colspan="3" style="text-align: center">
+ − 1568
<h3><?php echo $lang->get('database_table_title'); ?></h3>
+ − 1569
</td>
+ − 1570
</tr>
+ − 1571
<tr>
+ − 1572
<td>
+ − 1573
<b><?php echo $lang->get('database_field_hostname_title'); ?></b>
+ − 1574
<br /><?php echo $lang->get('database_field_hostname_body'); ?>
+ − 1575
<br /><span style="color: #993300" id="e_db_host"></span>
+ − 1576
</td>
+ − 1577
<td>
+ − 1578
<input onkeyup="verify();" name="db_host" size="30" type="text" />
+ − 1579
</td>
+ − 1580
<td>
+ − 1581
<img id="s_db_host" alt="Good/bad icon" src="images/bad.gif" />
+ − 1582
</td>
+ − 1583
</tr>
+ − 1584
<tr>
+ − 1585
<td>
+ − 1586
<b><?php echo $lang->get('database_field_dbname_title'); ?></b><br />
+ − 1587
<?php echo $lang->get('database_field_dbname_body'); ?><br />
+ − 1588
<span style="color: #993300" id="e_db_name"></span>
+ − 1589
</td>
+ − 1590
<td>
+ − 1591
<input onkeyup="verify();" name="db_name" size="30" type="text" />
+ − 1592
</td>
+ − 1593
<td>
+ − 1594
<img id="s_db_name" alt="Good/bad icon" src="images/bad.gif" />
+ − 1595
</td>
+ − 1596
</tr>
+ − 1597
<tr>
+ − 1598
<td rowspan="2">
+ − 1599
<b><?php echo $lang->get('database_field_dbauth_title'); ?></b><br />
+ − 1600
<?php echo $lang->get('database_field_dbauth_body'); ?><br />
+ − 1601
<span style="color: #993300" id="e_db_auth"></span>
+ − 1602
</td>
+ − 1603
<td>
+ − 1604
<input onkeyup="verify();" name="db_user" size="30" type="text" />
+ − 1605
</td>
+ − 1606
<td rowspan="2">
+ − 1607
<img id="s_db_auth" alt="Good/bad icon" src="images/bad.gif" />
+ − 1608
</td>
+ − 1609
</tr>
+ − 1610
<tr>
+ − 1611
<td>
+ − 1612
<input name="db_pass" size="30" type="password" />
+ − 1613
</td>
+ − 1614
</tr>
+ − 1615
<tr>
+ − 1616
<td colspan="3" style="text-align: center">
+ − 1617
<h3><?php echo $lang->get('database_heading_optionalinfo'); ?></h3>
+ − 1618
</td>
+ − 1619
</tr>
+ − 1620
<tr>
+ − 1621
<td>
+ − 1622
<b><?php echo $lang->get('database_field_tableprefix_title'); ?></b><br />
+ − 1623
<?php echo $lang->get('database_field_tableprefix_body'); ?>
+ − 1624
</td>
+ − 1625
<td>
+ − 1626
<input onkeyup="verify();" name="table_prefix" size="30" type="text" />
+ − 1627
</td>
+ − 1628
<td>
+ − 1629
<img id="s_table_prefix" alt="Good/bad icon" src="images/good.gif" />
+ − 1630
</td>
+ − 1631
</tr>
+ − 1632
<tr>
+ − 1633
<td rowspan="2">
+ − 1634
<b><?php echo $lang->get('database_field_rootauth_title'); ?></b><br />
+ − 1635
<?php echo $lang->get('database_field_rootauth_body'); ?><br />
+ − 1636
<span style="color: #993300" id="e_db_root"></span>
+ − 1637
</td>
+ − 1638
<td>
+ − 1639
<input onkeyup="verify();" name="db_root_user" size="30" type="text" />
+ − 1640
</td>
+ − 1641
<td rowspan="2">
+ − 1642
<img id="s_db_root" alt="Good/bad icon" src="images/good.gif" />
+ − 1643
</td>
+ − 1644
</tr>
+ − 1645
<tr>
+ − 1646
<td>
+ − 1647
<input onkeyup="verify();" name="db_root_pass" size="30" type="password" />
+ − 1648
</td>
+ − 1649
</tr>
+ − 1650
<tr>
+ − 1651
<td>
+ − 1652
<b><?php echo $lang->get('database_field_mysqlversion_title'); ?></b>
+ − 1653
</td>
+ − 1654
<td id="e_mysql_version">
+ − 1655
<?php echo $lang->get('database_field_mysqlversion_blurb_willbechecked'); ?>
+ − 1656
</td>
+ − 1657
<td>
+ − 1658
<img id="s_mysql_version" alt="Good/bad icon" src="images/unknown.gif" />
+ − 1659
</td>
+ − 1660
</tr>
+ − 1661
<tr>
+ − 1662
<td>
+ − 1663
<b><?php echo $lang->get('database_field_droptables_title'); ?></b><br />
+ − 1664
<?php echo $lang->get('database_field_droptables_body'); ?>
+ − 1665
</td>
+ − 1666
<td>
+ − 1667
<input type="checkbox" name="drop_tables" id="dtcheck" /> <label for="dtcheck"><?php echo $lang->get('database_field_droptables_lbl'); ?></label>
+ − 1668
</td>
+ − 1669
</tr>
+ − 1670
<tr>
+ − 1671
<td colspan="3" style="text-align: center">
+ − 1672
<input type="button" value="<?php echo $lang->get('database_btn_testconnection'); ?>" onclick="ajaxTestConnection();" />
+ − 1673
</td>
+ − 1674
</tr>
256
+ − 1675
</table>
+ − 1676
<div class="pagenav">
244
+ − 1677
<table border="0">
+ − 1678
<tr>
+ − 1679
<td>
+ − 1680
<input type="submit" value="<?php echo $lang->get('meta_btn_continue'); ?>" onclick="return verify();" name="_cont" />
+ − 1681
</td>
+ − 1682
<td>
+ − 1683
<p>
+ − 1684
<span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
+ − 1685
• <?php echo $lang->get('database_objective_test'); ?><br />
+ − 1686
• <?php echo $lang->get('database_objective_uncrypt'); ?>
+ − 1687
</p>
+ − 1688
</td>
+ − 1689
</tr>
+ − 1690
</table>
+ − 1691
</div>
322
+ − 1692
} else {
+ − 1693
if (window.ActiveXObject) {
+ − 1694
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 1695
} else {
+ − 1696
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 1697
return;
+ − 1698
}
+ − 1699
}
+ − 1700
ajax.onreadystatechange = f;
+ − 1701
ajax.open('GET', uri, true);
+ − 1702
ajax.send(null);
+ − 1703
}
+ − 1704
+ − 1705
function ajaxPost(uri, parms, f) {
+ − 1706
if (window.XMLHttpRequest) {
+ − 1707
ajax = new XMLHttpRequest();
+ − 1708
} else {
+ − 1709
if (window.ActiveXObject) {
+ − 1710
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 1711
} else {
+ − 1712
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 1713
return;
+ − 1714
}
+ − 1715
}
+ − 1716
ajax.onreadystatechange = f;
+ − 1717
ajax.open('POST', uri, true);
+ − 1718
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ − 1719
ajax.setRequestHeader("Content-length", parms.length);
+ − 1720
ajax.setRequestHeader("Connection", "close");
+ − 1721
ajax.send(parms);
+ − 1722
}
+ − 1723
function ajaxTestConnection()
+ − 1724
{
+ − 1725
v = verify();
+ − 1726
if(!v)
+ − 1727
{
+ − 1728
alert('One or more of the form fields is incorrect. Please correct any information in the form that has an "X" next to it.');
+ − 1729
return false;
+ − 1730
}
+ − 1731
var frm = document.forms.dbinfo;
+ − 1732
db_host = escape(frm.db_host.value.replace('+', '%2B'));
+ − 1733
db_name = escape(frm.db_name.value.replace('+', '%2B'));
+ − 1734
db_user = escape(frm.db_user.value.replace('+', '%2B'));
+ − 1735
db_pass = escape(frm.db_pass.value.replace('+', '%2B'));
+ − 1736
db_root_user = escape(frm.db_root_user.value.replace('+', '%2B'));
+ − 1737
db_root_pass = escape(frm.db_root_pass.value.replace('+', '%2B'));
+ − 1738
+ − 1739
parms = 'host='+db_host+'&name='+db_name+'&user='+db_user+'&pass='+db_pass+'&root_user='+db_root_user+'&root_pass='+db_root_pass;
+ − 1740
ajaxPost('<?php echo scriptPath; ?>/install.php?mode=pgsql_test', parms, function() {
+ − 1741
if(ajax.readyState==4)
+ − 1742
{
+ − 1743
s = ajax.responseText.substr(0, 4);
+ − 1744
t = ajax.responseText.substr(4, ajax.responseText.length);
+ − 1745
if(s.substr(0, 4)=='good')
+ − 1746
{
+ − 1747
document.getElementById('s_db_host').src='images/good.gif';
+ − 1748
document.getElementById('s_db_name').src='images/good.gif';
+ − 1749
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1750
document.getElementById('s_db_root').src='images/good.gif';
+ − 1751
if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = '<b>Warning:<\/b> The database you specified does not exist. It will be created during installation.';
+ − 1752
if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = '<b>Warning:<\/b> The specified regular user does not exist or the password is incorrect. The user will be created during installation. If the user already exists, the password will be reset.';
+ − 1753
document.getElementById('s_mysql_version').src='images/good.gif';
+ − 1754
document.getElementById('e_mysql_version').innerHTML = 'Your version of PostgreSQL meets Enano requirements.';
+ − 1755
}
+ − 1756
else
+ − 1757
{
+ − 1758
switch(s)
+ − 1759
{
+ − 1760
case 'host':
+ − 1761
document.getElementById('s_db_host').src='images/bad.gif';
+ − 1762
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1763
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 1764
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 1765
document.getElementById('e_db_host').innerHTML = '<b>Error:<\/b> The database server "'+document.forms.dbinfo.db_host.value+'" couldn\'t be contacted.<br \/>'+t;
+ − 1766
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 1767
break;
+ − 1768
case 'auth':
+ − 1769
document.getElementById('s_db_host').src='images/good.gif';
+ − 1770
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1771
document.getElementById('s_db_auth').src='images/bad.gif';
+ − 1772
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 1773
document.getElementById('e_db_auth').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
+ − 1774
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 1775
break;
+ − 1776
case 'perm':
+ − 1777
document.getElementById('s_db_host').src='images/good.gif';
+ − 1778
document.getElementById('s_db_name').src='images/bad.gif';
+ − 1779
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1780
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 1781
document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> Access to the specified database using those login credentials was denied.<br \/>'+t;
+ − 1782
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 1783
break;
+ − 1784
case 'name':
+ − 1785
document.getElementById('s_db_host').src='images/good.gif';
+ − 1786
document.getElementById('s_db_name').src='images/bad.gif';
+ − 1787
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1788
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 1789
document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> The specified database does not exist<br \/>'+t;
+ − 1790
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 1791
break;
+ − 1792
case 'root':
+ − 1793
document.getElementById('s_db_host').src='images/good.gif';
+ − 1794
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1795
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 1796
document.getElementById('s_db_root').src='images/bad.gif';
+ − 1797
document.getElementById('e_db_root').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
+ − 1798
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 1799
break;
+ − 1800
case 'vers':
+ − 1801
document.getElementById('s_db_host').src='images/good.gif';
+ − 1802
document.getElementById('s_db_name').src='images/good.gif';
+ − 1803
document.getElementById('s_db_auth').src='images/good.gif';
+ − 1804
document.getElementById('s_db_root').src='images/good.gif';
+ − 1805
if(t.match(/_creating_db/)) document.getElementById('e_db_name').innerHTML = '<b>Warning:<\/b> The database you specified does not exist. It will be created during installation.';
+ − 1806
if(t.match(/_creating_user/)) document.getElementById('e_db_auth').innerHTML = '<b>Warning:<\/b> The specified regular user does not exist or the password is incorrect. The user will be created during installation. If the user already exists, the password will be reset.';
+ − 1807
+ − 1808
document.getElementById('e_mysql_version').innerHTML = '<b>Error:<\/b> Your version of MySQL ('+t+') is older than 4.1.17. Enano will still work, but there is a known bug with the comment system and MySQL 4.1.11 that involves some comments not being displayed, due to an issue with the PHP function mysql_fetch_row().';
+ − 1809
document.getElementById('s_mysql_version').src='images/bad.gif';
+ − 1810
default:
+ − 1811
alert(t);
+ − 1812
break;
+ − 1813
}
+ − 1814
}
+ − 1815
}
+ − 1816
});
+ − 1817
}
+ − 1818
function verify()
+ − 1819
{
+ − 1820
document.getElementById('e_db_host').innerHTML = '';
+ − 1821
document.getElementById('e_db_auth').innerHTML = '';
+ − 1822
document.getElementById('e_db_name').innerHTML = '';
+ − 1823
document.getElementById('e_db_root').innerHTML = '';
+ − 1824
var frm = document.forms.dbinfo;
+ − 1825
ret = true;
+ − 1826
if(frm.db_host.value != '')
+ − 1827
{
+ − 1828
document.getElementById('s_db_host').src='images/unknown.gif';
+ − 1829
}
+ − 1830
else
+ − 1831
{
+ − 1832
document.getElementById('s_db_host').src='images/bad.gif';
+ − 1833
ret = false;
+ − 1834
}
+ − 1835
if(frm.db_name.value.match(/^([a-z0-9_-]+)$/g))
+ − 1836
{
+ − 1837
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 1838
}
+ − 1839
else
+ − 1840
{
+ − 1841
document.getElementById('s_db_name').src='images/bad.gif';
+ − 1842
ret = false;
+ − 1843
}
+ − 1844
if(frm.db_user.value != '')
+ − 1845
{
+ − 1846
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 1847
}
+ − 1848
else
+ − 1849
{
+ − 1850
document.getElementById('s_db_auth').src='images/bad.gif';
+ − 1851
ret = false;
+ − 1852
}
+ − 1853
if(frm.table_prefix.value.match(/^([a-z0-9_]*)$/g))
+ − 1854
{
+ − 1855
document.getElementById('s_table_prefix').src='images/good.gif';
+ − 1856
}
+ − 1857
else
+ − 1858
{
+ − 1859
document.getElementById('s_table_prefix').src='images/bad.gif';
+ − 1860
ret = false;
+ − 1861
}
+ − 1862
if(frm.db_root_user.value == '')
+ − 1863
{
+ − 1864
document.getElementById('s_db_root').src='images/good.gif';
+ − 1865
}
+ − 1866
else if(frm.db_root_user.value != '' && frm.db_root_pass.value == '')
+ − 1867
{
+ − 1868
document.getElementById('s_db_root').src='images/bad.gif';
+ − 1869
ret = false;
+ − 1870
}
+ − 1871
else
+ − 1872
{
+ − 1873
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 1874
}
+ − 1875
if(ret) frm._cont.disabled = false;
+ − 1876
else frm._cont.disabled = true;
+ − 1877
return ret;
+ − 1878
}
+ − 1879
window.onload = verify;
+ − 1880
</script>
+ − 1881
<p>Now we need some information that will allow Enano to contact your database server. Enano uses PostgreSQL as a data storage backend,
+ − 1882
and we need to have access to a PostgreSQL server in order to continue.</p>
+ − 1883
<p>If you do not have access to a PostgreSQL server, and you are using your own server, you can download PostgreSQL for free from
+ − 1884
<a href="http://www.postgresql.org/">PostgreSQL.org</a>.</p>
+ − 1885
<form name="dbinfo" action="install.php?mode=website" method="post">
+ − 1886
<input type="hidden" name="db_driver" value="postgresql" />
+ − 1887
<table border="0">
+ − 1888
<tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr>
+ − 1889
<tr><td><b>Database hostname</b><br />This is the hostname (or sometimes the IP address) of your Postgres server. In many cases, this is "localhost".<br /><span style="color: #993300" id="e_db_host"></span></td><td><input onkeyup="verify();" name="db_host" size="30" type="text" /></td><td><img id="s_db_host" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 1890
<tr><td><b>Database name</b><br />The name of the actual database. If you don't already have a database, you can create one here, if you have the username and password of a PostgreSQL superuser.<br /><span style="color: #993300" id="e_db_name"></span></td><td><input onkeyup="verify();" name="db_name" size="30" type="text" /></td><td><img id="s_db_name" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 1891
<tr><td rowspan="2"><b>Database login</b><br />These fields should be the username and password for a role that has permission to create and alter tables, select data, insert data, update data, and delete data. You may or may not choose to allow dropping tables.<br /><span style="color: #993300" id="e_db_auth"></span></td><td><input onkeyup="verify();" name="db_user" size="30" type="text" /></td><td rowspan="2"><img id="s_db_auth" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 1892
<tr><td><input name="db_pass" size="30" type="password" /></td></tr>
+ − 1893
<tr><td colspan="3" style="text-align: center"><h3>Optional information</h3></td></tr>
+ − 1894
<tr><td><b>Table prefix</b><br />The value that you enter here will be added to the beginning of the name of each Enano table. You may use lowercase letters (a-z), numbers (0-9), and underscores (_).</td><td><input onkeyup="verify();" name="table_prefix" size="30" type="text" /></td><td><img id="s_table_prefix" alt="Good/bad icon" src="images/good.gif" /></td></tr>
+ − 1895
<tr><td rowspan="2"><b>Database administrative login</b><br />If the Postgres database or role that you entered above does not exist yet, you can create them here, assuming that you have the login information for a PostgreSQL superuser. Leave these fields blank unless you need to use them.<br /><span style="color: #993300" id="e_db_root"></span></td><td><input onkeyup="verify();" name="db_root_user" size="30" type="text" /></td><td rowspan="2"><img id="s_db_root" alt="Good/bad icon" src="images/good.gif" /></td></tr>
+ − 1896
<tr><td><input onkeyup="verify();" name="db_root_pass" size="30" type="password" /></td></tr>
+ − 1897
<tr><td><b>PostgreSQL version</b></td><td id="e_mysql_version">PostgreSQL version information will<br />be checked when you click "Test<br />Connection". You need to have at<br />least PostgreSQL 8.2.0 to install Enano.</td><td><img id="s_mysql_version" alt="Good/bad icon" src="images/unknown.gif" /></td></tr>
+ − 1898
<tr><td><b>Delete existing tables?</b><br />If this option is checked, all the tables that will be used by Enano will be dropped (deleted) before the schema is executed. Do NOT use this option unless specifically instructed to.</td><td><input type="checkbox" name="drop_tables" id="dtcheck" /> <label for="dtcheck">Drop existing tables</label></td></tr>
+ − 1899
<tr><td colspan="3" style="text-align: center"><input type="button" value="Test connection" onclick="ajaxTestConnection();" /></td></tr>
+ − 1900
</table>
+ − 1901
<div class="pagenav">
+ − 1902
<table border="0">
+ − 1903
<tr>
+ − 1904
<td><input type="submit" value="Continue" onclick="return verify();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Check your PostgreSQL connection using the "Test Connection" button.<br />• Be aware that your database information will be transmitted unencrypted several times.</p></td>
+ − 1905
</tr>
+ − 1906
</table>
+ − 1907
</div>
+ − 1908
</form>
+ − 1909
<?php
+ − 1910
break;
256
+ − 1911
case "website":
244
+ − 1912
if ( !isset($_POST['_cont']) )
+ − 1913
{
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 1914
echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.';
256
+ − 1915
$template->footer();
+ − 1916
exit;
+ − 1917
}
+ − 1918
unset($_POST['_cont']);
+ − 1919
?>
+ − 1920
<script type="text/javascript">
+ − 1921
function verify()
+ − 1922
{
+ − 1923
var frm = document.forms.siteinfo;
+ − 1924
ret = true;
+ − 1925
if(frm.sitename.value.match(/^(.+)$/g) && frm.sitename.value != 'Enano')
+ − 1926
{
+ − 1927
document.getElementById('s_name').src='images/good.gif';
+ − 1928
}
+ − 1929
else
+ − 1930
{
+ − 1931
document.getElementById('s_name').src='images/bad.gif';
+ − 1932
ret = false;
+ − 1933
}
+ − 1934
if(frm.sitedesc.value.match(/^(.+)$/g))
+ − 1935
{
+ − 1936
document.getElementById('s_desc').src='images/good.gif';
+ − 1937
}
+ − 1938
else
+ − 1939
{
+ − 1940
document.getElementById('s_desc').src='images/bad.gif';
+ − 1941
ret = false;
+ − 1942
}
+ − 1943
if(frm.copyright.value.match(/^(.+)$/g))
+ − 1944
{
+ − 1945
document.getElementById('s_copyright').src='images/good.gif';
+ − 1946
}
+ − 1947
else
+ − 1948
{
+ − 1949
document.getElementById('s_copyright').src='images/bad.gif';
+ − 1950
ret = false;
+ − 1951
}
+ − 1952
if(ret) frm._cont.disabled = false;
+ − 1953
else frm._cont.disabled = true;
+ − 1954
return ret;
+ − 1955
}
+ − 1956
window.onload = verify;
+ − 1957
</script>
+ − 1958
<form name="siteinfo" action="install.php?mode=login" method="post">
+ − 1959
<?php
+ − 1960
$k = array_keys($_POST);
+ − 1961
for($i=0;$i<sizeof($_POST);$i++) {
+ − 1962
echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
+ − 1963
}
+ − 1964
?>
249
+ − 1965
<p><?php echo $lang->get('website_header_blurb'); ?></p>
256
+ − 1966
<table border="0">
249
+ − 1967
<tr>
+ − 1968
<td>
+ − 1969
<b><?php echo $lang->get('website_field_name_title'); ?></b><br />
+ − 1970
<?php echo $lang->get('website_field_name_body'); ?>
+ − 1971
</td>
+ − 1972
<td>
+ − 1973
<input onkeyup="verify();" name="sitename" type="text" size="30" />
+ − 1974
</td>
+ − 1975
<td>
+ − 1976
<img id="s_name" alt="Good/bad icon" src="images/bad.gif" />
+ − 1977
</td>
+ − 1978
</tr>
+ − 1979
<tr>
+ − 1980
<td>
+ − 1981
<b><?php echo $lang->get('website_field_desc_title'); ?></b><br />
+ − 1982
<?php echo $lang->get('website_field_desc_body'); ?>
+ − 1983
</td>
+ − 1984
<td>
+ − 1985
<input onkeyup="verify();" name="sitedesc" type="text" size="30" />
+ − 1986
</td>
+ − 1987
<td>
+ − 1988
<img id="s_desc" alt="Good/bad icon" src="images/bad.gif" />
+ − 1989
</td>
+ − 1990
</tr>
+ − 1991
<tr>
+ − 1992
<td>
+ − 1993
<b><?php echo $lang->get('website_field_copyright_title'); ?></b><br />
+ − 1994
<?php echo $lang->get('website_field_copyright_body'); ?>
+ − 1995
</td>
+ − 1996
<td>
+ − 1997
<input onkeyup="verify();" name="copyright" type="text" size="30" />
+ − 1998
</td>
+ − 1999
<td>
+ − 2000
<img id="s_copyright" alt="Good/bad icon" src="images/bad.gif" />
+ − 2001
</td>
+ − 2002
</tr>
+ − 2003
<tr>
+ − 2004
<td>
+ − 2005
<b><?php echo $lang->get('website_field_wikimode_title'); ?></b><br />
+ − 2006
<?php echo $lang->get('website_field_wikimode_body'); ?>
+ − 2007
</td>
+ − 2008
<td>
+ − 2009
<input name="wiki_mode" type="checkbox" id="wmcheck" /> <label for="wmcheck"><?php echo $lang->get('website_field_wikimode_checkbox'); ?></label>
+ − 2010
</td>
+ − 2011
<td>
+ − 2012
+ − 2013
</td>
+ − 2014
</tr>
+ − 2015
<tr>
+ − 2016
<td>
+ − 2017
<b><?php echo $lang->get('website_field_urlscheme_title'); ?></b><br />
+ − 2018
<?php echo $lang->get('website_field_urlscheme_body'); ?>
+ − 2019
</td>
+ − 2020
<td colspan="2">
+ − 2021
<input type="radio" <?php if(!is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="ugly" id="ugly" /> <label for="ugly"><?php echo $lang->get('website_field_urlscheme_ugly'); ?></label><br />
+ − 2022
<input type="radio" <?php if(is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="short" id="short" /> <label for="short"><?php echo $lang->get('website_field_urlscheme_short'); ?></label><br />
304
+ − 2023
<input type="radio" name="urlscheme" value="tiny" id="petite"> <label for="petite"><?php echo $lang->get('website_field_urlscheme_tiny'); ?></label><br />
+ − 2024
<small><a href="install.php?mode=pophelp&topic=url_schemes" onclick="window.open(this.href, 'pophelpwin', 'width=550,height=400,status=no,toolbars=no,toolbar=no,address=no,scroll=yes'); return false;"><?php echo $lang->get('website_field_urlscheme_helplink'); ?></a></small>
249
+ − 2025
</td>
+ − 2026
</tr>
256
+ − 2027
</table>
+ − 2028
<div class="pagenav">
+ − 2029
<table border="0">
249
+ − 2030
<tr>
+ − 2031
<td>
+ − 2032
<input type="submit" value="<?php echo $lang->get('meta_btn_continue'); ?>" onclick="return verify();" name="_cont" />
+ − 2033
</td>
+ − 2034
<td>
+ − 2035
<p>
+ − 2036
<span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
+ − 2037
• <?php echo $lang->get('website_objective_verify'); ?>
+ − 2038
</p>
+ − 2039
</td>
+ − 2040
</tr>
256
+ − 2041
</table>
+ − 2042
</div>
+ − 2043
</form>
+ − 2044
<?php
+ − 2045
break;
+ − 2046
case "login":
+ − 2047
if(!isset($_POST['_cont'])) {
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 2048
echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.';
256
+ − 2049
$template->footer();
+ − 2050
exit;
+ − 2051
}
+ − 2052
unset($_POST['_cont']);
+ − 2053
require('config.new.php');
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
diff
changeset
+ − 2054
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
256
+ − 2055
if ( isset($crypto_key) )
+ − 2056
{
+ − 2057
$cryptkey = $crypto_key;
+ − 2058
}
+ − 2059
if(!isset($cryptkey) || ( isset($cryptkey) && strlen($cryptkey) != AES_BITS / 4) )
+ − 2060
{
+ − 2061
$cryptkey = $aes->gen_readymade_key();
+ − 2062
$handle = @fopen(ENANO_ROOT.'/config.new.php', 'w');
+ − 2063
if(!$handle)
+ − 2064
{
249
+ − 2065
echo '<p>ERROR: Despite my repeated attempts to verify that the configuration file can be written, I was indeed prevented from opening it for writing. Maybe you\'re still on <del>crack</del> Windows?</p>';
256
+ − 2066
$template->footer();
+ − 2067
exit;
+ − 2068
}
+ − 2069
fwrite($handle, '<?php $cryptkey = \''.$cryptkey.'\'; ?>');
+ − 2070
fclose($handle);
+ − 2071
}
+ − 2072
// Sorry for the ugly hack, but this f***s up jEdit badly.
+ − 2073
echo '
+ − 2074
<script type="text/javascript">
+ − 2075
function verify()
+ − 2076
{
+ − 2077
var frm = document.forms.login;
+ − 2078
ret = true;
284
0f039028f7a5
Made the username validation regexp in install less picky since it was blacklisting two of the letters in my name. >.<
Dan
diff
changeset
+ − 2079
if ( frm.admin_user.value.match(/^([^<>&\?\'"%\/]+)$/) && !frm.admin_user.value.match(/^(?:(?:\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(?:\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$/) && frm.admin_user.value.toLowerCase() != \'anonymous\' )
256
+ − 2080
{
+ − 2081
document.getElementById(\'s_user\').src = \'images/good.gif\';
+ − 2082
}
+ − 2083
else
+ − 2084
{
+ − 2085
document.getElementById(\'s_user\').src = \'images/bad.gif\';
+ − 2086
ret = false;
+ − 2087
}
+ − 2088
if(frm.admin_pass.value.length >= 6 && frm.admin_pass.value == frm.admin_pass_confirm.value)
+ − 2089
{
+ − 2090
document.getElementById(\'s_password\').src = \'images/good.gif\';
+ − 2091
}
+ − 2092
else
+ − 2093
{
+ − 2094
document.getElementById(\'s_password\').src = \'images/bad.gif\';
+ − 2095
ret = false;
+ − 2096
}
295
f948557af068
Add warning in installer for PHP < 5.2.0; hopefully fix validation of e-mail addresses with dashes
Dan
diff
changeset
+ − 2097
if(frm.admin_email.value.match(/^(?:[\\w\\d_-]+\\.?)+@(?:(?:[\\w\\d-]\\-?)+\\.)+\\w{2,4}$/))
256
+ − 2098
{
+ − 2099
document.getElementById(\'s_email\').src = \'images/good.gif\';
+ − 2100
}
+ − 2101
else
+ − 2102
{
+ − 2103
document.getElementById(\'s_email\').src = \'images/bad.gif\';
+ − 2104
ret = false;
+ − 2105
}
+ − 2106
if(ret) frm._cont.disabled = false;
+ − 2107
else frm._cont.disabled = true;
+ − 2108
return ret;
+ − 2109
}
+ − 2110
window.onload = verify;
+ − 2111
+ − 2112
function cryptdata()
+ − 2113
{
+ − 2114
if(!verify()) return false;
+ − 2115
}
+ − 2116
</script>
+ − 2117
';
+ − 2118
?>
+ − 2119
<form name="login" action="install.php?mode=confirm" method="post" onsubmit="runEncryption();">
+ − 2120
<?php
+ − 2121
$k = array_keys($_POST);
+ − 2122
for($i=0;$i<sizeof($_POST);$i++) {
+ − 2123
echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
+ − 2124
}
+ − 2125
?>
249
+ − 2126
<p><?php echo $lang->get('login_header_blurb'); ?></p>
256
+ − 2127
<table border="0">
249
+ − 2128
<tr>
+ − 2129
<td><b><?php echo $lang->get('login_field_username_title'); ?></b><br /><small><?php echo $lang->get('login_field_username_body'); ?></small></td>
+ − 2130
<td><input onkeyup="verify();" name="admin_user" type="text" size="30" /></td>
+ − 2131
<td><img id="s_user" alt="Good/bad icon" src="images/bad.gif" /></td>
+ − 2132
</tr>
+ − 2133
<tr>
+ − 2134
<td><?php echo $lang->get('login_field_password_title'); ?></td>
+ − 2135
<td><input onkeyup="verify();" name="admin_pass" type="password" size="30" /></td>
+ − 2136
<td rowspan="2"><img id="s_password" alt="Good/bad icon" src="images/bad.gif" /></td>
+ − 2137
</tr>
+ − 2138
<tr>
+ − 2139
<td><?php echo $lang->get('login_field_password_confirm'); ?></td>
+ − 2140
<td><input onkeyup="verify();" name="admin_pass_confirm" type="password" size="30" /></td>
+ − 2141
</tr>
+ − 2142
<tr>
+ − 2143
<td><?php echo $lang->get('login_field_email_title'); ?></td>
+ − 2144
<td><input onkeyup="verify();" name="admin_email" type="text" size="30" /></td>
+ − 2145
<td><img id="s_email" alt="Good/bad icon" src="images/bad.gif" /></td>
+ − 2146
</tr>
256
+ − 2147
<tr>
+ − 2148
<td>
249
+ − 2149
<?php echo $lang->get('login_field_allowphp_title'); ?><br />
+ − 2150
<small>
+ − 2151
<span style="color: #D84308">
+ − 2152
<?php
+ − 2153
echo $lang->get('login_field_allowphp_body',
+ − 2154
array(
+ − 2155
'important_notes' => '<a href="install.php?mode=pophelp&topic=admin_embed_php" onclick="window.open(this.href, \'pophelpwin\', \'width=550,height=400,status=no,toolbars=no,toolbar=no,address=no,scroll=yes\'); return false;" style="color: #D84308; text-decoration: underline;">' . $lang->get('login_field_allowphp_isi') . '</a>'
+ − 2156
)
+ − 2157
);
+ − 2158
?>
+ − 2159
</span>
+ − 2160
</small>
256
+ − 2161
</td>
+ − 2162
<td>
249
+ − 2163
<label><input type="radio" name="admin_embed_php" value="2" checked="checked" /> <?php echo $lang->get('login_field_allowphp_disabled'); ?></label>
+ − 2164
<label><input type="radio" name="admin_embed_php" value="4" /> <?php echo $lang->get('login_field_allowphp_enabled'); ?></label>
256
+ − 2165
</td>
+ − 2166
<td></td>
+ − 2167
</tr>
249
+ − 2168
<tr><td colspan="3"><?php echo $lang->get('login_aes_blurb'); ?></td></tr>
256
+ − 2169
</table>
+ − 2170
<div class="pagenav">
+ − 2171
<table border="0">
249
+ − 2172
<tr>
+ − 2173
<td>
+ − 2174
<input type="submit" value="<?php echo $lang->get('meta_btn_continue'); ?>" onclick="return cryptdata();" name="_cont" />
+ − 2175
</td>
+ − 2176
<td>
+ − 2177
<p>
+ − 2178
<span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
+ − 2179
• <?php echo $lang->get('login_objective_remember'); ?>
+ − 2180
</p>
+ − 2181
</td>
+ − 2182
</tr>
256
+ − 2183
</table>
+ − 2184
</div>
+ − 2185
<div id="cryptdebug"></div>
249
+ − 2186
<input type="hidden" name="use_crypt" value="no" />
+ − 2187
<input type="hidden" name="crypt_key" value="<?php echo $cryptkey; ?>" />
+ − 2188
<input type="hidden" name="crypt_data" value="" />
256
+ − 2189
</form>
+ − 2190
<script type="text/javascript">
+ − 2191
// <![CDATA[
+ − 2192
var frm = document.forms.login;
+ − 2193
frm.admin_user.focus();
+ − 2194
function runEncryption()
+ − 2195
{
+ − 2196
str = '';
+ − 2197
for(i=0;i<keySizeInBits/4;i++) str+='0';
+ − 2198
var key = hexToByteArray(str);
+ − 2199
var pt = hexToByteArray(str);
+ − 2200
var ct = rijndaelEncrypt(pt, key, "ECB");
+ − 2201
var ect = byteArrayToHex(ct);
+ − 2202
switch(keySizeInBits)
+ − 2203
{
+ − 2204
case 128:
+ − 2205
v = '66e94bd4ef8a2c3b884cfa59ca342b2e';
+ − 2206
break;
+ − 2207
case 192:
+ − 2208
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7';
+ − 2209
break;
+ − 2210
case 256:
+ − 2211
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087';
+ − 2212
break;
+ − 2213
}
+ − 2214
var testpassed = ( ect == v && md5_vm_test() );
+ − 2215
var frm = document.forms.login;
+ − 2216
if(testpassed)
+ − 2217
{
+ − 2218
// alert('encryption self-test passed');
+ − 2219
frm.use_crypt.value = 'yes';
+ − 2220
var cryptkey = frm.crypt_key.value;
+ − 2221
frm.crypt_key.value = '';
+ − 2222
if(cryptkey != byteArrayToHex(hexToByteArray(cryptkey)))
+ − 2223
{
+ − 2224
alert('Byte array conversion SUCKS');
+ − 2225
testpassed = false;
+ − 2226
}
+ − 2227
cryptkey = hexToByteArray(cryptkey);
+ − 2228
if(!cryptkey || ( ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ) && cryptkey.length != keySizeInBits / 8 )
+ − 2229
{
+ − 2230
frm._cont.disabled = true;
+ − 2231
len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : '';
+ − 2232
alert('The key is messed up\nType: '+typeof(cryptkey)+len);
+ − 2233
}
+ − 2234
}
+ − 2235
else
+ − 2236
{
+ − 2237
// alert('encryption self-test FAILED');
+ − 2238
}
+ − 2239
if(testpassed)
+ − 2240
{
+ − 2241
pass = frm.admin_pass.value;
+ − 2242
pass = stringToByteArray(pass);
+ − 2243
cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB');
+ − 2244
//decrypted = rijndaelDecrypt(cryptstring, cryptkey, 'ECB');
+ − 2245
//decrypted = byteArrayToString(decrypted);
+ − 2246
//return false;
+ − 2247
if(!cryptstring)
+ − 2248
{
+ − 2249
return false;
+ − 2250
}
+ − 2251
cryptstring = byteArrayToHex(cryptstring);
+ − 2252
// document.getElementById('cryptdebug').innerHTML = '<pre>Data: '+cryptstring+'<br />Key: '+byteArrayToHex(cryptkey)+'</pre>';
+ − 2253
frm.crypt_data.value = cryptstring;
+ − 2254
frm.admin_pass.value = '';
+ − 2255
frm.admin_pass_confirm.value = '';
+ − 2256
}
+ − 2257
return false;
+ − 2258
}
+ − 2259
// ]]>
+ − 2260
</script>
+ − 2261
<?php
+ − 2262
break;
+ − 2263
case "confirm":
+ − 2264
if(!isset($_POST['_cont'])) {
+ − 2265
echo 'No POST data signature found. Please <a href="install.php?mode=sysreqs">restart the installation</a>.';
+ − 2266
$template->footer();
+ − 2267
exit;
+ − 2268
}
+ − 2269
unset($_POST['_cont']);
+ − 2270
?>
+ − 2271
<form name="confirm" action="install.php?mode=install" method="post">
+ − 2272
<?php
+ − 2273
$k = array_keys($_POST);
+ − 2274
for($i=0;$i<sizeof($_POST);$i++) {
+ − 2275
echo '<input type="hidden" name="'.htmlspecialchars($k[$i]).'" value="'.htmlspecialchars($_POST[$k[$i]]).'" />'."\n";
+ − 2276
}
+ − 2277
?>
249
+ − 2278
<h3><?php echo $lang->get('confirm_header_blurb_title'); ?></h3>
+ − 2279
<p><?php echo $lang->get('confirm_header_blurb_body'); ?></p>
256
+ − 2280
<ul>
249
+ − 2281
<li><?php echo $lang->get('confirm_lbl_db_host'); ?> <?php echo $_POST['db_host']; ?></li>
+ − 2282
<li><?php echo $lang->get('confirm_lbl_db_name'); ?> <?php echo $_POST['db_name']; ?></li>
+ − 2283
<li><?php echo $lang->get('confirm_lbl_db_user'); ?> <?php echo $_POST['db_user']; ?></li>
+ − 2284
<li><?php echo $lang->get('confirm_lbl_db_pass'); ?></li>
+ − 2285
<li><?php echo $lang->get('confirm_lbl_sitename'); ?> <?php echo $_POST['sitename']; ?></li>
+ − 2286
<li><?php echo $lang->get('confirm_lbl_sitedesc'); ?> <?php echo $_POST['sitedesc']; ?></li>
+ − 2287
<li><?php echo $lang->get('confirm_lbl_adminuser'); ?> <?php echo $_POST['admin_user']; ?></li>
+ − 2288
<li><?php echo $lang->get('confirm_lbl_aesbits'); ?> <?php echo $lang->get('confirm_lbl_aes_strength', array( 'aes_bits' => AES_BITS )); ?><br /><small><?php echo $lang->get('confirm_lbl_aes_change'); ?></small></li>
256
+ − 2289
</ul>
+ − 2290
<div class="pagenav">
+ − 2291
<table border="0">
+ − 2292
<tr>
249
+ − 2293
<td>
+ − 2294
<input type="submit" value="<?php echo $lang->get('confirm_btn_install_enano'); ?>" name="_cont" />
+ − 2295
</td>
+ − 2296
<td>
+ − 2297
<p>
+ − 2298
<span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
+ − 2299
<!-- Like this even needs to be localized. :-P -->
+ − 2300
• <?php echo $lang->get('confirm_objective_pray'); ?>
+ − 2301
</p>
+ − 2302
</td>
256
+ − 2303
</tr>
+ − 2304
</table>
+ − 2305
</div>
+ − 2306
</form>
+ − 2307
<?php
+ − 2308
break;
+ − 2309
case "install":
+ − 2310
if(!isset($_POST['db_host']) ||
+ − 2311
!isset($_POST['db_name']) ||
+ − 2312
!isset($_POST['db_user']) ||
+ − 2313
!isset($_POST['db_pass']) ||
322
+ − 2314
!isset($_POST['db_driver']) ||
256
+ − 2315
!isset($_POST['sitename']) ||
+ − 2316
!isset($_POST['sitedesc']) ||
+ − 2317
!isset($_POST['copyright']) ||
+ − 2318
!isset($_POST['admin_user']) ||
+ − 2319
!isset($_POST['admin_pass']) ||
+ − 2320
!isset($_POST['admin_embed_php']) || ( isset($_POST['admin_embed_php']) && !in_array($_POST['admin_embed_php'], array('2', '4')) ) ||
+ − 2321
!isset($_POST['urlscheme'])
+ − 2322
)
+ − 2323
{
204
473cc747022a
You know what folks, a lot of Mercurial merges failed, and I just now figured out why. So now all changes from stable are permanently synced in.
Dan
diff
changeset
+ − 2324
echo 'The installer has detected that one or more required form values is not set. Please <a href="install.php?mode=license">restart the installation</a>.';
256
+ − 2325
$template->footer();
+ − 2326
exit;
+ − 2327
}
322
+ − 2328
if ( !in_array($_POST['db_driver'], array('mysql', 'postgresql')) )
+ − 2329
{
+ − 2330
echo 'Invalid database driver.';
+ − 2331
$template->footer();
+ − 2332
exit;
+ − 2333
}
256
+ − 2334
switch($_POST['urlscheme'])
+ − 2335
{
+ − 2336
case "ugly":
+ − 2337
default:
+ − 2338
$cp = scriptPath.'/index.php?title=';
+ − 2339
break;
+ − 2340
case "short":
+ − 2341
$cp = scriptPath.'/index.php/';
+ − 2342
break;
+ − 2343
case "tiny":
+ − 2344
$cp = scriptPath.'/';
+ − 2345
break;
+ − 2346
}
+ − 2347
function err($t) { global $template; echo $t; $template->footer(); exit; }
+ − 2348
+ − 2349
// $stages = array('connect', 'decrypt', 'genkey', 'parse', 'sql', 'writeconfig', 'renameconfig', 'startapi', 'initlogs');
+ − 2350
252
+ − 2351
if ( !preg_match('/^[a-z0-9_-]*$/', $_POST['table_prefix']) )
256
+ − 2352
err('Hacking attempt was detected in table_prefix.');
+ − 2353
+ − 2354
start_install_table();
269
+ − 2355
+ − 2356
// Are we just trying to auto-rename the config files? If so, skip everything else
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2357
if ( !isset($_GET['stage']) || ( isset($_GET['stage']) && $_GET['stage'] != 'renameconfig' ) )
256
+ − 2358
{
+ − 2359
269
+ − 2360
// The stages connect, decrypt, genkey, and parse are preprocessing and don't do any actual data modification.
+ − 2361
// Thus, they need to be run on each retry, e.g. never skipped.
271
+ − 2362
run_installer_stage('connect', $lang->get('install_stg_connect_title'), 'stg_mysql_connect', $lang->get('install_stg_connect_body'), false);
269
+ − 2363
if ( isset($_POST['drop_tables']) )
+ − 2364
{
+ − 2365
// Are we supposed to drop any existing tables? If so, do it now
271
+ − 2366
run_installer_stage('drop', $lang->get('install_stg_drop_title'), 'stg_drop_tables', 'This step never returns failure');
269
+ − 2367
}
271
+ − 2368
run_installer_stage('decrypt', $lang->get('install_stg_decrypt_title'), 'stg_decrypt_admin_pass', $lang->get('install_stg_decrypt_body'), false);
+ − 2369
run_installer_stage('genkey', $lang->get('install_stg_genkey_title', array( 'aes_bits' => AES_BITS )), 'stg_generate_aes_key', $lang->get('install_stg_genkey_body'), false);
+ − 2370
run_installer_stage('parse', $lang->get('install_stg_parse_title'), 'stg_parse_schema', $lang->get('install_stg_parse_body'), false);
+ − 2371
run_installer_stage('sql', $lang->get('install_stg_sql_title'), 'stg_install', $lang->get('install_stg_sql_body'), false);
+ − 2372
run_installer_stage('writeconfig', $lang->get('install_stg_writeconfig_title'), 'stg_write_config', $lang->get('install_stg_writeconfig_body'));
269
+ − 2373
+ − 2374
// Mainstream installation complete - Enano should be usable now
+ − 2375
// The stage of starting the API is special because it has to be called out of function context.
+ − 2376
// To alleviate this, we have two functions, one that returns success and one that returns failure
+ − 2377
// If the Enano API load is successful, the success function is called to report the action to the user
+ − 2378
// If unsuccessful, the failure report is sent
+ − 2379
+ − 2380
$template_bak = $template;
+ − 2381
+ − 2382
$_GET['title'] = 'Main_Page';
+ − 2383
require('includes/common.php');
+ − 2384
+ − 2385
if ( is_object($db) && is_object($session) )
+ − 2386
{
271
+ − 2387
run_installer_stage('startapi', $lang->get('install_stg_startapi_title'), 'stg_start_api_success', '...', false);
269
+ − 2388
}
+ − 2389
else
+ − 2390
{
271
+ − 2391
run_installer_stage('startapi', $lang->get('install_stg_startapi_title'), 'stg_start_api_failure', $lang->get('install_stg_startapi_body'), false);
269
+ − 2392
}
+ − 2393
+ − 2394
// We need to be logged in (with admin rights) before logs can be flushed
+ − 2395
$admin_password = stg_decrypt_admin_pass(true);
+ − 2396
$session->login_without_crypto($_POST['admin_user'], $admin_password, false);
+ − 2397
+ − 2398
// Now that login cookies are set, initialize the session manager and ACLs
+ − 2399
$session->start();
+ − 2400
$paths->init();
+ − 2401
271
+ − 2402
run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_import_language', $lang->get('install_stg_importlang_body'));
+ − 2403
run_installer_stage('initlogs', $lang->get('install_stg_initlogs_title'), 'stg_init_logs', $lang->get('install_stg_initlogs_body'));
269
+ − 2404
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 2405
run_installer_stage('buildindex', 'Initialize search index', 'stg_build_index', 'Something went wrong while the page manager was attempting to build a search index.');
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
diff
changeset
+ − 2406
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2407
/*
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2408
* HACKERS:
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2409
* If you're making a custom distribution of Enano, put all your custom plugin-related code here.
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2410
* You have access to the full Enano API as well as being logged in with complete admin rights.
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2411
* Don't do anything horrendously fancy here, unless you add a new stage (or more than one) and
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2412
* have the progress printed out properly.
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2413
*/
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2414
269
+ − 2415
} // check for stage == renameconfig
256
+ − 2416
else
+ − 2417
{
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2418
// If we did skip the main installer routine, set $template_bak to make the reversal later work properly
269
+ − 2419
$template_bak = $template;
256
+ − 2420
}
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
diff
changeset
+ − 2421
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2422
// Final step is to rename the config file
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2423
// In early revisions of 1.0.2, this step was performed prior to the initialization of the Enano API. It was decided to move
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2424
// this stage to the end because it will fail more often than any other stage, thus making alternate routes imperative. If this
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
diff
changeset
+ − 2425
// stage fails, then no big deal, we'll just have the user rename the files manually and then let them see the pretty success message.
252
+ − 2426
run_installer_stage('renameconfig', $lang->get('install_stg_rename_title'), 'stg_rename_config', $lang->get('install_stg_rename_body'));
268
58477ab3937f
Hopefully managed to put enough hacks in there to make renaming the config file the last step, so if it fails, it can be done manually
Dan
diff
changeset
+ − 2427
256
+ − 2428
close_install_table();
+ − 2429
+ − 2430
unset($template);
+ − 2431
$template =& $template_bak;
+ − 2432
252
+ − 2433
echo '<h3>' . $lang->get('install_msg_complete_title') . '</h3>';
+ − 2434
echo '<p>' . $lang->get('install_msg_complete_body', array('finish_link' => 'install.php?mode=finish')) . '</p>';
256
+ − 2435
+ − 2436
// echo '<script type="text/javascript">window.location="'.scriptPath.'/install.php?mode=finish";</script>';
+ − 2437
+ − 2438
break;
+ − 2439
case "finish":
252
+ − 2440
echo '<h3>' . $lang->get('finish_msg_congratulations') . '</h3>
+ − 2441
' . $lang->get('finish_body') . '
+ − 2442
<p>' . $lang->get('finish_link_mainpage', array('mainpage_link' => 'index.php')) . '</p>';
256
+ − 2443
break;
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 2444
// this stage is never shown during the installation, but is provided for legal purposes
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 2445
case "showlicense":
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 2446
show_license(true);
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
diff
changeset
+ − 2447
break;
256
+ − 2448
}
+ − 2449
$template->footer();
+ − 2450
+ − 2451
?>