1
|
<?php
|
2
|
|
3
|
// $Id: upgrade-script.php 595 2008-01-25 15:08:43Z doc $
|
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
|
|
353
|
|
354
|
//******************************************************************************
|
355
|
//Start of upgrade script for the form modul
|
356
|
//******************************************************************************
|
357
|
|
358
|
echo "<BR><B>Adding new field to database table mod_form_settings</B><BR>";
|
359
|
|
360
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_subject` VARCHAR(255) NOT NULL AFTER `success_message`")) {
|
361
|
echo 'Database Field success_email_subject added successfully<br />';
|
362
|
}
|
363
|
echo mysql_error().'<br />';
|
364
|
|
365
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_text` TEXT NOT NULL AFTER `success_message`")) {
|
366
|
echo 'Database Field success_email_text added successfully<br />';
|
367
|
}
|
368
|
echo mysql_error().'<br />';
|
369
|
|
370
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_from` VARCHAR(255) NOT NULL AFTER `success_message`")) {
|
371
|
echo 'Database Field success_email_from added successfully<br />';
|
372
|
}
|
373
|
echo mysql_error().'<br />';
|
374
|
|
375
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_to` TEXT NOT NULL AFTER `success_message`")) {
|
376
|
echo 'Database Field success_email_to added successfully<br />';
|
377
|
}
|
378
|
echo mysql_error().'<br />';
|
379
|
|
380
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_page` TEXT NOT NULL AFTER `success_message`")) {
|
381
|
echo 'Database Field success_page added successfully<br />';
|
382
|
}
|
383
|
echo mysql_error().'<br />';
|
384
|
|
385
|
echo "<BR><B>Deleting field success_message from table mod_form_settings</B><BR>";
|
386
|
|
387
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` DROP `success_message`")) {
|
388
|
echo 'Database field success_message droped successfully<br>';
|
389
|
}
|
390
|
echo mysql_error().'<br />';
|
391
|
|
392
|
|
393
|
// UPDATING DATA INTO FIELDS
|
394
|
echo "<BR>";
|
395
|
|
396
|
// These are the default setting
|
397
|
$success_page = 'none';
|
398
|
$success_email_to = '';
|
399
|
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
|
400
|
$success_email_text = addslashes($success_email_text);
|
401
|
$success_email_subject = 'You have submitted a form';
|
402
|
|
403
|
// Insert default settings into database
|
404
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
|
405
|
while($result = $query_dates->fetchRow()) {
|
406
|
|
407
|
echo "<B>Add default settings data to database for form section_id= ".$result['section_id']."</b><BR>";
|
408
|
$section_id = $result['section_id'];
|
409
|
|
410
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_page` = '$success_page' WHERE `section_id` = $section_id")) {
|
411
|
echo 'Database data success_page added successfully<br>';
|
412
|
}
|
413
|
echo mysql_error().'<br />';
|
414
|
|
415
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_to` = '$success_email_to' WHERE `section_id` = $section_id")) {
|
416
|
echo 'Database data success_email_to added successfully<br>';
|
417
|
}
|
418
|
echo mysql_error().'<br />';
|
419
|
|
420
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_text` = '$success_email_text' WHERE `section_id` = $section_id")) {
|
421
|
echo 'Database data success_email_text added successfully<br>';
|
422
|
}
|
423
|
echo mysql_error().'<br />';
|
424
|
|
425
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_subject` = '$success_email_subject' WHERE `section_id` = $section_id")) {
|
426
|
echo 'Database data success_email_subject added successfully<br>';
|
427
|
}
|
428
|
echo mysql_error().'<br />';
|
429
|
|
430
|
}
|
431
|
|
432
|
// copy field email_to to success_email_from
|
433
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
|
434
|
while($result = $query_dates->fetchRow()) {
|
435
|
|
436
|
echo "<B>Copying field email_to to success_email_from for form section_id= ".$result['section_id']."</B><BR>";
|
437
|
$section_id = $result['section_id'];
|
438
|
|
439
|
$success_email_from = $result['email_to'];
|
440
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_from` = '$success_email_from' WHERE `section_id` = $section_id")) {
|
441
|
echo 'Copyied field email_to to success_email_from successfully<br>';
|
442
|
}
|
443
|
echo mysql_error().'<br />';
|
444
|
}
|
445
|
|
446
|
//******************************************************************************
|
447
|
//End of upgrade script for the form modul
|
448
|
//******************************************************************************
|
449
|
|
450
|
//******************************************************************************
|
451
|
//Start of upgrade script for the news modul
|
452
|
//******************************************************************************
|
453
|
|
454
|
echo "<BR><B>Adding new field to database table mod_news_posts</B><BR>";
|
455
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_news_posts` ADD `published_when` INT NOT NULL AFTER `commenting`")) {
|
456
|
echo 'Database Field published_when added successfully<br />';
|
457
|
}
|
458
|
echo mysql_error().'<br />';
|
459
|
|
460
|
// UPDATING DATA INTO FIELDS
|
461
|
echo "<BR>";
|
462
|
|
463
|
// These are the default setting
|
464
|
$header = '<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"98%\">';
|
465
|
$post_loop = '<tr class=\"post_top\">
|
466
|
<td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
|
467
|
<td class=\"post_date\">[MODI_TIME], [MODI_DATE]</td>
|
468
|
</tr>
|
469
|
<tr>
|
470
|
<td class=\"post_short\" colspan=\"2\">
|
471
|
[SHORT]
|
472
|
<a href=\"[LINK]\">[TEXT_READ_MORE]</a>
|
473
|
</td>
|
474
|
</tr>';
|
475
|
$post_header = addslashes('<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
476
|
<tr>
|
477
|
<td height="30"><h1>[TITLE]</h1></td>
|
478
|
<td rowspan="3" style="display: [DISPLAY_IMAGE]"><img src="[GROUP_IMAGE]" alt="[GROUP_TITLE]" /></td>
|
479
|
</tr>
|
480
|
<tr>
|
481
|
<td valign="top"><b>Posted by [DISPLAY_NAME] ([USERNAME]) on [PUBL_DATE]</b></td>
|
482
|
</tr>
|
483
|
<tr style="display: [DISPLAY_GROUP]">
|
484
|
<td valign="top"><a href="[BACK]">[PAGE_TITLE]</a> >> <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
|
485
|
</tr>
|
486
|
</table>
|
487
|
<p style="text-align: justify;">');
|
488
|
$post_footer = '</p><p>Last changed: [MODI_DATE] at [MODI_TIME]</p>
|
489
|
<a href=\"[BACK]\">Back</a>';
|
490
|
$comments_header = addslashes('<br /><br />
|
491
|
<h2>Comments</h2>
|
492
|
<table cellpadding="2" cellspacing="0" border="0" width="98%">');
|
493
|
|
494
|
// Insert default settings into database
|
495
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
|
496
|
while($result = $query_dates->fetchRow()) {
|
497
|
|
498
|
echo "<B>Add default settings data to database for news section_id= ".$result['section_id']."</b><BR>";
|
499
|
$section_id = $result['section_id'];
|
500
|
|
501
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
|
502
|
echo 'Database data header added successfully<br>';
|
503
|
}
|
504
|
echo mysql_error().'<br />';
|
505
|
|
506
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
|
507
|
echo 'Database data post_loop added successfully<br>';
|
508
|
}
|
509
|
echo mysql_error().'<br />';
|
510
|
|
511
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
|
512
|
echo 'Database data post_header added successfully<br>';
|
513
|
}
|
514
|
echo mysql_error().'<br />';
|
515
|
|
516
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
|
517
|
echo 'Database data post_footer added successfully<br>';
|
518
|
}
|
519
|
echo mysql_error().'<br />';
|
520
|
|
521
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
|
522
|
echo 'Database data comments_header added successfully<br>';
|
523
|
}
|
524
|
echo mysql_error().'<br />';
|
525
|
|
526
|
}
|
527
|
|
528
|
// MIGRATING FIELD DATES to POSTED_WHEN
|
529
|
echo "<B>Copying field posted_when value to published_when</B><BR>";
|
530
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts where section_id != 0 and page_id != 0");
|
531
|
|
532
|
while($result = $query_dates->fetchRow()) {
|
533
|
$pid = $result['post_id'];
|
534
|
$NEW_DATE = $result['posted_when'];
|
535
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_posts` SET `published_when` = '$NEW_DATE' WHERE `post_id` = $pid")) {
|
536
|
echo 'Copying posted_when value to published_when successfully<br>';
|
537
|
}
|
538
|
echo mysql_error().'<br />';
|
539
|
}
|
540
|
|
541
|
//******************************************************************************
|
542
|
//End of upgrade script for the news modul
|
543
|
//******************************************************************************
|
544
|
|
545
|
echo "<br /><br />Done<br />";
|
546
|
|
547
|
?>
|
548
|
|
549
|
</body>
|
550
|
</html>
|