aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/mcp
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-08-12 13:14:39 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-08-12 13:14:39 +0000
commit8405f0d324fd42bec2f775986e69e5d8cf548ebf (patch)
treeefa8caf14f78d67ece434c39e294532adbd20a8b /phpBB/includes/mcp
parent0c6bfcf4c715b64d8c971adb6077018994fe5ce9 (diff)
downloadforums-8405f0d324fd42bec2f775986e69e5d8cf548ebf.tar
forums-8405f0d324fd42bec2f775986e69e5d8cf548ebf.tar.gz
forums-8405f0d324fd42bec2f775986e69e5d8cf548ebf.tar.bz2
forums-8405f0d324fd42bec2f775986e69e5d8cf548ebf.tar.xz
forums-8405f0d324fd42bec2f775986e69e5d8cf548ebf.zip
sql_in_set changes
git-svn-id: file:///svn/phpbb/trunk@6271 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/mcp')
-rw-r--r--phpBB/includes/mcp/mcp_forum.php2
-rw-r--r--phpBB/includes/mcp/mcp_front.php4
-rwxr-xr-xphpBB/includes/mcp/mcp_logs.php2
-rw-r--r--phpBB/includes/mcp/mcp_main.php22
-rwxr-xr-xphpBB/includes/mcp/mcp_notes.php2
-rw-r--r--phpBB/includes/mcp/mcp_queue.php12
-rwxr-xr-xphpBB/includes/mcp/mcp_reports.php37
7 files changed, 41 insertions, 40 deletions
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index 36211ab5b0..09470b8269 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -177,7 +177,7 @@ function mcp_resync_topics($topic_ids)
$sql = 'SELECT topic_id, forum_id, topic_title
FROM ' . TOPICS_TABLE . '
- WHERE topic_id IN (' . implode(', ', $topic_ids) . ')';
+ WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$result = $db->sql_query($sql);
// Log this action
diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php
index 4ff02c7a43..745b2c0d61 100644
--- a/phpBB/includes/mcp/mcp_front.php
+++ b/phpBB/includes/mcp/mcp_front.php
@@ -41,7 +41,7 @@ function mcp_front_view($id, $mode, $action)
$sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . '
- WHERE forum_id IN (' . implode(', ', $forum_list) . ')';
+ WHERE ' . $db->sql_in_set('forum_id', $forum_list);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -65,7 +65,7 @@ function mcp_front_view($id, $mode, $action)
$sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
- WHERE p.post_id IN (' . implode(', ', $post_list) . ')
+ WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
AND t.topic_id = p.topic_id
AND p.poster_id = u.user_id
ORDER BY p.post_time DESC';
diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php
index e14ac094fe..f9cf7d27df 100755
--- a/phpBB/includes/mcp/mcp_logs.php
+++ b/phpBB/includes/mcp/mcp_logs.php
@@ -84,7 +84,7 @@ class mcp_logs
$sql_in[] = $mark;
}
- $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')';
+ $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
unset($sql_in);
}
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index ce0c47941d..9b2d47c818 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -224,8 +224,8 @@ function lock_unlock($action, $ids)
if (confirm_box(true))
{
$sql = "UPDATE $table
- SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . "
- WHERE $sql_id IN (" . implode(', ', $ids) . ")";
+ SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . '
+ WHERE ' . $db->sql_in_set($sql_id, $ids);
$db->sql_query($sql);
$data = ($action == 'lock' || $action == 'unlock') ? get_topic_data($ids) : get_post_data($ids);
@@ -311,7 +311,7 @@ function change_topic_type($action, $topic_ids)
{
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type
- WHERE topic_id IN (" . implode(', ', $topic_ids) . ')
+ WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id <> 0';
$db->sql_query($sql);
@@ -320,14 +320,14 @@ function change_topic_type($action, $topic_ids)
{
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type, forum_id = $forum_id
- WHERE topic_id IN (" . implode(', ', $topic_ids) . ')
+ WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id = 0';
$db->sql_query($sql);
// Update forum_ids for all posts
$sql = 'UPDATE ' . POSTS_TABLE . "
SET forum_id = $forum_id
- WHERE topic_id IN (" . implode(', ', $topic_ids) . ')
+ WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id = 0';
$db->sql_query($sql);
@@ -339,7 +339,7 @@ function change_topic_type($action, $topic_ids)
// Get away with those topics already being a global announcement by re-calculating $topic_ids
$sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . '
- WHERE topic_id IN (' . implode(', ', $topic_ids) . ')
+ WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id <> 0';
$result = $db->sql_query($sql);
@@ -354,18 +354,18 @@ function change_topic_type($action, $topic_ids)
{
// Delete topic shadows for global announcements
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE topic_moved_id IN (' . implode(', ', $topic_ids) . ')';
+ WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type, forum_id = 0
- WHERE topic_id IN (" . implode(', ', $topic_ids) . ')';
+ WHERE " . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
// Update forum_ids for all posts
$sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = 0
- WHERE topic_id IN (' . implode(', ', $topic_ids) . ')';
+ WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
sync('forum', 'forum_id', $forum_id);
@@ -640,7 +640,7 @@ function mcp_delete_post($post_ids)
$sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . '
- WHERE post_id IN (' . implode(', ', $post_ids) . ')';
+ WHERE ' . $db->sql_in_set('post_id', $post_ids);
$result = $db->sql_query($sql);
$topic_id_list = array();
@@ -663,7 +663,7 @@ function mcp_delete_post($post_ids)
$sql = 'SELECT COUNT(topic_id) AS topics_left
FROM ' . TOPICS_TABLE . '
- WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
+ WHERE ' . $db->sql_in_set('topic_id', $topic_id_list);
$result = $db->sql_query_limit($sql, 1);
$deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics;
diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php
index 0f716f5f9e..cc4ed0e72b 100755
--- a/phpBB/includes/mcp/mcp_notes.php
+++ b/phpBB/includes/mcp/mcp_notes.php
@@ -106,7 +106,7 @@ class mcp_notes
{
$sql_in[] = $mark;
}
- $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')';
+ $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
unset($sql_in);
}
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 25fdc0a90a..95e89fa9dc 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -251,10 +251,10 @@ class mcp_queue
if (sizeof($post_ids))
{
$sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username
- FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . " u
- WHERE p.post_id IN (" . implode(', ', $post_ids) . ")
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
+ WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . '
AND t.topic_id = p.topic_id
- AND u.user_id = p.poster_id";
+ AND u.user_id = p.poster_id';
$result = $db->sql_query($sql);
$post_data = $rowset = array();
@@ -306,7 +306,7 @@ class mcp_queue
// Select the names for the forum_ids
$sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . '
- WHERE forum_id IN (' . implode(',', $forum_names) . ')';
+ WHERE ' . $db->sql_in_set('forum_id', $forum_names);
$result = $db->sql_query($sql, 3600);
$forum_names = array();
@@ -449,7 +449,7 @@ function approve_post($post_id_list, $mode)
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_approved = 1
- WHERE topic_id IN (' . implode(', ', $topic_approve_sql) . ')';
+ WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql);
$db->sql_query($sql);
}
@@ -457,7 +457,7 @@ function approve_post($post_id_list, $mode)
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_approved = 1
- WHERE post_id IN (' . implode(', ', $post_approve_sql) . ')';
+ WHERE ' . $db->sql_in_set('post_id', $post_approve_sql);
$db->sql_query($sql);
}
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index be4502e23e..a52bc02359 100755
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -191,9 +191,10 @@ class mcp_reports
$forum_id = $topic_info['forum_id'];
}
+ $forum_list = array();
+
if (!$forum_id)
{
- $forum_list = array();
foreach ($forum_list_reports as $row)
{
$forum_list[] = $row['forum_id'];
@@ -201,14 +202,14 @@ class mcp_reports
$global_id = $forum_list[0];
- if (!($forum_list = implode(', ', $forum_list)))
+ if (!sizeof($forum_list))
{
trigger_error('NOT_MODERATOR');
}
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics
- FROM ' . FORUMS_TABLE . "
- WHERE forum_id IN ($forum_list)";
+ FROM ' . FORUMS_TABLE . '
+ WHERE ' . $db->sql_in_set('forum_id', $forum_list);
$result = $db->sql_query($sql);
$forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics');
$db->sql_freeresult($result);
@@ -223,11 +224,11 @@ class mcp_reports
}
$forum_info = $forum_info[$forum_id];
- $forum_list = $forum_id;
+ $forum_list = array($forum_id);
$global_id = $forum_id;
}
- $forum_list .= ', 0';
+ $forum_list[] = 0;
$forum_data = array();
$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
@@ -256,8 +257,8 @@ class mcp_reports
}
$sql = 'SELECT r.report_id
- FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . "
- WHERE p.forum_id IN ($forum_list)
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . '
+ WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . "
$report_state
AND r.post_id = p.post_id
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
@@ -280,12 +281,12 @@ class mcp_reports
if (sizeof($report_ids))
{
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, r.user_id as reporter_id, ru.username as reporter_name, r.report_time, r.report_id
- FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . " ru
- WHERE r.report_id IN (" . implode(', ', $report_ids) . ")
+ FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru
+ WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . '
AND t.topic_id = p.topic_id
AND r.post_id = p.post_id
AND u.user_id = p.poster_id
- AND ru.user_id = r.user_id";
+ AND ru.user_id = r.user_id';
$result = $db->sql_query($sql);
$report_data = $rowset = array();
@@ -387,7 +388,7 @@ function close_report($post_id_list, $mode, $action)
$sql = 'SELECT r.post_id, r.report_closed, r.user_id, r.user_notify, u.username, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type
FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u
- WHERE r.post_id IN (' . implode(',', array_keys($post_info)) . ')
+ WHERE ' . $db->sql_in_set('r.post_id', array_keys($post_info)) . '
' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . '
AND r.user_id = u.user_id';
$result = $db->sql_query($sql);
@@ -421,9 +422,9 @@ function close_report($post_id_list, $mode, $action)
// Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . '
- WHERE topic_id IN (' . implode(', ', $close_report_topics) . ')
+ WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . '
AND post_reported = 1
- AND post_id NOT IN (' . implode(', ', $close_report_posts) . ')';
+ AND ' . $db->sql_in_set('post_id', $close_report_posts, true);
$result = $db->sql_query($sql);
$keep_report_topics = array();
@@ -442,25 +443,25 @@ function close_report($post_id_list, $mode, $action)
{
$sql = 'UPDATE ' . REPORTS_TABLE . '
SET report_closed = 1
- WHERE post_id IN (' . implode(', ', $close_report_posts) . ')';
+ WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
}
else
{
$sql = 'DELETE FROM ' . REPORTS_TABLE . '
- WHERE post_id IN (' . implode(', ', $close_report_posts) . ')';
+ WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
}
$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0
- WHERE post_id IN (' . implode(', ', $close_report_posts) . ')';
+ WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
$db->sql_query($sql);
if (sizeof($close_report_topics))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
- WHERE topic_id IN (' . implode(', ', $close_report_topics) . ')';
+ WHERE ' . $db->sql_in_set('topic_id', $close_report_topics);
$db->sql_query($sql);
}