Project

General

Profile

1
<?php
2
/**
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18

    
19
/**
20
 * 
21
 * 
22
 * @category     Core
23
 * @package      Core_package
24
 * @subpackage   upgrade-script
25
 * @author       Dietmar Wöllbrink <dietmar.woellbrink@websitebaker.org>
26
 * @author       Werner v.d.Decken <wkl@isteam.de>
27
 * @copyright    Werner v.d.Decken <wkl@isteam.de>
28
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
29
 * @version      0.0.1
30
 * @revision     $Revision: 1893 $
31
 * @link         $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/upgrade-script.php $
32
 * @lastmodified $Date: 2013-03-19 18:31:38 +0100 (Tue, 19 Mar 2013) $
33
 * @since        File available since 17.01.2013
34
 * @deprecated   
35
 * @description  xyz
36
 */
37
// Include config file
38
$config_file = realpath('config.php');
39
if(file_exists($config_file) && !defined('WB_URL'))
40
{
41
	require($config_file);
42

    
43
}
44
// solved wrong pages_directory value before creating access files
45
$sql  = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` '
46
      . 'WHERE `name`=\'pages_directory\'';
47
$sPagesDirectory = WbDatabase::getInstance()->get_one($sql);
48
$sTmp = trim($sPagesDirectory, '/');
49
$sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
50
if($sTmp != $sPagesDirectory) {
51
 $sql = 'UPDATE `'.TABLE_PREFIX.'settings` '
52
      . 'SET `value` = \''.$sTmpDir.'\' '
53
      . 'WHERE `name`=\'pages_directory\' ';
54
 WbDatabase::getInstance()->query($sql);
55
}
56
//require_once(WB_PATH.'/framework/class.admin.php');
57
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
58
require_once(WB_PATH.'/framework/functions.php');
59
// require_once(WB_PATH.'/framework/Database.php');
60
$admin = new admin('Addons', 'modules', false, false);
61

    
62
$oldVersion  = 'Version '.WB_VERSION;
63
$oldVersion .= (defined('WB_SP') ? WB_SP : '');
64
$oldRevision = (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
65
$newVersion  = 'Version '.VERSION;
66
$newVersion .= (defined('SP') ? SP : '');
67
$newRevision = (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
68

    
69
$bDebugModus = false;
70

    
71
// set addition settings if not exists, otherwise upgrade will be breaks
72
if(!defined('WB_SP')) { define('WB_SP',''); }
73
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
74
// database tables including in WB package
75
$aPackage = array (
76
    'settings','groups','addons','pages','sections','search','users',
77
    'mod_captcha_control','mod_jsadmin','mod_menu_link','mod_output_filter','mod_wrapper','mod_wysiwyg'
78
);
79

    
80
$OK            = ' <span class="ok">OK</span> ';
81
$FAIL          = ' <span class="error">FAILED</span> ';
82
$DEFAULT_THEME = 'wb_theme';
83

    
84
$stepID = 0;
85
$filesRemove = array();
86
$aFilesToRemove = array();
87
$dirRemove = array(
88
/*
89
			'[TEMPLATE]/allcss/',
90
			'[TEMPLATE]/blank/',
91
			'[TEMPLATE]/round/',
92
			'[TEMPLATE]/simple/',
93
*/
94
			'[ADMIN]/themes/',
95
		 );
96
//
97
	$filesRemove['0'] = array(
98

    
99
			'[ADMIN]/preferences/details.php',
100
			'[ADMIN]/preferences/email.php',
101
			'[ADMIN]/preferences/password.php',
102
			'[ADMIN]/pages/settings2.php',
103
			'[ADMIN]/users/users.php',
104
			'[ADMIN]/groups/add.php',
105
			'[ADMIN]/groups/groups.php',
106
			'[ADMIN]/groups/save.php',
107
			'[ADMIN]/skel/themes/htt/groups.htt',
108

    
109
			'[FRAMEWORK]/class.msg_queue.php',
110
			'[FRAMEWORK]/class.logfile.php',
111
			'[MODULES]/droplets/js/mdcr.js',
112

    
113
		 );
114
	$aFilesToRemove = array_merge($filesRemove['0']);
115

    
116
// deleting files below only from less 2.8.4 stable
117
if(version_compare(WB_VERSION, '2.8.4', '<'))
118
{
119
	$filesRemove['1'] = array(
120

    
121
			'[TEMPLATE]/argos_theme/templates/access.htt',
122
			'[TEMPLATE]/argos_theme/templates/addons.htt',
123
			'[TEMPLATE]/argos_theme/templates/admintools.htt',
124
			'[TEMPLATE]/argos_theme/templates/error.htt',
125
			'[TEMPLATE]/argos_theme/templates/groups.htt',
126
			'[TEMPLATE]/argos_theme/templates/groups_form.htt',
127
			'[TEMPLATE]/argos_theme/templates/languages.htt',
128
			'[TEMPLATE]/argos_theme/templates/languages_details.htt',
129
			'[TEMPLATE]/argos_theme/templates/login.htt',
130
			'[TEMPLATE]/argos_theme/templates/login_forgot.htt',
131
			'[TEMPLATE]/argos_theme/templates/media.htt',
132
			'[TEMPLATE]/argos_theme/templates/media_browse.htt',
133
			'[TEMPLATE]/argos_theme/templates/media_rename.htt',
134
			'[TEMPLATE]/argos_theme/templates/modules.htt',
135
			'[TEMPLATE]/argos_theme/templates/modules_details.htt',
136
			'[TEMPLATE]/argos_theme/templates/pages.htt',
137
			'[TEMPLATE]/argos_theme/templates/pages_modify.htt',
138
			'[TEMPLATE]/argos_theme/templates/pages_sections.htt',
139
			'[TEMPLATE]/argos_theme/templates/pages_settings.htt',
140
			'[TEMPLATE]/argos_theme/templates/preferences.htt',
141
			'[TEMPLATE]/argos_theme/templates/setparameter.htt',
142
			'[TEMPLATE]/argos_theme/templates/settings.htt',
143
			'[TEMPLATE]/argos_theme/templates/start.htt',
144
			'[TEMPLATE]/argos_theme/templates/success.htt',
145
			'[TEMPLATE]/argos_theme/templates/templates.htt',
146
			'[TEMPLATE]/argos_theme/templates/templates_details.htt',
147
			'[TEMPLATE]/argos_theme/templates/users.htt',
148
			'[TEMPLATE]/argos_theme/templates/users_form.htt',
149

    
150
			'[TEMPLATE]/wb_theme/templates/access.htt',
151
			'[TEMPLATE]/wb_theme/templates/addons.htt',
152
			'[TEMPLATE]/wb_theme/templates/admintools.htt',
153
			'[TEMPLATE]/wb_theme/templates/error.htt',
154
			'[TEMPLATE]/wb_theme/templates/groups.htt',
155
			'[TEMPLATE]/wb_theme/templates/groups_form.htt',
156
			'[TEMPLATE]/wb_theme/templates/languages.htt',
157
			'[TEMPLATE]/wb_theme/templates/languages_details.htt',
158
			'[TEMPLATE]/wb_theme/templates/login.htt',
159
			'[TEMPLATE]/wb_theme/templates/login_forgot.htt',
160
			'[TEMPLATE]/wb_theme/templates/media.htt',
161
			'[TEMPLATE]/wb_theme/templates/media_browse.htt',
162
			'[TEMPLATE]/wb_theme/templates/media_rename.htt',
163
			'[TEMPLATE]/wb_theme/templates/modules.htt',
164
			'[TEMPLATE]/wb_theme/templates/modules_details.htt',
165
			'[TEMPLATE]/wb_theme/templates/pages.htt',
166
			'[TEMPLATE]/wb_theme/templates/pages_modify.htt',
167
			'[TEMPLATE]/wb_theme/templates/pages_sections.htt',
168
			'[TEMPLATE]/wb_theme/templates/pages_settings.htt',
169
			'[TEMPLATE]/wb_theme/templates/preferences.htt',
170
			'[TEMPLATE]/wb_theme/templates/setparameter.htt',
171
			'[TEMPLATE]/wb_theme/templates/settings.htt',
172
			'[TEMPLATE]/wb_theme/templates/start.htt',
173
			'[TEMPLATE]/wb_theme/templates/success.htt',
174
			'[TEMPLATE]/wb_theme/templates/templates.htt',
175
			'[TEMPLATE]/wb_theme/templates/templates_details.htt',
176
			'[TEMPLATE]/wb_theme/templates/users.htt',
177
			'[TEMPLATE]/wb_theme/templates/users_form.htt'
178
		 );
179

    
180
	$aFilesToRemove = array_merge($aFilesToRemove,$filesRemove['1']);
181

    
182
}
183
/* display a status message on the screen **************************************
184
 * @param string $message: the message to show
185
 * @param string $class:   kind of message as a css-class
186
 * @param string $element: witch HTML-tag use to cover the message
187
 * @return void
188
 */
189
function status_msg($message, $class='check', $element='div')
190
{
191
	// returns a status message
192
	$msg  = '<'.$element.' class="'.$class.'">';
193
	$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>';
194
	$msg .= $message.'</'.$element.'>';
195
	echo $msg;
196
}
197

    
198
/**
199
 * add_modify_field_in_database()
200
 *
201
 * @param mixed $sTable
202
 * @param mixed $sField
203
 * @param mixed $sDescription
204
 * @return
205
 */
206
function add_modify_field_in_database($sTable,$sField,$sDescription){
207
	global $OK,$FAIL,$bDebugModus;
208
	$database=WbDatabase::getInstance();
209
	$aDebugMessage = array();
210
	if(!$database->field_exists($sTable,$sField)) {
211
		$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>";
212
		$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
213
	} else {
214
		$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>";
215
		$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
216
	}
217
	if($bDebugModus) {
218
		echo implode(PHP_EOL,$aDebugMessage);
219
	}
220
return;
221
}
222

    
223
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
224
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
225
<head>
226
<title>Upgrade script</title>
227
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
228
<style type="text/css">
229
html { overflow-y: scroll; /* Force firefox to always show room for a vertical scrollbar */ }
230

    
231
body {
232
	margin:0;
233
	padding:0;
234
	border:0;
235
	background: #EBF7FC;
236
	color:#000;
237
	font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
238
	font-size: small;
239
	height:101%;
240
}
241

    
242
#container {
243
	min-width:48em;
244
    width: 70%;
245
	background: #A8BCCB url(<?php echo WB_URL; ?>/templates/wb_theme/images/background.png) repeat-x;
246
	border:1px solid #000;
247
	color:#000;
248
	margin:2em auto;
249
	padding:0 20px;
250
	min-height: 500px;
251
	text-align:left;
252
}
253
.page {
254
	width:100%;
255
    overflow: hidden;
256
}
257
.content {
258
    padding: 10px;
259
}
260
p { line-height:1.5em; }
261

    
262
form {
263
	display: inline-block;
264
	line-height: 20px;
265
	vertical-align: baseline;
266
}
267
input[type="submit"].restart {
268
	background-color: #FFDBDB;
269
	font-weight: bold;
270
}
271

    
272
h1,h2,h3,h4,h5,h6 {
273
	font-family: Verdana, Arial, Helvetica, sans-serif;
274
	color: #26527D;
275
	margin-top: 1.0em;
276
	margin-bottom: 0.1em;
277
}
278

    
279
h1 { font-size:150%; }
280
h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
281
h3 { font-size: 110%; font-weight: bold; }
282

    
283
textarea {
284
	width:100%;
285
	border: 2px groove #0F1D44;
286
	padding: 2px;
287
	color: #000;
288
	font-weight: normal;
289
}
290
.ok, .error { font-weight:bold; }
291
.ok { color:green; }
292
.error { color:red; }
293
.check { color:#555; }
294

    
295
span.ok,
296
span.error {
297
    margin-left: 0em;
298
}
299

    
300
.warning {
301
	background:#FFDBDB;
302
	padding:1em;
303
	margin-top:0.5em;
304
	border: 1px solid #DB0909;
305
}
306
.info {
307
	background:#C7F4C7;
308
	padding:1em;
309
	margin-top:0.5em;
310
	border: 1px solid #277A29;
311
}
312

    
313
</style>
314
</head>
315
<body>
316
<div id="container">
317
<div class="page">
318
<img src="<?php echo WB_URL; ?>/templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
319
<div class="content">
320
<h1>WebsiteBaker Upgrade</h1>
321
<?php
322
	if( version_compare( WB_VERSION, '2.7', '<' )) {
323
		status_msg('<strong>Warning:</strong><br />It is not possible to upgrade from WebsiteBaker Versions before 2.7.<br />For upgrading to version '.VERSION.' you must upgrade first to v.2.7 at least!!!', 'warning', 'div');
324
		echo '<br /><br />';
325
		echo "</div>
326
		</div>
327
		</div>
328
		</body>
329
		</html>
330
		";
331
		exit();
332
	}
333

    
334
?>
335
<p class="info">This script upgrades an existing WebsiteBaker <strong> <?php echo $oldRevision; ?></strong> installation to the <strong> <?php echo $newRevision ?> </strong>.<br />The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
336

    
337
<?php
338

    
339
/**
340
 * Check if disclaimer was accepted
341
 */
342
$bDebugModus = false;
343
$bDebugModus = ( (isset($_POST['debug_confirmed']) && $_POST['debug_confirmed'] == 'debug') ? true : false);
344
if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
345
<h2>Step 1: Backup your files</h2>
346
<h5 class="warning">It is highly recommended to <strong>create a manual backup</strong> of the entire <strong class="error"><?php echo  PAGES_DIRECTORY ?>/</strong> folder and the <strong>MySQL database</strong> before proceeding.</h5>
347
<p><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p>
348

    
349
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
350
<textarea cols="92" 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 <?php echo  PAGES_DIRECTORY ?>/ folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
351
<br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" />&nbsp;<strong>I confirm that a manual backup of the <?php echo  PAGES_DIRECTORY ?>/ folder and the MySQL database was created.</strong>
352
<br /><br /><input name="debug_confirmed" type="checkbox" value="debug" />&nbsp;<strong>Here you can get more details during running upgrade.</strong>
353
<br /><br /><input name="send" type="submit" value="Start upgrade script" />
354
</form>
355
<br />
356

    
357
<?php
358
	status_msg('<strong> Notice:</strong><br />You need to confirm that you have created a manual backup of the '.PAGES_DIRECTORY.'/ directory and the MySQL database before you can proceed.', 'warning', 'div');
359
	echo "<br /><br /></div>
360
	</div>
361
	</div>
362
	</body>
363
	</html>";
364
	exit();
365
}
366

    
367
/**********************************************************
368
 *  - check tables coming with WebsiteBaker
369
 */
370
	$aMissingTables = UpgradeHelper::existsAllTables($aPackage);
371
	if( sizeof($aMissingTables) == 0){
372
        echo '<h4 style="margin-left:0;">NOTICE: '.sizeof($aPackage).' total tables included in package are successful installed your database `'.$database->DbName.'` '.$OK.'</h4>';
373
    } else {
374
        status_msg('<strong>:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
375
        echo '<h4>Missing required tables. You can install them in backend->addons->modules.<br />';
376
        echo 'Or if you uploaded per FTP install possible by backend->addons->modules->advanced.<br />';
377
        echo 'First rename or delete the upgrade-script.php, so the script can\'t start automatically by backend<br />';
378
        echo 'After installing missing tables upload and run again upgrade-script.php<br /><br /></h4>';
379
        echo '<h4 class="warning">';
380
        echo 'Missing required tables.<br /><br />';
381
        echo 'TABLE `'.implode('` missing! '.$FAIL.'<br />TABLE `',$aMissingTables).'` missing! '.$FAIL;
382
        echo '<br /><br /></h4>';
383
        echo '<br /><br />';
384
        if(isset($_SERVER['SCRIPT_NAME'])) {
385
        	echo '<form action="'.$_SERVER['SCRIPT_NAME'].'/">';
386
        	echo '&nbsp;<input type="submit" value="Start upgrade again" />';
387
        	echo '</form>';
388
        }
389
        if(defined('ADMIN_URL')) {
390
        	echo '<form action="'.ADMIN_URL.'/index.php" method="post">';
391
        	echo '&nbsp;<input name="backend_send" type="submit" value="kick me to the Backend" />';
392
        	echo '</form>';
393
        }
394
        echo "<br /><br /></div>
395
        </div>
396
        </div>
397
        </body>
398
        </html>";
399

    
400
        exit();
401
    }
402

    
403
echo '<h3>Step '.(++$stepID).': Setting default_theme</h3>';
404
$aDebugMessage = array();
405
    /**********************************************************
406
     *  - Adding field default_theme to settings table
407
     */
408
    $aDebugMessage[] = '<div style="margin-left:2em;">';
409
    $aDebugMessage[] = "<br /><span><strong>Adding default_theme to settings table</strong></span>";
410
    // db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
411
    $cfg = array(
412
    	'default_theme' => defined('DEFAULT_THEME')&& (DEFAULT_THEME!='') ? DEFAULT_THEME : $DEFAULT_THEME
413
    );
414
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
415
    $aDebugMessage[] = '</div>';
416

    
417
if($bDebugModus) {
418
    echo implode(PHP_EOL,$aDebugMessage);
419
}
420
$aDebugMessage = array();
421
echo'<h3>Step '.(++$stepID).': Updating core table included in package</h3>';
422
    /**********************************************************
423
     *  - Adding field sec_anchor to settings table
424
     */
425
    echo '<div style="margin-left:2em;">';
426
    echo "<h4>Adding/updating entries on table settings</h4>";
427
    $aDebugMessage[] = "<span>Adding/updating sec_anchor to settings table</span>";
428
    $cfg = array(
429
    	'sec_anchor' => defined('SEC_ANCHOR')&& (SEC_ANCHOR!='') ? SEC_ANCHOR : 'section_'
430
    );
431
   $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
432

    
433
    /**********************************************************
434
     *  - Adding redirect timer to settings table
435
     */
436
    $aDebugMessage[] = "<span>Adding/updating redirect timer to settings table</span>";
437
    $cfg = array(
438
    	'redirect_timer' => defined('REDIRECT_TIMER')&& (REDIRECT_TIMER!='') ? REDIRECT_TIMER : '1500'
439
    );
440
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
441

    
442
    /**********************************************************
443
     *  - Adding default_time_formatr to settings table
444
     */
445
    $aDebugMessage[] = "<span>Adding/updating default_time_format to settings table</span>";
446
    $cfg = array(
447
    	'default_time_format' => defined('DEFAULT_TIME_FORMAT')&& (DEFAULT_TIME_FORMAT!='') ? DEFAULT_TIME_FORMAT : 'h:i A'
448
    );
449
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
450

    
451
    /**********************************************************
452
     *  - Adding rename_files_on_upload to settings table
453
     */
454
    $aDebugMessage[] = "<span>Adding/Updating rename_files_on_upload to settings table</span>";
455
    $cfg = array(
456
        'rename_files_on_upload' => (defined('RENAME_FILES_ON_UPLOAD')&& (RENAME_FILES_ON_UPLOAD!='') ? RENAME_FILES_ON_UPLOAD : 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js')
457
    );
458
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
459

    
460
    /**********************************************************
461
     *  - Adding mediasettings to settings table
462
     */
463
    $aDebugMessage[] = "<span>Adding/updating mediasettings to settings table</span>";
464
    $cfg = array(
465
    	'mediasettings' => (defined('MEDIASETTINGS')&& (MEDIASETTINGS!='') ? MEDIASETTINGS : ''),
466
    );
467

    
468
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
469

    
470
    /**********************************************************
471
     *  - Adding fingerprint_with_ip_octets to settings table
472
     */
473
    $aDebugMessage[] = "<span>Adding/updating fingerprint_with_ip_octets to settings table</span>";
474
    $cfg = array(
475
    	'fingerprint_with_ip_octets' => (defined('FINGERPRINT_WITH_IP_OCTETS') ? FINGERPRINT_WITH_IP_OCTETS : '2'),
476
    	'secure_form_module' => (defined('SECURE_FORM_MODULE') ? SECURE_FORM_MODULE : '')
477
    );
478

    
479
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
480

    
481
    /**********************************************************
482
     *  - Adding page_icon_dir to settings table
483
     */
484
    $aDebugMessage[] = "<span>Adding/updating page_icon_dir to settings table</span>";
485
    $cfg = array(
486
    	'page_icon_dir' => (defined('PAGE_ICON_DIR')&& (PAGE_ICON_DIR!='') ? PAGE_ICON_DIR : '/templates/*/title_images'),
487
    );
488

    
489
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
490
    /**********************************************************
491
     *  - Adding page_extended to settings table
492
     */
493
    $aDebugMessage[] = "<span>Adding/updating page_extendet to settings table</span>";
494
    $cfg = array(
495
    	'page_extendet' => (defined('PAGE_EXTENDET') ? PAGE_EXTENDET : 'true'),
496
    );
497

    
498
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
499

    
500
    /**********************************************************
501
     *  - Adding wbmail_signature to settings table
502
     */
503
    $aDebugMessage[] = "<span>Adding/updating wbmail_signature to settings table</span>";
504
    $cfg = array(
505
    	'wbmail_signature' => (defined('WBMAIL_SIGNATURE')&& (WBMAIL_SIGNATURE!='') ? WBMAIL_SIGNATURE : '')
506
    );
507

    
508
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
509

    
510
    /**********************************************************
511
     *  - Adding confirmed_registration to settings table
512
     */
513
    $aDebugMessage[] = "<span>Adding/updating confirmed_registration to settings table</span>";
514
    $cfg = array(
515
    	'confirmed_registration' => (defined('CONFIRMED_REGISTRATION') ? CONFIRMED_REGISTRATION : '0')
516
    );
517

    
518
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
519

    
520
    /**********************************************************
521
     *  - Adding dev_infos to settings table
522
     */
523
    $aDebugMessage[] = "<span>Adding/updating dev_infos to settings table</span>";
524
    $cfg = array(
525
    	'dev_infos' => (defined('DEV_INFOS') ? DEV_INFOS : 'false')
526
    );
527

    
528
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
529

    
530
if($bDebugModus) {
531
    echo implode(PHP_EOL,$aDebugMessage);
532
}
533
echo '</div>';
534

    
535
$aDebugMessage = array();
536
if(version_compare(WB_REVISION, REVISION, '<='))
537
{
538
    echo '<div style="margin-left:2em;">';
539
	/**********************************************************
540
	 *  - Update search no results database filed to create
541
	 *  valid XHTML if search is empty
542
	 */
543
	if (version_compare(WB_VERSION, '2.8', '<'))
544
	{
545
        echo "<h4>Adding/updating fields on table search</h4>";
546
	    echo "Updating database field `no_results` on search table: ";
547
	    $search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
548
	    $sql  = 'UPDATE `'.TABLE_PREFIX.'search` ';
549
		$sql .= 'SET `value`=\''.$search_no_results.'\' ';
550
		$sql .= 'WHERE `name`=\'no_results\'';
551
	    echo ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
552
	}
553

    
554
	echo "<h4>Adding/updating field on table mod_menu_link</h4>";
555
	/**********************************************************
556
     *  - Add field "redirect_type" to table "mod_menu_link"
557
     *  has to be moved later to upgrade.php in modul menu_link, because modul can be removed
558
     */
559
	$table_name = TABLE_PREFIX.'mod_menu_link';
560
	$field_name = 'redirect_type';
561
	$description = "INT NOT NULL DEFAULT '301' AFTER `target_page_id`";
562
	add_modify_field_in_database($table_name,$field_name,$description);
563

    
564
    if($bDebugModus) {
565
        echo implode(PHP_EOL,$aDebugMessage);
566
    }
567

    
568
    $aDebugMessage = array();
569
    echo "<h4>Adding/updating field on table pages</h4>";
570
	/**********************************************************
571
	 *  - Add field "page_trail" to table "pages"
572
	 */
573
	$table_name = TABLE_PREFIX.'pages';
574
	$field_name = 'page_trail';
575
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
576
	add_modify_field_in_database($table_name,$field_name,$description);
577

    
578
	/**********************************************************
579
     *  - Add field "page_icon" to table "pages"
580
     */
581
	$table_name = TABLE_PREFIX.'pages';
582
	$field_name = 'page_icon';
583
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `page_title`";
584
    add_modify_field_in_database($table_name,$field_name,$description);
585

    
586
	/**********************************************************
587
	 *  - Add field "page_code" to table "pages"
588
	 */
589
	$table_name = TABLE_PREFIX.'pages';
590
	$field_name = 'page_code';
591
	$description = "INT NOT NULL DEFAULT '0' AFTER `language`";
592
    add_modify_field_in_database($table_name,$field_name,$description);
593

    
594
	/**********************************************************
595
     *  - Add field "menu_icon_0" to table "pages"
596
     */
597
	$table_name = TABLE_PREFIX.'pages';
598
	$field_name = 'menu_icon_0';
599
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_title`";
600
    add_modify_field_in_database($table_name,$field_name,$description);
601

    
602
	/**********************************************************
603
	 *  - Add field "menu_icon_1" to table "pages"
604
     */
605
	$table_name = TABLE_PREFIX.'pages';
606
	$field_name = 'menu_icon_1';
607
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_0`";
608
    add_modify_field_in_database($table_name,$field_name,$description);
609

    
610
	/**********************************************************
611
	 *  - Add field "tooltip" to table "pages"
612
     */
613
	$table_name = TABLE_PREFIX.'pages';
614
	$field_name = 'tooltip';
615
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_1`";
616
    add_modify_field_in_database($table_name,$field_name,$description);
617

    
618
	/**********************************************************
619
	 *  - Add field "admin_groups" to table "pages"
620
     */
621
	$table_name = TABLE_PREFIX.'pages';
622
	$field_name = 'admin_groups';
623
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
624
    add_modify_field_in_database($table_name,$field_name,$description);
625

    
626
	/**********************************************************
627
	 *  - Add field "admin_users" to table "pages"
628
	 */
629
	$table_name = TABLE_PREFIX.'pages';
630
	$field_name = 'admin_users';
631
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
632
    add_modify_field_in_database($table_name,$field_name,$description);
633

    
634
	/**********************************************************
635
	 *  - Add field "viewing_groups" to table "pages"
636
	 */
637
	$table_name = TABLE_PREFIX.'pages';
638
	$field_name = 'viewing_groups';
639
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
640
//	echo "<span>Modify field viewing_groups to pages table</span>";
641
//	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
642
    add_modify_field_in_database($table_name,$field_name,$description);
643

    
644
	/**********************************************************
645
	 *  - Add field "viewing_users" to table "pages"
646
	 */
647
	$table_name = TABLE_PREFIX.'pages';
648
	$field_name = 'viewing_users';
649
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
650
    add_modify_field_in_database($table_name,$field_name,$description);
651

    
652
	/**********************************************************
653
     *  - Add field "custom01" to table "pages"
654
     */
655
	$table_name = TABLE_PREFIX.'pages';
656
	$field_name = 'custom01';
657
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
658
    add_modify_field_in_database($table_name,$field_name,$description);
659

    
660
	/**********************************************************
661
     *  - Add field "custom02" to table "pages"
662
     */
663
	$table_name = TABLE_PREFIX.'pages';
664
	$field_name = 'custom02';
665
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
666
    add_modify_field_in_database($table_name,$field_name,$description);
667

    
668
    if($bDebugModus) {
669
        echo implode(PHP_EOL,$aDebugMessage);
670
    }
671

    
672
	$aDebugMessage = array();
673
	/**********************************************************
674
     * modify wrong strucre on table sections
675
     * wrong structure let crash wb
676
     */
677
	echo "<h4>Change field structure on table sections</h4>";
678
	$table_name = TABLE_PREFIX.'sections';
679
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
680
	$aDebugMessage[] = "<span>Modify field module on sections table</span>";
681
	$aDebugMessage[] = ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
682
	$aDebugMessage[] = "<span>Modify field block on sections table</span>";
683
	$description = "int(11) NOT NULL DEFAULT '1'";
684
	$aDebugMessage[] = ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
685
	$description = "int(11) NOT NULL DEFAULT '0'";
686
	$aDebugMessage[] = "<span>Modify field publ_start on sections table</span>";
687
	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
688
	$aDebugMessage[] = "<span>Modify field publ_end on sections table</span>";
689
	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
690

    
691
    if($bDebugModus) {
692
        echo implode(PHP_EOL,$aDebugMessage);
693
    }
694
    echo '</div>';
695
}
696

    
697
if(version_compare(WB_REVISION, REVISION, '<='))
698
{
699
    $aDebugMessage = array();
700
    echo '<h3>Step '.(++$stepID).': Updating structure in table users/groups</h3>';
701
	/**********************************************************
702
	 * Modify Administrator on groups table
703
	 */
704
	echo '<div style="margin-left:2em;">';
705
	echo "<h4>Updating Administrator group permissions on table groups</h4>";
706
	$aDebugMessage[] = "<span>Modify Administrator on groups table</span>";
707
	$sModulePermissions = '';
708
	$sTemplatePermissions = '';
709
	$sSystemPermissions  = 'access,addons,admintools,admintools_view,groups,groups_add,groups_delete,groups_modify,groups_view,';
710
	$sSystemPermissions .= 'languages,languages_install,languages_uninstall,languages_view,media,media_create,media_delete,media_rename,media_upload,media_view,';
711
	$sSystemPermissions .= 'modules,modules_advanced,modules_install,modules_uninstall,modules_view,pages,pages_add,pages_add_l0,pages_delete,pages_intro,pages_modify,pages_settings,pages_view,';
712
	$sSystemPermissions .= 'preferences,preferences_view,settings,settings_advanced,settings_basic,settings_view,templates,templates_install,templates_uninstall,templates_view,users,users_add,users_delete,users_modify,users_view';
713

    
714
	$sql  = 'UPDATE `'.TABLE_PREFIX.'groups` ';
715
	$sql .= 'SET `name` = \'Administrators\', ';
716
	$sql .= '`system_permissions` = \''.$sSystemPermissions.'\', ';
717
	$sql .= '`module_permissions` = \''.$sModulePermissions.'\', ';
718
	$sql .= '`template_permissions` = \''.$sTemplatePermissions.'\' ';
719
	$sql .= 'WHERE `group_id` = \'1\' ';
720
    $aDebugMessage[] = ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
721
    if( ($admin->is_authenticated() == true) && ($admin->ami_group_member('1') ) ) {
722
        $_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $sSystemPermissions));
723
    }
724

    
725
    if($bDebugModus) {
726
        echo implode(PHP_EOL,$aDebugMessage);
727
    }
728
    echo '</div>';
729
    $aDebugMessage = array();
730
    /**********************************************************
731
	$aDebugMessage = array();
732
	/**********************************************************
733
 *   `confirm_code` VARCHAR(32) NOT NULL DEFAULT '',
734
 *   `confirm_timeout` INT(11) NOT NULL DEFAULT '0',
735
 */
736
	echo '<div style="margin-left:2em;">';
737
	echo "<h4>Change field structure on table users</h4>";
738
	$table_name = TABLE_PREFIX.'users';
739
	$field_name = 'confirm_code';
740
	$description = "VARCHAR( 32 ) NOT NULL DEFAULT '' AFTER `password` ";
741
    add_modify_field_in_database($table_name,$field_name,$description);
742

    
743
	$table_name = TABLE_PREFIX.'users';
744
	$field_name = 'confirm_timeout';
745
	$description = "INT(11) NOT NULL DEFAULT '0' AFTER `confirm_code` ";
746
    add_modify_field_in_database($table_name,$field_name,$description);
747

    
748
    if($bDebugModus) {
749
        echo implode(PHP_EOL,$aDebugMessage);
750
    }
751
    echo '</div>';
752

    
753
    $aDebugMessage = array();
754
   /**********************************************************
755
    * Updating group_id in table users
756
    */
757
	echo '<div style="margin-left:2em;">';
758
	echo "<h4>Updating users groups permissions on table groups</h4>";
759
        $aUsers = array();
760
		// Get existing values
761
        $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'users` ' ;
762
        $sql .= 'WHERE `user_id` != 1 ';
763
        if($oUser = $database->query($sql)){
764
            $iTotalUsers = $oUser->numRows();
765
            while($Users = $oUser->fetchRow(MYSQL_ASSOC)) {
766
                $aUsers[$Users['user_id']]['groups_id'] = $Users['groups_id'];
767
                $aUsers[$Users['user_id']]['display_name'] = $Users['display_name'];
768
            }
769
        } else {
770
            $aDebugMessage[] = $database->is_error()==false ? " $OK<br />" : " $FAIL!<br />";
771
        }
772
        foreach($aUsers AS $user_id => $value){
773
                // choose group_id from groups_id - workaround for still remaining calls to group_id (to be cleaned-up)
774
                $aGroups_id = explode(',', $aUsers[$user_id]['groups_id']);
775
                $groups_id = $aUsers[$user_id]['groups_id'];
776
                $group_id = 0;
777
                //if user is in administrator-group, get this group else just get the first one
778
                if($admin->is_group_match($aGroups_id,'1')) { $group_id = 1; $groups_id = '1'; } else { $group_id = intval($aGroups_id[0]); }
779
                $sMessage = "<span>Updating group_id ".$TEXT['DISPLAY_NAME']." " .$aUsers[$user_id]['display_name']."</span>";
780
                $sql  = 'UPDATE `'.TABLE_PREFIX.'users` ';
781
                $sql .= 'SET `group_id`  = '.$group_id.', ';
782
                $sql .=     '`groups_id` = \''.$groups_id.'\' ';
783
                $sql .= 'WHERE `user_id` = '.intval($user_id);
784
                if($oRes = $database->query($sql)){  }
785
                $aDebugMessage[] = $database->is_error()==false ? $sMessage." $OK<br />" : $sMessage." $FAIL!<br />";
786
        }
787
        unset($aUsers);
788
    $aDebugMessage[] = '</div>';
789

    
790
    if($bDebugModus) {
791
    // $aDebugMessage[] =
792
        echo implode(PHP_EOL,$aDebugMessage);
793
    }else {
794
        echo '<span><strong>'.$iTotalUsers.' users updating the groups</strong></span>'." $OK<br />";
795
        echo '</div>';
796
    }
797
}
798

    
799
$aDebugMessage = array();
800
echo '<h3>Step '.(++$stepID).': Updating access and protected files in folders</h3>';
801

    
802
echo '<div style="margin-left:2em;">';
803
    /**********************************************************
804
    * upgrade media directory index protect files
805
    */
806
    $dir = (WB_PATH.MEDIA_DIRECTORY);
807
    echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
808
    $aDebugMessage = rebuildFolderProtectFile($dir);
809
    if( sizeof( $aDebugMessage ) ){
810
    	echo '<span><strong>Upgrade '.sizeof( $aDebugMessage ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
811
    } else {
812
    	echo '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />";
813
    	echo implode ('<br />',$aDebugMessage);
814
    }
815

    
816
    $aDebugMessage = array();
817
    /**********************************************************
818
     * upgrade pages directory index access files
819
     */
820
	echo '<h4>Upgrade pages directory '.PAGES_DIRECTORY.'/  protect and access files</h4>';
821

    
822
    /**********************************************************
823
     *  - Reformat/rebuild all existing access files
824
     */
825
    $sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
826
    $msg = rebuild_all_accessfiles();
827

    
828
	echo '<strong>'.implode ('<br />',$msg).'</strong>';
829
    echo '</div>';
830

    
831
	/* *****************************************************************************
832
	 * - check for deprecated / never needed files
833
	 */
834
	$iLoaded = sizeof($aFilesToRemove);
835
	if($iLoaded) {
836
		echo '<h3>Step '.(++$stepID).': Remove deprecated and outdated files</h3>';
837
		$iFailed = 0;
838
		$iFound = 0;
839
		$searches = array(
840
			'[ADMIN]',
841
			'[MEDIA]',
842
			'[PAGES]',
843
			'[FRAMEWORK]',
844
			'[MODULES]',
845
			'[TEMPLATE]'
846
		);
847
		$replacements = array(
848
			'/'.substr(ADMIN_PATH, strlen(WB_PATH)+1),
849
			MEDIA_DIRECTORY,
850
			PAGES_DIRECTORY,
851
			'/framework',
852
			'/modules',
853
			'/templates'
854
		);
855

    
856
		$msg = '';
857
		echo '<div style="margin-left:2em;">';
858
		echo '<h4>Search '.$iLoaded.' deprecated and outdated files</h4>';
859
		foreach( $aFilesToRemove as $file )
860
		{
861
			$file = str_replace($searches, $replacements, $file);
862
			if( is_writable(WB_PATH.'/'.$file) ) {
863
				$iFound++;
864
				// try to unlink file
865
				if(!unlink(WB_PATH.$file)) {
866
					$iFailed++;
867
				}
868
			}
869
			if( is_readable(WB_PATH.'/'.$file) ) {
870
				// save in err-list, if failed
871
				$msg .= $file.'<br />';
872
			}
873
		}
874
		$iRemove = $iFound-$iFailed;
875
		echo '<strong>Remove '.$iRemove.' from '.$iFound.' founded</strong> ';
876
		echo ($iFailed == 0) ? $OK : $FAIL;
877
		echo '</div>';
878

    
879
		if($msg != '')
880
		{
881
			$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
882
				    can not be removed automatically.<br /><br />Please delete them
883
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
884
			status_msg($msg, 'error warning', 'div');
885
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
886

    
887
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
888
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
889
			echo '</form>';
890
			echo "<br /><br /></div>
891
			</div>
892
			</div>
893
			</body>
894
			</html>";
895
			exit;
896
		}
897
	}
898

    
899

    
900
	/**********************************************************
901
	 * - check for deprecated / never needed files
902
	 */
903
	$iLoaded = sizeof($dirRemove);
904
	if($iLoaded) {
905
		echo '<h3>Step  '.(++$stepID).': Remove deprecated and outdated folders</h3>';
906
		$iFailed = 0;
907
		$iFound = 0;
908
		$searches = array(
909
			'[ADMIN]',
910
			'[MEDIA]',
911
			'[PAGES]',
912
			'[TEMPLATE]'
913
		);
914
		$replacements = array(
915
			substr(ADMIN_PATH, strlen(WB_PATH)+1),
916
			MEDIA_DIRECTORY,
917
			PAGES_DIRECTORY,
918
			'/templates',
919
		);
920
		$msg = '';
921
		echo '<div style="margin-left:2em;">';
922
		echo '<h4>Search '.$iLoaded.' deprecated and outdated folders</h4>';
923
		foreach( $dirRemove as $dir ) {
924
			$dir = str_replace($searches, $replacements, $dir);
925
			$dir = WB_PATH.'/'.$dir;
926
			if( is_dir( $dir )) {
927
				$iFound++;
928
			// try to delete dir
929
				if(!is_writable( $dir ) || !rm_full_dir($dir)) {
930
				// save in err-list, if failed
931
					$iFailed++;
932
				}
933
			}
934
			if( is_readable(WB_PATH.'/'.$dir) ) {
935
				$msg .= str_replace(WB_PATH,'',$dir).'<br />';
936
			}
937
		}
938
		
939
		$iRemove = $iFound-$iFailed;
940
		echo '<strong>Remove '.$iRemove.' from '.$iFound.' founded</strong> ';
941
		echo ($iFailed == 0) ? $OK : $FAIL;
942
		echo '</div>';
943

    
944
		if($msg != '') {
945
			$msg = '<br /><br />Following directories are deprecated, outdated or a security risk and
946
					can not be removed automatically.<br /><br />Please delete them
947
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
948
			status_msg($msg, 'error warning', 'div');
949
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
950
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
951
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
952
			echo '</form>';
953
			echo "<br /><br /></div>
954
			</div>
955
			</div>
956
			</body>
957
			</html>";
958
			exit;
959
		}
960

    
961

    
962
	}
963

    
964
	/**********************************************************
965
	 * upgrade modules if newer version is available
966
	 * $aModuleList list of proofed modules
967
	 */
968
	$aModuleList = array('wysiwyg','form','code','captcha_control','output_filter');
969
	if(sizeof($aModuleList)) 
970
	{
971
		echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
972
		foreach($aModuleList as $sModul) {
973
			if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
974
				$currModulVersion = get_modul_version ($sModul, false);
975
				$newModulVersion =  get_modul_version ($sModul, true);
976
				if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
977
					echo '<div style="margin-left:2em;">';
978
					echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
979
					require(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
980
					echo '</div>';
981
				}
982
			}
983
		}
984
	}
985

    
986
	/**********************************************************
987
	 * Reformat/rebuild all existing moules access files
988
	 * $aModuleList list of modules
989
	 */
990
	$aModuleList = array('bakery','topics','news');
991
	if(sizeof($aModuleList)) 
992
	{
993
		echo '<h3>Step '.(++$stepID).': Create/Reorg Accessfiles from modules</h3>';
994
		foreach($aModuleList as $sModul) {
995
			$aReturnMsg = array();
996
			$sModulReorg = 'm_'.$sModul.'_Reorg';
997
			if(class_exists($sModulReorg)) {
998
				$sModulVersion =  get_modul_version ($sModul, true);
999
				echo '<div style="margin-left:2em;">';
1000
				echo '<h4>'.'Create/Reorg Accesfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>';
1001
				$oReorg = new $sModulReorg();
1002
				$aReturnMsg = $oReorg->execute(); // show details
1003
				if(is_array($aReturnMsg)) {
1004
					foreach($aReturnMsg as $title) {
1005
					echo '<strong>'.$title.'</strong><br />';
1006
					}
1007
				}
1008
				echo '</div>';
1009
			}
1010
		}
1011
	}
1012
/**********************************************************
1013
 *  - Reload all addons
1014
 */
1015

    
1016
	echo '<h3>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h3><br />';
1017
	echo '<div style="margin-left:2em;">';
1018
	$iFound = 0;
1019
	$iLoaded = 0;
1020
	////delete modules
1021
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
1022
	// Load all modules
1023
	if( ($handle = opendir(WB_PATH.'/modules/')) ) {
1024
		while(false !== ($file = readdir($handle))) {
1025
			if($file != '' && substr($file, 0, 1) != '.' && is_dir(WB_PATH.'/modules/'.$file) ) {
1026
				$iFound++;
1027
				$iLoaded = load_module(WB_PATH.'/modules/'.$file ) ? $iLoaded+1 : $iLoaded;
1028
// 	upgrade_module($file, true);
1029
			}
1030
		}
1031
		closedir($handle);
1032
	}
1033
	echo '<strong><span>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
1034

    
1035
	$iFound = 0;
1036
	$iLoaded = 0;
1037
	////delete templates
1038
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
1039
	// Load all templates
1040
	if( ($handle = opendir(WB_PATH.'/templates/')) ) {
1041
		while(false !== ($file = readdir($handle))) {
1042
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
1043

    
1044
				$iFound++;
1045
				$iLoaded = (load_template(WB_PATH.'/templates/'.$file)==true) ? $iLoaded+1 : $iLoaded;
1046

    
1047
			}
1048
		}
1049
		closedir($handle);
1050
	}
1051
	echo '<strong><span>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
1052

    
1053
	$iFound = 0;
1054
	$iLoaded = 0;
1055
	////delete languages
1056
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
1057
	// Load all languages
1058
	if( ($handle = opendir(WB_PATH.'/languages/')) ) {
1059
		while(false !== ($file = readdir($handle))) {
1060
			if($file != '' AND (preg_match('#^([A-Z]{2}.php)#', basename($file)))) {
1061
				$iFound++;
1062
				$iLoaded = load_language(WB_PATH.'/languages/'.$file) ? $iLoaded+1 : $iLoaded;
1063
			}
1064
		}
1065
		closedir($handle);
1066
	}
1067
	echo '<strong><span>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
1068
	echo '</div>';
1069

    
1070
/**********************************************************
1071
 *  - install new droplets
1072
	$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
1073
	echo $drops;
1074
	$file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
1075
	require_once (WB_PATH."/modules/droplets/".$file_name);
1076
********************************************************** */
1077

    
1078
/**********************************************************
1079
 *  - End of upgrade script
1080
 */
1081
	if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
1082
	if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
1083
/**********************************************************
1084
 *  - Set Version to new Version
1085
 */
1086
echo '<h3>Step '.(++$stepID).': Update database version number </h3>';
1087
echo '<div style="margin-left:2em;">';
1088

    
1089
$cfg = array(
1090
	'wb_version' => VERSION,
1091
	'wb_revision' => REVISION,
1092
	'wb_sp' => SP
1093
);
1094
echo '<br /><span><strong>Set WebsiteBaker version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : </strong></span>';
1095
echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
1096
echo '</div>';
1097

    
1098
echo '<p style="font-size:140%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
1099
status_msg('<strong>:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
1100
// show buttons to go to the backend or frontend
1101
echo '<br />';
1102

    
1103
if(defined('WB_URL')) {
1104
	echo '<form action="'.WB_URL.'/">';
1105
	echo '&nbsp;<input type="submit" value="kick me to the Frontend" />';
1106
	echo '</form>';
1107
}
1108
if(defined('ADMIN_URL')) {
1109
	echo '<form action="'.ADMIN_URL.'/">';
1110
	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
1111
	echo '</form>';
1112
}
1113

    
1114
echo "<br /><br /></div>
1115
</div>
1116
</div>
1117
</body>
1118
</html>
1119
";
1120
exit();
(6-6/6)