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