|
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 |
|
15 //@include('config.php'); |
|
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; |
|
171 default: |
|
172 break; |
|
173 } |
|
174 |
|
175 $template = new template_nodb(); |
|
176 $template->load_theme('oxygen', 'bleu', false); |
|
177 |
|
178 $modestrings = Array( |
|
179 'welcome' => 'Welcome', |
|
180 'license' => 'License Agreement', |
|
181 'sysreqs' => 'Server requirements', |
|
182 'database'=> 'Database information', |
|
183 'website' => 'Website configuration', |
|
184 'login' => 'Administration login', |
|
185 'confirm' => 'Confirm installation', |
|
186 'install' => 'Database installation', |
|
187 'finish' => 'Installation complete' |
|
188 ); |
|
189 |
|
190 $sideinfo = ''; |
|
191 $vars = $template->extract_vars('elements.tpl'); |
|
192 $p = $template->makeParserText($vars['sidebar_button']); |
|
193 foreach ( $modestrings as $id => $str ) |
|
194 { |
|
195 if ( $_GET['mode'] == $id ) |
|
196 { |
|
197 $flags = 'style="font-weight: bold; text-decoration: underline;"'; |
|
198 $this_page = $str; |
|
199 } |
|
200 else |
|
201 { |
|
202 $flags = ''; |
|
203 } |
|
204 $p->assign_vars(Array( |
|
205 'HREF' => '#', |
|
206 'FLAGS' => $flags . ' onclick="return false;"', |
|
207 'TEXT' => $str |
|
208 )); |
|
209 $sideinfo .= $p->run(); |
|
210 } |
|
211 |
|
212 $template->init_vars(); |
|
213 |
|
214 if(isset($_GET['mode']) && $_GET['mode'] == 'css') |
|
215 { |
|
216 header('Content-type: text/css'); |
|
217 echo $template->get_css(); |
|
218 exit; |
|
219 } |
|
220 |
|
221 $template->header(); |
|
222 if(!isset($_GET['mode'])) $_GET['mode'] = 'license'; |
|
223 switch($_GET['mode']) |
|
224 { |
|
225 default: |
|
226 case 'welcome': |
|
227 ?> |
|
228 <div style="text-align: center; margin-top: 10px;"> |
|
229 <img alt="[ Enano CMS Project logo ]" src="images/enano-artwork/installer-greeting-blue.png" style="display: block; margin: 0 auto; padding-left: 100px;" /> |
|
230 <h2>Welcome to Enano</h2> |
|
231 <h3>version 1.0 – stable<br /> |
|
232 <span style="font-weight: normal;">also affectionately known as "banshee" <tt>:)</tt></span></h3> |
|
233 <?php |
|
234 if ( file_exists('./_nightly.php') ) |
|
235 { |
|
236 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>'; |
|
237 } |
|
238 ?> |
|
239 <form action="install.php?mode=license" method="post"> |
|
240 <input type="submit" value="Start installation" /> |
|
241 </form> |
|
242 </div> |
|
243 <?php |
|
244 break; |
|
245 case "license": |
|
246 ?> |
|
247 <h3>Welcome to the Enano installer.</h3> |
|
248 <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> |
|
249 <p>To get started, please read and accept the following license agreement. You've probably seen it before.</p> |
|
250 <div style="height: 500px; clip: rect(0px,auto,500px,auto); overflow: auto; padding: 10px; border: 1px dashed #456798; margin: 1em;"> |
|
251 <h2>GNU General Public License</h2> |
|
252 <h3>Declaration of license usage</h3> |
|
253 <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> |
|
254 <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> |
|
255 <h3>Human-readable version</h3> |
|
256 <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> |
|
257 <ul> |
|
258 <li>You may to run Enano for any purpose.</li> |
|
259 <li>You may study how Enano works and adapt it to your needs.</li> |
|
260 <li>You may redistribute copies so you can help your neighbor.</li> |
|
261 <li>You may improve Enano and release your improvements to the public, so that the whole community benefits.</li> |
|
262 </ul> |
|
263 <p>You may exercise the freedoms specified here provided that you comply with the express conditions of this license. The principal conditions are:</p> |
|
264 <ul> |
|
265 <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> |
|
266 <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> |
|
267 <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> |
|
268 </ul> |
|
269 <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> |
|
270 <?php |
|
271 if ( defined('ENANO_BETA_VERSION') ) |
|
272 { |
|
273 ?> |
|
274 <h3>Notice for prerelease versions</h3> |
|
275 <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> |
|
276 <?php |
|
277 } |
|
278 ?> |
|
279 <h3>Lawyer-readable version</h3> |
|
280 <?php echo wikiFormat(file_get_contents(ENANO_ROOT . '/GPL')); ?> |
|
281 </div> |
|
282 <div class="pagenav"> |
|
283 <form action="install.php?mode=sysreqs" method="post"> |
|
284 <table border="0"> |
|
285 <tr> |
|
286 <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> |
|
287 </tr> |
|
288 </table> |
|
289 </form> |
|
290 </div> |
|
291 <?php |
|
292 break; |
|
293 case "sysreqs": |
|
294 error_reporting(E_ALL); |
|
295 ?> |
|
296 <h3>Checking your server</h3> |
|
297 <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> |
|
298 <table border="0" cellspacing="0" cellpadding="0"> |
|
299 <?php |
|
300 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.'); |
|
301 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.'); |
|
302 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".'); |
|
303 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); |
|
304 //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); |
|
305 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.'); |
|
306 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); |
|
307 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); |
|
308 echo '</table>'; |
|
309 if(!$failed) |
|
310 { |
|
311 ?> |
|
312 |
|
313 <div class="pagenav"> |
|
314 <?php |
|
315 if($warned) { |
|
316 echo '<table border="0" cellspacing="0" cellpadding="0">'; |
|
317 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); |
|
318 echo '</table>'; |
|
319 } else { |
|
320 echo '<table border="0" cellspacing="0" cellpadding="0">'; |
|
321 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!'); |
|
322 echo '</table>'; |
|
323 } |
|
324 ?> |
|
325 <form action="install.php?mode=database" method="post"> |
|
326 <table border="0"> |
|
327 <tr> |
|
328 <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> |
|
329 </tr> |
|
330 </table> |
|
331 </form> |
|
332 </div> |
|
333 <?php |
|
334 } else { |
|
335 if($failed) { |
|
336 echo '<div class="pagenav"><table border="0" cellspacing="0" cellpadding="0">'; |
|
337 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.'); |
|
338 echo '</table></div>'; |
|
339 } |
|
340 } |
|
341 ?> |
|
342 <?php |
|
343 break; |
|
344 case "database": |
|
345 ?> |
|
346 <script type="text/javascript"> |
|
347 function ajaxGet(uri, f) { |
|
348 if (window.XMLHttpRequest) { |
|
349 ajax = new XMLHttpRequest(); |
|
350 } else { |
|
351 if (window.ActiveXObject) { |
|
352 ajax = new ActiveXObject("Microsoft.XMLHTTP"); |
|
353 } else { |
|
354 alert('Enano client-side runtime error: No AJAX support, unable to continue'); |
|
355 return; |
|
356 } |
|
357 } |
|
358 ajax.onreadystatechange = f; |
|
359 ajax.open('GET', uri, true); |
|
360 ajax.send(null); |
|
361 } |
|
362 |
|
363 function ajaxPost(uri, parms, f) { |
|
364 if (window.XMLHttpRequest) { |
|
365 ajax = new XMLHttpRequest(); |
|
366 } else { |
|
367 if (window.ActiveXObject) { |
|
368 ajax = new ActiveXObject("Microsoft.XMLHTTP"); |
|
369 } else { |
|
370 alert('Enano client-side runtime error: No AJAX support, unable to continue'); |
|
371 return; |
|
372 } |
|
373 } |
|
374 ajax.onreadystatechange = f; |
|
375 ajax.open('POST', uri, true); |
|
376 ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|
377 ajax.setRequestHeader("Content-length", parms.length); |
|
378 ajax.setRequestHeader("Connection", "close"); |
|
379 ajax.send(parms); |
|
380 } |
|
381 function ajaxTestConnection() |
|
382 { |
|
383 v = verify(); |
|
384 if(!v) |
|
385 { |
|
386 alert('One or more of the form fields is incorrect. Please correct any information in the form that has an "X" next to it.'); |
|
387 return false; |
|
388 } |
|
389 var frm = document.forms.dbinfo; |
|
390 db_host = escape(frm.db_host.value.replace('+', '%2B')); |
|
391 db_name = escape(frm.db_name.value.replace('+', '%2B')); |
|
392 db_user = escape(frm.db_user.value.replace('+', '%2B')); |
|
393 db_pass = escape(frm.db_pass.value.replace('+', '%2B')); |
|
394 db_root_user = escape(frm.db_root_user.value.replace('+', '%2B')); |
|
395 db_root_pass = escape(frm.db_root_pass.value.replace('+', '%2B')); |
|
396 |
|
397 parms = 'host='+db_host+'&name='+db_name+'&user='+db_user+'&pass='+db_pass+'&root_user='+db_root_user+'&root_pass='+db_root_pass; |
|
398 ajaxPost('<?php echo scriptPath; ?>/install.php?mode=mysql_test', parms, function() { |
|
399 if(ajax.readyState==4) |
|
400 { |
|
401 s = ajax.responseText.substr(0, 4); |
|
402 t = ajax.responseText.substr(4, ajax.responseText.length); |
|
403 if(s.substr(0, 4)=='good') |
|
404 { |
|
405 document.getElementById('s_db_host').src='images/good.gif'; |
|
406 document.getElementById('s_db_name').src='images/good.gif'; |
|
407 document.getElementById('s_db_auth').src='images/good.gif'; |
|
408 document.getElementById('s_db_root').src='images/good.gif'; |
|
409 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.'; |
|
410 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.'; |
|
411 document.getElementById('s_mysql_version').src='images/good.gif'; |
|
412 document.getElementById('e_mysql_version').innerHTML = 'Your version of MySQL meets Enano requirements.'; |
|
413 } |
|
414 else |
|
415 { |
|
416 switch(s) |
|
417 { |
|
418 case 'host': |
|
419 document.getElementById('s_db_host').src='images/bad.gif'; |
|
420 document.getElementById('s_db_name').src='images/unknown.gif'; |
|
421 document.getElementById('s_db_auth').src='images/unknown.gif'; |
|
422 document.getElementById('s_db_root').src='images/unknown.gif'; |
|
423 document.getElementById('e_db_host').innerHTML = '<b>Error:<\/b> The database server "'+document.forms.dbinfo.db_host.value+'" couldn\'t be contacted.<br \/>'+t; |
|
424 document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.'; |
|
425 break; |
|
426 case 'auth': |
|
427 document.getElementById('s_db_host').src='images/good.gif'; |
|
428 document.getElementById('s_db_name').src='images/unknown.gif'; |
|
429 document.getElementById('s_db_auth').src='images/bad.gif'; |
|
430 document.getElementById('s_db_root').src='images/unknown.gif'; |
|
431 document.getElementById('e_db_auth').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t; |
|
432 document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.'; |
|
433 break; |
|
434 case 'perm': |
|
435 document.getElementById('s_db_host').src='images/good.gif'; |
|
436 document.getElementById('s_db_name').src='images/bad.gif'; |
|
437 document.getElementById('s_db_auth').src='images/good.gif'; |
|
438 document.getElementById('s_db_root').src='images/unknown.gif'; |
|
439 document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> Access to the specified database using those login credentials was denied.<br \/>'+t; |
|
440 document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.'; |
|
441 break; |
|
442 case 'name': |
|
443 document.getElementById('s_db_host').src='images/good.gif'; |
|
444 document.getElementById('s_db_name').src='images/bad.gif'; |
|
445 document.getElementById('s_db_auth').src='images/good.gif'; |
|
446 document.getElementById('s_db_root').src='images/unknown.gif'; |
|
447 document.getElementById('e_db_name').innerHTML = '<b>Error:<\/b> The specified database does not exist<br \/>'+t; |
|
448 document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.'; |
|
449 break; |
|
450 case 'root': |
|
451 document.getElementById('s_db_host').src='images/good.gif'; |
|
452 document.getElementById('s_db_name').src='images/unknown.gif'; |
|
453 document.getElementById('s_db_auth').src='images/unknown.gif'; |
|
454 document.getElementById('s_db_root').src='images/bad.gif'; |
|
455 document.getElementById('e_db_root').innerHTML = '<b>Error:<\/b> Access to MySQL under the specified credentials was denied.<br \/>'+t; |
|
456 document.getElementById('e_mysql_version').innerHTML = 'The MySQL version that your server is running could not be determined.'; |
|
457 break; |
|
458 case 'vers': |
|
459 document.getElementById('s_db_host').src='images/good.gif'; |
|
460 document.getElementById('s_db_name').src='images/good.gif'; |
|
461 document.getElementById('s_db_auth').src='images/good.gif'; |
|
462 document.getElementById('s_db_root').src='images/good.gif'; |
|
463 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.'; |
|
464 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.'; |
|
465 |
|
466 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().'; |
|
467 document.getElementById('s_mysql_version').src='images/bad.gif'; |
|
468 default: |
|
469 alert(t); |
|
470 break; |
|
471 } |
|
472 } |
|
473 } |
|
474 }); |
|
475 } |
|
476 function verify() |
|
477 { |
|
478 document.getElementById('e_db_host').innerHTML = ''; |
|
479 document.getElementById('e_db_auth').innerHTML = ''; |
|
480 document.getElementById('e_db_name').innerHTML = ''; |
|
481 document.getElementById('e_db_root').innerHTML = ''; |
|
482 var frm = document.forms.dbinfo; |
|
483 ret = true; |
|
484 if(frm.db_host.value != '') |
|
485 { |
|
486 document.getElementById('s_db_host').src='images/unknown.gif'; |
|
487 } |
|
488 else |
|
489 { |
|
490 document.getElementById('s_db_host').src='images/bad.gif'; |
|
491 ret = false; |
|
492 } |
|
493 if(frm.db_name.value.match(/^([a-z0-9_]+)$/g)) |
|
494 { |
|
495 document.getElementById('s_db_name').src='images/unknown.gif'; |
|
496 } |
|
497 else |
|
498 { |
|
499 document.getElementById('s_db_name').src='images/bad.gif'; |
|
500 ret = false; |
|
501 } |
|
502 if(frm.db_user.value != '') |
|
503 { |
|
504 document.getElementById('s_db_auth').src='images/unknown.gif'; |
|
505 } |
|
506 else |
|
507 { |
|
508 document.getElementById('s_db_auth').src='images/bad.gif'; |
|
509 ret = false; |
|
510 } |
|
511 if(frm.table_prefix.value.match(/^([a-z0-9_]*)$/g)) |
|
512 { |
|
513 document.getElementById('s_table_prefix').src='images/good.gif'; |
|
514 } |
|
515 else |
|
516 { |
|
517 document.getElementById('s_table_prefix').src='images/bad.gif'; |
|
518 ret = false; |
|
519 } |
|
520 if(frm.db_root_user.value == '') |
|
521 { |
|
522 document.getElementById('s_db_root').src='images/good.gif'; |
|
523 } |
|
524 else if(frm.db_root_user.value != '' && frm.db_root_pass.value == '') |
|
525 { |
|
526 document.getElementById('s_db_root').src='images/bad.gif'; |
|
527 ret = false; |
|
528 } |
|
529 else |
|
530 { |
|
531 document.getElementById('s_db_root').src='images/unknown.gif'; |
|
532 } |
|
533 if(ret) frm._cont.disabled = false; |
|
534 else frm._cont.disabled = true; |
|
535 return ret; |
|
536 } |
|
537 window.onload = verify; |
|
538 </script> |
|
539 <p>Now we need some information that will allow Enano to contact your database server. Enano uses MySQL as a data storage backend, |
|
540 and we need to have access to a MySQL server in order to continue.</p> |
|
541 <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 |
|
542 <a href="http://www.mysql.com/">MySQL.com</a>. <b>Please note that, like Enano, MySQL is licensed under the GNU GPL.</b> |
|
543 If you need to modify MySQL and then distribute your modifications, you must either distribute them under the terms of the GPL |
|
544 or purchase a proprietary license.</p> |
|
545 <form name="dbinfo" action="install.php?mode=website" method="post"> |
|
546 <table border="0"> |
|
547 <tr><td colspan="3" style="text-align: center"><h3>Database information</h3></td></tr> |
|
548 <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> |
|
549 <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> |
|
550 <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> |
|
551 <tr><td><input name="db_pass" size="30" type="password" /></td></tr> |
|
552 <tr><td colspan="3" style="text-align: center"><h3>Optional information</h3></td></tr> |
|
553 <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> |
|
554 <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> |
|
555 <tr><td><input onkeyup="verify();" name="db_root_pass" size="30" type="password" /></td></tr> |
|
556 <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> |
|
557 <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> |
|
558 <tr><td colspan="3" style="text-align: center"><input type="button" value="Test connection" onclick="ajaxTestConnection();" /></td></tr> |
|
559 </table> |
|
560 <div class="pagenav"> |
|
561 <table border="0"> |
|
562 <tr> |
|
563 <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> |
|
564 </tr> |
|
565 </table> |
|
566 </div> |
|
567 </form> |
|
568 <?php |
|
569 break; |
|
570 case "website": |
|
571 if(!isset($_POST['_cont'])) { |
|
572 echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.'; |
|
573 $template->footer(); |
|
574 exit; |
|
575 } |
|
576 unset($_POST['_cont']); |
|
577 ?> |
|
578 <script type="text/javascript"> |
|
579 function verify() |
|
580 { |
|
581 var frm = document.forms.siteinfo; |
|
582 ret = true; |
|
583 if(frm.sitename.value.match(/^([A-z0-9 ]+)$/g) && frm.sitename.value != 'Enano') |
|
584 { |
|
585 document.getElementById('s_name').src='images/good.gif'; |
|
586 } |
|
587 else |
|
588 { |
|
589 document.getElementById('s_name').src='images/bad.gif'; |
|
590 ret = false; |
|
591 } |
|
592 if(frm.sitedesc.value.match(/^(.+)$/g)) |
|
593 { |
|
594 document.getElementById('s_desc').src='images/good.gif'; |
|
595 } |
|
596 else |
|
597 { |
|
598 document.getElementById('s_desc').src='images/bad.gif'; |
|
599 ret = false; |
|
600 } |
|
601 if(frm.copyright.value.match(/^(.+)$/g)) |
|
602 { |
|
603 document.getElementById('s_copyright').src='images/good.gif'; |
|
604 } |
|
605 else |
|
606 { |
|
607 document.getElementById('s_copyright').src='images/bad.gif'; |
|
608 ret = false; |
|
609 } |
|
610 if(ret) frm._cont.disabled = false; |
|
611 else frm._cont.disabled = true; |
|
612 return ret; |
|
613 } |
|
614 window.onload = verify; |
|
615 </script> |
|
616 <form name="siteinfo" action="install.php?mode=login" method="post"> |
|
617 <?php |
|
618 $k = array_keys($_POST); |
|
619 for($i=0;$i<sizeof($_POST);$i++) { |
|
620 echo '<input type="hidden" name="'.$k[$i].'" value="'.$_POST[$k[$i]].'" />'."\n"; |
|
621 } |
|
622 ?> |
|
623 <p>The next step is to enter some information about your website. You can always change this information later, using the administration panel.</p> |
|
624 <table border="0"> |
|
625 <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> |
|
626 <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> |
|
627 <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> |
|
628 <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> |
|
629 <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> |
|
630 </table> |
|
631 <div class="pagenav"> |
|
632 <table border="0"> |
|
633 <tr> |
|
634 <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> |
|
635 </tr> |
|
636 </table> |
|
637 </div> |
|
638 </form> |
|
639 <?php |
|
640 break; |
|
641 case "login": |
|
642 if(!isset($_POST['_cont'])) { |
|
643 echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.'; |
|
644 $template->footer(); |
|
645 exit; |
|
646 } |
|
647 unset($_POST['_cont']); |
|
648 require('config.php'); |
|
649 $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE); |
|
650 if(!isset($cryptkey) || ( isset($cryptkey) && strlen($cryptkey) != AES_BITS / 4) ) |
|
651 { |
|
652 $cryptkey = $aes->gen_readymade_key(); |
|
653 $handle = @fopen(ENANO_ROOT.'/config.php', 'w'); |
|
654 if(!$handle) |
|
655 { |
|
656 echo '<p>ERROR: Cannot open config.php for writing - exiting!</p>'; |
|
657 $template->footer(); |
|
658 exit; |
|
659 } |
|
660 fwrite($handle, '<?php $cryptkey = \''.$cryptkey.'\'; ?>'); |
|
661 fclose($handle); |
|
662 } |
|
663 ?> |
|
664 <script type="text/javascript"> |
|
665 function verify() |
|
666 { |
|
667 var frm = document.forms.login; |
|
668 ret = true; |
|
669 if(frm.admin_user.value.match(/^([A-z0-9_\-\.]+)$/g)) |
|
670 { |
|
671 document.getElementById('s_user').src = 'images/good.gif'; |
|
672 } |
|
673 else |
|
674 { |
|
675 document.getElementById('s_user').src = 'images/bad.gif'; |
|
676 ret = false; |
|
677 } |
|
678 if(frm.admin_pass.value.length >= 6 && frm.admin_pass.value == frm.admin_pass_confirm.value) |
|
679 { |
|
680 document.getElementById('s_password').src = 'images/good.gif'; |
|
681 } |
|
682 else |
|
683 { |
|
684 document.getElementById('s_password').src = 'images/bad.gif'; |
|
685 ret = false; |
|
686 } |
|
687 if(frm.admin_email.value.match(/^(?:[\w\d]+\.?)+@(?:(?:[\w\d]\-?)+\.)+\w{2,4}$/)) |
|
688 { |
|
689 document.getElementById('s_email').src = 'images/good.gif'; |
|
690 } |
|
691 else |
|
692 { |
|
693 document.getElementById('s_email').src = 'images/bad.gif'; |
|
694 ret = false; |
|
695 } |
|
696 if(ret) frm._cont.disabled = false; |
|
697 else frm._cont.disabled = true; |
|
698 return ret; |
|
699 } |
|
700 window.onload = verify; |
|
701 |
|
702 function cryptdata() |
|
703 { |
|
704 if(!verify()) return false; |
|
705 } |
|
706 </script> |
|
707 <form name="login" action="install.php?mode=confirm" method="post" onsubmit="runEncryption();"> |
|
708 <?php |
|
709 $k = array_keys($_POST); |
|
710 for($i=0;$i<sizeof($_POST);$i++) { |
|
711 echo '<input type="hidden" name="'.$k[$i].'" value="'.$_POST[$k[$i]].'" />'."\n"; |
|
712 } |
|
713 ?> |
|
714 <p>Next, enter your desired username and password. The account you create here will be used to administer your site.</p> |
|
715 <table border="0"> |
|
716 <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> |
|
717 <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> |
|
718 <tr><td>Enter it again to confirm:</td><td><input onkeyup="verify();" name="admin_pass_confirm" type="password" size="30" /></td></tr> |
|
719 <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> |
|
720 <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> |
|
721 </table> |
|
722 <div class="pagenav"> |
|
723 <table border="0"> |
|
724 <tr> |
|
725 <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> |
|
726 </tr> |
|
727 </table> |
|
728 </div> |
|
729 <div id="cryptdebug"></div> |
|
730 <input type="hidden" name="use_crypt" value="no" /> |
|
731 <input type="hidden" name="crypt_key" value="<?php echo $cryptkey; ?>" /> |
|
732 <input type="hidden" name="crypt_data" value="" /> |
|
733 </form> |
|
734 <script type="text/javascript"> |
|
735 // <![CDATA[ |
|
736 disableJSONExts(); |
|
737 str = ''; |
|
738 for(i=0;i<keySizeInBits/4;i++) str+='0'; |
|
739 var key = hexToByteArray(str); |
|
740 var pt = hexToByteArray(str); |
|
741 var ct = rijndaelEncrypt(pt, key, "ECB"); |
|
742 var ect = byteArrayToHex(ct); |
|
743 switch(keySizeInBits) |
|
744 { |
|
745 case 128: |
|
746 v = '66e94bd4ef8a2c3b884cfa59ca342b2e'; |
|
747 break; |
|
748 case 192: |
|
749 v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7'; |
|
750 break; |
|
751 case 256: |
|
752 v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087'; |
|
753 break; |
|
754 } |
|
755 var testpassed = ( ect == v && md5_vm_test() ); |
|
756 var frm = document.forms.login; |
|
757 if(testpassed) |
|
758 { |
|
759 frm.use_crypt.value = 'yes'; |
|
760 var cryptkey = frm.crypt_key.value; |
|
761 frm.crypt_key.value = ''; |
|
762 if(cryptkey != byteArrayToHex(hexToByteArray(cryptkey))) |
|
763 { |
|
764 alert('Byte array conversion SUCKS'); |
|
765 testpassed = false; |
|
766 } |
|
767 cryptkey = hexToByteArray(cryptkey); |
|
768 if(!cryptkey || ( ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ) && cryptkey.length != keySizeInBits / 8 ) |
|
769 { |
|
770 frm._cont.disabled = true; |
|
771 len = ( typeof cryptkey == 'string' || typeof cryptkey == 'object' ) ? '\nLen: '+cryptkey.length : ''; |
|
772 alert('The key is messed up\nType: '+typeof(cryptkey)+len); |
|
773 } |
|
774 } |
|
775 frm.admin_user.focus(); |
|
776 function runEncryption() |
|
777 { |
|
778 if(testpassed) |
|
779 { |
|
780 pass = frm.admin_pass.value; |
|
781 pass = stringToByteArray(pass); |
|
782 cryptstring = rijndaelEncrypt(pass, cryptkey, 'ECB'); |
|
783 //decrypted = rijndaelDecrypt(cryptstring, cryptkey, 'ECB'); |
|
784 //decrypted = byteArrayToString(decrypted); |
|
785 //return false; |
|
786 if(!cryptstring) |
|
787 { |
|
788 return false; |
|
789 } |
|
790 cryptstring = byteArrayToHex(cryptstring); |
|
791 document.getElementById('cryptdebug').innerHTML = '<pre>Data: '+cryptstring+'<br />Key: '+byteArrayToHex(cryptkey)+'</pre>'; |
|
792 frm.crypt_data.value = cryptstring; |
|
793 frm.admin_pass.value = ''; |
|
794 frm.admin_pass_confirm.value = ''; |
|
795 } |
|
796 return false; |
|
797 } |
|
798 // ]]> |
|
799 </script> |
|
800 <?php |
|
801 break; |
|
802 case "confirm": |
|
803 if(!isset($_POST['_cont'])) { |
|
804 echo 'No POST data signature found. Please <a href="install.php?mode=license">restart the installation</a>.'; |
|
805 $template->footer(); |
|
806 exit; |
|
807 } |
|
808 unset($_POST['_cont']); |
|
809 ?> |
|
810 <form name="confirm" action="install.php?mode=install" method="post"> |
|
811 <?php |
|
812 $k = array_keys($_POST); |
|
813 for($i=0;$i<sizeof($_POST);$i++) { |
|
814 echo '<input type="hidden" name="'.$k[$i].'" value="'.$_POST[$k[$i]].'" />'."\n"; |
|
815 } |
|
816 ?> |
|
817 <h3>Enano is ready to install.</h3> |
|
818 <p>The wizard has finished collecting information and is ready to install the database schema. Please review the information below, |
|
819 and then click the button below to install the database.</p> |
|
820 <ul> |
|
821 <li>Database hostname: <?php echo $_POST['db_host']; ?></li> |
|
822 <li>Database name: <?php echo $_POST['db_name']; ?></li> |
|
823 <li>Database user: <?php echo $_POST['db_user']; ?></li> |
|
824 <li>Database password: <hidden></li> |
|
825 <li>Site name: <?php echo $_POST['sitename']; ?></li> |
|
826 <li>Site description: <?php echo $_POST['sitedesc']; ?></li> |
|
827 <li>Administration username: <?php echo $_POST['admin_user']; ?></li> |
|
828 <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> |
|
829 </ul> |
|
830 <div class="pagenav"> |
|
831 <table border="0"> |
|
832 <tr> |
|
833 <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> |
|
834 </tr> |
|
835 </table> |
|
836 </div> |
|
837 </form> |
|
838 <?php |
|
839 break; |
|
840 case "install": |
|
841 if(!isset($_POST['db_host']) || |
|
842 !isset($_POST['db_name']) || |
|
843 !isset($_POST['db_user']) || |
|
844 !isset($_POST['db_pass']) || |
|
845 !isset($_POST['sitename']) || |
|
846 !isset($_POST['sitedesc']) || |
|
847 !isset($_POST['copyright']) || |
|
848 !isset($_POST['admin_user']) || |
|
849 !isset($_POST['admin_pass']) || |
|
850 !isset($_POST['urlscheme']) |
|
851 ) |
|
852 { |
|
853 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>.'; |
|
854 $template->footer(); |
|
855 exit; |
|
856 } |
|
857 switch($_POST['urlscheme']) |
|
858 { |
|
859 case "ugly": |
|
860 default: |
|
861 $cp = scriptPath.'/index.php?title='; |
|
862 break; |
|
863 case "short": |
|
864 $cp = scriptPath.'/index.php/'; |
|
865 break; |
|
866 case "tiny": |
|
867 $cp = scriptPath.'/'; |
|
868 break; |
|
869 } |
|
870 function err($t) { global $template; echo $t; $template->footer(); exit; } |
|
871 |
|
872 echo 'Connecting to MySQL...'; |
|
873 if($_POST['db_root_user'] != '') |
|
874 { |
|
875 $conn = mysql_connect($_POST['db_host'], $_POST['db_root_user'], $_POST['db_root_pass']); |
|
876 if(!$conn) err('Error connecting to MySQL: '.mysql_error()); |
|
877 $q = mysql_query('USE '.$_POST['db_name']); |
|
878 if(!$q) |
|
879 { |
|
880 $q = mysql_query('CREATE DATABASE '.$_POST['db_name']); |
|
881 if(!$q) err('Error initializing database: '.mysql_error()); |
|
882 } |
|
883 $q = mysql_query('GRANT ALL PRIVILEGES ON '.$_POST['db_name'].'.* TO \''.$_POST['db_user'].'\'@\'localhost\' IDENTIFIED BY \''.$_POST['db_pass'].'\' WITH GRANT OPTION;'); |
|
884 if(!$q) err('Could not create the user account'); |
|
885 $q = mysql_query('GRANT ALL PRIVILEGES ON '.$_POST['db_name'].'.* TO \''.$_POST['db_user'].'\'@\'%\' IDENTIFIED BY \''.$_POST['db_pass'].'\' WITH GRANT OPTION;'); |
|
886 if(!$q) err('Could not create the user account'); |
|
887 mysql_close($conn); |
|
888 } |
|
889 $conn = mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']); |
|
890 if(!$conn) err('Error connecting to MySQL: '.mysql_error()); |
|
891 $q = mysql_query('USE '.$_POST['db_name']); |
|
892 if(!$q) err('Error selecting database: '.mysql_error()); |
|
893 echo 'done!<br />'; |
|
894 |
|
895 // Are we supposed to drop any existing tables? If so, do it now |
|
896 if(isset($_POST['drop_tables'])) |
|
897 { |
|
898 echo 'Dropping existing Enano tables...'; |
|
899 // Our list of tables included in Enano |
|
900 $tables = Array( 'mdg_categories', 'mdg_comments', 'mdg_config', 'mdg_logs', 'mdg_page_text', 'mdg_session_keys', 'mdg_pages', 'mdg_users', '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' ); |
|
901 $tables = implode(', ', $tables); |
|
902 $tables = str_replace('mdg_', $_POST['table_prefix'], $tables); |
|
903 $query_of_death = 'DROP TABLE '.$tables.';'; |
|
904 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 |
|
905 echo 'done!<br />'; |
|
906 } |
|
907 |
|
908 $cacheonoff = is_writable(ENANO_ROOT.'/cache/') ? '1' : '0'; |
|
909 |
|
910 echo 'Decrypting administration password...'; |
|
911 require('config.php'); |
|
912 $aes = new AESCrypt(AES_BITS, AES_BLOCKSIZE); |
|
913 $key = $aes->hexToByteArray($cryptkey); |
|
914 $enc = $aes->hexToByteArray($_POST['crypt_data']); |
|
915 $dec = $aes->rijndaelDecrypt($enc, $key, 'ECB'); |
|
916 $dec = $aes->byteArrayToString($dec); |
|
917 echo 'done!<br />Generating '.AES_BITS.'-bit AES private key...'; |
|
918 $privkey = $aes->gen_readymade_key(); |
|
919 $pkba = hexdecode($privkey); |
|
920 $encpass = $aes->encrypt($dec, $pkba, ENC_HEX); |
|
921 |
|
922 echo 'done!<br />Preparing for schema execution...'; |
|
923 $schema = file_get_contents('schema.sql'); |
|
924 $schema = str_replace('{{SITE_NAME}}', mysql_real_escape_string($_POST['sitename'] ), $schema); |
|
925 $schema = str_replace('{{SITE_DESC}}', mysql_real_escape_string($_POST['sitedesc'] ), $schema); |
|
926 $schema = str_replace('{{COPYRIGHT}}', mysql_real_escape_string($_POST['copyright'] ), $schema); |
|
927 $schema = str_replace('{{ADMIN_USER}}', mysql_real_escape_string($_POST['admin_user'] ), $schema); |
|
928 $schema = str_replace('{{ADMIN_PASS}}', mysql_real_escape_string($encpass ), $schema); |
|
929 $schema = str_replace('{{ADMIN_EMAIL}}', mysql_real_escape_string($_POST['admin_email']), $schema); |
|
930 $schema = str_replace('{{ENABLE_CACHE}}', mysql_real_escape_string($cacheonoff ), $schema); |
|
931 $schema = str_replace('{{REAL_NAME}}', '', $schema); |
|
932 $schema = str_replace('{{TABLE_PREFIX}}', $_POST['table_prefix'], $schema); |
|
933 $schema = str_replace('{{VERSION}}', ENANO_VERSION, $schema); |
|
934 // Not anymore! :-D |
|
935 // $schema = str_replace('{{BETA_VERSION}}', ENANO_BETA_VERSION, $schema); |
|
936 |
|
937 if(isset($_POST['wiki_mode'])) $schema = str_replace('{{WIKI_MODE}}', '1', $schema); |
|
938 else $schema = str_replace('{{WIKI_MODE}}', '0', $schema); |
|
939 |
|
940 // Build an array of queries |
|
941 $schema = explode(";\n", $schema); |
|
942 echo 'done!<br />Executing schema.sql...'; |
|
943 |
|
944 // OK, do the loop, baby!!! |
|
945 foreach($schema as $q) |
|
946 { |
|
947 $r = mysql_query($q, $conn); |
|
948 if(!$r) err('Error during mainstream installation: '.mysql_error()); |
|
949 } |
|
950 |
|
951 echo 'done!<br />Writing configuration files...'; |
|
952 if($_POST['urlscheme']=='tiny') |
|
953 { |
|
954 $ht = fopen(dirname(__FILE__).'/.htaccess', 'a+'); |
|
955 if(!$ht) err('Error opening file .htaccess for writing'); |
|
956 fwrite($ht, ' |
|
957 RewriteEngine on |
|
958 RewriteCond %{REQUEST_FILENAME} !-d |
|
959 RewriteCond %{REQUEST_FILENAME} !-f |
|
960 RewriteRule ^(.+) '.scriptPath.'/index.php/$1 [L,QSA] |
|
961 RewriteRule \.(php|html|gif|jpg|png|css|js)$ - [L] |
|
962 '); |
|
963 fclose($ht); |
|
964 } |
|
965 |
|
966 $config_file = '<?php |
|
967 /* Enano auto-generated configuration file - editing not recommended! */ |
|
968 $dbhost = \''.addslashes($_POST['db_host']).'\'; |
|
969 $dbname = \''.addslashes($_POST['db_name']).'\'; |
|
970 $dbuser = \''.addslashes($_POST['db_user']).'\'; |
|
971 $dbpasswd = \''.addslashes($_POST['db_pass']).'\'; |
|
972 if(!defined(\'ENANO_CONSTANTS\')) { |
|
973 define(\'ENANO_CONSTANTS\', \'\'); |
|
974 define(\'table_prefix\', \''.$_POST['table_prefix'].'\'); |
|
975 define(\'scriptPath\', \''.scriptPath.'\'); |
|
976 define(\'contentPath\', \''.$cp.'\'); |
|
977 define(\'ENANO_INSTALLED\', \'true\'); |
|
978 } |
|
979 $crypto_key = \''.$privkey.'\'; |
|
980 ?>'; |
|
981 |
|
982 $cf_handle = fopen(dirname(__FILE__).'/config.php', 'w'); |
|
983 if(!$cf_handle) err('Couldn\'t open file config.php for writing'); |
|
984 fwrite($cf_handle, $config_file); |
|
985 fclose($cf_handle); |
|
986 |
|
987 echo 'done!<br />Initializing logs...'; |
|
988 |
|
989 $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); |
|
990 if ( !$q ) |
|
991 err('Error setting up logs: '.mysql_error()); |
|
992 |
|
993 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>.'; |
|
994 |
|
995 // echo '<script type="text/javascript">window.location="'.scriptPath.'/install.php?mode=finish";</script>'; |
|
996 |
|
997 break; |
|
998 case "finish": |
|
999 echo '<h3>Congratulations!</h3> |
|
1000 <p>You have finished installing Enano on this server.</p> |
|
1001 <h3>Now what?</h3> |
|
1002 <p>Click the link below to see the main page for your website. Where to go from here:</p> |
|
1003 <ul> |
|
1004 <li>The first thing you should do is log into your site using the Log in link on the sidebar.</li> |
|
1005 <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> |
|
1006 <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> |
|
1007 <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> |
|
1008 <li>Hire some moderators, to help you keep rowdy users tame.</li> |
|
1009 <li>Tell the <a href="http://enanocms.org/Contact_us">Enano team</a> what you think.</li> |
|
1010 <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> |
|
1011 </ul> |
|
1012 <p><a href="index.php">Go to your website...</a></p>'; |
|
1013 break; |
|
1014 } |
|
1015 $template->footer(); |
|
1016 |
|
1017 ?> |