Project

General

Profile

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