Project

General

Profile

« Previous | Next » 

Revision 1457

Added by Dietmar over 13 years ago

Preparing 2.8.2 stable, last tests

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.8.2 ------------------------------------
14
25 Jun-2011 Build 1457 Dietmar Woellbrink (Luisehahne)
15
! Preparing 2.8.2 stable, last tests
14 16
10 Jun-2011 Build 1456 Dietmar Woellbrink (Luisehahne)
15 17
+ add PL languages to news and captcha_control (tks to vixrealitum)
16 18
! update PL language for WebsiteBaker (tks to vixrealitum)
branches/2.8.x/wb/media/index.php
23 23

  
24 24
*/
25 25

  
26
header('Location: ../');
27

  
28
?>
26
header('Location: ../index.php');
29 27

  
branches/2.8.x/wb/upgrade-script.php
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$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
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 bevor 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

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

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

  
349
/**********************************************************
350
 *  - Adding mediasettings to settings table
351
 */
352
echo "<br />Adding mediasettings to settings table<br />";
353
$cfg = array(
354
	'mediasettings' => ''
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' => '3'
366
);
367
foreach($cfg as $key=>$value) {
368
	db_add_key_value($key, $value);
369
}
370

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

  
377

  
378

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

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

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

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

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

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

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

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

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

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

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

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

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

  
501
        }
502
     }
503
   }
504
}
505
/**********************************************************
506
 * upgrade news if newer version is available
507
 */
508
	if(file_exists(WB_PATH.'/modules/news/upgrade.php'))
509
	{
510
		$currNewsVersion = get_modul_version ('news', false);
511
		$newNewsVersion =  get_modul_version ('news', true);
512
		if((version_compare($currNewsVersion, $newNewsVersion) <= 0)) {
513
			echo '<h4>Upgrade existings basically news module</h4><br />';
514
			// change old postfiles to new postfiles
515
			require_once(WB_PATH."/modules/news/upgrade.php");
516
		}
517
	}
518
/**********************************************************
519
 *  - Set Version to new Version
520
 */
521
echo '<br />Update database version number to '.VERSION.' : ';
522
echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
523

  
524
/**********************************************************
525
 *  - Reload all addons
526
 */
527

  
528
////delete modules
529
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
530
// Load all modules
531
if( ($handle = opendir(WB_PATH.'/modules/')) ) {
532
	while(false !== ($file = readdir($handle))) {
533
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
534
			load_module(WB_PATH.'/modules/'.$file);
535
		}
536
	}
537
	closedir($handle);
538
}
539
echo '<br />Modules reloaded<br />';
540

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

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

  
567

  
568
/**********************************************************
569
 *  - End of upgrade script
570
 */
571

  
572
// require(WB_PATH.'/framework/initialize.php');
573

  
574
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', 'wb_theme'); }
575
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
576

  
577
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
578
status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
579
// show buttons to go to the backend or frontend
580
echo '<br />';
581
if(defined('WB_URL')) {
582
	echo '<form action="'.WB_URL.'">';
583
	echo '<input type="submit" value="kick me to the Frontend" style="float:left;" />';
584
	echo '</form>';
585
}
586
if(defined('ADMIN_URL')) {
587
	echo '<form action="'.ADMIN_URL.'">';
588
	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
589
	echo '</form>';
590
}
591
echo '<p>&nbsp;</p>';
592

  
593
?>
594
</div>
595
</body>
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$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
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 bevor 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

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

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

  
349
/**********************************************************
350
 *  - Adding mediasettings to settings table
351
 */
352
echo "<br />Adding mediasettings to settings table<br />";
353
$cfg = array(
354
	'mediasettings' => ''
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' => '3'
366
);
367
foreach($cfg as $key=>$value) {
368
	db_add_key_value($key, $value);
369
}
370

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

  
377

  
378

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  
541
////delete modules
542
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
543
// Load all modules
544
if( ($handle = opendir(WB_PATH.'/modules/')) ) {
545
	while(false !== ($file = readdir($handle))) {
546
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
547
			load_module(WB_PATH.'/modules/'.$file);
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>
596 609
</html>
branches/2.8.x/wb/admin/groups/get_permissions.php
11 11
 * @platform        WebsiteBaker 2.8.x
12 12
 * @requirements    PHP 5.2.2 and higher
13 13
 * @version         $Id$
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16 16
 *
17 17
 */
18 18

  
19 19

  
branches/2.8.x/wb/admin/groups/save.php
11 11
 * @platform        WebsiteBaker 2.8.x
12 12
 * @requirements    PHP 5.2.2 and higher
13 13
 * @version         $Id$
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16 16
 *
17 17
 */
18 18

  
19 19
// Print admin header
20 20
require('../../config.php');
21 21
require_once(WB_PATH.'/framework/class.admin.php');
22
$admin = new admin('Access', 'groups_modify');
23

  
22
// suppress to print the header, so no new FTAN will be set
23
$admin = new admin('Access', 'groups_modify', false);
24 24
// Create a javascript back link
25 25
$js_back = ADMIN_URL.'/groups/index.php';
26 26

  
27 27
if (!$admin->checkFTAN())
28 28
{
29 29
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back);
30
	exit();
31 30
}
31
// After check print the header
32
$admin->print_header();
32 33

  
33 34
// Check if group group_id is a valid number and doesnt equal 1
34 35
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) {
35 36

  
branches/2.8.x/wb/admin/groups/groups.php
47 47
	if (!$admin->checkFTAN())
48 48
	{
49 49
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL);
50
		exit();
51 50
	}
52 51

  
53 52
	// Print header
......
175 174
	if (!$admin->checkFTAN())
176 175
	{
177 176
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL);
178
		exit();
179 177
	}
180

  
181 178
	// Print header
182 179
	$admin->print_header();
183 180
	// Delete the group
184 181

  
branches/2.8.x/wb/admin/groups/add.php
11 11
 * @platform        WebsiteBaker 2.8.x
12 12
 * @requirements    PHP 5.2.2 and higher
13 13
 * @version         $Id$
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16 16
 *
17 17
 */
18 18

  
19 19
// Print admin header
20 20
require('../../config.php');
21 21
require_once(WB_PATH.'/framework/class.admin.php');
22
$admin = new admin('Access', 'groups_add');
23 22

  
23
// suppress to print the header, so no new FTAN will be set
24
$admin = new admin('Access', 'groups_add', false);
24 25
// Create a javascript back link
25 26
$js_back = ADMIN_URL.'/groups/index.php';
26 27

  
27 28
if (!$admin->checkFTAN())
28 29
{
30
	$admin->print_header();
29 31
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back);
30
	exit();
31 32
}
33
// After check print the header
34
$admin->print_header();
32 35

  
33 36
// Gather details entered
34 37
$group_name = mysql_real_escape_string(strip_tags(trim($admin->get_post('group_name'))));
35 38

  
branches/2.8.x/wb/admin/media/rename2.php
21 21
require_once(WB_PATH.'/framework/class.admin.php');
22 22
$admin = new admin('Media', 'media_rename', false);
23 23

  
24
if (!$admin->checkFTAN())
25
{
26
	$admin->print_error('RN5::'.$MESSAGE['GENERIC_SECURITY_ACCESS']);
27
	exit();
28
}
29

  
30 24
// Include the WB functions file
31 25
require_once(WB_PATH.'/framework/functions.php');
32 26

  
......
40 34
$file_extensions=explode(",",$file_extension_string);
41 35

  
42 36
// Get the current dir
43
$directory = $admin->get_post('dir');
37
// $directory = $admin->get_post('dir');
38

  
39
// Target location
40
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
41
$directory = (isset(${$requestMethod}['dir'])) ? ${$requestMethod}['dir'] : '';
44 42
if($directory == '/') {
45 43
	$directory = '';
46 44
}
......
96 94
		}
97 95
	}
98 96
}
99

  
97
$file_id = $admin->getIDKEY($file_id);
100 98
if(!isset($rename_file)) {
101 99
	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
102 100
}
......
158 156

  
159 157
// Try and rename the file/folder
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff