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