Project

General

Profile

1 1457 Luisehahne
<?php
2
/**
3 1866 Luisehahne
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 1457 Luisehahne
 *
5 1866 Luisehahne
 * 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 1457 Luisehahne
 *
10 1866 Luisehahne
 * 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 1457 Luisehahne
 */
18
19 1866 Luisehahne
/**
20
 *
21
 *
22 1875 Luisehahne
 * @category     Core
23 1935 darkviper
 * @package      Core_service
24 1875 Luisehahne
 * @subpackage   upgrade-script
25
 * @author       Dietmar Wöllbrink <dietmar.woellbrink@websitebaker.org>
26 1866 Luisehahne
 * @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$
31
 * @link         $HeadURL$
32
 * @lastmodified $Date$
33
 * @since        File available since 17.01.2013
34
 * @deprecated
35
 * @description  xyz
36
 */
37 1785 Luisehahne
// Include config file
38
$config_file = realpath('config.php');
39
if(file_exists($config_file) && !defined('WB_URL'))
40
{
41 1813 Luisehahne
	require($config_file);
42 1870 Luisehahne
43 1785 Luisehahne
}
44 1920 Luisehahne
//require_once(WB_PATH.'/framework/class.admin.php');
45
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
46
$admin = new admin('Addons', 'modules', false, false);
47
48 1870 Luisehahne
// solved wrong pages_directory value before creating access files
49 1871 Luisehahne
$sql  = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` '
50
      . 'WHERE `name`=\'pages_directory\'';
51
$sPagesDirectory = WbDatabase::getInstance()->get_one($sql);
52
$sTmp = trim($sPagesDirectory, '/');
53
$sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
54
if($sTmp != $sPagesDirectory) {
55
 $sql = 'UPDATE `'.TABLE_PREFIX.'settings` '
56
      . 'SET `value` = \''.$sTmpDir.'\' '
57
      . 'WHERE `name`=\'pages_directory\' ';
58
 WbDatabase::getInstance()->query($sql);
59 1870 Luisehahne
}
60 1484 Luisehahne
require_once(WB_PATH.'/framework/functions.php');
61 1684 Luisehahne
// require_once(WB_PATH.'/framework/Database.php');
62 1484 Luisehahne
63 1677 Luisehahne
$oldVersion  = 'Version '.WB_VERSION;
64 1689 darkviper
$oldVersion .= (defined('WB_SP') ? WB_SP : '');
65 1688 Luisehahne
$oldRevision = (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
66 1677 Luisehahne
$newVersion  = 'Version '.VERSION;
67 1689 darkviper
$newVersion .= (defined('SP') ? SP : '');
68 1688 Luisehahne
$newRevision = (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
69 1457 Luisehahne
70 1765 Luisehahne
$bDebugModus = false;
71
72 1677 Luisehahne
// set addition settings if not exists, otherwise upgrade will be breaks
73
if(!defined('WB_SP')) { define('WB_SP',''); }
74
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
75 1457 Luisehahne
// database tables including in WB package
76 1765 Luisehahne
$aPackage = array (
77 1457 Luisehahne
    'settings','groups','addons','pages','sections','search','users',
78 1889 Luisehahne
    'mod_captcha_control','mod_jsadmin','mod_menu_link','mod_output_filter','mod_wrapper','mod_wysiwyg'
79 1457 Luisehahne
);
80
81 1484 Luisehahne
$OK            = ' <span class="ok">OK</span> ';
82
$FAIL          = ' <span class="error">FAILED</span> ';
83
$DEFAULT_THEME = 'wb_theme';
84 1677 Luisehahne
85 1671 Luisehahne
$stepID = 0;
86 1883 Luisehahne
$filesRemove = array();
87 1765 Luisehahne
$aFilesToRemove = array();
88 1532 Luisehahne
$dirRemove = array(
89 1484 Luisehahne
/*
90
			'[TEMPLATE]/allcss/',
91
			'[TEMPLATE]/blank/',
92
			'[TEMPLATE]/round/',
93
			'[TEMPLATE]/simple/',
94
*/
95 1641 Luisehahne
			'[ADMIN]/themes/',
96 1484 Luisehahne
		 );
97 1866 Luisehahne
//
98
	$filesRemove['0'] = array(
99 1484 Luisehahne
100 1525 Luisehahne
			'[ADMIN]/preferences/details.php',
101
			'[ADMIN]/preferences/email.php',
102 1666 Luisehahne
			'[ADMIN]/preferences/password.php',
103 1684 Luisehahne
			'[ADMIN]/pages/settings2.php',
104 1813 Luisehahne
			'[ADMIN]/users/users.php',
105 1883 Luisehahne
			'[ADMIN]/groups/add.php',
106
			'[ADMIN]/groups/groups.php',
107
			'[ADMIN]/groups/save.php',
108 1866 Luisehahne
			'[ADMIN]/skel/themes/htt/groups.htt',
109 1525 Luisehahne
110 1684 Luisehahne
			'[FRAMEWORK]/class.msg_queue.php',
111 1689 darkviper
			'[FRAMEWORK]/class.logfile.php',
112 1945 darkviper
			'[FRAMEWORK]/PasswordHash.php',
113 1785 Luisehahne
			'[MODULES]/droplets/js/mdcr.js',
114 1684 Luisehahne
115 1532 Luisehahne
		 );
116 1866 Luisehahne
	$aFilesToRemove = array_merge($filesRemove['0']);
117 1532 Luisehahne
118 1866 Luisehahne
// deleting files below only from less 2.8.4 stable
119 1883 Luisehahne
if(version_compare(WB_VERSION, '2.8.4', '<'))
120 1866 Luisehahne
{
121 1671 Luisehahne
	$filesRemove['1'] = array(
122 1532 Luisehahne
123 1529 Luisehahne
			'[TEMPLATE]/argos_theme/templates/access.htt',
124
			'[TEMPLATE]/argos_theme/templates/addons.htt',
125
			'[TEMPLATE]/argos_theme/templates/admintools.htt',
126
			'[TEMPLATE]/argos_theme/templates/error.htt',
127
			'[TEMPLATE]/argos_theme/templates/groups.htt',
128
			'[TEMPLATE]/argos_theme/templates/groups_form.htt',
129
			'[TEMPLATE]/argos_theme/templates/languages.htt',
130
			'[TEMPLATE]/argos_theme/templates/languages_details.htt',
131
			'[TEMPLATE]/argos_theme/templates/login.htt',
132
			'[TEMPLATE]/argos_theme/templates/login_forgot.htt',
133
			'[TEMPLATE]/argos_theme/templates/media.htt',
134
			'[TEMPLATE]/argos_theme/templates/media_browse.htt',
135
			'[TEMPLATE]/argos_theme/templates/media_rename.htt',
136
			'[TEMPLATE]/argos_theme/templates/modules.htt',
137
			'[TEMPLATE]/argos_theme/templates/modules_details.htt',
138
			'[TEMPLATE]/argos_theme/templates/pages.htt',
139
			'[TEMPLATE]/argos_theme/templates/pages_modify.htt',
140
			'[TEMPLATE]/argos_theme/templates/pages_sections.htt',
141
			'[TEMPLATE]/argos_theme/templates/pages_settings.htt',
142
			'[TEMPLATE]/argos_theme/templates/preferences.htt',
143
			'[TEMPLATE]/argos_theme/templates/setparameter.htt',
144
			'[TEMPLATE]/argos_theme/templates/settings.htt',
145
			'[TEMPLATE]/argos_theme/templates/start.htt',
146
			'[TEMPLATE]/argos_theme/templates/success.htt',
147
			'[TEMPLATE]/argos_theme/templates/templates.htt',
148
			'[TEMPLATE]/argos_theme/templates/templates_details.htt',
149
			'[TEMPLATE]/argos_theme/templates/users.htt',
150
			'[TEMPLATE]/argos_theme/templates/users_form.htt',
151
152
			'[TEMPLATE]/wb_theme/templates/access.htt',
153
			'[TEMPLATE]/wb_theme/templates/addons.htt',
154
			'[TEMPLATE]/wb_theme/templates/admintools.htt',
155
			'[TEMPLATE]/wb_theme/templates/error.htt',
156
			'[TEMPLATE]/wb_theme/templates/groups.htt',
157
			'[TEMPLATE]/wb_theme/templates/groups_form.htt',
158
			'[TEMPLATE]/wb_theme/templates/languages.htt',
159
			'[TEMPLATE]/wb_theme/templates/languages_details.htt',
160
			'[TEMPLATE]/wb_theme/templates/login.htt',
161
			'[TEMPLATE]/wb_theme/templates/login_forgot.htt',
162
			'[TEMPLATE]/wb_theme/templates/media.htt',
163
			'[TEMPLATE]/wb_theme/templates/media_browse.htt',
164
			'[TEMPLATE]/wb_theme/templates/media_rename.htt',
165
			'[TEMPLATE]/wb_theme/templates/modules.htt',
166
			'[TEMPLATE]/wb_theme/templates/modules_details.htt',
167
			'[TEMPLATE]/wb_theme/templates/pages.htt',
168
			'[TEMPLATE]/wb_theme/templates/pages_modify.htt',
169
			'[TEMPLATE]/wb_theme/templates/pages_sections.htt',
170
			'[TEMPLATE]/wb_theme/templates/pages_settings.htt',
171
			'[TEMPLATE]/wb_theme/templates/preferences.htt',
172
			'[TEMPLATE]/wb_theme/templates/setparameter.htt',
173
			'[TEMPLATE]/wb_theme/templates/settings.htt',
174
			'[TEMPLATE]/wb_theme/templates/start.htt',
175
			'[TEMPLATE]/wb_theme/templates/success.htt',
176
			'[TEMPLATE]/wb_theme/templates/templates.htt',
177
			'[TEMPLATE]/wb_theme/templates/templates_details.htt',
178
			'[TEMPLATE]/wb_theme/templates/users.htt',
179 1866 Luisehahne
			'[TEMPLATE]/wb_theme/templates/users_form.htt'
180 1525 Luisehahne
		 );
181 1765 Luisehahne
182 1866 Luisehahne
	$aFilesToRemove = array_merge($aFilesToRemove,$filesRemove['1']);
183 1765 Luisehahne
184 1671 Luisehahne
}
185 1677 Luisehahne
/* display a status message on the screen **************************************
186
 * @param string $message: the message to show
187
 * @param string $class:   kind of message as a css-class
188
 * @param string $element: witch HTML-tag use to cover the message
189
 * @return void
190
 */
191 1765 Luisehahne
function status_msg($message, $class='check', $element='div')
192 1677 Luisehahne
{
193
	// returns a status message
194
	$msg  = '<'.$element.' class="'.$class.'">';
195
	$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>';
196
	$msg .= $message.'</'.$element.'>';
197
	echo $msg;
198
}
199
200 1772 Luisehahne
/**
201
 * add_modify_field_in_database()
202
 *
203
 * @param mixed $sTable
204
 * @param mixed $sField
205
 * @param mixed $sDescription
206
 * @return
207
 */
208
function add_modify_field_in_database($sTable,$sField,$sDescription){
209 1889 Luisehahne
	global $OK,$FAIL,$bDebugModus;
210
	$database=WbDatabase::getInstance();
211 1866 Luisehahne
	$aDebugMessage = array();
212 1772 Luisehahne
	if(!$database->field_exists($sTable,$sField)) {
213
		$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>";
214
		$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
215
	} else {
216
		$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>";
217
		$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
218
	}
219 1866 Luisehahne
	if($bDebugModus) {
220
		echo implode(PHP_EOL,$aDebugMessage);
221
	}
222
return;
223 1457 Luisehahne
}
224
225 1671 Luisehahne
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
226 1457 Luisehahne
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
227
<head>
228
<title>Upgrade script</title>
229
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
230
<style type="text/css">
231 1684 Luisehahne
html { overflow-y: scroll; /* Force firefox to always show room for a vertical scrollbar */ }
232 1457 Luisehahne
233
body {
234
	margin:0;
235
	padding:0;
236
	border:0;
237
	background: #EBF7FC;
238
	color:#000;
239
	font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
240
	font-size: small;
241
	height:101%;
242
}
243
244
#container {
245 1765 Luisehahne
	min-width:48em;
246
    width: 70%;
247 1866 Luisehahne
	background: #A8BCCB url(<?php echo WB_URL; ?>/templates/wb_theme/images/background.png) repeat-x;
248 1457 Luisehahne
	border:1px solid #000;
249
	color:#000;
250
	margin:2em auto;
251 1765 Luisehahne
	padding:0 20px;
252 1457 Luisehahne
	min-height: 500px;
253
	text-align:left;
254
}
255 1765 Luisehahne
.page {
256
	width:100%;
257
    overflow: hidden;
258
}
259
.content {
260
    padding: 10px;
261
}
262 1457 Luisehahne
p { line-height:1.5em; }
263
264 1532 Luisehahne
form {
265
	display: inline-block;
266
	line-height: 20px;
267
	vertical-align: baseline;
268
}
269
input[type="submit"].restart {
270
	background-color: #FFDBDB;
271
	font-weight: bold;
272
}
273
274 1457 Luisehahne
h1,h2,h3,h4,h5,h6 {
275
	font-family: Verdana, Arial, Helvetica, sans-serif;
276 1765 Luisehahne
	color: #26527D;
277 1457 Luisehahne
	margin-top: 1.0em;
278
	margin-bottom: 0.1em;
279
}
280
281
h1 { font-size:150%; }
282
h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
283 1765 Luisehahne
h3 { font-size: 110%; font-weight: bold; }
284 1457 Luisehahne
285 1765 Luisehahne
textarea {
286
	width:100%;
287 1866 Luisehahne
	border: 2px groove #0F1D44;
288
	padding: 2px;
289
	color: #000;
290
	font-weight: normal;
291 1765 Luisehahne
}
292 1457 Luisehahne
.ok, .error { font-weight:bold; }
293
.ok { color:green; }
294
.error { color:red; }
295
.check { color:#555; }
296
297 1765 Luisehahne
span.ok,
298
span.error {
299
    margin-left: 0em;
300
}
301
302 1457 Luisehahne
.warning {
303
	background:#FFDBDB;
304 1765 Luisehahne
	padding:1em;
305 1457 Luisehahne
	margin-top:0.5em;
306 1765 Luisehahne
	border: 1px solid #DB0909;
307 1457 Luisehahne
}
308
.info {
309 1765 Luisehahne
	background:#C7F4C7;
310
	padding:1em;
311 1457 Luisehahne
	margin-top:0.5em;
312 1765 Luisehahne
	border: 1px solid #277A29;
313 1457 Luisehahne
}
314
315
</style>
316
</head>
317
<body>
318
<div id="container">
319 1765 Luisehahne
<div class="page">
320 1866 Luisehahne
<img src="<?php echo WB_URL; ?>/templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
321 1765 Luisehahne
<div class="content">
322 1457 Luisehahne
<h1>WebsiteBaker Upgrade</h1>
323
<?php
324 1525 Luisehahne
	if( version_compare( WB_VERSION, '2.7', '<' )) {
325 1920 Luisehahne
		status_msg('<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');
326 1457 Luisehahne
		echo "</div>
327 1866 Luisehahne
		</div>
328
		</div>
329 1457 Luisehahne
		</body>
330
		</html>
331
		";
332
		exit();
333
	}
334 1920 Luisehahne
if($admin->get_user_id()!=1){
335
	status_msg('<br /><h3>WebsiteBaker upgrading is not possible!<br />Before upgrading to Revision '.REVISION.' you have to login as System-Administrator!</h3>', 'warning', 'div');
336
        echo '<br /><br />';
337
// delete remember key of current user from database
338
//if (isset($_SESSION['USER_ID']) && isset($database)) {
339
//	$table = TABLE_PREFIX . 'users';
340
//	$sql = "UPDATE `$table` SET `remember_key` = '' WHERE `user_id` = '" . (int) $_SESSION['USER_ID'] . "'";
341
//	$database->query($sql);
342
//}
343 1532 Luisehahne
344 1920 Luisehahne
// delete remember key cookie if set
345 1935 darkviper
if (isset($_COOKIE['REMEMBER_KEY']) && !headers_sent() ) {
346 1920 Luisehahne
	setcookie('REMEMBER_KEY', '', time() - 3600, '/');
347
}
348
349
// delete most critical session variables manually
350
$_SESSION['USER_ID'] = null;
351
$_SESSION['GROUP_ID'] = null;
352
$_SESSION['GROUPS_ID'] = null;
353
$_SESSION['USERNAME'] = null;
354
$_SESSION['PAGE_PERMISSIONS'] = null;
355
$_SESSION['SYSTEM_PERMISSIONS'] = null;
356
// overwrite session array
357
$_SESSION = array();
358
// delete session cookie if set
359 1935 darkviper
if (isset($_COOKIE[session_name()]) && !headers_sent()) {
360 1920 Luisehahne
    setcookie(session_name(), '', time() - 42000, '/');
361
}
362
// delete the session itself
363
session_destroy();
364
status_msg('<br /><h3>After login as System-Adminstrator you have to start upgrade-script.php again!</h3>', 'info', 'div');
365
        echo '<br /><br />';
366
        if(defined('ADMIN_URL')) {
367
        	echo '<form action="'.ADMIN_URL.'/index.php" method="post">';
368
        	echo '&nbsp;<input name="backend_send" type="submit" value="Kick me to the Login" />';
369
        	echo '</form>';
370
        }
371
echo "<br /><br /></div>
372
	</div>
373
	</div>
374
	</body>
375
	</html>
376
	";
377
	exit();
378
}
379
380 1457 Luisehahne
?>
381 1765 Luisehahne
<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>
382 1457 Luisehahne
383
<?php
384 1870 Luisehahne
385 1457 Luisehahne
/**
386
 * Check if disclaimer was accepted
387
 */
388 1765 Luisehahne
$bDebugModus = false;
389
$bDebugModus = ( (isset($_POST['debug_confirmed']) && $_POST['debug_confirmed'] == 'debug') ? true : false);
390 1457 Luisehahne
if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
391
<h2>Step 1: Backup your files</h2>
392 1785 Luisehahne
<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>
393
<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>
394 1457 Luisehahne
395 1866 Luisehahne
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
396 1765 Luisehahne
<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>
397
<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>
398
<br /><br /><input name="debug_confirmed" type="checkbox" value="debug" />&nbsp;<strong>Here you can get more details during running upgrade.</strong>
399 1457 Luisehahne
<br /><br /><input name="send" type="submit" value="Start upgrade script" />
400
</form>
401
<br />
402
403
<?php
404 1765 Luisehahne
	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');
405 1866 Luisehahne
	echo "<br /><br /></div>
406
	</div>
407
	</div>
408
	</body>
409
	</html>";
410 1457 Luisehahne
	exit();
411
}
412
413
/**********************************************************
414 1765 Luisehahne
 *  - check tables coming with WebsiteBaker
415 1457 Luisehahne
 */
416 1889 Luisehahne
	$aMissingTables = UpgradeHelper::existsAllTables($aPackage);
417
	if( sizeof($aMissingTables) == 0){
418 1894 Luisehahne
        echo '<h4 style="margin-left:0;">NOTICE: '.sizeof($aPackage).' total tables included in package are successfully installed into your database `'.$database->DbName.'` '.$OK.'</h4>';
419 1889 Luisehahne
    } else {
420 1765 Luisehahne
        status_msg('<strong>:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
421
        echo '<h4>Missing required tables. You can install them in backend->addons->modules.<br />';
422
        echo 'Or if you uploaded per FTP install possible by backend->addons->modules->advanced.<br />';
423 1866 Luisehahne
        echo 'First rename or delete the upgrade-script.php, so the script can\'t start automatically by backend<br />';
424 1889 Luisehahne
        echo 'After installing missing tables upload and run again upgrade-script.php<br /><br /></h4>';
425
        echo '<h4 class="warning">';
426
        echo 'Missing required tables.<br /><br />';
427
        echo 'TABLE `'.implode('` missing! '.$FAIL.'<br />TABLE `',$aMissingTables).'` missing! '.$FAIL;
428
        echo '<br /><br /></h4>';
429 1765 Luisehahne
        echo '<br /><br />';
430
        if(isset($_SERVER['SCRIPT_NAME'])) {
431
        	echo '<form action="'.$_SERVER['SCRIPT_NAME'].'/">';
432
        	echo '&nbsp;<input type="submit" value="Start upgrade again" />';
433
        	echo '</form>';
434
        }
435
        if(defined('ADMIN_URL')) {
436 1866 Luisehahne
        	echo '<form action="'.ADMIN_URL.'/index.php" method="post">';
437
        	echo '&nbsp;<input name="backend_send" type="submit" value="kick me to the Backend" />';
438 1457 Luisehahne
        	echo '</form>';
439
        }
440
        echo "<br /><br /></div>
441 1765 Luisehahne
        </div>
442
        </div>
443 1457 Luisehahne
        </body>
444 1866 Luisehahne
        </html>";
445 1765 Luisehahne
446 1894 Luisehahne
		exit();
447
	}
448 1457 Luisehahne
449 1765 Luisehahne
echo '<h3>Step '.(++$stepID).': Setting default_theme</h3>';
450 1768 Luisehahne
$aDebugMessage = array();
451 1894 Luisehahne
	/**********************************************************
452
	 *  - Adding field default_theme to settings table
453
	 */
454
	$aDebugMessage[] = '<div style="margin-left:2em;">';
455
	$aDebugMessage[] = "<br /><span><strong>Adding default_theme to settings table</strong></span>";
456
	// db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
457
	$cfg = array(
458 1920 Luisehahne
		'default_theme' => $DEFAULT_THEME
459 1894 Luisehahne
	);
460
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
461
	$aDebugMessage[] = '</div>';
462 1457 Luisehahne
463 1768 Luisehahne
if($bDebugModus) {
464 1894 Luisehahne
	echo implode(PHP_EOL,$aDebugMessage);
465 1765 Luisehahne
}
466 1768 Luisehahne
$aDebugMessage = array();
467 1889 Luisehahne
echo'<h3>Step '.(++$stepID).': Updating core table included in package</h3>';
468 1894 Luisehahne
	/**********************************************************
469
	 *  - Adding field sec_anchor to settings table
470
	 */
471
	echo '<div style="margin-left:2em;">';
472
	echo "<h4>Adding/updating entries on table settings</h4>";
473
	$aDebugMessage[] = "<span>Adding/updating sec_anchor to settings table</span>";
474
	$cfg = array(
475 1920 Luisehahne
		'sec_anchor' => defined( 'SEC_ANCHOR' )&& (SEC_ANCHOR!='') ? SEC_ANCHOR : 'Sec'
476 1894 Luisehahne
	);
477
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
478 1457 Luisehahne
479 1894 Luisehahne
	/**********************************************************
480
	 *  - Adding redirect timer to settings table
481
	 */
482
	$aDebugMessage[] = "<span>Adding/updating redirect timer to settings table</span>";
483
	$cfg = array(
484
		'redirect_timer' => defined('REDIRECT_TIMER')&& (REDIRECT_TIMER!='') ? REDIRECT_TIMER : '1500'
485
	);
486
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
487 1484 Luisehahne
488 1894 Luisehahne
	/**********************************************************
489
	 *  - Adding default_time_formatr to settings table
490
	 */
491
	$aDebugMessage[] = "<span>Adding/updating default_time_format to settings table</span>";
492
	$cfg = array(
493
		'default_time_format' => defined('DEFAULT_TIME_FORMAT')&& (DEFAULT_TIME_FORMAT!='') ? DEFAULT_TIME_FORMAT : 'h:i A'
494
	);
495
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
496 1889 Luisehahne
497 1894 Luisehahne
	/**********************************************************
498
	 *  - Adding rename_files_on_upload to settings table
499
	 */
500
	$aDebugMessage[] = "<span>Adding/Updating rename_files_on_upload to settings table</span>";
501
	$cfg = array(
502
	    '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')
503
	);
504
	if( version_compare( WB_VERSION, '2.8.2', '<' )) {
505
		$cfg = array(
506
		    'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js'
507
		);
508
	}
509
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
510 1457 Luisehahne
511 1894 Luisehahne
	/**********************************************************
512
	 *  - Adding mediasettings to settings table
513
	 */
514
	$aDebugMessage[] = "<span>Adding/updating mediasettings to settings table</span>";
515
	$cfg = array(
516
		'mediasettings' => (defined('MEDIASETTINGS')&& (MEDIASETTINGS!='') ? MEDIASETTINGS : ''),
517
	);
518 1671 Luisehahne
519 1894 Luisehahne
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
520 1671 Luisehahne
521 1894 Luisehahne
	/**********************************************************
522
	 *  - Adding fingerprint_with_ip_octets to settings table
523
	 */
524
	$aDebugMessage[] = "<span>Adding/updating fingerprint_with_ip_octets to settings table</span>";
525
	$cfg = array(
526
		'fingerprint_with_ip_octets' => (defined('FINGERPRINT_WITH_IP_OCTETS') ? FINGERPRINT_WITH_IP_OCTETS : '2'),
527
		'secure_form_module' => (defined('SECURE_FORM_MODULE') ? SECURE_FORM_MODULE : '')
528
	);
529 1671 Luisehahne
530 1894 Luisehahne
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
531 1671 Luisehahne
532 1894 Luisehahne
	/**********************************************************
533
	 *  - Adding page_icon_dir to settings table
534
	 */
535
	$aDebugMessage[] = "<span>Adding/updating page_icon_dir to settings table</span>";
536
	$cfg = array(
537
		'page_icon_dir' => (defined('PAGE_ICON_DIR')&& (PAGE_ICON_DIR!='') ? PAGE_ICON_DIR : '/templates/*/title_images'),
538
	);
539 1731 Luisehahne
540 1894 Luisehahne
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
541
	/**********************************************************
542
	 *  - Adding page_extended to settings table
543
	 */
544
	$aDebugMessage[] = "<span>Adding/updating page_extendet to settings table</span>";
545
	$cfg = array(
546
		'page_extendet' => (defined('PAGE_EXTENDET') ? PAGE_EXTENDET : 'true'),
547
	);
548 1745 Luisehahne
549 1894 Luisehahne
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
550 1457 Luisehahne
551 1894 Luisehahne
	/**********************************************************
552
	 *  - Adding wbmail_signature to settings table
553
	 */
554
	$aDebugMessage[] = "<span>Adding/updating wbmail_signature to settings table</span>";
555
	$cfg = array(
556
		'wbmail_signature' => (defined('WBMAIL_SIGNATURE')&& (WBMAIL_SIGNATURE!='') ? WBMAIL_SIGNATURE : '')
557
	);
558 1671 Luisehahne
559 1894 Luisehahne
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
560 1765 Luisehahne
561 1894 Luisehahne
	/**********************************************************
562
	 *  - Adding confirmed_registration to settings table
563
	 */
564
	$aDebugMessage[] = "<span>Adding/updating confirmed_registration to settings table</span>";
565
	$cfg = array(
566
		'confirmed_registration' => (defined('CONFIRMED_REGISTRATION') ? CONFIRMED_REGISTRATION : '0')
567
	);
568 1765 Luisehahne
569 1894 Luisehahne
	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
570 1765 Luisehahne
571 1894 Luisehahne
	/**********************************************************
572
	 *  - Adding dev_infos to settings table
573
	 */
574
	$aDebugMessage[] = "<span>Adding/updating dev_infos to settings table</span>";
575
	$cfg = array(
576
		'dev_infos' => (defined('DEV_INFOS') ? DEV_INFOS : 'false')
577
	);
578 1765 Luisehahne
579 1768 Luisehahne
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
580 1765 Luisehahne
581 1930 darkviper
	/**********************************************************
582
	 *  - Adding password settings to settings table
583
	 */
584
	$aDebugMessage[] = "<span>Adding/updating password settings to settings table</span>";
585
	$cfg = array();
586
	$cfg['password_crypt_loops'] = (defined('PASSWORD_CRYPT_LOOPS') ? PASSWORD_CRYPT_LOOPS : '12');
587
	$cfg['password_hash_type'] = (defined('PASSWORD_HASH_TYPES') ? PASSWORD_HASH_TYPES : 'false');
588
	$cfg['password_length'] = (defined('PASSWORD_LENGTH') ? PASSWORD_LENGTH : '10');
589
	$cfg['password_use_types'] = (defined('PASSWORD_USE_TYPES') ? PASSWORD_USE_TYPES : (int)0xFFFF);
590
    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
591
592 1768 Luisehahne
if($bDebugModus) {
593
    echo implode(PHP_EOL,$aDebugMessage);
594 1765 Luisehahne
}
595 1768 Luisehahne
echo '</div>';
596 1765 Luisehahne
597 1768 Luisehahne
$aDebugMessage = array();
598 1772 Luisehahne
if(version_compare(WB_REVISION, REVISION, '<='))
599 1671 Luisehahne
{
600 1894 Luisehahne
	echo '<div style="margin-left:2em;">';
601 1671 Luisehahne
	/**********************************************************
602
	 *  - Update search no results database filed to create
603
	 *  valid XHTML if search is empty
604
	 */
605
	if (version_compare(WB_VERSION, '2.8', '<'))
606
	{
607 1894 Luisehahne
		echo "<h4>Adding/updating fields on table search</h4>";
608
		echo "Updating database field `no_results` on search table: ";
609
		$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
610
		$sql  = 'UPDATE `'.TABLE_PREFIX.'search` ';
611 1671 Luisehahne
		$sql .= 'SET `value`=\''.$search_no_results.'\' ';
612
		$sql .= 'WHERE `name`=\'no_results\'';
613 1894 Luisehahne
		echo ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
614 1671 Luisehahne
	}
615 1760 Luisehahne
616 1894 Luisehahne
	$aDebugMessage = array();
617
	echo "<h4>Adding/updating field on table pages</h4>";
618 1671 Luisehahne
	/**********************************************************
619
	 *  - Add field "page_trail" to table "pages"
620
	 */
621
	$table_name = TABLE_PREFIX.'pages';
622
	$field_name = 'page_trail';
623
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
624 1889 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
625 1671 Luisehahne
626
	/**********************************************************
627 1894 Luisehahne
	 *  - Add field "page_icon" to table "pages"
628
	 */
629 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
630
	$field_name = 'page_icon';
631 1684 Luisehahne
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `page_title`";
632 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
633 1666 Luisehahne
634 1671 Luisehahne
	/**********************************************************
635
	 *  - Add field "page_code" to table "pages"
636
	 */
637
	$table_name = TABLE_PREFIX.'pages';
638
	$field_name = 'page_code';
639
	$description = "INT NOT NULL DEFAULT '0' AFTER `language`";
640 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
641 1671 Luisehahne
642
	/**********************************************************
643 1894 Luisehahne
	 *  - Add field "menu_icon_0" to table "pages"
644
	 */
645 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
646
	$field_name = 'menu_icon_0';
647 1684 Luisehahne
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_title`";
648 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
649 1666 Luisehahne
650 1671 Luisehahne
	/**********************************************************
651
	 *  - Add field "menu_icon_1" to table "pages"
652 1894 Luisehahne
	 */
653 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
654
	$field_name = 'menu_icon_1';
655 1684 Luisehahne
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_0`";
656 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
657 1666 Luisehahne
658 1671 Luisehahne
	/**********************************************************
659 1684 Luisehahne
	 *  - Add field "tooltip" to table "pages"
660 1894 Luisehahne
	 */
661 1684 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
662
	$field_name = 'tooltip';
663
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_1`";
664 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
665 1684 Luisehahne
666
	/**********************************************************
667 1671 Luisehahne
	 *  - Add field "admin_groups" to table "pages"
668 1894 Luisehahne
	 */
669 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
670
	$field_name = 'admin_groups';
671
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
672 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
673 1671 Luisehahne
674
	/**********************************************************
675
	 *  - Add field "admin_users" to table "pages"
676
	 */
677
	$table_name = TABLE_PREFIX.'pages';
678
	$field_name = 'admin_users';
679
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
680 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
681 1671 Luisehahne
682
	/**********************************************************
683
	 *  - Add field "viewing_groups" to table "pages"
684
	 */
685
	$table_name = TABLE_PREFIX.'pages';
686
	$field_name = 'viewing_groups';
687
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
688 1894 Luisehahne
	 add_modify_field_in_database($table_name,$field_name,$description);
689 1671 Luisehahne
690
	/**********************************************************
691
	 *  - Add field "viewing_users" to table "pages"
692
	 */
693
	$table_name = TABLE_PREFIX.'pages';
694
	$field_name = 'viewing_users';
695
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
696 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
697 1755 Luisehahne
698 1768 Luisehahne
	/**********************************************************
699 1894 Luisehahne
	 *  - Add field "custom01" to table "pages"
700
	 */
701 1768 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
702
	$field_name = 'custom01';
703
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
704 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
705 1760 Luisehahne
706 1768 Luisehahne
	/**********************************************************
707 1894 Luisehahne
	 *  - Add field "custom02" to table "pages"
708
	 */
709 1768 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
710
	$field_name = 'custom02';
711
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
712 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
713 1768 Luisehahne
714 1894 Luisehahne
	if($bDebugModus) {
715
		echo implode(PHP_EOL,$aDebugMessage);
716
	}
717 1772 Luisehahne
718 1866 Luisehahne
	$aDebugMessage = array();
719
	/**********************************************************
720 1894 Luisehahne
	 * modify wrong strucre on table sections
721
	 * wrong structure let crash wb
722
	 */
723 1765 Luisehahne
	echo "<h4>Change field structure on table sections</h4>";
724
	$table_name = TABLE_PREFIX.'sections';
725
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
726 1772 Luisehahne
	$aDebugMessage[] = "<span>Modify field module on sections table</span>";
727
	$aDebugMessage[] = ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
728
	$aDebugMessage[] = "<span>Modify field block on sections table</span>";
729 1889 Luisehahne
	$description = "int(11) NOT NULL DEFAULT '1'";
730 1772 Luisehahne
	$aDebugMessage[] = ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
731 1889 Luisehahne
	$description = "int(11) NOT NULL DEFAULT '0'";
732 1772 Luisehahne
	$aDebugMessage[] = "<span>Modify field publ_start on sections table</span>";
733
	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
734
	$aDebugMessage[] = "<span>Modify field publ_end on sections table</span>";
735
	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
736 1755 Luisehahne
737 1894 Luisehahne
	if($bDebugModus) {
738
		echo implode(PHP_EOL,$aDebugMessage);
739
	}
740
	echo '</div>';
741 1890 Luisehahne
}
742 1772 Luisehahne
743 1890 Luisehahne
if(version_compare(WB_REVISION, REVISION, '<='))
744
{
745 1894 Luisehahne
	$aDebugMessage = array();
746
	echo '<h3>Step '.(++$stepID).': Updating structure in table users/groups</h3>';
747 1789 Luisehahne
	/**********************************************************
748 1890 Luisehahne
	 * Modify Administrator on groups table
749
	 */
750
	echo '<div style="margin-left:2em;">';
751 1893 Luisehahne
	echo "<h4>Updating Administrator group permissions on table groups</h4>";
752 1789 Luisehahne
	$aDebugMessage[] = "<span>Modify Administrator on groups table</span>";
753 1866 Luisehahne
	$sModulePermissions = '';
754
	$sTemplatePermissions = '';
755 1789 Luisehahne
	$sSystemPermissions  = 'access,addons,admintools,admintools_view,groups,groups_add,groups_delete,groups_modify,groups_view,';
756
	$sSystemPermissions .= 'languages,languages_install,languages_uninstall,languages_view,media,media_create,media_delete,media_rename,media_upload,media_view,';
757
	$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,';
758
	$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';
759
760
	$sql  = 'UPDATE `'.TABLE_PREFIX.'groups` ';
761
	$sql .= 'SET `name` = \'Administrators\', ';
762
	$sql .= '`system_permissions` = \''.$sSystemPermissions.'\', ';
763
	$sql .= '`module_permissions` = \''.$sModulePermissions.'\', ';
764
	$sql .= '`template_permissions` = \''.$sTemplatePermissions.'\' ';
765
	$sql .= 'WHERE `group_id` = \'1\' ';
766 1894 Luisehahne
	$aDebugMessage[] = ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
767
	if( ($admin->is_authenticated() == true) && ($admin->ami_group_member('1') ) ) {
768
	    $_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $sSystemPermissions));
769
	}
770 1789 Luisehahne
771 1894 Luisehahne
	if($bDebugModus) {
772
		echo implode(PHP_EOL,$aDebugMessage);
773
	}
774
	echo '</div>';
775 1890 Luisehahne
	$aDebugMessage = array();
776
	/**********************************************************
777 1894 Luisehahne
	 *   `confirm_code` VARCHAR(32) NOT NULL DEFAULT '',
778
	 *   `confirm_timeout` INT(11) NOT NULL DEFAULT '0',
779
	 */
780 1890 Luisehahne
	echo '<div style="margin-left:2em;">';
781
	echo "<h4>Change field structure on table users</h4>";
782
	$table_name = TABLE_PREFIX.'users';
783
	$field_name = 'confirm_code';
784
	$description = "VARCHAR( 32 ) NOT NULL DEFAULT '' AFTER `password` ";
785 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
786 1671 Luisehahne
787 1890 Luisehahne
	$table_name = TABLE_PREFIX.'users';
788
	$field_name = 'confirm_timeout';
789
	$description = "INT(11) NOT NULL DEFAULT '0' AFTER `confirm_code` ";
790 1894 Luisehahne
	add_modify_field_in_database($table_name,$field_name,$description);
791 1890 Luisehahne
792 1894 Luisehahne
	if($bDebugModus) {
793
	    echo implode(PHP_EOL,$aDebugMessage);
794
	}
795
	echo '</div>';
796 1893 Luisehahne
797 1894 Luisehahne
	$aDebugMessage = array();
798
	/**********************************************************
799
	* Updating group_id in table users
800
	*/
801 1890 Luisehahne
	echo '<div style="margin-left:2em;">';
802 1893 Luisehahne
	echo "<h4>Updating users groups permissions on table groups</h4>";
803 1894 Luisehahne
	    $aUsers = array();
804 1813 Luisehahne
		// Get existing values
805
        $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'users` ' ;
806
        $sql .= 'WHERE `user_id` != 1 ';
807
        if($oUser = $database->query($sql)){
808
            $iTotalUsers = $oUser->numRows();
809
            while($Users = $oUser->fetchRow(MYSQL_ASSOC)) {
810
                $aUsers[$Users['user_id']]['groups_id'] = $Users['groups_id'];
811
                $aUsers[$Users['user_id']]['display_name'] = $Users['display_name'];
812
            }
813
        } else {
814
            $aDebugMessage[] = $database->is_error()==false ? " $OK<br />" : " $FAIL!<br />";
815
        }
816
        foreach($aUsers AS $user_id => $value){
817
                // choose group_id from groups_id - workaround for still remaining calls to group_id (to be cleaned-up)
818 1815 Luisehahne
                $aGroups_id = explode(',', $aUsers[$user_id]['groups_id']);
819
                $groups_id = $aUsers[$user_id]['groups_id'];
820 1813 Luisehahne
                $group_id = 0;
821
                //if user is in administrator-group, get this group else just get the first one
822 1815 Luisehahne
                if($admin->is_group_match($aGroups_id,'1')) { $group_id = 1; $groups_id = '1'; } else { $group_id = intval($aGroups_id[0]); }
823 1813 Luisehahne
                $sMessage = "<span>Updating group_id ".$TEXT['DISPLAY_NAME']." " .$aUsers[$user_id]['display_name']."</span>";
824
                $sql  = 'UPDATE `'.TABLE_PREFIX.'users` ';
825 1815 Luisehahne
                $sql .= 'SET `group_id`  = '.$group_id.', ';
826 1817 Luisehahne
                $sql .=     '`groups_id` = \''.$groups_id.'\' ';
827 1813 Luisehahne
                $sql .= 'WHERE `user_id` = '.intval($user_id);
828
                if($oRes = $database->query($sql)){  }
829
                $aDebugMessage[] = $database->is_error()==false ? $sMessage." $OK<br />" : $sMessage." $FAIL!<br />";
830
        }
831
        unset($aUsers);
832 1894 Luisehahne
	$aDebugMessage[] = '</div>';
833 1813 Luisehahne
834 1894 Luisehahne
	if($bDebugModus) {
835
	// $aDebugMessage[] =
836
	    echo implode(PHP_EOL,$aDebugMessage);
837
	}else {
838
	    echo '<span><strong>'.$iTotalUsers.' users updating the groups</strong></span>'." $OK<br />";
839
	    echo '</div>';
840
	}
841 1813 Luisehahne
}
842
843
$aDebugMessage = array();
844 1866 Luisehahne
echo '<h3>Step '.(++$stepID).': Updating access and protected files in folders</h3>';
845 1765 Luisehahne
846
echo '<div style="margin-left:2em;">';
847 1894 Luisehahne
	/**********************************************************
848
	* upgrade media directory index protect files
849
	*/
850
	$dir = (WB_PATH.MEDIA_DIRECTORY);
851
	echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
852
	$aDebugMessage = rebuildFolderProtectFile($dir);
853
	if( sizeof( $aDebugMessage ) ){
854
		echo '<span><strong>Upgrade '.sizeof( $aDebugMessage ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
855
	} else {
856
		echo '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />";
857
		echo implode ('<br />',$aDebugMessage);
858
	}
859 1677 Luisehahne
860 1866 Luisehahne
    $aDebugMessage = array();
861 1765 Luisehahne
    /**********************************************************
862
     * upgrade pages directory index access files
863
     */
864
	echo '<h4>Upgrade pages directory '.PAGES_DIRECTORY.'/  protect and access files</h4>';
865 1677 Luisehahne
866 1765 Luisehahne
    /**********************************************************
867
     *  - Reformat/rebuild all existing access files
868
     */
869
    $sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
870
    $msg = rebuild_all_accessfiles();
871 1920 Luisehahne
	$dir = (WB_PATH.PAGES_DIRECTORY);
872
//	$aDebugMessage = rebuildFolderProtectFile($dir);
873 1866 Luisehahne
	echo '<strong>'.implode ('<br />',$msg).'</strong>';
874 1765 Luisehahne
    echo '</div>';
875 1866 Luisehahne
876 1883 Luisehahne
	/* *****************************************************************************
877
	 * - check for deprecated / never needed files
878
	 */
879
	$iLoaded = sizeof($aFilesToRemove);
880
	if($iLoaded) {
881
		echo '<h3>Step '.(++$stepID).': Remove deprecated and outdated files</h3>';
882
		$iFailed = 0;
883
		$iFound = 0;
884
		$searches = array(
885
			'[ADMIN]',
886
			'[MEDIA]',
887
			'[PAGES]',
888
			'[FRAMEWORK]',
889
			'[MODULES]',
890
			'[TEMPLATE]'
891
		);
892
		$replacements = array(
893
			'/'.substr(ADMIN_PATH, strlen(WB_PATH)+1),
894
			MEDIA_DIRECTORY,
895
			PAGES_DIRECTORY,
896
			'/framework',
897
			'/modules',
898
			'/templates'
899
		);
900 1677 Luisehahne
901 1532 Luisehahne
		$msg = '';
902 1883 Luisehahne
		echo '<div style="margin-left:2em;">';
903
		echo '<h4>Search '.$iLoaded.' deprecated and outdated files</h4>';
904
		foreach( $aFilesToRemove as $file )
905
		{
906 1532 Luisehahne
			$file = str_replace($searches, $replacements, $file);
907 1765 Luisehahne
			if( is_writable(WB_PATH.'/'.$file) ) {
908 1883 Luisehahne
				$iFound++;
909 1588 darkviper
				// try to unlink file
910 1765 Luisehahne
				if(!unlink(WB_PATH.$file)) {
911 1883 Luisehahne
					$iFailed++;
912 1801 Luisehahne
				}
913 1484 Luisehahne
			}
914 1883 Luisehahne
			if( is_readable(WB_PATH.'/'.$file) ) {
915
				// save in err-list, if failed
916
				$msg .= $file.'<br />';
917
			}
918
		}
919
		$iRemove = $iFound-$iFailed;
920
		echo '<strong>Remove '.$iRemove.' from '.$iFound.' founded</strong> ';
921
		echo ($iFailed == 0) ? $OK : $FAIL;
922
		echo '</div>';
923 1532 Luisehahne
924
		if($msg != '')
925
		{
926
			$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
927
				    can not be removed automatically.<br /><br />Please delete them
928
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
929 1889 Luisehahne
			status_msg($msg, 'error warning', 'div');
930 1532 Luisehahne
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
931
932
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
933
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
934
			echo '</form>';
935 1866 Luisehahne
			echo "<br /><br /></div>
936
			</div>
937
			</div>
938
			</body>
939
			</html>";
940 1532 Luisehahne
			exit;
941
		}
942 1889 Luisehahne
	}
943 1484 Luisehahne
944 1532 Luisehahne
945 1883 Luisehahne
	/**********************************************************
946
	 * - check for deprecated / never needed files
947
	 */
948
	$iLoaded = sizeof($dirRemove);
949
	if($iLoaded) {
950
		echo '<h3>Step  '.(++$stepID).': Remove deprecated and outdated folders</h3>';
951
		$iFailed = 0;
952
		$iFound = 0;
953 1588 darkviper
		$searches = array(
954
			'[ADMIN]',
955
			'[MEDIA]',
956
			'[PAGES]',
957
			'[TEMPLATE]'
958
		);
959
		$replacements = array(
960
			substr(ADMIN_PATH, strlen(WB_PATH)+1),
961
			MEDIA_DIRECTORY,
962
			PAGES_DIRECTORY,
963
			'/templates',
964
		);
965
		$msg = '';
966 1883 Luisehahne
		echo '<div style="margin-left:2em;">';
967
		echo '<h4>Search '.$iLoaded.' deprecated and outdated folders</h4>';
968 1588 darkviper
		foreach( $dirRemove as $dir ) {
969
			$dir = str_replace($searches, $replacements, $dir);
970
			$dir = WB_PATH.'/'.$dir;
971
			if( is_dir( $dir )) {
972 1883 Luisehahne
				$iFound++;
973 1588 darkviper
			// try to delete dir
974 1641 Luisehahne
				if(!is_writable( $dir ) || !rm_full_dir($dir)) {
975 1588 darkviper
				// save in err-list, if failed
976 1883 Luisehahne
					$iFailed++;
977 1588 darkviper
				}
978 1525 Luisehahne
			}
979 1883 Luisehahne
			if( is_readable(WB_PATH.'/'.$dir) ) {
980
				$msg .= str_replace(WB_PATH,'',$dir).'<br />';
981
			}
982 1525 Luisehahne
		}
983 1883 Luisehahne
984
		$iRemove = $iFound-$iFailed;
985
		echo '<strong>Remove '.$iRemove.' from '.$iFound.' founded</strong> ';
986
		echo ($iFailed == 0) ? $OK : $FAIL;
987
		echo '</div>';
988 1765 Luisehahne
989 1588 darkviper
		if($msg != '') {
990 1641 Luisehahne
			$msg = '<br /><br />Following directories are deprecated, outdated or a security risk and
991 1588 darkviper
					can not be removed automatically.<br /><br />Please delete them
992
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
993
			status_msg($msg, 'error warning', 'div');
994
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
995
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
996
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
997
			echo '</form>';
998 1866 Luisehahne
			echo "<br /><br /></div>
999
			</div>
1000
			</div>
1001
			</body>
1002
			</html>";
1003 1588 darkviper
			exit;
1004
		}
1005 1883 Luisehahne
1006
1007 1525 Luisehahne
	}
1008 1532 Luisehahne
1009 1883 Luisehahne
	/**********************************************************
1010
	 * upgrade modules if newer version is available
1011
	 * $aModuleList list of proofed modules
1012
	 */
1013 1894 Luisehahne
	$aModuleList = array(
1014 1920 Luisehahne
	              'captcha_control','code','droplets','form','jsadmin',
1015
	              'menu_link','news','output_filter','wrapper','wysiwyg','MultiLingual');
1016 1866 Luisehahne
	if(sizeof($aModuleList))
1017
	{
1018 1890 Luisehahne
		echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
1019 1866 Luisehahne
		foreach($aModuleList as $sModul) {
1020
			if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
1021
				$currModulVersion = get_modul_version ($sModul, false);
1022
				$newModulVersion =  get_modul_version ($sModul, true);
1023
				if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
1024 1883 Luisehahne
					echo '<div style="margin-left:2em;">';
1025 1866 Luisehahne
					echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
1026
					require(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
1027 1883 Luisehahne
					echo '</div>';
1028 1866 Luisehahne
				}
1029 1588 darkviper
			}
1030
		}
1031 1525 Luisehahne
	}
1032 1765 Luisehahne
1033 1883 Luisehahne
	/**********************************************************
1034
	 * Reformat/rebuild all existing moules access files
1035
	 * $aModuleList list of modules
1036
	 */
1037
	$aModuleList = array('bakery','topics','news');
1038 1866 Luisehahne
	if(sizeof($aModuleList))
1039
	{
1040
		echo '<h3>Step '.(++$stepID).': Create/Reorg Accessfiles from modules</h3>';
1041
		foreach($aModuleList as $sModul) {
1042
			$aReturnMsg = array();
1043
			$sModulReorg = 'm_'.$sModul.'_Reorg';
1044
			if(class_exists($sModulReorg)) {
1045
				$sModulVersion =  get_modul_version ($sModul, true);
1046
				echo '<div style="margin-left:2em;">';
1047
				echo '<h4>'.'Create/Reorg Accesfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>';
1048
				$oReorg = new $sModulReorg();
1049
				$aReturnMsg = $oReorg->execute(); // show details
1050 1881 Luisehahne
				if(is_array($aReturnMsg)) {
1051 1866 Luisehahne
					foreach($aReturnMsg as $title) {
1052
					echo '<strong>'.$title.'</strong><br />';
1053
					}
1054
				}
1055
				echo '</div>';
1056
			}
1057
		}
1058
	}
1059 1525 Luisehahne
/**********************************************************
1060 1457 Luisehahne
 *  - Reload all addons
1061
 */
1062
1063 1765 Luisehahne
	echo '<h3>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h3><br />';
1064 1883 Luisehahne
	echo '<div style="margin-left:2em;">';
1065
	$iFound = 0;
1066
	$iLoaded = 0;
1067 1588 darkviper
	////delete modules
1068
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
1069
	// Load all modules
1070
	if( ($handle = opendir(WB_PATH.'/modules/')) ) {
1071
		while(false !== ($file = readdir($handle))) {
1072 1769 Luisehahne
			if($file != '' && substr($file, 0, 1) != '.' && is_dir(WB_PATH.'/modules/'.$file) ) {
1073 1889 Luisehahne
				$iFound++;
1074 1765 Luisehahne
				$iLoaded = load_module(WB_PATH.'/modules/'.$file ) ? $iLoaded+1 : $iLoaded;
1075 1889 Luisehahne
// 	upgrade_module($file, true);
1076 1588 darkviper
			}
1077 1457 Luisehahne
		}
1078 1588 darkviper
		closedir($handle);
1079 1457 Luisehahne
	}
1080 1866 Luisehahne
	echo '<strong><span>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
1081 1457 Luisehahne
1082 1889 Luisehahne
	$iFound = 0;
1083
	$iLoaded = 0;
1084 1588 darkviper
	////delete templates
1085
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
1086
	// Load all templates
1087
	if( ($handle = opendir(WB_PATH.'/templates/')) ) {
1088
		while(false !== ($file = readdir($handle))) {
1089
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
1090 1769 Luisehahne
1091 1889 Luisehahne
				$iFound++;
1092 1765 Luisehahne
				$iLoaded = (load_template(WB_PATH.'/templates/'.$file)==true) ? $iLoaded+1 : $iLoaded;
1093 1769 Luisehahne
1094 1588 darkviper
			}
1095 1457 Luisehahne
		}
1096 1588 darkviper
		closedir($handle);
1097 1457 Luisehahne
	}
1098 1866 Luisehahne
	echo '<strong><span>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
1099 1457 Luisehahne
1100 1889 Luisehahne
	$iFound = 0;
1101
	$iLoaded = 0;
1102 1588 darkviper
	////delete languages
1103
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
1104
	// Load all languages
1105
	if( ($handle = opendir(WB_PATH.'/languages/')) ) {
1106
		while(false !== ($file = readdir($handle))) {
1107 1769 Luisehahne
			if($file != '' AND (preg_match('#^([A-Z]{2}.php)#', basename($file)))) {
1108 1889 Luisehahne
				$iFound++;
1109 1765 Luisehahne
				$iLoaded = load_language(WB_PATH.'/languages/'.$file) ? $iLoaded+1 : $iLoaded;
1110 1588 darkviper
			}
1111 1457 Luisehahne
		}
1112 1588 darkviper
		closedir($handle);
1113 1457 Luisehahne
	}
1114 1866 Luisehahne
	echo '<strong><span>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
1115 1889 Luisehahne
	echo '</div>';
1116 1457 Luisehahne
1117
/**********************************************************
1118 1671 Luisehahne
 *  - install new droplets
1119
	$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
1120
	echo $drops;
1121
	$file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
1122
	require_once (WB_PATH."/modules/droplets/".$file_name);
1123
********************************************************** */
1124
1125
/**********************************************************
1126 1457 Luisehahne
 *  - End of upgrade script
1127
 */
1128 1588 darkviper
	if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
1129
	if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
1130 1532 Luisehahne
/**********************************************************
1131
 *  - Set Version to new Version
1132
 */
1133 1765 Luisehahne
echo '<h3>Step '.(++$stepID).': Update database version number </h3>';
1134
echo '<div style="margin-left:2em;">';
1135 1457 Luisehahne
1136 1671 Luisehahne
$cfg = array(
1137
	'wb_version' => VERSION,
1138
	'wb_revision' => REVISION,
1139
	'wb_sp' => SP
1140
);
1141 1883 Luisehahne
echo '<br /><span><strong>Set WebsiteBaker version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : </strong></span>';
1142 1671 Luisehahne
echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
1143 1765 Luisehahne
echo '</div>';
1144 1671 Luisehahne
1145 1765 Luisehahne
echo '<p style="font-size:140%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
1146
status_msg('<strong>:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
1147
// show buttons to go to the backend or frontend
1148
echo '<br />';
1149 1532 Luisehahne
1150 1765 Luisehahne
if(defined('WB_URL')) {
1151
	echo '<form action="'.WB_URL.'/">';
1152
	echo '&nbsp;<input type="submit" value="kick me to the Frontend" />';
1153
	echo '</form>';
1154
}
1155
if(defined('ADMIN_URL')) {
1156
	echo '<form action="'.ADMIN_URL.'/">';
1157
	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
1158
	echo '</form>';
1159
}
1160 1457 Luisehahne
1161 1765 Luisehahne
echo "<br /><br /></div>
1162
</div>
1163
</div>
1164
</body>
1165
</html>
1166
";
1167
exit();