diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2006-03-22 17:30:20 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-03-22 17:30:20 +0000 |
commit | 1e2ed1bc9f8128d4d252c6761b50216d0b01998e (patch) | |
tree | a0f77cfde33df5debf9cc45a1444a8df5135f0fb /phpBB/includes | |
parent | 02239880a55f38828b1f4151fc2d2a658312b98e (diff) | |
download | forums-1e2ed1bc9f8128d4d252c6761b50216d0b01998e.tar forums-1e2ed1bc9f8128d4d252c6761b50216d0b01998e.tar.gz forums-1e2ed1bc9f8128d4d252c6761b50216d0b01998e.tar.bz2 forums-1e2ed1bc9f8128d4d252c6761b50216d0b01998e.tar.xz forums-1e2ed1bc9f8128d4d252c6761b50216d0b01998e.zip |
adjusting sql_freeresult a bit as well as our error handler (it now prints out if it is because of DEBUG_EXTRA being defined - which is not enabled within the betas/rc's and stable releases).
git-svn-id: file:///svn/phpbb/trunk@5699 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
24 files changed, 75 insertions, 66 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 2c5f04faf1..e316a0f926 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -519,7 +519,7 @@ class acp_attachments FROM ' . EXTENSION_GROUPS_TABLE . " WHERE group_id = $group_id"; $result = $db->sql_query($sql); - $group_name = $db->sql_fetchfield('group_name', 0, $result); + $group_name = (string) $db->sql_fetchfield('group_name'); $db->sql_freeresult($result); $sql = 'DELETE diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index b870a451db..03ed3b4696 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -174,7 +174,7 @@ class acp_email FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; $result = $db->sql_query($sql); - $group_name = (string) $db->sql_fetchfield('group_name', 0, $result); + $group_name = (string) $db->sql_fetchfield('group_name'); $db->sql_freeresult($result); } else diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 644f4f7cf9..75fc125920 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -488,8 +488,7 @@ class acp_groups WHERE group_id = $group_id AND group_leader = 1"; $result = $db->sql_query($sql); - - $total_leaders = (int) $db->sql_fetchfield('total_leaders', 0, $result); + $total_leaders = (int) $db->sql_fetchfield('total_leaders'); $db->sql_freeresult($result); // Total number of group members (non-leaders) @@ -498,8 +497,7 @@ class acp_groups WHERE group_id = $group_id AND group_leader <> 1"; $result = $db->sql_query($sql); - - $total_members = (int) $db->sql_fetchfield('total_members', 0, $result); + $total_members = (int) $db->sql_fetchfield('total_members'); $db->sql_freeresult($result); // Grab the members diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 7b683186ee..f269c0027d 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -271,7 +271,7 @@ class acp_icons $result = $db->sql_query("SELECT {$fields}_order FROM $table WHERE {$fields}_id = " . $image_id[$image]); - $order_old = $db->sql_fetchfield($fields . '_order', 0, $result); + $order_old = (int) $db->sql_fetchfield($fields . '_order'); $db->sql_freeresult($result); if ($order_old == $image_order[$image]) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 9c1c32fb24..cd692c22de 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -190,14 +190,14 @@ class acp_main FROM ' . ATTACHMENTS_TABLE; $result = $db->sql_query($sql); - set_config('num_files', (int) $db->sql_fetchfield('stat', 0, $result), true); + set_config('num_files', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); $sql = 'SELECT SUM(filesize) as stat FROM ' . ATTACHMENTS_TABLE; $result = $db->sql_query($sql); - set_config('upload_dir_size', (int) $db->sql_fetchfield('stat', 0, $result), true); + set_config('upload_dir_size', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); add_log('admin', 'LOG_RESYNC_STATS'); diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 6e19c0d09c..804bbb8792 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -99,7 +99,7 @@ class acp_profile FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id"; $result = $db->sql_query($sql); - $field_ident = $db->sql_fetchfield('field_ident', 0, $result); + $field_ident = (string) $db->sql_fetchfield('field_ident'); $db->sql_freeresult($result); $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id"); @@ -152,9 +152,9 @@ class acp_profile $sql = 'SELECT lang_id FROM ' . LANG_TABLE . " - WHERE lang_iso = '{$config['default_lang']}'"; + WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'"; $result = $db->sql_query($sql); - $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); + $default_lang_id = (int) $db->sql_fetchfield('lang_id'); $db->sql_freeresult($result); if (!in_array($default_lang_id, $lang_defs['entry'][$field_id])) @@ -171,7 +171,7 @@ class acp_profile FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id"; $result = $db->sql_query($sql); - $field_ident = $db->sql_fetchfield('field_ident', 0, $result); + $field_ident = (string) $db->sql_fetchfield('field_ident'); $db->sql_freeresult($result); add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident); @@ -196,7 +196,7 @@ class acp_profile FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id"; $result = $db->sql_query($sql); - $field_ident = $db->sql_fetchfield('field_ident', 0, $result); + $field_ident = (string) $db->sql_fetchfield('field_ident'); $db->sql_freeresult($result); add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident); @@ -915,10 +915,12 @@ class acp_profile if ($action == 'create') { - $result = $db->sql_query('SELECT MAX(field_order) as max_field_order FROM ' . PROFILE_FIELDS_TABLE); - $new_field_order = (int) $db->sql_fetchfield('max_field_order', 0, $result); + $sql = 'SELECT MAX(field_order) as max_field_order + FROM ' . PROFILE_FIELDS_TABLE; + $result = $db->sql_query($sql); + $new_field_order = (int) $db->sql_fetchfield('max_field_order'); $db->sql_freeresult($result); - + $field_ident = $cp->vars['field_ident']; } diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php index 8866a762e6..890350f26b 100644 --- a/phpBB/includes/acp/acp_reasons.php +++ b/phpBB/includes/acp/acp_reasons.php @@ -97,7 +97,7 @@ class acp_reasons $sql = 'SELECT MAX(reason_order) as max_reason_order FROM ' . REASONS_TABLE; $result = $db->sql_query($sql); - $max_order = (int) $db->sql_fetchfield('max_reason_order', 0, $result); + $max_order = (int) $db->sql_fetchfield('max_reason_order'); $db->sql_freeresult($result); $sql_ary = array( @@ -191,7 +191,7 @@ class acp_reasons FROM ' . REASONS_TABLE . " WHERE reason_title = 'other'"; $result = $db->sql_query($sql); - $other_reason_id = (int) $db->sql_fetchfield('reason_id', 0, $result); + $other_reason_id = (int) $db->sql_fetchfield('reason_id'); $db->sql_freeresult($result); // Change the reports using this reason to 'other' diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 3b6f935b9e..3daba4e4d5 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -452,7 +452,7 @@ class acp_search $sql = 'SELECT MAX(post_id) as max_post_id FROM '. POSTS_TABLE; $result = $db->sql_query($sql); - $max_post_id = (int) $db->sql_fetchfield('max_post_id', 0, $result); + $max_post_id = (int) $db->sql_fetchfield('max_post_id'); $db->sql_freeresult($result); return $max_post_id; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 653c33f5da..f72c6d3310 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -81,7 +81,7 @@ class acp_users FROM ' . USERS_TABLE . " WHERE username = '" . $db->sql_escape($username) . "'"; $result = $db->sql_query($sql); - $user_id = (int) $db->sql_fetchfield('user_id', false, $result); + $user_id = (int) $db->sql_fetchfield('user_id'); $db->sql_freeresult($result); if (!$user_id) @@ -1560,11 +1560,11 @@ class acp_users $order_by = $sk_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - $sql = 'SELECT COUNT(*) as num_attachments + $sql = 'SELECT COUNT(attach_id) as num_attachments FROM ' . ATTACHMENTS_TABLE . " WHERE poster_id = $user_id"; $result = $db->sql_query_limit($sql, 1); - $num_attachments = (int) $db->sql_fetchfield('num_attachments', false, $result); + $num_attachments = (int) $db->sql_fetchfield('num_attachments'); $db->sql_freeresult($result); $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title diff --git a/phpBB/includes/acp/acp_words.php b/phpBB/includes/acp/acp_words.php index d7f1a9d724..bea148b057 100644 --- a/phpBB/includes/acp/acp_words.php +++ b/phpBB/includes/acp/acp_words.php @@ -114,7 +114,7 @@ class acp_words FROM ' . WORDS_TABLE . " WHERE word_id = $word_id"; $result = $db->sql_query($sql); - $deleted_word = $db->sql_fetchfield('word', 0, $result); + $deleted_word = $db->sql_fetchfield('word'); $db->sql_freeresult($result); $sql = 'DELETE FROM ' . WORDS_TABLE . " diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3e136e6dd4..c61e6a5bda 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1838,7 +1838,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) { if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.php') === false) { - echo "<b>PHP Notice</b>: in file <b>$errfile</b> on line <b>$errline</b>: <b>$msg_text</b><br>"; + echo '<b>[phpBB Debug Extra] PHP Notice</b>: in file <b>' . str_replace(array(realpath($phpbb_root_path), '\\'), array('', '/'), $errfile) . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n"; } } @@ -2006,7 +2006,7 @@ function page_header($page_title = '') AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) . $reading_sql; $result = $db->sql_query($sql); - $guests_online = (int) $db->sql_fetchfield('num_guests', 0, $result); + $guests_online = (int) $db->sql_fetchfield('num_guests'); $db->sql_freeresult($result); } diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index a81ea659e1..9105c09c52 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -460,9 +460,8 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) AND folder_id = " . PRIVMSGS_INBOX . " GROUP BY folder_id"; $result = $db->sql_query_limit($sql, 1); - - $folder[PRIVMSGS_INBOX] = (int) $db->sql_fetchfield('num_messages', 0, $result); - $db->sql_freeresult($result); + $folder[PRIVMSGS_INBOX] = (int) $db->sql_fetchfield('num_messages'); + $db->sql_freeresult($result); } } @@ -622,7 +621,10 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol WHERE folder_id = ' . PRIVMSGS_INBOX . " AND user_id = $user_id"; $result = $db->sql_query($sql); - if ($db->sql_fetchfield('num_messages', 0, $result) + sizeof($move_msg_ids) > $message_limit) + $num_messages = (int) $db->sql_fetchfield('num_messages'); + $db->sql_freeresult($result); + + if ($num_messages + sizeof($move_msg_ids) > $message_limit) { $message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $user->lang['PM_INBOX']) . '<br /><br />'; $message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], "<a href=\"{$phpbb_root_path}ucp.$phpEx$SID&i=pm&folder=inbox\">", '</a>', $user->lang['PM_INBOX']); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index dad4d5b254..c36a57c4d0 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -280,7 +280,7 @@ function user_active_flip($user_id, $user_type, $user_actkey = false, $username FROM ' . USERS_TABLE . " WHERE user_id = $user_id"; $result = $db->sql_query($sql); - $username = $db->sql_fetchfield('username', 0, $result); + $username = (string) $db->sql_fetchfield('username'); $db->sql_freeresult($result); } @@ -1245,7 +1245,7 @@ function group_delete($group_id, $group_name = false) FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; $result = $db->sql_query($sql); - $group_name = $db->sql_fetchfield('group_name', 0, $result); + $group_name = (string) $db->sql_fetchfield('group_name'); $db->sql_freeresult($result); } @@ -1518,7 +1518,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; $result = $db->sql_query($sql); - $group_name = $db->sql_fetchfield('group_name', 0, $result); + $group_name = (string) $db->sql_fetchfield('group_name'); $db->sql_freeresult($result); } @@ -1582,7 +1582,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; $result = $db->sql_query($sql); - $group_name = $db->sql_fetchfield('group_name', 0, $result); + $group_name = (string) $db->sql_fetchfield('group_name'); $db->sql_freeresult($result); } diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index dd3efd4a71..67f0885caf 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -34,7 +34,7 @@ function mcp_front_view($id, $mode, $action) WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') AND post_approved = 0'; $result = $db->sql_query($sql); - $total = (int) $db->sql_fetchfield('total', 0, $result); + $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a76e767ceb..422cb140f7 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -158,7 +158,7 @@ class mcp_queue FROM ' . FORUMS_TABLE . " WHERE forum_id IN ($forum_list)"; $result = $db->sql_query($sql); - $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics', 0, $result); + $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 26b0bc6ecb..6bb6a2e609 100755 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -189,7 +189,7 @@ class mcp_reports FROM ' . FORUMS_TABLE . " WHERE forum_id IN ($forum_list)"; $result = $db->sql_query($sql); - $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics', 0, $result); + $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index bfdc61a9c6..3ef8fe0b2d 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -376,12 +376,13 @@ class fulltext_mysql extends search_backend { $sql = 'SELECT FOUND_ROWS() as result_count'; $result = $db->sql_query($sql); + $result_count = (int) $db->sql_fetchfield('result_count'); + $db->sql_freeresult($result); - if (!($result_count = (int) $db->sql_fetchfield('result_count', 0, $result))) + if (!$result_count) { return false; } - $db->sql_freeresult($result); } // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page @@ -519,12 +520,13 @@ class fulltext_mysql extends search_backend { $sql = 'SELECT FOUND_ROWS() as result_count'; $result = $db->sql_query($sql); + $result_count = (int) $db->sql_fetchfield('result_count'); + $db->sql_freeresult($result); - if (!($result_count = (int) $db->sql_fetchfield('result_count', 0, $result))) + if (!$result_count) { return false; } - $db->sql_freeresult($result); } if (sizeof($id_ary)) @@ -724,10 +726,10 @@ class fulltext_mysql extends search_backend } $db->sql_freeresult($result); - $sql = 'SELECT COUNT(*) as total_posts + $sql = 'SELECT COUNT(post_id) as total_posts FROM ' . POSTS_TABLE; $result = $db->sql_query($sql); - $this->stats['total_posts'] = $db->sql_fetchfield('total_posts', 0, $result); + $this->stats['total_posts'] = (int) $db->sql_fetchfield('total_posts'); $db->sql_freeresult($result); } } diff --git a/phpBB/includes/search/fulltext_phpbb.php b/phpBB/includes/search/fulltext_phpbb.php index 4403c92c46..9ea3c5f4cd 100644 --- a/phpBB/includes/search/fulltext_phpbb.php +++ b/phpBB/includes/search/fulltext_phpbb.php @@ -1015,13 +1015,13 @@ class fulltext_phpbb extends search_backend $sql = 'SELECT COUNT(*) as total_words FROM ' . SEARCH_WORD_TABLE; $result = $db->sql_query($sql); - $this->stats['total_words'] = $db->sql_fetchfield('total_words', 0, $result); + $this->stats['total_words'] = (int) $db->sql_fetchfield('total_words'); $db->sql_freeresult($result); $sql = 'SELECT COUNT(*) as total_matches FROM ' . SEARCH_MATCH_TABLE; $result = $db->sql_query($sql); - $this->stats['total_matches'] = $db->sql_fetchfield('total_matches', 0, $result); + $this->stats['total_matches'] = (int) $db->sql_fetchfield('total_matches'); $db->sql_freeresult($result); } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index a478c8466e..b038039d9b 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1130,10 +1130,12 @@ class user extends session $sql = 'SELECT lang_id FROM ' . LANG_TABLE . " - WHERE lang_iso = '{$this->lang_name}'"; + WHERE lang_iso = '" . $db->sql_escape($this->lang_name) . "'"; $result = $db->sql_query($sql); + $lang_id = (int) $db->sql_fetchfield('lang_id'); + $db->sql_freeresult($result); - return (int) $db->sql_fetchfield('lang_id', 0, $result); + return $lang_id; } // Get profile fields for user diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php index d06eb08709..3c3b9c24ad 100644 --- a/phpBB/includes/ucp/ucp_attachments.php +++ b/phpBB/includes/ucp/ucp_attachments.php @@ -77,11 +77,11 @@ class ucp_attachments $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); - $sql = 'SELECT COUNT(*) as num_attachments + $sql = 'SELECT COUNT(attach_id) as num_attachments FROM ' . ATTACHMENTS_TABLE . ' WHERE poster_id = ' . $user->data['user_id']; $result = $db->sql_query_limit($sql, 1); - $num_attachments = $db->sql_fetchfield('num_attachments', 0, $result); + $num_attachments = $db->sql_fetchfield('num_attachments'); $db->sql_freeresult($result); $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 784fb9efe9..43e4ee1603 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -625,8 +625,7 @@ class ucp_groups WHERE group_id = $group_id AND group_leader <> 1"; $result = $db->sql_query($sql); - - $total_members = (int) $db->sql_fetchfield('total_members', 0, $result); + $total_members = (int) $db->sql_fetchfield('total_members'); $db->sql_freeresult($result); $start = request_var('start', 0); diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 898103043c..f992d22a15 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -67,7 +67,7 @@ class ucp_main $sql .= ' AND forum_id NOT IN ( ' . implode(', ', $forum_ary) . ')'; } $result = $db->sql_query_limit($sql, 1); - $g_forum_id = (int) $db->sql_fetchfield('forum_id', 0, $result); + $g_forum_id = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); $sql = "SELECT t.* $sql_select @@ -303,7 +303,7 @@ class ucp_main FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); - $topics_count = (int) $db->sql_fetchfield('topics_count', 0, $result); + $topics_count = (int) $db->sql_fetchfield('topics_count'); $db->sql_freeresult($result); if ($topics_count) @@ -451,10 +451,11 @@ class ucp_main $move_up = request_var('move_up', 0); $move_down = request_var('move_down', 0); - $sql = 'SELECT MAX(order_id) as max_order_id FROM ' . BOOKMARKS_TABLE . ' + $sql = 'SELECT MAX(order_id) as max_order_id + FROM ' . BOOKMARKS_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); - $max_order_id = $db->sql_fetchfield('max_order_id', 0, $result); + $max_order_id = (int) $db->sql_fetchfield('max_order_id'); $db->sql_freeresult($result); if ($move_up || $move_down) diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php index 7e2fb0a901..530b3493d8 100644 --- a/phpBB/includes/ucp/ucp_pm.php +++ b/phpBB/includes/ucp/ucp_pm.php @@ -125,7 +125,7 @@ class ucp_pm FROM ' . GROUPS_TABLE . ' WHERE group_id = ' . $user->data['group_id']; $result = $db->sql_query($sql); - $message_limit = (int) $db->sql_fetchfield('group_message_limit', 0, $result); + $message_limit = (int) $db->sql_fetchfield('group_message_limit'); $db->sql_freeresult($result); $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit; @@ -162,7 +162,7 @@ class ucp_pm FROM ' . GROUPS_TABLE . ' WHERE group_id = ' . $user->data['group_id']; $result = $db->sql_query($sql); - $message_limit = (int) $db->sql_fetchfield('group_message_limit', 0, $result); + $message_limit = (int) $db->sql_fetchfield('group_message_limit'); $db->sql_freeresult($result); $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit; diff --git a/phpBB/includes/ucp/ucp_pm_options.php b/phpBB/includes/ucp/ucp_pm_options.php index 40f8baba7a..b3f6b02bbe 100644 --- a/phpBB/includes/ucp/ucp_pm_options.php +++ b/phpBB/includes/ucp/ucp_pm_options.php @@ -76,12 +76,13 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit FROM ' . PRIVMSGS_FOLDER_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); - - if ($db->sql_fetchfield('num_folder', 0, $result) >= $config['pm_max_boxes']) + $num_folder = (int) $db->sql_fetchfield('num_folder'); + $db->sql_freeresult($result); + + if ($num_folder >= $config['pm_max_boxes']) { trigger_error('MAX_FOLDER_REACHED'); } - $db->sql_freeresult($result); $sql = 'INSERT INTO ' . PRIVMSGS_FOLDER_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'user_id' => (int) $user->data['user_id'], 'folder_name' => $folder_name)); @@ -344,7 +345,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit WHERE user_id = ' . $user->data['user_id'] . ' AND folder_id = ' . PRIVMSGS_INBOX; $result = $db->sql_query($sql); - $num_messages = $db->sql_fetchfield('num_messages', 0, $result); + $num_messages = (int) $db->sql_fetchfield('num_messages'); $db->sql_freeresult($result); $folder[PRIVMSGS_INBOX] = array( @@ -641,12 +642,13 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule FROM ' . USERS_TABLE . " WHERE username = '" . $db->sql_escape($rule_string) . "'"; $result = $db->sql_query($sql); + $rule_user_id = (int) $db->sql_fetchfield('user_id'); + $db->sql_freeresult($result); - if (!($rule_user_id = $db->sql_fetchfield('user_id', 0, $result))) + if (!$rule_user_id) { $rule_string = ''; } - $db->sql_freeresult($result); } else if (!$rule_string && $rule_user_id) { @@ -654,12 +656,13 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule FROM ' . USERS_TABLE . " WHERE user_id = $rule_user_id"; $result = $db->sql_query($sql); - - if (!($rule_string = $db->sql_fetchfield('username', 0, $result))) + $rule_string = $db->sql_fetchfield('username'); + $db->sql_freeresult($result); + + if (!$rule_string) { $rule_user_id = 0; } - $db->sql_freeresult($result); } $template->assign_vars(array( |