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