0
+ − 1
<?php
+ − 2
/*
+ − 3
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
+ − 4
* Version 1.0 (Banshee)
+ − 5
* Copyright (C) 2006-2007 Dan Fuhry
+ − 6
* install.php - handles everything related to installation and initial configuration
+ − 7
*
+ − 8
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
+ − 9
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 10
*
+ − 11
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 12
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 13
*/
+ − 14
11
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 15
@include('config.php');
0
+ − 16
if( ( defined('ENANO_INSTALLED') || defined('MIDGET_INSTALLED') ) && ((isset($_GET['mode']) && ($_GET['mode']!='finish' && $_GET['mode']!='css')) || !isset($_GET['mode']))) {
+ − 17
$_GET['title'] = 'Enano:WhoCaresWhatThisIs';
+ − 18
require('includes/common.php');
+ − 19
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>');
+ − 20
exit;
+ − 21
}
+ − 22
+ − 23
define('IN_ENANO_INSTALL', 'true');
+ − 24
+ − 25
define('ENANO_VERSION', '1.0');
+ − 26
// In beta versions, define ENANO_BETA_VERSION here
+ − 27
+ − 28
if(!defined('scriptPath')) {
+ − 29
$sp = dirname($_SERVER['REQUEST_URI']);
+ − 30
if($sp == '/' || $sp == '\\') $sp = '';
+ − 31
define('scriptPath', $sp);
+ − 32
}
+ − 33
+ − 34
if(!defined('contentPath')) {
+ − 35
$sp = dirname($_SERVER['REQUEST_URI']);
+ − 36
if($sp == '/' || $sp == '\\') $sp = '';
+ − 37
define('contentPath', $sp);
+ − 38
}
+ − 39
global $_starttime, $this_page, $sideinfo;
+ − 40
$_starttime = microtime(true);
+ − 41
+ − 42
define('ENANO_ROOT', dirname(__FILE__));
+ − 43
+ − 44
function is_page($p) { return true; }
+ − 45
require('includes/wikiformat.php');
+ − 46
require('includes/constants.php');
+ − 47
require('includes/rijndael.php');
+ − 48
require('includes/functions.php');
+ − 49
+ − 50
//die('Key size: ' . AES_BITS . '<br />Block size: ' . AES_BLOCKSIZE);
+ − 51
+ − 52
if(!function_exists('wikiFormat')) {
+ − 53
function wikiFormat($message, $filter_links = true) {
+ − 54
$wiki = & Text_Wiki::singleton('Mediawiki');
+ − 55
$wiki->setRenderConf('Xhtml', 'code', 'css_filename', 'codefilename');
+ − 56
$wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
+ − 57
$result = $wiki->transform($message, 'Xhtml');
+ − 58
+ − 59
// HTML fixes
+ − 60
$result = preg_replace('#<tr>([\s]*?)<\/tr>#is', '', $result);
+ − 61
$result = preg_replace('#<p>([\s]*?)<\/p>#is', '', $result);
+ − 62
$result = preg_replace('#<br />([\s]*?)<table#is', '<table', $result);
+ − 63
+ − 64
return $result;
+ − 65
}
+ − 66
}
+ − 67
+ − 68
global $failed, $warned;
+ − 69
$failed = false;
+ − 70
$warned = false;
+ − 71
function not($var) { if($var) return false; else return true; }
+ − 72
function run_test($code, $desc, $extended_desc, $warn = false)
+ − 73
{
+ − 74
global $failed, $warned;
+ − 75
static $cv = true;
+ − 76
$cv = not($cv);
+ − 77
$val = eval($code);
+ − 78
if($val)
+ − 79
{
+ − 80
if($cv) $color='CCFFCC'; else $color='AAFFAA';
+ − 81
echo "<tr><td style='background-color: #$color; width: 500px;'>$desc</td><td style='padding-left: 10px;'><img alt='Test passed' src='images/good.gif' /></td></tr>";
+ − 82
} elseif(!$val && $warn) {
+ − 83
if($cv) $color='FFFFCC'; else $color='FFFFAA';
+ − 84
echo "<tr><td style='background-color: #$color; width: 500px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test passed with warning' src='images/unknown.gif' /></td></tr>";
+ − 85
$warned = true;
+ − 86
} else {
+ − 87
if($cv) $color='FFCCCC'; else $color='FFAAAA';
+ − 88
echo "<tr><td style='background-color: #$color; width: 500px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test failed' src='images/bad.gif' /></td></tr>";
+ − 89
$failed = true;
+ − 90
}
+ − 91
}
+ − 92
function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; }
+ − 93
+ − 94
require_once('includes/template.php');
+ − 95
+ − 96
if(!isset($_GET['mode'])) $_GET['mode'] = 'welcome';
+ − 97
switch($_GET['mode'])
+ − 98
{
+ − 99
case 'mysql_test':
+ − 100
error_reporting(0);
+ − 101
$dbhost = rawurldecode($_POST['host']);
+ − 102
$dbname = rawurldecode($_POST['name']);
+ − 103
$dbuser = rawurldecode($_POST['user']);
+ − 104
$dbpass = rawurldecode($_POST['pass']);
+ − 105
$dbrootuser = rawurldecode($_POST['root_user']);
+ − 106
$dbrootpass = rawurldecode($_POST['root_pass']);
+ − 107
if($dbrootuser != '')
+ − 108
{
+ − 109
$conn = mysql_connect($dbhost, $dbrootuser, $dbrootpass);
+ − 110
if(!$conn)
+ − 111
{
+ − 112
$e = mysql_error();
+ − 113
if(strstr($e, "Lost connection"))
+ − 114
die('host'.$e);
+ − 115
else
+ − 116
die('root'.$e);
+ − 117
}
+ − 118
$rsp = 'good';
+ − 119
$q = mysql_query('USE '.$dbname, $conn);
+ − 120
if(!$q)
+ − 121
{
+ − 122
$e = mysql_error();
+ − 123
if(strstr($e, 'Unknown database'))
+ − 124
{
+ − 125
$rsp .= '_creating_db';
+ − 126
}
+ − 127
}
+ − 128
mysql_close($conn);
+ − 129
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
+ − 130
if(!$conn)
+ − 131
{
+ − 132
$e = mysql_error();
+ − 133
if(strstr($e, "Lost connection"))
+ − 134
die('host'.$e);
+ − 135
else
+ − 136
$rsp .= '_creating_user';
+ − 137
}
+ − 138
mysql_close($conn);
+ − 139
die($rsp);
+ − 140
}
+ − 141
else
+ − 142
{
+ − 143
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
+ − 144
if(!$conn)
+ − 145
{
+ − 146
$e = mysql_error();
+ − 147
if(strstr($e, "Lost connection"))
+ − 148
die('host'.$e);
+ − 149
else
+ − 150
die('auth'.$e);
+ − 151
}
+ − 152
$q = mysql_query('USE '.$dbname, $conn);
+ − 153
if(!$q)
+ − 154
{
+ − 155
$e = mysql_error();
+ − 156
if(strstr($e, 'Unknown database'))
+ − 157
{
+ − 158
die('name'.$e);
+ − 159
}
+ − 160
else
+ − 161
{
+ − 162
die('perm'.$e);
+ − 163
}
+ − 164
}
+ − 165
}
+ − 166
$v = mysql_get_server_info();
+ − 167
if(version_compare($v, '4.1.17', '<')) die('vers'.$v);
+ − 168
mysql_close($conn);
+ − 169
die('good');
+ − 170
break;
11
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 171
case 'pophelp':
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 172
$topic = ( isset($_GET['topic']) ) ? $_GET['topic'] : 'invalid';
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 173
switch($topic)
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 174
{
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 175
case 'admin_embed_php':
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 176
$title = 'Allow administrators to embed PHP';
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 177
$content = '<p>This option allows you to control whether anything between the standard <?php and ?> tags will be treated as
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 178
PHP code by Enano. If this option is enabled, and members of the Administrators group use these tags, Enano will
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 179
execute that code when the page is loaded. There are obvious potential security implications here, which should
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 180
be carefully considered before enabling this option.</p>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 181
<p>If you are the only administrator of this site, or if you have a high level of trust for those will be administering
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 182
the site with you, you should enable this to allow extreme customization of pages.</p>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 183
<p>Leave this option off if you are at all concerned about security – if your account is compromised and PHP embedding
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 184
is enabled, an attacker can run arbitrary code on your server! Enabling this will also allow administrators to
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 185
embed Javascript and arbitrary HTML and CSS.</p>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 186
<p>If you don\'t have experience coding in PHP, you can safely disable this option. You may change this at any time
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 187
using the ACL editor by selecting the Administrators group and This Entire Website under the scope selection, or by
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 188
using the "embedded PHP kill switch" in the administration panel.</p>';
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 189
break;
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 190
default:
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 191
$title = 'Invalid topic';
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 192
$content = 'Invalid help topic.';
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 193
break;
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 194
}
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 195
echo <<<EOF
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 196
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 197
<html>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 198
<head>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 199
<title>Enano installation quick help • {$title}</title>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 200
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 201
<style type="text/css">
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 202
body {
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 203
font-family: trebuchet ms, verdana, arial, helvetica, sans-serif;
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 204
font-size: 9pt;
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 205
}
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 206
h2 { border-bottom: 1px solid #90B0D0; margin-bottom: 0; }
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 207
h3 { font-size: 11pt; font-weight: bold; }
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 208
li { list-style: url(../images/bullet.gif); }
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 209
p { margin: 1.0em; }
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 210
blockquote { background-color: #F4F4F4; border: 1px dotted #406080; margin: 1em; padding: 10px; max-height: 250px; overflow: auto; }
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 211
a { color: #7090B0; }
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 212
a:hover { color: #90B0D0; }
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 213
</style>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 214
</head>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 215
<body>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 216
<h2>{$title}</h2>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 217
{$content}
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 218
<p style="text-align: right;">
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 219
<a href="#" onclick="window.close(); return false;">Close window</a>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 220
</p>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 221
</body>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 222
</html>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 223
EOF;
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 224
exit;
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 225
break;
0
+ − 226
default:
+ − 227
break;
+ − 228
}
+ − 229
+ − 230
$template = new template_nodb();
+ − 231
$template->load_theme('oxygen', 'bleu', false);
+ − 232
+ − 233
$modestrings = Array(
+ − 234
'welcome' => 'Welcome',
+ − 235
'license' => 'License Agreement',
+ − 236
'sysreqs' => 'Server requirements',
+ − 237
'database'=> 'Database information',
+ − 238
'website' => 'Website configuration',
+ − 239
'login' => 'Administration login',
+ − 240
'confirm' => 'Confirm installation',
+ − 241
'install' => 'Database installation',
+ − 242
'finish' => 'Installation complete'
+ − 243
);
+ − 244
+ − 245
$sideinfo = '';
+ − 246
$vars = $template->extract_vars('elements.tpl');
+ − 247
$p = $template->makeParserText($vars['sidebar_button']);
+ − 248
foreach ( $modestrings as $id => $str )
+ − 249
{
+ − 250
if ( $_GET['mode'] == $id )
+ − 251
{
+ − 252
$flags = 'style="font-weight: bold; text-decoration: underline;"';
+ − 253
$this_page = $str;
+ − 254
}
+ − 255
else
+ − 256
{
+ − 257
$flags = '';
+ − 258
}
+ − 259
$p->assign_vars(Array(
+ − 260
'HREF' => '#',
+ − 261
'FLAGS' => $flags . ' onclick="return false;"',
+ − 262
'TEXT' => $str
+ − 263
));
+ − 264
$sideinfo .= $p->run();
+ − 265
}
+ − 266
+ − 267
$template->init_vars();
+ − 268
+ − 269
if(isset($_GET['mode']) && $_GET['mode'] == 'css')
+ − 270
{
+ − 271
header('Content-type: text/css');
+ − 272
echo $template->get_css();
+ − 273
exit;
+ − 274
}
+ − 275
+ − 276
$template->header();
+ − 277
if(!isset($_GET['mode'])) $_GET['mode'] = 'license';
+ − 278
switch($_GET['mode'])
+ − 279
{
+ − 280
default:
+ − 281
case 'welcome':
+ − 282
?>
+ − 283
<div style="text-align: center; margin-top: 10px;">
+ − 284
<img alt="[ Enano CMS Project logo ]" src="images/enano-artwork/installer-greeting-blue.png" style="display: block; margin: 0 auto; padding-left: 100px;" />
+ − 285
<h2>Welcome to Enano</h2>
+ − 286
<h3>version 1.0 – stable<br />
+ − 287
<span style="font-weight: normal;">also affectionately known as "banshee" <tt>:)</tt></span></h3>
+ − 288
<?php
+ − 289
if ( file_exists('./_nightly.php') )
+ − 290
{
+ − 291
echo '<div class="warning-box" style="text-align: left; margin: 10px 0;"><b>You are about to install a NIGHTLY BUILD of Enano.</b><br />Nightly builds are NOT upgradeable and may contain serious flaws, security problems, or extraneous debugging information. Installing this version of Enano on a production site is NOT recommended.</div>';
+ − 292
}
+ − 293
?>
+ − 294
<form action="install.php?mode=license" method="post">
+ − 295
<input type="submit" value="Start installation" />
+ − 296
</form>
+ − 297
</div>
+ − 298
<?php
+ − 299
break;
+ − 300
case "license":
+ − 301
?>
+ − 302
<h3>Welcome to the Enano installer.</h3>
+ − 303
<p>Thank you for choosing Enano as your CMS. You've selected the finest in design, the strongest in security, and the latest in Web 2.0 toys. Trust us, you'll like it.</p>
+ − 304
<p>To get started, please read and accept the following license agreement. You've probably seen it before.</p>
+ − 305
<div style="height: 500px; clip: rect(0px,auto,500px,auto); overflow: auto; padding: 10px; border: 1px dashed #456798; margin: 1em;">
+ − 306
<h2>GNU General Public License</h2>
+ − 307
<h3>Declaration of license usage</h3>
+ − 308
<p>Enano is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p>
+ − 309
<p>This program is distributed in the hope that it will be useful, but <u>without any warranty</u>; without even the implied warranty of <u>merchantability</u> or <u>fitness for a particular purpose</u>. See the GNU General Public License (below) for more details.</p>
+ − 310
<h3>Human-readable version</h3>
+ − 311
<p>Enano is distributed under certain licensing terms that we believe make it of the greatest possible use to the public. The license we distribute it under, the GNU General Public License, provides certain terms and conditions that, rather than limit your use of Enano, allow you to get the most out of it. If you would like to read the full text, it can be found below. Here is a human-readable version that we think is a little easier to understand.</p>
+ − 312
<ul>
+ − 313
<li>You may to run Enano for any purpose.</li>
+ − 314
<li>You may study how Enano works and adapt it to your needs.</li>
+ − 315
<li>You may redistribute copies so you can help your neighbor.</li>
+ − 316
<li>You may improve Enano and release your improvements to the public, so that the whole community benefits.</li>
+ − 317
</ul>
+ − 318
<p>You may exercise the freedoms specified here provided that you comply with the express conditions of this license. The principal conditions are:</p>
+ − 319
<ul>
+ − 320
<li>You must conspicuously and appropriately publish on each copy distributed an appropriate copyright notice and disclaimer of warranty and keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of Enano a copy of the GNU General Public License along with Enano. Any translation of the GNU General Public License must be accompanied by the GNU General Public License.</li>
+ − 321
<li>If you modify your copy or copies of Enano or any portion of it, or develop a program based upon it, you may distribute the resulting work provided you do so under the GNU General Public License. Any translation of the GNU General Public License must be accompanied by the GNU General Public License.</li>
+ − 322
<li>If you copy or distribute Enano, you must accompany it with the complete corresponding machine-readable source code or with a written offer, valid for at least three years, to furnish the complete corresponding machine-readable source code.</li>
+ − 323
</ul>
+ − 324
<p><b>Disclaimer</b>: The above text is not a license. It is simply a handy reference for understanding the Legal Code (the full license) – it is a human-readable expression of some of its key terms. Think of it as the user-friendly interface to the Legal Code beneath. The above text itself has no legal value, and its contents do not appear in the actual license.<br /><span style="color: #CCC">Text copied from the <a href="http://creativecommons.org/licenses/GPL/2.0/">Creative Commons GPL Deed page</a></span></p>
+ − 325
<?php
+ − 326
if ( defined('ENANO_BETA_VERSION') )
+ − 327
{
+ − 328
?>
+ − 329
<h3>Notice for prerelease versions</h3>
+ − 330
<p>This version of Enano is designed only for testing and evaluation purposes. <b>It is not yet completely stable, and should not be used on production websites.</b> As with any Enano version, Dan Fuhry and the Enano team cannot be responsible for any damage, physical or otherwise, to any property as a result of the use of Enano. While security is a number one priority, sometimes things slip through.</p>
+ − 331
<?php
+ − 332
}
+ − 333
?>
+ − 334
<h3>Lawyer-readable version</h3>
+ − 335
<?php echo wikiFormat(file_get_contents(ENANO_ROOT . '/GPL')); ?>
+ − 336
</div>
+ − 337
<div class="pagenav">
+ − 338
<form action="install.php?mode=sysreqs" method="post">
+ − 339
<table border="0">
+ − 340
<tr>
+ − 341
<td><input type="submit" value="Continue" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Ensure that you agree with the terms of the license<br />• Have your database host, name, username, and password available</p></td>
+ − 342
</tr>
+ − 343
</table>
+ − 344
</form>
+ − 345
</div>
+ − 346
<?php
+ − 347
break;
+ − 348
case "sysreqs":
+ − 349
error_reporting(E_ALL);
+ − 350
?>
+ − 351
<h3>Checking your server</h3>
+ − 352
<p>Enano has several requirements that must be met before it can be installed. If all is good then note any warnings and click Continue below.</p>
+ − 353
<table border="0" cellspacing="0" cellpadding="0">
+ − 354
<?php
+ − 355
run_test('return version_compare(\'4.3.0\', PHP_VERSION, \'<\');', 'PHP Version >=4.3.0', 'It seems that the version of PHP that your server is running is too old to support Enano properly. If this is your server, please upgrade to the most recent version of PHP, remembering to use the --with-mysql configure option if you compile it yourself. If this is not your server, please contact your webhost and ask them if it would be possible to upgrade PHP. If this is not possible, you will need to switch to a different webhost in order to use Enano.');
+ − 356
run_test('return function_exists(\'mysql_connect\');', 'MySQL extension for PHP', 'It seems that your PHP installation does not have the MySQL extension enabled. If this is your own server, you may need to just enable the "libmysql.so" extension in php.ini. If you do not have the MySQL extension installed, you will need to either use your distribution\'s package manager to install it, or you will have to compile PHP from source. If you compile PHP from source, please remember to use the "--with-mysql" configure option, and you will have to have the MySQL development files installed (they usually are). If this is not your server, please contact your hosting company and ask them to install the PHP MySQL extension.');
+ − 357
run_test('return @ini_get(\'file_uploads\');', 'File upload support', 'It seems that your server does not support uploading files. Enano *requires* this functionality in order to work properly. Please ask your server administrator to set the "file_uploads" option in php.ini to "On".');
+ − 358
run_test('return is_apache();', 'Apache HTTP Server', 'Apparently your server is running a web server other than Apache. Enano will work nontheless, but there are some known bugs with non-Apache servers, and the "fancy" URLs will not work properly. The "Standard URLs" option will be set on the website configuration page, only change it if you are absolutely certain that your server is running Apache.', true);
+ − 359
//run_test('return function_exists(\'finfo_file\');', 'Fileinfo PECL extension', 'The MIME magic PHP extension is used to determine the type of a file by looking for a certain "magic" string of characters inside it. This functionality is used by Enano to more effectively prevent malicious file uploads. The MIME magic option will be disabled by default.', true);
+ − 360
run_test('return is_writable(ENANO_ROOT.\'/config.php\');', 'Configuration file writable', 'It looks like the configuration file, config.php, is not writable. Enano needs to be able to write to this file in order to install.<br /><br /><b>If you are installing Enano on a SourceForge web site:</b><br />SourceForge mounts the web partitions read-only now, so you will need to use the project shell service to symlink config.php to a file in the /tmp/persistent directory.');
+ − 361
run_test('return file_exists(\'/usr/bin/convert\');', 'ImageMagick support', 'Enano uses ImageMagick to scale images into thumbnails. Because ImageMagick was not found on your server, Enano will use the width= and height= attributes on the <img> tag to scale images. This can cause somewhat of a performance increase, but bandwidth usage will be higher, especially if you use high-resolution images on your site.<br /><br />If you are sure that you have ImageMagick, you can set the location of the "convert" program using the administration panel after installation is complete.', true);
+ − 362
run_test('return is_writable(ENANO_ROOT.\'/cache/\');', 'Cache directory writable', 'Apparently the cache/ directory is not writable. Enano will still work, but you will not be able to cache thumbnails, meaning the server will need to re-render them each time they are requested. In some cases, this can cause a significant slowdown.', true);
+ − 363
echo '</table>';
+ − 364
if(!$failed)
+ − 365
{
+ − 366
?>
+ − 367
+ − 368
<div class="pagenav">
+ − 369
<?php
+ − 370
if($warned) {
+ − 371
echo '<table border="0" cellspacing="0" cellpadding="0">';
+ − 372
run_test('return false;', 'Some scalebacks were made due to your server configuration.', 'Enano has detected that some of the features or configuration settings on your server are not optimal for the best behavior and/or performance for Enano. As a result, certain features or enhancements that are part of Enano have been disabled to prevent further errors. You have seen those "fatal error" notices that spew from PHP, haven\'t you?<br /><br />Fatal error:</b> call to undefined function wannahokaloogie() in file <b>'.__FILE__.'</b> on line <b>'.__LINE__.'', true);
+ − 373
echo '</table>';
+ − 374
} else {
+ − 375
echo '<table border="0" cellspacing="0" cellpadding="0">';
+ − 376
run_test('return true;', '<b>Your server meets all the requirements for running Enano.</b><br />Click the button below to continue the installation.', 'You should never see this text. Congratulations for being a Enano hacker!');
+ − 377
echo '</table>';
+ − 378
}
+ − 379
?>
+ − 380
<form action="install.php?mode=database" method="post">
+ − 381
<table border="0">
+ − 382
<tr>
+ − 383
<td><input type="submit" value="Continue" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Ensure that you are satisfied with any scalebacks that may have been made to accomodate your server configuration<br />• Have your database host, name, username, and password available</p></td>
+ − 384
</tr>
+ − 385
</table>
+ − 386
</form>
+ − 387
</div>
+ − 388
<?php
+ − 389
} else {
+ − 390
if($failed) {
+ − 391
echo '<div class="pagenav"><table border="0" cellspacing="0" cellpadding="0">';
+ − 392
run_test('return false;', 'Your server does not meet the requirements for Enano to run.', 'As a precaution, Enano will not install until the above requirements have been met. Contact your server administrator or hosting company and convince them to upgrade. Good luck.');
+ − 393
echo '</table></div>';
+ − 394
}
+ − 395
}
+ − 396
?>
+ − 397
<?php
+ − 398
break;
+ − 399
case "database":
+ − 400
?>
+ − 401
<script type="text/javascript">
+ − 402
function ajaxGet(uri, f) {
+ − 403
if (window.XMLHttpRequest) {
+ − 404
ajax = new XMLHttpRequest();
+ − 405
} else {
+ − 406
if (window.ActiveXObject) {
+ − 407
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 408
} else {
+ − 409
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 410
return;
+ − 411
}
+ − 412
}
+ − 413
ajax.onreadystatechange = f;
+ − 414
ajax.open('GET', uri, true);
+ − 415
ajax.send(null);
+ − 416
}
+ − 417
+ − 418
function ajaxPost(uri, parms, f) {
+ − 419
if (window.XMLHttpRequest) {
+ − 420
ajax = new XMLHttpRequest();
+ − 421
} else {
+ − 422
if (window.ActiveXObject) {
+ − 423
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 424
} else {
+ − 425
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 426
return;
+ − 427
}
+ − 428
}
+ − 429
ajax.onreadystatechange = f;
+ − 430
ajax.open('POST', uri, true);
+ − 431
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ − 432
ajax.setRequestHeader("Content-length", parms.length);
+ − 433
ajax.setRequestHeader("Connection", "close");
+ − 434
ajax.send(parms);
+ − 435
}
+ − 436
function ajaxTestConnection()
+ − 437
{
+ − 438
v = verify();
+ − 439
if(!v)
+ − 440
{
+ − 441
alert('One or more of the form fields is incorrect. Please correct any information in the form that has an "X" next to it.');
+ − 442
return false;
+ − 443
}
+ − 444
var frm = document.forms.dbinfo;
+ − 445
db_host = escape(frm.db_host.value.replace('+', '%2B'));
+ − 446
db_name = escape(frm.db_name.value.replace('+', '%2B'));
+ − 447
db_user = escape(frm.db_user.value.replace('+', '%2B'));
+ − 448
db_pass = escape(frm.db_pass.value.replace('+', '%2B'));
+ − 449
db_root_user = escape(frm.db_root_user.value.replace('+', '%2B'));
+ − 450
db_root_pass = escape(frm.db_root_pass.value.replace('+', '%2B'));
+ − 451
+ − 452
parms = 'host='+db_host+'&name='+db_name+'&user='+db_user+'&pass='+db_pass+'&root_user='+db_root_user+'&root_pass='+db_root_pass;
+ − 453
ajaxPost('<?php echo scriptPath; ?>/install.php?mode=mysql_test', parms, function() {
+ − 454
if(ajax.readyState==4)
+ − 455
{
+ − 456
s = ajax.responseText.substr(0, 4);
+ − 457
t = ajax.responseText.substr(4, ajax.responseText.length);
+ − 458
if(s.substr(0, 4)=='good')
+ − 459
{
+ − 460
document.getElementById('s_db_host').src='images/good.gif';
+ − 461
document.getElementById('s_db_name').src='images/good.gif';
+ − 462
document.getElementById('s_db_auth').src='images/good.gif';
+ − 463
document.getElementById('s_db_root').src='images/good.gif';
+ − 464
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.';
+ − 465
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.';
+ − 466
document.getElementById('s_mysql_version').src='images/good.gif';
+ − 467
document.getElementById('e_mysql_version').innerHTML = 'Your version of MySQL meets Enano requirements.';
+ − 468
}
+ − 469
else
+ − 470
{
+ − 471
switch(s)
+ − 472
{
+ − 473
case 'host':
+ − 474
document.getElementById('s_db_host').src='images/bad.gif';
+ − 475
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 476
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 477
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 478
document.getElementById('e_db_host').innerHTML = '<b>Error:<\/b> The database server "'+document.forms.dbinfo.db_host.value+'" couldn\'t be contacted.<br \/>'+t;
+ − 479
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 480
break;
+ − 481
case 'auth':
+ − 482
document.getElementById('s_db_host').src='images/good.gif';
+ − 483
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 484
document.getElementById('s_db_auth').src='images/bad.gif';
+ − 485
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 486
document.getElementById('e_db_auth').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
+ − 487
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 488
break;
+ − 489
case 'perm':
+ − 490
document.getElementById('s_db_host').src='images/good.gif';
+ − 491
document.getElementById('s_db_name').src='images/bad.gif';
+ − 492
document.getElementById('s_db_auth').src='images/good.gif';
+ − 493
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 494
document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> Access to the specified database using those login credentials was denied.<br \/>'+t;
+ − 495
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 496
break;
+ − 497
case 'name':
+ − 498
document.getElementById('s_db_host').src='images/good.gif';
+ − 499
document.getElementById('s_db_name').src='images/bad.gif';
+ − 500
document.getElementById('s_db_auth').src='images/good.gif';
+ − 501
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 502
document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> The specified database does not exist<br \/>'+t;
+ − 503
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 504
break;
+ − 505
case 'root':
+ − 506
document.getElementById('s_db_host').src='images/good.gif';
+ − 507
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 508
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 509
document.getElementById('s_db_root').src='images/bad.gif';
+ − 510
document.getElementById('e_db_root').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t;
+ − 511
document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.';
+ − 512
break;
+ − 513
case 'vers':
+ − 514
document.getElementById('s_db_host').src='images/good.gif';
+ − 515
document.getElementById('s_db_name').src='images/good.gif';
+ − 516
document.getElementById('s_db_auth').src='images/good.gif';
+ − 517
document.getElementById('s_db_root').src='images/good.gif';
+ − 518
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.';
+ − 519
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.';
+ − 520
+ − 521
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().';
+ − 522
document.getElementById('s_mysql_version').src='images/bad.gif';
+ − 523
default:
+ − 524
alert(t);
+ − 525
break;
+ − 526
}
+ − 527
}
+ − 528
}
+ − 529
});
+ − 530
}
+ − 531
function verify()
+ − 532
{
+ − 533
document.getElementById('e_db_host').innerHTML = '';
+ − 534
document.getElementById('e_db_auth').innerHTML = '';
+ − 535
document.getElementById('e_db_name').innerHTML = '';
+ − 536
document.getElementById('e_db_root').innerHTML = '';
+ − 537
var frm = document.forms.dbinfo;
+ − 538
ret = true;
+ − 539
if(frm.db_host.value != '')
+ − 540
{
+ − 541
document.getElementById('s_db_host').src='images/unknown.gif';
+ − 542
}
+ − 543
else
+ − 544
{
+ − 545
document.getElementById('s_db_host').src='images/bad.gif';
+ − 546
ret = false;
+ − 547
}
+ − 548
if(frm.db_name.value.match(/^([a-z0-9_]+)$/g))
+ − 549
{
+ − 550
document.getElementById('s_db_name').src='images/unknown.gif';
+ − 551
}
+ − 552
else
+ − 553
{
+ − 554
document.getElementById('s_db_name').src='images/bad.gif';
+ − 555
ret = false;
+ − 556
}
+ − 557
if(frm.db_user.value != '')
+ − 558
{
+ − 559
document.getElementById('s_db_auth').src='images/unknown.gif';
+ − 560
}
+ − 561
else
+ − 562
{
+ − 563
document.getElementById('s_db_auth').src='images/bad.gif';
+ − 564
ret = false;
+ − 565
}
+ − 566
if(frm.table_prefix.value.match(/^([a-z0-9_]*)$/g))
+ − 567
{
+ − 568
document.getElementById('s_table_prefix').src='images/good.gif';
+ − 569
}
+ − 570
else
+ − 571
{
+ − 572
document.getElementById('s_table_prefix').src='images/bad.gif';
+ − 573
ret = false;
+ − 574
}
+ − 575
if(frm.db_root_user.value == '')
+ − 576
{
+ − 577
document.getElementById('s_db_root').src='images/good.gif';
+ − 578
}
+ − 579
else if(frm.db_root_user.value != '' && frm.db_root_pass.value == '')
+ − 580
{
+ − 581
document.getElementById('s_db_root').src='images/bad.gif';
+ − 582
ret = false;
+ − 583
}
+ − 584
else
+ − 585
{
+ − 586
document.getElementById('s_db_root').src='images/unknown.gif';
+ − 587
}
+ − 588
if(ret) frm._cont.disabled = false;
+ − 589
else frm._cont.disabled = true;
+ − 590
return ret;
+ − 591
}
+ − 592
window.onload = verify;
+ − 593
</script>
+ − 594
<p>Now we need some information that will allow Enano to contact your database server. Enano uses MySQL as a data storage backend,
+ − 595
and we need to have access to a MySQL server in order to continue.</p>
+ − 596
<p>If you do not have access to a MySQL server, and you are using your own server, you can download MySQL for free from
+ − 597
<a href="http://www.mysql.com/">MySQL.com</a>. <b>Please note that, like Enano, MySQL is licensed under the GNU GPL.</b>
+ − 598
If you need to modify MySQL and then distribute your modifications, you must either distribute them under the terms of the GPL
+ − 599
or purchase a proprietary license.</p>
+ − 600
<form name="dbinfo" action="install.php?mode=website" method="post">
+ − 601
<table border="0">
+ − 602
<tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr>
+ − 603
<tr><td><b>Database hostname</b><br />This is the hostname (or sometimes the IP address) of your MySQL 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>
+ − 604
<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 MySQL user with administrative rights.<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>
+ − 605
<tr><td rowspan="2"><b>Database login</b><br />These fields should be the username and password of a user with "select", "insert", "update", "delete", "create table", and "replace" privileges for your database.<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>
+ − 606
<tr><td><input name="db_pass" size="30" type="password" /></td></tr>
+ − 607
<tr><td colspan="3" style="text-align: center"><h3>Optional information</h3></td></tr>
+ − 608
<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>
+ − 609
<tr><td rowspan="2"><b>Database administrative login</b><br />If the MySQL database or username that you entered above does not exist yet, you can create them here, assuming that you have the login information for an administrative user (such as root). 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>
+ − 610
<tr><td><input onkeyup="verify();" name="db_root_pass" size="30" type="password" /></td></tr>
+ − 611
<tr><td><b>MySQL version</b></td><td id="e_mysql_version">MySQL version information will be checked when you click "Test Connection".</td><td><img id="s_mysql_version" alt="Good/bad icon" src="images/unknown.gif" /></td></tr>
+ − 612
<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>
+ − 613
<tr><td colspan="3" style="text-align: center"><input type="button" value="Test connection" onclick="ajaxTestConnection();" /></td></tr>
+ − 614
</table>
+ − 615
<div class="pagenav">
+ − 616
<table border="0">
+ − 617
<tr>
+ − 618
<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 MySQL connection using the "Test Connection" button.<br />• Be aware that your database information will be transmitted unencrypted several times.</p></td>
+ − 619
</tr>
+ − 620
</table>
+ − 621
</div>
+ − 622
</form>
+ − 623
<?php
+ − 624
break;
+ − 625
case "website":
+ − 626
if(!isset($_POST['_cont'])) {
+ − 627
echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.';
+ − 628
$template->footer();
+ − 629
exit;
+ − 630
}
+ − 631
unset($_POST['_cont']);
+ − 632
?>
+ − 633
<script type="text/javascript">
+ − 634
function verify()
+ − 635
{
+ − 636
var frm = document.forms.siteinfo;
+ − 637
ret = true;
+ − 638
if(frm.sitename.value.match(/^([A-z0-9 ]+)$/g) && frm.sitename.value != 'Enano')
+ − 639
{
+ − 640
document.getElementById('s_name').src='images/good.gif';
+ − 641
}
+ − 642
else
+ − 643
{
+ − 644
document.getElementById('s_name').src='images/bad.gif';
+ − 645
ret = false;
+ − 646
}
+ − 647
if(frm.sitedesc.value.match(/^(.+)$/g))
+ − 648
{
+ − 649
document.getElementById('s_desc').src='images/good.gif';
+ − 650
}
+ − 651
else
+ − 652
{
+ − 653
document.getElementById('s_desc').src='images/bad.gif';
+ − 654
ret = false;
+ − 655
}
+ − 656
if(frm.copyright.value.match(/^(.+)$/g))
+ − 657
{
+ − 658
document.getElementById('s_copyright').src='images/good.gif';
+ − 659
}
+ − 660
else
+ − 661
{
+ − 662
document.getElementById('s_copyright').src='images/bad.gif';
+ − 663
ret = false;
+ − 664
}
+ − 665
if(ret) frm._cont.disabled = false;
+ − 666
else frm._cont.disabled = true;
+ − 667
return ret;
+ − 668
}
+ − 669
window.onload = verify;
+ − 670
</script>
+ − 671
<form name="siteinfo" action="install.php?mode=login" method="post">
+ − 672
<?php
+ − 673
$k = array_keys($_POST);
+ − 674
for($i=0;$i<sizeof($_POST);$i++) {
+ − 675
echo '<input type="hidden" name="'.$k[$i].'" value="'.$_POST[$k[$i]].'" />'."\n";
+ − 676
}
+ − 677
?>
+ − 678
<p>The next step is to enter some information about your website. You can always change this information later, using the administration panel.</p>
+ − 679
<table border="0">
+ − 680
<tr><td><b>Website name</b><br />The display name of your website. Allowed characters are uppercase and lowercase letters, numerals, and spaces. This must not be blank or "Enano".</td><td><input onkeyup="verify();" name="sitename" type="text" size="30" /></td><td><img id="s_name" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 681
<tr><td><b>Website description</b><br />This text will be shown below the name of your website.</td><td><input onkeyup="verify();" name="sitedesc" type="text" size="30" /></td><td><img id="s_desc" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 682
<tr><td><b>Copyright info</b><br />This should be a one-line legal notice that will appear at the bottom of all your pages.</td><td><input onkeyup="verify();" name="copyright" type="text" size="30" /></td><td><img id="s_copyright" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 683
<tr><td><b>Wiki mode</b><br />This feature allows people to create and edit pages on your site. Enano keeps a history of all page modifications, and you can protect pages to prevent editing.</td><td><input name="wiki_mode" type="checkbox" id="wmcheck" /> <label for="wmcheck">Yes, make my website a wiki.</label></td><td></td></tr>
+ − 684
<tr><td><b>URL scheme</b><br />Choose how the page URLs will look. Depending on your server configuration, you may need to select the first option. If you don't know, select the first option, and you can always change it later.</td><td colspan="2"><input type="radio" <?php if(!is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="ugly" id="ugly"> <label for="ugly">Standard URLs - compatible with any web server (www.example.com/index.php?title=Page_name)</label><br /><input type="radio" <?php if(is_apache()) echo 'checked="checked" '; ?>name="urlscheme" value="short" id="short"> <label for="short">Short URLs - requires Apache with a PHP module (www.example.com/index.php/Page_name)</label><br /><input type="radio" name="urlscheme" value="tiny" id="petite"> <label for="petite">Tiny URLs - requires Apache on Linux/Unix/BSD with PHP module and mod_rewrite enabled (www.example.com/Page_name)</label></td></tr>
+ − 685
</table>
+ − 686
<div class="pagenav">
+ − 687
<table border="0">
+ − 688
<tr>
+ − 689
<td><input type="submit" value="Continue" onclick="return verify();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Verify that your site information is correct. Again, all of the above settings can be changed from the administration panel.</p></td>
+ − 690
</tr>
+ − 691
</table>
+ − 692
</div>
+ − 693
</form>
+ − 694
<?php
+ − 695
break;
+ − 696
case "login":
+ − 697
if(!isset($_POST['_cont'])) {
+ − 698
echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.';
+ − 699
$template->footer();
+ − 700
exit;
+ − 701
}
+ − 702
unset($_POST['_cont']);
+ − 703
require('config.php');
+ − 704
$aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE);
+ − 705
if(!isset($cryptkey) || ( isset($cryptkey) && strlen($cryptkey) != AES_BITS / 4) )
+ − 706
{
+ − 707
$cryptkey = $aes->gen_readymade_key();
+ − 708
$handle = @fopen(ENANO_ROOT.'/config.php', 'w');
+ − 709
if(!$handle)
+ − 710
{
+ − 711
echo '<p>ERROR: Cannot open config.php for writing - exiting!</p>';
+ − 712
$template->footer();
+ − 713
exit;
+ − 714
}
+ − 715
fwrite($handle, '<?php $cryptkey = \''.$cryptkey.'\'; ?>');
+ − 716
fclose($handle);
+ − 717
}
+ − 718
?>
+ − 719
<script type="text/javascript">
+ − 720
function verify()
+ − 721
{
+ − 722
var frm = document.forms.login;
+ − 723
ret = true;
+ − 724
if(frm.admin_user.value.match(/^([A-z0-9_\-\.]+)$/g))
+ − 725
{
+ − 726
document.getElementById('s_user').src = 'images/good.gif';
+ − 727
}
+ − 728
else
+ − 729
{
+ − 730
document.getElementById('s_user').src = 'images/bad.gif';
+ − 731
ret = false;
+ − 732
}
+ − 733
if(frm.admin_pass.value.length >= 6 && frm.admin_pass.value == frm.admin_pass_confirm.value)
+ − 734
{
+ − 735
document.getElementById('s_password').src = 'images/good.gif';
+ − 736
}
+ − 737
else
+ − 738
{
+ − 739
document.getElementById('s_password').src = 'images/bad.gif';
+ − 740
ret = false;
+ − 741
}
+ − 742
if(frm.admin_email.value.match(/^(?:[\w\d]+\.?)+@(?:(?:[\w\d]\-?)+\.)+\w{2,4}$/))
+ − 743
{
+ − 744
document.getElementById('s_email').src = 'images/good.gif';
+ − 745
}
+ − 746
else
+ − 747
{
+ − 748
document.getElementById('s_email').src = 'images/bad.gif';
+ − 749
ret = false;
+ − 750
}
+ − 751
if(ret) frm._cont.disabled = false;
+ − 752
else frm._cont.disabled = true;
+ − 753
return ret;
+ − 754
}
+ − 755
window.onload = verify;
+ − 756
+ − 757
function cryptdata()
+ − 758
{
+ − 759
if(!verify()) return false;
+ − 760
}
+ − 761
</script>
+ − 762
<form name="login" action="install.php?mode=confirm" method="post" onsubmit="runEncryption();">
+ − 763
<?php
+ − 764
$k = array_keys($_POST);
+ − 765
for($i=0;$i<sizeof($_POST);$i++) {
+ − 766
echo '<input type="hidden" name="'.$k[$i].'" value="'.$_POST[$k[$i]].'" />'."\n";
+ − 767
}
+ − 768
?>
+ − 769
<p>Next, enter your desired username and password. The account you create here will be used to administer your site.</p>
+ − 770
<table border="0">
+ − 771
<tr><td><b>Administration username</b><br />The administration username you will use to log into your site.</td><td><input onkeyup="verify();" name="admin_user" type="text" size="30" /></td><td><img id="s_user" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 772
<tr><td>Administration password:</td><td><input onkeyup="verify();" name="admin_pass" type="password" size="30" /></td><td rowspan="2"><img id="s_password" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
+ − 773
<tr><td>Enter it again to confirm:</td><td><input onkeyup="verify();" name="admin_pass_confirm" type="password" size="30" /></td></tr>
+ − 774
<tr><td>Your e-mail address:</td><td><input onkeyup="verify();" name="admin_email" type="text" size="30" /></td><td><img id="s_email" alt="Good/bad icon" src="images/bad.gif" /></td></tr>
11
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 775
<tr>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 776
<td>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 777
Allow administrative embedding of PHP:<br />
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 778
<small><span style="color: #D84308">Do not under any circumstances enable this option without reading these
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 779
<a href="install.php?mode=pophelp&topic=admin_embed_php"
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 780
onclick="window.open(this.href, 'pophelpwin', 'width=550,height=400,status=no,toolbars=no,toolbar=no,address=no,scroll=yes'); return false;"
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 781
style="color: #D84308; text-decoration: underline;">important security implications</a>.
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 782
</span></small>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 783
</td>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 784
<td>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 785
<label><input type="radio" name="admin_embed_php" value="2" checked="checked" /> Disabled</label>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 786
<label><input type="radio" name="admin_embed_php" value="4" /> Enabled</label>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 787
</td>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 788
<td></td>
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 789
</tr>
0
+ − 790
<tr><td colspan="3">If your browser supports Javascript, the password you enter here will be encrypted with AES before it is sent to the server.</td></tr>
+ − 791
</table>
+ − 792
<div class="pagenav">
+ − 793
<table border="0">
+ − 794
<tr>
+ − 795
<td><input type="submit" value="Continue" onclick="return cryptdata();" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Remember the username and password you enter here! You will not be able to administer your site without the information you enter on this page.</p></td>
+ − 796
</tr>
+ − 797
</table>
+ − 798
</div>
+ − 799
<div id="cryptdebug"></div>
+ − 800
<input type="hidden" name="use_crypt" value="no" />
+ − 801
<input type="hidden" name="crypt_key" value="<?php echo $cryptkey; ?>" />
+ − 802
<input type="hidden" name="crypt_data" value="" />
+ − 803
</form>
+ − 804
<script type="text/javascript">
+ − 805
// <![CDATA[
+ − 806
disableJSONExts();
+ − 807
str = '';
+ − 808
for(i=0;i<keySizeInBits/4;i++) str+='0';
+ − 809
var key = hexToByteArray(str);
+ − 810
var pt = hexToByteArray(str);
+ − 811
var ct = rijndaelEncrypt(pt, key, "ECB");
+ − 812
var ect = byteArrayToHex(ct);
+ − 813
switch(keySizeInBits)
+ − 814
{
+ − 815
case 128:
+ − 816
v = '66e94bd4ef8a2c3b884cfa59ca342b2e';
+ − 817
break;
+ − 818
case 192:
+ − 819
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7';
+ − 820
break;
+ − 821
case 256:
+ − 822
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087';
+ − 823
break;
+ − 824
}
+ − 825
var testpassed = ( ect == v && md5_vm_test() );
+ − 826
var frm = document.forms.login;
+ − 827
if(testpassed)
+ − 828
{
+ − 829
frm.use_crypt.value = 'yes';
+ − 830
var cryptkey = frm.crypt_key.value;
+ − 831
frm.crypt_key.value = '';
+ − 832
if(cryptkey != byteArrayToHex(hexToByteArray(cryptkey)))
+ − 833
{
+ − 834
alert('Byte array conversion SUCKS');
+ − 835
testpassed = false;
+ − 836
}
+ − 837
cryptkey = hexToByteArray(cryptkey);
+ − 838
if(!cryptkey || ( ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ) && cryptkey.length != keySizeInBits / 8 )
+ − 839
{
+ − 840
frm._cont.disabled = true;
+ − 841
len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : '';
+ − 842
alert('The key is messed up\nType: '+typeof(cryptkey)+len);
+ − 843
}
+ − 844
}
+ − 845
frm.admin_user.focus();
+ − 846
function runEncryption()
+ − 847
{
+ − 848
if(testpassed)
+ − 849
{
+ − 850
pass = frm.admin_pass.value;
+ − 851
pass = stringToByteArray(pass);
+ − 852
cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB');
+ − 853
//decrypted = rijndaelDecrypt(cryptstring, cryptkey, 'ECB');
+ − 854
//decrypted = byteArrayToString(decrypted);
+ − 855
//return false;
+ − 856
if(!cryptstring)
+ − 857
{
+ − 858
return false;
+ − 859
}
+ − 860
cryptstring = byteArrayToHex(cryptstring);
+ − 861
document.getElementById('cryptdebug').innerHTML = '<pre>Data: '+cryptstring+'<br />Key: '+byteArrayToHex(cryptkey)+'</pre>';
+ − 862
frm.crypt_data.value = cryptstring;
+ − 863
frm.admin_pass.value = '';
+ − 864
frm.admin_pass_confirm.value = '';
+ − 865
}
+ − 866
return false;
+ − 867
}
+ − 868
// ]]>
+ − 869
</script>
+ − 870
<?php
+ − 871
break;
+ − 872
case "confirm":
+ − 873
if(!isset($_POST['_cont'])) {
+ − 874
echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.';
+ − 875
$template->footer();
+ − 876
exit;
+ − 877
}
+ − 878
unset($_POST['_cont']);
+ − 879
?>
+ − 880
<form name="confirm" action="install.php?mode=install" method="post">
+ − 881
<?php
+ − 882
$k = array_keys($_POST);
+ − 883
for($i=0;$i<sizeof($_POST);$i++) {
+ − 884
echo '<input type="hidden" name="'.$k[$i].'" value="'.$_POST[$k[$i]].'" />'."\n";
+ − 885
}
+ − 886
?>
+ − 887
<h3>Enano is ready to install.</h3>
+ − 888
<p>The wizard has finished collecting information and is ready to install the database schema. Please review the information below,
+ − 889
and then click the button below to install the database.</p>
+ − 890
<ul>
+ − 891
<li>Database hostname: <?php echo $_POST['db_host']; ?></li>
+ − 892
<li>Database name: <?php echo $_POST['db_name']; ?></li>
+ − 893
<li>Database user: <?php echo $_POST['db_user']; ?></li>
+ − 894
<li>Database password: <hidden></li>
+ − 895
<li>Site name: <?php echo $_POST['sitename']; ?></li>
+ − 896
<li>Site description: <?php echo $_POST['sitedesc']; ?></li>
+ − 897
<li>Administration username: <?php echo $_POST['admin_user']; ?></li>
+ − 898
<li>Cipher strength: <?php echo (string)AES_BITS; ?>-bit AES<br /><small>Cipher strength is defined in the file constants.php; if you desire to change the cipher strength, you may do so and then restart installation. Unless your site is mission-critical, changing the cipher strength is not necessary.</small></li>
+ − 899
</ul>
+ − 900
<div class="pagenav">
+ − 901
<table border="0">
+ − 902
<tr>
+ − 903
<td><input type="submit" value="Install Enano!" name="_cont" /></td><td><p><span style="font-weight: bold;">Before clicking continue:</span><br />• Pray.</p></td>
+ − 904
</tr>
+ − 905
</table>
+ − 906
</div>
+ − 907
</form>
+ − 908
<?php
+ − 909
break;
+ − 910
case "install":
+ − 911
if(!isset($_POST['db_host']) ||
+ − 912
!isset($_POST['db_name']) ||
+ − 913
!isset($_POST['db_user']) ||
+ − 914
!isset($_POST['db_pass']) ||
+ − 915
!isset($_POST['sitename']) ||
+ − 916
!isset($_POST['sitedesc']) ||
+ − 917
!isset($_POST['copyright']) ||
+ − 918
!isset($_POST['admin_user']) ||
+ − 919
!isset($_POST['admin_pass']) ||
11
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 920
!isset($_POST['admin_embed_php']) || ( isset($_POST['admin_embed_php']) && !in_array($_POST['admin_embed_php'], array('2', '4')) ) ||
0
+ − 921
!isset($_POST['urlscheme'])
+ − 922
)
+ − 923
{
+ − 924
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>.';
+ − 925
$template->footer();
+ − 926
exit;
+ − 927
}
+ − 928
switch($_POST['urlscheme'])
+ − 929
{
+ − 930
case "ugly":
+ − 931
default:
+ − 932
$cp = scriptPath.'/index.php?title=';
+ − 933
break;
+ − 934
case "short":
+ − 935
$cp = scriptPath.'/index.php/';
+ − 936
break;
+ − 937
case "tiny":
+ − 938
$cp = scriptPath.'/';
+ − 939
break;
+ − 940
}
+ − 941
function err($t) { global $template; echo $t; $template->footer(); exit; }
+ − 942
+ − 943
echo 'Connecting to MySQL...';
+ − 944
if($_POST['db_root_user'] != '')
+ − 945
{
+ − 946
$conn = mysql_connect($_POST['db_host'], $_POST['db_root_user'], $_POST['db_root_pass']);
+ − 947
if(!$conn) err('Error connecting to MySQL: '.mysql_error());
+ − 948
$q = mysql_query('USE '.$_POST['db_name']);
+ − 949
if(!$q)
+ − 950
{
+ − 951
$q = mysql_query('CREATE DATABASE '.$_POST['db_name']);
+ − 952
if(!$q) err('Error initializing database: '.mysql_error());
+ − 953
}
+ − 954
$q = mysql_query('GRANT ALL PRIVILEGES ON '.$_POST['db_name'].'.* TO \''.$_POST['db_user'].'\'@\'localhost\' IDENTIFIED BY \''.$_POST['db_pass'].'\' WITH GRANT OPTION;');
+ − 955
if(!$q) err('Could not create the user account');
+ − 956
$q = mysql_query('GRANT ALL PRIVILEGES ON '.$_POST['db_name'].'.* TO \''.$_POST['db_user'].'\'@\'%\' IDENTIFIED BY \''.$_POST['db_pass'].'\' WITH GRANT OPTION;');
+ − 957
if(!$q) err('Could not create the user account');
+ − 958
mysql_close($conn);
+ − 959
}
+ − 960
$conn = mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']);
+ − 961
if(!$conn) err('Error connecting to MySQL: '.mysql_error());
+ − 962
$q = mysql_query('USE '.$_POST['db_name']);
+ − 963
if(!$q) err('Error selecting database: '.mysql_error());
+ − 964
echo 'done!<br />';
+ − 965
+ − 966
// Are we supposed to drop any existing tables? If so, do it now
+ − 967
if(isset($_POST['drop_tables']))
+ − 968
{
+ − 969
echo 'Dropping existing Enano tables...';
+ − 970
// Our list of tables included in Enano
10
+ − 971
$tables = Array( 'mdg_categories', 'mdg_comments', 'mdg_config', 'mdg_logs', 'mdg_page_text', 'mdg_session_keys', 'mdg_pages', 'mdg_users', 'mdg_users_extra', 'mdg_themes', 'mdg_buddies', 'mdg_banlist', 'mdg_files', 'mdg_privmsgs', 'mdg_sidebar', 'mdg_hits', 'mdg_search_index', 'mdg_groups', 'mdg_group_members', 'mdg_acl', 'mdg_search_cache' );
0
+ − 972
$tables = implode(', ', $tables);
+ − 973
$tables = str_replace('mdg_', $_POST['table_prefix'], $tables);
+ − 974
$query_of_death = 'DROP TABLE '.$tables.';';
+ − 975
mysql_query($query_of_death); // We won't check for errors here because if this operation fails it probably means the tables didn't exist
+ − 976
echo 'done!<br />';
+ − 977
}
+ − 978
+ − 979
$cacheonoff = is_writable(ENANO_ROOT.'/cache/') ? '1' : '0';
+ − 980
+ − 981
echo 'Decrypting administration password...';
+ − 982
require('config.php');
+ − 983
$aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE);
+ − 984
$key = $aes->hexToByteArray($cryptkey);
+ − 985
$enc = $aes->hexToByteArray($_POST['crypt_data']);
+ − 986
$dec = $aes->rijndaelDecrypt($enc, $key, 'ECB');
+ − 987
$dec = $aes->byteArrayToString($dec);
+ − 988
echo 'done!<br />Generating '.AES_BITS.'-bit AES private key...';
+ − 989
$privkey = $aes->gen_readymade_key();
+ − 990
$pkba = hexdecode($privkey);
+ − 991
$encpass = $aes->encrypt($dec, $pkba, ENC_HEX);
+ − 992
+ − 993
echo 'done!<br />Preparing for schema execution...';
+ − 994
$schema = file_get_contents('schema.sql');
+ − 995
$schema = str_replace('{{SITE_NAME}}', mysql_real_escape_string($_POST['sitename'] ), $schema);
+ − 996
$schema = str_replace('{{SITE_DESC}}', mysql_real_escape_string($_POST['sitedesc'] ), $schema);
+ − 997
$schema = str_replace('{{COPYRIGHT}}', mysql_real_escape_string($_POST['copyright'] ), $schema);
+ − 998
$schema = str_replace('{{ADMIN_USER}}', mysql_real_escape_string($_POST['admin_user'] ), $schema);
+ − 999
$schema = str_replace('{{ADMIN_PASS}}', mysql_real_escape_string($encpass ), $schema);
+ − 1000
$schema = str_replace('{{ADMIN_EMAIL}}', mysql_real_escape_string($_POST['admin_email']), $schema);
+ − 1001
$schema = str_replace('{{ENABLE_CACHE}}', mysql_real_escape_string($cacheonoff ), $schema);
+ − 1002
$schema = str_replace('{{REAL_NAME}}', '', $schema);
+ − 1003
$schema = str_replace('{{TABLE_PREFIX}}', $_POST['table_prefix'], $schema);
+ − 1004
$schema = str_replace('{{VERSION}}', ENANO_VERSION, $schema);
11
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
diff
changeset
+ − 1005
$schema = str_replace('{{ADMIN_EMBED_PHP}}', $_POST['admin_embed_php'], $schema);
0
+ − 1006
// Not anymore! :-D
+ − 1007
// $schema = str_replace('{{BETA_VERSION}}', ENANO_BETA_VERSION, $schema);
+ − 1008
+ − 1009
if(isset($_POST['wiki_mode'])) $schema = str_replace('{{WIKI_MODE}}', '1', $schema);
+ − 1010
else $schema = str_replace('{{WIKI_MODE}}', '0', $schema);
+ − 1011
+ − 1012
// Build an array of queries
+ − 1013
$schema = explode(";\n", $schema);
+ − 1014
echo 'done!<br />Executing schema.sql...';
+ − 1015
+ − 1016
// OK, do the loop, baby!!!
+ − 1017
foreach($schema as $q)
+ − 1018
{
+ − 1019
$r = mysql_query($q, $conn);
+ − 1020
if(!$r) err('Error during mainstream installation: '.mysql_error());
+ − 1021
}
+ − 1022
+ − 1023
echo 'done!<br />Writing configuration files...';
+ − 1024
if($_POST['urlscheme']=='tiny')
+ − 1025
{
+ − 1026
$ht = fopen(dirname(__FILE__).'/.htaccess', 'a+');
+ − 1027
if(!$ht) err('Error opening file .htaccess for writing');
+ − 1028
fwrite($ht, '
+ − 1029
RewriteEngine on
+ − 1030
RewriteCond %{REQUEST_FILENAME} !-d
+ − 1031
RewriteCond %{REQUEST_FILENAME} !-f
+ − 1032
RewriteRule ^(.+) '.scriptPath.'/index.php/$1 [L,QSA]
+ − 1033
RewriteRule \.(php|html|gif|jpg|png|css|js)$ - [L]
+ − 1034
');
+ − 1035
fclose($ht);
+ − 1036
}
+ − 1037
+ − 1038
$config_file = '<?php
+ − 1039
/* Enano auto-generated configuration file - editing not recommended! */
+ − 1040
$dbhost = \''.addslashes($_POST['db_host']).'\';
+ − 1041
$dbname = \''.addslashes($_POST['db_name']).'\';
+ − 1042
$dbuser = \''.addslashes($_POST['db_user']).'\';
+ − 1043
$dbpasswd = \''.addslashes($_POST['db_pass']).'\';
+ − 1044
if(!defined(\'ENANO_CONSTANTS\')) {
+ − 1045
define(\'ENANO_CONSTANTS\', \'\');
+ − 1046
define(\'table_prefix\', \''.$_POST['table_prefix'].'\');
+ − 1047
define(\'scriptPath\', \''.scriptPath.'\');
+ − 1048
define(\'contentPath\', \''.$cp.'\');
+ − 1049
define(\'ENANO_INSTALLED\', \'true\');
+ − 1050
}
+ − 1051
$crypto_key = \''.$privkey.'\';
+ − 1052
?>';
+ − 1053
+ − 1054
$cf_handle = fopen(dirname(__FILE__).'/config.php', 'w');
+ − 1055
if(!$cf_handle) err('Couldn\'t open file config.php for writing');
+ − 1056
fwrite($cf_handle, $config_file);
+ − 1057
fclose($cf_handle);
+ − 1058
+ − 1059
echo 'done!<br />Initializing logs...';
+ − 1060
+ − 1061
$q = mysql_query('INSERT INTO ' . $_POST['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']) . '\');', $conn);
+ − 1062
if ( !$q )
+ − 1063
err('Error setting up logs: '.mysql_error());
+ − 1064
+ − 1065
echo 'done!<h3>Installation of Enano is complete.</h3><p>Review any warnings above, and then <a href="install.php?mode=finish">click here to finish the installation</a>.';
+ − 1066
+ − 1067
// echo '<script type="text/javascript">window.location="'.scriptPath.'/install.php?mode=finish";</script>';
+ − 1068
+ − 1069
break;
+ − 1070
case "finish":
+ − 1071
echo '<h3>Congratulations!</h3>
+ − 1072
<p>You have finished installing Enano on this server.</p>
+ − 1073
<h3>Now what?</h3>
+ − 1074
<p>Click the link below to see the main page for your website. Where to go from here:</p>
+ − 1075
<ul>
+ − 1076
<li>The first thing you should do is log into your site using the Log in link on the sidebar.</li>
+ − 1077
<li>Go into the Administration panel, expand General, and click General Configuration. There you will be able to configure some basic information about your site.</li>
+ − 1078
<li>Visit the <a href="http://enanocms.org/Category:Plugins" onclick="window.open(this.href); return false;">Enano Plugin Gallery</a> to download and use plugins on your site.</li>
+ − 1079
<li>Periodically create a backup of your database and filesystem, in case something goes wrong. This should be done at least once a week – more for wiki-based sites.</li>
+ − 1080
<li>Hire some moderators, to help you keep rowdy users tame.</li>
+ − 1081
<li>Tell the <a href="http://enanocms.org/Contact_us">Enano team</a> what you think.</li>
+ − 1082
<li><b>Spread the word about Enano by adding a link to the Enano homepage on your sidebar!</b> You can enable this option in the General Configuration section of the administration panel.</li>
+ − 1083
</ul>
+ − 1084
<p><a href="index.php">Go to your website...</a></p>';
+ − 1085
break;
+ − 1086
}
+ − 1087
$template->footer();
+ − 1088
+ − 1089
?>