Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        backend
5
 * @package         installation
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id: upgrade-script.php 1477 2011-07-21 02:47:28Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/upgrade-script.php $
15
 * @lastmodified    $Date: 2011-07-21 04:47:28 +0200 (Thu, 21 Jul 2011) $
16
 *
17
 */
18

    
19
@require_once('config.php');
20

    
21
// this function checks the basic configurations of an existing WB intallation
22
function status_msg($message, $class='check', $element='span') {
23
	// returns a status message
24
	echo '<'.$element .' class="' .$class .'">' .$message .'</' .$element.'>';
25
}
26

    
27
// database tables including in WB package
28
$table_list = array (
29
    'settings','groups','addons','pages','sections','search','users',
30
    'mod_captcha_control','mod_code','mod_droplets','mod_form_fields',
31
    'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link',
32
    'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
33
    'mod_output_filter','mod_wrapper','mod_wysiwyg'
34
);
35

    
36
// analyze/check database tables
37
function mysqlCheckTables( $dbName )
38
{
39
    global $table_list;
40
    $table_prefix = TABLE_PREFIX;
41
    $sql = "SHOW TABLES FROM " . $dbName;
42
    $result = @mysql_query( $sql );
43
    $data = array();
44
    $x = 0;
45

    
46
    while( ( $row = @mysql_fetch_array( $result, MYSQL_NUM ) ) == true )
47
    {
48
        $tmp = str_replace($table_prefix, '', $row[0]);
49

    
50
        if( stristr( $row[0], $table_prefix )&& in_array($tmp,$table_list) )
51
        {
52
            $sql = "CHECK TABLE " . $dbName . '.' . $row[0];
53
            $analyze = @mysql_query( $sql );
54
            $rowFetch = @mysql_fetch_array( $analyze, MYSQL_ASSOC );
55
            $data[$x]['Op'] = $rowFetch["Op"];
56
            $data[$x]['Msg_type'] = $rowFetch["Msg_type"];
57
            $msgColor = '<span class="error">';
58
            $data[$x]['Table'] = $row[0];
59
           // print  " ";
60
            $msgColor = ($rowFetch["Msg_text"] == 'OK') ? '<span class="ok">' : '<span class="error">';
61
            $data[$x]['Msg_text'] = $msgColor.$rowFetch["Msg_text"].'</span>';
62
           // print  "<br />";
63
            $x++;
64
        }
65
    }
66

    
67

    
68

    
69

    
70
    return $data;
71
}
72

    
73

    
74
// check existings tables for upgrade or install
75
function check_wb_tables()
76
{
77
    global $database,$table_list;
78

    
79
 // if prefix inludes '_' or '%'
80
 $search_for = addcslashes ( TABLE_PREFIX, '%_' );
81
 $get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
82

    
83
        // $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
84
        $all_tables = array();
85
        if($get_result->numRows() > 0)
86
        {
87
            while ($data = $get_result->fetchRow())
88
            {
89
                $tmp = str_replace(TABLE_PREFIX, '', $data[0]);
90
                if(in_array($tmp,$table_list))
91
                {
92
                    $all_tables[] = $tmp;
93
                }
94
            }
95
        }
96
     return $all_tables;
97
}
98

    
99
// check existing tables
100
$all_tables = check_wb_tables();
101

    
102
// only for array tests
103
function show_array($array=array())
104
{
105
    print '<pre>';
106
    print_r ($array);
107
    print '</pre>';
108
}
109

    
110
require_once(WB_PATH.'/framework/functions.php');
111
require_once(WB_PATH.'/framework/class.admin.php');
112
$admin = new admin('Addons', 'modules', false, false);
113
?>
114
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
115
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
116
<head>
117
<title>Upgrade script</title>
118
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
119
<style type="text/css">
120
html { overflow: -moz-scrollbars-vertical; /* Force firefox to always show room for a vertical scrollbar */ }
121

    
122
body {
123
	margin:0;
124
	padding:0;
125
	border:0;
126
	background: #EBF7FC;
127
	color:#000;
128
	font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
129
	font-size: small;
130
	height:101%;
131
}
132

    
133
#container {
134
	width:85%;
135
	background: #A8BCCB url(templates/wb_theme/images/background.png) repeat-x;
136
	border:1px solid #000;
137
	color:#000;
138
	margin:2em auto;
139
	padding:0 15px;
140
	min-height: 500px;
141
	text-align:left;
142
}
143

    
144
p { line-height:1.5em; }
145

    
146
h1,h2,h3,h4,h5,h6 {
147
	font-family: Verdana, Arial, Helvetica, sans-serif;
148
	color: #369;
149
	margin-top: 1.0em;
150
	margin-bottom: 0.1em;
151
}
152

    
153
h1 { font-size:150%; }
154
h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
155
h3 { font-size: 120%; }
156

    
157
.ok, .error { font-weight:bold; }
158
.ok { color:green; }
159
.error { color:red; }
160
.check { color:#555; }
161

    
162
.warning {
163
	width: 98%;
164
	background:#FFDBDB;
165
	padding:0.2em;
166
	margin-top:0.5em;
167
	border: 1px solid black;
168
}
169
.info {
170
	width: 98%;
171
	background:#99CC99;
172
	padding:0.2em;
173
	margin-top:0.5em;
174
	border: 1px solid black;
175
}
176

    
177
</style>
178
</head>
179
<body>
180
<div id="container">
181
<img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
182
<h1>WebsiteBaker Upgrade</h1>
183
<?php
184
	if( version_compare( WB_VERSION, '2.7.0', '<' )) {
185
		status_msg('<strong>Warning:</strong><br />It is not possible to upgrade from WebsiteBaker Versions before 2.7.0.<br />For upgrading to version '.VERSION.' you must upgrade first to v.2.7.0 at least!!!', 'warning', 'div');
186
		echo '<br /><br />';
187
		echo "</div>
188
		</body>
189
		</html>
190
		";
191
		exit();
192
	}
193
?>
194
<p>This script upgrades an existing WebsiteBaker <strong>Version <?php echo WB_VERSION; ?></strong> installation to the <strong>Version <?php echo VERSION ?></strong>. The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
195

    
196
<?php
197
/**
198
 * Check if disclaimer was accepted
199
 */
200
if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
201
<h2>Step 1: Backup your files</h2>
202
<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>
203

    
204
<form name="send" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
205
<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>
206
<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.
207
<br /><br /><input name="send" type="submit" value="Start upgrade script" />
208
</form>
209
<br />
210

    
211
<?php
212
	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');
213
	echo '<br /><br />';
214
    echo "</div>
215
    </body>
216
    </html>
217
    ";
218
	exit();
219
}
220
echo '<h2>Step 2: Updating database entries</h2>';
221
$OK   = '<span class="ok">OK</span>';
222
$FAIL = '<span class="error">FAILED</span>';
223

    
224
// function to add a var/value-pair into settings-table
225
function db_add_key_value($key, $value) {
226
	global $database; global $OK; global $FAIL;
227
	$table = TABLE_PREFIX.'settings';
228
	$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
229
	if($query->numRows() > 0) {
230
		echo "$key: already exists. $OK.<br />";
231
		return true;
232
	} else {
233
		$database->query("INSERT INTO $table (name,value) VALUES ('$key', '$value')");
234
		echo (mysql_error()?mysql_error().'<br />':'');
235
		$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
236
		if($query->numRows() > 0) {
237
			echo "$key: $OK.<br />";
238
			return true;
239
		} else {
240
			echo "$key: $FAIL!<br />";
241
			return false;
242
		}
243
	}
244
}
245

    
246
// function to add a new field into a table
247
function db_add_field($field, $table, $desc) {
248
	global $database; global $OK; global $FAIL;
249
	$table = TABLE_PREFIX.$table;
250
	$query = $database->query("DESCRIBE $table '$field'");
251
	if($query->numRows() == 0) { // add field
252
		$query = $database->query("ALTER TABLE $table ADD $field $desc");
253
		echo (mysql_error()?mysql_error().'<br />':'');
254
		$query = $database->query("DESCRIBE $table '$field'");
255
		echo (mysql_error()?mysql_error().'<br />':'');
256
		if($query->numRows() > 0) {
257
			echo "'$field' added. $OK.<br />";
258
		} else {
259
			echo "adding '$field' $FAIL!<br />";
260
		}
261
	} else {
262
		echo "'$field' already exists. $OK.<br />";
263
	}
264
}
265

    
266
/**********************************************************
267
 *  - Adding field default_theme to settings table
268
 */
269
echo "<br />Adding default_theme to settings table<br />";
270
$cfg = array(
271
	'default_theme' => 'wb_theme'
272
);
273

    
274
foreach($cfg as $key=>$value) {
275
	db_add_key_value($key, $value);
276
}
277

    
278
/**********************************************************
279
 *  - install droplets
280
 */
281
    $drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
282
    echo $drops;
283

    
284
     $file_name = (!in_array ( "mod_droplets", $all_tables)) ? "install.php" : "upgrade.php";
285
     require_once (WB_PATH."/modules/droplets/".$file_name);
286

    
287
// check again all tables, to get a new array
288
 if(sizeof($all_tables) < 22) { $all_tables = check_wb_tables(); }
289
/**********************************************************
290
 *  - check tables comin with WebsiteBaker
291
 */
292
    $check_text = 'total ';
293
    // $check_tables = mysqlCheckTables( DB_NAME ) ;
294

    
295
    if(sizeof($all_tables) == 22)
296
    {
297
        echo '<h4>NOTICE: Your database '.DB_NAME.' has '.sizeof($all_tables).' '.$check_text.' tables from '.sizeof($table_list).' included in package '.$OK.'</h4>';
298
    }
299
    else
300
    {
301
        status_msg('<strong>WARNING:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
302
    	echo '<h4>Missing required tables. You can install them in backend->addons->modules->advanced. Then again run upgrade-script.php</h4>';
303
        $result = array_diff ( $table_list, $all_tables );
304
        echo '<h4 class="warning"><br />';
305
        while ( list ( $key, $val ) = each ( $result ) )
306
        {
307
            echo TABLE_PREFIX.$val.' '.$FAIL.'<br>';
308
        }
309
        echo '<br /></h4>';
310
    	echo '<br /><form action="'. $_SERVER['PHP_SELF'] .'">';
311
    	echo '<input type="submit" value="kick me back" style="float:left;" />';
312
    	echo '</form>';
313
        if(defined('ADMIN_URL'))
314
        {
315
        	echo '<form action="'.ADMIN_URL.'" target="_self">';
316
        	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
317
        	echo '</form>';
318
        }
319
        echo "<br /><br /></div>
320
        </body>
321
        </html>
322
        ";
323
        exit();
324
    }
325

    
326
/**********************************************************
327
 *  - Adding field sec_anchor to settings table
328
 */
329
echo "<br />Adding sec_anchor to settings table<br />";
330
$cfg = array(
331
	'sec_anchor' => 'wb_'
332
);
333
foreach($cfg as $key=>$value) {
334
	db_add_key_value($key, $value);
335
}
336

    
337
/**********************************************************
338
 *  - Adding redirect timer to settings table
339
 */
340
echo "<br />Adding redirect timer to settings table<br />";
341
$cfg = array(
342
	'redirect_timer' => '1500'
343
);
344
foreach($cfg as $key=>$value) {
345
	db_add_key_value($key, $value);
346
}
347

    
348
/**********************************************************
349
 *  - Adding mediasettings to settings table
350
 */
351
echo "<br />Adding mediasettings to settings table<br />";
352
$cfg = array(
353
	'mediasettings' => '',
354
	'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx'
355
);
356
foreach($cfg as $key=>$value) {
357
	db_add_key_value($key, $value);
358
}
359

    
360
/**********************************************************
361
 *  - Adding fingerprint_with_ip_octets to settings table
362
 */
363
echo "<br />Adding fingerprint_with_ip_octets to settings table<br />";
364
$cfg = array(
365
	'fingerprint_with_ip_octets' => '2',
366
	'secure_form_module' => ''
367
);
368
foreach($cfg as $key=>$value) {
369
	db_add_key_value($key, $value);
370
}
371

    
372
/**********************************************************
373
 *  - Add field "redirect_type" to table "mod_menu_link"
374
 */
375
echo "<br />Adding field redirect_type to mod_menu_link table<br />";
376
db_add_field('redirect_type', 'mod_menu_link', "INT NOT NULL DEFAULT '302' AFTER `target_page_id`");
377

    
378
if (version_compare(WB_VERSION, '2.8.0') < 0)
379
{
380
    /**********************************************************
381
     *  - Update search no results database filed to create
382
     *  valid XHTML if search is empty
383
     */
384
    echo "<br />Updating database field `no_results` of search table: ";
385
    $search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
386
    $sql = "UPDATE `" . TABLE_PREFIX . "search` SET `value` = '$search_no_results' WHERE `name`= 'no_results'";
387
    $database->query($sql);
388
    echo ($database->query($sql)) ? " $OK<br />" : " $FAIL<br />";
389
    /**********************************************************
390
     *  - Update settings of News Modul
391
     */
392

    
393
    // These are the default setting
394
    $header = '<table cellpadding=\"0\" cellspacing=\"0\" class=\"loop-header\">'."\n";
395
    $post_loop = '<tr class=\"post_top\">
396
<td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
397
<td class=\"post_date\">[PUBLISHED_TIME], [PUBLISHED_DATE]</td>
398
</tr>
399
<tr>
400
<td class=\"post_short\" colspan=\"2\">
401
[SHORT]
402
<span style=\"visibility:[SHOW_READ_MORE];\"><a href=\"[LINK]\">[TEXT_READ_MORE]</a></span>
403
</td>
404
</tr>';
405
    $footer = '</table>
406
<table cellpadding="0" cellspacing="0" class="page-header" style="display: [DISPLAY_PREVIOUS_NEXT_LINKS]">
407
<tr>
408
<td class="page-left">[PREVIOUS_PAGE_LINK]</td>
409
<td class="page-center">[OF]</td>
410
<td class="page-right">[NEXT_PAGE_LINK]</td>
411
</tr>
412
</table>';
413
    $post_header = addslashes('<table cellpadding="0" cellspacing="0" class="post-header">
414
<tr>
415
<td><h1>[TITLE]</h1></td>
416
<td rowspan="3" style="display: [DISPLAY_IMAGE]">[GROUP_IMAGE]</td>
417
</tr>
418
<tr>
419
<td class="public-info"><b>[TEXT_POSTED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [PUBLISHED_DATE]</b></td>
420
</tr>
421
<tr style="display: [DISPLAY_GROUP]">
422
<td class="group-page"><a href="[BACK]">[PAGE_TITLE]</a> &gt;&gt; <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
423
</tr>
424
</table>');
425
    $post_footer = '<p>[TEXT_LAST_CHANGED]: [MODI_DATE] [TEXT_AT] [MODI_TIME]</p>
426
<a href=\"[BACK]\">[TEXT_BACK]</a>';
427
    $comments_header = addslashes('<br /><br />
428
<h2>[TEXT_COMMENTS]</h2>
429
<table cellpadding="2" cellspacing="0" class="comment-header">');
430
    $comments_loop = addslashes('<tr>
431
<td class="comment_title">[TITLE]</td>
432
<td class="comment_info">[TEXT_BY] [DISPLAY_NAME] [TEXT_ON] [DATE] [TEXT_AT] [TIME]</td>
433
</tr>
434
<tr>
435
<td colspan="2" class="comment_text">[COMMENT]</td>
436
</tr>');
437
    $comments_footer = '</table>
438
<br /><a href=\"[ADD_COMMENT_URL]\">[TEXT_ADD_COMMENT]</a>';
439
    $comments_page = '<h1>[TEXT_COMMENT]</h1>
440
<h2>[POST_TITLE]</h2>
441
<br />';
442

    
443
	if(in_array('mod_news_settings', $all_tables))
444
	{
445
	   // Insert default settings into database
446
	   $query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
447
	   if($query_dates->numRows() > 1)
448
	   {
449
	        while($result = $query_dates->fetchRow())
450
	        {
451

    
452
	        	echo "<br /><u>Add default settings to database for news section_id= ".$result['section_id']."</u><br />";
453
	        	$section_id = $result['section_id'];
454

    
455
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
456
	        		echo 'Database data header added successfully';
457
	        	}
458
	        	echo mysql_error().'<br />';
459

    
460
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
461
	        		echo 'Database data post_loop added successfully';
462
	        	}
463
	        	echo mysql_error().'<br />';
464

    
465
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `footer` = '$footer' WHERE `section_id` = $section_id")) {
466
	        		echo 'Database data footer added successfully';
467
	        	}
468
	        	echo mysql_error().'<br />';
469

    
470
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
471
	        		echo 'Database data post_header added successfully';
472
	        	}
473
	        	echo mysql_error().'<br />';
474

    
475
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
476
	        		echo 'Database data post_footer added successfully';
477
	        	}
478
	        	echo mysql_error().'<br />';
479

    
480
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
481
	        		echo 'Database data comments_header added successfully';
482
	        	}
483
	        	echo mysql_error().'<br />';
484

    
485
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_loop` = '$comments_loop' WHERE `section_id` = $section_id")) {
486
	        		echo 'Database data comments_loop added successfully';
487
	        	}
488
	        	echo mysql_error().'<br />';
489

    
490
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_footer` = '$comments_footer' WHERE `section_id` = $section_id")) {
491
	        		echo 'Database data comments_footer added successfully';
492
	        	}
493
	        	echo mysql_error().'<br />';
494

    
495
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_page` = '$comments_page' WHERE `section_id` = $section_id")) {
496
	        		echo 'Database data comments_page added successfully';
497
	        	}
498
	        	echo mysql_error().'<br />';
499

    
500
	        }
501
	     }
502
	   }
503
}
504
/**********************************************************
505
 * upgrade media folder index protect files
506
 */
507
$dir = (WB_PATH.MEDIA_DIRECTORY);
508
echo '<h4>Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
509
$array = rebuildFolderProtectFile($dir);
510
if( sizeof( $array ) ){
511
	print 'Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files'." $OK<br />";
512
} else {
513
	print 'Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files'." $FAIL!<br />";
514
	print implode ('<br />',$array);
515
}
516

    
517
/**********************************************************
518
 * upgrade news if newer version is available
519
 */
520
	if(file_exists(WB_PATH.'/modules/news/upgrade.php'))
521
	{
522
		$currNewsVersion = get_modul_version ('news', false);
523
		$newNewsVersion =  get_modul_version ('news', true);
524
		if((version_compare($currNewsVersion, $newNewsVersion) <= 0)) {
525
			echo '<h4>Upgrade existings basically news module</h4><br />';
526
			// change old postfiles to new postfiles
527
			require_once(WB_PATH."/modules/news/upgrade.php");
528
		}
529
	}
530
/**********************************************************
531
 *  - Set Version to new Version
532
 */
533
echo '<br />Update database version number to '.VERSION.' : ';
534
echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
535

    
536
/**********************************************************
537
 *  - Reload all addons
538
 */
539

    
540
////delete modules
541
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
542
// Load all modules
543
if( ($handle = opendir(WB_PATH.'/modules/')) ) {
544
	while(false !== ($file = readdir($handle))) {
545
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
546
			load_module(WB_PATH.'/modules/'.$file );
547
			upgrade_module($file, true);
548
		}
549
	}
550
	closedir($handle);
551
}
552
echo '<br />Modules reloaded<br />';
553

    
554
////delete templates
555
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
556
// Load all templates
557
if( ($handle = opendir(WB_PATH.'/templates/')) ) {
558
	while(false !== ($file = readdir($handle))) {
559
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
560
			load_template(WB_PATH.'/templates/'.$file);
561
		}
562
	}
563
	closedir($handle);
564
}
565
echo '<br />Templates reloaded<br />';
566

    
567
////delete languages
568
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
569
// Load all languages
570
if( ($handle = opendir(WB_PATH.'/languages/')) ) {
571
	while(false !== ($file = readdir($handle))) {
572
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
573
			load_language(WB_PATH.'/languages/'.$file);
574
		}
575
	}
576
	closedir($handle);
577
}
578
echo '<br />Languages reloaded<br />';
579

    
580

    
581
/**********************************************************
582
 *  - End of upgrade script
583
 */
584

    
585
// require(WB_PATH.'/framework/initialize.php');
586

    
587
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', 'wb_theme'); }
588
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
589

    
590
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
591
status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
592
// show buttons to go to the backend or frontend
593
echo '<br />';
594
if(defined('WB_URL')) {
595
	echo '<form action="'.WB_URL.'">';
596
	echo '<input type="submit" value="kick me to the Frontend" style="float:left;" />';
597
	echo '</form>';
598
}
599
if(defined('ADMIN_URL')) {
600
	echo '<form action="'.ADMIN_URL.'">';
601
	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
602
	echo '</form>';
603
}
604
echo '<p>&nbsp;</p>';
605

    
606
?>
607
</div>
608
</body>
609
</html>
(4-4/4)