author | Dan |
Tue, 18 Dec 2007 23:47:33 -0500 | |
changeset 324 | 16d0c9f33466 |
parent 322 | 5f1cd51bf1be |
child 326 | ab66d6d1f1f4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
||
3 |
/* |
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
317
diff
changeset
|
5 |
* Version 1.0.3 (Dyrad) |
0 | 6 |
* upgrade.php - upgrade script |
7 |
* Copyright (C) 2006-2007 Dan Fuhry |
|
8 |
* |
|
9 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
13 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
14 |
*/ |
|
15 |
||
289
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
16 |
define('IN_ENANO_INSTALL', 'true'); |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
17 |
define('IN_ENANO_UPGRADE', 'true'); |
0 | 18 |
|
19 |
if(!defined('scriptPath')) { |
|
20 |
$sp = dirname($_SERVER['REQUEST_URI']); |
|
21 |
if($sp == '/' || $sp == '\\') $sp = ''; |
|
22 |
define('scriptPath', $sp); |
|
23 |
} |
|
24 |
||
25 |
if(!defined('contentPath')) { |
|
26 |
$sp = dirname($_SERVER['REQUEST_URI']); |
|
27 |
if($sp == '/' || $sp == '\\') $sp = ''; |
|
28 |
define('contentPath', $sp); |
|
29 |
} |
|
30 |
||
289
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
31 |
global $this_page, $sideinfo; |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
32 |
|
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
33 |
function microtime_float() |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
34 |
{ |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
35 |
list($usec, $sec) = explode(" ", microtime()); |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
36 |
return ((float)$usec + (float)$sec); |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
37 |
} |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
38 |
|
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
39 |
global $_starttime; |
2b60c89dc27f
Fixed a few major bugs with the upgrade script and the config file not getting loaded properly due to IN_ENANO_INSTALL
Dan
parents:
272
diff
changeset
|
40 |
$_starttime = microtime_float(); |
0 | 41 |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
42 |
// Determine directory (special case for development servers) |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
43 |
if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') ) |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
44 |
{ |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
45 |
$filename = str_replace('/repo/', '/', __FILE__); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
46 |
} |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
47 |
else |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
48 |
{ |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
49 |
$filename = __FILE__; |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
50 |
} |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
51 |
|
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
52 |
define('ENANO_ROOT', dirname($filename)); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
53 |
|
0 | 54 |
require(ENANO_ROOT.'/includes/constants.php'); |
55 |
||
56 |
if(defined('ENANO_DEBUG')) |
|
57 |
{ |
|
58 |
require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php'); |
|
59 |
} |
|
60 |
else |
|
61 |
{ |
|
62 |
function dc_here($m) { return false; } |
|
63 |
function dc_dump($a, $g) { return false; } |
|
64 |
function dc_watch($n) { return false; } |
|
65 |
function dc_start_timer($u) { return false; } |
|
66 |
function dc_stop_timer($m) { return false; } |
|
67 |
} |
|
68 |
||
69 |
// SCRIPT CONFIGURATION |
|
70 |
// Everything related to versions goes here! |
|
71 |
||
72 |
// Valid versions to upgrade from |
|
317 | 73 |
$valid_versions = Array('1.0b1', '1.0b2', '1.0b3', '1.0b4', '1.0RC1', '1.0RC2', '1.0RC3', '1.0', '1.0.1', '1.0.1.1', '1.0.2b1', '1.0.2'); |
0 | 74 |
|
75 |
// Basically a list of dependencies, which should be resolved automatically |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
76 |
// If, for example, upgrading from 1.0b1 to 1.0RC1 requires one extra query that would not |
0 | 77 |
// normally be required (for whatever reason) then you would add a custom version number to the array under key '1.0b1'. |
78 |
$deps_list = Array( |
|
79 |
'1.0b1' => Array('1.0b2'), |
|
80 |
'1.0b2' => Array('1.0b3'), |
|
81 |
'1.0b3' => Array('1.0b4'), |
|
82 |
'1.0b4' => Array('1.0RC1'), |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
83 |
'1.0RC1' => Array('1.0RC2'), |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
33
diff
changeset
|
84 |
'1.0RC2' => Array('1.0RC3'), |
129
0b5244001799
Rebranded as 1.0.1.1; fixed category page drawing bug; updated link to GPL in the about page to the GPLv2
Dan
parents:
113
diff
changeset
|
85 |
'1.0RC3' => Array('1.0'), |
142
ca9118d9c0f2
Rebrand as 1.0.2 (Coblynau); internal links are now parsed by RenderMan::parse_internal_links()
Dan
parents:
129
diff
changeset
|
86 |
'1.0' => Array('1.0.1'), |
149 | 87 |
'1.0.1' => Array('1.0.1.1'), |
88 |
'1.0.1.1' => Array('1.0.2b1') |
|
0 | 89 |
); |
317 | 90 |
$this_version = '1.0.3'; |
0 | 91 |
$func_list = Array( |
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
92 |
'1.0' => Array('u_1_0_1_update_del_votes'), |
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
93 |
'1.0b4' => Array('u_1_0_RC1_update_user_ids', 'u_1_0_RC1_add_admins_to_group', 'u_1_0_RC1_alter_files_table', 'u_1_0_RC1_destroy_session_cookie', 'u_1_0_RC1_set_contact_email', 'u_1_0_RC1_update_page_text'), // , |
16
64e0d3d4cf14
Emergency version change to 1.0rc3 to fix XSS vulnerabilities
Dan
parents:
0
diff
changeset
|
94 |
// '1.0RC2' => Array('u_1_0_populate_userpage_comments') |
290
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
95 |
'1.0RC3' => Array('u_1_0_RC3_make_users_extra'), |
297
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
96 |
'1.0.2b1' => Array('u_1_0_2_nuke_template_cache', 'u_1_0_2_rebuild_search_index') |
0 | 97 |
); |
98 |
||
99 |
if(!isset($_GET['mode'])) |
|
100 |
{ |
|
101 |
$_GET['mode'] = 'login'; |
|
102 |
} |
|
103 |
||
104 |
function err($t) |
|
105 |
{ |
|
106 |
global $template; |
|
107 |
echo $t; |
|
108 |
$template->footer(); |
|
109 |
exit; |
|
110 |
} |
|
111 |
||
112 |
require(ENANO_ROOT.'/includes/template.php'); |
|
113 |
||
114 |
// Initialize the session manager |
|
115 |
require(ENANO_ROOT.'/includes/functions.php'); |
|
116 |
require(ENANO_ROOT.'/includes/dbal.php'); |
|
117 |
require(ENANO_ROOT.'/includes/paths.php'); |
|
118 |
require(ENANO_ROOT.'/includes/sessions.php'); |
|
119 |
require(ENANO_ROOT.'/includes/plugins.php'); |
|
120 |
require(ENANO_ROOT.'/includes/rijndael.php'); |
|
121 |
require(ENANO_ROOT.'/includes/render.php'); |
|
306 | 122 |
require(ENANO_ROOT.'/includes/search.php'); |
0 | 123 |
$db = new mysql(); |
124 |
$db->connect(); |
|
125 |
||
126 |
$plugins = new pluginLoader(); |
|
127 |
||
128 |
if(!defined('ENANO_CONFIG_FETCHED')) |
|
129 |
{ |
|
130 |
// Select and fetch the site configuration |
|
131 |
$e = $db->sql_query('SELECT config_name, config_value FROM '.table_prefix.'config;'); |
|
132 |
if ( !$e ) |
|
133 |
{ |
|
134 |
$db->_die('Some critical configuration information could not be selected.'); |
|
135 |
} |
|
136 |
else |
|
137 |
{ |
|
138 |
define('ENANO_CONFIG_FETCHED', ''); // Used in die_semicritical to figure out whether to call getConfig() or not |
|
139 |
} |
|
140 |
||
141 |
$enano_config = Array(); |
|
142 |
while($r = $db->fetchrow()) |
|
143 |
{ |
|
144 |
$enano_config[$r['config_name']] = $r['config_value']; |
|
145 |
} |
|
146 |
$db->free_result(); |
|
147 |
} |
|
148 |
||
149 |
$v = enano_version(); |
|
150 |
if(in_array($v, Array(false, '', '1.0b3', '1.0b4'))) |
|
151 |
{ |
|
152 |
$ul_admin = 2; |
|
153 |
$ul_mod = 1; |
|
154 |
$ul_member = 0; |
|
155 |
$ul_guest = -1; |
|
156 |
} |
|
157 |
else |
|
158 |
{ |
|
159 |
$ul_admin = USER_LEVEL_ADMIN; |
|
160 |
$ul_mod = USER_LEVEL_MOD; |
|
161 |
$ul_member = USER_LEVEL_MEMBER; |
|
162 |
$ul_guest = USER_LEVEL_GUEST; |
|
163 |
} |
|
164 |
||
165 |
$_GET['title'] = 'unset'; |
|
166 |
||
167 |
$session = new sessionManager(); |
|
168 |
$paths = new pathManager(); |
|
169 |
$session->start(); |
|
170 |
||
171 |
$template = new template_nodb(); |
|
172 |
$template->load_theme('oxygen', 'bleu', false); |
|
173 |
||
174 |
$modestrings = Array( |
|
175 |
'login' => 'Administrative login', |
|
176 |
'welcome' => 'Welcome', |
|
177 |
'setversion' => 'Select Enano version', |
|
178 |
'confirm' => 'Confirm upgrade', |
|
179 |
'upgrade' => 'Database installation', |
|
180 |
'finish' => 'Upgrade complete' |
|
181 |
); |
|
182 |
||
183 |
$sideinfo = ''; |
|
184 |
$vars = $template->extract_vars('elements.tpl'); |
|
185 |
$p = $template->makeParserText($vars['sidebar_button']); |
|
186 |
foreach ( $modestrings as $id => $str ) |
|
187 |
{ |
|
188 |
if ( $_GET['mode'] == $id ) |
|
189 |
{ |
|
190 |
$flags = 'style="font-weight: bold; text-decoration: underline;"'; |
|
191 |
$this_page = $str; |
|
192 |
} |
|
193 |
else |
|
194 |
{ |
|
195 |
$flags = ''; |
|
196 |
} |
|
197 |
$p->assign_vars(Array( |
|
198 |
'HREF' => '#', |
|
199 |
'FLAGS' => $flags . ' onclick="return false;"', |
|
200 |
'TEXT' => $str |
|
201 |
)); |
|
202 |
$sideinfo .= $p->run(); |
|
203 |
} |
|
204 |
||
205 |
$template->init_vars(); |
|
206 |
||
207 |
function upg_assign_vars($schema) |
|
208 |
{ |
|
209 |
$schema = str_replace('{{SITE_NAME}}', mysql_real_escape_string(getConfig('site_name')), $schema); |
|
210 |
$schema = str_replace('{{SITE_DESC}}', mysql_real_escape_string(getConfig('site_desc')), $schema); |
|
211 |
$schema = str_replace('{{COPYRIGHT}}', mysql_real_escape_string(getConfig('copyright_notice')), $schema); |
|
212 |
$schema = str_replace('{{TABLE_PREFIX}}', table_prefix, $schema); |
|
213 |
if(getConfig('wiki_mode')=='1') $schema = str_replace('{{WIKI_MODE}}', '1', $schema); |
|
214 |
else $schema = str_replace('{{WIKI_MODE}}', '0', $schema); |
|
215 |
return $schema; |
|
216 |
} |
|
217 |
||
218 |
/* Version-specific functions */ |
|
219 |
||
220 |
function u_1_0_RC1_update_user_ids() |
|
221 |
{ |
|
222 |
global $db; |
|
223 |
// First, make sure this hasn't already been done |
|
224 |
$q = $db->sql_query('SELECT username FROM '.table_prefix.'users WHERE user_id=1;'); |
|
225 |
if ( !$q ) |
|
226 |
$db->_die(); |
|
227 |
$row = $db->fetchrow(); |
|
228 |
if ( $row['username'] == 'Anonymous' ) |
|
229 |
return true; |
|
230 |
// Find the first unused user ID |
|
231 |
$used = Array(); |
|
95
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
232 |
$q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users;'); |
0 | 233 |
if ( !$q ) |
234 |
$db->_die(); |
|
95
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
235 |
$notfirst = false; |
0 | 236 |
while ( $row = $db->fetchrow() ) |
237 |
{ |
|
238 |
$i = intval($row['user_id']); |
|
239 |
$used[$i] = true; |
|
95
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
240 |
if ( !isset($used[$i - 1]) && $notfirst ) |
0 | 241 |
{ |
242 |
$id = $i - 1; |
|
243 |
break; |
|
244 |
} |
|
95
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
245 |
$notfirst = true; |
0 | 246 |
} |
247 |
if ( !isset($id) ) |
|
248 |
$id = $i + 1; |
|
95
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
249 |
if ( $id == 0 ) |
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
250 |
$id = 2; |
0 | 251 |
$db->free_result(); |
252 |
||
253 |
$q = $db->sql_query('UPDATE '.table_prefix.'users SET user_id=' . $id . ' WHERE user_id=1;'); |
|
254 |
if(!$q) |
|
255 |
$db->_die(); |
|
256 |
$q = $db->sql_query('UPDATE '.table_prefix.'users SET user_id=1 WHERE user_id=-1 AND username=\'Anonymous\';'); |
|
257 |
if(!$q) |
|
258 |
$db->_die(); |
|
259 |
||
260 |
} |
|
261 |
||
262 |
function u_1_0_RC1_add_admins_to_group() |
|
263 |
{ |
|
264 |
global $db; |
|
265 |
$q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE user_level=' . USER_LEVEL_ADMIN . ';'); |
|
266 |
if ( !$q ) |
|
267 |
$db->_die(); |
|
268 |
$base = 'INSERT INTO '.table_prefix.'group_members(group_id,user_id) VALUES'; |
|
269 |
$blocks = Array(); |
|
270 |
while ( $row = $db->fetchrow($q) ) |
|
271 |
{ |
|
272 |
$blocks[] = '(2,' . $row['user_id'] . ')'; |
|
273 |
} |
|
274 |
$blocks = implode(',', $blocks); |
|
275 |
$sql = $base . $blocks . ';'; |
|
276 |
if(!$db->sql_query($sql)) |
|
277 |
$db->_die(); |
|
278 |
} |
|
279 |
||
280 |
function u_1_0_RC1_alter_files_table() |
|
281 |
{ |
|
282 |
global $db; |
|
283 |
if(!is_dir(ENANO_ROOT.'/files')) |
|
284 |
@mkdir(ENANO_ROOT . '/files'); |
|
285 |
if(!is_dir(ENANO_ROOT.'/files')) |
|
286 |
die('ERROR: Couldn\'t create files directory'); |
|
287 |
$q = $db->sql_unbuffered_query('SELECT * FROM '.table_prefix.'files;', $db->_conn); |
|
288 |
if(!$q) $db->_die(); |
|
289 |
while ( $row = $db->fetchrow() ) |
|
290 |
{ |
|
291 |
$file_data = base64_decode($row['data']); |
|
292 |
$path = ENANO_ROOT . '/files/' . md5( $row['filename'] . '_' . $file_data ) . '_' . $row['time_id'] . $row['file_extension']; |
|
293 |
@unlink($path); |
|
294 |
$handle = @fopen($path, 'w'); |
|
295 |
if(!$handle) |
|
296 |
die('fopen failed'); |
|
297 |
fwrite($handle, $file_data); |
|
298 |
fclose($handle); |
|
299 |
||
300 |
} |
|
301 |
||
302 |
$q = $db->sql_query('ALTER TABLE '.table_prefix.'files DROP PRIMARY KEY, ADD COLUMN file_id int(12) NOT NULL auto_increment FIRST, ADD PRIMARY KEY (file_id), ADD COLUMN file_key varchar(32) NOT NULL;'); |
|
303 |
if(!$q) $db->_die(); |
|
304 |
||
305 |
$list = Array(); |
|
306 |
$q = $db->sql_unbuffered_query('SELECT * FROM '.table_prefix.'files;', $db->_conn); |
|
307 |
if(!$q) $db->_die(); |
|
308 |
while ( $row = $db->fetchrow($q) ) |
|
309 |
{ |
|
310 |
$file_data = base64_decode($row['data']); |
|
311 |
$key = md5( $row['filename'] . '_' . $file_data ); |
|
312 |
$list[] = 'UPDATE '.table_prefix.'files SET file_key=\'' . $key . '\' WHERE file_id=' . $row['file_id'] . ';'; |
|
313 |
} |
|
314 |
||
315 |
foreach ( $list as $sql ) |
|
316 |
{ |
|
317 |
if(!$db->sql_query($sql)) $db->_die(); |
|
318 |
} |
|
319 |
||
320 |
if(!$db->sql_query('ALTER TABLE '.table_prefix.'files DROP data')) $db->_die(); |
|
321 |
||
322 |
} |
|
323 |
||
324 |
function u_1_0_RC1_destroy_session_cookie() |
|
325 |
{ |
|
326 |
unset($_COOKIE['sid']); |
|
327 |
setcookie('sid', '', time()-3600*24, scriptPath); |
|
328 |
setcookie('sid', '', time()-3600*24, scriptPath.'/'); |
|
329 |
} |
|
330 |
||
331 |
function u_1_0_RC1_set_contact_email() |
|
332 |
{ |
|
333 |
global $db; |
|
334 |
$q = $db->sql_query('SELECT email FROM '.table_prefix.'users WHERE user_level='.USER_LEVEL_ADMIN.' ORDER BY user_level ASC LIMIT 1;'); |
|
335 |
if(!$q) |
|
336 |
$db->_die(); |
|
337 |
$row = $db->fetchrow(); |
|
338 |
setConfig('contact_email', $row['email']); |
|
339 |
} |
|
340 |
||
341 |
function u_1_0_RC1_update_page_text() |
|
342 |
{ |
|
343 |
global $db; |
|
344 |
$q = $db->sql_unbuffered_query('SELECT page_id,namespace,page_text,char_tag FROM '.table_prefix.'page_text'); |
|
345 |
if (!$q) |
|
346 |
$db->_die(); |
|
347 |
||
348 |
$qs = array(); |
|
349 |
||
350 |
while ( $row = $db->fetchrow($q) ) |
|
351 |
{ |
|
352 |
$row['page_text'] = str_replace(Array( |
|
353 |
"{QUOT:{$row['char_tag']}}", |
|
354 |
"{APOS:{$row['char_tag']}}", |
|
355 |
"{SLASH:{$row['char_tag']}}" |
|
356 |
), Array( |
|
357 |
'"', "'", '\\' |
|
358 |
), $row['page_text']); |
|
359 |
$qs[] = 'UPDATE '.table_prefix.'page_text SET page_text=\'' . mysql_real_escape_string($row['page_text']) . '\' |
|
360 |
WHERE page_id=\'' . mysql_real_escape_string($row['page_id']) . '\' AND |
|
361 |
namespace=\'' . mysql_real_escape_string($row['namespace']) . '\';'; |
|
362 |
} |
|
363 |
||
364 |
foreach($qs as $query) |
|
365 |
{ |
|
366 |
if(!$db->sql_query($query)) |
|
367 |
$db->_die(); |
|
368 |
} |
|
369 |
} |
|
370 |
||
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
371 |
function u_1_0_1_update_del_votes() |
0 | 372 |
{ |
373 |
global $db; |
|
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
374 |
$q = $db->sql_query('SELECT urlname, namespace, delvote_ips FROM '.table_prefix.'pages;'); |
0 | 375 |
if ( !$q ) |
376 |
$db->_die(); |
|
377 |
||
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
378 |
while ( $row = $db->fetchrow($q) ) |
0 | 379 |
{ |
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
380 |
$ips = strval($row['delvote_ips']); |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
381 |
if ( is_array( @unserialize($ips) ) ) |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
382 |
continue; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
383 |
$ips = explode('|', $ips); |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
384 |
$new = array( |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
385 |
'ip' => array(), |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
386 |
'u' => array() |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
387 |
); |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
388 |
$i = 0; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
389 |
$prev = ''; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
390 |
$prev_is_ip = false; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
391 |
foreach ( $ips as $ip ) |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
392 |
{ |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
393 |
$i++; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
394 |
$current_is_ip = is_valid_ip($ip); |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
395 |
if ( $current_is_ip && $prev_is_ip ) |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
396 |
{ |
113
6f357b951f7a
Oops - fixed small glitch in delvote_ips converter code
Dan
parents:
112
diff
changeset
|
397 |
$i++; |
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
398 |
$new['u'][] = $prev; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
399 |
} |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
400 |
if ( $current_is_ip ) |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
401 |
{ |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
402 |
$new['ip'][] = $ip; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
403 |
} |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
404 |
else |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
405 |
{ |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
406 |
$new['u'][] = $ip; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
407 |
} |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
408 |
$prev = $ip; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
409 |
$prev_is_ip = $current_is_ip; |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
410 |
} |
113
6f357b951f7a
Oops - fixed small glitch in delvote_ips converter code
Dan
parents:
112
diff
changeset
|
411 |
if ( $i % 2 == 1 && $prev_is_ip ) |
6f357b951f7a
Oops - fixed small glitch in delvote_ips converter code
Dan
parents:
112
diff
changeset
|
412 |
{ |
6f357b951f7a
Oops - fixed small glitch in delvote_ips converter code
Dan
parents:
112
diff
changeset
|
413 |
$new['u'][] = $ip; |
6f357b951f7a
Oops - fixed small glitch in delvote_ips converter code
Dan
parents:
112
diff
changeset
|
414 |
} |
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
415 |
$new = serialize($new); |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
416 |
$e = $db->sql_query('UPDATE '.table_prefix.'pages SET delvote_ips=\'' . $db->escape($new) . '\' WHERE urlname=\'' . $db->escape($row['urlname']) . '\' AND namespace=\'' . $db->escape($row['namespace']) . '\';'); |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
417 |
if ( !$e ) |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
418 |
$db->_die(); |
0 | 419 |
} |
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
110
diff
changeset
|
420 |
$db->free_result($q); |
0 | 421 |
} |
422 |
||
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
423 |
function u_1_0_RC3_make_users_extra() |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
424 |
{ |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
425 |
global $db; |
95
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
426 |
$q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE user_id > 0;'); |
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
427 |
if ( !$q ) |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
428 |
$db->_die(); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
429 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
430 |
$ids = array(); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
431 |
while ( $row = $db->fetchrow() ) |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
432 |
{ |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
433 |
$ids[] = intval($row['user_id']); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
434 |
} |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
435 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
436 |
$ids = '(' . implode('),(', $ids) . ')'; |
95
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
437 |
if ( $ids == '' ) |
1dac77b46f07
Changed style of copyright in St. Patty; first attempt at fixing some upgrade issues from beta 3 or so
dan
parents:
91
diff
changeset
|
438 |
return false; |
31
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
439 |
$sql = "INSERT INTO " . table_prefix . "users_extra(user_id) VALUES$ids;"; |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
440 |
|
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
441 |
if ( !$db->sql_query($sql) ) |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
442 |
$db->_die(); |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
443 |
} |
dc8741857bde
Finished Special:Preferences/Profile page! Only the wikitext parser cleanup left, yay!
Dan
parents:
21
diff
changeset
|
444 |
|
290
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
445 |
function u_1_0_2_nuke_template_cache() |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
446 |
{ |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
447 |
$dir = @opendir(ENANO_ROOT . '/cache'); |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
448 |
if ( !$dir ) |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
449 |
{ |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
450 |
return false; |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
451 |
} |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
452 |
while ( ($fname = @readdir($dir)) ) |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
453 |
{ |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
454 |
if ( preg_match('/\.tpl\.php$/', $fname) ) |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
455 |
{ |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
456 |
unlink( ENANO_ROOT . '/cache/' . $fname ); |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
457 |
} |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
458 |
} |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
459 |
} |
1201c9412cb6
The template-cache incompatibility bug has finally been isolated, so a function to clear the template cache was added into the upgrade script for 1.0.2
Dan
parents:
289
diff
changeset
|
460 |
|
297
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
461 |
function u_1_0_2_rebuild_search_index() |
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
462 |
{ |
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
463 |
global $paths; |
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
464 |
@set_time_limit(0); |
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
465 |
$paths->rebuild_search_index(); |
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
466 |
} |
ee1fc84f12a8
SECURITY: Tighten default allowed file types; make sure search index rebuild is performed on upgrade
Dan
parents:
290
diff
changeset
|
467 |
|
0 | 468 |
switch($_GET['mode']) |
469 |
{ |
|
470 |
case "login": |
|
110 | 471 |
if ( $session->user_logged_in && $session->user_level < $ul_admin ) |
472 |
{ |
|
473 |
$template->header(); |
|
474 |
echo '<p>Your user account does not have permission to perform an upgrade of Enano. Return to the <a href="index.php">index page</a>.</p>'; |
|
475 |
$template->footer(); |
|
476 |
exit; |
|
477 |
} |
|
0 | 478 |
if($session->user_logged_in && $session->user_level >= $ul_admin) |
479 |
{ |
|
480 |
if(isset($_POST['login'])) |
|
481 |
{ |
|
482 |
$session->login_without_crypto($_POST['username'], $_POST['password'], false, $ul_admin); |
|
483 |
if($session->sid_super) |
|
484 |
{ |
|
485 |
header('Location: upgrade.php?mode=welcome&auth='.$session->sid_super); |
|
486 |
exit; |
|
487 |
} |
|
488 |
} |
|
489 |
$template->header(); |
|
490 |
?> |
|
491 |
<form action="upgrade.php?mode=login" method="post"> |
|
492 |
<table border="0" style="margin-left: auto; margin-right: auto; margin-top: 5px;" cellspacing="1" cellpadding="4"> |
|
493 |
<tr> |
|
494 |
<th colspan="2">You must re-authenticate to perform this upgrade.</th> |
|
495 |
</tr> |
|
496 |
<?php |
|
497 |
if(isset($_POST['login'])) |
|
498 |
{ |
|
499 |
echo '<tr><td colspan="2"><p style="color: red;">Login failed. Bad password?</p></td></tr>'; |
|
500 |
} |
|
501 |
?> |
|
502 |
<tr> |
|
503 |
<td>Username:</td><td><input type="text" name="username" size="30" /></td> |
|
504 |
</tr> |
|
505 |
<tr> |
|
506 |
<td>Password:</td><td><input type="password" name="password" size="30" /></td> |
|
507 |
</tr> |
|
508 |
<tr> |
|
509 |
<td colspan="2" style="text-align: center;"><input type="submit" name="login" value="Log in" /> |
|
510 |
</tr> |
|
511 |
</table> |
|
512 |
</form> |
|
513 |
<?php |
|
514 |
} |
|
515 |
else |
|
516 |
{ |
|
517 |
if(isset($_POST['login'])) |
|
518 |
{ |
|
519 |
$result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, $ul_member); |
|
520 |
if($result == 'success') |
|
521 |
{ |
|
522 |
header('Location: upgrade.php'); |
|
523 |
exit; |
|
524 |
} |
|
525 |
} |
|
526 |
$template->header(); |
|
527 |
?> |
|
528 |
<form action="upgrade.php?mode=login" method="post"> |
|
529 |
<table border="0" style="margin-left: auto; margin-right: auto; margin-top: 5px;" cellspacing="1" cellpadding="4"> |
|
530 |
<tr> |
|
531 |
<th colspan="2">Please log in to continue with this upgrade.</th> |
|
532 |
</tr> |
|
533 |
<?php |
|
534 |
if(isset($_POST['login'])) |
|
535 |
{ |
|
536 |
echo '<tr><td colspan="2"><p style="color: red;">Login failed. Bad password?</p></td></tr>'; |
|
537 |
} |
|
538 |
?> |
|
539 |
<tr> |
|
540 |
<td>Username:</td><td><input type="text" name="username" size="30" /></td> |
|
541 |
</tr> |
|
542 |
<tr> |
|
543 |
<td>Password:</td><td><input type="password" name="password" size="30" /></td> |
|
544 |
</tr> |
|
545 |
<tr> |
|
546 |
<td colspan="2" style="text-align: center;"><input type="submit" name="login" value="Log in" /> |
|
547 |
</tr> |
|
548 |
</table> |
|
549 |
</form> |
|
550 |
<?php |
|
551 |
} |
|
552 |
break; |
|
553 |
case "welcome": |
|
554 |
if(!$session->sid_super) { $template->header(); echo '<p>No admin session found! Please <a href="upgrade.php">restart the upgrade</a>.</p>'; $template->footer(); exit; } |
|
555 |
||
556 |
// Just show a simple welcome page to display version information |
|
557 |
$template->header(); |
|
558 |
require('config.php'); |
|
559 |
||
560 |
?> |
|
561 |
||
562 |
<div style="text-align: center; margin-top: 10px;"> |
|
563 |
<img alt="[ Enano CMS Project logo ]" src="images/enano-artwork/installer-greeting-blue.png" style="display: block; margin: 0 auto; padding-left: 134px;" /> |
|
564 |
<h2>Welcome to the Enano upgrade wizard</h2> |
|
565 |
<?php |
|
566 |
if ( file_exists('./_nightly.php') ) |
|
567 |
{ |
|
568 |
echo '<div class="warning-box" style="text-align: left; margin: 10px auto; display: table; width: 60%;"><b>You are about to upgrade to a NIGHTLY BUILD of Enano.</b><br />Nightly builds CANNOT be re-upgraded to the final release. They may also contain serious flaws, security problems, or extraneous debugging information. Continuing this process on a production site is NOT recommended.</div>'; |
|
569 |
} |
|
570 |
?> |
|
571 |
</div> |
|
572 |
<div style="display: table; margin: 0 auto;"> |
|
573 |
<p>You are about to upgrade Enano to version <b><?php echo $this_version; ?></b>. Before you continue, please ensure that:</p> |
|
574 |
<ul> |
|
575 |
<li>You have completely backed up your database (<b><?php echo "$dbhost:$dbname"; ?></b>)</li> |
|
576 |
<li>You have backed up the entire Enano directory (<b><?php echo ENANO_ROOT; ?></b>)</li> |
|
577 |
<li>You have reviewed the release notes for this version, and you<br />are comfortable with any known bugs or issues</li> |
|
91 | 578 |
<li>If you've configured Enano to work using a MySQL user with restricted<br />privileges, you need to enable ALTER, CREATE TABLE, and CREATE INDEX privileges<br />for this upgrade to work.</li> |
0 | 579 |
</ul> |
580 |
</div> |
|
581 |
<div style="text-align: center; margin-top: 10px;"> |
|
582 |
<form action="upgrade.php?mode=setversion&auth=<?php echo $session->sid_super; ?>" method="post"> |
|
583 |
<input type="submit" value="Continue with upgrade" /> |
|
584 |
</form> |
|
585 |
</div> |
|
586 |
||
587 |
<?php |
|
588 |
||
589 |
break; |
|
590 |
case "setversion": |
|
591 |
if(!$session->sid_super) { $template->header(); echo '<p>No admin session found! Please <a href="upgrade.php">restart the upgrade</a>.</p>'; $template->footer(); exit; } |
|
592 |
$v = ( function_exists('enano_version') ) ? enano_version() : ''; |
|
593 |
if(!in_array($v, $valid_versions) && $v != '') |
|
594 |
{ |
|
595 |
$template->header(); |
|
596 |
?> |
|
597 |
<p>Your version of Enano (<?php echo $v; ?>) can't be upgraded to this version (<?php echo $this_version; ?>).</p> |
|
598 |
<?php |
|
599 |
break; |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
600 |
} |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
601 |
else if($v == '') |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
602 |
{ |
0 | 603 |
// OK, we don't know which version he's running. So we'll cheat ;-) |
604 |
$template->header(); |
|
605 |
echo "<form action='upgrade.php?mode=confirm&auth={$session->sid_super}' method='post'>"; |
|
606 |
?> |
|
607 |
<p>Sorry, we couldn't detect which version of Enano you're running on your server. Please select which version of Enano you have below, and make absolutely sure that you're correct.</p> |
|
608 |
<p><select name="version"><?php |
|
609 |
foreach($valid_versions as $c) |
|
610 |
{ |
|
611 |
echo "<option value='{$c}'>{$c}</option>"; |
|
612 |
} |
|
613 |
?></select></p> |
|
614 |
<p> |
|
615 |
<input type="submit" value="Continue" /> |
|
616 |
</p> |
|
617 |
<?php |
|
618 |
echo `</form>`; |
|
619 |
break; |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
620 |
} |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
621 |
else |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
16
diff
changeset
|
622 |
{ |
0 | 623 |
header('Location: upgrade.php?mode=confirm&auth='.$session->sid_super); |
624 |
} |
|
625 |
break; |
|
626 |
case "confirm": |
|
627 |
$enano_version = ( isset($_POST['version']) ) ? $_POST['version'] : enano_version(); |
|
628 |
||
629 |
$template->header(); |
|
630 |
if(!$session->sid_super) { echo '<p>No admin session found! Please <a href="upgrade.php">restart the upgrade</a>.</p>'; $template->footer(); exit; } |
|
631 |
?> |
|
632 |
<form action="upgrade.php?mode=upgrade&auth=<?php echo $session->sid_super; ?>" method="post"> |
|
633 |
<table border="0" style="margin-left: auto; margin-right: auto; margin-top: 5px;" cellspacing="1" cellpadding="4"> |
|
634 |
<tr> |
|
635 |
<td colspan="2"><p><b>Are you sure you want to perform this upgrade?</b></p><p>You can still cancel the upgrade process now. If<br />the upgrade fails, you will need to roll back<br />any actions made using manual SQL queries.</p><p><b>Please clear your browser cache or<br />shift-reload after the upgrade.</b><br />If you fail to do so, some page elements may<br />be broken.</td> |
|
636 |
</tr> |
|
637 |
<tr> |
|
638 |
<td colspan="2" style="text-align: center;"> |
|
639 |
<input type="hidden" name="enano_version" value="<?php echo $enano_version; ?>" /> |
|
640 |
<input type="submit" name="doit" value="Upgrade Enano!" /> |
|
641 |
</td> |
|
642 |
</tr> |
|
643 |
</table> |
|
644 |
</form> |
|
645 |
<?php |
|
646 |
break; |
|
647 |
case "upgrade": |
|
648 |
$template->header(); |
|
649 |
if(!$session->sid_super) { echo '<p>No admin session found! Please <a href="upgrade.php">restart the upgrade</a>.</p>'; $template->footer(); exit; } |
|
650 |
if(!isset($_POST['enano_version'])) { echo '<p>Can\'t find the version information on the POST query, are you trying to do this upgrade directly? Please <a href="upgrade.php">restart the upgrade</a>.</p>'; break; } |
|
651 |
$enano_version = $_POST['enano_version']; |
|
652 |
echo '<p>Preparing for schema execution...'; |
|
653 |
// Build an array of queries |
|
654 |
$schema = file_get_contents('upgrade.sql'); |
|
655 |
||
656 |
// Strip out and process version blocks |
|
149 | 657 |
preg_match_all('#---BEGIN ([0-9A-z\.\-]*?)---'."\n".'((.*?)'."\n)?".'---END \\1---#is', $schema, $matches); |
0 | 658 |
|
659 |
$from_list =& $matches[1]; |
|
149 | 660 |
$query_list =& $matches[3]; |
0 | 661 |
|
662 |
foreach($matches[0] as $m) |
|
663 |
{ |
|
664 |
$schema = str_replace($m, '', $schema); |
|
665 |
} |
|
666 |
$schema = explode("\n", $schema); |
|
667 |
foreach($schema as $k => $q) |
|
668 |
{ |
|
669 |
if(substr($q, 0, 2) == '--' || $q == '') |
|
670 |
{ |
|
671 |
unset($schema[$k]); |
|
672 |
//die('<pre>'.htmlspecialchars(print_r($schema, true)).'</pre>'); |
|
673 |
} |
|
674 |
else |
|
675 |
{ |
|
676 |
$schema[$k] = upg_assign_vars($schema[$k]); |
|
677 |
} |
|
678 |
} |
|
679 |
||
680 |
foreach($query_list as $k => $q) |
|
681 |
{ |
|
682 |
$query_list[$k] = explode("\n", $query_list[$k]); |
|
683 |
foreach($query_list[$k] as $i => $s) |
|
684 |
{ |
|
685 |
$tq =& $query_list[$k][$i]; |
|
686 |
if(substr($s, 0, 2) == '--' || $s == '') |
|
687 |
{ |
|
688 |
unset($query_list[$k][$i]); |
|
689 |
//die('<pre>'.htmlspecialchars(print_r($schema, true)).'</pre>'); |
|
690 |
} |
|
691 |
else |
|
692 |
{ |
|
693 |
$query_list[$k][$i] = upg_assign_vars($query_list[$k][$i]); |
|
694 |
} |
|
695 |
} |
|
696 |
$query_list[$k] = array_values($query_list[$k]); |
|
697 |
} |
|
698 |
||
699 |
$assoc_list = Array(); |
|
700 |
||
701 |
foreach($from_list as $i => $v) |
|
702 |
{ |
|
703 |
$assoc_list[$v] = $query_list[$i]; |
|
704 |
} |
|
705 |
||
706 |
$schema = array_values($schema); |
|
707 |
||
708 |
$deps_resolved = false; |
|
709 |
$installing_versions = Array($enano_version); |
|
710 |
||
711 |
while(true) |
|
712 |
{ |
|
713 |
$v = array_keys($deps_list); |
|
714 |
foreach($v as $i => $ver) |
|
715 |
{ |
|
716 |
if(in_array($ver, $installing_versions)) |
|
717 |
{ |
|
718 |
// $ver is on the list of versions to be installed. Add its dependencies to the list of versions to install. |
|
719 |
foreach($deps_list[$ver] as $dep) |
|
720 |
{ |
|
721 |
if(!in_array($dep, $installing_versions)) |
|
722 |
{ |
|
723 |
$installing_versions[] = $dep; |
|
724 |
} |
|
725 |
} |
|
726 |
} |
|
727 |
if($i == count($deps_list) - 1) |
|
728 |
{ |
|
729 |
break 2; |
|
730 |
} |
|
731 |
} |
|
732 |
} |
|
733 |
||
734 |
foreach($installing_versions as $this_ver) |
|
735 |
{ |
|
736 |
$schema = array_merge($schema, $assoc_list[$this_ver]); |
|
737 |
} |
|
738 |
||
739 |
// Time for some proper SQL syntax! |
|
740 |
// Also check queries for so-called injection attempts to make |
|
741 |
// sure that it doesn't fail during the upgrade process and |
|
742 |
// leave the user with a half-upgraded database |
|
743 |
foreach($schema as $s => $q) |
|
744 |
{ |
|
745 |
if(substr($q, strlen($q)-1, 1) != ';') |
|
746 |
{ |
|
747 |
$schema[$s] .= ';'; |
|
748 |
} |
|
749 |
if ( !$db->check_query($schema[$s]) ) |
|
750 |
{ |
|
751 |
// Uh-oh, the check failed, bail out |
|
752 |
// The DBAL runs sanity checks on all queries for safety, |
|
753 |
// so if the check fails in mid-upgrade we are in deep |
|
754 |
// dodo doo-doo. |
|
755 |
echo 'Query failed sanity check, this should never happen and is a bug.</p><p>Query was:</p><pre>'.$schema[$s].'</pre>'; |
|
756 |
break 2; |
|
757 |
} |
|
758 |
} |
|
759 |
||
760 |
$schema = array_values($schema); |
|
761 |
||
762 |
// Used extensively for debugging |
|
763 |
// echo '<pre>'.htmlspecialchars(print_r($schema, true)).'</pre>'; |
|
764 |
// break; |
|
765 |
||
766 |
echo 'done!<br />Executing upgrade schema...'; |
|
767 |
||
768 |
// OK, do the loop, baby!!! |
|
769 |
foreach($schema as $q) |
|
770 |
{ |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
771 |
if ( substr($q, 0, 1) == '@' ) |
0 | 772 |
{ |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
773 |
// if the first character is @, don't fail on error |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
774 |
$db->sql_query(substr($q, 1)); |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
775 |
} |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
776 |
else |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
777 |
{ |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
778 |
if ( !$db->sql_query($q) ) |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
779 |
{ |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
780 |
echo $db->get_error(); |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
781 |
break 2; |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
196
diff
changeset
|
782 |
} |
0 | 783 |
} |
784 |
} |
|
785 |
||
786 |
// Call any custom functions |
|
787 |
foreach ( $installing_versions as $ver ) |
|
788 |
{ |
|
789 |
if ( isset($func_list[$ver]) ) |
|
790 |
{ |
|
791 |
foreach($func_list[$ver] as $function) |
|
792 |
{ |
|
793 |
@call_user_func($function); |
|
794 |
} |
|
795 |
} |
|
796 |
} |
|
797 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
798 |
// Log the upgrade |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
799 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,page_text,edit_summary) VALUES(\'security\', \'upgrade_enano\', ' . time() . ', \'' . date('d M Y h:i a') . '\', \'' . mysql_real_escape_string($session->username) . '\', \'' . mysql_real_escape_string($this_version) . '\', \'' . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . '\');'); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
800 |
|
0 | 801 |
echo 'done!</p>'; |
802 |
echo '<p>You will be redirected shortly. If you aren\'t redirected, <a href="index.php">click here</a>.</p> |
|
803 |
<script type="text/javascript">setTimeout("window.location=\'index.php\'", 2000)</script>'; |
|
804 |
break; |
|
805 |
} |
|
806 |
$template->footer(); |
|
807 |
||
808 |
?> |