1
|
<?php
|
2
|
|
3
|
// $Id: upgrade-script.php 560 2008-01-18 20:42:06Z Ruebenwurzel $
|
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 D".TABLE_PREFIX."search (name,value,extra) VALUES ('$key', '$value', '')");
|
70
|
echo 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().'<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().'<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
|
$query = $database->query("DESCRIBE $table 'publ_start'");
|
179
|
if($query->numRows() > 0) {
|
180
|
echo "'publ_start' added. $OK.<br />";
|
181
|
} else {
|
182
|
echo "adding 'publ_start' $FAIL!<br />";
|
183
|
}
|
184
|
} else {
|
185
|
echo "'publ_start' allready there. $OK.<br />";
|
186
|
}
|
187
|
$query = $database->query("DESCRIBE $table 'publ_end'");
|
188
|
if($query->numRows() == 0) { // add field
|
189
|
$query = $database->query("ALTER TABLE $table ADD publ_end INT NOT NULL DEFAULT '0'");
|
190
|
$query = $database->query("DESCRIBE $table 'publ_end'");
|
191
|
if($query->numRows() > 0) {
|
192
|
echo "'publ_end' added. $OK.<br />";
|
193
|
} else {
|
194
|
echo "adding 'publ_end' $FAIL!<br />";
|
195
|
}
|
196
|
} else {
|
197
|
echo "'publ_end' allready there. $OK<br />";
|
198
|
}
|
199
|
|
200
|
|
201
|
//******************************************************************************
|
202
|
//The following lines upgrades the form modul from 2.6.x to the andvanced version from 2.7.x
|
203
|
//******************************************************************************
|
204
|
|
205
|
$database = new database(DB_URL);
|
206
|
|
207
|
echo "<BR><B>Adding new field to database table mod_form_settings</B><BR>";
|
208
|
|
209
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_subject` VARCHAR(255) NOT NULL AFTER `success_message`")) {
|
210
|
echo 'Database Field success_email_subject added successfully<br />';
|
211
|
}
|
212
|
echo mysql_error().'<br />';
|
213
|
|
214
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_text` TEXT NOT NULL AFTER `success_message`")) {
|
215
|
echo 'Database Field success_email_text added successfully<br />';
|
216
|
}
|
217
|
echo mysql_error().'<br />';
|
218
|
|
219
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_from` VARCHAR(255) NOT NULL AFTER `success_message`")) {
|
220
|
echo 'Database Field success_email_from added successfully<br />';
|
221
|
}
|
222
|
echo mysql_error().'<br />';
|
223
|
|
224
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_to` TEXT NOT NULL AFTER `success_message`")) {
|
225
|
echo 'Database Field success_email_to added successfully<br />';
|
226
|
}
|
227
|
echo mysql_error().'<br />';
|
228
|
|
229
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_page` TEXT NOT NULL AFTER `success_message`")) {
|
230
|
echo 'Database Field success_page added successfully<br />';
|
231
|
}
|
232
|
echo mysql_error().'<br />';
|
233
|
|
234
|
echo "<BR><B>Deleting field success_message from table mod_form_settings</B><BR>";
|
235
|
|
236
|
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` DROP `success_message`")) {
|
237
|
echo 'Database field success_message droped successfully<br>';
|
238
|
}
|
239
|
echo mysql_error().'<br />';
|
240
|
|
241
|
|
242
|
// UPDATING DATA INTO FIELDS
|
243
|
echo "<BR>";
|
244
|
|
245
|
// These are the default setting
|
246
|
$success_page = 'none';
|
247
|
$success_email_to = '';
|
248
|
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
|
249
|
$success_email_text = addslashes($success_email_text);
|
250
|
$success_email_subject = 'You have submitted a form';
|
251
|
|
252
|
// Insert default settings into database
|
253
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
|
254
|
while($result = $query_dates->fetchRow()) {
|
255
|
|
256
|
echo "<B>Add default settings data to database for form section_id= ".$result['section_id']."</b><BR>";
|
257
|
$section_id = $result['section_id'];
|
258
|
|
259
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_page` = '$success_page' WHERE `section_id` = $section_id")) {
|
260
|
echo 'Database data success_page added successfully<br>';
|
261
|
}
|
262
|
echo mysql_error().'<br />';
|
263
|
|
264
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_to` = '$success_email_to' WHERE `section_id` = $section_id")) {
|
265
|
echo 'Database data success_email_to added successfully<br>';
|
266
|
}
|
267
|
echo mysql_error().'<br />';
|
268
|
|
269
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_text` = '$success_email_text' WHERE `section_id` = $section_id")) {
|
270
|
echo 'Database data success_email_text added successfully<br>';
|
271
|
}
|
272
|
echo mysql_error().'<br />';
|
273
|
|
274
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_subject` = '$success_email_subject' WHERE `section_id` = $section_id")) {
|
275
|
echo 'Database data success_email_subject added successfully<br>';
|
276
|
}
|
277
|
echo mysql_error().'<br />';
|
278
|
|
279
|
}
|
280
|
|
281
|
// copy field email_to to success_email_from
|
282
|
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
|
283
|
while($result = $query_dates->fetchRow()) {
|
284
|
|
285
|
echo "<B>Copying field email_to to success_email_from for form section_id= ".$result['section_id']."</B><BR>";
|
286
|
$section_id = $result['section_id'];
|
287
|
|
288
|
$success_email_from = $result['email_to'];
|
289
|
if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_from` = '$success_email_from' WHERE `section_id` = $section_id")) {
|
290
|
echo 'Copyied field email_to to success_email_from successfully<br>';
|
291
|
}
|
292
|
echo mysql_error().'<br />';
|
293
|
}
|
294
|
|
295
|
//******************************************************************************
|
296
|
//End of upgrade script for the form modul
|
297
|
//******************************************************************************
|
298
|
|
299
|
echo "<br /><br />Done<br />";
|
300
|
|
301
|
?>
|
302
|
|
303
|
</body>
|
304
|
</html>
|