Project

General

Profile

1
<?php
2

    
3
// $Id: upgrade-script.php 648 2008-01-31 13:25:08Z 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
<!--
43
<style type="text/css">
44
*.red { background-color:#FF0000 }
45
*.green { background-color:#00FF00 }
46
</style>
47
-->
48
<h2>Upgrade-script</h2>
49
<p>
50
will upgrade Website Baker 2.6.5 / 2.6.7 to version 2.7
51
</p>
52
<?php
53

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

    
57

    
58
/**********************************************************
59
 *  - modules-based search
60
 */
61
function db_add_search_key_value($key, $value) {
62
	global $database; global $OK; global $FAIL;
63
	$table = TABLE_PREFIX.'search';
64
	$query = $database->query("SELECT value FROM $table 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 (name,value,extra) VALUES ('$key', '$value', '')");
70
		echo (mysql_error()?mysql_error().'<br />':'');
71
		$query = $database->query("SELECT value FROM $table 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
function db_add_field($field, $table, $desc) {
82
	global $database; global $OK; global $FAIL;
83
	echo "<u>Adding field '$field' to table '$table'</u><br />";
84
	$table = TABLE_PREFIX.$table;
85
	$query = $database->query("DESCRIBE $table '$field'");
86
	if($query->numRows() == 0) { // add field
87
		$query = $database->query("ALTER TABLE $table ADD $field $desc");
88
		echo (mysql_error()?mysql_error().'<br />':'');
89
		$query = $database->query("DESCRIBE $table '$field'");
90
		echo (mysql_error()?mysql_error().'<br />':'');
91
		if($query->numRows() > 0) {
92
			echo "'$field' added. $OK.<br />";
93
		} else {
94
			echo "adding '$field' $FAIL!<br />";
95
		}
96
	} else {
97
		echo "'$field' allready there. $OK.<br />";
98
	}
99
}
100

    
101

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

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

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

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

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

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

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

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

    
193

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

    
215
$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'");
216
if($query_page->numRows() > 0) {
217
	while($page = $query_page->fetchRow()) {
218
		$pages[$page['page_id']]['page_details'] = $page;
219
	}
220
}
221
if($pages!=array())
222
	echo "<br /><u>Convert menu_links</u><br />";
223

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

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

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

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

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

    
375
/**********************************************************
376
 *  - multi-group
377
 */
378
db_add_field('groups_id', 'users', "VARCHAR( 255 ) NOT NULL DEFAULT '0' AFTER group_id");
379
$table = TABLE_PREFIX.'users';
380
if($query_group = $database->query("SELECT user_id,group_id,groups_id FROM $table")) {
381
	while($group = $query_group->fetchRow()) {
382
		if($group['groups_id'] == '0') {
383
			if($database->query("UPDATE $table SET groups_id = group_id WHERE user_id = {$group['user_id']}")) {
384
				echo 'groups_id updated successfully<br>';
385
			}
386
			echo mysql_error().'<br />';
387
		}
388
	}
389
}
390

    
391

    
392

    
393
//******************************************************************************
394
//Start of upgrade script for the form modul
395
//******************************************************************************
396

    
397
db_add_field('success_email_subject', 'mod_form_settings', "VARCHAR(255) NOT NULL AFTER `email_subject`");
398
db_add_field('success_email_text', 'mod_form_settings', "TEXT NOT NULL AFTER `email_subject`");
399
db_add_field('success_email_from', 'mod_form_settings', "VARCHAR(255) NOT NULL AFTER `email_subject`");
400
db_add_field('success_email_to', 'mod_form_settings', "TEXT NOT NULL AFTER `email_subject`");
401
db_add_field('success_page', 'mod_form_settings', "TEXT NOT NULL AFTER `email_subject`");
402
db_add_field('email_fromname', 'mod_form_settings', "VARCHAR( 255 ) NOT NULL AFTER email_from");
403
db_add_field('success_email_fromname', 'mod_form_settings', "VARCHAR( 255 ) NOT NULL AFTER success_email_from");
404

    
405
echo "<BR><B>Deleting field success_message from table mod_form_settings</B><BR>";
406

    
407
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` DROP `success_message`")) {
408
	echo 'Database field success_message droped successfully<br>';
409
}
410
echo mysql_error().'<br />';
411

    
412

    
413
// UPDATING DATA INTO FIELDS
414
echo "<BR>";
415

    
416
// These are the default setting
417
$success_page = 'none';
418
$success_email_to = '';
419
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
420
$success_email_text = addslashes($success_email_text);
421
$success_email_subject = 'You have submitted a form';
422

    
423
// Insert default settings into database
424
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
425
while($result = $query_dates->fetchRow()) {
426
	
427
	echo "<B>Add default settings data to database for form section_id= ".$result['section_id']."</b><BR>";
428
	$section_id = $result['section_id'];
429

    
430
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_page` = '$success_page' WHERE `section_id` = $section_id")) {
431
		echo 'Database data success_page added successfully<br>';
432
	}
433
	echo mysql_error().'<br />';
434
	
435
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_to` = '$success_email_to' WHERE `section_id` = $section_id")) {
436
		echo 'Database data success_email_to added successfully<br>';
437
	}
438
	echo mysql_error().'<br />';
439
	
440
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_text` = '$success_email_text' WHERE `section_id` = $section_id")) {
441
		echo 'Database data success_email_text added successfully<br>';
442
	}
443
	echo mysql_error().'<br />';
444
	
445
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_subject` = '$success_email_subject' WHERE `section_id` = $section_id")) {
446
		echo 'Database data success_email_subject added successfully<br>';
447
	}
448
	echo mysql_error().'<br />';
449
	
450
}
451

    
452
// copy field email_to to success_email_from
453
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
454
while($result = $query_dates->fetchRow()) {
455
	
456
	echo "<B>Copying field email_to to success_email_from for form section_id= ".$result['section_id']."</B><BR>";
457
	$section_id = $result['section_id'];
458

    
459
	$success_email_from = $result['email_to'];
460
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_from` = '$success_email_from' WHERE `section_id` = $section_id")) {
461
		echo 'Copyied field email_to to success_email_from successfully<br>';
462
	}
463
	echo mysql_error().'<br />';
464
}
465

    
466
//******************************************************************************
467
//End of upgrade script for the form modul
468
//******************************************************************************
469

    
470
//******************************************************************************
471
//Start of upgrade script for the news modul
472
//******************************************************************************
473

    
474
db_add_field('published_when', 'mod_news_posts', "INT NOT NULL AFTER `commenting`");
475
db_add_field('published_until', 'mod_news_posts', "INT NOT NULL AFTER `published_when`");
476

    
477
// UPDATING DATA INTO FIELDS
478
echo "<BR>";
479

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

    
511
// Insert default settings into database
512
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
513
while($result = $query_dates->fetchRow()) {
514
	
515
	echo "<B>Add default settings data to database for news section_id= ".$result['section_id']."</b><BR>";
516
	$section_id = $result['section_id'];
517

    
518
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
519
		echo 'Database data header added successfully<br>';
520
	}
521
	echo mysql_error().'<br />';
522
	
523
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
524
		echo 'Database data post_loop added successfully<br>';
525
	}
526
	echo mysql_error().'<br />';
527
	
528
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
529
		echo 'Database data post_header added successfully<br>';
530
	}
531
	echo mysql_error().'<br />';
532
	
533
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
534
		echo 'Database data post_footer added successfully<br>';
535
	}
536
	echo mysql_error().'<br />';
537
	
538
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
539
		echo 'Database data comments_header added successfully<br>';
540
	}
541
	echo mysql_error().'<br />';
542

    
543
}
544

    
545
// MIGRATING FIELD DATES to POSTED_WHEN
546
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts where section_id != 0 and page_id != 0");
547
if($query_dates->numRows() > 0) {
548
	echo "<B>Copying field posted_when value to published_when</B><BR>";
549
}
550
while($result = $query_dates->fetchRow()) {
551
	$pid = $result['post_id'];
552
	$NEW_DATE = $result['posted_when'];
553
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_posts` SET `published_when` = '$NEW_DATE' WHERE `post_id` = $pid")) {
554
		echo 'Copying posted_when value to published_when successfully<br>';
555
	}
556
	echo mysql_error().'<br />';
557
}
558

    
559
//******************************************************************************
560
//End of upgrade script for the news modul
561
//******************************************************************************
562

    
563

    
564

    
565

    
566
echo "<br /><br />Done<br />";
567

    
568
?>
569

    
570
</body>
571
</html>
(4-4/4)