1 <?php |
1 <?php |
2 |
2 |
3 /* |
3 /* |
4 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
4 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
5 * Version 1.0 (Banshee) |
5 * Version 1.1.1 |
6 * Copyright (C) 2006-2007 Dan Fuhry |
6 * Copyright (C) 2006-2007 Dan Fuhry |
7 * |
7 * |
8 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
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. |
9 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
10 * |
10 * |
54 die(__FILE__.':'.__LINE__.': The debugConsole requires PHP 5.x.x or greater. Please comment out the ENANO_DEBUG constant in your index.php.'); |
54 die(__FILE__.':'.__LINE__.': The debugConsole requires PHP 5.x.x or greater. Please comment out the ENANO_DEBUG constant in your index.php.'); |
55 } |
55 } |
56 |
56 |
57 if(defined('ENANO_DEBUG')) |
57 if(defined('ENANO_DEBUG')) |
58 { |
58 { |
59 // require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php'); |
59 require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php'); |
60 function dc_here($m) { return false; } |
|
61 function dc_dump($a, $g) { return false; } |
|
62 function dc_watch($n) { return false; } |
|
63 function dc_start_timer($u) { return false; } |
|
64 function dc_stop_timer($m) { return false; } |
|
65 } else { |
60 } else { |
66 function dc_here($m) { return false; } |
61 function dc_here($m) { return false; } |
67 function dc_dump($a, $g) { return false; } |
62 function dc_dump($a, $g) { return false; } |
68 function dc_watch($n) { return false; } |
63 function dc_watch($n) { return false; } |
69 function dc_start_timer($u) { return false; } |
64 function dc_start_timer($u) { return false; } |
70 function dc_stop_timer($m) { return false; } |
65 function dc_stop_timer($m) { return false; } |
71 } |
66 } |
72 |
67 |
73 if ( file_exists( ENANO_ROOT . '/_nightly.php') ) |
68 if ( file_exists( ENANO_ROOT . '/_nightly.php') ) |
74 require(ENANO_ROOT.'/_nightly.php'); |
69 require(ENANO_ROOT.'/_nightly.php'); |
|
70 |
|
71 // List of scheduled tasks |
|
72 $cron_tasks = array(); |
75 |
73 |
76 // Start including files. LOTS of files. Yeah! |
74 // Start including files. LOTS of files. Yeah! |
77 require_once(ENANO_ROOT.'/includes/constants.php'); |
75 require_once(ENANO_ROOT.'/includes/constants.php'); |
78 dc_here('Enano CMS '.$version.' (dev) - debug window<br />Powered by debugConsole'); |
76 dc_here('Enano CMS '.$version.' (dev) - debug window<br />Powered by debugConsole'); |
79 dc_here('common: including files'); |
77 dc_here('common: including files'); |
81 require_once(ENANO_ROOT.'/includes/dbal.php'); |
79 require_once(ENANO_ROOT.'/includes/dbal.php'); |
82 require_once(ENANO_ROOT.'/includes/paths.php'); |
80 require_once(ENANO_ROOT.'/includes/paths.php'); |
83 require_once(ENANO_ROOT.'/includes/sessions.php'); |
81 require_once(ENANO_ROOT.'/includes/sessions.php'); |
84 require_once(ENANO_ROOT.'/includes/template.php'); |
82 require_once(ENANO_ROOT.'/includes/template.php'); |
85 require_once(ENANO_ROOT.'/includes/plugins.php'); |
83 require_once(ENANO_ROOT.'/includes/plugins.php'); |
|
84 require_once(ENANO_ROOT.'/includes/lang.php'); |
86 require_once(ENANO_ROOT.'/includes/comment.php'); |
85 require_once(ENANO_ROOT.'/includes/comment.php'); |
87 require_once(ENANO_ROOT.'/includes/wikiformat.php'); |
86 require_once(ENANO_ROOT.'/includes/wikiformat.php'); |
88 require_once(ENANO_ROOT.'/includes/diff.php'); |
87 require_once(ENANO_ROOT.'/includes/diff.php'); |
89 require_once(ENANO_ROOT.'/includes/render.php'); |
88 require_once(ENANO_ROOT.'/includes/render.php'); |
90 require_once(ENANO_ROOT.'/includes/stats.php'); |
89 require_once(ENANO_ROOT.'/includes/stats.php'); |
106 global $db, $session, $paths, $template, $plugins; // Common objects |
105 global $db, $session, $paths, $template, $plugins; // Common objects |
107 global $enano_config; // A global used to cache config information without making loads of queries ;-) |
106 global $enano_config; // A global used to cache config information without making loads of queries ;-) |
108 // In addition, $enano_config is used to fetch config information if die_semicritical() is called. |
107 // In addition, $enano_config is used to fetch config information if die_semicritical() is called. |
109 |
108 |
110 global $email; |
109 global $email; |
|
110 global $lang; |
111 |
111 |
112 if(!isset($_SERVER['HTTP_HOST'])) grinding_halt('Cannot get hostname', '<p>Your web browser did not provide the HTTP Host: field. This site requires a modern browser that supports the HTTP 1.1 standard.</p>'); |
112 if(!isset($_SERVER['HTTP_HOST'])) grinding_halt('Cannot get hostname', '<p>Your web browser did not provide the HTTP Host: field. This site requires a modern browser that supports the HTTP 1.1 standard.</p>'); |
113 |
113 |
114 $db = new mysql(); |
114 $db = new mysql(); |
115 dc_here('common: calling $db->connect();'); |
115 dc_here('common: calling $db->connect();'); |
150 $db->free_result(); |
150 $db->free_result(); |
151 |
151 |
152 if(enano_version(false, true) != $version) |
152 if(enano_version(false, true) != $version) |
153 { |
153 { |
154 grinding_halt('Version mismatch', '<p>It seems that the Enano release we\'re trying to run ('.$version.') is different from the version specified in your database ('.enano_version().'). Perhaps you need to <a href="'.scriptPath.'/upgrade.php">upgrade</a>?</p>'); |
154 grinding_halt('Version mismatch', '<p>It seems that the Enano release we\'re trying to run ('.$version.') is different from the version specified in your database ('.enano_version().'). Perhaps you need to <a href="'.scriptPath.'/upgrade.php">upgrade</a>?</p>'); |
|
155 } |
|
156 |
|
157 // |
|
158 // Low level maintenance |
|
159 // |
|
160 |
|
161 // If the search algorithm backend has been changed, empty out the search cache (the two cache formats are incompatible with each other) |
|
162 if ( getConfig('last_search_algo') != SEARCH_MODE ) |
|
163 { |
|
164 if ( !$db->sql_query('DELETE FROM '.table_prefix.'search_cache;') ) |
|
165 $db->_die(); |
|
166 setConfig('last_search_algo', SEARCH_MODE); |
|
167 } |
|
168 |
|
169 // If the AES key size has been changed, bail out and fast |
|
170 if ( !getConfig('aes_key_size') ) |
|
171 { |
|
172 setConfig('aes_key_size', AES_BITS); |
|
173 } |
|
174 else if ( $ks = getConfig('aes_key_size') ) |
|
175 { |
|
176 if ( intval($ks) != AES_BITS ) |
|
177 { |
|
178 grinding_halt('AES key size changed', '<p>Enano has detected that the AES key size in constants.php has been changed. This change cannot be performed after installation, otherwise the private key would have to be re-generated and all passwords would have to be re-encrypted.</p><p>Please change the key size back to ' . $ks . ' bits and reload this page.</p>'); |
|
179 } |
|
180 } |
|
181 |
|
182 // Same for AES block size |
|
183 if ( !getConfig('aes_block_size') ) |
|
184 { |
|
185 setConfig('aes_block_size', AES_BLOCKSIZE); |
|
186 } |
|
187 else if ( $ks = getConfig('aes_block_size') ) |
|
188 { |
|
189 if ( intval($ks) != AES_BLOCKSIZE ) |
|
190 { |
|
191 grinding_halt('AES block size changed', '<p>Enano has detected that the AES block size in constants.php has been changed. This change cannot be performed after installation, otherwise all passwords would have to be re-encrypted.</p><p>Please change the block size back to ' . $ks . ' bits and reload this page.</p>'); |
|
192 } |
|
193 } |
|
194 |
|
195 // Is there no default language? |
|
196 if ( getConfig('lang_default') === false ) |
|
197 { |
|
198 $q = $db->sql_query('SELECT lang_id FROM '.table_prefix.'language LIMIT 1;'); |
|
199 if ( !$q ) |
|
200 $db->_die('common.php - setting default language'); |
|
201 if ( $db->numrows() < 1 && !defined('ENANO_ALLOW_LOAD_NOLANG') ) |
|
202 { |
|
203 grinding_halt('No languages', '<p>There are no languages installed on this site.</p> |
|
204 <p>If you are the website administrator, you may install a language by writing and executing a simple PHP script to install it:</p> |
|
205 <pre> |
|
206 <?php |
|
207 define("ENANO_ALLOW_LOAD_NOLANG", 1); |
|
208 $_GET["title"] = "langinstall"; |
|
209 require("includes/common.php"); |
|
210 install_language("eng", "English", "English", ENANO_ROOT . "/language/english/enano.json");</pre>'); |
|
211 } |
|
212 $row = $db->fetchrow(); |
|
213 setConfig('default_language', $row['lang_id']); |
155 } |
214 } |
156 |
215 |
157 // Our list of tables included in Enano |
216 // Our list of tables included in Enano |
158 $system_table_list = Array( |
217 $system_table_list = Array( |
159 table_prefix.'categories', |
218 table_prefix.'categories', |
174 table_prefix.'hits', |
233 table_prefix.'hits', |
175 table_prefix.'search_index', |
234 table_prefix.'search_index', |
176 table_prefix.'groups', |
235 table_prefix.'groups', |
177 table_prefix.'group_members', |
236 table_prefix.'group_members', |
178 table_prefix.'acl', |
237 table_prefix.'acl', |
179 table_prefix.'search_cache' |
238 table_prefix.'search_cache', |
|
239 table_prefix.'page_groups', |
|
240 table_prefix.'page_group_members', |
|
241 table_prefix.'tags' |
180 ); |
242 ); |
181 |
243 |
182 dc_here('common: initializing base classes'); |
244 dc_here('common: initializing base classes'); |
183 $plugins = new pluginLoader(); |
245 $plugins = new pluginLoader(); |
184 |
246 |
230 $n = 'The administrator has disabled the site. Please check back later.'; |
292 $n = 'The administrator has disabled the site. Please check back later.'; |
231 } |
293 } |
232 |
294 |
233 $text = RenderMan::render($n) . ' |
295 $text = RenderMan::render($n) . ' |
234 <div class="info-box"> |
296 <div class="info-box"> |
235 If you have an administrative account, you may <a href="'.makeUrlNS('Special', 'Login').'">log in</a> to the site or <a href="'.makeUrlNS('Special', 'Administration').'">use the administration panel</a>. |
297 If you have an administrative account, you may <a href="'.makeUrlNS('Special', 'Login').'">log in</a> to the site. |
236 </div>'; |
298 </div>'; |
237 $paths->wiki_mode = 0; |
299 $paths->wiki_mode = 0; |
238 die_semicritical('Site disabled', $text); |
300 die_semicritical('Site disabled', $text); |
239 } |
301 } |
240 } |
302 } |