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