Project

General

Profile

1
<?php
2

    
3
// $Id: upgrade-script.php 593 2008-01-24 22:09:15Z 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
	$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = '$key' LIMIT 1");
65
	if($query->numRows() > 0) {
66
		echo "$key: allready there. $OK.<br />";
67
		return true;
68
	} else {
69
		$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('$key', '$value', '')");
70
		echo mysql_error()?mysql_error().'<br />':'';
71
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = '$key' LIMIT 1");
72
		if($query->numRows() > 0) {
73
			echo "$key: $OK.<br />";
74
			return true;
75
		} else {
76
			echo "$key: $FAIL!<br />";
77
			return false;
78
		}
79
	}
80
}
81

    
82

    
83
echo "<br /><u>Adding module_order and max_excerpt to search-table</u><br />";
84
// module_order - in which order to show the search-results
85
// max_excerpt - how many lines of excerpt to print per matching page
86

    
87
$cfg = array(
88
	'module_order' => 'faqbaker,manual,wysiwyg',
89
	'max_excerpt' => '15'
90
);
91
foreach($cfg as $key=>$value) {
92
	db_add_search_key_value($key, $value);
93
}
94

    
95

    
96
echo "<br /><u>Changing results_loop in search-table</u><br />";
97
// adding [EXCERPT]
98

    
99
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1");
100
if($query->numRows() > 0) {
101
	$fetch_results_loop = $query->fetchRow();
102
	$string = $fetch_results_loop['value'];
103
	if(preg_match("/\[EXCERPT\]/", $string)) {
104
		echo "[EXCERPT] is allready there. $OK.<br />";
105
	} else {
106
		$string = preg_replace("/10px;\">\[DESCRIPTION\]/", "5px;\">[DESCRIPTION]", $string);
107
		$string .= "<tr><td colspan=\"2\" style=\"text-align: justify; padding-bottom: 10px;\">[EXCERPT]</td></tr>";
108
		$string = addslashes($string);
109
		$database->query("UPDATE ".TABLE_PREFIX."search SET name='results_loop',value='".$string."',extra='' WHERE name = 'results_loop' LIMIT 1");
110
		echo mysql_error()?mysql_error().'<br />':'';
111
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1");
112
		if($query->numRows() > 0) {
113
			$fetch_results_loop = $query->fetchRow();
114
			$string = $fetch_results_loop['value'];
115
			if(preg_match("/\[EXCERPT\]/", $string)) {
116
				echo "[EXCERPT] added. $OK.<br />";
117
			} else {
118
				echo "adding [EXCERPT] $FAIL!<br />";
119
			}
120
		}
121
	}
122
}
123

    
124
echo "<br /><u>Changing \"Header:\" in search-table</u><br />";
125
// adding [SEARCH_PATH]
126

    
127
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1");
128
if($query->numRows() > 0) {
129
	$fetch_header = $query->fetchRow();
130
	$string = $fetch_header['value'];
131
	if(preg_match("/\[SEARCH_PATH\]/", $string)) {
132
		echo "[SEARCH_PATH] is allready there. $OK.<br />";
133
	} else {
134
		$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);
135
		$string = addslashes($string);
136
		$database->query("UPDATE ".TABLE_PREFIX."search SET name='header',value='".$string."',extra='' WHERE name = 'header' LIMIT 1");
137
		echo mysql_error()?mysql_error().'<br />':'';
138
		$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1");
139
		if($query->numRows() > 0) {
140
			$fetch_header = $query->fetchRow();
141
			$string = $fetch_header['value'];
142
			if(preg_match("/\[SEARCH_PATH\]/", $string)) {
143
				echo "[SEARCH_PATH] added. $OK.<br />";
144
			} else {
145
				echo "adding [SEARCH_PATH] $FAIL!<br />";
146
			}
147
		}
148
	}
149
}
150

    
151
echo "<br /><u>Adding some internal config-elements to search-table</u><br />";
152
// These are global config-elements which don't appear in settings-page. Change them in the database if needed.
153
// cfg_show_description - whether to show page-description on the results page (true/false), def: true
154
// cfg_search_description - whether to search in page-description (true/false), def: true [only used while searching title/link/description/keywords]
155
// cfg_search_keywords - whether to search in page-keywords (true/false), def: true [only used while searching title/link/description/keywords]
156
// cfg_enable_old_search - use old search-method, too (true/false), def: true [use old method as fallback]
157
$cfg = array(
158
	'cfg_show_description' => 'true',
159
	'cfg_search_description' => 'true',
160
	'cfg_search_keywords' => 'true',
161
	'cfg_enable_old_search' => 'true'
162
);
163
foreach($cfg as $key=>$value) {
164
	db_add_search_key_value($key, $value);
165
}
166

    
167

    
168
/**********************************************************
169
 *  - publish-by-date
170
 */
171
echo "<br /><u>Adding fields 'publ_start' and 'publ_end' to table 'sections'</u><br />";
172
// Add fields "publ_start" and "publ_end" to table "sections"
173
// check if fields are present
174
$table = TABLE_PREFIX."sections";
175
$query = $database->query("DESCRIBE $table 'publ_start'");
176
if($query->numRows() == 0) { // add field
177
	$query = $database->query("ALTER TABLE $table ADD publ_start INT NOT NULL DEFAULT '0'");
178
	echo mysql_error()?mysql_error().'<br />':'';
179
	$query = $database->query("DESCRIBE $table 'publ_start'");
180
	echo mysql_error()?mysql_error().'<br />':'';
181
	if($query->numRows() > 0) {
182
		echo "'publ_start' added. $OK.<br />";
183
	} else {
184
		echo "adding 'publ_start' $FAIL!<br />";
185
	}
186
} else {
187
	echo "'publ_start' allready there. $OK.<br />";
188
}
189
$query = $database->query("DESCRIBE $table 'publ_end'");
190
if($query->numRows() == 0) { // add field
191
	$query = $database->query("ALTER TABLE $table ADD publ_end INT NOT NULL DEFAULT '0'");
192
	echo mysql_error()?mysql_error().'<br />':'';
193
	$query = $database->query("DESCRIBE $table 'publ_end'");
194
	if($query->numRows() > 0) {
195
		echo "'publ_end' added. $OK.<br />";
196
	} else {
197
		echo "adding 'publ_end' $FAIL!<br />";
198
	}
199
} else {
200
	echo "'publ_end' allready there. $OK<br />";
201
}
202

    
203

    
204
/**********************************************************
205
 *  - core-module menu_link
206
 */
207
echo "<br /><u>Convert menu_links</u><br />";
208
// create table
209
$table = TABLE_PREFIX ."mod_menu_link";
210
$database->query("DROP TABLE IF EXISTS `$table`");
211
$database->query("
212
	CREATE TABLE `$table` (
213
		`section_id` INT(11) NOT NULL DEFAULT '0',
214
		`page_id` INT(11) NOT NULL DEFAULT '0',
215
		`target_page_id` INT(11) NOT NULL DEFAULT '0',
216
		`anchor` VARCHAR(255) NOT NULL DEFAULT '0' ,
217
		PRIMARY KEY (`section_id`)
218
	)
219
");
220
// fetch all menu_link-pages in $pages
221
$pages = array();
222
$table_p = TABLE_PREFIX.'pages';
223
$table_s = TABLE_PREFIX.'sections';
224
$table_mm = TABLE_PREFIX ."mod_menu_link";
225

    
226
$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'");
227
if($query_page->numRows() > 0) {
228
	while($page = $query_page->fetchRow()) {
229
		$pages[$page['page_id']]['page_details'] = $page;
230
	}
231
}
232
// get all related files with content from pages/ in $pages, too
233
function list_files_dirs($dir, $depth=true, $files=array(), $dirs=array()) {
234
	$dh=opendir($dir);
235
	while(($file = readdir($dh)) !== false) {
236
		if($file == '.' || $file == '..') {
237
			continue;
238
		}
239
		if(is_dir($dir.'/'.$file)) {
240
			if($depth) {
241
				$dirs[] = $dir.'/'.$file;
242
				list($files, $dirs) = list_files_dirs($dir.'/'.$file, $depth, $files, $dirs);
243
			}
244
		} else {
245
			$files[] = $dir.'/'.$file;
246
		}
247
	}
248
	closedir($dh);
249
	natcasesort($files);
250
	natcasesort($dirs);
251
	return(array($files, $dirs));
252
}
253
list($files, $dirs) = list_files_dirs(WB_PATH.PAGES_DIRECTORY);
254
foreach($files as $file) {
255
	if(($content = implode('', file($file))) !== FALSE) {
256
		if(preg_match('/\$page_id = (\d+)/', $content, $matches)) {
257
			if(array_key_exists($matches[1], $pages)) {
258
				$pages[$matches[1]]['file_content'] = $content;
259
				$pages[$matches[1]]['filename'] = $file;
260
			}
261
		}
262
	}
263
}
264
unset($files); unset($dirs);
265
// try to convert old menu_links to new ones
266
foreach($pages as $p) {
267
	$page = $p['page_details'];
268
	$file_content = $p['file_content'];
269
	$filename = $p['filename'];
270
	$link = $p['page_details']['link'];
271
	$parent_pid = $p['page_details']['parent'];
272
	$page_id = $p['page_details']['page_id'];
273
	$section_id = $p['page_details']['section_id'];
274
	$menu_title = $p['page_details']['menu_title'];
275

    
276
	// calculate link from wb_pages.parent and menu_title
277
	$cur_link = '';
278
	if($parent_pid != '0' && $query_link = $database->query("SELECT link FROM $table_p WHERE page_id = '$parent_pid'")) {
279
		$res = $query_link->fetchRow();
280
		$cur_link .= $res['link'];
281
	}
282
	$cur_link .= '/'.page_filename($menu_title);
283
echo "found: $cur_link<br />";
284
	$database->query("UPDATE $table_p SET link = '$cur_link' WHERE page_id = '$page_id'");
285
	echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
286
	
287
	$new_filenames[$page_id]['file'] = WB_PATH.PAGES_DIRECTORY.$cur_link.PAGE_EXTENSION;
288
	$new_filenames[$page_id]['link'] = $cur_link;
289
	$new_filenames[$page_id]['menu'] = $menu_title;
290

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

    
352
// some code missing to regenerate page_title from link/filename
353
// for_all_pages: if filename($page_title) != basename($link) {
354
//   rename $page_title to basename($link)
355
// }
356
// This must be done after menu_link-upgrade
357
// 
358
// Should we really do this? - must be checked
359

    
360

    
361
//******************************************************************************
362
//Start of upgrade script for the form modul
363
//******************************************************************************
364

    
365
echo "<BR><B>Adding new field to database table mod_form_settings</B><BR>";
366

    
367
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_subject` VARCHAR(255) NOT NULL AFTER `success_message`")) {
368
	echo 'Database Field success_email_subject added successfully<br />';
369
}
370
echo mysql_error().'<br />';
371

    
372
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_text` TEXT NOT NULL AFTER `success_message`")) {
373
	echo 'Database Field success_email_text added successfully<br />';
374
}
375
echo mysql_error().'<br />';
376

    
377
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_from` VARCHAR(255) NOT NULL AFTER `success_message`")) {
378
	echo 'Database Field success_email_from added successfully<br />';
379
}
380
echo mysql_error().'<br />';
381

    
382
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_to` TEXT NOT NULL AFTER `success_message`")) {
383
	echo 'Database Field success_email_to added successfully<br />';
384
}
385
echo mysql_error().'<br />';
386

    
387
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_page` TEXT NOT NULL AFTER `success_message`")) {
388
	echo 'Database Field success_page added successfully<br />';
389
}
390
echo mysql_error().'<br />';
391

    
392
echo "<BR><B>Deleting field success_message from table mod_form_settings</B><BR>";
393

    
394
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` DROP `success_message`")) {
395
	echo 'Database field success_message droped successfully<br>';
396
}
397
echo mysql_error().'<br />';
398

    
399

    
400
// UPDATING DATA INTO FIELDS
401
echo "<BR>";
402

    
403
// These are the default setting
404
$success_page = 'none';
405
$success_email_to = '';
406
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
407
$success_email_text = addslashes($success_email_text);
408
$success_email_subject = 'You have submitted a form';
409

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

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

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

    
446
	$success_email_from = $result['email_to'];
447
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_from` = '$success_email_from' WHERE `section_id` = $section_id")) {
448
		echo 'Copyied field email_to to success_email_from successfully<br>';
449
	}
450
	echo mysql_error().'<br />';
451
}
452

    
453
//******************************************************************************
454
//End of upgrade script for the form modul
455
//******************************************************************************
456

    
457
//******************************************************************************
458
//Start of upgrade script for the news modul
459
//******************************************************************************
460

    
461
echo "<BR><B>Adding new field to database table mod_news_posts</B><BR>";
462
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_news_posts` ADD `published_when` INT NOT NULL AFTER `commenting`")) {
463
	echo 'Database Field published_when added successfully<br />';
464
}
465
echo mysql_error().'<br />';
466

    
467
// UPDATING DATA INTO FIELDS
468
echo "<BR>";
469

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

    
501
// Insert default settings into database
502
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
503
while($result = $query_dates->fetchRow()) {
504
	
505
	echo "<B>Add default settings data to database for news section_id= ".$result['section_id']."</b><BR>";
506
	$section_id = $result['section_id'];
507

    
508
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
509
		echo 'Database data header added successfully<br>';
510
	}
511
	echo mysql_error().'<br />';
512
	
513
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
514
		echo 'Database data post_loop added successfully<br>';
515
	}
516
	echo mysql_error().'<br />';
517
	
518
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
519
		echo 'Database data post_header added successfully<br>';
520
	}
521
	echo mysql_error().'<br />';
522
	
523
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
524
		echo 'Database data post_footer added successfully<br>';
525
	}
526
	echo mysql_error().'<br />';
527
	
528
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
529
		echo 'Database data comments_header added successfully<br>';
530
	}
531
	echo mysql_error().'<br />';
532

    
533
}
534

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

    
539
while($result = $query_dates->fetchRow()) {
540
	$pid = $result['post_id'];
541
	$NEW_DATE = $result['posted_when'];
542
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_posts` SET `published_when` = '$NEW_DATE' WHERE `post_id` = $pid")) {
543
		echo 'Copying posted_when value to published_when successfully<br>';
544
	}
545
	echo mysql_error().'<br />';
546
}
547

    
548
//******************************************************************************
549
//End of upgrade script for the news modul
550
//******************************************************************************
551

    
552
echo "<br /><br />Done<br />";
553

    
554
?>
555

    
556
</body>
557
</html>
(4-4/4)