Project

General

Profile

« Previous | Next » 

Revision 1484

Added by Dietmar over 13 years ago

move fixes 2.8.2 to 2.8.3
fixes will be shown in an extra readme
an package with the fixed files will be created
for all users who downloaded the 2.8.2 before 29 Jul-2011

View differences:

upgrade-script.php
18 18

  
19 19
@require_once('config.php');
20 20

  
21
// this function checks the basic configurations of an existing WB intallation
22
function status_msg($message, $class='check', $element='span') {
21
require_once(WB_PATH.'/framework/functions.php');
22
require_once(WB_PATH.'/framework/class.admin.php');
23
$admin = new admin('Addons', 'modules', false, false);
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
{
23 33
	// returns a status message
24
	echo '<'.$element .' class="' .$class .'">' .$message .'</' .$element.'>';
34
	$msg  = '<'.$element.' class="'.$class.'">';
35
	$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong><br />';
36
	$msg .= $message.'</'.$element.'>';
37
	echo $msg;
25 38
}
26 39

  
27 40
// database tables including in WB package
......
33 46
    'mod_output_filter','mod_wrapper','mod_wysiwyg'
34 47
);
35 48

  
49
$OK            = ' <span class="ok">OK</span> ';
50
$FAIL          = ' <span class="error">FAILED</span> ';
51
$DEFAULT_THEME = 'wb_theme';
52

  
53
$files2remove = array(
54

  
55
			'[ADMIN]/preferences/details.php',
56
			'[ADMIN]/preferences/email.php',
57
			'[ADMIN]/preferences/password.php',
58
/*
59
			'[TEMPLATE]/allcss/',
60
			'[TEMPLATE]/blank/',
61
			'[TEMPLATE]/round/',
62
			'[TEMPLATE]/simple/',
63
*/
64
		 );
65

  
66

  
36 67
// analyze/check database tables
37 68
function mysqlCheckTables( $dbName )
38 69
{
......
63 94
            $x++;
64 95
        }
65 96
    }
66

  
67

  
68

  
69

  
70 97
    return $data;
71 98
}
72 99

  
73

  
74 100
// check existings tables for upgrade or install
75 101
function check_wb_tables()
76 102
{
......
99 125
// check existing tables
100 126
$all_tables = check_wb_tables();
101 127

  
102
// only for array tests
103
function show_array($array=array())
104
{
105
    print '<pre>';
106
    print_r ($array);
107
    print '</pre>';
108
}
109

  
110
require_once(WB_PATH.'/framework/functions.php');
111
require_once(WB_PATH.'/framework/class.admin.php');
112
$admin = new admin('Addons', 'modules', false, false);
113 128
?>
114 129
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
115 130
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
......
218 233
	exit();
219 234
}
220 235
echo '<h2>Step 2: Updating database entries</h2>';
221
$OK   = '<span class="ok">OK</span>';
222
$FAIL = '<span class="error">FAILED</span>';
223 236

  
224 237
// function to add a var/value-pair into settings-table
225 238
function db_add_key_value($key, $value) {
......
267 280
 *  - Adding field default_theme to settings table
268 281
 */
269 282
echo "<br />Adding default_theme to settings table<br />";
283
db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
284
/*
270 285
$cfg = array(
271 286
	'default_theme' => 'wb_theme'
272 287
);
273

  
274 288
foreach($cfg as $key=>$value) {
275 289
	db_add_key_value($key, $value);
276 290
}
277

  
291
*/
278 292
/**********************************************************
279 293
 *  - install droplets
280 294
 */
......
351 365
echo "<br />Adding mediasettings to settings table<br />";
352 366
$cfg = array(
353 367
	'mediasettings' => '',
354
	'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx'
368
	'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js'
355 369
);
370
db_update_key_value('settings', 'rename_files_on_upload', $cfg['rename_files_on_upload']);
371

  
356 372
foreach($cfg as $key=>$value) {
357 373
	db_add_key_value($key, $value);
358 374
}
......
505 521
 * upgrade media folder index protect files
506 522
 */
507 523
$dir = (WB_PATH.MEDIA_DIRECTORY);
508
echo '<h4>Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
524
echo '<h4>Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files</h4><br />';
509 525
$array = rebuildFolderProtectFile($dir);
510 526
if( sizeof( $array ) ){
511
	print 'Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files'." $OK<br />";
527
	print '<br /><strong>Upgrade '.sizeof( $array ).' '.MEDIA_DIRECTORY.'/ protect files</strong>'." $OK<br />";
512 528
} else {
513
	print 'Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files'." $FAIL!<br />";
529
	print '<br /><strong>Upgrade '.MEDIA_DIRECTORY.'/ protect files</strong>'." $FAIL!<br />";
514 530
	print implode ('<br />',$array);
515 531
}
516 532

  
......
531 547
 *  - Set Version to new Version
532 548
 */
533 549
echo '<br />Update database version number to '.VERSION.' : ';
534
echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
550
// echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
551
db_update_key_value('settings', 'wb_version', VERSION);
535 552

  
553
/* *****************************************************************************
554
 * - check for deprecated / never needed files
555
 */
556
?>
557
<h2>Step 3: Remove deprecated and old files</h2>
558
<?php
559

  
560
	$searches = array(
561
		'[ADMIN]',
562
		'[MEDIA]',
563
		'[PAGES]'
564
	);
565
	$replacements = array(
566
		substr(ADMIN_PATH, strlen(WB_PATH)),
567
		MEDIA_DIRECTORY,
568
		PAGES_DIRECTORY
569
	);
570

  
571
	$msg = '';
572
	foreach( $files2remove as $file )
573
	{
574
		$file = str_replace($searches, $replacements, $file);
575
		$file = WB_PATH.'/'.$file;
576
		if( file_exists( $file ))
577
		{ // try to unlink file
578
			if(!unlink($file))
579
			{ // save in err-list, if failed
580
				$msg .= $file.'<br />';
581
			}
582
		}
583
	}
584

  
585
	if($msg != '')
586
	{
587
		$msg = 'Following files are deprecated, outdated or a security risk and
588
			    can not be removed automatically.<br /><br />Please delete them
589
				using FTP and restart upgrade-script!<br /><br />'.$msg;
590
        status_msg($msg, 'error warning', 'div');
591
		echo '<br /><br /></div></body></html>';
592
		exit();
593
	}
536 594
/**********************************************************
537 595
 *  - Reload all addons
538 596
 */
......
544 602
	while(false !== ($file = readdir($handle))) {
545 603
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
546 604
			load_module(WB_PATH.'/modules/'.$file );
547
			upgrade_module($file, true);
605
		   // 	upgrade_module($file, true);
548 606
		}
549 607
	}
550 608
	closedir($handle);
......
584 642

  
585 643
// require(WB_PATH.'/framework/initialize.php');
586 644

  
587
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', 'wb_theme'); }
645
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
588 646
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
589 647

  
590 648
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';

Also available in: Unified diff