Project

General

Profile

1 1457 Luisehahne
<?php
2
/**
3
 *
4
 * @category        backend
5
 * @package         installation
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @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
@require_once('config.php');
19
20 1484 Luisehahne
require_once(WB_PATH.'/framework/functions.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
$admin = new admin('Addons', 'modules', false, false);
23
24
/* display a status message on the screen **************************************
25
 * @param string $message: the message to show
26
 * @param string $class:   kind of message as a css-class
27
 * @param string $element: witch HTML-tag use to cover the message
28
 * @return void
29
 */
30
function status_msg($message, $class='check', $element='span')
31
{
32 1457 Luisehahne
	// returns a status message
33 1484 Luisehahne
	$msg  = '<'.$element.' class="'.$class.'">';
34 1532 Luisehahne
	$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>';
35 1484 Luisehahne
	$msg .= $message.'</'.$element.'>';
36
	echo $msg;
37 1457 Luisehahne
}
38
39
// database tables including in WB package
40
$table_list = array (
41
    'settings','groups','addons','pages','sections','search','users',
42
    'mod_captcha_control','mod_code','mod_droplets','mod_form_fields',
43
    'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link',
44
    'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
45
    'mod_output_filter','mod_wrapper','mod_wysiwyg'
46
);
47
48 1484 Luisehahne
$OK            = ' <span class="ok">OK</span> ';
49
$FAIL          = ' <span class="error">FAILED</span> ';
50
$DEFAULT_THEME = 'wb_theme';
51 1532 Luisehahne
$stepID = 1;
52
$dirRemove = array(
53 1484 Luisehahne
/*
54
			'[TEMPLATE]/allcss/',
55
			'[TEMPLATE]/blank/',
56
			'[TEMPLATE]/round/',
57
			'[TEMPLATE]/simple/',
58
*/
59
		 );
60
61 1532 Luisehahne
$filesRemove['0'] = array(
62 1484 Luisehahne
63 1525 Luisehahne
			'[ADMIN]/preferences/details.php',
64
			'[ADMIN]/preferences/email.php',
65 1532 Luisehahne
			'[ADMIN]/preferences/password.php'
66 1525 Luisehahne
67 1532 Luisehahne
		 );
68
69
$filesRemove['1'] = array(
70
71 1529 Luisehahne
			'[TEMPLATE]/argos_theme/templates/access.htt',
72
			'[TEMPLATE]/argos_theme/templates/addons.htt',
73
			'[TEMPLATE]/argos_theme/templates/admintools.htt',
74
			'[TEMPLATE]/argos_theme/templates/error.htt',
75
			'[TEMPLATE]/argos_theme/templates/groups.htt',
76
			'[TEMPLATE]/argos_theme/templates/groups_form.htt',
77
			'[TEMPLATE]/argos_theme/templates/languages.htt',
78
			'[TEMPLATE]/argos_theme/templates/languages_details.htt',
79
			'[TEMPLATE]/argos_theme/templates/login.htt',
80
			'[TEMPLATE]/argos_theme/templates/login_forgot.htt',
81
			'[TEMPLATE]/argos_theme/templates/media.htt',
82
			'[TEMPLATE]/argos_theme/templates/media_browse.htt',
83
			'[TEMPLATE]/argos_theme/templates/media_rename.htt',
84
			'[TEMPLATE]/argos_theme/templates/modules.htt',
85
			'[TEMPLATE]/argos_theme/templates/modules_details.htt',
86
			'[TEMPLATE]/argos_theme/templates/pages.htt',
87
			'[TEMPLATE]/argos_theme/templates/pages_modify.htt',
88
			'[TEMPLATE]/argos_theme/templates/pages_sections.htt',
89
			'[TEMPLATE]/argos_theme/templates/pages_settings.htt',
90
			'[TEMPLATE]/argos_theme/templates/preferences.htt',
91
			'[TEMPLATE]/argos_theme/templates/setparameter.htt',
92
			'[TEMPLATE]/argos_theme/templates/settings.htt',
93
			'[TEMPLATE]/argos_theme/templates/start.htt',
94
			'[TEMPLATE]/argos_theme/templates/success.htt',
95
			'[TEMPLATE]/argos_theme/templates/templates.htt',
96
			'[TEMPLATE]/argos_theme/templates/templates_details.htt',
97
			'[TEMPLATE]/argos_theme/templates/users.htt',
98
			'[TEMPLATE]/argos_theme/templates/users_form.htt',
99
100
			'[TEMPLATE]/wb_theme/templates/access.htt',
101
			'[TEMPLATE]/wb_theme/templates/addons.htt',
102
			'[TEMPLATE]/wb_theme/templates/admintools.htt',
103
			'[TEMPLATE]/wb_theme/templates/error.htt',
104
			'[TEMPLATE]/wb_theme/templates/groups.htt',
105
			'[TEMPLATE]/wb_theme/templates/groups_form.htt',
106
			'[TEMPLATE]/wb_theme/templates/languages.htt',
107
			'[TEMPLATE]/wb_theme/templates/languages_details.htt',
108
			'[TEMPLATE]/wb_theme/templates/login.htt',
109
			'[TEMPLATE]/wb_theme/templates/login_forgot.htt',
110
			'[TEMPLATE]/wb_theme/templates/media.htt',
111
			'[TEMPLATE]/wb_theme/templates/media_browse.htt',
112
			'[TEMPLATE]/wb_theme/templates/media_rename.htt',
113
			'[TEMPLATE]/wb_theme/templates/modules.htt',
114
			'[TEMPLATE]/wb_theme/templates/modules_details.htt',
115
			'[TEMPLATE]/wb_theme/templates/pages.htt',
116
			'[TEMPLATE]/wb_theme/templates/pages_modify.htt',
117
			'[TEMPLATE]/wb_theme/templates/pages_sections.htt',
118
			'[TEMPLATE]/wb_theme/templates/pages_settings.htt',
119
			'[TEMPLATE]/wb_theme/templates/preferences.htt',
120
			'[TEMPLATE]/wb_theme/templates/setparameter.htt',
121
			'[TEMPLATE]/wb_theme/templates/settings.htt',
122
			'[TEMPLATE]/wb_theme/templates/start.htt',
123
			'[TEMPLATE]/wb_theme/templates/success.htt',
124
			'[TEMPLATE]/wb_theme/templates/templates.htt',
125
			'[TEMPLATE]/wb_theme/templates/templates_details.htt',
126
			'[TEMPLATE]/wb_theme/templates/users.htt',
127
			'[TEMPLATE]/wb_theme/templates/users_form.htt',
128
129 1525 Luisehahne
		 );
130
131 1457 Luisehahne
// analyze/check database tables
132
function mysqlCheckTables( $dbName )
133
{
134
    global $table_list;
135
    $table_prefix = TABLE_PREFIX;
136
    $sql = "SHOW TABLES FROM " . $dbName;
137
    $result = @mysql_query( $sql );
138
    $data = array();
139
    $x = 0;
140
141
    while( ( $row = @mysql_fetch_array( $result, MYSQL_NUM ) ) == true )
142
    {
143
        $tmp = str_replace($table_prefix, '', $row[0]);
144
145
        if( stristr( $row[0], $table_prefix )&& in_array($tmp,$table_list) )
146
        {
147
            $sql = "CHECK TABLE " . $dbName . '.' . $row[0];
148
            $analyze = @mysql_query( $sql );
149
            $rowFetch = @mysql_fetch_array( $analyze, MYSQL_ASSOC );
150
            $data[$x]['Op'] = $rowFetch["Op"];
151
            $data[$x]['Msg_type'] = $rowFetch["Msg_type"];
152
            $msgColor = '<span class="error">';
153
            $data[$x]['Table'] = $row[0];
154
           // print  " ";
155
            $msgColor = ($rowFetch["Msg_text"] == 'OK') ? '<span class="ok">' : '<span class="error">';
156
            $data[$x]['Msg_text'] = $msgColor.$rowFetch["Msg_text"].'</span>';
157
           // print  "<br />";
158
            $x++;
159
        }
160
    }
161
    return $data;
162
}
163
164
// check existings tables for upgrade or install
165
function check_wb_tables()
166
{
167
    global $database,$table_list;
168
169
 // if prefix inludes '_' or '%'
170
 $search_for = addcslashes ( TABLE_PREFIX, '%_' );
171
 $get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
172
173
        // $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
174
        $all_tables = array();
175
        if($get_result->numRows() > 0)
176
        {
177
            while ($data = $get_result->fetchRow())
178
            {
179
                $tmp = str_replace(TABLE_PREFIX, '', $data[0]);
180
                if(in_array($tmp,$table_list))
181
                {
182
                    $all_tables[] = $tmp;
183
                }
184
            }
185
        }
186
     return $all_tables;
187
}
188
189
// check existing tables
190
$all_tables = check_wb_tables();
191
192
?>
193
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
194
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
195
<head>
196
<title>Upgrade script</title>
197
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
198
<style type="text/css">
199
html { overflow: -moz-scrollbars-vertical; /* Force firefox to always show room for a vertical scrollbar */ }
200
201
body {
202
	margin:0;
203
	padding:0;
204
	border:0;
205
	background: #EBF7FC;
206
	color:#000;
207
	font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
208
	font-size: small;
209
	height:101%;
210
}
211
212
#container {
213
	width:85%;
214
	background: #A8BCCB url(templates/wb_theme/images/background.png) repeat-x;
215
	border:1px solid #000;
216
	color:#000;
217
	margin:2em auto;
218
	padding:0 15px;
219
	min-height: 500px;
220
	text-align:left;
221
}
222
223
p { line-height:1.5em; }
224
225 1532 Luisehahne
form {
226
	display: inline-block;
227
	line-height: 20px;
228
	vertical-align: baseline;
229
}
230
input[type="submit"].restart {
231
	background-color: #FFDBDB;
232
	font-weight: bold;
233
}
234
235 1457 Luisehahne
h1,h2,h3,h4,h5,h6 {
236
	font-family: Verdana, Arial, Helvetica, sans-serif;
237
	color: #369;
238
	margin-top: 1.0em;
239
	margin-bottom: 0.1em;
240
}
241
242
h1 { font-size:150%; }
243
h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
244
h3 { font-size: 120%; }
245
246
.ok, .error { font-weight:bold; }
247
.ok { color:green; }
248
.error { color:red; }
249
.check { color:#555; }
250
251
.warning {
252
	width: 98%;
253
	background:#FFDBDB;
254
	padding:0.2em;
255
	margin-top:0.5em;
256
	border: 1px solid black;
257
}
258
.info {
259
	width: 98%;
260
	background:#99CC99;
261
	padding:0.2em;
262
	margin-top:0.5em;
263
	border: 1px solid black;
264
}
265
266
</style>
267
</head>
268
<body>
269
<div id="container">
270
<img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
271
<h1>WebsiteBaker Upgrade</h1>
272
<?php
273 1525 Luisehahne
	if( version_compare( WB_VERSION, '2.7', '<' )) {
274 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');
275 1457 Luisehahne
		echo '<br /><br />';
276
		echo "</div>
277
		</body>
278
		</html>
279
		";
280
		exit();
281
	}
282 1532 Luisehahne
283
$oldVersion  = 'Version '.WB_VERSION;
284
$oldVersion .= (defined('WB_SP') ? ' '.WB_SP : '');
285
$oldVersion .= (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
286
$newVersion  = 'Version '.VERSION;
287
$newVersion .= (defined('SP') ? ' '.SP : '');
288
$newVersion .= (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
289
// set addition settings if not exists, otherwise upgrade will be breaks
290
if(!defined('WB_SP')) { define('WB_SP',''); }
291
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
292
293 1457 Luisehahne
?>
294 1532 Luisehahne
<p>This script upgrades an existing WebsiteBaker <strong> <?php echo $oldVersion; ?></strong> installation to the <strong> <?php echo $newVersion ?> </strong>.<br />The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
295 1457 Luisehahne
296
<?php
297
/**
298
 * Check if disclaimer was accepted
299
 */
300
if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
301
<h2>Step 1: Backup your files</h2>
302
<p>It is highly recommended to <strong>create a manual backup</strong> of the entire <strong>/pages 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>
303
304 1532 Luisehahne
<form name="send" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
305 1457 Luisehahne
<textarea cols="80" 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 /pages folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
306
<br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" />&nbsp;I confirm that a manual backup of the /pages folder and the MySQL database was created.
307
<br /><br /><input name="send" type="submit" value="Start upgrade script" />
308
</form>
309
<br />
310
311
<?php
312
	status_msg('<strong>Notice:</strong><br />You need to confirm that you have created a manual backup of the /pages directory and the MySQL database before you can proceed.', 'warning', 'div');
313
	echo '<br /><br />';
314
    echo "</div>
315
    </body>
316
    </html>
317
    ";
318
	exit();
319
}
320
321 1532 Luisehahne
echo '<h2>Step '.(++$stepID).' : Updating database entries</h2>';
322
323 1457 Luisehahne
// function to add a var/value-pair into settings-table
324
function db_add_key_value($key, $value) {
325
	global $database; global $OK; global $FAIL;
326
	$table = TABLE_PREFIX.'settings';
327
	$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
328
	if($query->numRows() > 0) {
329
		echo "$key: already exists. $OK.<br />";
330
		return true;
331
	} else {
332
		$database->query("INSERT INTO $table (name,value) VALUES ('$key', '$value')");
333
		echo (mysql_error()?mysql_error().'<br />':'');
334
		$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
335
		if($query->numRows() > 0) {
336
			echo "$key: $OK.<br />";
337
			return true;
338
		} else {
339
			echo "$key: $FAIL!<br />";
340
			return false;
341
		}
342
	}
343
}
344
345
// function to add a new field into a table
346
function db_add_field($field, $table, $desc) {
347
	global $database; global $OK; global $FAIL;
348
	$table = TABLE_PREFIX.$table;
349
	$query = $database->query("DESCRIBE $table '$field'");
350
	if($query->numRows() == 0) { // add field
351
		$query = $database->query("ALTER TABLE $table ADD $field $desc");
352
		echo (mysql_error()?mysql_error().'<br />':'');
353
		$query = $database->query("DESCRIBE $table '$field'");
354
		echo (mysql_error()?mysql_error().'<br />':'');
355
		if($query->numRows() > 0) {
356
			echo "'$field' added. $OK.<br />";
357
		} else {
358
			echo "adding '$field' $FAIL!<br />";
359
		}
360
	} else {
361
		echo "'$field' already exists. $OK.<br />";
362
	}
363
}
364
365
/**********************************************************
366
 *  - Adding field default_theme to settings table
367
 */
368
echo "<br />Adding default_theme to settings table<br />";
369 1484 Luisehahne
db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
370 1457 Luisehahne
/**********************************************************
371
 *  - install droplets
372
 */
373
    $drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
374
    echo $drops;
375
376 1533 Luisehahne
     $file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
377 1457 Luisehahne
     require_once (WB_PATH."/modules/droplets/".$file_name);
378
379
// check again all tables, to get a new array
380
 if(sizeof($all_tables) < 22) { $all_tables = check_wb_tables(); }
381
/**********************************************************
382
 *  - check tables comin with WebsiteBaker
383
 */
384
    $check_text = 'total ';
385
    // $check_tables = mysqlCheckTables( DB_NAME ) ;
386
387
    if(sizeof($all_tables) == 22)
388
    {
389
        echo '<h4>NOTICE: Your database '.DB_NAME.' has '.sizeof($all_tables).' '.$check_text.' tables from '.sizeof($table_list).' included in package '.$OK.'</h4>';
390
    }
391
    else
392
    {
393
        status_msg('<strong>WARNING:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
394
    	echo '<h4>Missing required tables. You can install them in backend->addons->modules->advanced. Then again run upgrade-script.php</h4>';
395
        $result = array_diff ( $table_list, $all_tables );
396
        echo '<h4 class="warning"><br />';
397
        while ( list ( $key, $val ) = each ( $result ) )
398
        {
399
            echo TABLE_PREFIX.$val.' '.$FAIL.'<br>';
400
        }
401
        echo '<br /></h4>';
402
    	echo '<br /><form action="'. $_SERVER['PHP_SELF'] .'">';
403
    	echo '<input type="submit" value="kick me back" style="float:left;" />';
404
    	echo '</form>';
405
        if(defined('ADMIN_URL'))
406
        {
407
        	echo '<form action="'.ADMIN_URL.'" target="_self">';
408
        	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
409
        	echo '</form>';
410
        }
411
        echo "<br /><br /></div>
412
        </body>
413
        </html>
414
        ";
415
        exit();
416
    }
417
418
/**********************************************************
419
 *  - Adding field sec_anchor to settings table
420
 */
421
echo "<br />Adding sec_anchor to settings table<br />";
422
$cfg = array(
423
	'sec_anchor' => 'wb_'
424
);
425
foreach($cfg as $key=>$value) {
426
	db_add_key_value($key, $value);
427
}
428
429
/**********************************************************
430
 *  - Adding redirect timer to settings table
431
 */
432
echo "<br />Adding redirect timer to settings table<br />";
433
$cfg = array(
434
	'redirect_timer' => '1500'
435
);
436
foreach($cfg as $key=>$value) {
437
	db_add_key_value($key, $value);
438
}
439
440
/**********************************************************
441 1532 Luisehahne
 *  - Adding rename_files_on_upload to settings table
442
 */
443
echo "<br />Updating rename_files_on_upload to settings table<br />";
444
$cfg = array(
445
	'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js'
446
);
447
db_update_key_value('settings', 'rename_files_on_upload', $cfg['rename_files_on_upload']);
448
449
/**********************************************************
450 1457 Luisehahne
 *  - Adding mediasettings to settings table
451
 */
452
echo "<br />Adding mediasettings to settings table<br />";
453
$cfg = array(
454 1476 Luisehahne
	'mediasettings' => '',
455 1457 Luisehahne
);
456 1484 Luisehahne
457 1457 Luisehahne
foreach($cfg as $key=>$value) {
458
	db_add_key_value($key, $value);
459
}
460
461
/**********************************************************
462
 *  - Adding fingerprint_with_ip_octets to settings table
463
 */
464
echo "<br />Adding fingerprint_with_ip_octets to settings table<br />";
465
$cfg = array(
466 1476 Luisehahne
	'fingerprint_with_ip_octets' => '2',
467
	'secure_form_module' => ''
468 1457 Luisehahne
);
469
foreach($cfg as $key=>$value) {
470
	db_add_key_value($key, $value);
471
}
472
473
/**********************************************************
474
 *  - Add field "redirect_type" to table "mod_menu_link"
475
 */
476
echo "<br />Adding field redirect_type to mod_menu_link table<br />";
477
db_add_field('redirect_type', 'mod_menu_link', "INT NOT NULL DEFAULT '302' AFTER `target_page_id`");
478
479 1525 Luisehahne
if (version_compare(WB_VERSION, '2.8') < 0)
480 1457 Luisehahne
{
481
    /**********************************************************
482
     *  - Update search no results database filed to create
483
     *  valid XHTML if search is empty
484
     */
485
    echo "<br />Updating database field `no_results` of search table: ";
486
    $search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
487
    $sql = "UPDATE `" . TABLE_PREFIX . "search` SET `value` = '$search_no_results' WHERE `name`= 'no_results'";
488
    $database->query($sql);
489
    echo ($database->query($sql)) ? " $OK<br />" : " $FAIL<br />";
490
    /**********************************************************
491
     *  - Update settings of News Modul
492
     */
493
494
    // These are the default setting
495
    $header = '<table cellpadding=\"0\" cellspacing=\"0\" class=\"loop-header\">'."\n";
496
    $post_loop = '<tr class=\"post_top\">
497
<td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
498
<td class=\"post_date\">[PUBLISHED_TIME], [PUBLISHED_DATE]</td>
499
</tr>
500
<tr>
501
<td class=\"post_short\" colspan=\"2\">
502
[SHORT]
503
<span style=\"visibility:[SHOW_READ_MORE];\"><a href=\"[LINK]\">[TEXT_READ_MORE]</a></span>
504
</td>
505
</tr>';
506
    $footer = '</table>
507
<table cellpadding="0" cellspacing="0" class="page-header" style="display: [DISPLAY_PREVIOUS_NEXT_LINKS]">
508
<tr>
509
<td class="page-left">[PREVIOUS_PAGE_LINK]</td>
510
<td class="page-center">[OF]</td>
511
<td class="page-right">[NEXT_PAGE_LINK]</td>
512
</tr>
513
</table>';
514
    $post_header = addslashes('<table cellpadding="0" cellspacing="0" class="post-header">
515
<tr>
516
<td><h1>[TITLE]</h1></td>
517
<td rowspan="3" style="display: [DISPLAY_IMAGE]">[GROUP_IMAGE]</td>
518
</tr>
519
<tr>
520
<td class="public-info"><b>[TEXT_POSTED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [PUBLISHED_DATE]</b></td>
521
</tr>
522
<tr style="display: [DISPLAY_GROUP]">
523
<td class="group-page"><a href="[BACK]">[PAGE_TITLE]</a> &gt;&gt; <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
524
</tr>
525
</table>');
526
    $post_footer = '<p>[TEXT_LAST_CHANGED]: [MODI_DATE] [TEXT_AT] [MODI_TIME]</p>
527
<a href=\"[BACK]\">[TEXT_BACK]</a>';
528
    $comments_header = addslashes('<br /><br />
529
<h2>[TEXT_COMMENTS]</h2>
530
<table cellpadding="2" cellspacing="0" class="comment-header">');
531
    $comments_loop = addslashes('<tr>
532
<td class="comment_title">[TITLE]</td>
533
<td class="comment_info">[TEXT_BY] [DISPLAY_NAME] [TEXT_ON] [DATE] [TEXT_AT] [TIME]</td>
534
</tr>
535
<tr>
536
<td colspan="2" class="comment_text">[COMMENT]</td>
537
</tr>');
538
    $comments_footer = '</table>
539
<br /><a href=\"[ADD_COMMENT_URL]\">[TEXT_ADD_COMMENT]</a>';
540
    $comments_page = '<h1>[TEXT_COMMENT]</h1>
541
<h2>[POST_TITLE]</h2>
542
<br />';
543
544 1477 Luisehahne
	if(in_array('mod_news_settings', $all_tables))
545
	{
546
	   // Insert default settings into database
547
	   $query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
548
	   if($query_dates->numRows() > 1)
549
	   {
550
	        while($result = $query_dates->fetchRow())
551
	        {
552 1457 Luisehahne
553 1477 Luisehahne
	        	echo "<br /><u>Add default settings to database for news section_id= ".$result['section_id']."</u><br />";
554
	        	$section_id = $result['section_id'];
555 1457 Luisehahne
556 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
557
	        		echo 'Database data header added successfully';
558
	        	}
559
	        	echo mysql_error().'<br />';
560 1457 Luisehahne
561 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
562
	        		echo 'Database data post_loop added successfully';
563
	        	}
564
	        	echo mysql_error().'<br />';
565 1457 Luisehahne
566 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `footer` = '$footer' WHERE `section_id` = $section_id")) {
567
	        		echo 'Database data footer added successfully';
568
	        	}
569
	        	echo mysql_error().'<br />';
570 1457 Luisehahne
571 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
572
	        		echo 'Database data post_header added successfully';
573
	        	}
574
	        	echo mysql_error().'<br />';
575 1457 Luisehahne
576 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
577
	        		echo 'Database data post_footer added successfully';
578
	        	}
579
	        	echo mysql_error().'<br />';
580 1457 Luisehahne
581 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
582
	        		echo 'Database data comments_header added successfully';
583
	        	}
584
	        	echo mysql_error().'<br />';
585 1457 Luisehahne
586 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_loop` = '$comments_loop' WHERE `section_id` = $section_id")) {
587
	        		echo 'Database data comments_loop added successfully';
588
	        	}
589
	        	echo mysql_error().'<br />';
590 1457 Luisehahne
591 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_footer` = '$comments_footer' WHERE `section_id` = $section_id")) {
592
	        		echo 'Database data comments_footer added successfully';
593
	        	}
594
	        	echo mysql_error().'<br />';
595 1457 Luisehahne
596 1477 Luisehahne
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_page` = '$comments_page' WHERE `section_id` = $section_id")) {
597
	        		echo 'Database data comments_page added successfully';
598
	        	}
599
	        	echo mysql_error().'<br />';
600 1457 Luisehahne
601 1477 Luisehahne
	        }
602
	     }
603
	   }
604 1457 Luisehahne
}
605
/**********************************************************
606
 * upgrade media folder index protect files
607
 */
608
$dir = (WB_PATH.MEDIA_DIRECTORY);
609 1484 Luisehahne
echo '<h4>Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files</h4><br />';
610 1457 Luisehahne
$array = rebuildFolderProtectFile($dir);
611
if( sizeof( $array ) ){
612 1484 Luisehahne
	print '<br /><strong>Upgrade '.sizeof( $array ).' '.MEDIA_DIRECTORY.'/ protect files</strong>'." $OK<br />";
613 1457 Luisehahne
} else {
614 1484 Luisehahne
	print '<br /><strong>Upgrade '.MEDIA_DIRECTORY.'/ protect files</strong>'." $FAIL!<br />";
615 1457 Luisehahne
	print implode ('<br />',$array);
616
}
617
618
/**********************************************************
619
 * upgrade news if newer version is available
620
 */
621
	if(file_exists(WB_PATH.'/modules/news/upgrade.php'))
622
	{
623
		$currNewsVersion = get_modul_version ('news', false);
624
		$newNewsVersion =  get_modul_version ('news', true);
625
		if((version_compare($currNewsVersion, $newNewsVersion) <= 0)) {
626
			echo '<h4>Upgrade existings basically news module</h4><br />';
627
			// change old postfiles to new postfiles
628
			require_once(WB_PATH."/modules/news/upgrade.php");
629
		}
630
	}
631
632 1484 Luisehahne
/* *****************************************************************************
633
 * - check for deprecated / never needed files
634
 */
635 1532 Luisehahne
if(sizeof($filesRemove)) {
636 1484 Luisehahne
?>
637 1532 Luisehahne
<h2>Step <?php echo (++$stepID) ?>: Remove deprecated and old files</h2>
638 1484 Luisehahne
<?php
639 1532 Luisehahne
}
640 1484 Luisehahne
	$searches = array(
641
		'[ADMIN]',
642
		'[MEDIA]',
643 1525 Luisehahne
		'[PAGES]',
644 1533 Luisehahne
		'[FRAMEWORK]',
645
		'[MODULES]',
646 1525 Luisehahne
		'[TEMPLATE]'
647 1484 Luisehahne
	);
648
	$replacements = array(
649 1525 Luisehahne
		substr(ADMIN_PATH, strlen(WB_PATH)+1),
650 1484 Luisehahne
		MEDIA_DIRECTORY,
651 1525 Luisehahne
		PAGES_DIRECTORY,
652 1533 Luisehahne
		'/framework',
653
		'/modules',
654
		'/templates'
655 1484 Luisehahne
	);
656
657 1532 Luisehahne
	foreach( $filesRemove as $filesId )
658 1484 Luisehahne
	{
659 1532 Luisehahne
		$msg = '';
660
		foreach( $filesId as $file )
661
		{
662
			$file = str_replace($searches, $replacements, $file);
663
			$file = WB_PATH.'/'.$file;
664
			if( file_exists($file) )
665
			{ // try to unlink file
666
				if(!is_writable( $file ) || !unlink($file))
667
				{ // save in err-list, if failed
668
					$msg .= $file.'<br />';
669
				}
670 1484 Luisehahne
			}
671
		}
672 1532 Luisehahne
673
		if($msg != '')
674
		{
675
			$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
676
				    can not be removed automatically.<br /><br />Please delete them
677
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
678
	        status_msg($msg, 'error warning', 'div');
679
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
680
681
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
682
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
683
			echo '</form>';
684
			echo '<br /><br /></div></body></html>';
685
			exit;
686
		}
687 1484 Luisehahne
	}
688
689 1532 Luisehahne
690 1457 Luisehahne
/**********************************************************
691 1525 Luisehahne
 * - check for deprecated / never needed files
692
 */
693 1532 Luisehahne
if(sizeof($dirRemove)) {
694 1525 Luisehahne
?>
695 1532 Luisehahne
<h2>Step  <?php echo (++$stepID) ?> : Remove deprecated and old folders</h2>
696 1525 Luisehahne
<?php
697
698
	$searches = array(
699
		'[ADMIN]',
700
		'[MEDIA]',
701
		'[PAGES]',
702
		'[TEMPLATE]'
703
	);
704
	$replacements = array(
705
		substr(ADMIN_PATH, strlen(WB_PATH)+1),
706
		MEDIA_DIRECTORY,
707
		PAGES_DIRECTORY,
708
		'/templates',
709
	);
710
711
	$msg = '';
712 1532 Luisehahne
	foreach( $dirRemove as $dir )
713 1525 Luisehahne
	{
714
		$dir = str_replace($searches, $replacements, $dir);
715
		$dir = WB_PATH.'/'.$dir;
716
		if( is_dir( $dir ))
717
		{ // try to delete dir
718
			if(!rm_full_dir($dir))
719
			{ // save in err-list, if failed
720
				$msg .= $dir.'<br />';
721
			}
722
		}
723
	}
724
	if($msg != '')
725
	{
726 1532 Luisehahne
		$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
727 1525 Luisehahne
			    can not be removed automatically.<br /><br />Please delete them
728 1532 Luisehahne
				using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
729 1525 Luisehahne
        status_msg($msg, 'error warning', 'div');
730 1532 Luisehahne
		echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
731
732
		echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
733
		echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
734
		echo '</form>';
735
		echo '<br /><br /></div></body></html>';
736
		exit;
737 1525 Luisehahne
	}
738 1532 Luisehahne
739
}
740
741
?>
742
<h2>Step <?php echo (++$stepID) ?> : Reload all addons database entry (no upgrade)</h2>
743
<?php
744 1525 Luisehahne
/**********************************************************
745 1457 Luisehahne
 *  - Reload all addons
746
 */
747
748
////delete modules
749
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
750
// Load all modules
751
if( ($handle = opendir(WB_PATH.'/modules/')) ) {
752
	while(false !== ($file = readdir($handle))) {
753
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
754 1477 Luisehahne
			load_module(WB_PATH.'/modules/'.$file );
755 1484 Luisehahne
		   // 	upgrade_module($file, true);
756 1457 Luisehahne
		}
757
	}
758
	closedir($handle);
759
}
760
echo '<br />Modules reloaded<br />';
761
762
////delete templates
763
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
764
// Load all templates
765
if( ($handle = opendir(WB_PATH.'/templates/')) ) {
766
	while(false !== ($file = readdir($handle))) {
767
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
768
			load_template(WB_PATH.'/templates/'.$file);
769
		}
770
	}
771
	closedir($handle);
772
}
773
echo '<br />Templates reloaded<br />';
774
775
////delete languages
776
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
777
// Load all languages
778
if( ($handle = opendir(WB_PATH.'/languages/')) ) {
779
	while(false !== ($file = readdir($handle))) {
780
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
781
			load_language(WB_PATH.'/languages/'.$file);
782
		}
783
	}
784
	closedir($handle);
785
}
786
echo '<br />Languages reloaded<br />';
787
788
/**********************************************************
789
 *  - End of upgrade script
790
 */
791
792
// require(WB_PATH.'/framework/initialize.php');
793
794 1484 Luisehahne
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
795 1457 Luisehahne
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
796 1532 Luisehahne
/**********************************************************
797
 *  - Set Version to new Version
798
 */
799
echo '<br />Update database version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : ';
800
// echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
801
db_update_key_value('settings', 'wb_version', VERSION);
802
db_update_key_value('settings', 'wb_revision', REVISION);
803
db_update_key_value('settings', 'wb_sp', SP);
804 1457 Luisehahne
805
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
806
status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
807
// show buttons to go to the backend or frontend
808
echo '<br />';
809 1532 Luisehahne
810 1457 Luisehahne
if(defined('WB_URL')) {
811 1532 Luisehahne
	echo '<form action="'.WB_URL.'/">';
812
	echo '&nbsp;<input type="submit" value="kick me to the Frontend" />';
813 1457 Luisehahne
	echo '</form>';
814
}
815
if(defined('ADMIN_URL')) {
816 1532 Luisehahne
	echo '<form action="'.ADMIN_URL.'/">';
817 1457 Luisehahne
	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
818
	echo '</form>';
819
}
820
821 1532 Luisehahne
?><br /><br />
822 1457 Luisehahne
</div>
823
</body>
824 714 Ruebenwurz
</html>