1
|
<?php
|
2
|
|
3
|
// $Id: upgrade-script.php 600 2008-01-26 11:26:54Z 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
|
|
83
|
|
84
|
echo "<br /><u>Adding module_order and max_excerpt to search-table</u><br />";
|
85
|
// module_order - in which order to show the search-results
|
86
|
// max_excerpt - how many lines of excerpt to print per matching page
|
87
|
|
88
|
$cfg = array(
|
89
|
'module_order' => 'faqbaker,manual,wysiwyg',
|
90
|
'max_excerpt' => '15'
|
91
|
);
|
92
|
foreach($cfg as $key=>$value) {
|
93
|
db_add_search_key_value($key, $value);
|
94
|
}
|
95
|
|
96
|
|
97
|
echo "<br /><u>Changing results_loop in search-table</u><br />";
|
98
|
// adding [EXCERPT]
|
99
|
|
100
|
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1");
|
101
|
if($query->numRows() > 0) {
|
102
|
$fetch_results_loop = $query->fetchRow();
|
103
|
$string = $fetch_results_loop['value'];
|
104
|
if(preg_match("/\[EXCERPT\]/", $string)) {
|
105
|
echo "[EXCERPT] is allready there. $OK.<br />";
|
106
|
} else {
|
107
|
$string = preg_replace("/10px;\">\[DESCRIPTION\]/", "5px;\">[DESCRIPTION]", $string);
|
108
|
$string .= "<tr><td colspan=\"2\" style=\"text-align: justify; padding-bottom: 10px;\">[EXCERPT]</td></tr>";
|
109
|
$string = addslashes($string);
|
110
|
$database->query("UPDATE ".TABLE_PREFIX."search SET name='results_loop',value='".$string."',extra='' WHERE name = 'results_loop' LIMIT 1");
|
111
|
echo mysql_error()?mysql_error().'<br />':'';
|
112
|
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1");
|
113
|
if($query->numRows() > 0) {
|
114
|
$fetch_results_loop = $query->fetchRow();
|
115
|
$string = $fetch_results_loop['value'];
|
116
|
if(preg_match("/\[EXCERPT\]/", $string)) {
|
117
|
echo "[EXCERPT] added. $OK.<br />";
|
118
|
} else {
|
119
|
echo "adding [EXCERPT] $FAIL!<br />";
|
120
|
}
|
121
|
}
|
122
|
}
|
123
|
}
|
124
|
|
125
|
echo "<br /><u>Changing \"Header:\" in search-table</u><br />";
|
126
|
// adding [SEARCH_PATH]
|
127
|
|
128
|
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1");
|
129
|
if($query->numRows() > 0) {
|
130
|
$fetch_header = $query->fetchRow();
|
131
|
$string = $fetch_header['value'];
|
132
|
if(preg_match("/\[SEARCH_PATH\]/", $string)) {
|
133
|
echo "[SEARCH_PATH] is allready there. $OK.<br />";
|
134
|
} else {
|
135
|
$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);
|
136
|
$string = addslashes($string);
|
137
|
$database->query("UPDATE ".TABLE_PREFIX."search SET name='header',value='".$string."',extra='' WHERE name = 'header' LIMIT 1");
|
138
|
echo mysql_error()?mysql_error().'<br />':'';
|
139
|
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1");
|
140
|
if($query->numRows() > 0) {
|
141
|
$fetch_header = $query->fetchRow();
|
142
|
$string = $fetch_header['value'];
|
143
|
if(preg_match("/\[SEARCH_PATH\]/", $string)) {
|
144
|
echo "[SEARCH_PATH] added. $OK.<br />";
|
145
|
} else {
|
146
|
echo "adding [SEARCH_PATH] $FAIL!<br />";
|
147
|
}
|
148
|
}
|
149
|
}
|
150
|
}
|
151
|
|
152
|
echo "<br /><u>Adding some internal config-elements to search-table</u><br />";
|
153
|
// These are global config-elements which don't appear in settings-page. Change them in the database if needed.
|
154
|
// cfg_show_description - whether to show page-description on the results page (true/false), def: true
|
155
|
// cfg_search_description - whether to search in page-description (true/false), def: true [only used while searching title/link/description/keywords]
|
156
|
// cfg_search_keywords - whether to search in page-keywords (true/false), def: true [only used while searching title/link/description/keywords]
|
157
|
// cfg_enable_old_search - use old search-method, too (true/false), def: true [use old method as fallback]
|
158
|
$cfg = array(
|
159
|
'cfg_show_description' => 'true',
|
160
|
'cfg_search_description' => 'true',
|
161
|
'cfg_search_keywords' => 'true',
|
162
|
'cfg_enable_old_search' => 'true'
|
163
|
);
|
164
|
foreach($cfg as $key=>$value) {
|
165
|
db_add_search_key_value($key, $value);
|
166
|
}
|
167
|
|
168
|
|
169
|
/**********************************************************
|
170
|
* - publish-by-date
|
171
|
*/
|
172
|
echo "<br /><u>Adding fields 'publ_start' and 'publ_end' to table 'sections'</u><br />";
|
173
|
// Add fields "publ_start" and "publ_end" to table "sections"
|
174
|
// check if fields are present
|
175
|
$table = TABLE_PREFIX."sections";
|
176
|
$query = $database->query("DESCRIBE $table 'publ_start'");
|
177
|
if($query->numRows() == 0) { // add field
|
178
|
$query = $database->query("ALTER TABLE $table ADD publ_start INT NOT NULL DEFAULT '0'");
|
179
|
echo mysql_error()?mysql_error().'<br />':'';
|
180
|
$query = $database->query("DESCRIBE $table 'publ_start'");
|
181
|
echo mysql_error()?mysql_error().'<br />':'';
|
182
|
if($query->numRows() > 0) {
|
183
|
echo "'publ_start' added. $OK.<br />";
|
184
|
} else {
|
185
|
echo "adding 'publ_start' $FAIL!<br />";
|
186
|
}
|
187
|
} else {
|
188
|
echo "'publ_start' allready there. $OK.<br />";
|
189
|
}
|
190
|
$query = $database->query("DESCRIBE $table 'publ_end'");
|
191
|
if($query->numRows() == 0) { // add field
|
192
|
$query = $database->query("ALTER TABLE $table ADD publ_end INT NOT NULL DEFAULT '0'");
|
193
|
echo mysql_error()?mysql_error().'<br />':'';
|
194
|
$query = $database->query("DESCRIBE $table 'publ_end'");
|
195
|
if($query->numRows() > 0) {
|
196
|
echo "'publ_end' added. $OK.<br />";
|
197
|
} else {
|
198
|
echo "adding 'publ_end' $FAIL!<br />";
|
199
|
}
|
200
|
} else {
|
201
|
echo "'publ_end' allready there. $OK<br />";
|
202
|
}
|
203
|
|
204
|
|
205
|
/**********************************************************
|
206
|
* - core-module menu_link
|
207
|
*/
|
208
|
echo "<br /><u>Convert menu_links</u><br />";
|
209
|
// create table
|
210
|
$table = TABLE_PREFIX ."mod_menu_link";
|
211
|
$database->query("DROP TABLE IF EXISTS `$table`");
|
212
|
$database->query("
|
213
|
CREATE TABLE `$table` (
|
214
|
`section_id` INT(11) NOT NULL DEFAULT '0',
|
215
|
`page_id` INT(11) NOT NULL DEFAULT '0',
|
216
|
`target_page_id` INT(11) NOT NULL DEFAULT '0',
|
217
|
`anchor` VARCHAR(255) NOT NULL DEFAULT '0' ,
|
218
|
PRIMARY KEY (`section_id`)
|
219
|
)
|
220
|
");
|
221
|
// fetch all menu_link-pages in $pages
|
222
|
$pages = array();
|
223
|
$table_p = TABLE_PREFIX.'pages';
|
224
|
$table_s = TABLE_PREFIX.'sections';
|
225
|
$table_mm = TABLE_PREFIX ."mod_menu_link";
|
226
|
|
227
|
$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'");
|
228
|
if($query_page->numRows() > 0) {
|
229
|
while($page = $query_page->fetchRow()) {
|
230
|
$pages[$page['page_id']]['page_details'] = $page;
|
231
|
}
|
232
|
}
|
233
|
// get all related files with content from pages/ in $pages, too
|
234
|
function list_files_dirs($dir, $depth=true, $files=array(), $dirs=array()) {
|
235
|
$dh=opendir($dir);
|
236
|
while(($file = readdir($dh)) !== false) {
|
237
|
if($file == '.' || $file == '..') {
|
238
|
continue;
|
239
|
}
|
240
|
if(is_dir($dir.'/'.$file)) {
|
241
|
if($depth) {
|
242
|
$dirs[] = $dir.'/'.$file;
|
243
|
list($files, $dirs) = list_files_dirs($dir.'/'.$file, $depth, $files, $dirs);
|
244
|
}
|
245
|
} else {
|
246
|
$files[] = $dir.'/'.$file;
|
247
|
}
|
248
|
}
|
249
|
closedir($dh);
|
250
|
natcasesort($files);
|
251
|
natcasesort($dirs);
|
252
|
return(array($files, $dirs));
|
253
|
}
|
254
|
list($files, $dirs) = list_files_dirs(WB_PATH.PAGES_DIRECTORY);
|
255
|
foreach($files as $file) {
|
256
|
if(($content = implode('', file($file))) !== FALSE) {
|
257
|
if(preg_match('/\$page_id = (\d+)/', $content, $matches)) {
|
258
|
if(array_key_exists($matches[1], $pages)) {
|
259
|
$pages[$matches[1]]['file_content'] = $content;
|
260
|
$pages[$matches[1]]['filename'] = $file;
|
261
|
}
|
262
|
}
|
263
|
}
|
264
|
}
|
265
|
unset($files); unset($dirs);
|
266
|
// try to convert old menu_links to new ones
|
267
|
foreach($pages as $p) {
|
268
|
$page = $p['page_details'];
|
269
|
$file_content = $p['file_content'];
|
270
|
$filename = $p['filename'];
|
271
|
$link = $p['page_details']['link'];
|
272
|
$parent_pid = $p['page_details']['parent'];
|
273
|
$page_id = $p['page_details']['page_id'];
|
274
|
$section_id = $p['page_details']['section_id'];
|
275
|
$menu_title = $p['page_details']['menu_title'];
|
276
|
|
277
|
// calculate link from wb_pages.parent and menu_title
|
278
|
$cur_link = '';
|
279
|
if($parent_pid != '0' && $query_link = $database->query("SELECT link FROM $table_p WHERE page_id = '$parent_pid'")) {
|
280
|
$res = $query_link->fetchRow();
|
281
|
$cur_link .= $res['link'];
|
282
|
}
|
283
|
$cur_link .= '/'.page_filename($menu_title);
|
284
|
echo "found: $cur_link<br />";
|
285
|
$database->query("UPDATE $table_p SET link = '$cur_link' WHERE page_id = '$page_id'");
|
286
|
echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
|
287
|
|
288
|
$new_filenames[$page_id]['file'] = WB_PATH.PAGES_DIRECTORY.$cur_link.PAGE_EXTENSION;
|
289
|
$new_filenames[$page_id]['link'] = $cur_link;
|
290
|
$new_filenames[$page_id]['menu'] = $menu_title;
|
291
|
|
292
|
// delete old access files in pages
|
293
|
if(file_exists($filename)) {
|
294
|
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
|
295
|
echo "Cannot delete access file in pages/ - permission denied ($FAIL)<br />";
|
296
|
} else {
|
297
|
unlink($filename);
|
298
|
}
|
299
|
}
|
300
|
|
301
|
// make entry in wb_mod_menu_link
|
302
|
if($query_pid = $database->query("SELECT page_id FROM $table_p WHERE page_id != '$page_id' AND link = '$link'")) {
|
303
|
$res = $query_pid->fetchRow();
|
304
|
$target_page_id = $res['page_id'];
|
305
|
$database->query("INSERT INTO $table_mm (page_id, section_id, target_page_id, anchor) VALUES ('$page_id', '$section_id', '$target_page_id', '0')");
|
306
|
echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
|
307
|
}
|
308
|
}
|
309
|
// create new access files in pages/; make directories as needed
|
310
|
foreach($pages as $p) {
|
311
|
$page_id = $p['page_details']['page_id'];
|
312
|
$filename = $new_filenames[$page_id]['file'];
|
313
|
$menu_title = $new_filenames[$page_id]['menu'];
|
314
|
$link = $new_filenames[$page_id]['link'];
|
315
|
$content = $p['file_content'];
|
316
|
$level = $p['page_details']['level'];
|
317
|
$depth = '';
|
318
|
for($i=0; $i<=$level; $i++)
|
319
|
$depth .= '../';
|
320
|
$content = preg_replace('#((../)+)config\.php#', "{$depth}config.php", $content);
|
321
|
while(file_exists($filename)) {
|
322
|
echo "Cannot create '$filename' - file exist. Renamed to: ";
|
323
|
$menu_title .= '_';
|
324
|
$link .= '_';
|
325
|
$filename = WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
|
326
|
echo "$filename<br />";
|
327
|
$database->query("UPDATE $table_p SET link='$link', menu_title='$menu_title' WHERE page_id = '$page_id'");
|
328
|
echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
|
329
|
}
|
330
|
// check if we need to create a subdir somewhere
|
331
|
$dirs = array();
|
332
|
while(dirname($link) != '/') {
|
333
|
$link = dirname($link);
|
334
|
$dirs[] = WB_PATH.PAGES_DIRECTORY.$link;
|
335
|
}
|
336
|
foreach(array_reverse($dirs) as $dir) {
|
337
|
if(!file_exists($dir)) {
|
338
|
mkdir($dir, OCTAL_DIR_MODE);
|
339
|
}
|
340
|
}
|
341
|
// create new file in pages/
|
342
|
if($handle=fopen($filename, "wb")) {
|
343
|
if(!fwrite($handle, $content)) {
|
344
|
echo "Cannot write to $filename - ($FAIL)<br />";
|
345
|
}
|
346
|
fclose($handle);
|
347
|
} else {
|
348
|
echo "Cannot create $filename - ($FAIL)<br />";
|
349
|
}
|
350
|
|
351
|
}
|
352
|
|
353
|
/**********************************************************
|
354
|
* - asp - Advanced Spam Protection
|
355
|
*/
|
356
|
echo "<br /><u>Adding table mod_captcha_control</u><br />";
|
357
|
$table = TABLE_PREFIX.'mod_captcha_control';
|
358
|
$database->query("DROP TABLE IF EXISTS `$table`");
|
359
|
$database->query("CREATE TABLE `$table` (
|
360
|
`enabled_captcha` VARCHAR(1) NOT NULL DEFAULT '1',
|
361
|
`enabled_asp` VARCHAR(1) NOT NULL DEFAULT '1',
|
362
|
`captcha_type` VARCHAR(255) NOT NULL DEFAULT 'calc_text',
|
363
|
`asp_session_min_age` INT(11) NOT NULL DEFAULT '20',
|
364
|
`asp_view_min_age` INT(11) NOT NULL DEFAULT '10',
|
365
|
`asp_input_min_age` INT(11) NOT NULL DEFAULT '5'
|
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
|
//******************************************************************************
|
377
|
//Start of upgrade script for the form modul
|
378
|
//******************************************************************************
|
379
|
|
380
|
echo "<BR><B>Adding new field to database table mod_form_settings</B><BR>";
|
381
|
|
382
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_subject` VARCHAR(255) NOT NULL AFTER `success_message`")) {
|
383
|
echo 'Database Field success_email_subject added successfully<br />';
|
384
|
}
|
385
|
echo mysql_error().'<br />';
|
386
|
|
387
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_text` TEXT NOT NULL AFTER `success_message`")) {
|
388
|
echo 'Database Field success_email_text added successfully<br />';
|
389
|
}
|
390
|
echo mysql_error().'<br />';
|
391
|
|
392
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_from` VARCHAR(255) NOT NULL AFTER `success_message`")) {
|
393
|
echo 'Database Field success_email_from added successfully<br />';
|
394
|
}
|
395
|
echo mysql_error().'<br />';
|
396
|
|
397
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_to` TEXT NOT NULL AFTER `success_message`")) {
|
398
|
echo 'Database Field success_email_to added successfully<br />';
|
399
|
}
|
400
|
echo mysql_error().'<br />';
|
401
|
|
402
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_page` TEXT NOT NULL AFTER `success_message`")) {
|
403
|
echo 'Database Field success_page added successfully<br />';
|
404
|
}
|
405
|
echo mysql_error().'<br />';
|
406
|
|
407
|
echo "<BR><B>Deleting field success_message from table mod_form_settings</B><BR>";
|
408
|
|
409
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` DROP `success_message`")) {
|
410
|
echo 'Database field success_message droped successfully<br>';
|
411
|
}
|
412
|
echo mysql_error().'<br />';
|
413
|
|
414
|
|
415
|
// UPDATING DATA INTO FIELDS
|
416
|
echo "<BR>";
|
417
|
|
418
|
// These are the default setting
|
419
|
$success_page = 'none';
|
420
|
$success_email_to = '';
|
421
|
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
|
422
|
$success_email_text = addslashes($success_email_text);
|
423
|
$success_email_subject = 'You have submitted a form';
|
424
|
|
425
|
// Insert default settings into database
|
426
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
|
427
|
while($result = $query_dates->fetchRow()) {
|
428
|
|
429
|
echo "<B>Add default settings data to database for form section_id= ".$result['section_id']."</b><BR>";
|
430
|
$section_id = $result['section_id'];
|
431
|
|
432
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_page` = '$success_page' WHERE `section_id` = $section_id")) {
|
433
|
echo 'Database data success_page added successfully<br>';
|
434
|
}
|
435
|
echo mysql_error().'<br />';
|
436
|
|
437
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_to` = '$success_email_to' WHERE `section_id` = $section_id")) {
|
438
|
echo 'Database data success_email_to added successfully<br>';
|
439
|
}
|
440
|
echo mysql_error().'<br />';
|
441
|
|
442
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_text` = '$success_email_text' WHERE `section_id` = $section_id")) {
|
443
|
echo 'Database data success_email_text added successfully<br>';
|
444
|
}
|
445
|
echo mysql_error().'<br />';
|
446
|
|
447
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_subject` = '$success_email_subject' WHERE `section_id` = $section_id")) {
|
448
|
echo 'Database data success_email_subject added successfully<br>';
|
449
|
}
|
450
|
echo mysql_error().'<br />';
|
451
|
|
452
|
}
|
453
|
|
454
|
// copy field email_to to success_email_from
|
455
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
|
456
|
while($result = $query_dates->fetchRow()) {
|
457
|
|
458
|
echo "<B>Copying field email_to to success_email_from for form section_id= ".$result['section_id']."</B><BR>";
|
459
|
$section_id = $result['section_id'];
|
460
|
|
461
|
$success_email_from = $result['email_to'];
|
462
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_from` = '$success_email_from' WHERE `section_id` = $section_id")) {
|
463
|
echo 'Copyied field email_to to success_email_from successfully<br>';
|
464
|
}
|
465
|
echo mysql_error().'<br />';
|
466
|
}
|
467
|
|
468
|
//******************************************************************************
|
469
|
//End of upgrade script for the form modul
|
470
|
//******************************************************************************
|
471
|
|
472
|
//******************************************************************************
|
473
|
//Start of upgrade script for the news modul
|
474
|
//******************************************************************************
|
475
|
|
476
|
echo "<BR><B>Adding new fields to database table mod_news_posts</B><BR>";
|
477
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_news_posts` ADD `published_when` INT NOT NULL AFTER `commenting`")) {
|
478
|
echo 'Database Field published_when added successfully<br />';
|
479
|
}
|
480
|
echo mysql_error().'<br />';
|
481
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_news_posts` ADD `published_until` INT NOT NULL AFTER `published_when`")) {
|
482
|
echo 'Database Field published_until added successfully<br />';
|
483
|
}
|
484
|
echo mysql_error().'<br />';
|
485
|
|
486
|
// UPDATING DATA INTO FIELDS
|
487
|
echo "<BR>";
|
488
|
|
489
|
// These are the default setting
|
490
|
$header = '<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"98%\">';
|
491
|
$post_loop = '<tr class=\"post_top\">
|
492
|
<td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
|
493
|
<td class=\"post_date\">[MODI_TIME], [MODI_DATE]</td>
|
494
|
</tr>
|
495
|
<tr>
|
496
|
<td class=\"post_short\" colspan=\"2\">
|
497
|
[SHORT]
|
498
|
<a href=\"[LINK]\">[TEXT_READ_MORE]</a>
|
499
|
</td>
|
500
|
</tr>';
|
501
|
$post_header = addslashes('<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
502
|
<tr>
|
503
|
<td height="30"><h1>[TITLE]</h1></td>
|
504
|
<td rowspan="3" style="display: [DISPLAY_IMAGE]"><img src="[GROUP_IMAGE]" alt="[GROUP_TITLE]" /></td>
|
505
|
</tr>
|
506
|
<tr>
|
507
|
<td valign="top"><b>Posted by [DISPLAY_NAME] ([USERNAME]) on [PUBL_DATE]</b></td>
|
508
|
</tr>
|
509
|
<tr style="display: [DISPLAY_GROUP]">
|
510
|
<td valign="top"><a href="[BACK]">[PAGE_TITLE]</a> >> <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
|
511
|
</tr>
|
512
|
</table>
|
513
|
<p style="text-align: justify;">');
|
514
|
$post_footer = '</p><p>Last changed: [MODI_DATE] at [MODI_TIME]</p>
|
515
|
<a href=\"[BACK]\">Back</a>';
|
516
|
$comments_header = addslashes('<br /><br />
|
517
|
<h2>Comments</h2>
|
518
|
<table cellpadding="2" cellspacing="0" border="0" width="98%">');
|
519
|
|
520
|
// Insert default settings into database
|
521
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
|
522
|
while($result = $query_dates->fetchRow()) {
|
523
|
|
524
|
echo "<B>Add default settings data to database for news section_id= ".$result['section_id']."</b><BR>";
|
525
|
$section_id = $result['section_id'];
|
526
|
|
527
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
|
528
|
echo 'Database data header added successfully<br>';
|
529
|
}
|
530
|
echo mysql_error().'<br />';
|
531
|
|
532
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
|
533
|
echo 'Database data post_loop added successfully<br>';
|
534
|
}
|
535
|
echo mysql_error().'<br />';
|
536
|
|
537
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
|
538
|
echo 'Database data post_header added successfully<br>';
|
539
|
}
|
540
|
echo mysql_error().'<br />';
|
541
|
|
542
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
|
543
|
echo 'Database data post_footer added successfully<br>';
|
544
|
}
|
545
|
echo mysql_error().'<br />';
|
546
|
|
547
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
|
548
|
echo 'Database data comments_header added successfully<br>';
|
549
|
}
|
550
|
echo mysql_error().'<br />';
|
551
|
|
552
|
}
|
553
|
|
554
|
// MIGRATING FIELD DATES to POSTED_WHEN
|
555
|
echo "<B>Copying field posted_when value to published_when</B><BR>";
|
556
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts where section_id != 0 and page_id != 0");
|
557
|
|
558
|
while($result = $query_dates->fetchRow()) {
|
559
|
$pid = $result['post_id'];
|
560
|
$NEW_DATE = $result['posted_when'];
|
561
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_news_posts` SET `published_when` = '$NEW_DATE' WHERE `post_id` = $pid")) {
|
562
|
echo 'Copying posted_when value to published_when successfully<br>';
|
563
|
}
|
564
|
echo mysql_error().'<br />';
|
565
|
}
|
566
|
|
567
|
//******************************************************************************
|
568
|
//End of upgrade script for the news modul
|
569
|
//******************************************************************************
|
570
|
|
571
|
echo "<br /><br />Done<br />";
|
572
|
|
573
|
?>
|
574
|
|
575
|
</body>
|
576
|
</html>
|