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 1671 Luisehahne
429 1765 Luisehahne
if($bDebugModus) {
430
    /**********************************************************
431
     *  - Adding field default_theme to settings table
432
     */
433
    echo '<div style="margin-left:2em;">';
434
    echo "<br /><span><strong>Adding default_theme to settings table</strong></span>";
435
    // db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
436
    echo (db_update_key_value( 'settings', 'default_theme', $DEFAULT_THEME ) ? " $OK<br />" : " $FAIL!<br />");
437
    echo '</div>';
438 1457 Luisehahne
439 1765 Luisehahne
}
440
    echo '<h3>Step '.(++$stepID).': Updating core tables</h3>';
441 1671 Luisehahne
442 1765 Luisehahne
if($bDebugModus) {
443
    /**********************************************************
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
    echo "<span>Adding/updating sec_anchor to settings table</span>";
449
    $cfg = array(
450
    	'sec_anchor' => defined('SEC_ANCHOR') ? SEC_ANCHOR : 'section_'
451
    );
452 1671 Luisehahne
453 1765 Luisehahne
    echo (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
    echo "<span>Adding/updating redirect timer to settings table</span>";
460
    $cfg = array(
461
    	'redirect_timer' => defined('REDIRECT_TIMER') ? REDIRECT_TIMER : '1500'
462
    );
463
    echo (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
    echo "<span>Adding/Updating rename_files_on_upload to settings table</span>";
469
    $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
    echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
473 1457 Luisehahne
474 1765 Luisehahne
    /**********************************************************
475
     *  - Adding mediasettings to settings table
476
     */
477
    echo "<span>Adding/updating mediasettings to settings table</span>";
478
    $cfg = array(
479
    	'mediasettings' => (defined('MEDIASETTINGS') ? MEDIASETTINGS : ''),
480
    );
481 1671 Luisehahne
482 1765 Luisehahne
    echo (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
    echo "<span>Adding/updating fingerprint_with_ip_octets to settings table</span>";
488
    $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 1765 Luisehahne
    echo (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
    echo "<span>Adding/updating page_icon_dir to settings table</span>";
499
    $cfg = array(
500
    	'page_icon_dir' => (defined('PAGE_ICON_DIR') ? PAGE_ICON_DIR : '/templates/*/title_images'),
501
    );
502 1731 Luisehahne
503 1765 Luisehahne
    echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
504
    /**********************************************************
505
     *  - Adding page_extended to settings table
506
     */
507
    echo "<span>Adding/updating page_extended to settings table</span>";
508
    $cfg = array(
509
    	'page_extended' => (defined('PAGE_EXTENDED') ? PAGE_EXTENDED : 'true'),
510
    );
511 1745 Luisehahne
512 1765 Luisehahne
    echo (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
    echo "<span>Adding/updating website_signature to settings table</span>";
518
    $cfg = array(
519
    	'website_signature' => (defined('WEBSITE_SIGNATURE') && (WEBSITE_SIGNATURE=='') ? '' : WEBSITE_SIGNATURE)
520
    );
521 1671 Luisehahne
522 1765 Luisehahne
    echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
523
524
    /**********************************************************
525
     *  - Adding confirmed_registration to settings table
526
     */
527
    echo "<span>Adding/updating confirmed_registration to settings table</span>";
528
    $cfg = array(
529
    	'confirmed_registration' => (defined('CONFIRMED_REGISTRATION') && (CONFIRMED_REGISTRATION=='') ? '' : CONFIRMED_REGISTRATION)
530
    );
531
532
    echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
533
534
    /**********************************************************
535
     *  - Adding dev_infos to settings table
536
     */
537
    echo "<span>Adding/updating dev_infos to settings table</span>";
538
    $cfg = array(
539
    	'dev_infos' => (defined('DEV_INFOS') ? DEV_INFOS : 'false')
540
    );
541
542
    echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
543
544
    /**********************************************************
545
     *  - Adding dev_infos to settings table
546
     */
547
    echo "<span>Adding/updating modules_upgrade_list to settings table</span>";
548
    $cfg = array(
549
    	'modules_upgrade_list' => (defined('MODULES_UPGRADE_LIST') ? MODULES_UPGRADE_LIST : 'news')
550
    );
551
552
    echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
553
554
    echo '</div>';
555
556
557
}
558
559 1689 darkviper
if(version_compare(WB_REVISION, REVISION, '<'))
560 1671 Luisehahne
{
561 1765 Luisehahne
    echo '<div style="margin-left:2em;">';
562 1671 Luisehahne
	/**********************************************************
563
	 *  - Update search no results database filed to create
564
	 *  valid XHTML if search is empty
565
	 */
566
	if (version_compare(WB_VERSION, '2.8', '<'))
567
	{
568 1765 Luisehahne
        echo "<h4>Adding/updating fields on table search</h4>";
569
	    echo "Updating database field `no_results` on search table: ";
570 1671 Luisehahne
	    $search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
571
	    $sql  = 'UPDATE `'.TABLE_PREFIX.'search` ';
572
		$sql .= 'SET `value`=\''.$search_no_results.'\' ';
573
		$sql .= 'WHERE `name`=\'no_results\'';
574 1765 Luisehahne
	    echo ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
575 1671 Luisehahne
	}
576 1760 Luisehahne
577 1765 Luisehahne
    echo "<h4>Adding/updating fiekds on table mod_menu_link</h4>";
578 1671 Luisehahne
	/**********************************************************
579 1760 Luisehahne
     *  - Add field "redirect_type" to table "mod_menu_link"
580
     *  has to be moved later to upgrade.php in modul menu_link, because modul can be removed
581
     */
582 1671 Luisehahne
	$table_name = TABLE_PREFIX.'mod_menu_link';
583
	$field_name = 'redirect_type';
584 1696 Luisehahne
	$description = "INT NOT NULL DEFAULT '301' AFTER `target_page_id`";
585 1671 Luisehahne
	if(!$database->field_exists($table_name,$field_name)) {
586 1765 Luisehahne
		echo "<span>Adding field redirect_type to mod_menu_link table</span>";
587 1671 Luisehahne
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
588
	} else {
589 1765 Luisehahne
		echo "<span>Modify field redirect_type to mod_menu_link table</span>";
590 1671 Luisehahne
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
591
	}
592 1457 Luisehahne
593 1765 Luisehahne
    echo "<h4>Adding/updating fiekds on table pages</h4>";
594 1671 Luisehahne
	/**********************************************************
595
	 *  - Add field "page_trail" to table "pages"
596
	 */
597
	$table_name = TABLE_PREFIX.'pages';
598
	$field_name = 'page_trail';
599
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
600 1765 Luisehahne
	echo "<span>Modify field page_trail to pages table</span>";
601 1671 Luisehahne
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
602
603
	/**********************************************************
604 1760 Luisehahne
     *  - Add field "page_icon" to table "pages"
605
     */
606 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
607
	$field_name = 'page_icon';
608 1684 Luisehahne
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `page_title`";
609 1671 Luisehahne
	if(!$database->field_exists($table_name,$field_name)) {
610 1765 Luisehahne
		echo "<span>Adding field page_icon to pages table</span>";
611 1671 Luisehahne
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
612
	} else {
613 1765 Luisehahne
		echo "<span>Modify field page_icon to pages table</span>";
614 1671 Luisehahne
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
615
	}
616 1666 Luisehahne
617 1671 Luisehahne
	/**********************************************************
618
	 *  - Add field "page_code" to table "pages"
619
	 */
620
	$table_name = TABLE_PREFIX.'pages';
621
	$field_name = 'page_code';
622
	$description = "INT NOT NULL DEFAULT '0' AFTER `language`";
623
	if(!$database->field_exists($table_name,$field_name)) {
624 1765 Luisehahne
		echo "<span>Adding field page_code to pages table</span>";
625 1671 Luisehahne
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
626
	} else {
627 1765 Luisehahne
		echo "<span>Modify field page_code to pages table</span>";
628 1671 Luisehahne
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
629
	}
630
631
	/**********************************************************
632 1760 Luisehahne
     *  - Add field "menu_icon_0" to table "pages"
633
     */
634 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
635
	$field_name = 'menu_icon_0';
636 1684 Luisehahne
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_title`";
637 1671 Luisehahne
	if(!$database->field_exists($table_name,$field_name)) {
638 1765 Luisehahne
		echo "<span>Adding field menu_icon_0 to pages table</span>";
639 1671 Luisehahne
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
640
	} else {
641 1765 Luisehahne
		echo "<span>Modify field menu_icon_0 to pages table</span>";
642 1671 Luisehahne
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
643
	}
644 1666 Luisehahne
645 1671 Luisehahne
	/**********************************************************
646
	 *  - Add field "menu_icon_1" to table "pages"
647 1760 Luisehahne
     */
648 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
649
	$field_name = 'menu_icon_1';
650 1684 Luisehahne
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_0`";
651 1671 Luisehahne
	if(!$database->field_exists($table_name,$field_name)) {
652 1765 Luisehahne
		echo "<span>Adding field menu_icon_1 to pages table</span>";
653 1671 Luisehahne
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
654
	} else {
655 1765 Luisehahne
		echo "<span>Modify field menu_icon_1 to pages table</span>";
656 1671 Luisehahne
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
657
	}
658 1666 Luisehahne
659 1671 Luisehahne
	/**********************************************************
660 1684 Luisehahne
	 *  - Add field "tooltip" to table "pages"
661 1760 Luisehahne
     */
662 1684 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
663
	$field_name = 'tooltip';
664
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_1`";
665
	if(!$database->field_exists($table_name,$field_name)) {
666 1765 Luisehahne
		echo "<span>Adding field tooltip to pages table</span>";
667 1684 Luisehahne
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
668
	} else {
669 1765 Luisehahne
		echo "<span>Modify field tooltip to pages table";
670 1684 Luisehahne
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
671
	}
672
673
	/**********************************************************
674 1671 Luisehahne
	 *  - Add field "admin_groups" to table "pages"
675 1760 Luisehahne
     */
676 1671 Luisehahne
	$table_name = TABLE_PREFIX.'pages';
677
	$field_name = 'admin_groups';
678
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
679 1765 Luisehahne
	echo "<span>Modify field admin_groups to pages table";
680 1671 Luisehahne
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
681
682
	/**********************************************************
683
	 *  - Add field "admin_users" to table "pages"
684
	 */
685
	$table_name = TABLE_PREFIX.'pages';
686
	$field_name = 'admin_users';
687
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
688 1765 Luisehahne
	echo "<span>Modify field admin_users to pages table</span>";
689 1671 Luisehahne
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
690
691
	/**********************************************************
692
	 *  - Add field "viewing_groups" to table "pages"
693
	 */
694
	$table_name = TABLE_PREFIX.'pages';
695
	$field_name = 'viewing_groups';
696
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
697 1765 Luisehahne
	echo "<span>Modify field viewing_groups to pages table</span>";
698 1671 Luisehahne
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
699
700
	/**********************************************************
701
	 *  - Add field "viewing_users" to table "pages"
702
	 */
703
	$table_name = TABLE_PREFIX.'pages';
704
	$field_name = 'viewing_users';
705
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
706 1765 Luisehahne
	echo "<span>Modify field viewing_users to pages table";
707 1671 Luisehahne
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
708 1755 Luisehahne
709 1760 Luisehahne
710 1765 Luisehahne
    /**********************************************************
711
     * modify wrong strucre on table sections
712
     * wrong structure let crash wb
713
     */
714
	echo "<h4>Change field structure on table sections</h4>";
715
	$table_name = TABLE_PREFIX.'sections';
716
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
717
	echo "<span>Modify field module on sections table</span>";
718
	echo ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
719
	echo "<span>Modify field block on sections table</span>";
720
	echo ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
721
	echo "<span>Modify field publ_start on sections table</span>";
722
	echo ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
723
	echo "<span>Modify field publ_end on sections table</span>";
724
	echo ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
725 1755 Luisehahne
726 1765 Luisehahne
    echo '</div>';
727 1760 Luisehahne
728 1457 Luisehahne
}
729 1671 Luisehahne
730 1457 Luisehahne
/**********************************************************
731 1765 Luisehahne
 * This part with changing in mod_wysiwyg will be removed in the final version
732
 * special workout for the tester
733
 *  - Remove/add PRIMARY KEY from/to "section_id" from table "mod_wysiwygs"
734 1457 Luisehahne
 */
735 1765 Luisehahne
if($bDebugModus) {
736
    echo '<div style="margin-left:2em;">';
737 1677 Luisehahne
738 1765 Luisehahne
    $sTable = TABLE_PREFIX.'mod_wysiwyg';
739
    $field_name = 'wysiwyg_id';
740
    if($database->field_exists($sTable, 'wysiwyg_id')) {
741
        if($database->index_exists($sTable, 'PRIMARY')) {
742
            echo "<span>Remove PRIMARY KEY from table mod_wysiwyg.wysiwyg_id</span>";
743
            echo $database->index_remove($sTable, 'PRIMARY') ? " $OK<br />" : " $FAIL!<br />";
744 1688 Luisehahne
        }
745 1765 Luisehahne
        echo "<span>Remove field 'wysiwyg_id' from table mod_wysiwyg</span>";
746
        echo $database->field_remove($sTable, 'wysiwyg_id') ? " $OK<br />" : " $FAIL!<br />";
747
    }
748 1688 Luisehahne
749 1765 Luisehahne
    echo "<br /><span>Create PRIMARY KEY ( `section_id` ) on table mod_wysiwygs.</span>";
750
    echo $database->index_add($sTable, '', 'section_id', 'PRIMARY') ? " $OK<br />" : " $FAIL!<br />";
751
    echo '</div>';
752
}
753 1760 Luisehahne
754 1765 Luisehahne
echo '<h3>Step '.(++$stepID).': Updating acess and protected files in folders</h3>';
755
756
echo '<div style="margin-left:2em;">';
757
    /**********************************************************
758
    * upgrade media directory index protect files
759
    */
760
    $dir = (WB_PATH.MEDIA_DIRECTORY);
761
    echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
762
    $array = rebuildFolderProtectFile($dir);
763
    if( sizeof( $array ) ){
764
    	print '<span><strong>Upgrade '.sizeof( $array ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
765
    } else {
766
    	print '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />";
767
    	print implode ('<br />',$array);
768 1677 Luisehahne
    }
769
770 1765 Luisehahne
    /**********************************************************
771
     * upgrade pages directory index access files
772
     */
773
	echo '<h4>Upgrade pages directory '.PAGES_DIRECTORY.'/  protect and access files</h4>';
774 1677 Luisehahne
775 1765 Luisehahne
    /**********************************************************
776
     *  - Reformat/rebuild all existing access files
777
     */
778
    $sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
779
    $msg = rebuild_all_accessfiles();
780 1677 Luisehahne
781 1765 Luisehahne
	print implode ('<br />',$msg);
782
    echo '</div>';
783
    /* *****************************************************************************
784
     * - check for deprecated / never needed files
785
     */
786
    if(sizeof($aFilesToRemove)) {
787
    	echo '<h3>Step '.(++$stepID).': Remove deprecated and old files</h3>';
788
    	$searches = array(
789
    		'[ADMIN]',
790
    		'[MEDIA]',
791
    		'[PAGES]',
792
    		'[FRAMEWORK]',
793
    		'[MODULES]',
794
    		'[TEMPLATE]'
795
    	);
796
    	$replacements = array(
797
    		'/'.substr(ADMIN_PATH, strlen(WB_PATH)+1),
798
    		MEDIA_DIRECTORY,
799
    		PAGES_DIRECTORY,
800
    		'/framework',
801
    		'/modules',
802
    		'/templates'
803
    	);
804 1677 Luisehahne
805 1532 Luisehahne
		$msg = '';
806 1765 Luisehahne
    	foreach( $aFilesToRemove as $file )
807
    	{
808 1532 Luisehahne
			$file = str_replace($searches, $replacements, $file);
809 1765 Luisehahne
			if( is_writable(WB_PATH.'/'.$file) ) {
810 1588 darkviper
				// try to unlink file
811 1765 Luisehahne
				if(!unlink(WB_PATH.$file)) {
812 1588 darkviper
					// save in err-list, if failed
813 1532 Luisehahne
					$msg .= $file.'<br />';
814 1765 Luisehahne
				} else {
815
					$msg .= $file.'<br />';
816
    			}
817 1484 Luisehahne
			}
818 1765 Luisehahne
    	}
819 1532 Luisehahne
820
		if($msg != '')
821
		{
822
			$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
823
				    can not be removed automatically.<br /><br />Please delete them
824
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
825
	        status_msg($msg, 'error warning', 'div');
826
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
827
828
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
829
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
830
			echo '</form>';
831 1765 Luisehahne
            echo "<br /><br /></div>
832
            </div>
833
            </div>
834
            </body>
835
            </html>
836
            ";
837 1532 Luisehahne
			exit;
838
		}
839 1765 Luisehahne
    }
840 1484 Luisehahne
841 1532 Luisehahne
842 1457 Luisehahne
/**********************************************************
843 1525 Luisehahne
 * - check for deprecated / never needed files
844
 */
845 1588 darkviper
	if(sizeof($dirRemove)) {
846 1671 Luisehahne
		echo '<h3>Step  '.(++$stepID).': Remove deprecated and old folders</h3>';
847 1588 darkviper
		$searches = array(
848
			'[ADMIN]',
849
			'[MEDIA]',
850
			'[PAGES]',
851
			'[TEMPLATE]'
852
		);
853
		$replacements = array(
854
			substr(ADMIN_PATH, strlen(WB_PATH)+1),
855
			MEDIA_DIRECTORY,
856
			PAGES_DIRECTORY,
857
			'/templates',
858
		);
859
		$msg = '';
860
		foreach( $dirRemove as $dir ) {
861
			$dir = str_replace($searches, $replacements, $dir);
862
			$dir = WB_PATH.'/'.$dir;
863
			if( is_dir( $dir )) {
864
			// try to delete dir
865 1641 Luisehahne
				if(!is_writable( $dir ) || !rm_full_dir($dir)) {
866 1588 darkviper
				// save in err-list, if failed
867 1641 Luisehahne
					$msg .= str_replace(WB_PATH,'',$dir).'<br />';
868 1588 darkviper
				}
869 1525 Luisehahne
			}
870
		}
871 1765 Luisehahne
872 1588 darkviper
		if($msg != '') {
873 1641 Luisehahne
			$msg = '<br /><br />Following directories are deprecated, outdated or a security risk and
874 1588 darkviper
					can not be removed automatically.<br /><br />Please delete them
875
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
876
			status_msg($msg, 'error warning', 'div');
877
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
878
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
879
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
880
			echo '</form>';
881 1765 Luisehahne
            echo "<br /><br /></div>
882
            </div>
883
            </div>
884
            </body>
885
            </html>
886
            ";
887 1588 darkviper
			exit;
888
		}
889 1525 Luisehahne
	}
890 1532 Luisehahne
891 1765 Luisehahne
    /**********************************************************
892
     * upgrade modules if newer version is available
893
     * $aModuleList list of proofed modules
894
     */
895
    $sModuleList = 'news,wysiwyg,form';
896
    $aModuleList = explode(',', (defined('MODULES_UPGRADE_LIST') ? MODULES_UPGRADE_LIST : $sModuleList));
897
    echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
898
//	$aModuleList = array('news');
899 1588 darkviper
	foreach($aModuleList as $sModul) {
900
		if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
901
			$currModulVersion = get_modul_version ($sModul, false);
902
			$newModulVersion =  get_modul_version ($sModul, true);
903
			if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
904 1765 Luisehahne
                echo '<div style="margin-left:2em;">';
905
				echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
906 1588 darkviper
				require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
907 1765 Luisehahne
                echo '</div>';
908 1588 darkviper
			}
909
		}
910 1525 Luisehahne
	}
911 1765 Luisehahne
912 1525 Luisehahne
/**********************************************************
913 1457 Luisehahne
 *  - Reload all addons
914
 */
915
916 1765 Luisehahne
	echo '<h3>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h3><br />';
917
    echo '<div style="margin-left:2em;">';
918
    $iFound = 0;
919
    $iLoaded = 0;
920 1588 darkviper
	////delete modules
921
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
922
	// Load all modules
923
	if( ($handle = opendir(WB_PATH.'/modules/')) ) {
924
		while(false !== ($file = readdir($handle))) {
925
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
926 1765 Luisehahne
                $iFound++;
927
				$iLoaded = load_module(WB_PATH.'/modules/'.$file ) ? $iLoaded+1 : $iLoaded;
928 1588 darkviper
			   // 	upgrade_module($file, true);
929
			}
930 1457 Luisehahne
		}
931 1588 darkviper
		closedir($handle);
932 1457 Luisehahne
	}
933 1765 Luisehahne
	echo '<span><strong>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
934 1457 Luisehahne
935 1765 Luisehahne
    $iFound = 0;
936
    $iLoaded = 0;
937 1588 darkviper
	////delete templates
938
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
939
	// Load all templates
940
	if( ($handle = opendir(WB_PATH.'/templates/')) ) {
941
		while(false !== ($file = readdir($handle))) {
942
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
943 1765 Luisehahne
                $iFound++;
944
				$iLoaded = (load_template(WB_PATH.'/templates/'.$file)==true) ? $iLoaded+1 : $iLoaded;
945 1588 darkviper
			}
946 1457 Luisehahne
		}
947 1588 darkviper
		closedir($handle);
948 1457 Luisehahne
	}
949 1765 Luisehahne
	echo '<span><strong>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
950 1457 Luisehahne
951 1765 Luisehahne
    $iFound = 0;
952
    $iLoaded = 0;
953 1588 darkviper
	////delete languages
954
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
955
	// Load all languages
956
	if( ($handle = opendir(WB_PATH.'/languages/')) ) {
957
		while(false !== ($file = readdir($handle))) {
958
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
959 1765 Luisehahne
                $iFound++;
960
				$iLoaded = load_language(WB_PATH.'/languages/'.$file) ? $iLoaded+1 : $iLoaded;
961 1588 darkviper
			}
962 1457 Luisehahne
		}
963 1588 darkviper
		closedir($handle);
964 1457 Luisehahne
	}
965 1765 Luisehahne
	echo '<span><strong>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
966
    echo '</div>';
967 1457 Luisehahne
968
/**********************************************************
969 1671 Luisehahne
 *  - install new droplets
970
	$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
971
	echo $drops;
972
	$file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
973
	require_once (WB_PATH."/modules/droplets/".$file_name);
974
********************************************************** */
975
976
/**********************************************************
977 1457 Luisehahne
 *  - End of upgrade script
978
 */
979 1588 darkviper
	if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
980
	if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
981 1532 Luisehahne
/**********************************************************
982
 *  - Set Version to new Version
983
 */
984 1765 Luisehahne
echo '<h3>Step '.(++$stepID).': Update database version number </h3>';
985
echo '<div style="margin-left:2em;">';
986 1457 Luisehahne
987 1671 Luisehahne
$cfg = array(
988
	'wb_version' => VERSION,
989
	'wb_revision' => REVISION,
990
	'wb_sp' => SP
991
);
992 1765 Luisehahne
echo '<br /><span><strong>Set database version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : </strong></span>';
993 1671 Luisehahne
echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
994 1765 Luisehahne
echo '</div>';
995 1671 Luisehahne
996 1765 Luisehahne
echo '<p style="font-size:140%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
997
status_msg('<strong>:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
998
// show buttons to go to the backend or frontend
999
echo '<br />';
1000 1532 Luisehahne
1001 1765 Luisehahne
if(defined('WB_URL')) {
1002
	echo '<form action="'.WB_URL.'/">';
1003
	echo '&nbsp;<input type="submit" value="kick me to the Frontend" />';
1004
	echo '</form>';
1005
}
1006
if(defined('ADMIN_URL')) {
1007
	echo '<form action="'.ADMIN_URL.'/">';
1008
	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
1009
	echo '</form>';
1010
}
1011 1457 Luisehahne
1012 1765 Luisehahne
echo "<br /><br /></div>
1013
</div>
1014
</div>
1015
</body>
1016
</html>
1017
";
1018
exit();