Revision 1286
Added by Luisehahne almost 15 years ago
upgrade-script.php | ||
---|---|---|
64 | 64 |
$x++; |
65 | 65 |
} |
66 | 66 |
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
67 | 71 |
return $data; |
68 | 72 |
} |
69 | 73 |
|
70 |
// check existings tables for upgrade or install |
|
71 |
/* |
|
72 |
$get_result = mysql_list_tables (DB_NAME); */ |
|
73 |
$get_result = $database->query( "SHOW TABLES FROM ".DB_NAME); |
|
74 |
$all_tables = array(); |
|
75 |
if($get_result->numRows() > 0) |
|
74 |
|
|
75 |
// check existings tables for upgrade or install |
|
76 |
function check_wb_tables() |
|
76 | 77 |
{ |
77 |
while ($data = $get_result->fetchRow())
|
|
78 |
{
|
|
79 |
$tmp = str_replace(TABLE_PREFIX, '', $data[0]);
|
|
80 |
if(in_array($tmp,$table_list))
|
|
78 |
global $database,$table_list;
|
|
79 |
$get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
|
|
80 |
$all_tables = array();
|
|
81 |
if($get_result->numRows() > 0)
|
|
81 | 82 |
{ |
82 |
$all_tables[] = $tmp; |
|
83 |
while ($data = $get_result->fetchRow()) |
|
84 |
{ |
|
85 |
$tmp = str_replace(TABLE_PREFIX, '', $data[0]); |
|
86 |
if(in_array($tmp,$table_list)) |
|
87 |
{ |
|
88 |
$all_tables[] = $tmp; |
|
89 |
} |
|
90 |
} |
|
83 | 91 |
} |
84 |
}
|
|
85 |
}
|
|
92 |
return $all_tables;
|
|
93 |
} |
|
86 | 94 |
|
95 |
// check existing tables |
|
96 |
$all_tables = check_wb_tables(); |
|
87 | 97 |
|
98 |
// only for array tests |
|
88 | 99 |
function show_array($array=array()) |
89 | 100 |
{ |
90 | 101 |
print '<pre>'; |
... | ... | |
99 | 110 |
<title>Upgrade script</title> |
100 | 111 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
101 | 112 |
<style type="text/css"> |
113 |
html { overflow: -moz-scrollbars-vertical; /* Force firefox to always show room for a vertical scrollbar */ } |
|
114 |
|
|
102 | 115 |
body { |
103 | 116 |
margin:0; |
104 | 117 |
padding:0; |
... | ... | |
146 | 159 |
margin-top:0.5em; |
147 | 160 |
border: 1px solid black; |
148 | 161 |
} |
162 |
.info { |
|
163 |
width: 98%; |
|
164 |
background:#99CC99; |
|
165 |
padding:0.2em; |
|
166 |
margin-top:0.5em; |
|
167 |
border: 1px solid black; |
|
168 |
} |
|
169 |
|
|
149 | 170 |
</style> |
150 | 171 |
</head> |
151 | 172 |
<body> |
152 | 173 |
<div id="container"> |
153 |
<img src="templates/wb_theme/images/logo.png" alt="Website Baker Logo" />
|
|
174 |
<img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
|
|
154 | 175 |
|
155 |
<h1>Website Baker Upgrade</h1>
|
|
156 |
<p>This script upgrades an existing Website Baker <strong>Version 2.7</strong> installation to the <strong>Version <?php print $version ?></strong>. The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
|
|
176 |
<h1>WebsiteBaker Upgrade</h1> |
|
177 |
<p>This script upgrades an existing WebsiteBaker <strong>Version 2.7 and higher</strong> installation to the <strong>Version <?php echo $version ?></strong>. The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
|
|
157 | 178 |
|
158 | 179 |
<?php |
159 | 180 |
/** |
... | ... | |
164 | 185 |
<p>It is highly recommended to <strong>create a manual backup</strong> of the entire <strong>/pages folder</strong> and the <strong>MySQL database</strong> before proceeding.<br /><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p> |
165 | 186 |
|
166 | 187 |
<form name="send" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> |
167 |
<textarea cols="80" rows="5">DISCLAIMER: The Website Baker upgrade script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. One needs to confirm that a manual backup of the /pages folder (including all files and subfolders contained in it) and backup of the entire Website Baker MySQL database was created before you can proceed.</textarea>
|
|
188 |
<textarea cols="80" rows="5">DISCLAIMER: The WebsiteBaker upgrade script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. One needs to confirm that a manual backup of the /pages folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
|
|
168 | 189 |
<br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" /> I confirm that a manual backup of the /pages folder and the MySQL database was created. |
169 | 190 |
<br /><br /><input name="send" type="submit" value="Start upgrade script" /> |
170 | 191 |
</form> |
... | ... | |
181 | 202 |
} |
182 | 203 |
|
183 | 204 |
echo '<h2>Step 2: Updating database entries</h2>'; |
184 |
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', 'wb_theme'); } |
|
185 | 205 |
|
186 | 206 |
require_once(WB_PATH.'/framework/functions.php'); |
187 | 207 |
require_once(WB_PATH.'/framework/class.admin.php'); |
188 | 208 |
$admin = new admin('Addons', 'modules', false, false); |
189 |
require_once(WB_PATH.'/framework/initialize.php'); |
|
190 | 209 |
|
191 | 210 |
$OK = '<span class="ok">OK</span>'; |
192 | 211 |
$FAIL = '<span class="error">FAILED</span>'; |
193 | 212 |
|
194 |
$check_text = 'total '; |
|
195 |
// $check_tables = mysqlCheckTables( DB_NAME ) ; |
|
196 |
|
|
197 |
if(sizeof($all_tables) == 22) |
|
198 |
{ |
|
199 |
echo '<h4>NOTICE: Your database '.DB_NAME.' has '.sizeof($all_tables).' '.$check_text.' tables from '.sizeof($table_list).' included in package '.$OK.'</h4>'; |
|
200 |
} |
|
201 |
else |
|
202 |
{ |
|
203 |
status_msg('<strong>WARNING:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div'); |
|
204 |
echo '<h4>Install missing tables, you can install them in backend->addons->modules->advanced. Then again run upgrade-script.php</h4>'; |
|
205 |
$result = array_diff ( $table_list, $all_tables ); |
|
206 |
echo '<h4>'; |
|
207 |
while ( list ( $key, $val ) = each ( $result ) ) |
|
208 |
{ |
|
209 |
echo TABLE_PREFIX.$val.' '.$FAIL.'<br>'; |
|
210 |
} |
|
211 |
echo '</h4>'; |
|
212 |
echo '<br /><form action="'. $_SERVER['PHP_SELF'] .'">'; |
|
213 |
echo '<input type="submit" value="kick me back" style="float:left;" />'; |
|
214 |
echo '</form><br /><br />'; |
|
215 |
echo "</div> |
|
216 |
</body> |
|
217 |
</html> |
|
218 |
"; |
|
219 |
exit(); |
|
220 |
} |
|
221 | 213 |
// function to add a var/value-pair into settings-table |
222 | 214 |
function db_add_key_value($key, $value) { |
223 | 215 |
global $database; global $OK; global $FAIL; |
... | ... | |
261 | 253 |
} |
262 | 254 |
|
263 | 255 |
/********************************************************** |
264 |
* - Adding field sec_anchor to settings table
|
|
256 |
* - Adding field default_theme to settings table
|
|
265 | 257 |
*/ |
266 |
|
|
267 |
echo "<br />Adding sec_anchor to settings table<br />"; |
|
258 |
echo "<br />Adding default_theme to settings table<br />"; |
|
268 | 259 |
$cfg = array( |
269 |
'sec_anchor' => 'wb_'
|
|
260 |
'default_theme' => 'wb_theme'
|
|
270 | 261 |
); |
262 |
|
|
271 | 263 |
foreach($cfg as $key=>$value) { |
272 | 264 |
db_add_key_value($key, $value); |
273 | 265 |
} |
274 | 266 |
|
275 | 267 |
/********************************************************** |
276 |
* - Adding field default_theme to settings table
|
|
268 |
* - install droplets
|
|
277 | 269 |
*/ |
278 |
echo "<br />Adding default_theme to settings table<br />"; |
|
270 |
$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />"; |
|
271 |
echo $drops; |
|
272 |
|
|
273 |
$file_name = (!in_array ( "mod_droplets", $all_tables)) ? "install.php" : "upgrade.php"; |
|
274 |
require_once (WB_PATH."/modules/droplets/".$file_name); |
|
275 |
|
|
276 |
// check again all tables, to get a new array |
|
277 |
if(sizeof($all_tables) < 22) { $all_tables = check_wb_tables(); } |
|
278 |
/********************************************************** |
|
279 |
* - check tables comin with WebsiteBaker |
|
280 |
*/ |
|
281 |
$check_text = 'total '; |
|
282 |
// $check_tables = mysqlCheckTables( DB_NAME ) ; |
|
283 |
|
|
284 |
if(sizeof($all_tables) == 22) |
|
285 |
{ |
|
286 |
echo '<h4>NOTICE: Your database '.DB_NAME.' has '.sizeof($all_tables).' '.$check_text.' tables from '.sizeof($table_list).' included in package '.$OK.'</h4>'; |
|
287 |
} |
|
288 |
else |
|
289 |
{ |
|
290 |
status_msg('<strong>WARNING:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div'); |
|
291 |
echo '<h4>Install missing tables, you can install them in backend->addons->modules->advanced. Then again run upgrade-script.php</h4>'; |
|
292 |
$result = array_diff ( $table_list, $all_tables ); |
|
293 |
echo '<h4 class="warning">'; |
|
294 |
while ( list ( $key, $val ) = each ( $result ) ) |
|
295 |
{ |
|
296 |
echo TABLE_PREFIX.$val.' '.$FAIL.'<br>'; |
|
297 |
} |
|
298 |
echo '</h4>'; |
|
299 |
echo '<br /><form action="'. $_SERVER['PHP_SELF'] .'">'; |
|
300 |
echo '<input type="submit" value="kick me back" style="float:left;" />'; |
|
301 |
echo '</form>'; |
|
302 |
if(defined('ADMIN_URL')) |
|
303 |
{ |
|
304 |
echo '<form action="'.ADMIN_URL.'" target="_self">'; |
|
305 |
echo ' <input type="submit" value="kick me to the Backend" />'; |
|
306 |
echo '</form>'; |
|
307 |
} |
|
308 |
echo "<br /><br /></div> |
|
309 |
</body> |
|
310 |
</html> |
|
311 |
"; |
|
312 |
exit(); |
|
313 |
} |
|
314 |
|
|
315 |
/********************************************************** |
|
316 |
* - Adding field sec_anchor to settings table |
|
317 |
*/ |
|
318 |
|
|
319 |
echo "<br />Adding sec_anchor to settings table<br />"; |
|
279 | 320 |
$cfg = array( |
280 |
'default_theme' => 'wb_theme'
|
|
321 |
'sec_anchor' => 'wb_'
|
|
281 | 322 |
); |
282 | 323 |
foreach($cfg as $key=>$value) { |
283 | 324 |
db_add_key_value($key, $value); |
... | ... | |
311 | 352 |
echo "<br />Adding field redirect_type to mod_menu_link table<br />"; |
312 | 353 |
db_add_field('redirect_type', 'mod_menu_link', "INT NOT NULL DEFAULT '302' AFTER `target_page_id`"); |
313 | 354 |
|
314 |
/********************************************************** |
|
315 |
* - Update search no results database filed to create |
|
316 |
* valid XHTML if search is empty |
|
317 |
*/ |
|
318 |
echo "<br />Updating database field `no_results` of search table: "; |
|
319 |
$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>'); |
|
320 |
$sql = "UPDATE `" . TABLE_PREFIX . "search` SET `value` = '$search_no_results' WHERE `name`= 'no_results'"; |
|
321 |
$database->query($sql); |
|
322 |
echo ($database->query($sql)) ? " $OK<br />" : " $FAIL<br />"; |
|
323 | 355 |
|
324 | 356 |
|
325 |
if (version_compare(VERSION, '2.8.0') <= 0)
|
|
357 |
if (version_compare(WB_VERSION, '2.8.0') < 0)
|
|
326 | 358 |
{ |
327 | 359 |
/********************************************************** |
360 |
* - Update search no results database filed to create |
|
361 |
* valid XHTML if search is empty |
|
362 |
*/ |
|
363 |
echo "<br />Updating database field `no_results` of search table: "; |
|
364 |
$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>'); |
|
365 |
$sql = "UPDATE `" . TABLE_PREFIX . "search` SET `value` = '$search_no_results' WHERE `name`= 'no_results'"; |
|
366 |
$database->query($sql); |
|
367 |
echo ($database->query($sql)) ? " $OK<br />" : " $FAIL<br />"; |
|
368 |
/********************************************************** |
|
328 | 369 |
* - Update settings of News Modul |
329 | 370 |
*/ |
330 | 371 |
|
... | ... | |
378 | 419 |
<h2>[POST_TITLE]</h2> |
379 | 420 |
<br />'; |
380 | 421 |
|
381 |
if(in_array('mod_news_settings', $all_tables)) |
|
382 |
{ |
|
383 |
// Insert default settings into database |
|
384 |
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0"); |
|
422 |
if(in_array('mod_news_settings', $all_tables)) |
|
423 |
{ |
|
424 |
// Insert default settings into database |
|
425 |
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0"); |
|
426 |
if($query_dates->numRows() > 1) |
|
427 |
{ |
|
385 | 428 |
while($result = $query_dates->fetchRow()) |
386 | 429 |
{ |
387 | 430 |
|
... | ... | |
434 | 477 |
echo mysql_error().'<br />'; |
435 | 478 |
|
436 | 479 |
} |
480 |
|
|
481 |
|
|
482 |
if ((version_compare(WB_VERSION, '2.8.0') <= 0) && file_exists(WB_PATH."/modules/news/upgrade.php")) |
|
483 |
{ |
|
484 |
echo '<h4>Upgrade existings postfiles to new format</h4><br />'; |
|
485 |
// change old postfiles to new postfiles |
|
486 |
require_once(WB_PATH."/modules/news/upgrade.php"); |
|
487 |
} |
|
437 | 488 |
} |
438 |
else |
|
439 |
{ |
|
440 |
echo 'Missing database table '.TABLE_PREFIX.'mod_news_settings '.$FAIL.'<br />'; |
|
441 |
} |
|
442 | 489 |
|
443 |
if(file_exists(WB_PATH."/modules/news/upgrade.php")) |
|
444 |
{ |
|
445 |
echo '<h4>Upgrade existings postfiles to new format</h4><br />'; |
|
446 |
// change old postfiles to new postfiles |
|
447 |
require_once(WB_PATH."/modules/news/upgrade.php"); |
|
490 |
} |
|
491 |
|
|
448 | 492 |
} |
449 |
} |
|
450 | 493 |
|
451 | 494 |
/********************************************************** |
452 | 495 |
* - Set Version to WB 2.8.1 |
... | ... | |
455 | 498 |
echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value` = '$version' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />"; |
456 | 499 |
|
457 | 500 |
/********************************************************** |
458 |
* - install droplets |
|
459 |
*/ |
|
460 |
$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />"; |
|
461 |
echo $drops; |
|
462 |
|
|
463 |
$file_name = (!in_array ( "mod_droplets", $all_tables)) ? "install.php" : "upgrade.php"; |
|
464 |
require_once (WB_PATH."/modules/droplets/".$file_name); |
|
465 |
|
|
466 |
/********************************************************** |
|
467 | 501 |
* - Reload all addons |
468 | 502 |
*/ |
469 | 503 |
|
... | ... | |
510 | 544 |
/********************************************************** |
511 | 545 |
* - End of upgrade script |
512 | 546 |
*/ |
547 |
|
|
548 |
// require(WB_PATH.'/framework/initialize.php'); |
|
549 |
|
|
550 |
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', 'wb_theme'); } |
|
551 |
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);} |
|
552 |
|
|
513 | 553 |
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>'; |
514 | 554 |
status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div'); |
515 | 555 |
// show buttons to go to the backend or frontend |
516 | 556 |
echo '<br />'; |
517 | 557 |
if(defined('WB_URL')) { |
518 |
echo '<form action="'.WB_URL.'" target="_self">';
|
|
558 |
echo '<form action="'.WB_URL.'">'; |
|
519 | 559 |
echo '<input type="submit" value="kick me to the Frontend" style="float:left;" />'; |
520 | 560 |
echo '</form>'; |
521 | 561 |
} |
522 | 562 |
if(defined('ADMIN_URL')) { |
523 |
echo '<form action="'.ADMIN_URL.'" target="_self">';
|
|
563 |
echo '<form action="'.ADMIN_URL.'">'; |
|
524 | 564 |
echo ' <input type="submit" value="kick me to the Backend" />'; |
525 | 565 |
echo '</form>'; |
526 | 566 |
} |
Also available in: Unified diff
Droplet emailfilter fixed search mdcr.js
some little fixes in upgrade-script
new WebsiteBaker Logo in themes