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