From 9e55e1738874a0ab352f91a15012b33fe1c3e9f9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 15 Feb 2008 19:10:02 +0000 Subject: revamp how we query permissions. This is half-experimental actually, needs a bit of testing. Should fix the bug with low max_join_size values, but may give problems for those on very low memory settings. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8384 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 268eccbca4..7fd21948d0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2998,6 +2998,29 @@ function tidy_database() { global $db; + // Here we check permission consistency + + // Sometimes, it can happen permission tables having forums listed which do not exist + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE; + $result = $db->sql_query($sql); + + $forum_ids = array(0); + while ($row = $db->sql_fetchrow($result)) + { + $forum_ids[] = $row['forum_id']; + } + $db->sql_freeresult($result); + + // Delete those rows from the acl tables not having listed the forums above + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true); + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true); + $db->sql_query($sql); + set_config('database_last_gc', time(), true); } -- cgit v1.2.1 From 6accc46024d436e69802793956653412cde8f404 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Feb 2008 13:18:33 +0000 Subject: some language/style/code fixes (refer to the diff of the changelog) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8389 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 7fd21948d0..afaf165d66 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -196,7 +196,7 @@ function size_select_options($size_compare) { global $user; - $size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']); + $size_types_text = array($user->lang['BYTES'], $user->lang['KIB'], $user->lang['MIB']); $size_types = array('b', 'kb', 'mb'); $s_size_options = ''; @@ -2878,14 +2878,7 @@ function get_database_size() break; } - if ($database_size !== false) - { - $database_size = ($database_size >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($database_size / 1048576)) : (($database_size >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($database_size / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $database_size)); - } - else - { - $database_size = $user->lang['NOT_AVAILABLE']; - } + $database_size = ($database_size !== false) ? get_formatted_filesize($database_size) : $user->lang['NOT_AVAILABLE']; return $database_size; } -- cgit v1.2.1 From 3e64e9b8999e6c4c004e1cb0721c76ee6b612d53 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 20 Apr 2008 04:47:37 +0000 Subject: #14648 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8506 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index afaf165d66..6a4b6008bd 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1545,7 +1545,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT SUM(t.topic_replies + 1) AS forum_posts FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1'; + AND t.topic_approved = 1 + AND t.topic_status <> ' . ITEM_MOVED; } else { @@ -1553,6 +1554,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' AND t.topic_approved = 1 + AND t.topic_status <> ' . ITEM_MOVED .' GROUP BY t.forum_id'; } -- cgit v1.2.1 From 3cced0db7ee5364ab959bf2261bdbf8a2585928a Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 20 Apr 2008 04:58:29 +0000 Subject: fix whitespace git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8508 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 6a4b6008bd..028456c246 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1554,7 +1554,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' AND t.topic_approved = 1 - AND t.topic_status <> ' . ITEM_MOVED .' + AND t.topic_status <> ' . ITEM_MOVED . ' GROUP BY t.forum_id'; } -- cgit v1.2.1 From d7fa3f83ceb0f05a6295ea4d21ef9a81bfb378f1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Aug 2008 17:20:55 +0000 Subject: The same way we allow defining a custom template/style path we now allow this for languages too. This will allow applications to define their own language folder for certain parts for example. Callable by $user->set_custom_lang_path({new_path}) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8782 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 028456c246..5c3d624e95 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -97,7 +97,7 @@ function recalc_btree($sql_id, $sql_table, $module_class = '') $item_data['left_id'] = $row['right_id'] + 1; $item_data['right_id'] = $row['right_id'] + 2; } - + $sql = "UPDATE $sql_table SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']} WHERE $sql_id = " . $item_data[$sql_id]; @@ -916,7 +916,7 @@ function delete_attachments($mode, $ids, $resync = true) while ($row = $db->sql_fetchrow($result)) { - $remaining[] = $row['post_msg_id']; + $remaining[] = $row['post_msg_id']; } $db->sql_freeresult($result); @@ -940,7 +940,7 @@ function delete_attachments($mode, $ids, $resync = true) while ($row = $db->sql_fetchrow($result)) { - $remaining[] = $row['post_msg_id']; + $remaining[] = $row['post_msg_id']; } $db->sql_freeresult($result); @@ -978,7 +978,7 @@ function delete_attachments($mode, $ids, $resync = true) while ($row = $db->sql_fetchrow($result)) { - $remaining[] = $row['topic_id']; + $remaining[] = $row['topic_id']; } $db->sql_freeresult($result); @@ -1015,7 +1015,7 @@ function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true) . $where; $db->sql_query($sql); break; - + default: $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TABLE . ' t2 @@ -1213,7 +1213,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, AND t1.forum_id = t2.forum_id"; $db->sql_query($sql); break; - + default: $sql = 'SELECT t1.topic_id FROM ' .TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2 @@ -2369,7 +2369,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $log_type = LOG_USERS; $sql_forum = 'AND l.reportee_id = ' . (int) $user_id; break; - + case 'users': $log_type = LOG_USERS; $sql_forum = ''; @@ -2379,7 +2379,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $log_type = LOG_CRITICAL; $sql_forum = ''; break; - + default: return; } @@ -2637,7 +2637,7 @@ function update_foes($group_id = false, $user_id = false) $db->sql_freeresult($result); if (sizeof($users)) - { + { $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE ' . $db->sql_in_set('zebra_id', $users) . ' AND foe = 1'; @@ -2717,7 +2717,7 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li $row['inactive_reason'] = $user->lang['INACTIVE_REASON_REMIND']; break; } - + $users[] = $row; } @@ -2897,7 +2897,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port @fputs($fsock, "GET $directory/$filename HTTP/1.1\r\n"); @fputs($fsock, "HOST: $host\r\n"); @fputs($fsock, "Connection: close\r\n\r\n"); - + $file_info = ''; $get_info = false; @@ -2936,7 +2936,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port return false; } } - + return $file_info; } @@ -2972,7 +2972,7 @@ function tidy_warnings() $sql = 'DELETE FROM ' . WARNINGS_TABLE . ' WHERE ' . $db->sql_in_set('warning_id', $warning_list); $db->sql_query($sql); - + foreach ($user_list as $user_id => $value) { $sql = 'UPDATE ' . USERS_TABLE . " SET user_warnings = user_warnings - $value @@ -3034,7 +3034,7 @@ function add_permission_language() // Now search in acp and mods folder for permissions_ files. foreach (array('acp/', 'mods/') as $path) { - $dh = @opendir($user->lang_path . $path); + $dh = @opendir($user->lang_path . $user->lang_name . '/' . $path); if ($dh) { -- cgit v1.2.1 From 5c4870fcce2f2a71b74166947939461bea90eac2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 2 Sep 2008 06:36:24 +0000 Subject: Fix one design failure in phpBB3. Do not count non-approved posts to the user_posts. Before, a user was able to circumvent basically any protection based on post counts. At the same time implement the queue_trigger feature. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8805 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5c3d624e95..78ec47377a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -670,7 +670,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = $topic_ids[] = $row['topic_id']; $forum_ids[] = $row['forum_id']; - if ($row['post_postcount'] && $post_count_sync) + if ($row['post_postcount'] && $post_count_sync && $row['post_approved']) { $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; } @@ -709,6 +709,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = WHERE user_id = ' . $poster_id . ' AND user_posts < ' . $substract; $db->sql_query($sql); + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts - ' . $substract . ' WHERE user_id = ' . $poster_id . ' -- cgit v1.2.1 From 2fcd96ca72741bdfb36c24a0af9dd8230b5a828f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 4 Sep 2008 12:01:47 +0000 Subject: Ok, story real database server info, as well as caching it Store it on installation too - allows us to check the db version used on installation and used currently to warn the user about incompatibilities git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8814 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 78ec47377a..9e89926e1a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2616,7 +2616,7 @@ function update_foes($group_id = false, $user_id = false) { case 'mysqli': case 'mysql4': - $sql = 'DELETE ' . (($db->sql_layer === 'mysqli' || version_compare($db->mysql_version, '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . ' + $sql = 'DELETE ' . (($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . ' FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug WHERE z.zebra_id = ug.user_id AND z.foe = 1 -- cgit v1.2.1 From aa6c728e6fea34142008a2c62cfd508cf4026824 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 7 Sep 2008 17:10:43 +0000 Subject: Do not decrease topics counter when deleting shadow topics. #26495 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8836 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 9e89926e1a..0f5f10265f 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -551,7 +551,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s 'posts' => ($call_delete_posts) ? delete_posts($where_type, $where_ids, false, true, $post_count_sync, false) : 0, ); - $sql = 'SELECT topic_id, forum_id, topic_approved + $sql = 'SELECT topic_id, forum_id, topic_approved, topic_moved_id FROM ' . TOPICS_TABLE . ' WHERE ' . $where_clause; $result = $db->sql_query($sql); @@ -561,7 +561,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s $forum_ids[] = $row['forum_id']; $topic_ids[] = $row['topic_id']; - if ($row['topic_approved']) + if ($row['topic_approved'] && !$row['topic_moved_id']) { $approved_topics++; } -- cgit v1.2.1 From e12fce5f3d74d97b93b5a5931e59f9ddc2355a77 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 19 Sep 2008 15:39:43 +0000 Subject: Correctly delete message attachments. (Bug #23755) Also revamped and simplified delete_attachments() - it looks like we did not touch it for a long long time. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8890 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 206 +++++++++++++++---------------------- 1 file changed, 85 insertions(+), 121 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 0f5f10265f..96deda9f3f 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -791,8 +791,8 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = /** * Delete Attachments * -* @param string $mode can be: post|topic|attach|user -* @param mixed $ids can be: post_ids, topic_ids, attach_ids, user_ids +* @param string $mode can be: post|message|topic|attach|user +* @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids * @param bool $resync set this to false if you are deleting posts or topics */ function delete_attachments($mode, $ids, $resync = true) @@ -814,42 +814,55 @@ function delete_attachments($mode, $ids, $resync = true) return false; } - $sql_id = ($mode == 'user') ? 'poster_id' : (($mode == 'post') ? 'post_msg_id' : (($mode == 'topic') ? 'topic_id' : 'attach_id')); + switch ($mode) + { + case 'post': + case 'message': + $sql_id = 'post_msg_id'; + break; - $post_ids = $topic_ids = $physical = array(); + case 'topic': + $sql_id = 'topic_id'; + break; - // Collect post and topics ids for later use - if ($mode == 'attach' || $mode == 'user' || ($mode == 'topic' && $resync)) - { - $sql = 'SELECT post_msg_id as post_id, topic_id, physical_filename, thumbnail, filesize - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set($sql_id, $ids); - $result = $db->sql_query($sql); + case 'user': + $sql_id = 'poster_id'; + break; - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[] = $row['post_id']; - $topic_ids[] = $row['topic_id']; - $physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize']); - } - $db->sql_freeresult($result); + case 'attach': + default: + $sql_id = 'attach_id'; + $mode = 'attach'; + break; } - if ($mode == 'post') - { - $sql = 'SELECT topic_id, physical_filename, thumbnail, filesize + $post_ids = $message_ids = $topic_ids = $physical = array(); + + // Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled) + $sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $ids) . ' - AND in_message = 0'; - $result = $db->sql_query($sql); + WHERE ' . $db->sql_in_set($sql_id, $ids); + $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) + { + // We only need to store post/message/topic ids if resync is enabled and the file is not orphaned + if ($resync && !$row['is_orphan']) { - $topic_ids[] = $row['topic_id']; - $physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize']); + if (!$row['in_message']) + { + $post_ids[] = $row['post_msg_id']; + $topic_ids[] = $row['topic_id']; + } + else + { + $message_ids[] = $row['post_msg_id']; + } } - $db->sql_freeresult($result); + + $physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize'], 'is_orphan' => $row['is_orphan']); } + $db->sql_freeresult($result); // Delete attachments $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' @@ -866,8 +879,9 @@ function delete_attachments($mode, $ids, $resync = true) $space_removed = $files_removed = 0; foreach ($physical as $file_ary) { - if (phpbb_unlink($file_ary['filename'], 'file', true)) + if (phpbb_unlink($file_ary['filename'], 'file', true) && !$file_ary['is_orphan']) { + // Only non-orphaned files count to the file size $space_removed += $file_ary['filesize']; $files_removed++; } @@ -877,121 +891,71 @@ function delete_attachments($mode, $ids, $resync = true) phpbb_unlink($file_ary['filename'], 'thumbnail', true); } } - set_config('upload_dir_size', $config['upload_dir_size'] - $space_removed, true); - set_config('num_files', $config['num_files'] - $files_removed, true); - if ($mode == 'topic' && !$resync) + if ($space_removed || $files_removed) { - return $num_deleted; + set_config('upload_dir_size', $config['upload_dir_size'] - $space_removed, true); + set_config('num_files', $config['num_files'] - $files_removed, true); } - if ($mode == 'post') + // If we do not resync, we do not need to adjust any message, post, topic or user entries + if (!$resync) { - $post_ids = $ids; + return $num_deleted; } + + // No more use for the original ids unset($ids); + // Now, we need to resync posts, messages, topics. We go through every one of them $post_ids = array_unique($post_ids); + $message_ids = array_unique($message_ids); $topic_ids = array_unique($topic_ids); - // Update post indicators + // Update post indicators for posts now no longer having attachments if (sizeof($post_ids)) { - if ($mode == 'post' || $mode == 'topic') - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 0 - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); - } - - if ($mode == 'user' || $mode == 'attach') - { - $remaining = array(); - - $sql = 'SELECT post_msg_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . ' - AND in_message = 0'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $remaining[] = $row['post_msg_id']; - } - $db->sql_freeresult($result); - - $unset_ids = array_diff($post_ids, $remaining); - - if (sizeof($unset_ids)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 0 - WHERE ' . $db->sql_in_set('post_id', $unset_ids); - $db->sql_query($sql); - } - - $remaining = array(); - - $sql = 'SELECT post_msg_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . ' - AND in_message = 1'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $remaining[] = $row['post_msg_id']; - } - $db->sql_freeresult($result); - - $unset_ids = array_diff($post_ids, $remaining); + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_attachment = 0 + WHERE ' . $db->sql_in_set('post_id', $post_ids); + $db->sql_query($sql); + } - if (sizeof($unset_ids)) - { - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_attachment = 0 - WHERE ' . $db->sql_in_set('msg_id', $unset_ids); - $db->sql_query($sql); - } - } + // Update message table if messages are affected + if (sizeof($message_ids)) + { + $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' + SET message_attachment = 0 + WHERE ' . $db->sql_in_set('msg_id', $message_ids); + $db->sql_query($sql); } + // Now update the topics. This is a bit trickier, because there could be posts still having attachments within the topic if (sizeof($topic_ids)) { - // Update topic indicator - if ($mode == 'topic') + // Just check which topics are still having an assigned attachment not orphaned by querying the attachments table (much less entries expected) + $sql = 'SELECT topic_id + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' + AND is_orphan = 0'; + $result = $db->sql_query($sql); + + $remaining_ids = array(); + while ($row = $db->sql_fetchrow($result)) { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 0 - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); + $remaining_ids[] = $row['topic_id']; } + $db->sql_freeresult($result); - if ($mode == 'post' || $mode == 'user' || $mode == 'attach') - { - $remaining = array(); + // Now only unset those ids remaining + $topic_ids = array_diff($topic_ids, $remaining_ids); - $sql = 'SELECT topic_id - FROM ' . ATTACHMENTS_TABLE . ' + if (sizeof($topic_ids)) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_attachment = 0 WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $remaining[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - $unset_ids = array_diff($topic_ids, $remaining); - - if (sizeof($unset_ids)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 0 - WHERE ' . $db->sql_in_set('topic_id', $unset_ids); - $db->sql_query($sql); - } + $db->sql_query($sql); } } -- cgit v1.2.1 From 687da94982f5d6f8c3290893d40ed84b02f54a37 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 23 Sep 2008 12:01:26 +0000 Subject: Log the forum name that topics are moved into. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8908 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 96deda9f3f..0349cbc6a8 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2398,8 +2398,14 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id if (isset($user->lang[$row['log_operation']])) { - // We supress the warning about inappropriate number of passed parameters here due to possible changes within LOG strings from one version to another. - $log[$i]['action'] = @vsprintf($log[$i]['action'], $log_data_ary); + // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array + // It doesn't matter if we add more arguments than placeholders + if (substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) + { + $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($log[$i]['action'], '%') - sizeof($log_data_ary), '')); + } + + $log[$i]['action'] = vsprintf($log[$i]['action'], $log_data_ary); // If within the admin panel we do not censor text out if (defined('IN_ADMIN')) -- cgit v1.2.1 From b9bf3dafd3704b01a01b37b5277b4f7621c4c690 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 13 Nov 2008 17:32:55 +0000 Subject: Fix a bug in r8908 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9065 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 0349cbc6a8..5ec51e44cf 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2400,7 +2400,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id { // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array // It doesn't matter if we add more arguments than placeholders - if (substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) + if ((substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) > 0) { $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($log[$i]['action'], '%') - sizeof($log_data_ary), '')); } -- cgit v1.2.1 From b933bc87e207a5e4c3ddf695e9b65fbb8dbb7079 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 16 Mar 2009 22:39:37 +0000 Subject: Deleting private message attachments could delete post attachments. #42815 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9379 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5ec51e44cf..5da18d250c 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -814,11 +814,14 @@ function delete_attachments($mode, $ids, $resync = true) return false; } + $sql_where = ''; + switch ($mode) { case 'post': case 'message': $sql_id = 'post_msg_id'; + $sql_where = ' AND in_message = ' . ($mode == 'message' ? 1 : 0); break; case 'topic': @@ -842,6 +845,9 @@ function delete_attachments($mode, $ids, $resync = true) $sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set($sql_id, $ids); + + $sql .= $sql_where; + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -867,6 +873,9 @@ function delete_attachments($mode, $ids, $resync = true) // Delete attachments $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set($sql_id, $ids); + + $sql .= $sql_where; + $db->sql_query($sql); $num_deleted = $db->sql_affectedrows(); -- cgit v1.2.1 From e461162847b1ac9287870de680e8dbd17e9f2fc1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 19 Mar 2009 17:01:59 +0000 Subject: Fix race condition for updating post/topic/etc. counter. (reported by BartVB) please do not try such fixes at home - the correct solution would be to create a second config table with integer columns. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9398 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5da18d250c..549f854b78 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -619,7 +619,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s if ($approved_topics) { - set_config('num_topics', $config['num_topics'] - $approved_topics, true); + set_config_count('num_topics', $approved_topics * (-1), true); } return $return; @@ -776,7 +776,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = if ($approved_posts) { - set_config('num_posts', $config['num_posts'] - $approved_posts, true); + set_config_count('num_posts', $approved_posts * (-1), true); } // We actually remove topics now to not be inconsistent (the delete_topics function calls this function too) @@ -903,8 +903,8 @@ function delete_attachments($mode, $ids, $resync = true) if ($space_removed || $files_removed) { - set_config('upload_dir_size', $config['upload_dir_size'] - $space_removed, true); - set_config('num_files', $config['num_files'] - $files_removed, true); + set_config_count('upload_dir_size', $space_removed * (-1), true); + set_config_count('num_files', $files_removed * (-1), true); } // If we do not resync, we do not need to adjust any message, post, topic or user entries -- cgit v1.2.1 From 77fcc367e2ec60a1ca9a891d6cbcbf48be05badb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 11 Apr 2009 11:10:07 +0000 Subject: SQL optimizations git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9439 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 549f854b78..7aaff2a562 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -652,7 +652,21 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = return false; } - $where_clause = $db->sql_in_set($where_type, array_map('intval', $where_ids)); + $where_ids = array_map('intval', $where_ids); + +/* Possible code for splitting post deletion + if (sizeof($where_ids) >= 1001) + { + // Split into chunks of 1000 + $chunks = array_chunk($where_ids, 1000); + + foreach ($chunks as $_where_ids) + { + delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics); + } + }*/ + + $where_clause = $db->sql_in_set($where_type, $where_ids); } $approved_posts = 0; @@ -665,10 +679,10 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = while ($row = $db->sql_fetchrow($result)) { - $post_ids[] = $row['post_id']; - $poster_ids[] = $row['poster_id']; - $topic_ids[] = $row['topic_id']; - $forum_ids[] = $row['forum_id']; + $post_ids[] = (int) $row['post_id']; + $poster_ids[] = (int) $row['poster_id']; + $topic_ids[] = (int) $row['topic_id']; + $forum_ids[] = (int) $row['forum_id']; if ($row['post_postcount'] && $post_count_sync && $row['post_approved']) { -- cgit v1.2.1 From e35b5c26e6a3f2a8a764899eb0b03495aac284e0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 12 Apr 2009 13:21:25 +0000 Subject: Fix skipping messages if using next/prev PM in history links. (Bug #22205) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9441 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 7aaff2a562..79282c0358 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -664,6 +664,8 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = { delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics); } + + return; }*/ $where_clause = $db->sql_in_set($where_type, $where_ids); -- cgit v1.2.1 From 2af8393d0f5fa08b95df989ab879ce1b7d4cab21 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 8 Jun 2009 22:33:30 +0000 Subject: Fix bug #45705 - Show error in the ACP when template folder is not readable. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9565 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 79282c0358..a1f34792e0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -359,7 +359,7 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl */ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') { - $matches = array(); + $matches = array($dir => array()); // Remove initial / if present $rootdir = (substr($rootdir, 0, 1) == '/') ? substr($rootdir, 1) : $rootdir; -- cgit v1.2.1 From 4758d49b9b661703d2cd5cffaa9c6c443a624e1d Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 14 Jun 2009 10:53:08 +0000 Subject: view_log() breaks if the serialized data is corrupt. #46545 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9589 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a1f34792e0..a8e49a12bc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2419,7 +2419,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id if (!empty($row['log_data'])) { - $log_data_ary = unserialize($row['log_data']); + $log_data_ary = @unserialize($row['log_data']); + $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; if (isset($user->lang[$row['log_operation']])) { @@ -2442,7 +2443,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action'])); } } - else + else if (!empty($log_data_ary)) { $log[$i]['action'] .= '
' . implode('', $log_data_ary); } -- cgit v1.2.1 From 7b0d5c0164491fbce9b93e22bd28ab759c592420 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jun 2009 10:40:32 +0000 Subject: Fix bug #41555 - Fix function to recalculate Binary Tree Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9605 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 104 ++++++++++--------------------------- 1 file changed, 28 insertions(+), 76 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a8e49a12bc..d74bad53e9 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -18,94 +18,46 @@ if (!defined('IN_PHPBB')) /** * Recalculate Binary Tree -function recalc_btree($sql_id, $sql_table, $module_class = '') +* +* @param int $new_id first left_id (should start with 1) +* @param string $pkey primary key-column (containing the id for the parent_id of the children) +* @param string $table constant or fullname of the table +* @param int $parent_id parent_id of the current tree-path (default = 0) +* @param array $where contains strings to compare closer on the where statement (additional) +* +* @author EXreaction +*/ +function recalc_btree(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) { global $db; - if (!$sql_id || !$sql_table) - { - return; - } - - $sql_where = ($module_class) ? " WHERE module_class = '" . $db->sql_escape($module_class) . "'" : ''; - - // Reset to minimum possible left and right id - $sql = "SELECT MIN(left_id) as min_left_id, MIN(right_id) as min_right_id - FROM $sql_table - $sql_where"; + $sql = 'SELECT * + FROM ' . $table . ' + WHERE parent_id = ' . (int) $parent_id . + ((!empty($where)) ? ' AND ' . implode(' AND ', $where) : '') . ' + ORDER BY left_id ASC'; $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $substract = (int) (min($row['min_left_id'], $row['min_right_id']) - 1); - - if ($substract > 0) - { - $sql = "UPDATE $sql_table - SET left_id = left_id - $substract, right_id = right_id - $substract - $sql_where"; - $db->sql_query($sql); - } - - $sql = "SELECT $sql_id, parent_id, left_id, right_id - FROM $sql_table - $sql_where - ORDER BY left_id ASC, parent_id ASC, $sql_id ASC"; - $f_result = $db->sql_query($sql); - - while ($item_data = $db->sql_fetchrow($f_result)) + while ($row = $db->sql_fetchrow($result)) { - if ($item_data['parent_id']) + // First we update the left_id for this module + if ($row['left_id'] != $new_id) { - $sql = "SELECT left_id, right_id - FROM $sql_table - $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . " - $sql_id = {$item_data['parent_id']}"; - $result = $db->sql_query($sql); - - if (!$row = $db->sql_fetchrow($result)) - { - $sql = "UPDATE $sql_table SET parent_id = 0 WHERE $sql_id = " . $item_data[$sql_id]; - $db->sql_query($sql); - } - $db->sql_freeresult($result); + $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('left_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); + } + $new_id++; - $sql = "UPDATE $sql_table - SET left_id = left_id + 2, right_id = right_id + 2 - $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . " - left_id > {$row['right_id']}"; - $db->sql_query($sql); + // Then we go through any children and update their left/right id's + recalc_btree($new_id, $pkey, $table, $row[$pkey], $where); - $sql = "UPDATE $sql_table - SET right_id = right_id + 2 - $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . " - {$row['left_id']} BETWEEN left_id AND right_id"; - $db->sql_query($sql); - - $item_data['left_id'] = $row['right_id']; - $item_data['right_id'] = $row['right_id'] + 1; - } - else + // Then we come back and update the right_id for this module + if ($row['right_id'] != $new_id) { - $sql = "SELECT MAX(right_id) AS right_id - FROM $sql_table - $sql_where"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $item_data['left_id'] = $row['right_id'] + 1; - $item_data['right_id'] = $row['right_id'] + 2; + $db->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', array('right_id' => $new_id)) . " WHERE $pkey = {$row[$pkey]}"); } - - $sql = "UPDATE $sql_table - SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']} - WHERE $sql_id = " . $item_data[$sql_id]; - $db->sql_query($sql); + $new_id++; } - $db->sql_freeresult($f_result); + $db->sql_freeresult($result); } -*/ /** * Simple version of jumpbox, just lists authed forums -- cgit v1.2.1 From afddcaecf2886cd8f2442a419623bb1447d81aba Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jun 2009 12:15:54 +0000 Subject: fix r9605 Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9606 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d74bad53e9..52a7017e09 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -17,17 +17,17 @@ if (!defined('IN_PHPBB')) } /** -* Recalculate Binary Tree +* Recalculate Nested Sets * * @param int $new_id first left_id (should start with 1) * @param string $pkey primary key-column (containing the id for the parent_id of the children) * @param string $table constant or fullname of the table -* @param int $parent_id parent_id of the current tree-path (default = 0) +* @param int $parent_id parent_id of the current set (default = 0) * @param array $where contains strings to compare closer on the where statement (additional) * * @author EXreaction */ -function recalc_btree(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) +function recalc_nested_sets(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) { global $db; @@ -47,7 +47,7 @@ function recalc_btree(&$new_id, $pkey, $table, $parent_id = 0, $where = array()) $new_id++; // Then we go through any children and update their left/right id's - recalc_btree($new_id, $pkey, $table, $row[$pkey], $where); + recalc_nested_sets($new_id, $pkey, $table, $row[$pkey], $where); // Then we come back and update the right_id for this module if ($row['right_id'] != $new_id) -- cgit v1.2.1 From d7d96223e7bae7cd60b13c6e7896d95838c3633c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 19 Jun 2009 09:51:50 +0000 Subject: - Display coloured usernames in ACP groups management screens - Changed behaviour of group_create() function to support specifying additional group columns - New groups option to excempt group leaders from group permissions git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9625 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 52a7017e09..f9a072d1a8 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2137,12 +2137,13 @@ function cache_moderators() // Remove users who have group memberships with DENY moderator permissions $sql = $db->sql_build_query('SELECT', array( - 'SELECT' => 'a.forum_id, ug.user_id', + 'SELECT' => 'a.forum_id, ug.user_id, g.group_id', 'FROM' => array( ACL_OPTIONS_TABLE => 'o', USER_GROUP_TABLE => 'ug', - ACL_GROUPS_TABLE => 'a' + ACL_GROUPS_TABLE => 'a', + GROUPS_TABLE => 'g', ), 'LEFT_JOIN' => array( @@ -2156,6 +2157,8 @@ function cache_moderators() AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL) OR r.auth_setting = ' . ACL_NEVER . ') AND a.group_id = ug.group_id + AND g.ground_id = ug.group_id + AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " AND ug.user_pending = 0 AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char), -- cgit v1.2.1 From ffa5a33702d8ec5adec6bfc1c71bcf6e5708c4ff Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 22 Jun 2009 09:29:22 +0000 Subject: erm, yes... ground should be group git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9651 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index f9a072d1a8..b634410afc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2157,7 +2157,7 @@ function cache_moderators() AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL) OR r.auth_setting = ' . ACL_NEVER . ') AND a.group_id = ug.group_id - AND g.ground_id = ug.group_id + AND g.group_id = ug.group_id AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " AND ug.user_pending = 0 -- cgit v1.2.1 From b6a1271c3aedab008be367565db9c9713e22e638 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sat, 18 Jul 2009 19:19:38 +0000 Subject: - added ability to filter logs by log_operation git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9781 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index b634410afc..dd6378a2b5 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2278,7 +2278,7 @@ function cache_moderators() /** * View log */ -function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC') +function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $log_operation = '') { global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; @@ -2333,7 +2333,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u WHERE l.log_type = $log_type AND u.user_id = l.user_id - " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . " + " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . + (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum ORDER BY $sort_by"; $result = $db->sql_query_limit($sql, $limit, $offset); -- cgit v1.2.1 From b3767cd1436bf2b579ad2e0c1c17f55881d4dc4e Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Mon, 20 Jul 2009 00:57:18 +0000 Subject: - added filtration ability to MCP - added missing lang variable - fixed a pagination bug in filtration routines git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9800 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index dd6378a2b5..ff7f687945 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2499,7 +2499,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $sql = 'SELECT COUNT(l.log_id) AS total_entries FROM ' . LOG_TABLE . " l WHERE l.log_type = $log_type - AND l.log_time >= $limit_days + AND l.log_time >= $limit_days " . + (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum"; $result = $db->sql_query($sql); $log_count = (int) $db->sql_fetchfield('total_entries'); -- cgit v1.2.1 From 780854818b22ccdf36fe50e4e4bf5e68027c9e2b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 09:01:29 +0000 Subject: Fix bug #48265 - Correctly set attachment flag for topics, posts and pms after deleting attachments - Patch by WorldWar and nickvergessen Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9843 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 58 ++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index ff7f687945..457fac2458 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -892,19 +892,61 @@ function delete_attachments($mode, $ids, $resync = true) // Update post indicators for posts now no longer having attachments if (sizeof($post_ids)) { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 0 - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); + // Just check which posts are still having an assigned attachment not orphaned by querying the attachments table + $sql = 'SELECT post_msg_id + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . ' + AND in_message = 0 + AND is_orphan = 0'; + $result = $db->sql_query($sql); + + $remaining_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $remaining_ids[] = $row['post_msg_id']; + } + $db->sql_freeresult($result); + + // Now only unset those ids remaining + $post_ids = array_diff($post_ids, $remaining_ids); + + if (sizeof($post_ids)) + { + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_attachment = 0 + WHERE ' . $db->sql_in_set('post_id', $post_ids); + $db->sql_query($sql); + } } // Update message table if messages are affected if (sizeof($message_ids)) { - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET message_attachment = 0 - WHERE ' . $db->sql_in_set('msg_id', $message_ids); - $db->sql_query($sql); + // Just check which messages are still having an assigned attachment not orphaned by querying the attachments table + $sql = 'SELECT post_msg_id + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('post_msg_id', $message_ids) . ' + AND in_message = 1 + AND is_orphan = 0'; + $result = $db->sql_query($sql); + + $remaining_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $remaining_ids[] = $row['post_msg_id']; + } + $db->sql_freeresult($result); + + // Now only unset those ids remaining + $message_ids = array_diff($message_ids, $remaining_ids); + + if (sizeof($message_ids)) + { + $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' + SET message_attachment = 0 + WHERE ' . $db->sql_in_set('msg_id', $message_ids); + $db->sql_query($sql); + } } // Now update the topics. This is a bit trickier, because there could be posts still having attachments within the topic -- cgit v1.2.1 From 4739c7ba3957dfe585973dafe7465cb9fd8c6d1f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 24 Jul 2009 11:13:32 +0000 Subject: [Feature] Added new functionality to inactive users module: - Ability to set users per page. - Ability to sort by posts/number of reminders/last reminded date. - Show number of posts and ability to search posts. - Show number of reminders sent to user. - Show date of last reminder sent to user. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9845 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 457fac2458..aeb378953d 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2375,7 +2375,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u WHERE l.log_type = $log_type AND u.user_id = l.user_id - " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . + " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum ORDER BY $sort_by"; @@ -2685,7 +2685,7 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li $offset = ($offset - $limit < 0) ? 0 : $offset - $limit; } - $sql = 'SELECT user_id, username, user_regdate, user_lastvisit, user_inactive_time, user_inactive_reason + $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_type = ' . USER_INACTIVE . (($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . " -- cgit v1.2.1 From 986576e2457522e4d8fc1f877210b3aff60eefea Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 27 Jul 2009 12:57:29 +0000 Subject: Fix an SQL error git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9872 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index aeb378953d..8fc895efdc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2376,7 +2376,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id WHERE l.log_type = $log_type AND u.user_id = l.user_id " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . - (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " + (!empty($log_operation) ? " AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " $sql_forum ORDER BY $sort_by"; $result = $db->sql_query_limit($sql, $limit, $offset); -- cgit v1.2.1 From da169625a6a4e7682f0b3a2623f2081e52ad4a49 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Tue, 28 Jul 2009 13:58:01 +0000 Subject: - Display version check on ACP main page. - Cache version check. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9880 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 8fc895efdc..afd00f88bf 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3054,4 +3054,43 @@ function add_permission_language() return true; } +/** + * Obtains the latest version information + * + * @param bool $force_update Ignores cached data. Defaults to false. + * @param bool $warn_fail Trigger a warning if obtaining the latest version information fails. Defaults to false. + * @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours). + * + * @return string | false Version info on success, false on failure. + */ +function obtain_latest_version_info($force_update = false, $warn_fail = false, $ttl = 86400) +{ + global $cache; + + $info = $cache->get('versioncheck'); + + if ($info === false || $force_update) + { + $errstr = ''; + $errno = 0; + + $info = get_remote_file('www.phpbb.com', '/updatecheck', + ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); + + if ($info === false) + { + $cache->destroy('versioncheck'); + if ($warn_fail) + { + trigger_error($errstr, E_USER_WARNING); + } + return false; + } + + $cache->put('versioncheck', $info, $ttl); + } + + return $info; +} + ?> \ No newline at end of file -- cgit v1.2.1 From 1b8a1f73d77d3df21b8404611a130bb4ee19b822 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 22:09:46 +0000 Subject: [Feature] Ability to copy permissions from one forum to several other forums. [Fix] Add log entry when copying forum permissions. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9887 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 143 +++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index afd00f88bf..e9a95f1ec6 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -306,6 +306,149 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl return $rows; } +/** +* Copies permissions from one forum to others +* +* @param int $src_forum_id The source forum we want to copy permissions from +* @param array $dest_forum_ids The destination forum(s) we want to copy to +* @param bool $clear_dest_perms True if destination permissions should be deleted +* @param bool $add_log True if log entry should be added +* +* @return bool False on error +* +* @author bantu +*/ +function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perms = true, $add_log = true) +{ + global $db; + + // Only one forum id specified + if (!is_array($dest_forum_ids)) + { + $dest_forum_ids = array($dest_forum_ids); + } + + // Make sure forum ids are integers + $src_forum_id = (int) $src_forum_id; + $dest_forum_ids = array_map('intval', $dest_forum_ids); + + // No source forum or no destination forums specified + if (empty($src_forum_id) || empty($dest_forum_ids)) + { + return false; + } + + // Check if source forums exists + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $src_forum_id; + $result = $db->sql_query($sql); + $src_forum_name = $db->sql_fetchfield('forum_name'); + + // Source forum doesn't exist + if (empty($src_forum_name)) + { + return false; + } + + // Check if destination forums exists + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $dest_forum_ids[] = (int) $row['forum_id']; + $dest_forum_names[] = $row['forum_name']; + } + $db->sql_freeresult($result); + + // No destination forum exists + if (empty($dest_forum_ids)) + { + return false; + } + + // From the mysql documentation: + // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear + // in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. + // Due to this we stay on the safe side if we do the insertion "the manual way" + + // Rowsets we're going to insert + $users_sql_ary = $groups_sql_ary = array(); + + // Query acl users table for source forum data + $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting + FROM ' . ACL_USERS_TABLE . ' + WHERE forum_id = ' . $src_forum_id; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $row = array( + 'user_id' => (int) $row['user_id'], + 'auth_option_id' => (int) $row['auth_option_id'], + 'auth_role_id' => (int) $row['auth_role_id'], + 'auth_setting' => (int) $row['auth_setting'], + ); + + foreach ($dest_forum_ids as $dest_forum_id) + { + $users_sql_ary[] = $row + array('forum_id' => $dest_forum_id); + } + } + $db->sql_freeresult($result); + + // Query acl groups table for source forum data + $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting + FROM ' . ACL_GROUPS_TABLE . ' + WHERE forum_id = ' . $src_forum_id; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $row = array( + 'group_id' => (int) $row['group_id'], + 'auth_option_id' => (int) $row['auth_option_id'], + 'auth_role_id' => (int) $row['auth_role_id'], + 'auth_setting' => (int) $row['auth_setting'], + ); + + foreach ($dest_forum_ids as $dest_forum_id) + { + $groups_sql_ary[] = $row + array('forum_id' => $dest_forum_id); + } + } + $db->sql_freeresult($result); + + $db->sql_transaction('begin'); + + // Clear current permissions of destination forums + if ($clear_dest_perms) + { + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); + $db->sql_query($sql); + } + + $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); + $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); + + if ($add_log) + { + add_log('admin', 'LOG_FORUM_COPIED_PERMISSIONS', $src_forum_name, implode(', ', $dest_forum_names)); + } + + $db->sql_transaction('commit'); + + return true; +} + /** * Get physical file listing */ -- cgit v1.2.1 From 2958890439f29b9cf45997c52c8cfa57e0f16bc8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 12:28:50 +0000 Subject: Apply locale-independent basename() to attachment filenames. New function added: utf8_basename(). (Bug #43335 - Patch by ocean=Yohsuke) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9905 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index e9a95f1ec6..38388236eb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1235,7 +1235,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) // Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself. $sql = 'SELECT COUNT(attach_id) AS num_entries FROM ' . ATTACHMENTS_TABLE . " - WHERE physical_filename = '" . $db->sql_escape(basename($filename)) . "'"; + WHERE physical_filename = '" . $db->sql_escape(utf8_basename($filename)) . "'"; $result = $db->sql_query($sql); $num_entries = (int) $db->sql_fetchfield('num_entries'); $db->sql_freeresult($result); @@ -1246,7 +1246,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) return false; } - $filename = ($mode == 'thumbnail') ? 'thumb_' . basename($filename) : basename($filename); + $filename = ($mode == 'thumbnail') ? 'thumb_' . utf8_basename($filename) : utf8_basename($filename); return @unlink($phpbb_root_path . $config['upload_path'] . '/' . $filename); } -- cgit v1.2.1 From d2c818ffb9ab1081ebbf74d9895156d1805c237a Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 7 Aug 2009 13:02:14 +0000 Subject: add transactions to sync(); not one big one to avoid nesting. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9937 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 52 ++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 10 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 38388236eb..44675b9cc0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1330,6 +1330,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, switch ($mode) { case 'topic_moved': + $db->sql_transaction('begin'); switch ($db->sql_layer) { case 'mysql4': @@ -1363,12 +1364,16 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); $db->sql_query($sql); - + break; } - break; + + $db->sql_transaction('commit'); + break; case 'topic_approved': + + $db->sql_transaction('begin'); switch ($db->sql_layer) { case 'mysql4': @@ -1404,11 +1409,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); break; } - break; + + $db->sql_transaction('commit'); + break; case 'post_reported': $post_ids = $post_reported = array(); - + + $db->sql_transaction('begin'); + $sql = 'SELECT p.post_id, p.post_reported FROM ' . POSTS_TABLE . " p $where_sql @@ -1459,7 +1468,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + break; case 'topic_reported': if ($sync_extra) @@ -1469,6 +1480,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_ids = $topic_reported = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_reported = 1"; @@ -1501,11 +1514,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + break; case 'post_attachment': $post_ids = $post_attachment = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT p.post_id, p.post_attachment FROM ' . POSTS_TABLE . " p $where_sql @@ -1556,7 +1573,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + break; case 'topic_attachment': if ($sync_extra) @@ -1566,6 +1585,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_ids = $topic_attachment = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_attachment = 1"; @@ -1598,10 +1619,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - break; + + $db->sql_transaction('commit'); + + break; case 'forum': + $db->sql_transaction('begin'); + // 1: Get the list of all forums $sql = 'SELECT f.* FROM ' . FORUMS_TABLE . " f @@ -1802,11 +1828,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); } } - break; + + $db->sql_transaction('commit'); + break; case 'topic': $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); + $db->sql_transaction('begin'); + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; @@ -2129,6 +2159,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } unset($topic_data); + $db->sql_transaction('commit'); + // if some topics have been resync'ed then resync parent forums // except when we're only syncing a range, we don't want to sync forums during // batch processing. @@ -2136,7 +2168,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { sync('forum', 'forum_id', array_values($resync_forums), true, true); } - break; + break; } return; -- cgit v1.2.1 From 09ad10a734c0993f9465e6ac3463951251602fc6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 12 Aug 2009 15:00:47 +0000 Subject: ok, i am very sorry, but this needs to be fixed. Generally, our config table is not really suited for holding large datasets. Because feed settings for the forums to enable news feeds and excluded forums rely on the forums itself we have decided to introduce a forum_options table where custom options can be stored. Additionally, for this to work across all DBMS we support, we added a new method to the DBAL for the bitwise AND operator. Also moved the forum/topic feed template variable to the location where they belong to (forum and topic view) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9965 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 44675b9cc0..1931ae3dfa 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -69,7 +69,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = $acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel')); // This query is identical to the jumpbox one - $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id + $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600); @@ -1364,15 +1364,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary); $db->sql_query($sql); - + break; } - + $db->sql_transaction('commit'); break; case 'topic_approved': - + $db->sql_transaction('begin'); switch ($db->sql_layer) { @@ -1409,15 +1409,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); break; } - + $db->sql_transaction('commit'); break; case 'post_reported': $post_ids = $post_reported = array(); - + $db->sql_transaction('begin'); - + $sql = 'SELECT p.post_id, p.post_reported FROM ' . POSTS_TABLE . " p $where_sql @@ -1468,7 +1468,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); break; @@ -1481,7 +1481,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_ids = $topic_reported = array(); $db->sql_transaction('begin'); - + $sql = 'SELECT DISTINCT(t.topic_id) FROM ' . POSTS_TABLE . " t $where_sql_and t.post_reported = 1"; @@ -1514,7 +1514,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); break; @@ -1522,7 +1522,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $post_ids = $post_attachment = array(); $db->sql_transaction('begin'); - + $sql = 'SELECT p.post_id, p.post_attachment FROM ' . POSTS_TABLE . " p $where_sql @@ -1573,7 +1573,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); break; @@ -1619,15 +1619,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, WHERE ' . $db->sql_in_set('topic_id', $topic_ids); $db->sql_query($sql); } - + $db->sql_transaction('commit'); - + break; case 'forum': $db->sql_transaction('begin'); - + // 1: Get the list of all forums $sql = 'SELECT f.* FROM ' . FORUMS_TABLE . " f @@ -1828,7 +1828,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_query($sql); } } - + $db->sql_transaction('commit'); break; @@ -1836,7 +1836,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array(); $db->sql_transaction('begin'); - + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; @@ -2160,7 +2160,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, unset($topic_data); $db->sql_transaction('commit'); - + // if some topics have been resync'ed then resync parent forums // except when we're only syncing a range, we don't want to sync forums during // batch processing. -- cgit v1.2.1 From a6bf9b4e4aa71da9e0c01e892281d55d661db341 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 14 Aug 2009 11:15:44 +0000 Subject: Some things I missed in r9887. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9979 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 1931ae3dfa..2f8670a147 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -338,12 +338,13 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm return false; } - // Check if source forums exists + // Check if source forum exists $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $src_forum_id; $result = $db->sql_query($sql); $src_forum_name = $db->sql_fetchfield('forum_name'); + $db->sql_freeresult($result); // Source forum doesn't exist if (empty($src_forum_name)) @@ -357,6 +358,7 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); $result = $db->sql_query($sql); + $dest_forum_ids = $dest_forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $dest_forum_ids[] = (int) $row['forum_id']; -- cgit v1.2.1 From 69aa05376bd6cd04e23b6edcfe0d44e9e5f5f7e2 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Fri, 21 Aug 2009 21:47:19 +0000 Subject: - replaced the drop down menu log filter thing with log searching git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10041 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 42 ++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 2f8670a147..d84216701a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -338,13 +338,12 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm return false; } - // Check if source forum exists + // Check if source forums exists $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $src_forum_id; $result = $db->sql_query($sql); $src_forum_name = $db->sql_fetchfield('forum_name'); - $db->sql_freeresult($result); // Source forum doesn't exist if (empty($src_forum_name)) @@ -358,7 +357,6 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); $result = $db->sql_query($sql); - $dest_forum_ids = $dest_forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $dest_forum_ids[] = (int) $row['forum_id']; @@ -2497,7 +2495,7 @@ function cache_moderators() /** * View log */ -function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $log_operation = '') +function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') { global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; @@ -2548,12 +2546,40 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id return; } + $keywords = preg_split('#[\s+\-|*()]+#u', utf8_strtolower(preg_quote($keywords, '#')), 0, PREG_SPLIT_NO_EMPTY); + $sql_keywords = ''; + + if (!empty($keywords)) + { + $keywords_pattern = '#' . implode('|', $keywords) . '#ui'; + for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) + { + $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char); + } + + $operations = array(); + foreach ($user->lang as $key=>$value) + { + if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) + { + $operations[] = $key; + } + } + + $sql_keywords = 'AND ('; + if (!empty($operations)) + { + $sql_keywords.= $db->sql_in_set('l.log_operation', $operations) . ' OR '; + } + $sql_keywords.= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + } + $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u WHERE l.log_type = $log_type AND u.user_id = l.user_id - " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . - (!empty($log_operation) ? " AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " + " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . " + $sql_keywords $sql_forum ORDER BY $sort_by"; $result = $db->sql_query_limit($sql, $limit, $offset); @@ -2718,8 +2744,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $sql = 'SELECT COUNT(l.log_id) AS total_entries FROM ' . LOG_TABLE . " l WHERE l.log_type = $log_type - AND l.log_time >= $limit_days " . - (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . " + AND l.log_time >= $limit_days + $sql_keywords $sql_forum"; $result = $db->sql_query($sql); $log_count = (int) $db->sql_fetchfield('total_entries'); -- cgit v1.2.1 From 70c4e48b3973df360ec075b89011cb2841c1abb7 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sat, 22 Aug 2009 02:56:05 +0000 Subject: - accidentally undid changes introduced in r9979 - removed a few lines from the old log filtering system git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10042 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d84216701a..a021717f57 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -338,12 +338,13 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm return false; } - // Check if source forums exists + // Check if source forum exists $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $src_forum_id; $result = $db->sql_query($sql); $src_forum_name = $db->sql_fetchfield('forum_name'); + $db->sql_freeresult($result); // Source forum doesn't exist if (empty($src_forum_name)) @@ -357,6 +358,7 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm WHERE ' . $db->sql_in_set('forum_id', $dest_forum_ids); $result = $db->sql_query($sql); + $dest_forum_ids = $dest_forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $dest_forum_ids[] = (int) $row['forum_id']; -- cgit v1.2.1 From 17f40511bf4df9dd46cd13cbd2c7802c49575783 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 25 Aug 2009 09:07:26 +0000 Subject: Make sure only logs for existing users are displayed and user-specific logs removed on user deletion. (Bug #49855) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10053 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a021717f57..205d7046c7 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2744,8 +2744,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id } $sql = 'SELECT COUNT(l.log_id) AS total_entries - FROM ' . LOG_TABLE . " l + FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u WHERE l.log_type = $log_type + AND l.user_id = u.user_id AND l.log_time >= $limit_days $sql_keywords $sql_forum"; -- cgit v1.2.1 From df86a1b27c14f81915d11038072eba2df5ecdd93 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 6 Sep 2009 23:59:35 +0000 Subject: Some smaller changes to r10041. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10112 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 205d7046c7..d42a81fa35 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2517,15 +2517,15 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id if ($topic_id) { - $sql_forum = 'AND l.topic_id = ' . intval($topic_id); + $sql_forum = 'AND l.topic_id = ' . (int) $topic_id; } else if (is_array($forum_id)) { $sql_forum = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); } - else + else if ($forum_id) { - $sql_forum = ($forum_id) ? 'AND l.forum_id = ' . intval($forum_id) : ''; + $sql_forum = 'AND l.forum_id = ' . (int) $forum_id; } break; @@ -2560,7 +2560,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id } $operations = array(); - foreach ($user->lang as $key=>$value) + foreach ($user->lang as $key => $value) { if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) { @@ -2571,9 +2571,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $sql_keywords = 'AND ('; if (!empty($operations)) { - $sql_keywords.= $db->sql_in_set('l.log_operation', $operations) . ' OR '; + $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; } - $sql_keywords.= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; } $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour -- cgit v1.2.1 From 1df914d80ae0bd87837af1604c3b46620a97edea Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 15 Sep 2009 12:58:23 +0000 Subject: fix uninitialised variable in functions_admin.php (Bug #51295) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10146 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d42a81fa35..e49b4a8ccd 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2514,6 +2514,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id case 'mod': $log_type = LOG_MOD; + $sql_forum = ''; if ($topic_id) { -- cgit v1.2.1 From 13e8898563365d93525f08e1b4103c94b2114d48 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 17 Sep 2009 13:44:50 +0000 Subject: Return integers when get_forum_list() is supposed to only return IDs. This will save us some calls to the sql escape function when used with sql_in_set(). Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10159 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index e49b4a8ccd..c0db64dbfb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -254,7 +254,7 @@ function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = if ($acl_list == '' || ($acl_list != '' && $auth->acl_gets($acl_list, $row['forum_id']))) { - $rowset[] = ($id_only) ? $row['forum_id'] : $row; + $rowset[] = ($id_only) ? (int) $row['forum_id'] : $row; } } -- cgit v1.2.1 From 87e717ae8782b5d3a26ecc3d4fee3268fdadf6cb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 28 Oct 2009 15:10:32 +0000 Subject: Fix Bug #53245 - Correct regular expression escaping and only splitting keywords on space and "|" git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10240 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index c0db64dbfb..92dcf60ee0 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2549,17 +2549,24 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id return; } - $keywords = preg_split('#[\s+\-|*()]+#u', utf8_strtolower(preg_quote($keywords, '#')), 0, PREG_SPLIT_NO_EMPTY); + // Use no preg_quote for $keywords because this would lead to sole backslashes being added + // We also use an OR connection here for spaces and the | string. Currently, regex is not supported for searching (but may come later). + $keywords = preg_split('#[\s|]+#u', utf8_strtolower($keywords), 0, PREG_SPLIT_NO_EMPTY); $sql_keywords = ''; if (!empty($keywords)) { - $keywords_pattern = '#' . implode('|', $keywords) . '#ui'; + $keywords_pattern = array(); + + // Build pattern and keywords... for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) { + $keywords_pattern[] = preg_quote($keywords[$i], '#'); $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char); } + $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; + $operations = array(); foreach ($user->lang as $key => $value) { -- cgit v1.2.1 From a691f4c8bccccf2916aa5a0e1e36f69a97f36a2f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 9 Nov 2009 16:23:15 +0000 Subject: Fix sql error in cache_moderators() if using postgresql. (Bug #53765) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10260 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 92dcf60ee0..ddadda8ed2 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2361,8 +2361,8 @@ function cache_moderators() 'FROM' => array( ACL_OPTIONS_TABLE => 'o', USER_GROUP_TABLE => 'ug', - ACL_GROUPS_TABLE => 'a', GROUPS_TABLE => 'g', + ACL_GROUPS_TABLE => 'a', ), 'LEFT_JOIN' => array( -- cgit v1.2.1 From ad14664a3a53c270511bc19392c38b60a2c3e3ff Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Mon, 18 Jan 2010 16:41:21 +0000 Subject: - Bug #56255 - Moving topics to a forum where you are on queue - Allow some error handling in compress class by returning false if file does not exist. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10427 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index ddadda8ed2..a1bc2e7795 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -66,8 +66,6 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = { global $db, $user, $auth; - $acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel')); - // This query is identical to the jumpbox one $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id FROM ' . FORUMS_TABLE . ' @@ -98,18 +96,21 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = $right = $row['right_id']; $disabled = false; - if ($acl && !$auth->acl_gets($acl, $row['forum_id'])) + if (!$ignore_acl && $auth->acl_get('f_list', $row['forum_id'])) { - // List permission? - if ($auth->acl_get('f_list', $row['forum_id'])) + if ($only_acl_post && !$auth->acl_get('f_post', $row['forum_id']) || (!$auth->acl_get('m_approve', $row['forum_id']) && !$auth->acl_get('f_noapprove', $row['forum_id']))) { $disabled = true; } - else + else if (!$only_acl_post && !$auth->acl_gets(array('a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) { - continue; + $disabled = true; } } + else if (!$ignore_acl) + { + continue; + } if ( ((is_array($ignore_id) && in_array($row['forum_id'], $ignore_id)) || $row['forum_id'] == $ignore_id) -- cgit v1.2.1 From d26f66703b0164c5cdd9dc4abf77450faf53ba41 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 7 Feb 2010 01:04:10 +0000 Subject: Fix #57395, a regression from r10427 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10482 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a1bc2e7795..ff291fbe8a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -102,7 +102,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = { $disabled = true; } - else if (!$only_acl_post && !$auth->acl_gets(array('a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) + else if (!$only_acl_post && !$auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) { $disabled = true; } -- cgit v1.2.1 From 1802b9ff9286a7fc24493e71b3432816cbdbfcd8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 11 Feb 2010 00:02:51 +0000 Subject: Support for Microsoft's Native SQL Server Driver for PHP - Patch by Chris Pucci at Microsoft [Bug #57055] If you are using SQL Server, please try to test this new dbal so we can safely include it in 3.0.8. If you want to try it on a current phpBB version you can apply the latest version of the patch to your board which you can find attached to the bug tracker ticket (look in the comments for the latest version, the one in the ticket itself is outdated): http://www.phpbb.com/bugs/phpbb3/ticket.php?ticket_id=57055 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10489 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index ff291fbe8a..ea64bb3beb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3041,6 +3041,7 @@ function get_database_size() case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles'; $result = $db->sql_query($sql, 7200); -- cgit v1.2.1 From c6e176d88edb882a1cc02a4f6d83114554b38121 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 15 Feb 2010 15:04:44 +0000 Subject: Add sql_bit_or() dbal method. Add ability to enable quick reply in all forums. -- Voila ;-) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10491 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index ea64bb3beb..955ef4df58 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3309,4 +3309,24 @@ function obtain_latest_version_info($force_update = false, $warn_fail = false, $ return $info; } +/** + * Enables a particular flag in a bitfield column of a given table. + * + * @param string $table_name The table to update + * @param string $column_name The column containing a bitfield to update + * @param int $flag The binary flag which is OR-ed with the current column value + * @param string $sql_more This string is attached to the sql query generated to update the table. + * + * @return void + */ +function enable_bitfield_column_flag($table_name, $column_name, $flag, $sql_more = '') +{ + global $db; + + $sql = 'UPDATE ' . $table_name . ' + SET ' . $column_name . ' = ' . $db->sql_bit_or($column_name, $flag) . ' + ' . $sql_more; + $db->sql_query($sql); +} + ?> \ No newline at end of file -- cgit v1.2.1 From 2ec1d9238878fe3838f296e77cd05493e19e38ab Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 23 Feb 2010 18:52:06 +0000 Subject: Fix Bug #57375 - Do not delete unrelated attachments when deleting empty forums. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10526 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 955ef4df58..93244be55c 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -913,7 +913,13 @@ function delete_attachments($mode, $ids, $resync = true) { global $db, $config; - if (is_array($ids) && sizeof($ids)) + // 0 is as bad as an empty array + if (empty($ids)) + { + return false; + } + + if (is_array($ids)) { $ids = array_unique($ids); $ids = array_map('intval', $ids); @@ -923,11 +929,6 @@ function delete_attachments($mode, $ids, $resync = true) $ids = array((int) $ids); } - if (!sizeof($ids)) - { - return false; - } - $sql_where = ''; switch ($mode) -- cgit v1.2.1