Revision 1677
Added by Luisehahne over 13 years ago
| upgrade-script.php | ||
|---|---|---|
| 15 | 15 |
* |
| 16 | 16 |
*/ |
| 17 | 17 |
|
| 18 |
@require_once('config.php');
|
|
| 18 |
require_once('config.php');
|
|
| 19 | 19 |
|
| 20 | 20 |
require_once(WB_PATH.'/framework/functions.php'); |
| 21 | 21 |
require_once(WB_PATH.'/framework/class.admin.php'); |
| 22 | 22 |
require_once(WB_PATH.'/framework/class.database.php'); |
| 23 | 23 |
$admin = new admin('Addons', 'modules', false, false);
|
| 24 | 24 |
|
| 25 |
/* display a status message on the screen ************************************** |
|
| 26 |
* @param string $message: the message to show |
|
| 27 |
* @param string $class: kind of message as a css-class |
|
| 28 |
* @param string $element: witch HTML-tag use to cover the message |
|
| 29 |
* @return void |
|
| 30 |
*/ |
|
| 31 |
function status_msg($message, $class='check', $element='span') |
|
| 32 |
{
|
|
| 33 |
// returns a status message |
|
| 34 |
$msg = '<'.$element.' class="'.$class.'">'; |
|
| 35 |
$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>'; |
|
| 36 |
$msg .= $message.'</'.$element.'>'; |
|
| 37 |
echo $msg; |
|
| 38 |
} |
|
| 25 |
$oldVersion = 'Version '.WB_VERSION; |
|
| 26 |
$oldVersion .= (defined('WB_SP') ? ' '.WB_SP : '');
|
|
| 27 |
$oldVersion .= (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
|
|
| 28 |
$newVersion = 'Version '.VERSION; |
|
| 29 |
$newVersion .= (defined('SP') ? ' '.SP : '');
|
|
| 30 |
$newVersion .= (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
|
|
| 39 | 31 |
|
| 32 |
// set addition settings if not exists, otherwise upgrade will be breaks |
|
| 33 |
if(!defined('WB_SP')) { define('WB_SP',''); }
|
|
| 34 |
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
|
|
| 35 |
|
|
| 40 | 36 |
// database tables including in WB package |
| 41 |
$table_list = array (
|
|
| 37 |
$aTable = array (
|
|
| 42 | 38 |
'settings','groups','addons','pages','sections','search','users', |
| 43 | 39 |
'mod_captcha_control','mod_code','mod_droplets','mod_form_fields', |
| 44 | 40 |
'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link', |
| ... | ... | |
| 49 | 45 |
$OK = ' <span class="ok">OK</span> '; |
| 50 | 46 |
$FAIL = ' <span class="error">FAILED</span> '; |
| 51 | 47 |
$DEFAULT_THEME = 'wb_theme'; |
| 48 |
|
|
| 52 | 49 |
$stepID = 0; |
| 53 | 50 |
$dirRemove = array( |
| 54 | 51 |
/* |
| ... | ... | |
| 139 | 136 |
); |
| 140 | 137 |
} |
| 141 | 138 |
|
| 139 |
/* display a status message on the screen ************************************** |
|
| 140 |
* @param string $message: the message to show |
|
| 141 |
* @param string $class: kind of message as a css-class |
|
| 142 |
* @param string $element: witch HTML-tag use to cover the message |
|
| 143 |
* @return void |
|
| 144 |
*/ |
|
| 145 |
function status_msg($message, $class='check', $element='span') |
|
| 146 |
{
|
|
| 147 |
// returns a status message |
|
| 148 |
$msg = '<'.$element.' class="'.$class.'">'; |
|
| 149 |
$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>'; |
|
| 150 |
$msg .= $message.'</'.$element.'>'; |
|
| 151 |
echo $msg; |
|
| 152 |
} |
|
| 153 |
|
|
| 142 | 154 |
// analyze/check database tables |
| 143 | 155 |
function mysqlCheckTables( $dbName ) |
| 144 | 156 |
{
|
| 145 |
global $table_list;
|
|
| 157 |
global $aTable;
|
|
| 146 | 158 |
$table_prefix = TABLE_PREFIX; |
| 147 | 159 |
$sql = "SHOW TABLES FROM " . $dbName; |
| 148 | 160 |
$result = @mysql_query( $sql ); |
| 149 | 161 |
$data = array(); |
| 150 | 162 |
$x = 0; |
| 151 | 163 |
|
| 152 |
while( ( $row = @mysql_fetch_array( $result, MYSQL_NUM ) ) == true )
|
|
| 164 |
while( ( $row = mysql_fetch_array( $result, MYSQL_NUM ) ) == true ) |
|
| 153 | 165 |
{
|
| 154 | 166 |
$tmp = str_replace($table_prefix, '', $row[0]); |
| 155 | 167 |
|
| 156 |
if( stristr( $row[0], $table_prefix )&& in_array($tmp,$table_list) )
|
|
| 168 |
if( stristr( $row[0], $table_prefix )&& in_array($tmp,$aTable) )
|
|
| 157 | 169 |
{
|
| 158 | 170 |
$sql = "CHECK TABLE " . $dbName . '.' . $row[0]; |
| 159 |
$analyze = @mysql_query( $sql );
|
|
| 160 |
$rowFetch = @mysql_fetch_array( $analyze, MYSQL_ASSOC );
|
|
| 171 |
$analyze = mysql_query( $sql ); |
|
| 172 |
$rowFetch = mysql_fetch_array( $analyze, MYSQL_ASSOC ); |
|
| 161 | 173 |
$data[$x]['Op'] = $rowFetch["Op"]; |
| 162 | 174 |
$data[$x]['Msg_type'] = $rowFetch["Msg_type"]; |
| 163 | 175 |
$msgColor = '<span class="error">'; |
| ... | ... | |
| 175 | 187 |
// check existings tables for upgrade or install |
| 176 | 188 |
function check_wb_tables() |
| 177 | 189 |
{
|
| 178 |
global $database,$table_list;
|
|
| 190 |
global $database,$aTable;
|
|
| 179 | 191 |
|
| 180 | 192 |
// if prefix inludes '_' or '%' |
| 181 | 193 |
$search_for = addcslashes ( TABLE_PREFIX, '%_' ); |
| ... | ... | |
| 188 | 200 |
while ($data = $get_result->fetchRow()) |
| 189 | 201 |
{
|
| 190 | 202 |
$tmp = str_replace(TABLE_PREFIX, '', $data[0]); |
| 191 |
if(in_array($tmp,$table_list))
|
|
| 203 |
if(in_array($tmp,$aTable))
|
|
| 192 | 204 |
{
|
| 193 | 205 |
$all_tables[] = $tmp; |
| 194 | 206 |
} |
| ... | ... | |
| 290 | 302 |
exit(); |
| 291 | 303 |
} |
| 292 | 304 |
|
| 293 |
$oldVersion = 'Version '.WB_VERSION; |
|
| 294 |
$oldVersion .= (defined('WB_SP') ? ' '.WB_SP : '');
|
|
| 295 |
$oldVersion .= (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
|
|
| 296 |
$newVersion = 'Version '.VERSION; |
|
| 297 |
$newVersion .= (defined('SP') ? ' '.SP : '');
|
|
| 298 |
$newVersion .= (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
|
|
| 299 |
// set addition settings if not exists, otherwise upgrade will be breaks |
|
| 300 |
if(!defined('WB_SP')) { define('WB_SP',''); }
|
|
| 301 |
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
|
|
| 302 |
|
|
| 303 | 305 |
?> |
| 304 | 306 |
<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> |
| 305 | 307 |
|
| ... | ... | |
| 353 | 355 |
{
|
| 354 | 356 |
status_msg('<strong>WARNING:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
|
| 355 | 357 |
echo '<h4>Missing required tables. You can install them in backend->addons->modules->advanced. Then again run upgrade-script.php</h4>'; |
| 356 |
$result = array_diff ( $table_list, $all_tables );
|
|
| 358 |
$result = array_diff ( $aTable, $all_tables );
|
|
| 357 | 359 |
echo '<h4 class="warning"><br />'; |
| 358 | 360 |
while ( list ( $key, $val ) = each ( $result ) ) |
| 359 | 361 |
{
|
| ... | ... | |
| 448 | 450 |
|
| 449 | 451 |
echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />"); |
| 450 | 452 |
|
| 451 |
if(version_compare(WB_REVISION, '1671', '<'))
|
|
| 453 |
if(version_compare(WB_REVISION, '1675', '<'))
|
|
| 452 | 454 |
{
|
| 453 | 455 |
echo '<h3>Step '.(++$stepID).': Updating core tables</h3>'; |
| 454 | 456 |
|
| ... | ... | |
| 594 | 596 |
print '<br /><strong>Upgrade '.MEDIA_DIRECTORY.'/ protect files</strong>'." $FAIL!<br />"; |
| 595 | 597 |
print implode ('<br />',$array);
|
| 596 | 598 |
} |
| 599 |
|
|
| 597 | 600 |
/********************************************************** |
| 601 |
* upgrade pages folder index access files |
|
| 602 |
*/ |
|
| 603 |
echo '<h4>Upgrade /pages/ index.php access files</h4><br />'; |
|
| 604 |
///********************************************************** |
|
| 605 |
// * - Reformat/rebuild all existing access files |
|
| 606 |
// */ |
|
| 607 |
$msg[] = "All existing access files anew format"; |
|
| 608 |
$sql = 'SELECT `page_id`,`link`, `level` FROM `'.TABLE_PREFIX.'pages` ORDER BY `link`'; |
|
| 609 |
if (($res_pages = $database->query($sql))) |
|
| 610 |
{
|
|
| 611 |
$x = 0; |
|
| 612 |
while (($rec_page = $res_pages->fetchRow())) |
|
| 613 |
{
|
|
| 614 |
$filename = WB_PATH.PAGES_DIRECTORY.$rec_page['link'].PAGE_EXTENSION; |
|
| 615 |
$msg = create_access_file($filename, $rec_page['page_id'], $rec_page['level']); |
|
| 616 |
$x++; |
|
| 617 |
} |
|
| 618 |
$msg[] = '<strong>Number of the anew formatted access files: '.$x.'</strong><br />'; |
|
| 619 |
} |
|
| 620 |
|
|
| 621 |
print implode ('<br />',$msg);
|
|
| 622 |
|
|
| 623 |
/* |
|
| 624 |
if( sizeof( $msg ) ){
|
|
| 625 |
|
|
| 626 |
print '<br /><strong>Upgrade '.sizeof( $msg ).' /pages/ access files</strong>'." $OK<br />"; |
|
| 627 |
} else {
|
|
| 628 |
print '<br /><strong>Upgrade /pages/ access files</strong>'." $FAIL!<br />"; |
|
| 629 |
print implode ('<br />',$msg);
|
|
| 630 |
} |
|
| 631 |
*/ |
|
| 632 |
/********************************************************** |
|
| 598 | 633 |
* upgrade posts folder index protect files |
| 599 | 634 |
*/ |
| 600 | 635 |
$sPostsPath = WB_PATH.PAGES_DIRECTORY.'/posts'; |
| ... | ... | |
| 606 | 641 |
print '<br /><strong>Upgrade /posts/ protect files</strong>'." $FAIL!<br />"; |
| 607 | 642 |
print implode ('<br />',$array);
|
| 608 | 643 |
} |
| 644 |
|
|
| 609 | 645 |
/* ***************************************************************************** |
| 610 | 646 |
* - check for deprecated / never needed files |
| 611 | 647 |
*/ |
Also available in: Unified diff
! preparing new groups management and page settings
! upgrade-script insert or update page access files