diff --git a/phpBB/admin/admin_forumauth.php b/phpBB/admin/admin_forumauth.php index 1a2fb4c4b0..69e097e445 100644 --- a/phpBB/admin/admin_forumauth.php +++ b/phpBB/admin/admin_forumauth.php @@ -102,20 +102,23 @@ if( isset($HTTP_POST_VARS['submit']) ) { if(isset($HTTP_POST_VARS['simpleauth'])) { - $simple_ary = $simple_auth_ary[$HTTP_POST_VARS['simpleauth']]; + $simple_ary = $simple_auth_ary[intval($HTTP_POST_VARS['simpleauth'])]; for($i = 0; $i < count($simple_ary); $i++) { $sql .= ( ( $sql != '' ) ? ', ' : '' ) . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i]; } - $sql = "UPDATE " . FORUMS_TABLE . " SET $sql WHERE forum_id = $forum_id"; + if (is_array($simple_ary)) + { + $sql = "UPDATE " . FORUMS_TABLE . " SET $sql WHERE forum_id = $forum_id"; + } } else { for($i = 0; $i < count($forum_auth_fields); $i++) { - $value = $HTTP_POST_VARS[$forum_auth_fields[$i]]; + $value = intval($HTTP_POST_VARS[$forum_auth_fields[$i]]); if ( $forum_auth_fields[$i] == 'auth_vote' ) { diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php index ecc3d058bc..0f5ae4bd57 100644 --- a/phpBB/admin/admin_forums.php +++ b/phpBB/admin/admin_forums.php @@ -55,6 +55,7 @@ $forum_auth_ary = array( if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) { $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; + $mode = htmlspecialchars($mode); } else { diff --git a/phpBB/admin/admin_groups.php b/phpBB/admin/admin_groups.php index 0e99d7d79f..2b125e2f2d 100644 --- a/phpBB/admin/admin_groups.php +++ b/phpBB/admin/admin_groups.php @@ -49,6 +49,7 @@ else if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) { $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; + $mode = htmlspecialchars($mode); } else { diff --git a/phpBB/admin/admin_ranks.php b/phpBB/admin/admin_ranks.php index 1a2cfcee63..197cf207d4 100644 --- a/phpBB/admin/admin_ranks.php +++ b/phpBB/admin/admin_ranks.php @@ -38,6 +38,7 @@ require('./pagestart.' . $phpEx); if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) { $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; + $mode = htmlspecialchars($mode); } else { diff --git a/phpBB/admin/admin_smilies.php b/phpBB/admin/admin_smilies.php index 37e14a212a..8604220ebe 100644 --- a/phpBB/admin/admin_smilies.php +++ b/phpBB/admin/admin_smilies.php @@ -57,6 +57,7 @@ require('./pagestart.' . $phpEx); if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) { $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; + $mode = htmlspecialchars($mode); } else { @@ -313,6 +314,7 @@ else if ( $mode != "" ) // $smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; + $smiley_id = intval($smiley_id); $sql = "DELETE FROM " . SMILIES_TABLE . " WHERE smilies_id = " . $smiley_id; @@ -333,6 +335,7 @@ else if ( $mode != "" ) // $smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; + $smiley_id = intval($smiley_id); $sql = "SELECT * FROM " . SMILIES_TABLE . " diff --git a/phpBB/admin/admin_styles.php b/phpBB/admin/admin_styles.php index 300c240e89..322836bf0e 100644 --- a/phpBB/admin/admin_styles.php +++ b/phpBB/admin/admin_styles.php @@ -56,6 +56,7 @@ if ($cancel) if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) { $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; + $mode = htmlspecialchars($mode); } else { @@ -488,7 +489,7 @@ switch( $mode ) $themes_title = $lang['Edit_theme']; $themes_explain = $lang['Edit_theme_explain']; - $style_id = $HTTP_GET_VARS['style_id']; + $style_id = intval($HTTP_GET_VARS['style_id']); $selected_names = array(); $selected_values = array(); @@ -703,7 +704,7 @@ switch( $mode ) $sql = "SELECT * FROM " . THEMES_TABLE . " - WHERE template_name = '$template_name'"; + WHERE template_name = '" . str_replace("\'", "''", $template_name) . "'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Could not get theme data for selected template", "", __LINE__, __FILE__, $sql); diff --git a/phpBB/admin/admin_ug_auth.php b/phpBB/admin/admin_ug_auth.php index edcd4a4f2e..44bb276320 100644 --- a/phpBB/admin/admin_ug_auth.php +++ b/phpBB/admin/admin_ug_auth.php @@ -56,6 +56,8 @@ while( list($var, $param) = @each($params) ) $user_id = intval($user_id); $group_id = intval($group_id); +$adv = intval($adv); +$mode = htmlspecialchars($mode); // // Start program - define vars diff --git a/phpBB/admin/admin_user_ban.php b/phpBB/admin/admin_user_ban.php index f1f70c9c50..f04ed7d0ed 100644 --- a/phpBB/admin/admin_user_ban.php +++ b/phpBB/admin/admin_user_ban.php @@ -277,7 +277,7 @@ if ( isset($HTTP_POST_VARS['submit']) ) { if ( $user_list[$i] != -1 ) { - $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $user_list[$i]; + $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . intval($user_list[$i]); } } } @@ -290,7 +290,7 @@ if ( isset($HTTP_POST_VARS['submit']) ) { if ( $ip_list[$i] != -1 ) { - $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $ip_list[$i]; + $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . str_replace("\'", "''", $ip_list[$i]); } } } @@ -303,7 +303,7 @@ if ( isset($HTTP_POST_VARS['submit']) ) { if ( $email_list[$i] != -1 ) { - $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . $email_list[$i]; + $where_sql .= ( ( $where_sql != '' ) ? ', ' : '' ) . str_replace("\'", "''", $email_list[$i]); } } } diff --git a/phpBB/admin/admin_users.php b/phpBB/admin/admin_users.php index 4c66e2e48d..7347ee36d7 100644 --- a/phpBB/admin/admin_users.php +++ b/phpBB/admin/admin_users.php @@ -47,6 +47,7 @@ $html_entities_replace = array('<', '>'); if( isset( $HTTP_POST_VARS['mode'] ) || isset( $HTTP_GET_VARS['mode'] ) ) { $mode = ( isset( $HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; + $mode = htmlspecialchars($mode); } else { @@ -838,7 +839,7 @@ if ( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) if( isset($HTTP_POST_VARS['avatarcategory']) ) { - $category = $HTTP_POST_VARS['avatarcategory']; + $category = htmlspecialchars($HTTP_POST_VARS['avatarcategory']); } else { diff --git a/phpBB/admin/admin_words.php b/phpBB/admin/admin_words.php index 762f8378e5..c5a016362b 100644 --- a/phpBB/admin/admin_words.php +++ b/phpBB/admin/admin_words.php @@ -39,6 +39,7 @@ require('./pagestart.' . $phpEx); if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) { $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; + $mode = htmlspecialchars($mode); } else { @@ -63,7 +64,7 @@ if( $mode != "" ) { if( $mode == "edit" || $mode == "add" ) { - $word_id = ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : 0; + $word_id = ( isset($HTTP_GET_VARS['id']) ) ? intval($HTTP_GET_VARS['id']) : 0; $template->set_filenames(array( "body" => "admin/words_edit_body.tpl") @@ -113,7 +114,7 @@ if( $mode != "" ) } else if( $mode == "save" ) { - $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : 0; + $word_id = ( isset($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : 0; $word = ( isset($HTTP_POST_VARS['word']) ) ? trim($HTTP_POST_VARS['word']) : ""; $replacement = ( isset($HTTP_POST_VARS['replacement']) ) ? trim($HTTP_POST_VARS['replacement']) : ""; @@ -150,6 +151,7 @@ if( $mode != "" ) if( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) ) { $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; + $word_id = intval($word_id); } else { diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 9db328a159..fddbea2ef1 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -3,7 +3,7 @@
-
|
+
Progress :: ";
+flush();
+
+$error_ary = array();
+$errored = false;
+if (count($sql))
+{
+ for ($i = 0; $i < count($sql); $i++)
+ {
+ _sql($sql[$i], $errored, $error_ary);
+ }
+
+ echo " Done
Result :: \n";
+
+ if ($errored)
+ {
+ echo " Some queries failed, the statements and errors are listing below\n
This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.
\n"; + } + else + { + echo "No errors\n"; + } +} +else +{ + echo " No updates required\n"; +} + +// +// Data updates +// +unset($sql); +$error_ary = array(); +$errored = false; + +echo "Progress :: "; +flush(); + +switch ($row['config_value']) +{ + case '': + $sql = "SELECT themes_id + FROM " . THEMES_TABLE . " + WHERE template_name = 'subSilver'"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + $theme_id = $row['themes_id']; + + $sql = "UPDATE " . THEMES_TABLE . " + SET head_stylesheet = 'subSilver.css', body_background = '', body_bgcolor = 'E5E5E5', body_text = '000000', body_link = '006699', body_vlink = '5493B4', body_alink = '', body_hlink = 'DD6900', tr_color1 = 'EFEFEF', tr_color2 = 'DEE3E7', tr_color3 = 'D1D7DC', tr_class1 = '', tr_class2 = '', tr_class3 = '', th_color1 = '98AAB1', th_color2 = '006699', th_color3 = 'FFFFFF', th_class1 = 'cellpic1.gif', th_class2 = 'cellpic3.gif', th_class3 = 'cellpic2.jpg', td_color1 = 'FAFAFA', td_color2 = 'FFFFFF', td_color3 = '', td_class1 = 'row1', td_class2 = 'row2', td_class3 = '', fontface1 = 'Verdana, Arial, Helvetica, sans-serif', fontface2 = 'Trebuchet MS', fontface3 = 'Courier, ''Courier New'', sans-serif', fontsize1 = 10, fontsize2 = 11, fontsize3 = 12, fontcolor1 = '444444', fontcolor2 = '006600', fontcolor3 = 'FFA34F', span_class1 = '', span_class2 = '', span_class3 = '' + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . THEMES_NAME_TABLE . " + WHERE themes_id = $theme_id"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, tr_class1_name, tr_class2_name, tr_class3_name, th_color1_name, th_color2_name, th_color3_name, th_class1_name, th_class2_name, th_class3_name, td_color1_name, td_color2_name, td_color3_name, td_class1_name, td_class2_name, td_class3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, span_class1_name, span_class2_name, span_class3_name) + VALUES ($theme_id, 'The lightest row colour', 'The medium row color', 'The darkest row colour', '', '', '', 'Border round the whole page', 'Outer table border', 'Inner table border', 'Silver gradient picture', 'Blue gradient picture', 'Fade-out gradient on index', 'Background for quote boxes', 'All white areas', '', 'Background for topic posts', '2nd background for topic posts', '', 'Main fonts', 'Additional topic title font', 'Form fonts', 'Smallest font size', 'Medium font size', 'Normal font size (post body etc)', 'Quote & copyright text', 'Code text colour', 'Main table header text colour', '', '', '')"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + $sql = "SELECT MIN(post_id) AS first_post_id, topic_id + FROM " . POSTS_TABLE . " + GROUP BY topic_id + ORDER BY topic_id ASC"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + $sql = "UPDATE " . TOPICS_TABLE . " + SET topic_first_post_id = " . $row['first_post_id'] . " + WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + while ($row = $db->sql_fetchrow($result)); + } + $db->sql_freeresult($result); + + $sql = "SELECT DISTINCT u.user_id + FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa + WHERE aa.auth_mod = 1 + AND ug.group_id = aa.group_id + AND u.user_id = ug.user_id + AND u.user_level <> " . ADMIN; + $result = _sql($sql, $errored, $error_ary); + + $mod_user = array(); + while ($row = $db->sql_fetchrow($result)) + { + $mod_user[] = $row['user_id']; + } + $db->sql_freeresult($result); + + if (count($mod_user)) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_level = " . MOD . " + WHERE user_id IN (" . implode(', ', $mod_user) . ")"; + _sql($sql, $errored, $error_ary); + } + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_name', 'www.myserver.tld')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('script_path', '/phpBB2/')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('server_port', '80')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_users', '1')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('record_online_date', '" . time() . "')"; + _sql($sql, $errored, $error_ary); + + case 'RC-3': + case 'RC-4': + case '.0.0': + case '.0.1': + if (SQL_LAYER == 'postgresql') + { + $sql = "SELECT user_id, user_timezone_old + FROM " . USERS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + $sql = "UPDATE " . USERS_TABLE . " + SET user_timezone = " . $row['user_timezone_old'] . " + WHERE user_id = " . $row['user_id']; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + } + + $sql = "SELECT topic_id, topic_moved_id + FROM " . TOPICS_TABLE . " + WHERE topic_moved_id <> 0 + AND topic_status = " . TOPIC_MOVED; + $result = _sql($sql, $errored, $error_ary); + + $topic_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ary[$row['topic_id']] = $row['topic_moved_id']; + } + $db->sql_freeresult($result); + + while (list($topic_id, $topic_moved_id) = each($topic_ary)) + { + $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts + FROM " . POSTS_TABLE . " + WHERE topic_id = $topic_moved_id"; + $result = _sql($sql, $errored, $error_ary); + + $sql = ($row = $db->sql_fetchrow($result)) ? "UPDATE " . TOPICS_TABLE . " SET topic_replies = " . ($row['total_posts'] - 1) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " WHERE topic_id = $topic_id" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = " . $row['topic_id']; + _sql($sql, $errored, $error_ary); + } + + unset($sql); + + sync('all forums'); + + case '.0.2': + + case '.0.3': + + // Topics will resync automatically + + // Remove stop words from search match and search words + $dirname = 'language'; + $dir = opendir($phpbb_root_path . $dirname); + + while ($file = readdir($dir)) + { + if (preg_match("#^lang_#i", $file) && !is_file($phpbb_root_path . $dirname . "/" . $file) && !is_link($phpbb_root_path . $dirname . "/" . $file) && file_exists($phpbb_root_path . $dirname . "/" . $file . '/search_stopwords.txt')) + { + + $stopword_list = trim(preg_replace('#([\w\.\-_\+\'±µ-ÿ\\\]+?)[ \n\r]*?(,|$)#', '\'\1\'\2', str_replace("'", "\'", implode(', ', file($phpbb_root_path . $dirname . "/" . $file . '/search_stopwords.txt'))))); + + $sql = "SELECT word_id + FROM " . SEARCH_WORD_TABLE . " + WHERE word_text IN ($stopword_list)"; + $result = _sql($sql, $errored, $error_ary); + + $word_id_sql = ''; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $word_id_sql .= (($word_id_sql != '') ? ', ' : '') . $row['word_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = "DELETE FROM " . SEARCH_WORD_TABLE . " + WHERE word_id IN ($word_id_sql)"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . " + WHERE word_id IN ($word_id_sql)"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + } + } + closedir($dir); + + // Mark common words ... + remove_common('global', 4/10); + + // remove superfluous polls ... grab polls with topics then delete polls + // not in that list + $sql = "SELECT v.vote_id + FROM " . TOPICS_TABLE . " t, " . VOTE_DESC_TABLE . " v + WHERE v.topic_id = t.topic_id"; + $result = _sql($sql, $errored, $error_ary); + + $vote_id_sql = ''; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $vote_id_sql .= (($vote_id_sql != '') ? ', ' : '') . $row['vote_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = "DELETE FROM " . VOTE_DESC_TABLE . " + WHERE vote_id NOT IN ($vote_id_sql)"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " + WHERE vote_id NOT IN ($vote_id_sql)"; + _sql($sql, $errored, $error_ary); + + $sql = "DELETE FROM " . VOTE_USERS_TABLE . " + WHERE vote_id NOT IN ($vote_id_sql)"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + // update pm counters + $sql = "SELECT privmsgs_to_userid, COUNT(privmsgs_id) AS unread_count + FROM " . PRIVMSGS_TABLE . " + WHERE privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " + GROUP BY privmsgs_to_userid"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + $update_users = array(); + do + { + $update_users[$row['unread_count']][] = $row['privmsgs_to_userid']; + } + while ($row = $db->sql_fetchrow($result)); + + while (list($num, $user_ary) = each($update_users)) + { + $user_ids = implode(', ', $user_ary); + + $sql = "UPDATE " . USERS_TABLE . " + SET user_unread_privmsg = $num + WHERE user_id IN ($user_ids)"; + _sql($sql, $errored, $error_ary); + } + unset($update_list); + } + $db->sql_freeresult($result); + + $sql = "SELECT privmsgs_to_userid, COUNT(privmsgs_id) AS new_count + FROM " . PRIVMSGS_TABLE . " + WHERE privmsgs_type = " . PRIVMSGS_NEW_MAIL . " + GROUP BY privmsgs_to_userid"; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + $update_users = array(); + do + { + $update_users[$row['new_count']][] = $row['privmsgs_to_userid']; + } + while ($row = $db->sql_fetchrow($result)); + + while (list($num, $user_ary) = each($update_users)) + { + $user_ids = implode(', ', $user_ary); + + $sql = "UPDATE " . USERS_TABLE . " + SET user_new_privmsg = $num + WHERE user_id IN ($user_ids)"; + _sql($sql, $errored, $error_ary); + } + unset($update_list); + } + $db->sql_freeresult($result); + + // Remove superfluous watched topics + $sql = "SELECT t.topic_id + FROM " . TOPICS_TABLE . " t, " . TOPICS_WATCH_TABLE . " w + WHERE w.topic_id = t.topic_id"; + $result = _sql($sql, $errored, $error_ary); + + $topic_id_sql = ''; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . $row['topic_id']; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " + WHERE topic_id NOT IN ($topic_id_sql)"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + // Reset any email addresses which are non-compliant ... something + // not done in the upgrade script and thus which may affect some + // mysql users + switch (SQL_LAYER) + { + case 'mysql': + $sql = "UPDATE " . USERS_TABLE . " + SET user_email = '' + WHERE user_email NOT REGEXP '^[a-zA-Z0-9_\+\.\-]+@.*[a-zA-Z0-9_\-]+\.[a-zA-Z]{2,}$'"; + _sql($sql, $errored, $error_ary); + } + + case '.0.4': + + // Add the confirmation code switch ... save time and trouble elsewhere + $sql = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) + VALUES ('enable_confirm', '0')"; + _sql($sql, $errored, $error_ary); + + $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) + VALUES ('sendmail_fix', '0')"; + _sql($sql, $errored, $error_ary); + + case '.0.5': + + $sql = "SELECT user_id, username + FROM " . USERS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + if (!preg_match('#(>)|(<)|(")|(&)#', $row['username'])) + { + if ($row['username'] != htmlspecialchars($row['username'])) + { + $sql = "UPDATE " . USERS_TABLE . " + SET username = '" . str_replace("'", "''", htmlspecialchars($row['username'])) . "' + WHERE user_id = " . $row['user_id']; + _sql($sql, $errored, $error_ary); + } + } + } + $db->sql_freeresult($result); + + break; + + default: + echo " No updates where required
\n"; + break; +} + +echo "Progress :: ";
+flush();
+
+// update the version
+$sql = "UPDATE " . CONFIG_TABLE . "
+ SET config_value = '$updates_to_version'
+ WHERE config_name = 'version'";
+_sql($sql, $errored, $error_ary);
+
+// Optimize/vacuum analyze the tables where appropriate
+// this should be done for each version in future along with
+// the version number update
+switch (SQL_LAYER)
+{
+ case 'mysql':
+ case 'mysql4':
+ $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words';
+ _sql($sql, $errored, $error_ary);
+ break;
+
+ case 'postgresql':
+ _sql("VACUUM ANALYZE", $errored, $error_ary);
+ break;
+}
+
+echo " Done
Result :: \n";
+
+if ($errored)
+{
+ echo " Some queries failed, the statements and errors are listing below\n
This is probably nothing to worry about, update will continue. Should this fail to complete you may need to seek help at our development board. See README for details on how to obtain advice.
\n"; +} +else +{ + echo "No errors\n"; +} + +echo "You should now visit the General Configuration settings page in the Administration Panel and check the General Configuration of the board. If you updated from versions prior to RC-3 you must update some entries. If you do not do this emails sent from the board will contain incorrect information. Don't forget to delete this file!
\n"; + +?> + +