Revision 648
Added by thorn almost 17 years ago
upgrade-script.php | ||
---|---|---|
39 | 39 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
40 | 40 |
</head> |
41 | 41 |
<body> |
42 |
<!-- |
|
42 | 43 |
<style type="text/css"> |
43 |
<!-- |
|
44 | 44 |
*.red { background-color:#FF0000 } |
45 | 45 |
*.green { background-color:#00FF00 } |
46 |
</style> |
|
46 | 47 |
--> |
47 |
</style> |
|
48 |
|
|
49 | 48 |
<h2>Upgrade-script</h2> |
50 | 49 |
<p> |
51 | 50 |
will upgrade Website Baker 2.6.5 / 2.6.7 to version 2.7 |
... | ... | |
68 | 67 |
return true; |
69 | 68 |
} else { |
70 | 69 |
$database->query("INSERT INTO $table (name,value,extra) VALUES ('$key', '$value', '')"); |
71 |
echo mysql_error()?mysql_error().'<br />':'';
|
|
70 |
echo (mysql_error()?mysql_error().'<br />':'');
|
|
72 | 71 |
$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1"); |
73 | 72 |
if($query->numRows() > 0) { |
74 | 73 |
echo "$key: $OK.<br />"; |
... | ... | |
81 | 80 |
} |
82 | 81 |
function db_add_field($field, $table, $desc) { |
83 | 82 |
global $database; global $OK; global $FAIL; |
84 |
echo "<br /><u>Adding field '$field' to table '$table'</u><br />";
|
|
83 |
echo "<u>Adding field '$field' to table '$table'</u><br />"; |
|
85 | 84 |
$table = TABLE_PREFIX.$table; |
86 | 85 |
$query = $database->query("DESCRIBE $table '$field'"); |
87 | 86 |
if($query->numRows() == 0) { // add field |
88 | 87 |
$query = $database->query("ALTER TABLE $table ADD $field $desc"); |
89 |
echo mysql_error()?mysql_error().'<br />':'';
|
|
88 |
echo (mysql_error()?mysql_error().'<br />':'');
|
|
90 | 89 |
$query = $database->query("DESCRIBE $table '$field'"); |
91 |
echo mysql_error()?mysql_error().'<br />':'';
|
|
90 |
echo (mysql_error()?mysql_error().'<br />':'');
|
|
92 | 91 |
if($query->numRows() > 0) { |
93 | 92 |
echo "'$field' added. $OK.<br />"; |
94 | 93 |
} else { |
... | ... | |
142 | 141 |
$string .= "<tr><td colspan=\"2\" style=\"text-align: justify; padding-bottom: 10px;\">[EXCERPT]</td></tr>"; |
143 | 142 |
$string = addslashes($string); |
144 | 143 |
$database->query("UPDATE ".TABLE_PREFIX."search SET name='results_loop',value='".$string."',extra='' WHERE name = 'results_loop' LIMIT 1"); |
145 |
echo mysql_error()?mysql_error().'<br />':'';
|
|
144 |
echo (mysql_error()?mysql_error().'<br />':'');
|
|
146 | 145 |
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'results_loop' LIMIT 1"); |
147 | 146 |
if($query->numRows() > 0) { |
148 | 147 |
$fetch_results_loop = $query->fetchRow(); |
... | ... | |
169 | 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); |
170 | 169 |
$string = addslashes($string); |
171 | 170 |
$database->query("UPDATE ".TABLE_PREFIX."search SET name='header',value='".$string."',extra='' WHERE name = 'header' LIMIT 1"); |
172 |
echo mysql_error()?mysql_error().'<br />':'';
|
|
171 |
echo (mysql_error()?mysql_error().'<br />':'');
|
|
173 | 172 |
$query = $database->query("SELECT value FROM ".TABLE_PREFIX."search WHERE name = 'header' LIMIT 1"); |
174 | 173 |
if($query->numRows() > 0) { |
175 | 174 |
$fetch_header = $query->fetchRow(); |
... | ... | |
195 | 194 |
/********************************************************** |
196 | 195 |
* - core-module menu_link |
197 | 196 |
*/ |
198 |
echo "<br /><u>Convert menu_links</u><br />"; |
|
199 | 197 |
// create table |
200 | 198 |
$table = TABLE_PREFIX ."mod_menu_link"; |
201 | 199 |
$database->query("DROP TABLE IF EXISTS `$table`"); |
... | ... | |
220 | 218 |
$pages[$page['page_id']]['page_details'] = $page; |
221 | 219 |
} |
222 | 220 |
} |
221 |
if($pages!=array()) |
|
222 |
echo "<br /><u>Convert menu_links</u><br />"; |
|
223 |
|
|
223 | 224 |
// get all related files with content from pages/ in $pages, too |
224 | 225 |
function list_files_dirs($dir, $depth=true, $files=array(), $dirs=array()) { |
225 | 226 |
$dh=opendir($dir); |
... | ... | |
273 | 274 |
$cur_link .= '/'.page_filename($menu_title); |
274 | 275 |
echo "found: $cur_link<br />"; |
275 | 276 |
$database->query("UPDATE $table_p SET link = '$cur_link' WHERE page_id = '$page_id'"); |
276 |
echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
|
|
277 |
echo (mysql_error()?'mySQL: '.mysql_error().'<br />':'');
|
|
277 | 278 |
|
278 | 279 |
$new_filenames[$page_id]['file'] = WB_PATH.PAGES_DIRECTORY.$cur_link.PAGE_EXTENSION; |
279 | 280 |
$new_filenames[$page_id]['link'] = $cur_link; |
... | ... | |
293 | 294 |
$res = $query_pid->fetchRow(); |
294 | 295 |
$target_page_id = $res['page_id']; |
295 | 296 |
$database->query("INSERT INTO $table_mm (page_id, section_id, target_page_id, anchor) VALUES ('$page_id', '$section_id', '$target_page_id', '0')"); |
296 |
echo mysql_error()?'mySQL: '.mysql_error().'<br />':'';
|
|
297 |
echo (mysql_error()?'mySQL: '.mysql_error().'<br />':'');
|
|
297 | 298 |
} |
298 | 299 |
} |
299 | 300 |
// create new access files in pages/; make directories as needed |
... | ... | |
371 | 372 |
('1', '1', 'calc_text') |
372 | 373 |
"); |
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 |
} |
|
374 | 390 |
|
391 |
|
|
392 |
|
|
375 | 393 |
//****************************************************************************** |
376 | 394 |
//Start of upgrade script for the form modul |
377 | 395 |
//****************************************************************************** |
378 | 396 |
|
379 |
db_add_field('success_email_subject', 'mod_form_settings', "VARCHAR(255) NOT NULL AFTER `success_message`");
|
|
380 |
db_add_field('success_email_text', 'mod_form_settings', "TEXT NOT NULL AFTER `success_message`");
|
|
381 |
db_add_field('success_email_from', 'mod_form_settings', "VARCHAR(255) NOT NULL AFTER `success_message`");
|
|
382 |
db_add_field('success_email_to', 'mod_form_settings', "TEXT NOT NULL AFTER `success_message`");
|
|
383 |
db_add_field('success_page', 'mod_form_settings', "TEXT NOT NULL AFTER `success_message`");
|
|
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`");
|
|
384 | 402 |
db_add_field('email_fromname', 'mod_form_settings', "VARCHAR( 255 ) NOT NULL AFTER email_from"); |
385 | 403 |
db_add_field('success_email_fromname', 'mod_form_settings', "VARCHAR( 255 ) NOT NULL AFTER success_email_from"); |
386 | 404 |
|
... | ... | |
525 | 543 |
} |
526 | 544 |
|
527 | 545 |
// MIGRATING FIELD DATES to POSTED_WHEN |
528 |
echo "<B>Copying field posted_when value to published_when</B><BR>"; |
|
529 | 546 |
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts where section_id != 0 and page_id != 0"); |
530 |
|
|
547 |
if($query_dates->numRows() > 0) { |
|
548 |
echo "<B>Copying field posted_when value to published_when</B><BR>"; |
|
549 |
} |
|
531 | 550 |
while($result = $query_dates->fetchRow()) { |
532 | 551 |
$pid = $result['post_id']; |
533 | 552 |
$NEW_DATE = $result['posted_when']; |
Also available in: Unified diff
Added multi-group to upgrade-script. Did some minor changes in upgrade-script.