Revision 1532
Added by Luisehahne about 14 years ago
| upgrade-script.php | ||
|---|---|---|
| 31 | 31 |
{
|
| 32 | 32 |
// returns a status message |
| 33 | 33 |
$msg = '<'.$element.' class="'.$class.'">'; |
| 34 |
$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong><br />';
|
|
| 34 |
$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>'; |
|
| 35 | 35 |
$msg .= $message.'</'.$element.'>'; |
| 36 | 36 |
echo $msg; |
| 37 | 37 |
} |
| ... | ... | |
| 48 | 48 |
$OK = ' <span class="ok">OK</span> '; |
| 49 | 49 |
$FAIL = ' <span class="error">FAILED</span> '; |
| 50 | 50 |
$DEFAULT_THEME = 'wb_theme'; |
| 51 |
|
|
| 52 |
$dir2remove = array(
|
|
| 51 |
$stepID = 1; |
|
| 52 |
$dirRemove = array(
|
|
| 53 | 53 |
/* |
| 54 | 54 |
'[TEMPLATE]/allcss/', |
| 55 | 55 |
'[TEMPLATE]/blank/', |
| ... | ... | |
| 58 | 58 |
*/ |
| 59 | 59 |
); |
| 60 | 60 |
|
| 61 |
$files2remove = array(
|
|
| 61 |
$filesRemove['0'] = array(
|
|
| 62 | 62 |
|
| 63 | 63 |
'[ADMIN]/preferences/details.php', |
| 64 | 64 |
'[ADMIN]/preferences/email.php', |
| 65 |
'[ADMIN]/preferences/password.php',
|
|
| 65 |
'[ADMIN]/preferences/password.php' |
|
| 66 | 66 |
|
| 67 |
); |
|
| 68 |
|
|
| 69 |
$filesRemove['1'] = array( |
|
| 70 |
|
|
| 67 | 71 |
'[TEMPLATE]/argos_theme/templates/access.htt', |
| 68 | 72 |
'[TEMPLATE]/argos_theme/templates/addons.htt', |
| 69 | 73 |
'[TEMPLATE]/argos_theme/templates/admintools.htt', |
| ... | ... | |
| 124 | 128 |
|
| 125 | 129 |
); |
| 126 | 130 |
|
| 127 |
|
|
| 128 | 131 |
// analyze/check database tables |
| 129 | 132 |
function mysqlCheckTables( $dbName ) |
| 130 | 133 |
{
|
| ... | ... | |
| 219 | 222 |
|
| 220 | 223 |
p { line-height:1.5em; }
|
| 221 | 224 |
|
| 225 |
form {
|
|
| 226 |
display: inline-block; |
|
| 227 |
line-height: 20px; |
|
| 228 |
vertical-align: baseline; |
|
| 229 |
} |
|
| 230 |
input[type="submit"].restart {
|
|
| 231 |
background-color: #FFDBDB; |
|
| 232 |
font-weight: bold; |
|
| 233 |
} |
|
| 234 |
|
|
| 222 | 235 |
h1,h2,h3,h4,h5,h6 {
|
| 223 | 236 |
font-family: Verdana, Arial, Helvetica, sans-serif; |
| 224 | 237 |
color: #369; |
| ... | ... | |
| 266 | 279 |
"; |
| 267 | 280 |
exit(); |
| 268 | 281 |
} |
| 282 |
|
|
| 283 |
$oldVersion = 'Version '.WB_VERSION; |
|
| 284 |
$oldVersion .= (defined('WB_SP') ? ' '.WB_SP : '');
|
|
| 285 |
$oldVersion .= (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
|
|
| 286 |
$newVersion = 'Version '.VERSION; |
|
| 287 |
$newVersion .= (defined('SP') ? ' '.SP : '');
|
|
| 288 |
$newVersion .= (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
|
|
| 289 |
// set addition settings if not exists, otherwise upgrade will be breaks |
|
| 290 |
if(!defined('WB_SP')) { define('WB_SP',''); }
|
|
| 291 |
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
|
|
| 292 |
|
|
| 269 | 293 |
?> |
| 270 |
<p>This script upgrades an existing WebsiteBaker <strong>Version <?php echo WB_VERSION; ?></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>
|
|
| 294 |
<p>This script upgrades an existing WebsiteBaker <strong> <?php echo $oldVersion; ?></strong> installation to the <strong> <?php echo $newVersion ?> </strong>.<br />The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
|
|
| 271 | 295 |
|
| 272 | 296 |
<?php |
| 273 | 297 |
/** |
| ... | ... | |
| 277 | 301 |
<h2>Step 1: Backup your files</h2> |
| 278 | 302 |
<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> |
| 279 | 303 |
|
| 280 |
<form name="send" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
|
|
| 304 |
<form name="send" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
|
|
| 281 | 305 |
<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> |
| 282 | 306 |
<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. |
| 283 | 307 |
<br /><br /><input name="send" type="submit" value="Start upgrade script" /> |
| ... | ... | |
| 293 | 317 |
"; |
| 294 | 318 |
exit(); |
| 295 | 319 |
} |
| 296 |
echo '<h2>Step 2: Updating database entries</h2>'; |
|
| 297 | 320 |
|
| 321 |
echo '<h2>Step '.(++$stepID).' : Updating database entries</h2>'; |
|
| 322 |
|
|
| 298 | 323 |
// function to add a var/value-pair into settings-table |
| 299 | 324 |
function db_add_key_value($key, $value) {
|
| 300 | 325 |
global $database; global $OK; global $FAIL; |
| ... | ... | |
| 342 | 367 |
*/ |
| 343 | 368 |
echo "<br />Adding default_theme to settings table<br />"; |
| 344 | 369 |
db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
|
| 345 |
/* |
|
| 346 |
$cfg = array( |
|
| 347 |
'default_theme' => 'wb_theme' |
|
| 348 |
); |
|
| 349 |
foreach($cfg as $key=>$value) {
|
|
| 350 |
db_add_key_value($key, $value); |
|
| 351 |
} |
|
| 352 |
*/ |
|
| 353 | 370 |
/********************************************************** |
| 354 | 371 |
* - install droplets |
| 355 | 372 |
*/ |
| ... | ... | |
| 421 | 438 |
} |
| 422 | 439 |
|
| 423 | 440 |
/********************************************************** |
| 441 |
* - Adding rename_files_on_upload to settings table |
|
| 442 |
*/ |
|
| 443 |
echo "<br />Updating rename_files_on_upload to settings table<br />"; |
|
| 444 |
$cfg = array( |
|
| 445 |
'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js' |
|
| 446 |
); |
|
| 447 |
db_update_key_value('settings', 'rename_files_on_upload', $cfg['rename_files_on_upload']);
|
|
| 448 |
|
|
| 449 |
/********************************************************** |
|
| 424 | 450 |
* - Adding mediasettings to settings table |
| 425 | 451 |
*/ |
| 426 | 452 |
echo "<br />Adding mediasettings to settings table<br />"; |
| 427 | 453 |
$cfg = array( |
| 428 | 454 |
'mediasettings' => '', |
| 429 |
'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js' |
|
| 430 | 455 |
); |
| 431 |
db_update_key_value('settings', 'rename_files_on_upload', $cfg['rename_files_on_upload']);
|
|
| 432 | 456 |
|
| 433 | 457 |
foreach($cfg as $key=>$value) {
|
| 434 | 458 |
db_add_key_value($key, $value); |
| ... | ... | |
| 604 | 628 |
require_once(WB_PATH."/modules/news/upgrade.php"); |
| 605 | 629 |
} |
| 606 | 630 |
} |
| 607 |
/********************************************************** |
|
| 608 |
* - Set Version to new Version |
|
| 609 |
*/ |
|
| 610 |
echo '<br />Update database version number to '.VERSION.' : '; |
|
| 611 |
// echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
|
|
| 612 |
db_update_key_value('settings', 'wb_version', VERSION);
|
|
| 613 | 631 |
|
| 614 | 632 |
/* ***************************************************************************** |
| 615 | 633 |
* - check for deprecated / never needed files |
| 616 | 634 |
*/ |
| 635 |
if(sizeof($filesRemove)) {
|
|
| 617 | 636 |
?> |
| 618 |
<h2>Step 3: Remove deprecated and old files</h2>
|
|
| 637 |
<h2>Step <?php echo (++$stepID) ?>: Remove deprecated and old files</h2>
|
|
| 619 | 638 |
<?php |
| 620 |
|
|
| 639 |
} |
|
| 621 | 640 |
$searches = array( |
| 622 | 641 |
'[ADMIN]', |
| 623 | 642 |
'[MEDIA]', |
| ... | ... | |
| 631 | 650 |
'/templates', |
| 632 | 651 |
); |
| 633 | 652 |
|
| 634 |
$msg = ''; |
|
| 635 |
foreach( $files2remove as $file ) |
|
| 653 |
foreach( $filesRemove as $filesId ) |
|
| 636 | 654 |
{
|
| 637 |
$file = str_replace($searches, $replacements, $file); |
|
| 638 |
$file = WB_PATH.'/'.$file; |
|
| 639 |
if( file_exists( $file )) |
|
| 640 |
{ // try to unlink file
|
|
| 641 |
if(!unlink($file)) |
|
| 642 |
{ // save in err-list, if failed
|
|
| 643 |
$msg .= $file.'<br />'; |
|
| 655 |
$msg = ''; |
|
| 656 |
foreach( $filesId as $file ) |
|
| 657 |
{
|
|
| 658 |
$file = str_replace($searches, $replacements, $file); |
|
| 659 |
$file = WB_PATH.'/'.$file; |
|
| 660 |
if( file_exists($file) ) |
|
| 661 |
{ // try to unlink file
|
|
| 662 |
if(!is_writable( $file ) || !unlink($file)) |
|
| 663 |
{ // save in err-list, if failed
|
|
| 664 |
$msg .= $file.'<br />'; |
|
| 665 |
} |
|
| 644 | 666 |
} |
| 645 | 667 |
} |
| 668 |
|
|
| 669 |
if($msg != '') |
|
| 670 |
{
|
|
| 671 |
$msg = '<br /><br />Following files are deprecated, outdated or a security risk and |
|
| 672 |
can not be removed automatically.<br /><br />Please delete them |
|
| 673 |
using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />'; |
|
| 674 |
status_msg($msg, 'error warning', 'div'); |
|
| 675 |
echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>'; |
|
| 676 |
|
|
| 677 |
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">'; |
|
| 678 |
echo ' <input name="send" type="submit" value="Restart upgrade script" />'; |
|
| 679 |
echo '</form>'; |
|
| 680 |
echo '<br /><br /></div></body></html>'; |
|
| 681 |
exit; |
|
| 682 |
} |
|
| 646 | 683 |
} |
| 647 | 684 |
|
| 648 |
if($msg != '') |
|
| 649 |
{
|
|
| 650 |
$msg = 'Following files are deprecated, outdated or a security risk and |
|
| 651 |
can not be removed automatically.<br /><br />Please delete them |
|
| 652 |
using FTP and restart upgrade-script!<br /><br />'.$msg; |
|
| 653 |
status_msg($msg, 'error warning', 'div'); |
|
| 654 |
echo '<br /><br /><br /><br /></div></body></html>'; |
|
| 655 |
exit(); |
|
| 656 |
} |
|
| 685 |
|
|
| 657 | 686 |
/********************************************************** |
| 658 | 687 |
* - check for deprecated / never needed files |
| 659 | 688 |
*/ |
| 689 |
if(sizeof($dirRemove)) {
|
|
| 660 | 690 |
?> |
| 661 |
<h2>Step 4: Remove deprecated and old Templates</h2>
|
|
| 691 |
<h2>Step <?php echo (++$stepID) ?> : Remove deprecated and old folders</h2>
|
|
| 662 | 692 |
<?php |
| 663 | 693 |
|
| 664 | 694 |
$searches = array( |
| ... | ... | |
| 675 | 705 |
); |
| 676 | 706 |
|
| 677 | 707 |
$msg = ''; |
| 678 |
foreach( $dir2remove as $dir )
|
|
| 708 |
foreach( $dirRemove as $dir )
|
|
| 679 | 709 |
{
|
| 680 | 710 |
$dir = str_replace($searches, $replacements, $dir); |
| 681 | 711 |
$dir = WB_PATH.'/'.$dir; |
| ... | ... | |
| 689 | 719 |
} |
| 690 | 720 |
if($msg != '') |
| 691 | 721 |
{
|
| 692 |
$msg = 'Following directories are deprecated, outdated or a security risk and
|
|
| 722 |
$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
|
|
| 693 | 723 |
can not be removed automatically.<br /><br />Please delete them |
| 694 |
using FTP!<br /><br />'.$msg;
|
|
| 724 |
using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
|
|
| 695 | 725 |
status_msg($msg, 'error warning', 'div'); |
| 696 |
echo '<br /><br /><br /><br /></div>'; |
|
| 726 |
echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>'; |
|
| 727 |
|
|
| 728 |
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">'; |
|
| 729 |
echo ' <input name="send" type="submit" value="Restart upgrade script" />'; |
|
| 730 |
echo '</form>'; |
|
| 731 |
echo '<br /><br /></div></body></html>'; |
|
| 732 |
exit; |
|
| 697 | 733 |
} |
| 734 |
|
|
| 735 |
} |
|
| 736 |
|
|
| 737 |
?> |
|
| 738 |
<h2>Step <?php echo (++$stepID) ?> : Reload all addons database entry (no upgrade)</h2> |
|
| 739 |
<?php |
|
| 698 | 740 |
/********************************************************** |
| 699 | 741 |
* - Reload all addons |
| 700 | 742 |
*/ |
| ... | ... | |
| 748 | 790 |
|
| 749 | 791 |
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
|
| 750 | 792 |
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
|
| 793 |
/********************************************************** |
|
| 794 |
* - Set Version to new Version |
|
| 795 |
*/ |
|
| 796 |
echo '<br />Update database version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : '; |
|
| 797 |
// echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
|
|
| 798 |
db_update_key_value('settings', 'wb_version', VERSION);
|
|
| 799 |
db_update_key_value('settings', 'wb_revision', REVISION);
|
|
| 800 |
db_update_key_value('settings', 'wb_sp', SP);
|
|
| 751 | 801 |
|
| 752 | 802 |
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>'; |
| 753 | 803 |
status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
|
| 754 | 804 |
// show buttons to go to the backend or frontend |
| 755 | 805 |
echo '<br />'; |
| 806 |
|
|
| 756 | 807 |
if(defined('WB_URL')) {
|
| 757 |
echo '<form action="'.WB_URL.'">'; |
|
| 758 |
echo '<input type="submit" value="kick me to the Frontend" style="float:left;" />';
|
|
| 808 |
echo '<form action="'.WB_URL.'/">';
|
|
| 809 |
echo ' <input type="submit" value="kick me to the Frontend" />';
|
|
| 759 | 810 |
echo '</form>'; |
| 760 | 811 |
} |
| 761 | 812 |
if(defined('ADMIN_URL')) {
|
| 762 |
echo '<form action="'.ADMIN_URL.'">'; |
|
| 813 |
echo '<form action="'.ADMIN_URL.'/">';
|
|
| 763 | 814 |
echo ' <input type="submit" value="kick me to the Backend" />'; |
| 764 | 815 |
echo '</form>'; |
| 765 | 816 |
} |
| 766 |
echo '<p> </p>'; |
|
| 767 | 817 |
|
| 768 |
?> |
|
| 818 |
?><br /><br />
|
|
| 769 | 819 |
</div> |
| 770 | 820 |
</body> |
| 771 | 821 |
</html> |
Also available in: Unified diff
small changes in INSTALL and UPGRADE (Tks to unawave2)
update upgrade-script showing from Version to Version (Tks to unawave2)
add Servicepack version to header.htt