Project

General

Profile

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