Project

General

Profile

1
<?php
2

    
3
// $Id: upgrade-script.php 644 2008-01-30 01:14:18Z thorn $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2008, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
//
27
// upgrade-script for Website Baker from version 2.6.7 to 2.7
28
//
29

    
30
require('config.php');
31
require(WB_PATH.'/framework/functions.php');
32

    
33
?>
34

    
35
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
36
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
37
<head>
38
<title>Upgrade-Script</title>
39
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
40
</head>
41
<body>
42
<style type="text/css">
43
<!--
44
*.red { background-color:#FF0000 }
45
*.green { background-color:#00FF00 }
46
-->
47
</style>
48

    
49
<h2>Upgrade-script</h2>
50
<p>
51
will upgrade Website Baker 2.6.5 / 2.6.7 to version 2.7
52
</p>
53
<?php
54

    
55
$OK   = '<span class="green">OK</span>';
56
$FAIL = '<span class="red">failed</span>';
57

    
58

    
59
/**********************************************************
60
 *  - modules-based search
61
 */
62
function db_add_search_key_value($key, $value) {
63
	global $database; global $OK; global $FAIL;
64
	$table = TABLE_PREFIX.'search';
65
	$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
66
	if($query->numRows() > 0) {
67
		echo "$key: allready there. $OK.<br />";
68
		return true;
69
	} else {
70
		$database->query("INSERT INTO $table (name,value,extra) VALUES ('$key', '$value', '')");
71
		echo mysql_error()?mysql_error().'<br />':'';
72
		$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
73
		if($query->numRows() > 0) {
74
			echo "$key: $OK.<br />";
75
			return true;
76
		} else {
77
			echo "$key: $FAIL!<br />";
78
			return false;
79
		}
80
	}
81
}
82
function db_add_field($field, $table, $desc) {
83
	global $database; global $OK; global $FAIL;
84
	echo "<br /><u>Adding field '$field' to table '$table'</u><br />";
85
	$table = TABLE_PREFIX.$table;
86
	$query = $database->query("DESCRIBE $table '$field'");
87
	if($query->numRows() == 0) { // add field
88
		$query = $database->query("ALTER TABLE $table ADD $field $desc");
89
		echo mysql_error()?mysql_error().'<br />':'';
90
		$query = $database->query("DESCRIBE $table '$field'");
91
		echo mysql_error()?mysql_error().'<br />':'';
92
		if($query->numRows() > 0) {
93
			echo "'$field' added. $OK.<br />";
94
		} else {
95
			echo "adding '$field' $FAIL!<br />";
96
		}
97
	} else {
98
		echo "'$field' allready there. $OK.<br />";
99
	}
100
}
101

    
102

    
103
echo "<br /><u>Adding module_order and max_excerpt to search-table</u><br />";
104
// module_order - in which order to show the search-results
105
// max_excerpt - how many lines of excerpt to print per matching page
106

    
107
$cfg = array(
108
	'module_order' => 'faqbaker,manual,wysiwyg',
109
	'max_excerpt' => '15'
110
);
111
foreach($cfg as $key=>$value) {
112
	db_add_search_key_value($key, $value);
113
}
114

    
115
echo "<br /><u>Adding some internal config-elements to search-table</u><br />";
116
// These are global config-elements which don't appear in settings-page. Change them in the database if needed.
117
// cfg_show_description - whether to show page-description on the results page (true/false), def: true
118
// cfg_search_description - whether to search in page-description (true/false), def: true [only used while searching title/link/description/keywords]
119
// cfg_search_keywords - whether to search in page-keywords (true/false), def: true [only used while searching title/link/description/keywords]
120
// cfg_enable_old_search - use old search-method, too (true/false), def: true [use old method as fallback]
121
$cfg = array(
122
	'cfg_show_description' => 'true',
123
	'cfg_search_description' => 'true',
124
	'cfg_search_keywords' => 'true',
125
	'cfg_enable_old_search' => 'true'
126
);
127
foreach($cfg as $key=>$value) {
128
	db_add_search_key_value($key, $value);
129
}
130

    
131
echo "<br /><u>Changing results_loop in search-table</u><br />";
132
// adding [EXCERPT]
133

    
134
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1");
135
if($query->numRows() > 0) {
136
	$fetch_results_loop = $query->fetchRow();
137
	$string = $fetch_results_loop['value'];
138
	if(preg_match("/\[EXCERPT\]/", $string)) {
139
		echo "[EXCERPT] is allready there. $OK.<br />";
140
	} else {
141
		$string = preg_replace("/10px;\">\[DESCRIPTION\]/", "5px;\">[DESCRIPTION]", $string);
142
		$string .= "<tr><td colspan=\"2\" style=\"text-align: justify; padding-bottom: 10px;\">[EXCERPT]</td></tr>";
143
		$string = addslashes($string);
144
		$database->query("UPDATE ".TABLE_PREFIX."search SET name='results_loop',value='".$string."',extra='' WHERE name = 'results_loop' LIMIT 1");
145
		echo mysql_error()?mysql_error().'<br />':'';
146
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1");
147
		if($query->numRows() > 0) {
148
			$fetch_results_loop = $query->fetchRow();
149
			$string = $fetch_results_loop['value'];
150
			if(preg_match("/\[EXCERPT\]/", $string)) {
151
				echo "[EXCERPT] added. $OK.<br />";
152
			} else {
153
				echo "adding [EXCERPT] $FAIL!<br />";
154
			}
155
		}
156
	}
157
}
158

    
159
echo "<br /><u>Changing \"Header:\" in search-table</u><br />";
160
// adding [SEARCH_PATH]
161

    
162
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1");
163
if($query->numRows() > 0) {
164
	$fetch_header = $query->fetchRow();
165
	$string = $fetch_header['value'];
166
	if(preg_match("/\[SEARCH_PATH\]/", $string)) {
167
		echo "[SEARCH_PATH] is allready there. $OK.<br />";
168
	} else {
169
		$string = preg_replace("/<input type=\"text\" name=\"string\" value=\"\[SEARCH_STRING\]\" style=\"width: 100%;\" \/>/", "<input type=\"hidden\" name=\"search_path\" value=\"[SEARCH_PATH]\" /><input type=\"text\" name=\"string\" value=\"[SEARCH_STRING]\" style=\"width: 100%;\" />", $string);
170
		$string = addslashes($string);
171
		$database->query("UPDATE ".TABLE_PREFIX."search SET name='header',value='".$string."',extra='' WHERE name = 'header' LIMIT 1");
172
		echo mysql_error()?mysql_error().'<br />':'';
173
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1");
174
		if($query->numRows() > 0) {
175
			$fetch_header = $query->fetchRow();
176
			$string = $fetch_header['value'];
177
			if(preg_match("/\[SEARCH_PATH\]/", $string)) {
178
				echo "[SEARCH_PATH] added. $OK.<br />";
179
			} else {
180
				echo "adding [SEARCH_PATH] $FAIL!<br />";
181
			}
182
		}
183
	}
184
}
185

    
186
/**********************************************************
187
 *  - publish-by-date
188
 */
189
// Add fields "publ_start" and "publ_end" to table "sections"
190
// check if fields are present
191
db_add_field('publ_start', 'sections', "INT NOT NULL DEFAULT '0'");
192
db_add_field('publ_end', 'sections', "INT NOT NULL DEFAULT '0'");
193

    
194

    
195
/**********************************************************
196
 *  - core-module menu_link
197
 */
198
echo "<br /><u>Convert menu_links</u><br />";
199
// create table
200
$table = TABLE_PREFIX ."mod_menu_link";
201
$database->query("DROP TABLE IF EXISTS `$table`");
202
$database->query("
203
	CREATE TABLE `$table` (
204
		`section_id` INT(11) NOT NULL DEFAULT '0',
205
		`page_id` INT(11) NOT NULL DEFAULT '0',
206
		`target_page_id` INT(11) NOT NULL DEFAULT '0',
207
		`anchor` VARCHAR(255) NOT NULL DEFAULT '0' ,
208
		PRIMARY KEY (`section_id`)
209
	)
210
");
211
// fetch all menu_link-pages in $pages
212
$pages = array();
213
$table_p = TABLE_PREFIX.'pages';
214
$table_s = TABLE_PREFIX.'sections';
215
$table_mm = TABLE_PREFIX ."mod_menu_link";
216

    
217
$query_page = $database->query("SELECT p.*, s.section_id FROM $table_p AS p, $table_s AS s WHERE p.page_id=s.page_id AND s.module = 'menu_link'");
218
if($query_page->numRows() > 0) {
219
	while($page = $query_page->fetchRow()) {
220
		$pages[$page['page_id']]['page_details'] = $page;
221
	}
222
}
223
// get all related files with content from pages/ in $pages, too
224
function list_files_dirs($dir, $depth=true, $files=array(), $dirs=array()) {
225
	$dh=opendir($dir);
226
	while(($file = readdir($dh)) !== false) {
227
		if($file == '.' || $file == '..') {
228
			continue;
229
		}
230
		if(is_dir($dir.'/'.$file)) {
231
			if($depth) {
232
				$dirs[] = $dir.'/'.$file;
233
				list($files, $dirs) = list_files_dirs($dir.'/'.$file, $depth, $files, $dirs);
234
			}
235
		} else {
236
			$files[] = $dir.'/'.$file;
237
		}
238
	}
239
	closedir($dh);
240
	natcasesort($files);
241
	natcasesort($dirs);
242
	return(array($files, $dirs));
243
}
244
list($files, $dirs) = list_files_dirs(WB_PATH.PAGES_DIRECTORY);
245
foreach($files as $file) {
246
	if(($content = implode('', file($file))) !== FALSE) {
247
		if(preg_match('/\$page_id = (\d+)/', $content, $matches)) {
248
			if(array_key_exists($matches[1], $pages)) {
249
				$pages[$matches[1]]['file_content'] = $content;
250
				$pages[$matches[1]]['filename'] = $file;
251
			}
252
		}
253
	}
254
}
255
unset($files); unset($dirs);
256
// try to convert old menu_links to new ones
257
foreach($pages as $p) {
258
	$page = $p['page_details'];
259
	$file_content = $p['file_content'];
260
	$filename = $p['filename'];
261
	$link = $p['page_details']['link'];
262
	$parent_pid = $p['page_details']['parent'];
263
	$page_id = $p['page_details']['page_id'];
264
	$section_id = $p['page_details']['section_id'];
265
	$menu_title = $p['page_details']['menu_title'];
266

    
267
	// calculate link from wb_pages.parent and menu_title
268
	$cur_link = '';
269
	if($parent_pid != '0' && $query_link = $database->query("SELECT link FROM $table_p WHERE page_id = '$parent_pid'")) {
270
		$res = $query_link->fetchRow();
271
		$cur_link .= $res['link'];
272
	}
273
	$cur_link .= '/'.page_filename($menu_title);
274
echo "found: $cur_link<br />";
275
	$database->query("UPDATE $table_p SET link = '$cur_link' WHERE page_id = '$page_id'");
276
	echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
277
	
278
	$new_filenames[$page_id]['file'] = WB_PATH.PAGES_DIRECTORY.$cur_link.PAGE_EXTENSION;
279
	$new_filenames[$page_id]['link'] = $cur_link;
280
	$new_filenames[$page_id]['menu'] = $menu_title;
281

    
282
	// delete old access files in pages
283
	if(file_exists($filename)) {
284
		if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
285
			echo "Cannot delete access file in pages/ - permission denied ($FAIL)<br />";
286
		} else {
287
			unlink($filename);
288
		}
289
	}
290
	
291
	// make entry in wb_mod_menu_link
292
	if($query_pid = $database->query("SELECT page_id FROM $table_p WHERE page_id != '$page_id' AND link = '$link'")) {
293
		$res = $query_pid->fetchRow();
294
		$target_page_id = $res['page_id'];
295
		$database->query("INSERT INTO $table_mm (page_id, section_id, target_page_id, anchor) VALUES ('$page_id', '$section_id', '$target_page_id', '0')");
296
		echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
297
	}
298
}
299
// create new access files in pages/; make directories as needed
300
foreach($pages as $p) {
301
	$page_id = $p['page_details']['page_id'];
302
	$filename = $new_filenames[$page_id]['file'];
303
	$menu_title = $new_filenames[$page_id]['menu'];
304
	$link = $new_filenames[$page_id]['link'];
305
	$content = $p['file_content'];
306
	$level = $p['page_details']['level'];
307
	$depth = '';
308
	for($i=0; $i<=$level; $i++)
309
		$depth .= '../';
310
	$content = preg_replace('#((../)+)config\.php#', "{$depth}config.php", $content);
311
	while(file_exists($filename)) {
312
		echo "Cannot create '$filename' - file exist. Renamed to: ";
313
		$menu_title .= '_';
314
		$link .= '_';
315
		$filename = WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
316
		echo "$filename<br />";
317
		$database->query("UPDATE $table_p SET link='$link', menu_title='$menu_title' WHERE page_id = '$page_id'");
318
		echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
319
	}
320
	// check if we need to create a subdir somewhere
321
	$dirs = array();
322
	while(dirname($link) != '/') {
323
		$link = dirname($link);
324
		$dirs[] = WB_PATH.PAGES_DIRECTORY.$link;
325
	}
326
	foreach(array_reverse($dirs) as $dir) {
327
		if(!file_exists($dir)) {
328
			mkdir($dir, OCTAL_DIR_MODE);
329
		}
330
	}
331
	// create new file in pages/
332
	if($handle=fopen($filename, "wb")) {
333
		if(!fwrite($handle, $content)) {
334
			echo "Cannot write to $filename - ($FAIL)<br />";
335
		}
336
		fclose($handle);
337
	} else {
338
		echo "Cannot create $filename - ($FAIL)<br />";
339
	}
340
	
341
}
342

    
343
// some code missing to regenerate page_title from link/filename
344
// for_all_pages: if filename($page_title) != basename($link) {
345
//   rename $page_title to basename($link)
346
// }
347
// This must be done after menu_link-upgrade
348
// 
349
// Should we really do this? - must be checked
350

    
351
/**********************************************************
352
 *  - asp - Advanced Spam Protection
353
 */
354
echo "<br /><u>Adding table mod_captcha_control</u><br />";
355
$table = TABLE_PREFIX.'mod_captcha_control';
356
$database->query("DROP TABLE IF EXISTS `$table`");
357
$database->query("CREATE TABLE `$table` (
358
	`enabled_captcha` VARCHAR(1) NOT NULL DEFAULT '1',
359
	`enabled_asp` VARCHAR(1) NOT NULL DEFAULT '1',
360
	`captcha_type` VARCHAR(255) NOT NULL DEFAULT 'calc_text',
361
	`asp_session_min_age` INT(11) NOT NULL DEFAULT '20',
362
	`asp_view_min_age` INT(11) NOT NULL DEFAULT '10',
363
	`asp_input_min_age` INT(11) NOT NULL DEFAULT '5',
364
	`ct_text` LONGTEXT NOT NULL DEFAULT ''
365
	)"
366
);
367
$database->query("
368
	INSERT INTO `$table`
369
		(`enabled_captcha`, `enabled_asp`, `captcha_type`)
370
	VALUES
371
		('1', '1', 'calc_text')
372
");
373

    
374

    
375
//******************************************************************************
376
//Start of upgrade script for the form modul
377
//******************************************************************************
378

    
379
db_add_field('success_email_subject', 'mod_form_settings', "VARCHAR(255) NOT NULL AFTER `success_message`");
380
db_add_field('success_email_text', 'mod_form_settings', "TEXT NOT NULL AFTER `success_message`");
381
db_add_field('success_email_from', 'mod_form_settings', "VARCHAR(255) NOT NULL AFTER `success_message`");
382
db_add_field('success_email_to', 'mod_form_settings', "TEXT NOT NULL AFTER `success_message`");
383
db_add_field('success_page', 'mod_form_settings', "TEXT NOT NULL AFTER `success_message`");
384
db_add_field('email_fromname', 'mod_form_settings', "VARCHAR( 255 ) NOT NULL AFTER email_from");
385
db_add_field('success_email_fromname', 'mod_form_settings', "VARCHAR( 255 ) NOT NULL AFTER success_email_from");
386

    
387
echo "<BR><B>Deleting field success_message from table mod_form_settings</B><BR>";
388

    
389
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` DROP `success_message`")) {
390
	echo 'Database field success_message droped successfully<br>';
391
}
392
echo mysql_error().'<br />';
393

    
394

    
395
// UPDATING DATA INTO FIELDS
396
echo "<BR>";
397

    
398
// These are the default setting
399
$success_page = 'none';
400
$success_email_to = '';
401
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
402
$success_email_text = addslashes($success_email_text);
403
$success_email_subject = 'You have submitted a form';
404

    
405
// Insert default settings into database
406
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
407
while($result = $query_dates->fetchRow()) {
408
	
409
	echo "<B>Add default settings data to database for form section_id= ".$result['section_id']."</b><BR>";
410
	$section_id = $result['section_id'];
411

    
412
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_page` = '$success_page' WHERE `section_id` = $section_id")) {
413
		echo 'Database data success_page added successfully<br>';
414
	}
415
	echo mysql_error().'<br />';
416
	
417
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_to` = '$success_email_to' WHERE `section_id` = $section_id")) {
418
		echo 'Database data success_email_to added successfully<br>';
419
	}
420
	echo mysql_error().'<br />';
421
	
422
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_text` = '$success_email_text' WHERE `section_id` = $section_id")) {
423
		echo 'Database data success_email_text added successfully<br>';
424
	}
425
	echo mysql_error().'<br />';
426
	
427
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_subject` = '$success_email_subject' WHERE `section_id` = $section_id")) {
428
		echo 'Database data success_email_subject added successfully<br>';
429
	}
430
	echo mysql_error().'<br />';
431
	
432
}
433

    
434
// copy field email_to to success_email_from
435
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
436
while($result = $query_dates->fetchRow()) {
437
	
438
	echo "<B>Copying field email_to to success_email_from for form section_id= ".$result['section_id']."</B><BR>";
439
	$section_id = $result['section_id'];
440

    
441
	$success_email_from = $result['email_to'];
442
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_from` = '$success_email_from' WHERE `section_id` = $section_id")) {
443
		echo 'Copyied field email_to to success_email_from successfully<br>';
444
	}
445
	echo mysql_error().'<br />';
446
}
447

    
448
//******************************************************************************
449
//End of upgrade script for the form modul
450
//******************************************************************************
451

    
452
//******************************************************************************
453
//Start of upgrade script for the news modul
454
//******************************************************************************
455

    
456
db_add_field('published_when', 'mod_news_posts', "INT NOT NULL AFTER `commenting`");
457
db_add_field('published_until', 'mod_news_posts', "INT NOT NULL AFTER `published_when`");
458

    
459
// UPDATING DATA INTO FIELDS
460
echo "<BR>";
461

    
462
// These are the default setting
463
$header = '<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"98%\">';
464
$post_loop = '<tr class=\"post_top\">
465
<td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
466
<td class=\"post_date\">[MODI_TIME], [MODI_DATE]</td>
467
</tr>
468
<tr>
469
<td class=\"post_short\" colspan=\"2\">
470
[SHORT] 
471
<a href=\"[LINK]\">[TEXT_READ_MORE]</a>
472
</td>
473
</tr>';
474
$post_header = addslashes('<table cellpadding="0" cellspacing="0" border="0" width="100%">
475
<tr>
476
<td height="30"><h1>[TITLE]</h1></td>
477
<td rowspan="3" style="display: [DISPLAY_IMAGE]"><img src="[GROUP_IMAGE]" alt="[GROUP_TITLE]" /></td>
478
</tr>
479
<tr>
480
<td valign="top"><b>Posted by [DISPLAY_NAME] ([USERNAME]) on [PUBL_DATE]</b></td>
481
</tr>
482
<tr style="display: [DISPLAY_GROUP]">
483
<td valign="top"><a href="[BACK]">[PAGE_TITLE]</a> >> <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
484
</tr>
485
</table>
486
<p style="text-align: justify;">');
487
$post_footer = '</p><p>Last changed: [MODI_DATE] at [MODI_TIME]</p>
488
<a href=\"[BACK]\">Back</a>';
489
$comments_header = addslashes('<br /><br />
490
<h2>Comments</h2>
491
<table cellpadding="2" cellspacing="0" border="0" width="98%">');
492

    
493
// Insert default settings into database
494
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
495
while($result = $query_dates->fetchRow()) {
496
	
497
	echo "<B>Add default settings data to database for news section_id= ".$result['section_id']."</b><BR>";
498
	$section_id = $result['section_id'];
499

    
500
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
501
		echo 'Database data header added successfully<br>';
502
	}
503
	echo mysql_error().'<br />';
504
	
505
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
506
		echo 'Database data post_loop added successfully<br>';
507
	}
508
	echo mysql_error().'<br />';
509
	
510
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
511
		echo 'Database data post_header added successfully<br>';
512
	}
513
	echo mysql_error().'<br />';
514
	
515
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
516
		echo 'Database data post_footer added successfully<br>';
517
	}
518
	echo mysql_error().'<br />';
519
	
520
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
521
		echo 'Database data comments_header added successfully<br>';
522
	}
523
	echo mysql_error().'<br />';
524

    
525
}
526

    
527
// MIGRATING FIELD DATES to POSTED_WHEN
528
echo "<B>Copying field posted_when value to published_when</B><BR>";
529
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts where section_id != 0 and page_id != 0");
530

    
531
while($result = $query_dates->fetchRow()) {
532
	$pid = $result['post_id'];
533
	$NEW_DATE = $result['posted_when'];
534
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_posts` SET `published_when` = '$NEW_DATE' WHERE `post_id` = $pid")) {
535
		echo 'Copying posted_when value to published_when successfully<br>';
536
	}
537
	echo mysql_error().'<br />';
538
}
539

    
540
//******************************************************************************
541
//End of upgrade script for the news modul
542
//******************************************************************************
543

    
544

    
545

    
546

    
547
echo "<br /><br />Done<br />";
548

    
549
?>
550

    
551
</body>
552
</html>
(4-4/4)