$db-> to phpbb::$db->

git-svn-id: file:///svn/phpbb/trunk@9336 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-02-22 18:06:05 +00:00
parent 95b69cfa7f
commit 84f795e9fb
86 changed files with 3078 additions and 3080 deletions

View file

@ -56,12 +56,12 @@ if (phpbb::$config['cron_lock'])
define('CRON_ID', time() . ' ' . unique_id()); define('CRON_ID', time() . ' ' . unique_id());
$sql = 'UPDATE ' . CONFIG_TABLE . " $sql = 'UPDATE ' . CONFIG_TABLE . "
SET config_value = '" . $db->sql_escape(CRON_ID) . "' SET config_value = '" . phpbb::$db->sql_escape(CRON_ID) . "'
WHERE config_name = 'cron_lock' AND config_value = '" . $db->sql_escape(phpbb::$config['cron_lock']) . "'"; WHERE config_name = 'cron_lock' AND config_value = '" . phpbb::$db->sql_escape(phpbb::$config['cron_lock']) . "'";
phpbb::$db->sql_query($sql); phpbb::$db->sql_query($sql);
// another cron process altered the table between script start and UPDATE query so exit // another cron process altered the table between script start and UPDATE query so exit
if ($db->sql_affectedrows() != 1) if (phpbb::$db->sql_affectedrows() != 1)
{ {
exit; exit;
} }
@ -214,9 +214,9 @@ switch ($cron_type)
$sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -278,8 +278,8 @@ function unlock_cron()
{ {
$sql = 'UPDATE ' . CONFIG_TABLE . " $sql = 'UPDATE ' . CONFIG_TABLE . "
SET config_value = '0' SET config_value = '0'
WHERE config_name = 'cron_lock' AND config_value = '" . $db->sql_escape(CRON_ID) . "'"; WHERE config_name = 'cron_lock' AND config_value = '" . phpbb::$db->sql_escape(CRON_ID) . "'";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
?> ?>

View file

@ -82,7 +82,7 @@ class posting_api
static function insert_topic($data) static function insert_topic($data)
{ {
// one transaction, we can now garuntee that atomicity of insertions // one transaction, we can now garuntee that atomicity of insertions
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$user_id = (int) $data['user_id']; $user_id = (int) $data['user_id'];
$forum_id = (int) $data['forum_id']; $forum_id = (int) $data['forum_id'];
@ -105,17 +105,17 @@ class posting_api
$sql = 'SELECT username $sql = 'SELECT username
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$username = (string) $db->sql_fetchfield('username'); $username = (string) phpbb::$db->sql_fetchfield('username');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$sql = 'SELECT forum_topics, forum_unapproved_topics, forum_posts, forum_unapproved_posts $sql = 'SELECT forum_topics, forum_unapproved_topics, forum_posts, forum_unapproved_posts
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $forum_id; WHERE forum_id = ' . (int) $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// throw our topic to the dogs // throw our topic to the dogs
$topic_data = array( $topic_data = array(
@ -135,8 +135,8 @@ class posting_api
'forum_id' => $forum_id 'forum_id' => $forum_id
); );
$db->sql_handle_data('INSERT', TOPICS_TABLE, $topic_data); phpbb::$db->sql_handle_data('INSERT', TOPICS_TABLE, $topic_data);
$topic_id = $db->sql_nextid(); $topic_id = phpbb::$db->sql_nextid();
// I suppose it is time to make us a post, no? // I suppose it is time to make us a post, no?
$post_data = array( $post_data = array(
@ -150,11 +150,11 @@ class posting_api
'forum_id' => $forum_id 'forum_id' => $forum_id
); );
$db->sql_handle_data('INSERT', POSTS_TABLE, $post_data); phpbb::$db->sql_handle_data('INSERT', POSTS_TABLE, $post_data);
$post_id = $db->sql_nextid(); $post_id = phpbb::$db->sql_nextid();
// time to fill in the blanks // time to fill in the blanks
$db->sql_handle_data('UPDATE', TOPICS_TABLE, array('topic_first_post_id' => $post_id, 'topic_last_post_id' => $post_id), "topic_id = $topic_id"); phpbb::$db->sql_handle_data('UPDATE', TOPICS_TABLE, array('topic_first_post_id' => $post_id, 'topic_last_post_id' => $post_id), "topic_id = $topic_id");
// let's go update the forum table // let's go update the forum table
$forum_data = array( $forum_data = array(
@ -177,7 +177,7 @@ class posting_api
$forum_data['forum_unapproved_topics'] = ++$row['forum_unapproved_topics']; $forum_data['forum_unapproved_topics'] = ++$row['forum_unapproved_topics'];
} }
$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id"); phpbb::$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id");
foreach ($shadow_forums as $shadow_forum_id) foreach ($shadow_forums as $shadow_forum_id)
{ {
@ -187,14 +187,14 @@ class posting_api
} }
// we are consistant, victory is ours // we are consistant, victory is ours
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
} }
// inserts a shadow topic into the database // inserts a shadow topic into the database
static function insert_shadow_topic($data) static function insert_shadow_topic($data)
{ {
// one transaction, we can now garuntee that atomicity of insertions // one transaction, we can now garuntee that atomicity of insertions
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$user_id = (int) $data['user_id']; $user_id = (int) $data['user_id'];
$forum_id = (int) $data['forum_id']; $forum_id = (int) $data['forum_id'];
@ -214,18 +214,17 @@ class posting_api
$sql = 'SELECT username $sql = 'SELECT username
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $username = (stromg) phpbb::$db->sql_fetchfield('username');
$username = $row['username']; phpbb::$db->sql_freeresult($result);
$db->sql_freeresult($result);
} }
$sql = 'SELECT forum_topics, forum_shadow_topics $sql = 'SELECT forum_topics, forum_shadow_topics
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $forum_id; WHERE forum_id = ' . (int) $forum_id;
$result = $db->sql_query($sql); $result = phpbb::phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// throw our topic to the dogs // throw our topic to the dogs
$topic_data = array( $topic_data = array(
@ -246,7 +245,7 @@ class posting_api
'topic_shadow_id' => $shadow_topic_id 'topic_shadow_id' => $shadow_topic_id
); );
$db->sql_handle_data('INSERT', TOPICS_TABLE, $topic_data); phpbb::$db->sql_handle_data('INSERT', TOPICS_TABLE, $topic_data);
// let's go update the forum table // let's go update the forum table
$forum_data = array( $forum_data = array(
@ -260,16 +259,16 @@ class posting_api
$forum_data['forum_unapproved_topics'] = ++$row['forum_unapproved_topics']; $forum_data['forum_unapproved_topics'] = ++$row['forum_unapproved_topics'];
} }
$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id"); phpbb::$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id");
// we are consistant, victory is ours // we are consistant, victory is ours
$db->transaction('END'); phpbb::$db->transaction('END');
} }
static function insert_post($data) static function insert_post($data)
{ {
// one transaction, we can now garuntee that atomicity of insertions // one transaction, we can now garuntee that atomicity of insertions
$db->transaction('BEGIN'); phpbb::$db->transaction('BEGIN');
$user_id = (int) $data['user_id']; $user_id = (int) $data['user_id'];
$topic_id = (int) $data['topic_id']; $topic_id = (int) $data['topic_id'];
@ -285,9 +284,9 @@ class posting_api
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id; WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_id = (int) $db->sql_fetchfield('forum_id'); $forum_id = (int) phpbb::$db->sql_fetchfield('forum_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$post_title = $data['title']; $post_title = $data['title'];
@ -303,9 +302,9 @@ class posting_api
$sql = 'SELECT username $sql = 'SELECT username
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$username = (string) $db->sql_fetchfield('username'); $username = (string) phpbb::$db->sql_fetchfield('username');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// hand holding complete, lets write some posts // hand holding complete, lets write some posts
@ -313,9 +312,9 @@ class posting_api
$sql = 'SELECT forum_topics, forum_unapproved_topics, forum_posts, forum_unapproved_posts $sql = 'SELECT forum_topics, forum_unapproved_topics, forum_posts, forum_unapproved_posts
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $forum_id; WHERE forum_id = ' . (int) $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$post_status = (int) $data['post_status']; $post_status = (int) $data['post_status'];
$approved = ($post_status === self::NORMAL); $approved = ($post_status === self::NORMAL);
@ -330,10 +329,10 @@ class posting_api
'post_status' => $post_status, 'post_status' => $post_status,
'forum_id' => $forum_id, 'forum_id' => $forum_id,
); );
$db->sql_handle_data('INSERT', POSTS_TABLE, $post_data); phpbb::$db->sql_handle_data('INSERT', POSTS_TABLE, $post_data);
// what is the new post_id? // what is the new post_id?
$post_id = $db->sql_nextid(); $post_id = phpbb::$db->sql_nextid();
// iceberg ahead! we must only update the topic information if the post is approved ;) // iceberg ahead! we must only update the topic information if the post is approved ;)
if ($approved) if ($approved)
@ -346,7 +345,7 @@ class posting_api
'topic_last_post_title' => $post_title, 'topic_last_post_title' => $post_title,
'topic_last_post_time' => $time, 'topic_last_post_time' => $time,
); );
$db->sql_handle_data('UPDATE', TOPICS_TABLE, $topics_data, "topic_id = $topic_id"); phpbb::$db->sql_handle_data('UPDATE', TOPICS_TABLE, $topics_data, "topic_id = $topic_id");
} }
// let's go update the forum table // let's go update the forum table
@ -368,10 +367,10 @@ class posting_api
$forum_data['forum_unapproved_posts'] = ++$row['forum_unapproved_posts']; $forum_data['forum_unapproved_posts'] = ++$row['forum_unapproved_posts'];
} }
$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id"); phpbb::$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id");
// we are consistant, victory is ours // we are consistant, victory is ours
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
} }
static function delete_topic($data) static function delete_topic($data)
@ -383,7 +382,7 @@ class posting_api
static function delete_topics($data) static function delete_topics($data)
{ {
// lets get this party started // lets get this party started
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$topic_ids = array_map('intval', $data['topic_ids']); $topic_ids = array_map('intval', $data['topic_ids']);
@ -391,11 +390,11 @@ class posting_api
// TODO: investigate how aggregate functions can speed this up/reduce the number of results returned/misc. other benefits // TODO: investigate how aggregate functions can speed this up/reduce the number of results returned/misc. other benefits
$sql = 'SELECT topic_posts, topic_shadow_posts, topic_deleted_posts, topic_unapproved_posts, topic_shadow_id, forum_id, topic_status $sql = 'SELECT topic_posts, topic_shadow_posts, topic_deleted_posts, topic_unapproved_posts, topic_shadow_id, forum_id, topic_status
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
// the following in an array, key'd by forum id that refers to topic rows // the following in an array, key'd by forum id that refers to topic rows
$forum_lookup = array(); $forum_lookup = array();
while ($topic_row = $db->sql_fetchrow($result)) while ($topic_row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_id = (int) $topic_row['forum_id']; $forum_id = (int) $topic_row['forum_id'];
@ -412,28 +411,28 @@ class posting_api
$forum_lookup[$forum_id]['forum_deleted_topics'] += ($topic_status & self::DELETED); $forum_lookup[$forum_id]['forum_deleted_topics'] += ($topic_status & self::DELETED);
$forum_lookup[$forum_id]['forum_unapproved_topics'] += ($topic_status & self::UNAPPROVED); $forum_lookup[$forum_id]['forum_unapproved_topics'] += ($topic_status & self::UNAPPROVED);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// goodnight, topics // goodnight, topics
$db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); phpbb::$db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids));
// goodnight, posts // goodnight, posts
$db->sql_query('DELETE FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); phpbb::$db->sql_query('DELETE FROM ' . POSTS_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids));
$forum_ids = array_keys($forum_lookup); $forum_ids = array_keys($forum_lookup);
// what kind of topic is this? lets find out how much we must tamper with the forum table... // what kind of topic is this? lets find out how much we must tamper with the forum table...
$sql = 'SELECT forum_posts, forum_shadow_posts, forum_deleted_posts, forum_unapproved_posts, forum_id $sql = 'SELECT forum_posts, forum_shadow_posts, forum_deleted_posts, forum_unapproved_posts, forum_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_rows = array(); $forum_rows = array();
while ($forum_row = $db->sql_fetchrow($result)) while ($forum_row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_id = (int) $forum_row['forum_id']; $forum_id = (int) $forum_row['forum_id'];
$forum_rows[$forum_id] = $forum_row; $forum_rows[$forum_id] = $forum_row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$shadow_topic_ids = array(); $shadow_topic_ids = array();
foreach ($forum_rows as $forum_id => $forum_row) foreach ($forum_rows as $forum_id => $forum_row)
@ -456,9 +455,9 @@ class posting_api
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_status = ' . self::NORMAL . ' WHERE post_status = ' . self::NORMAL . '
AND forum_id = ' . $forum_id; AND forum_id = ' . $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// anything left? // anything left?
if ($row) if ($row)
@ -467,9 +466,9 @@ class posting_api
$sql = 'SELECT post_username, poster_id, post_subject, post_time $sql = 'SELECT post_username, poster_id, post_subject, post_time
FROM '. POSTS_TABLE . ' FROM '. POSTS_TABLE . '
WHERE post_id = ' . (int) $row['max_post_id']; WHERE post_id = ' . (int) $row['max_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$last_post = $db->sql_fetchrow($result); $last_post = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$forum_array['forum_last_user_id'] = (int) $last_post['poster_id']; $forum_array['forum_last_user_id'] = (int) $last_post['poster_id'];
$forum_array['forum_last_poster_name'] = $last_post['post_username']; $forum_array['forum_last_poster_name'] = $last_post['post_username'];
@ -485,22 +484,22 @@ class posting_api
$forum_array['forum_last_post_time'] = 0; $forum_array['forum_last_post_time'] = 0;
} }
$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_array, "forum_id = $forum_id"); phpbb::$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_array, "forum_id = $forum_id");
} }
// let's not get too hasty, we can kill off the shadows later, // let's not get too hasty, we can kill off the shadows later,
// instead we compose a list of all shadows and then efficiently kill them off :) // instead we compose a list of all shadows and then efficiently kill them off :)
$sql = 'SELECT topic_id $sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_shadow_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('topic_shadow_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$shadow_topic_ids[] = $row['topic_id']; $shadow_topic_ids[] = $row['topic_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// recursion, the other white meat. // recursion, the other white meat.
if (sizeof($shadow_topic_ids)) if (sizeof($shadow_topic_ids))
@ -509,7 +508,7 @@ class posting_api
} }
// goodnight, moon // goodnight, moon
$db->transaction('commit'); phpbb::$db->transaction('commit');
} }
static function delete_post($data) static function delete_post($data)
@ -521,20 +520,20 @@ class posting_api
static function delete_posts($data) static function delete_posts($data)
{ {
// lets get this party started // lets get this party started
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$post_ids = array_map('intval', $data['post_ids']); $post_ids = array_map('intval', $data['post_ids']);
$sql = 'SELECT topic_id, post_status, post_id, post_shadow_id, forum_id $sql = 'SELECT topic_id, post_status, post_id, post_shadow_id, forum_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('post_id', $post_ids); WHERE ' . phpbb::$db->sql_in_set('post_id', $post_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
// the following arrays are designed to allow for much faster updates // the following arrays are designed to allow for much faster updates
$topic_lookup = array(); $topic_lookup = array();
$forum_lookup = array(); $forum_lookup = array();
while ($post_row = $db->sql_fetchrow($result)) while ($post_row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_id = (int) $post_row['topic_id']; $topic_id = (int) $post_row['topic_id'];
$forum_id = (int) $post_row['forum_id']; $forum_id = (int) $post_row['forum_id'];
@ -550,25 +549,25 @@ class posting_api
$forum_lookup[$topic_id]['forum_deleted_posts'] += ($post_status & self::DELETED); $forum_lookup[$topic_id]['forum_deleted_posts'] += ($post_status & self::DELETED);
$forum_lookup[$topic_id]['forum_unapproved_posts'] += ($post_status & self::UNAPPROVED); $forum_lookup[$topic_id]['forum_unapproved_posts'] += ($post_status & self::UNAPPROVED);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$topic_ids = array_keys($forum_lookup); $topic_ids = array_keys($forum_lookup);
// goodnight, posts // goodnight, posts
$db->sql_query('DELETE FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); phpbb::$db->sql_query('DELETE FROM ' . POSTS_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids));
// mangle the forums table // mangle the forums table
$sql = 'SELECT forum_posts, forum_shadow_posts, forum_deleted_posts, forum_unapproved_posts, forum_id $sql = 'SELECT forum_posts, forum_shadow_posts, forum_deleted_posts, forum_unapproved_posts, forum_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $forum_id; WHERE forum_id = ' . $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_rows = array(); $forum_rows = array();
while ($forum_row = $db->sql_fetchrow($result)) while ($forum_row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_id = (int) $forum_row['forum_id']; $forum_id = (int) $forum_row['forum_id'];
$forum_rows[$forum_id] = $forum_row; $forum_rows[$forum_id] = $forum_row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$shadow_topic_ids = array(); $shadow_topic_ids = array();
foreach ($forum_rows as $forum_id => $forum_row) foreach ($forum_rows as $forum_id => $forum_row)
@ -586,9 +585,9 @@ class posting_api
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_status = ' . self::NORMAL . ' WHERE post_status = ' . self::NORMAL . '
AND forum_id = ' . $forum_id; AND forum_id = ' . $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// anything left? // anything left?
if ($row) if ($row)
@ -597,9 +596,9 @@ class posting_api
$sql = 'SELECT post_username, poster_id, post_subject, post_time $sql = 'SELECT post_username, poster_id, post_subject, post_time
FROM '. POSTS_TABLE . ' FROM '. POSTS_TABLE . '
WHERE post_id = ' . (int) $row['max_post_id']; WHERE post_id = ' . (int) $row['max_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$last_post = $db->sql_fetchrow($result); $last_post = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$forum_array['forum_last_user_id'] = (int) $last_post['poster_id']; $forum_array['forum_last_user_id'] = (int) $last_post['poster_id'];
$forum_array['forum_last_poster_name'] = $last_post['post_username']; $forum_array['forum_last_poster_name'] = $last_post['post_username'];
@ -615,21 +614,21 @@ class posting_api
$forum_array['forum_last_post_time'] = 0; $forum_array['forum_last_post_time'] = 0;
} }
$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_array, "forum_id = $forum_id"); phpbb::$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_array, "forum_id = $forum_id");
} }
// mangle the topics table now :) // mangle the topics table now :)
$sql = 'SELECT topic_posts, topic_shadow_posts, topic_deleted_posts, topic_unapproved_posts, topic_id $sql = 'SELECT topic_posts, topic_shadow_posts, topic_deleted_posts, topic_unapproved_posts, topic_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . $forum_id; WHERE forum_id = ' . $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_rows = array(); $topic_rows = array();
while ($topic_row = $db->sql_fetchrow($result)) while ($topic_row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_id = (int) $topic_row['topic_id']; $topic_id = (int) $topic_row['topic_id'];
$topic_rows[$topic_id] = $topic_row; $topic_rows[$topic_id] = $topic_row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$empty_topic_ids = array(); $empty_topic_ids = array();
@ -648,9 +647,9 @@ class posting_api
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_status = ' . self::NORMAL . ' WHERE post_status = ' . self::NORMAL . '
AND topic_id = ' . $topic_id; AND topic_id = ' . $topic_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// anything left? // anything left?
if ($row) if ($row)
@ -659,9 +658,9 @@ class posting_api
$sql = 'SELECT post_username, poster_id, post_subject, post_time $sql = 'SELECT post_username, poster_id, post_subject, post_time
FROM '. POSTS_TABLE . ' FROM '. POSTS_TABLE . '
WHERE post_id = ' . (int) $row['max_post_id']; WHERE post_id = ' . (int) $row['max_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$last_post = $db->sql_fetchrow($result); $last_post = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$topic_array['topic_last_user_id'] = (int) $last_post['poster_id']; $topic_array['topic_last_user_id'] = (int) $last_post['poster_id'];
$topic_array['topic_last_poster_name'] = $last_post['post_username']; $topic_array['topic_last_poster_name'] = $last_post['post_username'];
@ -674,7 +673,7 @@ class posting_api
$empty_topic_ids[] = $topic_id; $empty_topic_ids[] = $topic_id;
} }
$db->sql_handle_data('UPDATE', TOPICS_TABLE, $topic_array, "topic_id = $topic_id"); phpbb::$db->sql_handle_data('UPDATE', TOPICS_TABLE, $topic_array, "topic_id = $topic_id");
} }
$shadow_post_ids = array(); $shadow_post_ids = array();
@ -683,15 +682,15 @@ class posting_api
// instead we compose a list of all shadows and then efficiently kill them off :) // instead we compose a list of all shadows and then efficiently kill them off :)
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('post_shadow_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('post_shadow_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$shadow_post_ids[] = $row['post_id']; $shadow_post_ids[] = $row['post_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// recursion, the other white meat. // recursion, the other white meat.
if (sizeof($shadow_topic_ids)) if (sizeof($shadow_topic_ids))
@ -706,7 +705,7 @@ class posting_api
} }
// goodnight, moon // goodnight, moon
$db->transaction('commit'); phpbb::$db->transaction('commit');
} }
static function move_topic($data) static function move_topic($data)
@ -717,7 +716,7 @@ class posting_api
static function move_topics($data) static function move_topics($data)
{ {
// lets get this party started // lets get this party started
$db->transaction('begin'); phpbb::$db->transaction('begin');
// all of each are indexed by topic id // all of each are indexed by topic id
$to_forum_ids = $shadow_topic_ids = array(); $to_forum_ids = $shadow_topic_ids = array();
@ -739,10 +738,10 @@ class posting_api
// let us first determine how many items we are removing from the pool // let us first determine how many items we are removing from the pool
$sql = 'SELECT topic_posts, topic_shadow_posts, topic_deleted_posts, topic_unapproved_posts, forum_id, topic_status, topic_type, topic_shadow_id, topic_id $sql = 'SELECT topic_posts, topic_shadow_posts, topic_deleted_posts, topic_unapproved_posts, forum_id, topic_status, topic_type, topic_shadow_id, topic_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_lookup = array(); $forum_lookup = array();
while ($topic_row = $db->sql_fetchrow($result)) while ($topic_row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_id = $topic_row['topic_id']; $topic_id = $topic_row['topic_id'];
$from_forum_id = (int) $topic_row['forum_id']; $from_forum_id = (int) $topic_row['forum_id'];
@ -757,15 +756,15 @@ class posting_api
$forum_lookup[$to_forum_id][$column] += $topic_row['topic_posts']; $forum_lookup[$to_forum_id][$column] += $topic_row['topic_posts'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// determine the totals // determine the totals
$sql = 'SELECT forum_posts, forum_shadow_posts, forum_deleted_posts, forum_unapproved_posts, forum_id, forum_topics, forum_deleted_topics, forum_unapproved_topics $sql = 'SELECT forum_posts, forum_shadow_posts, forum_deleted_posts, forum_unapproved_posts, forum_id, forum_topics, forum_deleted_topics, forum_unapproved_topics
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', array_keys($forum_lookup)); WHERE ' . phpbb::$db->sql_in_set('forum_id', array_keys($forum_lookup));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_id = (int) $row['forum_id']; $forum_id = (int) $row['forum_id'];
@ -787,10 +786,10 @@ class posting_api
foreach ($update_list as $forum_id => $topic_ids) foreach ($update_list as $forum_id => $topic_ids)
{ {
// update the topic itself // update the topic itself
$db->sql_handle_data('UPDATE', TOPICS_TABLE, array('forum_id' => $to_forum_id), $db->sql_in_set('topic_id', $topic_ids)); phpbb::$db->sql_handle_data('UPDATE', TOPICS_TABLE, array('forum_id' => $to_forum_id), phpbb::$db->sql_in_set('topic_id', $topic_ids));
// update the posts now // update the posts now
$db->sql_handle_data('UPDATE', POSTS_TABLE, array('forum_id' => $to_forum_id), $db->sql_in_set('topic_id', $topic_ids)); phpbb::$db->sql_handle_data('UPDATE', POSTS_TABLE, array('forum_id' => $to_forum_id), phpbb::$db->sql_in_set('topic_id', $topic_ids));
} }
// start building the needed arrays for updating the forum data // start building the needed arrays for updating the forum data
@ -806,9 +805,9 @@ class posting_api
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_status = ' . self::NORMAL . ' WHERE post_status = ' . self::NORMAL . '
AND forum_id = ' . $forum_id; AND forum_id = ' . $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// anything left? // anything left?
if ($row) if ($row)
@ -817,9 +816,9 @@ class posting_api
$sql = 'SELECT post_username, poster_id, post_subject, post_time $sql = 'SELECT post_username, poster_id, post_subject, post_time
FROM '. POSTS_TABLE . ' FROM '. POSTS_TABLE . '
WHERE post_id = ' . (int) $row['max_post_id']; WHERE post_id = ' . (int) $row['max_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$last_post = $db->sql_fetchrow($result); $last_post = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$forum_data['forum_last_user_id'] = (int) $last_post['poster_id']; $forum_data['forum_last_user_id'] = (int) $last_post['poster_id'];
$forum_data['forum_last_poster_name'] = $last_post['post_username']; $forum_data['forum_last_poster_name'] = $last_post['post_username'];
@ -836,7 +835,7 @@ class posting_api
} }
// update the old forum // update the old forum
$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id"); phpbb::$db->sql_handle_data('UPDATE', FORUMS_TABLE, $forum_data, "forum_id = $forum_id");
} }
// hooray for code reuse! // hooray for code reuse!
@ -847,7 +846,7 @@ class posting_api
self::insert_shadow_topic($data); self::insert_shadow_topic($data);
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
} }
} }

View file

@ -95,19 +95,19 @@ echo 'done';
function add_bots($bots) function add_bots($bots)
{ {
$sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_id = (int) $db->sql_fetchfield('group_id', $result); $group_id = (int) phpbb::$db->sql_fetchfield('group_id', $result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$db->sql_query('TRUNCATE TABLE ' . BOTS_TABLE); phpbb::$db->sql_query('TRUNCATE TABLE ' . BOTS_TABLE);
if (!$group_id) if (!$group_id)
{ {
add_default_groups(); add_default_groups();
$sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_id = (int) $db->sql_fetchfield('group_id', $result); $group_id = (int) phpbb::$db->sql_fetchfield('group_id', $result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
@ -134,14 +134,14 @@ function add_bots($bots)
if ($user_id) if ($user_id)
{ {
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'bot_active' => 1, 'bot_active' => 1,
'bot_name' => $bot_name, 'bot_name' => $bot_name,
'user_id' => $user_id, 'user_id' => $user_id,
'bot_agent' => $bot_ary[0], 'bot_agent' => $bot_ary[0],
'bot_ip' => $bot_ary[1]) 'bot_ip' => $bot_ary[1])
); );
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
} }

View file

@ -56,13 +56,13 @@ print "<html>\n<body>\n";
// //
$sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id
FROM ". POSTS_TABLE; FROM ". POSTS_TABLE;
if ( !($result = $db->sql_query($sql)) ) if ( !($result = phpbb::$db->sql_query($sql)) )
{ {
$error = $db->sql_error(); $error = phpbb::$db->sql_error();
die("Couldn't get maximum post ID :: " . $sql . " :: " . $error['message']); die("Couldn't get maximum post ID :: " . $sql . " :: " . $error['message']);
} }
$max_post_id = $db->sql_fetchrow($result); $max_post_id = phpbb::$db->sql_fetchrow($result);
$totalposts = $max_post_id['total']; $totalposts = $max_post_id['total'];
$max_post_id = $max_post_id['max_post_id']; $max_post_id = $max_post_id['max_post_id'];
@ -82,14 +82,14 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
WHERE post_id WHERE post_id
BETWEEN $batchstart BETWEEN $batchstart
AND $batchend"; AND $batchend";
if( !($result = $db->sql_query($sql)) ) if( !($result = phpbb::$db->sql_query($sql)) )
{ {
$error = $db->sql_error(); $error = phpbb::$db->sql_error();
die("Couldn't get post_text :: " . $sql . " :: " . $error['message']); die("Couldn't get post_text :: " . $sql . " :: " . $error['message']);
} }
$rowset = $db->sql_fetchrowset($result); $rowset = phpbb::$db->sql_fetchrowset($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$post_rows = sizeof($rowset); $post_rows = sizeof($rowset);
@ -97,7 +97,7 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
{ {
// $sql = "LOCK TABLES ".POST_TEXT_TABLE." WRITE"; // $sql = "LOCK TABLES ".POST_TEXT_TABLE." WRITE";
// $result = $db->sql_query($sql); // $result = phpbb::$db->sql_query($sql);
print "\n<p>\n<a href='{$_SERVER['PHP_SELF']}?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n"; print "\n<p>\n<a href='{$_SERVER['PHP_SELF']}?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n";
// For every post in the batch: // For every post in the batch:
@ -111,7 +111,7 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
$search->index('post', $rowset[$post_nr]['post_id'], $rowset[$post_nr]['post_text'], $rowset[$post_nr]['post_subject'], $rowset[$post_nr]['poster_id']); $search->index('post', $rowset[$post_nr]['post_id'], $rowset[$post_nr]['post_text'], $rowset[$post_nr]['post_subject'], $rowset[$post_nr]['poster_id']);
} }
// $sql = "UNLOCK TABLES"; // $sql = "UNLOCK TABLES";
// $result = $db->sql_query($sql); // $result = phpbb::$db->sql_query($sql);
} }
} }

View file

@ -105,8 +105,8 @@ if (!phpbb::$config['allow_attachments'] && !phpbb::$config['allow_pm_attach'])
$sql = 'SELECT attach_id, in_message, post_msg_id, extension, is_orphan, poster_id, filetime $sql = 'SELECT attach_id, in_message, post_msg_id, extension, is_orphan, poster_id, filetime
FROM ' . ATTACHMENTS_TABLE . " FROM ' . ATTACHMENTS_TABLE . "
WHERE attach_id = $download_id"; WHERE attach_id = $download_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$attachment = $db->sql_fetchrow($result); $attachment = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$attachment) if (!$attachment)
@ -143,9 +143,9 @@ else
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
WHERE p.post_id = ' . $attachment['post_msg_id'] . ' WHERE p.post_id = ' . $attachment['post_msg_id'] . '
AND p.forum_id = f.forum_id'; AND p.forum_id = f.forum_id';
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Global announcement? // Global announcement?
$f_download = (!$row) ? phpbb::$acl->acl_getf_global('f_download') : phpbb::$acl->acl_get('f_download', $row['forum_id']); $f_download = (!$row) ? phpbb::$acl->acl_getf_global('f_download') : phpbb::$acl->acl_get('f_download', $row['forum_id']);
@ -176,10 +176,10 @@ else
$sql = 'SELECT user_id, author_id $sql = 'SELECT user_id, author_id
FROM ' . PRIVMSGS_TO_TABLE . ' FROM ' . PRIVMSGS_TO_TABLE . '
WHERE msg_id = ' . $attachment['post_msg_id']; WHERE msg_id = ' . $attachment['post_msg_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$allowed = false; $allowed = false;
while ($user_row = $db->sql_fetchrow($result)) while ($user_row = phpbb::$db->sql_fetchrow($result))
{ {
if (phpbb::$user->data['user_id'] == $user_row['user_id'] || phpbb::$user->data['user_id'] == $user_row['author_id']) if (phpbb::$user->data['user_id'] == $user_row['user_id'] || phpbb::$user->data['user_id'] == $user_row['author_id'])
{ {
@ -187,7 +187,7 @@ else
break; break;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$allowed) if (!$allowed)
{ {
@ -216,8 +216,8 @@ $download_mode = (int) $extensions[$attachment['extension']]['download_mode'];
$sql = 'SELECT attach_id, is_orphan, in_message, post_msg_id, extension, physical_filename, real_filename, mimetype, filetime $sql = 'SELECT attach_id, is_orphan, in_message, post_msg_id, extension, physical_filename, real_filename, mimetype, filetime
FROM ' . ATTACHMENTS_TABLE . " FROM ' . ATTACHMENTS_TABLE . "
WHERE attach_id = $download_id"; WHERE attach_id = $download_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$attachment = $db->sql_fetchrow($result); $attachment = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$attachment) if (!$attachment)
@ -248,7 +248,7 @@ else if (($display_cat == ATTACHMENT_CATEGORY_NONE || $display_cat == ATTACHMENT
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
SET download_count = download_count + 1 SET download_count = download_count + 1
WHERE attach_id = ' . $attachment['attach_id']; WHERE attach_id = ' . $attachment['attach_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && ((strpos(strtolower(phpbb::$user->system['browser']), 'msie') !== false) && (strpos(strtolower(phpbb::$user->system['browser']), 'msie 8.0') === false))) if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && ((strpos(strtolower(phpbb::$user->system['browser']), 'msie') !== false) && (strpos(strtolower(phpbb::$user->system['browser']), 'msie 8.0') === false)))
@ -460,7 +460,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
} }
// Close the db connection before sending the file // Close the db connection before sending the file
$db->sql_close(); phpbb::$db->sql_close();
if (!set_modified_headers($attachment['filetime'], phpbb::$user->system['browser'])) if (!set_modified_headers($attachment['filetime'], phpbb::$user->system['browser']))
{ {
@ -566,9 +566,9 @@ function download_allowed()
{ {
$sql = 'SELECT site_ip, site_hostname, ip_exclude $sql = 'SELECT site_ip, site_hostname, ip_exclude
FROM ' . SITELIST_TABLE; FROM ' . SITELIST_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$site_ip = trim($row['site_ip']); $site_ip = trim($row['site_ip']);
$site_hostname = trim($row['site_hostname']); $site_hostname = trim($row['site_hostname']);
@ -608,7 +608,7 @@ function download_allowed()
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
return $allowed; return $allowed;

View file

@ -295,11 +295,11 @@ class acm
$this->sql_rowset[$query_id] = array(); $this->sql_rowset[$query_id] = array();
$this->sql_row_pointer[$query_id] = 0; $this->sql_row_pointer[$query_id] = 0;
while ($row = $db->sql_fetchrow($query_result)) while ($row = phpbb::$db->sql_fetchrow($query_result))
{ {
$this->sql_rowset[$query_id][] = $row; $this->sql_rowset[$query_id][] = $row;
} }
$db->sql_freeresult($query_result); phpbb::$db->sql_freeresult($query_result);
apc_store('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl); apc_store('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);

View file

@ -273,11 +273,11 @@ class acm
$this->sql_rowset[$query_id] = array(); $this->sql_rowset[$query_id] = array();
$this->sql_row_pointer[$query_id] = 0; $this->sql_row_pointer[$query_id] = 0;
while ($row = $db->sql_fetchrow($query_result)) while ($row = phpbb::$db->sql_fetchrow($query_result))
{ {
$this->sql_rowset[$query_id][] = $row; $this->sql_rowset[$query_id][] = $row;
} }
$db->sql_freeresult($query_result); phpbb::$db->sql_freeresult($query_result);
eaccelerator_put('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl); eaccelerator_put('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);

View file

@ -299,11 +299,11 @@ class acm
$this->sql_rowset[$query_id] = array(); $this->sql_rowset[$query_id] = array();
$this->sql_row_pointer[$query_id] = 0; $this->sql_row_pointer[$query_id] = 0;
while ($row = $db->sql_fetchrow($query_result)) while ($row = phpbb::$db->sql_fetchrow($query_result))
{ {
$this->sql_rowset[$query_id][] = $row; $this->sql_rowset[$query_id][] = $row;
} }
$db->sql_freeresult($query_result); phpbb::$db->sql_freeresult($query_result);
memcache_set($this->memcache, 'sql_' . md5($query), $this->sql_rowset[$query_id], 0, $ttl); memcache_set($this->memcache, 'sql_' . md5($query), $this->sql_rowset[$query_id], 0, $ttl);

View file

@ -257,11 +257,11 @@ class acm
$this->sql_rowset[$query_id] = array(); $this->sql_rowset[$query_id] = array();
$this->sql_row_pointer[$query_id] = 0; $this->sql_row_pointer[$query_id] = 0;
while ($row = $db->sql_fetchrow($query_result)) while ($row = phpbb::$db->sql_fetchrow($query_result))
{ {
$this->sql_rowset[$query_id][] = $row; $this->sql_rowset[$query_id][] = $row;
} }
$db->sql_freeresult($query_result); phpbb::$db->sql_freeresult($query_result);
xcache_set('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl); xcache_set('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);

View file

@ -84,10 +84,10 @@ function login_apache(&$username, &$password)
$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE username = '" . $db->sql_escape($php_auth_user) . "'"; WHERE username = '" . phpbb::$db->sql_escape($php_auth_user) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -147,10 +147,10 @@ function autologin_apache()
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE username = '" . $db->sql_escape($php_auth_user) . "'"; WHERE username = '" . phpbb::$db->sql_escape($php_auth_user) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -167,10 +167,10 @@ function autologin_apache()
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($php_auth_user)) . "'"; WHERE username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($php_auth_user)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -189,11 +189,11 @@ function user_row_apache($username, $password)
// first retrieve default group id // first retrieve default group id
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_name_clean = '" . $db->sql_escape('registered') . "' WHERE group_name_clean = '" . phpbb::$db->sql_escape('registered') . "'
AND group_type = " . GROUP_SPECIAL; AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {

View file

@ -173,10 +173,10 @@ function login_ldap(&$username, &$password)
$sql ='SELECT user_id, username, user_password, user_passchg, user_email, user_type $sql ='SELECT user_id, username, user_password, user_passchg, user_email, user_type
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; WHERE username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -204,11 +204,11 @@ function login_ldap(&$username, &$password)
// retrieve default group id // retrieve default group id
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_name_clean = '" . $db->sql_escape('registered') . "' WHERE group_name_clean = '" . phpbb::$db->sql_escape('registered') . "'
AND group_type = " . GROUP_SPECIAL; AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {

View file

@ -163,10 +163,10 @@ class bbcode
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
WHERE ' . $db->sql_in_set('bbcode_id', $sql); WHERE ' . phpbb::$db->sql_in_set('bbcode_id', $sql);
$result = $db->sql_query($sql, 3600); $result = phpbb::$db->sql_query($sql, 3600);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// To circumvent replacing newlines with <br /> for the generated html, // To circumvent replacing newlines with <br /> for the generated html,
// we use carriage returns here. They are later changed back to newlines // we use carriage returns here. They are later changed back to newlines
@ -175,7 +175,7 @@ class bbcode
$rowset[$row['bbcode_id']] = $row; $rowset[$row['bbcode_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($bbcode_ids as $bbcode_id) foreach ($bbcode_ids as $bbcode_id)

View file

@ -118,25 +118,25 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
WHERE s.session_id IS NULL' . WHERE s.session_id IS NULL' .
((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type); ((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$sql_in = array(); $sql_in = array();
do do
{ {
$sql_in[] = (string) $row['session_id']; $sql_in[] = (string) $row['session_id'];
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
if (sizeof($sql_in)) if (sizeof($sql_in))
{ {
$sql = 'DELETE FROM ' . CONFIRM_TABLE . ' $sql = 'DELETE FROM ' . CONFIRM_TABLE . '
WHERE ' . $db->sql_in_set('session_id', $sql_in); WHERE ' . phpbb::$db->sql_in_set('session_id', $sql_in);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
function uninstall() function uninstall()
@ -195,14 +195,14 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
// compute $seed % 0x7fffffff // compute $seed % 0x7fffffff
$this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff); $this->seed -= 0x7fffffff * floor($this->seed / 0x7fffffff);
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'confirm_id' => (string) $this->confirm_id, 'confirm_id' => (string) $this->confirm_id,
'session_id' => (string) phpbb::$user->session_id, 'session_id' => (string) phpbb::$user->session_id,
'confirm_type' => (int) $this->type, 'confirm_type' => (int) $this->type,
'code' => (string) $this->code, 'code' => (string) $this->code,
'seed' => (int) $this->seed) 'seed' => (int) $this->seed)
); );
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
/** /**
@ -212,12 +212,12 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
{ {
$sql = 'SELECT code, seed $sql = 'SELECT code, seed
FROM ' . CONFIRM_TABLE . " FROM ' . CONFIRM_TABLE . "
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' WHERE confirm_id = '" . phpbb::$db->sql_escape($this->confirm_id) . "'
AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "' AND session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type; AND confirm_type = " . $this->type;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
$this->code = $row['code']; $this->code = $row['code'];
@ -243,21 +243,21 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
protected function delete_code() protected function delete_code()
{ {
$sql = 'DELETE FROM ' . CONFIRM_TABLE . " $sql = 'DELETE FROM ' . CONFIRM_TABLE . "
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "' WHERE confirm_id = '" . phpbb::$db->sql_escape($this->confirm_id) . "'
AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "' AND session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type; AND confirm_type = " . $this->type;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
function get_attempt_count() function get_attempt_count()
{ {
$sql = 'SELECT COUNT(session_id) AS attempts $sql = 'SELECT COUNT(session_id) AS attempts
FROM ' . CONFIRM_TABLE . " FROM ' . CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "' WHERE session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type; AND confirm_type = " . $this->type;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$attempts = (int) $db->sql_fetchfield('attempts'); $attempts = (int) phpbb::$db->sql_fetchfield('attempts');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return $attempts; return $attempts;
} }
@ -266,9 +266,9 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function reset() function reset()
{ {
$sql = 'DELETE FROM ' . CONFIRM_TABLE . " $sql = 'DELETE FROM ' . CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "' WHERE session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . (int) $this->type; AND confirm_type = " . (int) $this->type;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// we leave the class usable by generating a new question // we leave the class usable by generating a new question
$this->generate_code(); $this->generate_code();

View file

@ -364,7 +364,7 @@ abstract class phpbb_dbal
if ($type === 'UPDATE') if ($type === 'UPDATE')
{ {
$where = ($where) ? ' WHERE ' . $where : ''; $where = ($where) ? ' WHERE ' . $where : '';
$this->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', $data) . $where); $this->sql_query('UPDATE ' . $table . ' SET ' . $this->sql_build_array('UPDATE', $data) . $where);
} }
else else
{ {

View file

@ -150,9 +150,9 @@ class formatted_text
{ {
$this->changed = false; $this->changed = false;
$sql = 'UPDATE ' . $table . ' SET ' . $db->sql_build_query('UPDATE', $this->to_db_data($column)) $sql = 'UPDATE ' . $table . ' SET ' . phpbb::$db->sql_build_query('UPDATE', $this->to_db_data($column))
. ' WHERE ' . $where; . ' WHERE ' . $where;
return (bool) $db->sql_query($sql); return (bool) phpbb::$db->sql_query($sql);
} }
/** /**

File diff suppressed because it is too large Load diff

View file

@ -79,7 +79,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
{ {
$sql_array['LEFT_JOIN'][] = array( $sql_array['LEFT_JOIN'][] = array(
'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'),
'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'" 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'"
); );
$sql_array['SELECT'] .= ', fa.user_id'; $sql_array['SELECT'] .= ', fa.user_id';
@ -573,20 +573,20 @@ function get_forum_parents(&$forum_data)
WHERE left_id < ' . $forum_data['left_id'] . ' WHERE left_id < ' . $forum_data['left_id'] . '
AND right_id > ' . $forum_data['right_id'] . ' AND right_id > ' . $forum_data['right_id'] . '
ORDER BY left_id ASC'; ORDER BY left_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']); $forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$forum_data['forum_parents'] = serialize($forum_parents); $forum_data['forum_parents'] = serialize($forum_parents);
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "' SET forum_parents = '" . phpbb::$db->sql_escape($forum_data['forum_parents']) . "'
WHERE parent_id = " . $forum_data['parent_id']; WHERE parent_id = " . $forum_data['parent_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
@ -833,10 +833,10 @@ function display_custom_bbcodes()
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
WHERE display_on_posting = 1 WHERE display_on_posting = 1
ORDER BY bbcode_tag'; ORDER BY bbcode_tag';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$i = 0; $i = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('custom_tags', array( $template->assign_block_vars('custom_tags', array(
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'", 'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
@ -848,7 +848,7 @@ function display_custom_bbcodes()
$i++; $i++;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -859,9 +859,9 @@ function display_reasons($reason_id = 0)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . REPORTS_REASONS_TABLE . ' FROM ' . REPORTS_REASONS_TABLE . '
ORDER BY reason_order ASC'; ORDER BY reason_order ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// If the reason is defined within the language file, we will use the localized version, else just use the database entry... // If the reason is defined within the language file, we will use the localized version, else just use the database entry...
if (isset(phpbb::$user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset(phpbb::$user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) if (isset(phpbb::$user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset(phpbb::$user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
@ -877,7 +877,7 @@ function display_reasons($reason_id = 0)
'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false) 'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false)
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -905,7 +905,7 @@ function display_user_activity(&$userdata)
} }
$forum_ary = array_unique($forum_ary); $forum_ary = array_unique($forum_ary);
$forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : ''; $forum_sql = (sizeof($forum_ary)) ? 'AND ' . phpbb::$db->sql_in_set('forum_id', $forum_ary, true) : '';
// Obtain active forum // Obtain active forum
$sql = 'SELECT forum_id, COUNT(post_id) AS num_posts $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts
@ -915,18 +915,18 @@ function display_user_activity(&$userdata)
$forum_sql $forum_sql
GROUP BY forum_id GROUP BY forum_id
ORDER BY num_posts DESC"; ORDER BY num_posts DESC";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$active_f_row = $db->sql_fetchrow($result); $active_f_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!empty($active_f_row)) if (!empty($active_f_row))
{ {
$sql = 'SELECT forum_name $sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $active_f_row['forum_id']; WHERE forum_id = ' . $active_f_row['forum_id'];
$result = $db->sql_query($sql, 3600); $result = phpbb::$db->sql_query($sql, 3600);
$active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); $active_f_row['forum_name'] = (string) phpbb::$db->sql_fetchfield('forum_name');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Obtain active topic // Obtain active topic
@ -937,18 +937,18 @@ function display_user_activity(&$userdata)
$forum_sql $forum_sql
GROUP BY topic_id GROUP BY topic_id
ORDER BY num_posts DESC"; ORDER BY num_posts DESC";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$active_t_row = $db->sql_fetchrow($result); $active_t_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!empty($active_t_row)) if (!empty($active_t_row))
{ {
$sql = 'SELECT topic_title $sql = 'SELECT topic_title
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $active_t_row['topic_id']; WHERE topic_id = ' . $active_t_row['topic_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); $active_t_row['topic_title'] = (string) phpbb::$db->sql_fetchfield('topic_title');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$userdata['active_t_row'] = $active_t_row; $userdata['active_t_row'] = $active_t_row;
@ -1011,10 +1011,10 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
FROM $table_sql FROM $table_sql
WHERE $where_sql = $match_id WHERE $where_sql = $match_id
AND user_id = $user_id"; AND user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL; $notify_status = ($row = phpbb::$db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!is_null($notify_status) && $notify_status !== '') if (!is_null($notify_status) && $notify_status !== '')
@ -1036,7 +1036,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
$sql = 'DELETE FROM ' . $table_sql . " $sql = 'DELETE FROM ' . $table_sql . "
WHERE $where_sql = $match_id WHERE $where_sql = $match_id
AND user_id = $user_id"; AND user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$redirect_url = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&amp;start=$start"); $redirect_url = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&amp;start=$start");
@ -1056,7 +1056,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
SET notify_status = 0 SET notify_status = 0
WHERE $where_sql = $match_id WHERE $where_sql = $match_id
AND user_id = $user_id"; AND user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
} }
@ -1073,7 +1073,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status) $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
VALUES ($user_id, $match_id, 0)"; VALUES ($user_id, $match_id, 0)";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$message = phpbb::$user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>'); $message = phpbb::$user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
} }
else else

View file

@ -28,9 +28,9 @@ function generate_smilies($mode, $forum_id)
$sql = 'SELECT forum_style $sql = 'SELECT forum_style
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
phpbb::$user->setup('posting', (int) $row['forum_style']); phpbb::$user->setup('posting', (int) $row['forum_style']);
} }
@ -52,13 +52,13 @@ function generate_smilies($mode, $forum_id)
$sql = 'SELECT smiley_id $sql = 'SELECT smiley_id
FROM ' . SMILIES_TABLE . ' FROM ' . SMILIES_TABLE . '
WHERE display_on_posting = 0'; WHERE display_on_posting = 0';
$result = $db->sql_query_limit($sql, 1, 0, 3600); $result = phpbb::$db->sql_query_limit($sql, 1, 0, 3600);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$display_link = true; $display_link = true;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$last_url = ''; $last_url = '';
@ -67,17 +67,17 @@ function generate_smilies($mode, $forum_id)
FROM ' . SMILIES_TABLE . FROM ' . SMILIES_TABLE .
(($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . ' (($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . '
ORDER BY smiley_order'; ORDER BY smiley_order';
$result = $db->sql_query($sql, 3600); $result = phpbb::$db->sql_query($sql, 3600);
$smilies = array(); $smilies = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (empty($smilies[$row['smiley_url']])) if (empty($smilies[$row['smiley_url']]))
{ {
$smilies[$row['smiley_url']] = $row; $smilies[$row['smiley_url']] = $row;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($smilies)) if (sizeof($smilies))
{ {
@ -145,7 +145,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
{ {
$sql = 'SELECT MAX(p.post_id) as last_post_id $sql = 'SELECT MAX(p.post_id) as last_post_id
FROM ' . POSTS_TABLE . " p $topic_join FROM ' . POSTS_TABLE . " p $topic_join
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " WHERE " . phpbb::$db->sql_in_set('p.' . $type . '_id', $ids) . "
$topic_condition $topic_condition
AND p.post_approved = 1"; AND p.post_approved = 1";
} }
@ -153,15 +153,15 @@ function update_post_information($type, $ids, $return_update_sql = false)
{ {
$sql = 'SELECT p.' . $type . '_id, MAX(p.post_id) as last_post_id $sql = 'SELECT p.' . $type . '_id, MAX(p.post_id) as last_post_id
FROM ' . POSTS_TABLE . " p $topic_join FROM ' . POSTS_TABLE . " p $topic_join
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " WHERE " . phpbb::$db->sql_in_set('p.' . $type . '_id', $ids) . "
$topic_condition $topic_condition
AND p.post_approved = 1 AND p.post_approved = 1
GROUP BY p.{$type}_id"; GROUP BY p.{$type}_id";
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$last_post_ids = array(); $last_post_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (sizeof($ids) == 1) if (sizeof($ids) == 1)
{ {
@ -180,7 +180,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
$last_post_ids[] = $row['last_post_id']; $last_post_ids[] = $row['last_post_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($type == 'forum') if ($type == 'forum')
{ {
@ -202,19 +202,19 @@ function update_post_information($type, $ids, $return_update_sql = false)
$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour $sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id WHERE p.poster_id = u.user_id
AND ' . $db->sql_in_set('p.post_id', $last_post_ids); AND ' . phpbb::$db->sql_in_set('p.post_id', $last_post_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id']; $update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id'];
$update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . phpbb::$db->sql_escape($row['post_subject']) . "'";
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time']; $update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time'];
$update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id']; $update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_colour = '" . phpbb::$db->sql_escape($row['user_colour']) . "'";
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? phpbb::$db->sql_escape($row['post_username']) : phpbb::$db->sql_escape($row['username'])) . "'";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
unset($empty_forums, $ids, $last_post_ids); unset($empty_forums, $ids, $last_post_ids);
@ -230,7 +230,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
$sql = "UPDATE $table $sql = "UPDATE $table
SET " . implode(', ', $update_sql_ary) . " SET " . implode(', ', $update_sql_ary) . "
WHERE {$type}_id = $update_id"; WHERE {$type}_id = $update_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
return; return;
@ -823,9 +823,9 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
WHERE d.user_id = ' . phpbb::$user->data['user_id'] . " WHERE d.user_id = ' . phpbb::$user->data['user_id'] . "
$sql_and $sql_and
ORDER BY d.save_time DESC"; ORDER BY d.save_time DESC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['topic_id']) if ($row['topic_id'])
{ {
@ -833,7 +833,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
} }
$draft_rows[] = $row; $draft_rows[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($draft_rows)) if (!sizeof($draft_rows))
{ {
@ -845,14 +845,14 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
{ {
$sql = 'SELECT topic_id, forum_id, topic_title $sql = 'SELECT topic_id, forum_id, topic_title
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids)); WHERE ' . phpbb::$db->sql_in_set('topic_id', array_unique($topic_ids));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_rows[$row['topic_id']] = $row; $topic_rows[$row['topic_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
unset($topic_ids); unset($topic_ids);
@ -924,23 +924,22 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . '
ORDER BY p.post_time '; ORDER BY p.post_time ';
$sql .= ($mode == 'post_review') ? 'ASC' : 'DESC'; $sql .= ($mode == 'post_review') ? 'ASC' : 'DESC';
$result = $db->sql_query_limit($sql, phpbb::$config['posts_per_page']); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['posts_per_page']);
$post_list = array(); $post_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_list[] = $row['post_id']; $post_list[] = $row['post_id'];
} }
phpbb::$db->sql_freeresult($result);
$db->sql_freeresult($result);
if (!sizeof($post_list)) if (!sizeof($post_list))
{ {
return false; return false;
} }
$sql = $db->sql_build_query('SELECT', array( $sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => 'u.username, u.user_id, u.user_colour, p.*', 'SELECT' => 'u.username, u.user_id, u.user_colour, p.*',
'FROM' => array( 'FROM' => array(
@ -948,16 +947,16 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
POSTS_TABLE => 'p', POSTS_TABLE => 'p',
), ),
'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' 'WHERE' => phpbb::$db->sql_in_set('p.post_id', $post_list) . '
AND u.user_id = p.poster_id' AND u.user_id = p.poster_id'
)); ));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$bbcode_bitfield = ''; $bbcode_bitfield = '';
$rowset = array(); $rowset = array();
$has_attachments = false; $has_attachments = false;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$rowset[$row['post_id']] = $row; $rowset[$row['post_id']] = $row;
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
@ -967,7 +966,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$has_attachments = true; $has_attachments = true;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Instantiate BBCode class // Instantiate BBCode class
if (!isset($bbcode) && $bbcode_bitfield !== '') if (!isset($bbcode) && $bbcode_bitfield !== '')
@ -985,16 +984,16 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
// Get attachments... // Get attachments...
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $post_list) . ' WHERE ' . phpbb::$db->sql_in_set('post_msg_id', $post_list) . '
AND in_message = 0 AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC'; ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[$row['post_msg_id']][] = $row; $attachments[$row['post_msg_id']][] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
@ -1105,14 +1104,14 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
FROM ' . BANLIST_TABLE . ' FROM ' . BANLIST_TABLE . '
WHERE ban_userid <> 0 WHERE ban_userid <> 0
AND ban_exclude <> 1'; AND ban_exclude <> 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$sql_ignore_users = ANONYMOUS . ', ' . phpbb::$user->data['user_id']; $sql_ignore_users = ANONYMOUS . ', ' . phpbb::$user->data['user_id'];
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$sql_ignore_users .= ', ' . (int) $row['ban_userid']; $sql_ignore_users .= ', ' . (int) $row['ban_userid'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$notify_rows = array(); $notify_rows = array();
@ -1124,9 +1123,9 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
AND w.notify_status = 0 AND w.notify_status = 0
AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ') AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
AND u.user_id = w.user_id'; AND u.user_id = w.user_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$notify_rows[$row['user_id']] = array( $notify_rows[$row['user_id']] = array(
'user_id' => $row['user_id'], 'user_id' => $row['user_id'],
@ -1140,7 +1139,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
'allowed' => false 'allowed' => false
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// forum notification is sent to those not already receiving topic notifications // forum notification is sent to those not already receiving topic notifications
if ($topic_notification) if ($topic_notification)
@ -1157,9 +1156,9 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
AND fw.notify_status = 0 AND fw.notify_status = 0
AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ') AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
AND u.user_id = fw.user_id'; AND u.user_id = fw.user_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$notify_rows[$row['user_id']] = array( $notify_rows[$row['user_id']] = array(
'user_id' => $row['user_id'], 'user_id' => $row['user_id'],
@ -1173,7 +1172,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
'allowed' => false 'allowed' => false
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!sizeof($notify_rows)) if (!sizeof($notify_rows))
@ -1260,15 +1259,15 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
} }
// Handle the DB updates // Handle the DB updates
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
if (!empty($update_notification['topic'])) if (!empty($update_notification['topic']))
{ {
$sql = 'UPDATE ' . TOPICS_WATCH_TABLE . " $sql = 'UPDATE ' . TOPICS_WATCH_TABLE . "
SET notify_status = 1 SET notify_status = 1
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
AND " . $db->sql_in_set('user_id', $update_notification['topic']); AND " . phpbb::$db->sql_in_set('user_id', $update_notification['topic']);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if (!empty($update_notification['forum'])) if (!empty($update_notification['forum']))
@ -1276,8 +1275,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
$sql = 'UPDATE ' . FORUMS_WATCH_TABLE . " $sql = 'UPDATE ' . FORUMS_WATCH_TABLE . "
SET notify_status = 1 SET notify_status = 1
WHERE forum_id = $forum_id WHERE forum_id = $forum_id
AND " . $db->sql_in_set('user_id', $update_notification['forum']); AND " . phpbb::$db->sql_in_set('user_id', $update_notification['forum']);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Now delete the user_ids not authorised to receive notifications on this topic/forum // Now delete the user_ids not authorised to receive notifications on this topic/forum
@ -1285,19 +1284,19 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
{ {
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . " $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
AND " . $db->sql_in_set('user_id', $delete_ids['topic']); AND " . phpbb::$db->sql_in_set('user_id', $delete_ids['topic']);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if (!empty($delete_ids['forum'])) if (!empty($delete_ids['forum']))
{ {
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . " $sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . "
WHERE forum_id = $forum_id WHERE forum_id = $forum_id
AND " . $db->sql_in_set('user_id', $delete_ids['forum']); AND " . phpbb::$db->sql_in_set('user_id', $delete_ids['forum']);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
} }
// //
@ -1328,7 +1327,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
include_once(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT);
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
// we must make sure to update forums that contain the shadow'd topic // we must make sure to update forums that contain the shadow'd topic
if ($post_mode == 'delete_topic') if ($post_mode == 'delete_topic')
@ -1337,9 +1336,9 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_id); WHERE ' . phpbb::$db->sql_in_set('topic_moved_id', $topic_id);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!isset($shadow_forum_ids[(int) $row['forum_id']])) if (!isset($shadow_forum_ids[(int) $row['forum_id']]))
{ {
@ -1350,7 +1349,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$shadow_forum_ids[(int) $row['forum_id']]++; $shadow_forum_ids[(int) $row['forum_id']]++;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!delete_posts('post_id', array($post_id), false, false)) if (!delete_posts('post_id', array($post_id), false, false))
@ -1363,7 +1362,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
trigger_error('ALREADY_DELETED'); trigger_error('ALREADY_DELETED');
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
// Collect the necessary information for updating the tables // Collect the necessary information for updating the tables
$sql_data[FORUMS_TABLE] = ''; $sql_data[FORUMS_TABLE] = '';
@ -1375,7 +1374,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
{ {
// counting is fun! we only have to do sizeof($forum_ids) number of queries, // counting is fun! we only have to do sizeof($forum_ids) number of queries,
// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum) // even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_topics_real = forum_topics_real - ' . $topic_count . ', forum_topics = forum_topics - ' . $topic_count . ' WHERE forum_id = ' . $updated_forum); phpbb::$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_topics_real = forum_topics_real - ' . $topic_count . ', forum_topics = forum_topics - ' . $topic_count . ' WHERE forum_id = ' . $updated_forum);
update_post_information('forum', $updated_forum); update_post_information('forum', $updated_forum);
} }
@ -1401,16 +1400,16 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
WHERE p.topic_id = $topic_id WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id AND p.poster_id = u.user_id
ORDER BY p.post_time ASC"; ORDER BY p.post_time ASC";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($data['topic_type'] != POST_GLOBAL) if ($data['topic_type'] != POST_GLOBAL)
{ {
$sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : '';
} }
$sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; $sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . phpbb::$db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? phpbb::$db->sql_escape($row['post_username']) : phpbb::$db->sql_escape($row['username'])) . "'";
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply" // Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); $sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
@ -1445,9 +1444,9 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE topic_id = $topic_id " . WHERE topic_id = $topic_id " .
((!phpbb::$acl->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : ''); ((!phpbb::$acl->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '');
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$next_post_id = (int) $row['last_post_id']; $next_post_id = (int) $row['last_post_id'];
} }
@ -1460,9 +1459,9 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
((!phpbb::$acl->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '') . ' ((!phpbb::$acl->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '') . '
AND post_time > ' . $data['post_time'] . ' AND post_time > ' . $data['post_time'] . '
ORDER BY post_time ASC'; ORDER BY post_time ASC';
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($data['topic_type'] != POST_GLOBAL) if ($data['topic_type'] != POST_GLOBAL)
{ {
@ -1476,7 +1475,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
// $sql_data[USERS_TABLE] = ($data['post_postcount']) ? 'user_posts = user_posts - 1' : ''; // $sql_data[USERS_TABLE] = ($data['post_postcount']) ? 'user_posts = user_posts - 1' : '';
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$where_sql = array( $where_sql = array(
FORUMS_TABLE => "forum_id = $forum_id", FORUMS_TABLE => "forum_id = $forum_id",
@ -1488,7 +1487,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
{ {
if ($update_sql) if ($update_sql)
{ {
$db->sql_query("UPDATE $table SET $update_sql WHERE " . $where_sql[$table]); phpbb::$db->sql_query("UPDATE $table SET $update_sql WHERE " . $where_sql[$table]);
} }
} }
@ -1499,9 +1498,9 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . $topic_id . ' WHERE topic_id = ' . $topic_id . '
AND poster_id = ' . $data['poster_id']; AND poster_id = ' . $data['poster_id'];
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$poster_id = (int) $db->sql_fetchfield('poster_id'); $poster_id = (int) phpbb::$db->sql_fetchfield('poster_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// The user is not having any more posts within this topic // The user is not having any more posts within this topic
if (!$poster_id) if (!$poster_id)
@ -1509,11 +1508,11 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . ' $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
WHERE topic_id = ' . $topic_id . ' WHERE topic_id = ' . $topic_id . '
AND user_id = ' . $data['poster_id']; AND user_id = ' . $data['poster_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
if ($data['post_reported'] && ($post_mode != 'delete_topic')) if ($data['post_reported'] && ($post_mode != 'delete_topic'))
{ {
@ -1567,9 +1566,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
WHERE t.topic_id = p.topic_id WHERE t.topic_id = p.topic_id
AND p.post_id = ' . $data['post_id']; AND p.post_id = ' . $data['post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_row = $db->sql_fetchrow($result); $topic_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$data['topic_approved'] = $topic_row['topic_approved']; $data['topic_approved'] = $topic_row['topic_approved'];
$data['post_approved'] = $topic_row['post_approved']; $data['post_approved'] = $topic_row['post_approved'];
@ -1585,7 +1584,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
} }
// Start the transaction here // Start the transaction here
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
// Collect Information // Collect Information
switch ($post_mode) switch ($post_mode)
@ -1769,9 +1768,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $data['topic_id']; WHERE topic_id = ' . $data['topic_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_row = $db->sql_fetchrow($result); $topic_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// If this is the only post remaining we do not need to decrement topic_replies. // If this is the only post remaining we do not need to decrement topic_replies.
@ -1817,10 +1816,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if ($post_mode == 'post') if ($post_mode == 'post')
{ {
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' .
$db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); phpbb::$db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$data['topic_id'] = $db->sql_nextid(); $data['topic_id'] = phpbb::$db->sql_nextid();
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
'topic_id' => $data['topic_id']) 'topic_id' => $data['topic_id'])
@ -1838,9 +1837,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
); );
} }
$sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$data['post_id'] = $db->sql_nextid(); $data['post_id'] = phpbb::$db->sql_nextid();
if ($post_mode == 'post') if ($post_mode == 'post')
{ {
@ -1868,9 +1867,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved, topic_last_post_id $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved, topic_last_post_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $data['topic_id']; WHERE topic_id = ' . $data['topic_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_row = $db->sql_fetchrow($result); $topic_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// globalise/unglobalise? // globalise/unglobalise?
@ -1878,7 +1877,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{ {
if (!empty($sql_data[FORUMS_TABLE]['stat']) && implode('', $sql_data[FORUMS_TABLE]['stat'])) if (!empty($sql_data[FORUMS_TABLE]['stat']) && implode('', $sql_data[FORUMS_TABLE]['stat']))
{ {
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $sql_data[FORUMS_TABLE]['stat']) . ' WHERE forum_id = ' . $data['forum_id']); phpbb::$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $sql_data[FORUMS_TABLE]['stat']) . ' WHERE forum_id = ' . $data['forum_id']);
} }
$make_global = true; $make_global = true;
@ -1896,7 +1895,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = 0 SET forum_id = 0
WHERE topic_id = ' . $data['topic_id']; WHERE topic_id = ' . $data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// unglobalise // unglobalise
else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL) else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL)
@ -1909,7 +1908,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = ' . $data['forum_id'] . ' SET forum_id = ' . $data['forum_id'] . '
WHERE topic_id = ' . $data['topic_id']; WHERE topic_id = ' . $data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1917,18 +1916,18 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if (isset($sql_data[TOPICS_TABLE]['sql'])) if (isset($sql_data[TOPICS_TABLE]['sql']))
{ {
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . '
WHERE topic_id = ' . $data['topic_id']; WHERE topic_id = ' . $data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Update the posts table // Update the posts table
if (isset($sql_data[POSTS_TABLE]['sql'])) if (isset($sql_data[POSTS_TABLE]['sql']))
{ {
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . '
WHERE post_id = ' . $data['post_id']; WHERE post_id = ' . $data['post_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Update Poll Tables // Update Poll Tables
@ -1942,14 +1941,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POLL_OPTIONS_TABLE . ' FROM ' . POLL_OPTIONS_TABLE . '
WHERE topic_id = ' . $data['topic_id'] . ' WHERE topic_id = ' . $data['topic_id'] . '
ORDER BY poll_option_id'; ORDER BY poll_option_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$cur_poll_options = array(); $cur_poll_options = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$cur_poll_options[] = $row; $cur_poll_options[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$sql_insert_ary = array(); $sql_insert_ary = array();
@ -1970,29 +1969,29 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
else if ($poll['poll_options'][$i] != $cur_poll_options[$i]) else if ($poll['poll_options'][$i] != $cur_poll_options[$i])
{ {
$sql = 'UPDATE ' . POLL_OPTIONS_TABLE . " $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . "
SET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "' SET poll_option_text = '" . phpbb::$db->sql_escape($poll['poll_options'][$i]) . "'
WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . ' WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . '
AND topic_id = ' . $data['topic_id']; AND topic_id = ' . $data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
} }
$db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary); phpbb::$db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary);
if (sizeof($poll['poll_options']) < sizeof($cur_poll_options)) if (sizeof($poll['poll_options']) < sizeof($cur_poll_options))
{ {
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . '
WHERE poll_option_id > ' . sizeof($poll['poll_options']) . ' WHERE poll_option_id > ' . sizeof($poll['poll_options']) . '
AND topic_id = ' . $data['topic_id']; AND topic_id = ' . $data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option // If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option
if ($mode == 'edit' && sizeof($poll['poll_options']) != sizeof($cur_poll_options)) if ($mode == 'edit' && sizeof($poll['poll_options']) != sizeof($cur_poll_options))
{ {
$db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data['topic_id']); phpbb::$db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data['topic_id']);
$db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data['topic_id']); phpbb::$db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data['topic_id']);
} }
} }
@ -2011,17 +2010,17 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{ {
$sql = 'SELECT attach_id, filesize, physical_filename $sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' WHERE ' . phpbb::$db->sql_in_set('attach_id', array_keys($orphan_rows)) . '
AND is_orphan = 1 AND is_orphan = 1
AND poster_id = ' . phpbb::$user->data['user_id']; AND poster_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$orphan_rows = array(); $orphan_rows = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$orphan_rows[$row['attach_id']] = $row; $orphan_rows[$row['attach_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($data['attachment_data'] as $pos => $attach_row) foreach ($data['attachment_data'] as $pos => $attach_row)
@ -2035,10 +2034,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{ {
// update entry in db if attachment already stored in db and filespace // update entry in db if attachment already stored in db and filespace
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . " $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "' SET attach_comment = '" . phpbb::$db->sql_escape($attach_row['attach_comment']) . "'
WHERE attach_id = " . (int) $attach_row['attach_id'] . ' WHERE attach_id = " . (int) $attach_row['attach_id'] . '
AND is_orphan = 0'; AND is_orphan = 0';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
@ -2059,11 +2058,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'attach_comment' => $attach_row['attach_comment'], 'attach_comment' => $attach_row['attach_comment'],
); );
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $attach_sql) . '
WHERE attach_id = ' . $attach_row['attach_id'] . ' WHERE attach_id = ' . $attach_row['attach_id'] . '
AND is_orphan = 1 AND is_orphan = 1
AND poster_id = ' . phpbb::$user->data['user_id']; AND poster_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -2088,11 +2087,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if (($post_mode == 'post' || $post_mode == 'reply') && $post_approved) if (($post_mode == 'post' || $post_mode == 'reply') && $post_approved)
{ {
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . phpbb::$db->sql_escape($subject) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time;
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) phpbb::$user->data['user_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) phpbb::$user->data['user_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape((!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : '')) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . phpbb::$db->sql_escape((!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : '')) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape(phpbb::$user->data['user_colour']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . phpbb::$db->sql_escape(phpbb::$user->data['user_colour']) . "'";
} }
else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies'])) else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies']))
{ {
@ -2101,9 +2100,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'SELECT forum_last_post_id, forum_last_post_subject $sql = 'SELECT forum_last_post_id, forum_last_post_subject
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id']; WHERE forum_id = ' . (int) $data['forum_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// this post is the latest post in the forum, better update // this post is the latest post in the forum, better update
if ($row['forum_last_post_id'] == $data['post_id']) if ($row['forum_last_post_id'] == $data['post_id'])
@ -2114,13 +2113,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
// the post's subject changed // the post's subject changed
if ($row['forum_last_post_subject'] !== $subject) if ($row['forum_last_post_subject'] !== $subject)
{ {
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_subject = \'' . $db->sql_escape($subject) . '\''; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_subject = \'' . phpbb::$db->sql_escape($subject) . '\'';
} }
// Update the user name if poster is anonymous... just in case an admin changed it // Update the user name if poster is anonymous... just in case an admin changed it
if ($data['poster_id'] == ANONYMOUS) if ($data['poster_id'] == ANONYMOUS)
{ {
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . phpbb::$db->sql_escape($username) . "'";
} }
} }
else if ($data['post_approved'] !== $post_approved) else if ($data['post_approved'] !== $post_approved)
@ -2130,9 +2129,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id'] . ' WHERE forum_id = ' . (int) $data['forum_id'] . '
AND topic_approved = 1'; AND topic_approved = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// any posts left in this forum? // any posts left in this forum?
if (!empty($row['last_post_id'])) if (!empty($row['last_post_id']))
@ -2141,17 +2140,17 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $row['last_post_id']; AND p.post_id = ' . (int) $row['last_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// salvation, a post is found! jam it into the forums table // salvation, a post is found! jam it into the forums table
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . phpbb::$db->sql_escape($row['post_subject']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . phpbb::$db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . phpbb::$db->sql_escape($row['user_colour']) . "'";
} }
else else
{ {
@ -2173,9 +2172,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'SELECT forum_last_post_id $sql = 'SELECT forum_last_post_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id']; WHERE forum_id = ' . (int) $data['forum_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_row = $db->sql_fetchrow($result); $forum_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// we made a topic global, go get new data // we made a topic global, go get new data
if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL && $forum_row['forum_last_post_id'] == $topic_row['topic_last_post_id']) if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL && $forum_row['forum_last_post_id'] == $topic_row['topic_last_post_id'])
@ -2185,9 +2184,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id'] . ' WHERE forum_id = ' . (int) $data['forum_id'] . '
AND topic_approved = 1'; AND topic_approved = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// any posts left in this forum? // any posts left in this forum?
if (!empty($row['last_post_id'])) if (!empty($row['last_post_id']))
@ -2196,17 +2195,17 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $row['last_post_id']; AND p.post_id = ' . (int) $row['last_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// salvation, a post is found! jam it into the forums table // salvation, a post is found! jam it into the forums table
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . phpbb::$db->sql_escape($row['post_subject']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . phpbb::$db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . phpbb::$db->sql_escape($row['user_colour']) . "'";
} }
else else
{ {
@ -2226,17 +2225,17 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $topic_row['topic_last_post_id']; AND p.post_id = ' . (int) $topic_row['topic_last_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// salvation, a post is found! jam it into the forums table // salvation, a post is found! jam it into the forums table
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . phpbb::$db->sql_escape($row['post_subject']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time'];
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . phpbb::$db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . phpbb::$db->sql_escape($row['user_colour']) . "'";
} }
} }
@ -2249,20 +2248,20 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{ {
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_id = ' . (int) $data['post_id']; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_id = ' . (int) $data['post_id'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) phpbb::$user->data['user_id']; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) phpbb::$user->data['user_id'];
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape((!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : '')) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . phpbb::$db->sql_escape((!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : '')) . "'";
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . ((!phpbb::$user->is_guest) ? $db->sql_escape(phpbb::$user->data['user_colour']) : '') . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . ((!phpbb::$user->is_guest) ? phpbb::$db->sql_escape(phpbb::$user->data['user_colour']) : '') . "'";
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . phpbb::$db->sql_escape($subject) . "'";
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $current_time; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $current_time;
} }
else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies'])) else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies']))
{ {
// only the subject can be changed from edit // only the subject can be changed from edit
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . phpbb::$db->sql_escape($subject) . "'";
// Maybe not only the subject, but also changing anonymous usernames. ;) // Maybe not only the subject, but also changing anonymous usernames. ;)
if ($data['poster_id'] == ANONYMOUS) if ($data['poster_id'] == ANONYMOUS)
{ {
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . phpbb::$db->sql_escape($username) . "'";
} }
} }
} }
@ -2273,9 +2272,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . (int) $data['topic_id'] . ' WHERE topic_id = ' . (int) $data['topic_id'] . '
AND post_approved = 1'; AND post_approved = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// any posts left in this forum? // any posts left in this forum?
if (!empty($row['last_post_id'])) if (!empty($row['last_post_id']))
@ -2284,17 +2283,17 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $row['last_post_id']; AND p.post_id = ' . (int) $row['last_post_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// salvation, a post is found! jam it into the topics table // salvation, a post is found! jam it into the topics table
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_id = ' . (int) $row['post_id']; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_id = ' . (int) $row['post_id'];
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . phpbb::$db->sql_escape($row['post_subject']) . "'";
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $row['post_time']; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $row['post_time'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) $row['poster_id']; $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) $row['poster_id'];
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . phpbb::$db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'";
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . phpbb::$db->sql_escape($row['user_colour']) . "'";
} }
} }
@ -2321,7 +2320,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if (isset($update_ary['stat']) && implode('', $update_ary['stat'])) if (isset($update_ary['stat']) && implode('', $update_ary['stat']))
{ {
$sql = "UPDATE $table SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]; $sql = "UPDATE $table SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -2330,11 +2329,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{ {
$sql = 'DELETE FROM ' . TOPICS_TABLE . ' $sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE topic_moved_id = ' . $data['topic_id']; WHERE topic_moved_id = ' . $data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Committing the transaction before updating search index // Committing the transaction before updating search index
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
// Delete draft if post was loaded... // Delete draft if post was loaded...
$draft_id = request_var('draft_loaded', 0); $draft_id = request_var('draft_loaded', 0);
@ -2343,7 +2342,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'DELETE FROM ' . DRAFTS_TABLE . " $sql = 'DELETE FROM ' . DRAFTS_TABLE . "
WHERE draft_id = $draft_id WHERE draft_id = $draft_id
AND user_id = " . phpbb::$user->data['user_id']; AND user_id = " . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Index message contents // Index message contents
@ -2380,14 +2379,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{ {
$sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id)
VALUES (' . phpbb::$user->data['user_id'] . ', ' . $data['topic_id'] . ')'; VALUES (' . phpbb::$user->data['user_id'] . ', ' . $data['topic_id'] . ')';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else if ($data['notify_set'] && !$data['notify']) else if ($data['notify_set'] && !$data['notify'])
{ {
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . ' WHERE user_id = ' . phpbb::$user->data['user_id'] . '
AND topic_id = ' . $data['topic_id']; AND topic_id = ' . $data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -2408,9 +2407,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . FORUMS_TRACK_TABLE . ' FROM ' . FORUMS_TRACK_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . ' WHERE user_id = ' . phpbb::$user->data['user_id'] . '
AND forum_id = ' . $data['forum_id']; AND forum_id = ' . $data['forum_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$f_mark_time = (int) $db->sql_fetchfield('mark_time'); $f_mark_time = (int) phpbb::$db->sql_fetchfield('mark_time');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->is_registered) else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->is_registered)
{ {
@ -2423,9 +2422,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'SELECT forum_last_post_time $sql = 'SELECT forum_last_post_time
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $data['forum_id']; WHERE forum_id = ' . $data['forum_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); $forum_last_post_time = (int) phpbb::$db->sql_fetchfield('forum_last_post_time');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false); update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false);
} }

View file

@ -123,15 +123,15 @@ function get_folder($user_id, $folder_id = false)
WHERE user_id = $user_id WHERE user_id = $user_id
AND folder_id <> " . PRIVMSGS_NO_BOX . ' AND folder_id <> " . PRIVMSGS_NO_BOX . '
GROUP BY folder_id'; GROUP BY folder_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$num_messages = $num_unread = array(); $num_messages = $num_unread = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$num_messages[(int) $row['folder_id']] = $row['num_messages']; $num_messages[(int) $row['folder_id']] = $row['num_messages'];
$num_unread[(int) $row['folder_id']] = $row['num_unread']; $num_unread[(int) $row['folder_id']] = $row['num_unread'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Make sure the default boxes are defined // Make sure the default boxes are defined
$available_folder = array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX); $available_folder = array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX);
@ -162,9 +162,9 @@ function get_folder($user_id, $folder_id = false)
$sql = 'SELECT folder_id, folder_name, pm_count $sql = 'SELECT folder_id, folder_name, pm_count
FROM ' . PRIVMSGS_FOLDER_TABLE . " FROM ' . PRIVMSGS_FOLDER_TABLE . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$folder[$row['folder_id']] = array( $folder[$row['folder_id']] = array(
'folder_name' => $row['folder_name'], 'folder_name' => $row['folder_name'],
@ -172,7 +172,7 @@ function get_folder($user_id, $folder_id = false)
'unread_messages' => ((isset($num_unread[$row['folder_id']])) ? $num_unread[$row['folder_id']] : 0) 'unread_messages' => ((isset($num_unread[$row['folder_id']])) ? $num_unread[$row['folder_id']] : 0)
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$folder[PRIVMSGS_OUTBOX] = array( $folder[PRIVMSGS_OUTBOX] = array(
'folder_name' => phpbb::$user->lang['PM_OUTBOX'], 'folder_name' => phpbb::$user->lang['PM_OUTBOX'],
@ -229,14 +229,14 @@ function clean_sentbox($num_sentbox_messages)
AND t.user_id = ' . phpbb::$user->data['user_id'] . ' AND t.user_id = ' . phpbb::$user->data['user_id'] . '
AND t.folder_id = ' . PRIVMSGS_SENTBOX . ' AND t.folder_id = ' . PRIVMSGS_SENTBOX . '
ORDER BY p.message_time ASC'; ORDER BY p.message_time ASC';
$result = $db->sql_query_limit($sql, ($num_sentbox_messages - phpbb::$user->data['message_limit'])); $result = phpbb::$db->sql_query_limit($sql, ($num_sentbox_messages - phpbb::$user->data['message_limit']));
$delete_ids = array(); $delete_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$delete_ids[] = $row['msg_id']; $delete_ids[] = $row['msg_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
delete_pm(phpbb::$user->data['user_id'], $delete_ids, PRIVMSGS_SENTBOX); delete_pm(phpbb::$user->data['user_id'], $delete_ids, PRIVMSGS_SENTBOX);
} }
} }
@ -286,9 +286,9 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
$sql = 'SELECT user_id, user_type, user_permissions $sql = 'SELECT user_id, user_type, user_permissions
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $message_row['author_id']; WHERE user_id = ' . (int) $message_row['author_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$userdata = $db->sql_fetchrow($result); $userdata = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$auth2 = new auth(); $auth2 = new auth();
$auth2->acl($userdata); $auth2->acl($userdata);
@ -319,9 +319,9 @@ function update_pm_counts()
WHERE pm_unread = 1 WHERE pm_unread = 1
AND folder_id <> ' . PRIVMSGS_OUTBOX . ' AND folder_id <> ' . PRIVMSGS_OUTBOX . '
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
phpbb::$user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages'); phpbb::$user->data['user_unread_privmsg'] = (int) phpbb::$db->sql_fetchfield('num_messages');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Update new pm count // Update new pm count
$sql = 'SELECT COUNT(msg_id) as num_messages $sql = 'SELECT COUNT(msg_id) as num_messages
@ -329,11 +329,11 @@ function update_pm_counts()
WHERE pm_new = 1 WHERE pm_new = 1
AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
phpbb::$user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages'); phpbb::$user->data['user_new_privmsg'] = (int) phpbb::$db->sql_fetchfield('num_messages');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( phpbb::$db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', array(
'user_unread_privmsg' => (int) phpbb::$user->data['user_unread_privmsg'], 'user_unread_privmsg' => (int) phpbb::$user->data['user_unread_privmsg'],
'user_new_privmsg' => (int) phpbb::$user->data['user_new_privmsg'], 'user_new_privmsg' => (int) phpbb::$user->data['user_new_privmsg'],
)) . ' WHERE user_id = ' . phpbb::$user->data['user_id']); )) . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
@ -346,7 +346,7 @@ function update_pm_counts()
WHERE pm_new = 1 WHERE pm_new = 1
AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -373,7 +373,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
SET folder_id = ' . PRIVMSGS_NO_BOX . ' SET folder_id = ' . PRIVMSGS_NO_BOX . '
WHERE folder_id = ' . PRIVMSGS_HOLD_BOX . " WHERE folder_id = ' . PRIVMSGS_HOLD_BOX . "
AND user_id = $user_id"; AND user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Get those messages not yet placed into any box // Get those messages not yet placed into any box
@ -387,13 +387,13 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
// Just place into the appropriate arrays if no rules need to be checked // Just place into the appropriate arrays if no rules need to be checked
if (!$user_message_rules) if (!$user_message_rules)
{ {
$result = $db->sql_query($retrieve_sql); $result = phpbb::$db->sql_query($retrieve_sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$action_ary[$row['msg_id']][] = array('action' => false); $action_ary[$row['msg_id']][] = array('action' => false);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -404,28 +404,28 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . PRIVMSGS_RULES_TABLE . " FROM ' . PRIVMSGS_RULES_TABLE . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_rules = $db->sql_fetchrowset($result); $user_rules = phpbb::$db->sql_fetchrowset($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($user_rules)) if (sizeof($user_rules))
{ {
$sql = 'SELECT zebra_id, friend, foe $sql = 'SELECT zebra_id, friend, foe
FROM ' . ZEBRA_TABLE . " FROM ' . ZEBRA_TABLE . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$zebra[$row['zebra_id']] = $row; $zebra[$row['zebra_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Now build a bare-bone check_row array // Now build a bare-bone check_row array
$result = $db->sql_query($retrieve_sql); $result = phpbb::$db->sql_query($retrieve_sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$check_rows[] = array_merge($row, array( $check_rows[] = array_merge($row, array(
'to' => explode(':', $row['to_address']), 'to' => explode(':', $row['to_address']),
@ -438,22 +438,22 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$user_ids[] = $row['user_id']; $user_ids[] = $row['user_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Retrieve user memberships // Retrieve user memberships
if (sizeof($user_ids)) if (sizeof($user_ids))
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USER_GROUP_TABLE . ' FROM ' . USER_GROUP_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $user_ids) . ' WHERE ' . phpbb::$db->sql_in_set('user_id', $user_ids) . '
AND user_pending = 0'; AND user_pending = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$memberships[$row['user_id']][] = $row['group_id']; $memberships[$row['user_id']][] = $row['group_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Now place into the appropriate folder // Now place into the appropriate folder
@ -553,10 +553,10 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
{ {
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_unread = 0 SET pm_unread = 0
WHERE ' . $db->sql_in_set('msg_id', $unread_ids) . " WHERE ' . phpbb::$db->sql_in_set('msg_id', $unread_ids) . "
AND user_id = $user_id AND user_id = $user_id
AND folder_id = " . PRIVMSGS_NO_BOX; AND folder_id = " . PRIVMSGS_NO_BOX;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// mark messages as important // mark messages as important
@ -566,8 +566,8 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
SET pm_marked = 1 - pm_marked SET pm_marked = 1 - pm_marked
WHERE folder_id = ' . PRIVMSGS_NO_BOX . " WHERE folder_id = ' . PRIVMSGS_NO_BOX . "
AND user_id = $user_id AND user_id = $user_id
AND " . $db->sql_in_set('msg_id', $important_ids); AND " . phpbb::$db->sql_in_set('msg_id', $important_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Move into folder // Move into folder
@ -586,15 +586,15 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$sql = 'SELECT folder_id, pm_count $sql = 'SELECT folder_id, pm_count
FROM ' . PRIVMSGS_FOLDER_TABLE . ' FROM ' . PRIVMSGS_FOLDER_TABLE . '
WHERE ' . $db->sql_in_set('folder_id', $sql_folder) . " WHERE ' . phpbb::$db->sql_in_set('folder_id', $sql_folder) . "
AND user_id = $user_id"; AND user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$folder[(int) $row['folder_id']] = (int) $row['pm_count']; $folder[(int) $row['folder_id']] = (int) $row['pm_count'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
unset($sql_folder); unset($sql_folder);
@ -604,9 +604,9 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
FROM ' . PRIVMSGS_TO_TABLE . " FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id WHERE user_id = $user_id
AND folder_id = " . PRIVMSGS_INBOX; AND folder_id = " . PRIVMSGS_INBOX;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$folder[PRIVMSGS_INBOX] = (int) $db->sql_fetchfield('num_messages'); $folder[PRIVMSGS_INBOX] = (int) phpbb::$db->sql_fetchfield('num_messages');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -641,14 +641,14 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
WHERE user_id = $user_id WHERE user_id = $user_id
AND folder_id = $dest_folder AND folder_id = $dest_folder
ORDER BY msg_id ASC"; ORDER BY msg_id ASC";
$result = $db->sql_query_limit($sql, (($folder[$dest_folder] + sizeof($msg_ary)) - phpbb::$user->data['message_limit'])); $result = phpbb::$db->sql_query_limit($sql, (($folder[$dest_folder] + sizeof($msg_ary)) - phpbb::$user->data['message_limit']));
$delete_ids = array(); $delete_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$delete_ids[] = $row['msg_id']; $delete_ids[] = $row['msg_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$num_removed += sizeof($delete_ids); $num_removed += sizeof($delete_ids);
delete_pm($user_id, $delete_ids, $dest_folder); delete_pm($user_id, $delete_ids, $dest_folder);
@ -662,8 +662,8 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
SET folder_id = ' . PRIVMSGS_HOLD_BOX . ' SET folder_id = ' . PRIVMSGS_HOLD_BOX . '
WHERE folder_id = ' . PRIVMSGS_NO_BOX . " WHERE folder_id = ' . PRIVMSGS_NO_BOX . "
AND user_id = $user_id AND user_id = $user_id
AND " . $db->sql_in_set('msg_id', $msg_ary); AND " . phpbb::$db->sql_in_set('msg_id', $msg_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
@ -672,16 +672,16 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
WHERE folder_id = " . PRIVMSGS_NO_BOX . " WHERE folder_id = " . PRIVMSGS_NO_BOX . "
AND user_id = $user_id AND user_id = $user_id
AND pm_new = 1 AND pm_new = 1
AND " . $db->sql_in_set('msg_id', $msg_ary); AND " . phpbb::$db->sql_in_set('msg_id', $msg_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if ($dest_folder != PRIVMSGS_INBOX) if ($dest_folder != PRIVMSGS_INBOX)
{ {
$sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . ' $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . '
SET pm_count = pm_count + ' . (int) $db->sql_affectedrows() . " SET pm_count = pm_count + ' . (int) phpbb::$db->sql_affectedrows() . "
WHERE folder_id = $dest_folder WHERE folder_id = $dest_folder
AND user_id = $user_id"; AND user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
} }
@ -693,8 +693,8 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET folder_id = ' . PRIVMSGS_SENTBOX . ' SET folder_id = ' . PRIVMSGS_SENTBOX . '
WHERE folder_id = ' . PRIVMSGS_OUTBOX . ' WHERE folder_id = ' . PRIVMSGS_OUTBOX . '
AND ' . $db->sql_in_set('msg_id', array_keys($action_ary)); AND ' . phpbb::$db->sql_in_set('msg_id', array_keys($action_ary));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Update new/unread count // Update new/unread count
@ -705,9 +705,9 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
FROM ' . PRIVMSGS_TO_TABLE . " FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id WHERE user_id = $user_id
AND folder_id = " . PRIVMSGS_HOLD_BOX; AND folder_id = " . PRIVMSGS_HOLD_BOX;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$num_not_moved = (int) $db->sql_fetchfield('num_messages'); $num_not_moved = (int) phpbb::$db->sql_fetchfield('num_messages');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return array('not_moved' => $num_not_moved, 'removed' => $num_removed); return array('not_moved' => $num_not_moved, 'removed' => $num_removed);
} }
@ -734,9 +734,9 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
FROM ' . PRIVMSGS_FOLDER_TABLE . " FROM ' . PRIVMSGS_FOLDER_TABLE . "
WHERE folder_id = $dest_folder WHERE folder_id = $dest_folder
AND user_id = $user_id"; AND user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -756,9 +756,9 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
FROM ' . PRIVMSGS_TO_TABLE . ' FROM ' . PRIVMSGS_TO_TABLE . '
WHERE folder_id = ' . PRIVMSGS_INBOX . " WHERE folder_id = ' . PRIVMSGS_INBOX . "
AND user_id = $user_id"; AND user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$num_messages = (int) $db->sql_fetchfield('num_messages'); $num_messages = (int) phpbb::$db->sql_fetchfield('num_messages');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($message_limit && $num_messages + sizeof($move_msg_ids) > $message_limit) if ($message_limit && $num_messages + sizeof($move_msg_ids) > $message_limit)
{ {
@ -772,9 +772,9 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
SET folder_id = $dest_folder SET folder_id = $dest_folder
WHERE folder_id = $cur_folder_id WHERE folder_id = $cur_folder_id
AND user_id = $user_id AND user_id = $user_id
AND " . $db->sql_in_set('msg_id', $move_msg_ids); AND " . phpbb::$db->sql_in_set('msg_id', $move_msg_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$num_moved = $db->sql_affectedrows(); $num_moved = phpbb::$db->sql_affectedrows();
// Update pm counts // Update pm counts
if ($num_moved) if ($num_moved)
@ -785,7 +785,7 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
SET pm_count = pm_count - $num_moved SET pm_count = pm_count - $num_moved
WHERE folder_id = $cur_folder_id WHERE folder_id = $cur_folder_id
AND user_id = $user_id"; AND user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if ($dest_folder != PRIVMSGS_INBOX) if ($dest_folder != PRIVMSGS_INBOX)
@ -794,7 +794,7 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
SET pm_count = pm_count + $num_moved SET pm_count = pm_count + $num_moved
WHERE folder_id = $dest_folder WHERE folder_id = $dest_folder
AND user_id = $user_id"; AND user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
} }
@ -821,12 +821,12 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
WHERE msg_id = $msg_id WHERE msg_id = $msg_id
AND user_id = $user_id AND user_id = $user_id
AND folder_id = $folder_id"; AND folder_id = $folder_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_unread_privmsg = user_unread_privmsg - 1 SET user_unread_privmsg = user_unread_privmsg - 1
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (phpbb::$user->data['user_id'] == $user_id) if (phpbb::$user->data['user_id'] == $user_id)
{ {
@ -838,7 +838,7 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_unread_privmsg = 0 SET user_unread_privmsg = 0
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$user->data['user_unread_privmsg'] = 0; phpbb::$user->data['user_unread_privmsg'] = 0;
} }
@ -867,8 +867,8 @@ function handle_mark_actions($user_id, $mark_action)
SET pm_marked = 1 - pm_marked SET pm_marked = 1 - pm_marked
WHERE folder_id = $cur_folder_id WHERE folder_id = $cur_folder_id
AND user_id = $user_id AND user_id = $user_id
AND " . $db->sql_in_set('msg_id', $msg_ids); AND " . phpbb::$db->sql_in_set('msg_id', $msg_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
break; break;
@ -935,21 +935,21 @@ function delete_pm($user_id, $msg_ids, $folder_id)
// Get PM Information for later deleting // Get PM Information for later deleting
$sql = 'SELECT msg_id, pm_unread, pm_new $sql = 'SELECT msg_id, pm_unread, pm_new
FROM ' . PRIVMSGS_TO_TABLE . ' FROM ' . PRIVMSGS_TO_TABLE . '
WHERE ' . $db->sql_in_set('msg_id', array_map('intval', $msg_ids)) . " WHERE ' . phpbb::$db->sql_in_set('msg_id', array_map('intval', $msg_ids)) . "
AND folder_id = $folder_id AND folder_id = $folder_id
AND user_id = $user_id"; AND user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$delete_rows = array(); $delete_rows = array();
$num_unread = $num_new = $num_deleted = 0; $num_unread = $num_new = $num_deleted = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$num_unread += (int) $row['pm_unread']; $num_unread += (int) $row['pm_unread'];
$num_new += (int) $row['pm_new']; $num_new += (int) $row['pm_new'];
$delete_rows[$row['msg_id']] = 1; $delete_rows[$row['msg_id']] = 1;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
unset($msg_ids); unset($msg_ids);
if (!sizeof($delete_rows)) if (!sizeof($delete_rows))
@ -957,7 +957,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
return false; return false;
} }
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
// if no one has read the message yet (meaning it is in users outbox) // if no one has read the message yet (meaning it is in users outbox)
// then mark the message as deleted... // then mark the message as deleted...
@ -966,22 +966,22 @@ function delete_pm($user_id, $msg_ids, $folder_id)
// Remove PM from Outbox // Remove PM from Outbox
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . " $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id AND folder_id = " . PRIVMSGS_OUTBOX . ' WHERE user_id = $user_id AND folder_id = " . PRIVMSGS_OUTBOX . '
AND ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); AND ' . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Update PM Information for safety // Update PM Information for safety
$sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '' $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = ''
WHERE " . $db->sql_in_set('msg_id', array_keys($delete_rows)); WHERE " . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Set delete flag for those intended to receive the PM // Set delete flag for those intended to receive the PM
// We do not remove the message actually, to retain some basic information (sent time for example) // We do not remove the message actually, to retain some basic information (sent time for example)
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_deleted = 1 SET pm_deleted = 1
WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); WHERE ' . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$num_deleted = $db->sql_affectedrows(); $num_deleted = phpbb::$db->sql_affectedrows();
} }
else else
{ {
@ -989,9 +989,9 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . " $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id WHERE user_id = $user_id
AND folder_id = $folder_id AND folder_id = $folder_id
AND " . $db->sql_in_set('msg_id', array_keys($delete_rows)); AND " . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$num_deleted = $db->sql_affectedrows(); $num_deleted = phpbb::$db->sql_affectedrows();
} }
// if folder id is user defined folder then decrease pm_count // if folder id is user defined folder then decrease pm_count
@ -1000,7 +1000,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . "
SET pm_count = pm_count - $num_deleted SET pm_count = pm_count - $num_deleted
WHERE folder_id = $folder_id"; WHERE folder_id = $folder_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Update unread and new status field // Update unread and new status field
@ -1014,7 +1014,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new; $set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new;
} }
$db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id"); phpbb::$db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id");
phpbb::$user->data['user_new_privmsg'] -= $num_new; phpbb::$user->data['user_new_privmsg'] -= $num_new;
phpbb::$user->data['user_unread_privmsg'] -= $num_unread; phpbb::$user->data['user_unread_privmsg'] -= $num_unread;
@ -1023,14 +1023,14 @@ function delete_pm($user_id, $msg_ids, $folder_id)
// Now we have to check which messages we can delete completely // Now we have to check which messages we can delete completely
$sql = 'SELECT msg_id $sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . ' FROM ' . PRIVMSGS_TO_TABLE . '
WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows)); WHERE ' . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
unset($delete_rows[$row['msg_id']]); unset($delete_rows[$row['msg_id']]);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$delete_ids = array_keys($delete_rows); $delete_ids = array_keys($delete_rows);
@ -1045,11 +1045,11 @@ function delete_pm($user_id, $msg_ids, $folder_id)
delete_attachments('message', $delete_ids, false); delete_attachments('message', $delete_ids, false);
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
WHERE ' . $db->sql_in_set('msg_id', $delete_ids); WHERE ' . phpbb::$db->sql_in_set('msg_id', $delete_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
return true; return true;
} }
@ -1119,11 +1119,11 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
{ {
$sql = 'SELECT user_id, username, user_colour $sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $u) . ' WHERE ' . phpbb::$db->sql_in_set('user_id', $u) . '
AND user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')'; AND user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($check_type == 'to' || $author_id == phpbb::$user->data['user_id'] || $row['user_id'] == phpbb::$user->data['user_id']) if ($check_type == 'to' || $author_id == phpbb::$user->data['user_id'] || $row['user_id'] == phpbb::$user->data['user_id'])
{ {
@ -1137,7 +1137,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (sizeof($g)) if (sizeof($g))
@ -1146,28 +1146,28 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
{ {
$sql = 'SELECT group_name, group_type $sql = 'SELECT group_name, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE ' . $db->sql_in_set('group_id', $g); WHERE ' . phpbb::$db->sql_in_set('group_id', $g);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($check_type == 'to' || $author_id == phpbb::$user->data['user_id'] || $row['user_id'] == phpbb::$user->data['user_id']) if ($check_type == 'to' || $author_id == phpbb::$user->data['user_id'] || $row['user_id'] == phpbb::$user->data['user_id'])
{ {
$address[] = ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']; $address[] = ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
WHERE ' . $db->sql_in_set('g.group_id', $g) . ' WHERE ' . phpbb::$db->sql_in_set('g.group_id', $g) . '
AND g.group_id = ug.group_id AND g.group_id = ug.group_id
AND ug.user_pending = 0'; AND ug.user_pending = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!isset($address['group'][$row['group_id']])) if (!isset($address['group'][$row['group_id']]))
{ {
@ -1183,7 +1183,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
$address['user'][$row['user_id']]['in_group'] = $row['group_id']; $address['user'][$row['user_id']]['in_group'] = $row['group_id'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -1317,19 +1317,19 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
$sql = 'SELECT u.user_type, ug.group_id, ug.user_id $sql = 'SELECT u.user_type, ug.group_id, ug.user_id
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
WHERE ' . $db->sql_in_set('ug.group_id', array_keys($data['address_list']['g'])) . ' WHERE ' . phpbb::$db->sql_in_set('ug.group_id', array_keys($data['address_list']['g'])) . '
AND ug.user_pending = 0 AND ug.user_pending = 0
AND u.user_id = ug.user_id AND u.user_id = ug.user_id
AND u.user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')' . AND u.user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')' .
$sql_allow_pm; $sql_allow_pm;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc'; $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc';
$recipients[$row['user_id']] = $field; $recipients[$row['user_id']] = $field;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!sizeof($recipients)) if (!sizeof($recipients))
@ -1338,7 +1338,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
} }
} }
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$sql = ''; $sql = '';
@ -1402,15 +1402,15 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward') if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward')
{ {
$db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data)); phpbb::$db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_data));
$data['msg_id'] = $db->sql_nextid(); $data['msg_id'] = phpbb::$db->sql_nextid();
} }
else if ($mode == 'edit') else if ($mode == 'edit')
{ {
$sql = 'UPDATE ' . PRIVMSGS_TABLE . ' $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . ' SET message_edit_count = message_edit_count + 1, ' . phpbb::$db->sql_build_array('UPDATE', $sql_data) . '
WHERE msg_id = ' . $data['msg_id']; WHERE msg_id = ' . $data['msg_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1418,7 +1418,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
{ {
if ($sql) if ($sql)
{ {
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
unset($sql); unset($sql);
@ -1436,17 +1436,17 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
); );
} }
$db->sql_multi_insert(PRIVMSGS_TO_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(PRIVMSGS_TO_TABLE, $sql_ary);
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1, user_last_privmsg = ' . time() . ' SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1, user_last_privmsg = ' . time() . '
WHERE ' . $db->sql_in_set('user_id', array_keys($recipients)); WHERE ' . phpbb::$db->sql_in_set('user_id', array_keys($recipients));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Put PM into outbox // Put PM into outbox
if ($put_in_outbox) if ($put_in_outbox)
{ {
$db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array( phpbb::$db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'msg_id' => (int) $data['msg_id'], 'msg_id' => (int) $data['msg_id'],
'user_id' => (int) $data['from_user_id'], 'user_id' => (int) $data['from_user_id'],
'author_id' => (int) $data['from_user_id'], 'author_id' => (int) $data['from_user_id'],
@ -1464,7 +1464,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_lastpost_time = $current_time SET user_lastpost_time = $current_time
WHERE user_id = " . $data['from_user_id']; WHERE user_id = " . $data['from_user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Submit Attachments // Submit Attachments
@ -1482,18 +1482,18 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
{ {
$sql = 'SELECT attach_id, filesize, physical_filename $sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . ' WHERE ' . phpbb::$db->sql_in_set('attach_id', array_keys($orphan_rows)) . '
AND in_message = 1 AND in_message = 1
AND is_orphan = 1 AND is_orphan = 1
AND poster_id = ' . phpbb::$user->data['user_id']; AND poster_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$orphan_rows = array(); $orphan_rows = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$orphan_rows[$row['attach_id']] = $row; $orphan_rows[$row['attach_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($data['attachment_data'] as $pos => $attach_row) foreach ($data['attachment_data'] as $pos => $attach_row)
@ -1507,10 +1507,10 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
{ {
// update entry in db if attachment already stored in db and filespace // update entry in db if attachment already stored in db and filespace
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . " $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
SET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "' SET attach_comment = '" . phpbb::$db->sql_escape($attach_row['attach_comment']) . "'
WHERE attach_id = " . (int) $attach_row['attach_id'] . ' WHERE attach_id = " . (int) $attach_row['attach_id'] . '
AND is_orphan = 0'; AND is_orphan = 0';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
@ -1531,11 +1531,11 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
'attach_comment' => $attach_row['attach_comment'], 'attach_comment' => $attach_row['attach_comment'],
); );
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $attach_sql) . '
WHERE attach_id = ' . $attach_row['attach_id'] . ' WHERE attach_id = ' . $attach_row['attach_id'] . '
AND is_orphan = 1 AND is_orphan = 1
AND poster_id = ' . phpbb::$user->data['user_id']; AND poster_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1553,10 +1553,10 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
$sql = 'DELETE FROM ' . DRAFTS_TABLE . " $sql = 'DELETE FROM ' . DRAFTS_TABLE . "
WHERE draft_id = $draft_id WHERE draft_id = $draft_id
AND user_id = " . $data['from_user_id']; AND user_id = " . $data['from_user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
// Send Notifications // Send Notifications
if ($mode != 'edit') if ($mode != 'edit')
@ -1584,15 +1584,15 @@ function pm_notification($mode, $author, $recipients, $subject, $message)
// Get banned User ID's // Get banned User ID's
$sql = 'SELECT ban_userid $sql = 'SELECT ban_userid
FROM ' . BANLIST_TABLE . ' FROM ' . BANLIST_TABLE . '
WHERE ' . $db->sql_in_set('ban_userid', array_map('intval', array_keys($recipients))) . ' WHERE ' . phpbb::$db->sql_in_set('ban_userid', array_map('intval', array_keys($recipients))) . '
AND ban_exclude = 0'; AND ban_exclude = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
unset($recipients[$row['ban_userid']]); unset($recipients[$row['ban_userid']]);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($recipients)) if (!sizeof($recipients))
{ {
@ -1601,11 +1601,11 @@ function pm_notification($mode, $author, $recipients, $subject, $message)
$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($recipients))); WHERE ' . phpbb::$db->sql_in_set('user_id', array_map('intval', array_keys($recipients)));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$msg_list_ary = array(); $msg_list_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['user_notify_pm'] == 1 && trim($row['user_email'])) if ($row['user_notify_pm'] == 1 && trim($row['user_email']))
{ {
@ -1618,7 +1618,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message)
); );
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($msg_list_ary)) if (!sizeof($msg_list_ary))
{ {
@ -1677,12 +1677,12 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
} }
$sql .= ' ORDER BY p.message_time DESC'; $sql .= ' ORDER BY p.message_time DESC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
if (!$row) if (!$row)
{ {
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return false; return false;
} }
@ -1706,8 +1706,8 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
} }
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$title = $row['message_subject']; $title = $row['message_subject'];
@ -1817,9 +1817,9 @@ function set_user_message_limit()
WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . ' WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . '
AND ug.user_pending = 0 AND ug.user_pending = 0
AND ug.group_id = g.group_id'; AND ug.group_id = g.group_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$message_limit = (int) $db->sql_fetchfield('max_message_limit'); $message_limit = (int) phpbb::$db->sql_fetchfield('max_message_limit');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
phpbb::$user->data['message_limit'] = (!$message_limit) ? phpbb::$config['pm_max_msgs'] : $message_limit; phpbb::$user->data['message_limit'] = (!$message_limit) ? phpbb::$config['pm_max_msgs'] : $message_limit;
} }

View file

@ -61,9 +61,9 @@ class custom_profile
AND l.lang_id = $lang_id AND l.lang_id = $lang_id
AND l.field_id = f.field_id AND l.field_id = f.field_id
ORDER BY f.field_order"; ORDER BY f.field_order";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Return templated field // Return templated field
$tpl_snippet = $this->process_field_row('change', $row); $tpl_snippet = $this->process_field_row('change', $row);
@ -79,7 +79,7 @@ class custom_profile
'S_REQUIRED' => ($row['field_required']) ? true : false) 'S_REQUIRED' => ($row['field_required']) ? true : false)
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -211,13 +211,13 @@ class custom_profile
AND f.field_no_view = 0 AND f.field_no_view = 0
AND l.field_id = f.field_id AND l.field_id = f.field_id
ORDER BY f.field_order'; ORDER BY f.field_order';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$this->profile_cache[$row['field_ident']] = $row; $this->profile_cache[$row['field_ident']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -243,14 +243,14 @@ class custom_profile
AND lang_id = $lang_id AND lang_id = $lang_id
AND field_type = $field_type AND field_type = $field_type
ORDER BY option_id"; ORDER BY option_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
// @todo: ref optimize // @todo: ref optimize
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value']; $this->options_lang[$field_id][$lang_id][($row['option_id'] + 1)] = $row['lang_value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -288,9 +288,9 @@ class custom_profile
$sql_where $sql_where
AND l.field_id = f.field_id AND l.field_id = f.field_id
ORDER BY f.field_order"; ORDER BY f.field_order";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$cp_data['pf_' . $row['field_ident']] = $this->get_profile_field($row); $cp_data['pf_' . $row['field_ident']] = $this->get_profile_field($row);
$check_value = $cp_data['pf_' . $row['field_ident']]; $check_value = $cp_data['pf_' . $row['field_ident']];
@ -340,7 +340,7 @@ class custom_profile
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -369,15 +369,15 @@ class custom_profile
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . PROFILE_FIELDS_DATA_TABLE . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_map('intval', $user_id)); WHERE ' . phpbb::$db->sql_in_set('user_id', array_map('intval', $user_id));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$field_data = array(); $field_data = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$field_data[$row['user_id']] = $row; $field_data[$row['user_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$user_fields = array(); $user_fields = array();
@ -783,11 +783,11 @@ class custom_profile
$sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value $sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
WHERE l.lang_id = ' . phpbb::$user->get_iso_lang_id() . ' WHERE l.lang_id = ' . phpbb::$user->get_iso_lang_id() . '
' . ((sizeof($sql_not_in)) ? ' AND ' . $db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . ' ' . ((sizeof($sql_not_in)) ? ' AND ' . phpbb::$db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . '
AND l.field_id = f.field_id'; AND l.field_id = f.field_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['field_default_value'] == 'now' && $row['field_type'] == FIELD_DATE) if ($row['field_default_value'] == 'now' && $row['field_type'] == FIELD_DATE)
{ {
@ -797,7 +797,7 @@ class custom_profile
$cp_data['pf_' . $row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value']; $cp_data['pf_' . $row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return $cp_data; return $cp_data;
} }

View file

@ -137,13 +137,13 @@ class bbcode_firstpass extends bbcode
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . BBCODES_TABLE; FROM ' . BBCODES_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$rowset[] = $row; $rowset[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($rowset as $row) foreach ($rowset as $row)
@ -1250,10 +1250,10 @@ class parse_message extends bbcode_firstpass
// For now setting the ttl to 10 minutes // For now setting the ttl to 10 minutes
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . SMILIES_TABLE . ' FROM ' . SMILIES_TABLE . '
ORDER BY ' . $db->sql_function('length_varchar', 'code') . ' DESC'; ORDER BY ' . phpbb::$db->sql_function('length_varchar', 'code') . ' DESC';
$result = $db->sql_query($sql, 600); $result = phpbb::$db->sql_query($sql, 600);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (empty($row['code'])) if (empty($row['code']))
{ {
@ -1264,7 +1264,7 @@ class parse_message extends bbcode_firstpass
$match[] = '(?<=^|[\n .])' . preg_quote($row['code'], '#') . '(?![^<>]*>)'; $match[] = '(?<=^|[\n .])' . preg_quote($row['code'], '#') . '(?![^<>]*>)';
$replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILIES_PATH}/' . $row['smiley_url'] . '" alt="' . $row['code'] . '" title="' . $row['emotion'] . '" /><!-- s' . $row['code'] . ' -->'; $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILIES_PATH}/' . $row['smiley_url'] . '" alt="' . $row['code'] . '" title="' . $row['emotion'] . '" /><!-- s' . $row['code'] . ' -->';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (sizeof($match)) if (sizeof($match))
@ -1343,10 +1343,10 @@ class parse_message extends bbcode_firstpass
'poster_id' => phpbb::$user->data['user_id'], 'poster_id' => phpbb::$user->data['user_id'],
); );
$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
$new_entry = array( $new_entry = array(
'attach_id' => $db->sql_nextid(), 'attach_id' => phpbb::$db->sql_nextid(),
'is_orphan' => 1, 'is_orphan' => 1,
'real_filename' => $filedata['real_filename'], 'real_filename' => $filedata['real_filename'],
'attach_comment'=> $this->filename_data['filecomment'], 'attach_comment'=> $this->filename_data['filecomment'],
@ -1394,9 +1394,9 @@ class parse_message extends bbcode_firstpass
WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] . '
AND is_orphan = 1 AND is_orphan = 1
AND poster_id = ' . phpbb::$user->data['user_id']; AND poster_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -1407,7 +1407,7 @@ class parse_message extends bbcode_firstpass
phpbb_unlink($row['physical_filename'], 'thumbnail'); phpbb_unlink($row['physical_filename'], 'thumbnail');
} }
$db->sql_query('DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id']); phpbb::$db->sql_query('DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id']);
} }
} }
else else
@ -1445,10 +1445,10 @@ class parse_message extends bbcode_firstpass
'poster_id' => phpbb::$user->data['user_id'], 'poster_id' => phpbb::$user->data['user_id'],
); );
$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
$new_entry = array( $new_entry = array(
'attach_id' => $db->sql_nextid(), 'attach_id' => phpbb::$db->sql_nextid(),
'is_orphan' => 1, 'is_orphan' => 1,
'real_filename' => $filedata['real_filename'], 'real_filename' => $filedata['real_filename'],
'attach_comment'=> $this->filename_data['filecomment'], 'attach_comment'=> $this->filename_data['filecomment'],
@ -1508,11 +1508,11 @@ class parse_message extends bbcode_firstpass
// Get the attachment data, based on the poster id... // Get the attachment data, based on the poster id...
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($not_orphan)) . ' WHERE ' . phpbb::$db->sql_in_set('attach_id', array_keys($not_orphan)) . '
AND poster_id = ' . $check_user_id; AND poster_id = ' . $check_user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$pos = $not_orphan[(int) $row['attach_id']]; $pos = $not_orphan[(int) $row['attach_id']];
$this->attachment_data[$pos] = $row; $this->attachment_data[$pos] = $row;
@ -1520,7 +1520,7 @@ class parse_message extends bbcode_firstpass
unset($not_orphan[(int) $row['attach_id']]); unset($not_orphan[(int) $row['attach_id']]);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (sizeof($not_orphan)) if (sizeof($not_orphan))
@ -1533,12 +1533,12 @@ class parse_message extends bbcode_firstpass
{ {
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan)) . ' WHERE ' . phpbb::$db->sql_in_set('attach_id', array_keys($orphan)) . '
AND poster_id = ' . phpbb::$user->data['user_id'] . ' AND poster_id = ' . phpbb::$user->data['user_id'] . '
AND is_orphan = 1'; AND is_orphan = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$pos = $orphan[(int) $row['attach_id']]; $pos = $orphan[(int) $row['attach_id']];
$this->attachment_data[$pos] = $row; $this->attachment_data[$pos] = $row;
@ -1546,7 +1546,7 @@ class parse_message extends bbcode_firstpass
unset($orphan[(int) $row['attach_id']]); unset($orphan[(int) $row['attach_id']]);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (sizeof($orphan)) if (sizeof($orphan))

View file

@ -46,9 +46,9 @@ class fulltext_mysql extends search_backend
*/ */
public function init() public function init()
{ {
$result = $db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\''); $result = phpbb::$db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\'');
$info = $db->sql_fetchrow($result); $info = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$engine = ''; $engine = '';
if (isset($info['Engine'])) if (isset($info['Engine']))
@ -67,14 +67,14 @@ class fulltext_mysql extends search_backend
$sql = 'SHOW VARIABLES $sql = 'SHOW VARIABLES
LIKE \'ft\_%\''; LIKE \'ft\_%\'';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$mysql_info = array(); $mysql_info = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$mysql_info[$row['Variable_name']] = $row['Value']; $mysql_info[$row['Variable_name']] = $row['Value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
set_config('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); set_config('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']);
set_config('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']); set_config('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);
@ -336,7 +336,7 @@ class fulltext_mysql extends search_backend
} }
else else
{ {
$m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . phpbb::$db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
} }
$sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : ''; $sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : '';
@ -348,7 +348,7 @@ class fulltext_mysql extends search_backend
$sql_where_options = $sql_sort_join; $sql_where_options = $sql_sort_join;
$sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : ''; $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
$sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : ''; $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : '';
$sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . phpbb::$db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_where_options .= $m_approve_fid_sql; $sql_where_options .= $m_approve_fid_sql;
$sql_where_options .= (sizeof($author_ary)) ? ' AND p.poster_id ' . $sql_author : ''; $sql_where_options .= (sizeof($author_ary)) ? ' AND p.poster_id ' . $sql_author : '';
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
@ -356,16 +356,16 @@ class fulltext_mysql extends search_backend
$sql = "SELECT $sql_select $sql = "SELECT $sql_select
FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p
WHERE MATCH ($sql_match) AGAINST ('" . $db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE) WHERE MATCH ($sql_match) AGAINST ('" . phpbb::$db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
$sql_where_options $sql_where_options
ORDER BY $sql_sort"; ORDER BY $sql_sort";
$result = $db->sql_query_limit($sql, phpbb::$config['search_block_size'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['search_block_size'], $start);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$id_ary[] = $row[$field]; $id_ary[] = $row[$field];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$id_ary = array_unique($id_ary); $id_ary = array_unique($id_ary);
@ -378,9 +378,9 @@ class fulltext_mysql extends search_backend
if (!$result_count) if (!$result_count)
{ {
$sql = 'SELECT FOUND_ROWS() as result_count'; $sql = 'SELECT FOUND_ROWS() as result_count';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$result_count = (int) $db->sql_fetchfield('result_count'); $result_count = (int) phpbb::$db->sql_fetchfield('result_count');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$result_count) if (!$result_count)
{ {
@ -436,8 +436,8 @@ class fulltext_mysql extends search_backend
$id_ary = array(); $id_ary = array();
// Create some display specific sql strings // Create some display specific sql strings
$sql_author = $db->sql_in_set('p.poster_id', $author_ary); $sql_author = phpbb::$db->sql_in_set('p.poster_id', $author_ary);
$sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . phpbb::$db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : ''; $sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; $sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : ''; $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@ -473,7 +473,7 @@ class fulltext_mysql extends search_backend
} }
else else
{ {
$m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . phpbb::$db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
} }
// If the cache was completely empty count the results // If the cache was completely empty count the results
@ -512,21 +512,21 @@ class fulltext_mysql extends search_backend
} }
// Only read one block of posts from the db and then cache it // Only read one block of posts from the db and then cache it
$result = $db->sql_query_limit($sql, phpbb::$config['search_block_size'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['search_block_size'], $start);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$id_ary[] = $row[$field]; $id_ary[] = $row[$field];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// retrieve the total result count if needed // retrieve the total result count if needed
if (!$result_count) if (!$result_count)
{ {
$sql = 'SELECT FOUND_ROWS() as result_count'; $sql = 'SELECT FOUND_ROWS() as result_count';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$result_count = (int) $db->sql_fetchfield('result_count'); $result_count = (int) phpbb::$db->sql_fetchfield('result_count');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$result_count) if (!$result_count)
{ {
@ -622,10 +622,10 @@ class fulltext_mysql extends search_backend
if (sizeof($alter)) if (sizeof($alter))
{ {
$db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter)); phpbb::$db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
} }
$db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); phpbb::$db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false; return false;
} }
@ -665,10 +665,10 @@ class fulltext_mysql extends search_backend
if (sizeof($alter)) if (sizeof($alter))
{ {
$db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter)); phpbb::$db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
} }
$db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); phpbb::$db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false; return false;
} }
@ -703,7 +703,7 @@ class fulltext_mysql extends search_backend
private function get_stats() private function get_stats()
{ {
if ($db->dbms_type !== 'mysql') if (phpbb::$db->dbms_type !== 'mysql')
{ {
$this->stats = array(); $this->stats = array();
return; return;
@ -711,9 +711,9 @@ class fulltext_mysql extends search_backend
$sql = 'SHOW INDEX $sql = 'SHOW INDEX
FROM ' . POSTS_TABLE; FROM ' . POSTS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// deal with older MySQL versions which didn't use Index_type // deal with older MySQL versions which didn't use Index_type
$index_type = (isset($row['Index_type'])) ? $row['Index_type'] : $row['Comment']; $index_type = (isset($row['Index_type'])) ? $row['Index_type'] : $row['Comment'];
@ -734,13 +734,13 @@ class fulltext_mysql extends search_backend
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT COUNT(post_id) as total_posts $sql = 'SELECT COUNT(post_id) as total_posts
FROM ' . POSTS_TABLE; FROM ' . POSTS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$this->stats['total_posts'] = (int) $db->sql_fetchfield('total_posts'); $this->stats['total_posts'] = (int) phpbb::$db->sql_fetchfield('total_posts');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**

View file

@ -239,7 +239,7 @@ _sql($sql, $errored, $error_ary);
/* Optimize/vacuum analyze the tables where appropriate /* Optimize/vacuum analyze the tables where appropriate
// this should be done for each version in future along with // this should be done for each version in future along with
// the version number update // the version number update
switch ($db->dbms_type) switch (phpbb::$db->dbms_type)
{ {
case 'mysql': case 'mysql':
$sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words';

View file

@ -1488,7 +1488,7 @@ class install_install extends module
if (!$user_id) if (!$user_id)
{ {
// If we can't insert this user then continue to the next one to avoid inconsistant data // If we can't insert this user then continue to the next one to avoid inconsistant data
$this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__); $this->p_master->db_error('Unable to insert bot into users table', phpbb::$db->sql_error_sql, __LINE__, __FILE__);
continue; continue;
} }

View file

@ -414,9 +414,9 @@ class install_update extends module
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . STYLES_THEME_TABLE . " FROM ' . STYLES_THEME_TABLE . "
WHERE theme_name = 'prosilver'"; WHERE theme_name = 'prosilver'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$theme = $db->sql_fetchrow($result); $theme = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($theme) if ($theme)
{ {
@ -461,17 +461,17 @@ class install_update extends module
'theme_data' => $theme['theme_data'] 'theme_data' => $theme['theme_data']
); );
$sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE theme_id = ' . $theme['theme_id']; WHERE theme_id = ' . $theme['theme_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); phpbb::$acm->destroy_sql(STYLES_THEME_TABLE);
} }
} }
$db->sql_return_on_error(true); phpbb::$db->sql_return_on_error(true);
$db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); phpbb::$db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'");
$db->sql_return_on_error(false); phpbb::$db->sql_return_on_error(false);
phpbb::$acm->purge(); phpbb::$acm->purge();
} }
@ -1513,14 +1513,14 @@ class install_update extends module
$sql = 'SELECT template_name, template_path $sql = 'SELECT template_name, template_path
FROM ' . STYLES_TEMPLATE_TABLE . " FROM ' . STYLES_TEMPLATE_TABLE . "
WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')"; WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$templates = array(); $templates = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$templates[] = $row; $templates[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($templates)) if (sizeof($templates))
{ {

View file

@ -85,9 +85,9 @@ if ($post_id)
$sql = 'SELECT topic_id, forum_id $sql = 'SELECT topic_id, forum_id
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE post_id = $post_id"; WHERE post_id = $post_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$topic_id = (int) $row['topic_id']; $topic_id = (int) $row['topic_id'];
$forum_id = (int) ($row['forum_id']) ? $row['forum_id'] : $forum_id; $forum_id = (int) ($row['forum_id']) ? $row['forum_id'] : $forum_id;
@ -97,9 +97,9 @@ else if ($topic_id)
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . " FROM ' . TOPICS_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$forum_id = (int) $row['forum_id']; $forum_id = (int) $row['forum_id'];
} }
@ -369,7 +369,7 @@ function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
) )
), ),
'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids) 'WHERE' => phpbb::$db->sql_in_set('t.topic_id', $topic_ids)
); );
if ($read_tracking && phpbb::$config['load_db_lastread']) if ($read_tracking && phpbb::$config['load_db_lastread'])
@ -387,10 +387,10 @@ function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
); );
} }
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = phpbb::$db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!$row['forum_id']) if (!$row['forum_id'])
{ {
@ -407,7 +407,7 @@ function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
$topics[$row['topic_id']] = $row; $topics[$row['topic_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($cache_topic_ids as $id) foreach ($cache_topic_ids as $id)
@ -449,7 +449,7 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
) )
), ),
'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . ' 'WHERE' => phpbb::$db->sql_in_set('p.post_id', $post_ids) . '
AND u.user_id = p.poster_id AND u.user_id = p.poster_id
AND t.topic_id = p.topic_id', AND t.topic_id = p.topic_id',
); );
@ -469,11 +469,11 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
); );
} }
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = phpbb::$db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
unset($sql_array); unset($sql_array);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!$row['forum_id']) if (!$row['forum_id'])
{ {
@ -494,7 +494,7 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
$rowset[$row['post_id']] = $row; $rowset[$row['post_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return $rowset; return $rowset;
} }
@ -529,10 +529,10 @@ function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
$sql = "SELECT f.* $read_tracking_select $sql = "SELECT f.* $read_tracking_select
FROM " . FORUMS_TABLE . " f$read_tracking_join FROM " . FORUMS_TABLE . " f$read_tracking_join
WHERE " . $db->sql_in_set('f.forum_id', $forum_id); WHERE " . phpbb::$db->sql_in_set('f.forum_id', $forum_id);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($acl_list && !phpbb::$acl->acl_gets($acl_list, $row['forum_id'])) if ($acl_list && !phpbb::$acl->acl_gets($acl_list, $row['forum_id']))
{ {
@ -546,7 +546,7 @@ function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
$rowset[$row['forum_id']] = $row; $rowset[$row['forum_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return $rowset; return $rowset;
} }
@ -604,7 +604,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
$sql = 'SELECT COUNT(post_id) AS total $sql = 'SELECT COUNT(post_id) AS total
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' $where_sql " . phpbb::$db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
AND post_approved = 0'; AND post_approved = 0';
if ($min_time) if ($min_time)
@ -620,7 +620,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
$sql = 'SELECT COUNT(topic_id) AS total $sql = 'SELECT COUNT(topic_id) AS total
FROM ' . TOPICS_TABLE . " FROM ' . TOPICS_TABLE . "
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' $where_sql " . phpbb::$db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
AND topic_approved = 0'; AND topic_approved = 0';
if ($min_time) if ($min_time)
@ -646,7 +646,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
} }
else else
{ {
$where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true); $where_sql .= ' ' . phpbb::$db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true);
} }
if ($mode == 'reports') if ($mode == 'reports')
@ -672,7 +672,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
$sql = 'SELECT COUNT(log_id) AS total $sql = 'SELECT COUNT(log_id) AS total
FROM ' . LOG_TABLE . " FROM ' . LOG_TABLE . "
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . ' $where_sql " . phpbb::$db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . '
AND log_time >= ' . $min_time . ' AND log_time >= ' . $min_time . '
AND log_type = ' . LOG_MOD; AND log_type = ' . LOG_MOD;
break; break;
@ -732,9 +732,9 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts')) || $where_sql != 'WHERE') if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts')) || $where_sql != 'WHERE')
{ {
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total'); $total = (int) phpbb::$db->sql_fetchfield('total');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -763,13 +763,13 @@ function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = fa
} }
$sql = "SELECT $sql_id, forum_id FROM $table $sql = "SELECT $sql_id, forum_id FROM $table
WHERE " . $db->sql_in_set($sql_id, $ids); WHERE " . phpbb::$db->sql_in_set($sql_id, $ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ids = array(); $ids = array();
$forum_id = false; $forum_id = false;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($acl_list && $row['forum_id'] && !phpbb::$acl->acl_gets($acl_list, $row['forum_id'])) if ($acl_list && $row['forum_id'] && !phpbb::$acl->acl_gets($acl_list, $row['forum_id']))
{ {
@ -812,7 +812,7 @@ function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = fa
$ids[] = $row[$sql_id]; $ids[] = $row[$sql_id];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($ids)) if (!sizeof($ids))
{ {

View file

@ -121,9 +121,9 @@ switch ($mode)
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_name = 'ADMINISTRATORS'"; WHERE group_name = 'ADMINISTRATORS'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$admin_group_id = (int) $db->sql_fetchfield('group_id'); $admin_group_id = (int) phpbb::$db->sql_fetchfield('group_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Get group memberships for the admin id ary... // Get group memberships for the admin id ary...
$admin_memberships = group_memberships($admin_group_id, $admin_id_ary); $admin_memberships = group_memberships($admin_group_id, $admin_id_ary);
@ -142,16 +142,16 @@ switch ($mode)
$sql = 'SELECT forum_id, forum_name $sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE; FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forums = array(); $forums = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forums[$row['forum_id']] = $row['forum_name']; $forums[$row['forum_id']] = $row['forum_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = $db->sql_build_query('SELECT', array( $sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id', 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id',
'FROM' => array( 'FROM' => array(
@ -166,14 +166,14 @@ switch ($mode)
) )
), ),
'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . ' 'WHERE' => phpbb::$db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . '
AND u.group_id = g.group_id', AND u.group_id = g.group_id',
'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC' 'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC'
)); ));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod'; $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';
@ -259,7 +259,7 @@ switch ($mode)
'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
)); ));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'PM_IMG' => phpbb::$user->img('icon_contact_pm', phpbb::$user->lang['SEND_PRIVATE_MESSAGE'])) 'PM_IMG' => phpbb::$user->img('icon_contact_pm', phpbb::$user->lang['SEND_PRIVATE_MESSAGE']))
@ -310,9 +310,9 @@ switch ($mode)
FROM " . USERS_TABLE . " FROM " . USERS_TABLE . "
WHERE user_id = $user_id WHERE user_id = $user_id
AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')'; AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -404,10 +404,10 @@ switch ($mode)
// Get user... // Get user...
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id"); WHERE ' . (($username) ? "username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$member = $db->sql_fetchrow($result); $member = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$member) if (!$member)
{ {
@ -437,14 +437,14 @@ switch ($mode)
AND g.group_id = ug.group_id" . ((!phpbb::$acl->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . ' AND g.group_id = ug.group_id" . ((!phpbb::$acl->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
AND ug.user_pending = 0 AND ug.user_pending = 0
ORDER BY g.group_type, g.group_name'; ORDER BY g.group_type, g.group_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_options = ''; $group_options = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; $group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// What colour is the zebra // What colour is the zebra
$sql = 'SELECT friend, foe $sql = 'SELECT friend, foe
@ -452,20 +452,20 @@ switch ($mode)
WHERE zebra_id = ' . $user_id . ' WHERE zebra_id = ' . $user_id . '
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$foe = ($row['foe']) ? true : false; $foe = ($row['foe']) ? true : false;
$friend = ($row['friend']) ? true : false; $friend = ($row['friend']) ? true : false;
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (phpbb::$config['load_onlinetrack']) if (phpbb::$config['load_onlinetrack'])
{ {
$sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
FROM ' . SESSIONS_TABLE . " FROM ' . SESSIONS_TABLE . "
WHERE session_user_id = $user_id"; WHERE session_user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
$member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
@ -534,9 +534,9 @@ switch ($mode)
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $user_id . ' WHERE poster_id = ' . $user_id . '
AND post_approved = 0'; AND post_approved = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $member['posts_in_queue'] = (int) phpbb::$db->sql_fetchfield('posts_in_queue');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -673,9 +673,9 @@ switch ($mode)
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE user_id = $user_id WHERE user_id = $user_id
AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')'; AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -694,9 +694,9 @@ switch ($mode)
$sql = 'SELECT forum_id, topic_title $sql = 'SELECT forum_id, topic_title
FROM ' . TOPICS_TABLE . " FROM ' . TOPICS_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -784,7 +784,7 @@ switch ($mode)
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_emailtime = ' . time() . ' SET user_emailtime = ' . time() . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);
$messenger = new messenger(false); $messenger = new messenger(false);
@ -992,13 +992,13 @@ switch ($mode)
$s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
} }
$sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : ''; $sql_where .= ($username) ? ' AND u.username_clean ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, utf8_clean_string($username))) : '';
$sql_where .= ($email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : ''; $sql_where .= ($email) ? ' AND u.user_email ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, $email)) . ' ' : '';
$sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : ''; $sql_where .= ($icq) ? ' AND u.user_icq ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, $icq)) . ' ' : '';
$sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : ''; $sql_where .= ($aim) ? ' AND u.user_aim ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, $aim)) . ' ' : '';
$sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : ''; $sql_where .= ($yahoo) ? ' AND u.user_yim ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, $yahoo)) . ' ' : '';
$sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : ''; $sql_where .= ($msn) ? ' AND u.user_msnm ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, $msn)) . ' ' : '';
$sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : ''; $sql_where .= ($jabber) ? ' AND u.user_jabber ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, $jabber)) . ' ' : '';
$sql_where .= (is_numeric($count)) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; $sql_where .= (is_numeric($count)) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
$sql_where .= (sizeof($joined) > 1) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : ''; $sql_where .= (sizeof($joined) > 1) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
$sql_where .= (phpbb::$acl->acl_get('u_viewonline') && sizeof($active) > 1) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : ''; $sql_where .= (phpbb::$acl->acl_get('u_viewonline') && sizeof($active) > 1) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
@ -1026,7 +1026,7 @@ switch ($mode)
} }
else else
{ {
$ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'"; $ips = "'" . str_replace('*', '%', phpbb::$db->sql_escape($ipdomain)) . "'";
} }
if ($ips === false) if ($ips === false)
@ -1042,18 +1042,18 @@ switch ($mode)
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips) WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips)
AND forum_id IN (0, " . implode(', ', $ip_forums) . ')'; AND forum_id IN (0, " . implode(', ', $ip_forums) . ')';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ip_sql = array(); $ip_sql = array();
do do
{ {
$ip_sql[] = $row['poster_id']; $ip_sql[] = $row['poster_id'];
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
$sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql); $sql_where .= ' AND ' . phpbb::$db->sql_in_set('u.user_id', $ip_sql);
} }
else else
{ {
@ -1062,7 +1062,7 @@ switch ($mode)
} }
unset($ip_forums); unset($ip_forums);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
} }
@ -1073,12 +1073,12 @@ switch ($mode)
{ {
for ($i = 97; $i < 123; $i++) for ($i = 97; $i < 123; $i++)
{ {
$sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char); $sql_where .= ' AND u.username_clean NOT ' . phpbb::$db->sql_like_expression(chr($i) . phpbb::$db->any_char);
} }
} }
else if ($first_char) else if ($first_char)
{ {
$sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char); $sql_where .= ' AND u.username_clean ' . phpbb::$db->sql_like_expression(substr($first_char, 0, 1) . phpbb::$db->any_char);
} }
// Are we looking at a usergroup? If so, fetch additional info // Are we looking at a usergroup? If so, fetch additional info
@ -1090,9 +1090,9 @@ switch ($mode)
FROM ' . GROUPS_TABLE . ' g FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . phpbb::$user->data['user_id'] . " AND ug.group_id = $group_id) LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . phpbb::$user->data['user_id'] . " AND ug.group_id = $group_id)
WHERE g.group_id = $group_id"; WHERE g.group_id = $group_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_row = $db->sql_fetchrow($result); $group_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$group_row) if (!$group_row)
{ {
@ -1191,9 +1191,9 @@ switch ($mode)
FROM ' . USERS_TABLE . " u$sql_from FROM ' . USERS_TABLE . " u$sql_from
WHERE u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ") WHERE u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ")
$sql_where"; $sql_where";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users'); $total_users = (int) phpbb::$db->sql_fetchfield('total_users');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -1306,14 +1306,14 @@ switch ($mode)
$sql .= ' ORDER BY g.group_name ASC'; $sql .= ' ORDER BY g.group_name ASC';
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$group_ids[] = $row['group_id']; $group_ids[] = $row['group_id'];
$s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($group_selected !== 0 && !in_array($group_selected, $group_ids)) if ($group_selected !== 0 && !in_array($group_selected, $group_ids))
{ {
@ -1355,14 +1355,14 @@ switch ($mode)
WHERE u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ") WHERE u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ")
$sql_where $sql_where
ORDER BY $order_by"; ORDER BY $order_by";
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$user_list = array(); $user_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$user_list[] = (int) $row['user_id']; $user_list[] = (int) $row['user_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$leaders_set = false; $leaders_set = false;
// So, did we get any users? // So, did we get any users?
if (sizeof($user_list)) if (sizeof($user_list))
@ -1371,16 +1371,16 @@ switch ($mode)
$sql = 'SELECT session_user_id, MAX(session_time) AS session_time $sql = 'SELECT session_user_id, MAX(session_time) AS session_time
FROM ' . SESSIONS_TABLE . ' FROM ' . SESSIONS_TABLE . '
WHERE session_time >= ' . (time() - phpbb::$config['session_length']) . ' WHERE session_time >= ' . (time() - phpbb::$config['session_length']) . '
AND ' . $db->sql_in_set('session_user_id', $user_list) . ' AND ' . phpbb::$db->sql_in_set('session_user_id', $user_list) . '
GROUP BY session_user_id'; GROUP BY session_user_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$session_times = array(); $session_times = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$session_times[$row['session_user_id']] = $row['session_time']; $session_times[$row['session_user_id']] = $row['session_time'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Do the SQL thang // Do the SQL thang
if ($mode == 'group') if ($mode == 'group')
@ -1389,26 +1389,26 @@ switch ($mode)
$sql_select $sql_select
FROM " . USERS_TABLE . " u FROM " . USERS_TABLE . " u
$sql_from $sql_from
WHERE " . $db->sql_in_set('u.user_id', $user_list) . " WHERE " . phpbb::$db->sql_in_set('u.user_id', $user_list) . "
$sql_where_data"; $sql_where_data";
} }
else else
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $user_list); WHERE ' . phpbb::$db->sql_in_set('user_id', $user_list);
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$id_cache = array(); $id_cache = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0; $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0;
$row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit']; $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'];
$id_cache[$row['user_id']] = $row; $id_cache[$row['user_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Load custom profile fields // Load custom profile fields
if (phpbb::$config['load_cpf_memberlist']) if (phpbb::$config['load_cpf_memberlist'])

View file

@ -82,14 +82,14 @@ class acp_attachments
FROM ' . EXTENSION_GROUPS_TABLE . ' FROM ' . EXTENSION_GROUPS_TABLE . '
WHERE cat_id > 0 WHERE cat_id > 0
ORDER BY cat_id'; ORDER BY cat_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_assigned_groups = array(); $s_assigned_groups = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$s_assigned_groups[$row['cat_id']][] = $row['group_name']; $s_assigned_groups[$row['cat_id']][] = $row['group_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$l_legend_cat_images = phpbb::$user->lang['SETTINGS_CAT_IMAGES'] . ' [' . phpbb::$user->lang['ASSIGNED_GROUP'] . ': ' . ((!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : phpbb::$user->lang['NO_EXT_GROUP']) . ']'; $l_legend_cat_images = phpbb::$user->lang['SETTINGS_CAT_IMAGES'] . ' [' . phpbb::$user->lang['ASSIGNED_GROUP'] . ': ' . ((!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : phpbb::$user->lang['NO_EXT_GROUP']) . ']';
@ -214,12 +214,12 @@ class acp_attachments
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . SITELIST_TABLE; FROM ' . SITELIST_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$defined_ips = ''; $defined_ips = '';
$ips = array(); $ips = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$value = ($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']; $value = ($row['site_ip']) ? $row['site_ip'] : $row['site_hostname'];
if ($value) if ($value)
@ -228,7 +228,7 @@ class acp_attachments
$ips[$row['site_id']] = $value; $ips[$row['site_id']] = $value;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'], 'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'],
@ -314,21 +314,21 @@ class acp_attachments
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . EXTENSIONS_TABLE . ' FROM ' . EXTENSIONS_TABLE . '
ORDER BY extension_id'; ORDER BY extension_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['group_id'] != $extensions[$row['extension_id']]['group_id']) if ($row['group_id'] != $extensions[$row['extension_id']]['group_id'])
{ {
$sql = 'UPDATE ' . EXTENSIONS_TABLE . ' $sql = 'UPDATE ' . EXTENSIONS_TABLE . '
SET group_id = ' . (int) $extensions[$row['extension_id']]['group_id'] . ' SET group_id = ' . (int) $extensions[$row['extension_id']]['group_id'] . '
WHERE extension_id = ' . $row['extension_id']; WHERE extension_id = ' . $row['extension_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_ATTACH_EXT_UPDATE', $row['extension']); add_log('admin', 'LOG_ATTACH_EXT_UPDATE', $row['extension']);
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Delete Extension? // Delete Extension?
$extension_id_list = request_var('extension_id_list', array(0)); $extension_id_list = request_var('extension_id_list', array(0));
@ -337,20 +337,20 @@ class acp_attachments
{ {
$sql = 'SELECT extension $sql = 'SELECT extension
FROM ' . EXTENSIONS_TABLE . ' FROM ' . EXTENSIONS_TABLE . '
WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); WHERE ' . phpbb::$db->sql_in_set('extension_id', $extension_id_list);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$extension_list = ''; $extension_list = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$extension_list .= ($extension_list == '') ? $row['extension'] : ', ' . $row['extension']; $extension_list .= ($extension_list == '') ? $row['extension'] : ', ' . $row['extension'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'DELETE $sql = 'DELETE
FROM ' . EXTENSIONS_TABLE . ' FROM ' . EXTENSIONS_TABLE . '
WHERE ' . $db->sql_in_set('extension_id', $extension_id_list); WHERE ' . phpbb::$db->sql_in_set('extension_id', $extension_id_list);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_ATTACH_EXT_DEL', $extension_list); add_log('admin', 'LOG_ATTACH_EXT_DEL', $extension_list);
} }
@ -367,14 +367,14 @@ class acp_attachments
{ {
$sql = 'SELECT extension_id $sql = 'SELECT extension_id
FROM ' . EXTENSIONS_TABLE . " FROM ' . EXTENSIONS_TABLE . "
WHERE extension = '" . $db->sql_escape($add_extension) . "'"; WHERE extension = '" . phpbb::$db->sql_escape($add_extension) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$error[] = sprintf(phpbb::$user->lang['EXTENSION_EXIST'], $add_extension); $error[] = sprintf(phpbb::$user->lang['EXTENSION_EXIST'], $add_extension);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($error)) if (!sizeof($error))
{ {
@ -383,7 +383,7 @@ class acp_attachments
'extension' => $add_extension 'extension' => $add_extension
); );
$db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . EXTENSIONS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
add_log('admin', 'LOG_ATTACH_EXT_ADD', $add_extension); add_log('admin', 'LOG_ATTACH_EXT_ADD', $add_extension);
} }
} }
@ -406,9 +406,9 @@ class acp_attachments
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . EXTENSIONS_TABLE . ' FROM ' . EXTENSIONS_TABLE . '
ORDER BY group_id, extension'; ORDER BY group_id, extension';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$old_group_id = $row['group_id']; $old_group_id = $row['group_id'];
do do
@ -429,9 +429,9 @@ class acp_attachments
'GROUP_OPTIONS' => $this->group_select('group_select[]', $row['group_id'])) 'GROUP_OPTIONS' => $this->group_select('group_select[]', $row['group_id']))
); );
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
break; break;
@ -459,9 +459,9 @@ class acp_attachments
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . EXTENSION_GROUPS_TABLE . " FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ext_row = $db->sql_fetchrow($result); $ext_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$ext_row) if (!$ext_row)
{ {
@ -486,13 +486,13 @@ class acp_attachments
{ {
$sql = 'SELECT group_name $sql = 'SELECT group_name
FROM ' . EXTENSION_GROUPS_TABLE; FROM ' . EXTENSION_GROUPS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ext_row = $db->sql_fetchrow($result); $ext_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$clean_group_name = utf8_clean_string($new_group_name); $clean_group_name = utf8_clean_string($new_group_name);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (utf8_clean_string($row['group_name']) === $clean_group_name) if (utf8_clean_string($row['group_name']) === $clean_group_name)
{ {
@ -500,7 +500,7 @@ class acp_attachments
break; break;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!sizeof($error)) if (!sizeof($error))
@ -542,14 +542,14 @@ class acp_attachments
// @TODO: rewrite with the new param db functions // @TODO: rewrite with the new param db functions
$sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET '; $sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET ';
$sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary); $sql .= phpbb::$db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary);
$sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : ''; $sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : '';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if ($action == 'add') if ($action == 'add')
{ {
$group_id = $db->sql_nextid(); $group_id = phpbb::$db->sql_nextid();
} }
add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name); add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name);
@ -562,15 +562,15 @@ class acp_attachments
$sql = 'UPDATE ' . EXTENSIONS_TABLE . " $sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = 0 SET group_id = 0
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if (sizeof($extension_list)) if (sizeof($extension_list))
{ {
$sql = 'UPDATE ' . EXTENSIONS_TABLE . " $sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = $group_id SET group_id = $group_id
WHERE " . $db->sql_in_set('extension_id', $extension_list); WHERE " . phpbb::$db->sql_in_set('extension_id', $extension_list);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
phpbb::$acm->destroy('extensions'); phpbb::$acm->destroy('extensions');
@ -602,20 +602,20 @@ class acp_attachments
$sql = 'SELECT group_name $sql = 'SELECT group_name
FROM ' . EXTENSION_GROUPS_TABLE . " FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_name = (string) $db->sql_fetchfield('group_name'); $group_name = (string) phpbb::$db->sql_fetchfield('group_name');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'DELETE $sql = 'DELETE
FROM ' . EXTENSION_GROUPS_TABLE . " FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Set corresponding Extensions to a pending Group // Set corresponding Extensions to a pending Group
$sql = 'UPDATE ' . EXTENSIONS_TABLE . " $sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = 0 SET group_id = 0
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $group_name); add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $group_name);
@ -645,9 +645,9 @@ class acp_attachments
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . EXTENSION_GROUPS_TABLE . " FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ext_group_row = $db->sql_fetchrow($result); $ext_group_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$forum_ids = (!$ext_group_row['allowed_forums']) ? array() : unserialize(trim($ext_group_row['allowed_forums'])); $forum_ids = (!$ext_group_row['allowed_forums']) ? array() : unserialize(trim($ext_group_row['allowed_forums']));
@ -676,9 +676,9 @@ class acp_attachments
WHERE group_id = $group_id WHERE group_id = $group_id
OR group_id = 0 OR group_id = 0
ORDER BY extension"; ORDER BY extension";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$extensions = $db->sql_fetchrowset($result); $extensions = phpbb::$db->sql_fetchrowset($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($ext_group_row['max_filesize'] == 0) if ($ext_group_row['max_filesize'] == 0)
{ {
@ -771,13 +771,13 @@ class acp_attachments
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC'; ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600); $result = phpbb::$db->sql_query($sql, 600);
$right = $cat_right = $padding_inc = 0; $right = $cat_right = $padding_inc = 0;
$padding = $forum_list = $holding = ''; $padding = $forum_list = $holding = '';
$padding_store = array('0' => ''); $padding_store = array('0' => '');
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
{ {
@ -830,7 +830,7 @@ class acp_attachments
$s_forum_id_options .= $holding; $s_forum_id_options .= $holding;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
unset($padding_store); unset($padding_store);
$template->assign_vars(array( $template->assign_vars(array(
@ -843,10 +843,10 @@ class acp_attachments
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . EXTENSION_GROUPS_TABLE . ' FROM ' . EXTENSION_GROUPS_TABLE . '
ORDER BY allow_group DESC, allow_in_pm DESC, group_name'; ORDER BY allow_group DESC, allow_in_pm DESC, group_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$old_allow_group = $old_allow_pm = 1; $old_allow_group = $old_allow_pm = 1;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$s_add_spacer = ($old_allow_group != $row['allow_group'] || $old_allow_pm != $row['allow_in_pm']) ? true : false; $s_add_spacer = ($old_allow_group != $row['allow_group'] || $old_allow_pm != $row['allow_in_pm']) ? true : false;
@ -866,7 +866,7 @@ class acp_attachments
$old_allow_group = $row['allow_group']; $old_allow_group = $row['allow_group'];
$old_allow_pm = $row['allow_in_pm']; $old_allow_pm = $row['allow_in_pm'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
break; break;
@ -882,12 +882,12 @@ class acp_attachments
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' WHERE ' . phpbb::$db->sql_in_set('attach_id', $delete_files) . '
AND is_orphan = 1'; AND is_orphan = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$delete_files = array(); $delete_files = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
phpbb_unlink($row['physical_filename'], 'file'); phpbb_unlink($row['physical_filename'], 'file');
@ -898,14 +898,14 @@ class acp_attachments
$delete_files[$row['attach_id']] = $row['real_filename']; $delete_files[$row['attach_id']] = $row['real_filename'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (sizeof($delete_files)) if (sizeof($delete_files))
{ {
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files)); WHERE ' . phpbb::$db->sql_in_set('attach_id', array_keys($delete_files));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_ATTACH_ORPHAN_DEL', implode(', ', $delete_files)); add_log('admin', 'LOG_ATTACH_ORPHAN_DEL', implode(', ', $delete_files));
$notify[] = sprintf(phpbb::$user->lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files)); $notify[] = sprintf(phpbb::$user->lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files));
@ -927,36 +927,36 @@ class acp_attachments
$sql = 'SELECT forum_id, forum_name $sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE; FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_names = array(); $forum_names = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_names[$row['forum_id']] = $row['forum_name']; $forum_names[$row['forum_id']] = $row['forum_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT forum_id, topic_id, post_id, poster_id $sql = 'SELECT forum_id, topic_id, post_id, poster_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('post_id', $upload_list); WHERE ' . phpbb::$db->sql_in_set('post_id', $upload_list);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_info = array(); $post_info = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_info[$row['post_id']] = $row; $post_info[$row['post_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Select those attachments we want to change... // Select those attachments we want to change...
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($upload_list)) . ' WHERE ' . phpbb::$db->sql_in_set('attach_id', array_keys($upload_list)) . '
AND is_orphan = 1'; AND is_orphan = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$files_added = $space_taken = 0; $files_added = $space_taken = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_row = $post_info[$upload_list[$row['attach_id']]]; $post_row = $post_info[$upload_list[$row['attach_id']]];
@ -981,26 +981,26 @@ class acp_attachments
); );
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE attach_id = ' . $row['attach_id']; WHERE attach_id = ' . $row['attach_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 1 SET post_attachment = 1
WHERE post_id = ' . $post_row['post_id']; WHERE post_id = ' . $post_row['post_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_attachment = 1 SET topic_attachment = 1
WHERE topic_id = ' . $post_row['topic_id']; WHERE topic_id = ' . $post_row['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$space_taken += $row['filesize']; $space_taken += $row['filesize'];
$files_added++; $files_added++;
add_log('admin', 'LOG_ATTACH_FILEUPLOAD', $post_row['post_id'], $row['real_filename']); add_log('admin', 'LOG_ATTACH_FILEUPLOAD', $post_row['post_id'], $row['real_filename']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($files_added) if ($files_added)
{ {
@ -1020,9 +1020,9 @@ class acp_attachments
WHERE is_orphan = 1 WHERE is_orphan = 1
AND filetime < ' . (time() - 3*60*60) . ' AND filetime < ' . (time() - 3*60*60) . '
ORDER BY filetime DESC'; ORDER BY filetime DESC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('orphan', array( $template->assign_block_vars('orphan', array(
'FILESIZE' => get_formatted_filesize($row['filesize']), 'FILESIZE' => get_formatted_filesize($row['filesize']),
@ -1034,7 +1034,7 @@ class acp_attachments
'U_FILE' => append_sid('download/file', 'mode=view&amp;id=' . $row['attach_id'])) 'U_FILE' => append_sid('download/file', 'mode=view&amp;id=' . $row['attach_id']))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
break; break;
} }
@ -1075,11 +1075,11 @@ class acp_attachments
$sql = 'SELECT cat_id $sql = 'SELECT cat_id
FROM ' . EXTENSION_GROUPS_TABLE . ' FROM ' . EXTENSION_GROUPS_TABLE . '
WHERE group_id = ' . (int) $group_id; WHERE group_id = ' . (int) $group_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$cat_type = (!($row = $db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id']; $cat_type = (!($row = phpbb::$db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id'];
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -1109,14 +1109,14 @@ class acp_attachments
$sql = 'SELECT group_id, group_name $sql = 'SELECT group_id, group_name
FROM ' . EXTENSION_GROUPS_TABLE . ' FROM ' . EXTENSION_GROUPS_TABLE . '
ORDER BY group_name'; ORDER BY group_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_name = array(); $group_name = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$group_name[] = $row; $group_name[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$row['group_id'] = 0; $row['group_id'] = 0;
$row['group_name'] = phpbb::$user->lang['NOT_ASSIGNED']; $row['group_name'] = phpbb::$user->lang['NOT_ASSIGNED'];
@ -1309,9 +1309,9 @@ class acp_attachments
$sql = 'SELECT site_ip, site_hostname $sql = 'SELECT site_ip, site_hostname
FROM ' . SITELIST_TABLE . " FROM ' . SITELIST_TABLE . "
WHERE ip_exclude = $ip_exclude"; WHERE ip_exclude = $ip_exclude";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$iplist_tmp = array(); $iplist_tmp = array();
$hostlist_tmp = array(); $hostlist_tmp = array();
@ -1337,14 +1337,14 @@ class acp_attachments
} }
// break; // break;
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
$iplist = array_unique(array_diff($iplist, $iplist_tmp)); $iplist = array_unique(array_diff($iplist, $iplist_tmp));
$hostlist = array_unique(array_diff($hostlist, $hostlist_tmp)); $hostlist = array_unique(array_diff($hostlist, $hostlist_tmp));
unset($iplist_tmp); unset($iplist_tmp);
unset($hostlist_tmp); unset($hostlist_tmp);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($iplist)) if (sizeof($iplist))
{ {
@ -1352,7 +1352,7 @@ class acp_attachments
{ {
$sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_ip, ip_exclude) $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_ip, ip_exclude)
VALUES ($ip_entry, $ip_exclude)"; VALUES ($ip_entry, $ip_exclude)";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1362,7 +1362,7 @@ class acp_attachments
{ {
$sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_hostname, ip_exclude) $sql = 'INSERT INTO ' . SITELIST_TABLE . " (site_hostname, ip_exclude)
VALUES ($host_entry, $ip_exclude)"; VALUES ($host_entry, $ip_exclude)";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1386,18 +1386,18 @@ class acp_attachments
// Grab details of ips for logging information later // Grab details of ips for logging information later
$sql = 'SELECT site_ip, site_hostname $sql = 'SELECT site_ip, site_hostname
FROM ' . SITELIST_TABLE . ' FROM ' . SITELIST_TABLE . '
WHERE ' . $db->sql_in_set('site_id', $unip_sql); WHERE ' . phpbb::$db->sql_in_set('site_id', $unip_sql);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$l_unip_list .= (($l_unip_list != '') ? ', ' : '') . (($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']); $l_unip_list .= (($l_unip_list != '') ? ', ' : '') . (($row['site_ip']) ? $row['site_ip'] : $row['site_hostname']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'DELETE FROM ' . SITELIST_TABLE . ' $sql = 'DELETE FROM ' . SITELIST_TABLE . '
WHERE ' . $db->sql_in_set('site_id', $unip_sql); WHERE ' . phpbb::$db->sql_in_set('site_id', $unip_sql);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_DOWNLOAD_REMOVE_IP', $l_unip_list); add_log('admin', 'LOG_DOWNLOAD_REMOVE_IP', $l_unip_list);
} }

View file

@ -166,12 +166,12 @@ class acp_ban
AND ban_email <> ''"; AND ban_email <> ''";
break; break;
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$banned_options = ''; $banned_options = '';
$ban_length = $ban_reasons = $ban_give_reasons = array(); $ban_length = $ban_reasons = $ban_give_reasons = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$banned_options .= '<option' . (($row['ban_exclude']) ? ' class="sep"' : '') . ' value="' . $row['ban_id'] . '">' . $row[$field] . '</option>'; $banned_options .= '<option' . (($row['ban_exclude']) ? ' class="sep"' : '') . ' value="' . $row['ban_id'] . '">' . $row[$field] . '</option>';
@ -181,7 +181,7 @@ class acp_ban
$ban_reasons[$row['ban_id']] = $row['ban_reason']; $ban_reasons[$row['ban_id']] = $row['ban_reason'];
$ban_give_reasons[$row['ban_id']] = $row['ban_give_reason']; $ban_give_reasons[$row['ban_id']] = $row['ban_give_reason'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($ban_length)) if (sizeof($ban_length))
{ {

View file

@ -49,9 +49,9 @@ class acp_bbcodes
$sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline $sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
WHERE bbcode_id = ' . $bbcode_id; WHERE bbcode_id = ' . $bbcode_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -68,9 +68,9 @@ class acp_bbcodes
$sql = 'SELECT bbcode_id, bbcode_tag $sql = 'SELECT bbcode_id, bbcode_tag
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
WHERE bbcode_id = ' . $bbcode_id; WHERE bbcode_id = ' . $bbcode_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -130,10 +130,10 @@ class acp_bbcodes
{ {
$sql = 'SELECT 1 as test $sql = 'SELECT 1 as test
FROM ' . BBCODES_TABLE . " FROM ' . BBCODES_TABLE . "
WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'"; WHERE LOWER(bbcode_tag) = '" . phpbb::$db->sql_escape(strtolower($data['bbcode_tag'])) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$info = $db->sql_fetchrow($result); $info = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Grab the end, interrogate the last closing tag // Grab the end, interrogate the last closing tag
if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded))) if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded)))
@ -188,9 +188,9 @@ class acp_bbcodes
{ {
$sql = 'SELECT MAX(bbcode_id) as max_bbcode_id $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id
FROM ' . BBCODES_TABLE; FROM ' . BBCODES_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -214,7 +214,7 @@ class acp_bbcodes
$sql_ary['bbcode_id'] = (int) $bbcode_id; $sql_ary['bbcode_id'] = (int) $bbcode_id;
$db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . BBCODES_TABLE . phpbb::$db->sql_build_array('INSERT', $sql_ary));
phpbb::$acm->destroy_sql(BBCODES_TABLE); phpbb::$acm->destroy_sql(BBCODES_TABLE);
$lang = 'BBCODE_ADDED'; $lang = 'BBCODE_ADDED';
@ -223,9 +223,9 @@ class acp_bbcodes
else else
{ {
$sql = 'UPDATE ' . BBCODES_TABLE . ' $sql = 'UPDATE ' . BBCODES_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE bbcode_id = ' . $bbcode_id; WHERE bbcode_id = ' . $bbcode_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy_sql(BBCODES_TABLE); phpbb::$acm->destroy_sql(BBCODES_TABLE);
$lang = 'BBCODE_EDITED'; $lang = 'BBCODE_EDITED';
@ -243,15 +243,15 @@ class acp_bbcodes
$sql = 'SELECT bbcode_tag $sql = 'SELECT bbcode_tag
FROM ' . BBCODES_TABLE . " FROM ' . BBCODES_TABLE . "
WHERE bbcode_id = $bbcode_id"; WHERE bbcode_id = $bbcode_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
if (confirm_box(true)) if (confirm_box(true))
{ {
$db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id"); phpbb::$db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id");
phpbb::$acm->destroy_sql(BBCODES_TABLE); phpbb::$acm->destroy_sql(BBCODES_TABLE);
add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']); add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']);
} }
@ -276,9 +276,9 @@ class acp_bbcodes
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
ORDER BY bbcode_tag'; ORDER BY bbcode_tag';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('bbcodes', array( $template->assign_block_vars('bbcodes', array(
'BBCODE_TAG' => $row['bbcode_tag'], 'BBCODE_TAG' => $row['bbcode_tag'],
@ -286,7 +286,7 @@ class acp_bbcodes
'U_DELETE' => $this->u_action . '&amp;action=delete&amp;bbcode=' . $row['bbcode_id']) 'U_DELETE' => $this->u_action . '&amp;action=delete&amp;bbcode=' . $row['bbcode_id'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/* /*

View file

@ -59,7 +59,7 @@ class acp_bots
$sql = 'UPDATE ' . BOTS_TABLE . " $sql = 'UPDATE ' . BOTS_TABLE . "
SET bot_active = 1 SET bot_active = 1
WHERE bot_id $sql_id"; WHERE bot_id $sql_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
phpbb::$acm->destroy('bots'); phpbb::$acm->destroy('bots');
@ -73,7 +73,7 @@ class acp_bots
$sql = 'UPDATE ' . BOTS_TABLE . " $sql = 'UPDATE ' . BOTS_TABLE . "
SET bot_active = 0 SET bot_active = 0
WHERE bot_id $sql_id"; WHERE bot_id $sql_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
phpbb::$acm->destroy('bots'); phpbb::$acm->destroy('bots');
@ -90,21 +90,21 @@ class acp_bots
$sql = 'SELECT bot_name, user_id $sql = 'SELECT bot_name, user_id
FROM ' . BOTS_TABLE . " FROM ' . BOTS_TABLE . "
WHERE bot_id $sql_id"; WHERE bot_id $sql_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_id_ary = $bot_name_ary = array(); $user_id_ary = $bot_name_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$user_id_ary[] = (int) $row['user_id']; $user_id_ary[] = (int) $row['user_id'];
$bot_name_ary[] = $row['bot_name']; $bot_name_ary[] = $row['bot_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$sql = 'DELETE FROM ' . BOTS_TABLE . " $sql = 'DELETE FROM ' . BOTS_TABLE . "
WHERE bot_id $sql_id"; WHERE bot_id $sql_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (sizeof($user_id_ary)) if (sizeof($user_id_ary))
{ {
@ -112,12 +112,12 @@ class acp_bots
foreach ($_tables as $table) foreach ($_tables as $table)
{ {
$sql = "DELETE FROM $table $sql = "DELETE FROM $table
WHERE " . $db->sql_in_set('user_id', $user_id_ary); WHERE " . phpbb::$db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
phpbb::$acm->destroy('bots'); phpbb::$acm->destroy('bots');
@ -182,9 +182,9 @@ class acp_bots
FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . " u FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . " u
WHERE b.bot_id = $bot_id WHERE b.bot_id = $bot_id
AND u.user_id = b.user_id"; AND u.user_id = b.user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$bot_row) if (!$bot_row)
{ {
@ -209,9 +209,9 @@ class acp_bots
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_name_clean = 'bots' WHERE group_name_clean = 'bots'
AND group_type = " . GROUP_SPECIAL; AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_row = $db->sql_fetchrow($result); $group_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$group_row) if (!$group_row)
{ {
@ -232,14 +232,14 @@ class acp_bots
'user_allow_massemail' => 0, 'user_allow_massemail' => 0,
)); ));
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'user_id' => (int) $user_id, 'user_id' => (int) $user_id,
'bot_name' => (string) $bot_row['bot_name'], 'bot_name' => (string) $bot_row['bot_name'],
'bot_active' => (int) $bot_row['bot_active'], 'bot_active' => (int) $bot_row['bot_active'],
'bot_agent' => (string) $bot_row['bot_agent'], 'bot_agent' => (string) $bot_row['bot_agent'],
'bot_ip' => (string) $bot_row['bot_ip']) 'bot_ip' => (string) $bot_row['bot_ip'])
); );
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$log = 'ADDED'; $log = 'ADDED';
} }
@ -248,9 +248,9 @@ class acp_bots
$sql = 'SELECT user_id, bot_name $sql = 'SELECT user_id, bot_name
FROM ' . BOTS_TABLE . " FROM ' . BOTS_TABLE . "
WHERE bot_id = $bot_id"; WHERE bot_id = $bot_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -268,16 +268,16 @@ class acp_bots
$sql_ary['username_clean'] = (string) utf8_clean_string($bot_row['bot_name']); $sql_ary['username_clean'] = (string) utf8_clean_string($bot_row['bot_name']);
} }
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$row['user_id']}"; $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = {$row['user_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . BOTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( $sql = 'UPDATE ' . BOTS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', array(
'bot_name' => (string) $bot_row['bot_name'], 'bot_name' => (string) $bot_row['bot_name'],
'bot_active' => (int) $bot_row['bot_active'], 'bot_active' => (int) $bot_row['bot_active'],
'bot_agent' => (string) $bot_row['bot_agent'], 'bot_agent' => (string) $bot_row['bot_agent'],
'bot_ip' => (string) $bot_row['bot_ip']) 'bot_ip' => (string) $bot_row['bot_ip'])
) . " WHERE bot_id = $bot_id"; ) . " WHERE bot_id = $bot_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Updated username? // Updated username?
if ($bot_row['bot_name'] !== $row['bot_name']) if ($bot_row['bot_name'] !== $row['bot_name'])
@ -301,9 +301,9 @@ class acp_bots
FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . " u FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . " u
WHERE b.bot_id = $bot_id WHERE b.bot_id = $bot_id
AND u.user_id = b.user_id"; AND u.user_id = b.user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$bot_row = $db->sql_fetchrow($result); $bot_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$bot_row) if (!$bot_row)
{ {
@ -367,9 +367,9 @@ class acp_bots
FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . ' u FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . ' u
WHERE u.user_id = b.user_id WHERE u.user_id = b.user_id
ORDER BY u.user_lastvisit DESC, b.bot_name ASC'; ORDER BY u.user_lastvisit DESC, b.bot_name ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$active_lang = (!$row['bot_active']) ? 'BOT_ACTIVATE' : 'BOT_DEACTIVATE'; $active_lang = (!$row['bot_active']) ? 'BOT_ACTIVATE' : 'BOT_DEACTIVATE';
$active_value = (!$row['bot_active']) ? 'activate' : 'deactivate'; $active_value = (!$row['bot_active']) ? 'activate' : 'deactivate';
@ -385,7 +385,7 @@ class acp_bots
'U_DELETE' => $this->u_action . "&amp;id={$row['bot_id']}&amp;action=delete") 'U_DELETE' => $this->u_action . "&amp;id={$row['bot_id']}&amp;action=delete")
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -401,10 +401,10 @@ class acp_bots
// Admins might want to use names otherwise forbidden, thus we only check for duplicates. // Admins might want to use names otherwise forbidden, thus we only check for duplicates.
$sql = 'SELECT username $sql = 'SELECT username
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($newname)) . "'"; WHERE username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($newname)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return ($row) ? false : true; return ($row) ? false : true;
} }

View file

@ -83,7 +83,7 @@ class acp_database
$time = time(); $time = time();
$filename = 'backup_' . $time . '_' . unique_id(); $filename = 'backup_' . $time . '_' . unique_id();
switch ($db->dbms_type) switch (phpbb::$db->dbms_type)
{ {
case 'mysql': case 'mysql':
$extractor = new mysql_extractor($download, $store, $format, $filename, $time); $extractor = new mysql_extractor($download, $store, $format, $filename, $time);
@ -126,7 +126,7 @@ class acp_database
else else
{ {
// We might wanna empty out all that junk :D // We might wanna empty out all that junk :D
switch ($db->dbms_type) switch (phpbb::$db->dbms_type)
{ {
case 'sqlite': case 'sqlite':
case 'firebird': case 'firebird':
@ -314,14 +314,14 @@ class acp_database
break; break;
} }
switch ($db->dbms_type) switch (phpbb::$db->dbms_type)
{ {
case 'mysql': case 'mysql':
case 'sqlite': case 'sqlite':
case 'db2': case 'db2':
while (($sql = $fgetd($fp, ";\n", $read, $seek, $eof)) !== false) while (($sql = $fgetd($fp, ";\n", $read, $seek, $eof)) !== false)
{ {
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
break; break;
@ -335,7 +335,7 @@ class acp_database
$delim = $query[9] . "\n"; $delim = $query[9] . "\n";
continue; continue;
} }
$db->sql_query($query); phpbb::$db->sql_query($query);
} }
break; break;
@ -351,16 +351,16 @@ class acp_database
$sql = "SELECT domain_name $sql = "SELECT domain_name
FROM information_schema.domains FROM information_schema.domains
WHERE domain_name = '$domain';"; WHERE domain_name = '$domain';";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if (!$db->sql_fetchrow($result)) if (!phpbb::$db->sql_fetchrow($result))
{ {
$db->sql_query($query); phpbb::$db->sql_query($query);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
$db->sql_query($query); phpbb::$db->sql_query($query);
} }
if (substr($query, 0, 4) == 'COPY') if (substr($query, 0, 4) == 'COPY')
@ -371,10 +371,10 @@ class acp_database
{ {
trigger_error(phpbb::$user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error(phpbb::$user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
pg_put_line($db->db_connect_id, $sub . "\n"); pg_put_line(phpbb::$db->db_connect_id, $sub . "\n");
} }
pg_put_line($db->db_connect_id, "\\.\n"); pg_put_line(phpbb::$db->db_connect_id, "\\.\n");
pg_end_copy($db->db_connect_id); pg_end_copy(phpbb::$db->db_connect_id);
} }
} }
break; break;
@ -382,14 +382,14 @@ class acp_database
case 'oracle': case 'oracle':
while (($sql = $fgetd($fp, "/\n", $read, $seek, $eof)) !== false) while (($sql = $fgetd($fp, "/\n", $read, $seek, $eof)) !== false)
{ {
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
break; break;
case 'mssql': case 'mssql':
while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false) while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false)
{ {
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
break; break;
} }
@ -611,19 +611,19 @@ class mysql_extractor extends base_extractor
function write_table($table_name) function write_table($table_name)
{ {
$sql = 'SHOW CREATE TABLE ' . $table_name; $sql = 'SHOW CREATE TABLE ' . $table_name;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$sql_data = '# Table: ' . $table_name . "\n"; $sql_data = '# Table: ' . $table_name . "\n";
$sql_data .= "DROP TABLE IF EXISTS $table_name;\n"; $sql_data .= "DROP TABLE IF EXISTS $table_name;\n";
$this->flush($sql_data . $row['Create Table'] . ";\n\n"); $this->flush($sql_data . $row['Create Table'] . ";\n\n");
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
function write_data($table_name) function write_data($table_name)
{ {
if ($db->sql_layer === 'mysqli') if (phpbb::$db->sql_layer === 'mysqli')
{ {
$this->write_data_mysqli($table_name); $this->write_data_mysqli($table_name);
} }
@ -637,7 +637,7 @@ class mysql_extractor extends base_extractor
{ {
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = mysqli_query($db->db_connect_id, $sql, MYSQLI_USE_RESULT); $result = mysqli_query(phpbb::$db->db_connect_id, $sql, MYSQLI_USE_RESULT);
if ($result != false) if ($result != false)
{ {
$fields_cnt = mysqli_num_fields($result); $fields_cnt = mysqli_num_fields($result);
@ -715,7 +715,7 @@ class mysql_extractor extends base_extractor
{ {
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = mysql_unbuffered_query($sql, $db->db_connect_id); $result = mysql_unbuffered_query($sql, phpbb::$db->db_connect_id);
if ($result != false) if ($result != false)
{ {
@ -819,23 +819,23 @@ class sqlite_extractor extends base_extractor
$sql = "SELECT sql $sql = "SELECT sql
FROM sqlite_master FROM sqlite_master
WHERE type = 'table' WHERE type = 'table'
AND name = '" . $db->sql_escape($table_name) . "' AND name = '" . phpbb::$db->sql_escape($table_name) . "'
ORDER BY type DESC, name;"; ORDER BY type DESC, name;";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Create Table // Create Table
$sql_data .= $row['sql'] . ";\n"; $sql_data .= $row['sql'] . ";\n";
$result = $db->sql_query("PRAGMA index_list('" . $db->sql_escape($table_name) . "');"); $result = phpbb::$db->sql_query("PRAGMA index_list('" . phpbb::$db->sql_escape($table_name) . "');");
$ar = array(); $ar = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ar[] = $row; $ar[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($ar as $value) foreach ($ar as $value)
{ {
@ -844,14 +844,14 @@ class sqlite_extractor extends base_extractor
continue; continue;
} }
$result = $db->sql_query("PRAGMA index_info('" . $db->sql_escape($value['name']) . "');"); $result = phpbb::$db->sql_query("PRAGMA index_info('" . phpbb::$db->sql_escape($value['name']) . "');");
$fields = array(); $fields = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$fields[] = $row['name']; $fields[] = $row['name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_data .= 'CREATE ' . ($value['unique'] ? 'UNIQUE ' : '') . 'INDEX ' . $value['name'] . ' on ' . $table_name . ' (' . implode(', ', $fields) . ");\n"; $sql_data .= 'CREATE ' . ($value['unique'] ? 'UNIQUE ' : '') . 'INDEX ' . $value['name'] . ' on ' . $table_name . ' (' . implode(', ', $fields) . ");\n";
} }
@ -870,7 +870,7 @@ class sqlite_extractor extends base_extractor
if ($proper) if ($proper)
{ {
$col_types = sqlite_fetch_column_types($db->db_connect_id, $table_name); $col_types = sqlite_fetch_column_types(phpbb::$db->db_connect_id, $table_name);
} }
else else
{ {
@ -878,7 +878,7 @@ class sqlite_extractor extends base_extractor
FROM sqlite_master FROM sqlite_master
WHERE type = 'table' WHERE type = 'table'
AND name = '" . $table_name . "'"; AND name = '" . $table_name . "'";
$table_data = sqlite_single_query($db->db_connect_id, $sql); $table_data = sqlite_single_query(phpbb::$db->db_connect_id, $sql);
$table_data = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', '', $table_data); $table_data = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', '', $table_data);
$table_data = trim($table_data); $table_data = trim($table_data);
@ -901,7 +901,7 @@ class sqlite_extractor extends base_extractor
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = sqlite_unbuffered_query($db->db_connect_id, $sql); $result = sqlite_unbuffered_query(phpbb::$db->db_connect_id, $sql);
$rows = sqlite_fetch_all($result, SQLITE_ASSOC); $rows = sqlite_fetch_all($result, SQLITE_ASSOC);
$sql_insert = 'INSERT INTO ' . $table_name . ' (' . implode(', ', array_keys($col_types)) . ') VALUES ('; $sql_insert = 'INSERT INTO ' . $table_name . ' (' . implode(', ', array_keys($col_types)) . ') VALUES (';
foreach ($rows as $row) foreach ($rows as $row)
@ -956,8 +956,8 @@ class postgres_extractor extends base_extractor
FROM INFORMATION_SCHEMA.domains a, INFORMATION_SCHEMA.column_domain_usage b FROM INFORMATION_SCHEMA.domains a, INFORMATION_SCHEMA.column_domain_usage b
WHERE a.domain_name = b.domain_name WHERE a.domain_name = b.domain_name
AND b.table_name = '{$table_name}'"; AND b.table_name = '{$table_name}'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (empty($domains_created[$row['domain_name']])) if (empty($domains_created[$row['domain_name']]))
{ {
@ -984,35 +984,35 @@ class postgres_extractor extends base_extractor
FROM pg_class FROM pg_class
WHERE relkind = 'S' WHERE relkind = 'S'
AND relname = '{$table_name}_seq'"; AND relname = '{$table_name}_seq'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
// We don't even care about storing the results. We already know the answer if we get rows back. // We don't even care about storing the results. We already know the answer if we get rows back.
if ($db->sql_fetchrow($result)) if (phpbb::$db->sql_fetchrow($result))
{ {
$sql_data .= "DROP SEQUENCE {$table_name}_seq;\n"; $sql_data .= "DROP SEQUENCE {$table_name}_seq;\n";
$sql_data .= "CREATE SEQUENCE {$table_name}_seq;\n"; $sql_data .= "CREATE SEQUENCE {$table_name}_seq;\n";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$field_query = "SELECT a.attnum, a.attname as field, t.typname as type, a.attlen as length, a.atttypmod as lengthvar, a.attnotnull as notnull $field_query = "SELECT a.attnum, a.attname as field, t.typname as type, a.attlen as length, a.atttypmod as lengthvar, a.attnotnull as notnull
FROM pg_class c, pg_attribute a, pg_type t FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '" . $db->sql_escape($table_name) . "' WHERE c.relname = '" . phpbb::$db->sql_escape($table_name) . "'
AND a.attnum > 0 AND a.attnum > 0
AND a.attrelid = c.oid AND a.attrelid = c.oid
AND a.atttypid = t.oid AND a.atttypid = t.oid
ORDER BY a.attnum"; ORDER BY a.attnum";
$result = $db->sql_query($field_query); $result = phpbb::$db->sql_query($field_query);
$sql_data .= "CREATE TABLE $table_name(\n"; $sql_data .= "CREATE TABLE $table_name(\n";
$lines = array(); $lines = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Get the data from the table // Get the data from the table
$sql_get_default = "SELECT pg_get_expr(d.adbin, d.adrelid) as rowdefault $sql_get_default = "SELECT pg_get_expr(d.adbin, d.adrelid) as rowdefault
FROM pg_attrdef d, pg_class c FROM pg_attrdef d, pg_class c
WHERE (c.relname = '" . $db->sql_escape($table_name) . "') WHERE (c.relname = '" . phpbb::$db->sql_escape($table_name) . "')
AND (c.oid = d.adrelid) AND (c.oid = d.adrelid)
AND d.adnum = " . $row['attnum']; AND d.adnum = " . $row['attnum'];
$def_res = $db->sql_query($sql_get_default); $def_res = phpbb::$db->sql_query($sql_get_default);
if (!$def_res) if (!$def_res)
{ {
@ -1020,9 +1020,9 @@ class postgres_extractor extends base_extractor
} }
else else
{ {
$row['rowdefault'] = $db->sql_fetchfield('rowdefault', $def_res); $row['rowdefault'] = phpbb::$db->sql_fetchfield('rowdefault', $def_res);
} }
$db->sql_freeresult($def_res); phpbb::$db->sql_freeresult($def_res);
if ($row['type'] == 'bpchar') if ($row['type'] == 'bpchar')
{ {
@ -1059,7 +1059,7 @@ class postgres_extractor extends base_extractor
$lines[] = $line; $lines[] = $line;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Get the listing of primary keys. // Get the listing of primary keys.
@ -1069,17 +1069,17 @@ class postgres_extractor extends base_extractor
AND (ic.oid = i.indexrelid) AND (ic.oid = i.indexrelid)
AND (ia.attrelid = i.indexrelid) AND (ia.attrelid = i.indexrelid)
AND (ta.attrelid = bc.oid) AND (ta.attrelid = bc.oid)
AND (bc.relname = '" . $db->sql_escape($table_name) . "') AND (bc.relname = '" . phpbb::$db->sql_escape($table_name) . "')
AND (ta.attrelid = i.indrelid) AND (ta.attrelid = i.indrelid)
AND (ta.attnum = i.indkey[ia.attnum-1]) AND (ta.attnum = i.indkey[ia.attnum-1])
ORDER BY index_name, tab_name, column_name"; ORDER BY index_name, tab_name, column_name";
$result = $db->sql_query($sql_pri_keys); $result = phpbb::$db->sql_query($sql_pri_keys);
$index_create = $index_rows = $primary_key = array(); $index_create = $index_rows = $primary_key = array();
// We do this in two steps. It makes placing the comma easier // We do this in two steps. It makes placing the comma easier
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['primary_key'] == 't') if ($row['primary_key'] == 't')
{ {
@ -1095,7 +1095,7 @@ class postgres_extractor extends base_extractor
$index_rows[$row['index_name']]['column_names'][] = $row['column_name']; $index_rows[$row['index_name']]['column_names'][] = $row['column_name'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!empty($index_rows)) if (!empty($index_rows))
{ {
@ -1114,7 +1114,7 @@ class postgres_extractor extends base_extractor
$sql_checks = "SELECT conname as index_name, consrc $sql_checks = "SELECT conname as index_name, consrc
FROM pg_constraint, pg_class bc FROM pg_constraint, pg_class bc
WHERE conrelid = bc.oid WHERE conrelid = bc.oid
AND bc.relname = '" . $db->sql_escape($table_name) . "' AND bc.relname = '" . phpbb::$db->sql_escape($table_name) . "'
AND NOT EXISTS ( AND NOT EXISTS (
SELECT * SELECT *
FROM pg_constraint as c, pg_inherits as i FROM pg_constraint as c, pg_inherits as i
@ -1123,17 +1123,17 @@ class postgres_extractor extends base_extractor
AND c.consrc = pg_constraint.consrc AND c.consrc = pg_constraint.consrc
AND c.conrelid = i.inhparent AND c.conrelid = i.inhparent
)"; )";
$result = $db->sql_query($sql_checks); $result = phpbb::$db->sql_query($sql_checks);
// Add the constraints to the sql file. // Add the constraints to the sql file.
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!is_null($row['consrc'])) if (!is_null($row['consrc']))
{ {
$lines[] = ' CONSTRAINT ' . $row['index_name'] . ' CHECK ' . $row['consrc']; $lines[] = ' CONSTRAINT ' . $row['index_name'] . ' CHECK ' . $row['consrc'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_data .= implode(", \n", $lines); $sql_data .= implode(", \n", $lines);
$sql_data .= "\n);\n"; $sql_data .= "\n);\n";
@ -1150,7 +1150,7 @@ class postgres_extractor extends base_extractor
// Grab all of the data from current table. // Grab all of the data from current table.
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$i_num_fields = pg_num_fields($result); $i_num_fields = pg_num_fields($result);
$seq = ''; $seq = '';
@ -1166,8 +1166,8 @@ class postgres_extractor extends base_extractor
WHERE (c.relname = '{$table_name}') WHERE (c.relname = '{$table_name}')
AND (c.oid = d.adrelid) AND (c.oid = d.adrelid)
AND d.adnum = " . strval($i + 1); AND d.adnum = " . strval($i + 1);
$result2 = $db->sql_query($sql); $result2 = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result2)) if ($row = phpbb::$db->sql_fetchrow($result2))
{ {
// Determine if we must reset the sequences // Determine if we must reset the sequences
if (strpos($row['rowdefault'], "nextval('") === 0) if (strpos($row['rowdefault'], "nextval('") === 0)
@ -1178,7 +1178,7 @@ class postgres_extractor extends base_extractor
} }
$this->flush("COPY $table_name (" . implode(', ', $ary_name) . ') FROM stdin;' . "\n"); $this->flush("COPY $table_name (" . implode(', ', $ary_name) . ') FROM stdin;' . "\n");
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$schema_vals = array(); $schema_vals = array();
@ -1209,7 +1209,7 @@ class postgres_extractor extends base_extractor
// into a valid sql statement to recreate that field in the data. // into a valid sql statement to recreate that field in the data.
$this->flush(implode("\t", $schema_vals) . "\n"); $this->flush(implode("\t", $schema_vals) . "\n");
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$this->flush("\\.\n"); $this->flush("\\.\n");
// Write out the sequence statements // Write out the sequence statements
@ -1260,9 +1260,9 @@ class mssql_extractor extends base_extractor
$sql = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') as IS_IDENTITY $sql = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') as IS_IDENTITY
FROM INFORMATION_SCHEMA.COLUMNS FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '$table_name'"; WHERE TABLE_NAME = '$table_name'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$line = "\t[{$row['COLUMN_NAME']}] [{$row['DATA_TYPE']}]"; $line = "\t[{$row['COLUMN_NAME']}] [{$row['DATA_TYPE']}]";
@ -1297,7 +1297,7 @@ class mssql_extractor extends base_extractor
$rows[] = $line; $rows[] = $line;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_data .= implode(",\n", $rows); $sql_data .= implode(",\n", $rows);
$sql_data .= "\n) ON [PRIMARY]"; $sql_data .= "\n) ON [PRIMARY]";
@ -1313,8 +1313,8 @@ class mssql_extractor extends base_extractor
$sql = "SELECT CONSTRAINT_NAME, COLUMN_NAME $sql = "SELECT CONSTRAINT_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = '$table_name'"; WHERE TABLE_NAME = '$table_name'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!sizeof($rows)) if (!sizeof($rows))
{ {
@ -1328,19 +1328,19 @@ class mssql_extractor extends base_extractor
$sql_data .= implode(",\n", $rows); $sql_data .= implode(",\n", $rows);
$sql_data .= "\n\t) ON [PRIMARY] \nGO\n"; $sql_data .= "\n\t) ON [PRIMARY] \nGO\n";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$index = array(); $index = array();
$sql = "EXEC sp_statistics '$table_name'"; $sql = "EXEC sp_statistics '$table_name'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['TYPE'] == 3) if ($row['TYPE'] == 3)
{ {
$index[$row['INDEX_NAME']][] = '[' . $row['COLUMN_NAME'] . ']'; $index[$row['INDEX_NAME']][] = '[' . $row['COLUMN_NAME'] . ']';
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($index as $index_name => $column_name) foreach ($index as $index_name => $column_name)
{ {
@ -1356,11 +1356,11 @@ class mssql_extractor extends base_extractor
function write_data($table_name) function write_data($table_name)
{ {
if ($db->sql_layer === 'mssql') if (phpbb::$db->sql_layer === 'mssql')
{ {
$this->write_data_mssql($table_name); $this->write_data_mssql($table_name);
} }
else if ($db->sql_layer === 'mssql_odbc') else if (phpbb::$db->sql_layer === 'mssql_odbc')
{ {
$this->write_data_odbc($table_name); $this->write_data_odbc($table_name);
} }
@ -1380,7 +1380,7 @@ class mssql_extractor extends base_extractor
// Grab all of the data from current table. // Grab all of the data from current table.
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$retrieved_data = mssql_num_rows($result); $retrieved_data = mssql_num_rows($result);
@ -1397,17 +1397,17 @@ class mssql_extractor extends base_extractor
$sql = "SELECT 1 as has_identity $sql = "SELECT 1 as has_identity
FROM INFORMATION_SCHEMA.COLUMNS FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1"; WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1";
$result2 = $db->sql_query($sql); $result2 = phpbb::$db->sql_query($sql);
$row2 = $db->sql_fetchrow($result2); $row2 = phpbb::$db->sql_fetchrow($result2);
if (!empty($row2['has_identity'])) if (!empty($row2['has_identity']))
{ {
$sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n"; $sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n";
$ident_set = true; $ident_set = true;
} }
$db->sql_freeresult($result2); phpbb::$db->sql_freeresult($result2);
} }
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$schema_vals = $schema_fields = array(); $schema_vals = $schema_fields = array();
@ -1455,7 +1455,7 @@ class mssql_extractor extends base_extractor
$this->flush($sql_data); $this->flush($sql_data);
$sql_data = ''; $sql_data = '';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($retrieved_data && $ident_set) if ($retrieved_data && $ident_set)
{ {
@ -1473,7 +1473,7 @@ class mssql_extractor extends base_extractor
// Grab all of the data from current table. // Grab all of the data from current table.
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$retrieved_data = odbc_num_rows($result); $retrieved_data = odbc_num_rows($result);
@ -1482,14 +1482,14 @@ class mssql_extractor extends base_extractor
$sql = "SELECT 1 as has_identity $sql = "SELECT 1 as has_identity
FROM INFORMATION_SCHEMA.COLUMNS FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1"; WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1";
$result2 = $db->sql_query($sql); $result2 = phpbb::$db->sql_query($sql);
$row2 = $db->sql_fetchrow($result2); $row2 = phpbb::$db->sql_fetchrow($result2);
if (!empty($row2['has_identity'])) if (!empty($row2['has_identity']))
{ {
$sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n"; $sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n";
$ident_set = true; $ident_set = true;
} }
$db->sql_freeresult($result2); phpbb::$db->sql_freeresult($result2);
} }
$i_num_fields = odbc_num_fields($result); $i_num_fields = odbc_num_fields($result);
@ -1500,7 +1500,7 @@ class mssql_extractor extends base_extractor
$ary_name[$i] = odbc_field_name($result, $i + 1); $ary_name[$i] = odbc_field_name($result, $i + 1);
} }
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$schema_vals = $schema_fields = array(); $schema_vals = $schema_fields = array();
@ -1550,7 +1550,7 @@ class mssql_extractor extends base_extractor
$sql_data = ''; $sql_data = '';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($retrieved_data && $ident_set) if ($retrieved_data && $ident_set)
{ {
@ -1586,9 +1586,9 @@ class db2_extractor extends base_extractor
$sql = "SELECT colname, typename, length, default, identity, nulls $sql = "SELECT colname, typename, length, default, identity, nulls
FROM syscat.columns FROM syscat.columns
WHERE tabname = '$table_name'"; WHERE tabname = '$table_name'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$line = "\t{$row['colname']} {$row['typename']}"; $line = "\t{$row['colname']} {$row['typename']}";
@ -1618,19 +1618,19 @@ class db2_extractor extends base_extractor
$rows[] = $line; $rows[] = $line;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// switch to db2_columns()? // switch to db2_columns()?
$sql = "SELECT colname $sql = "SELECT colname
FROM SYSCAT.KEYCOLUSE FROM SYSCAT.KEYCOLUSE
WHERE tabname = '$table_name'"; WHERE tabname = '$table_name'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$prim_cols = array(); $prim_cols = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$prim_cols[] = $row['colname']; $prim_cols[] = $row['colname'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($prim_cols)) if (sizeof($prim_cols))
{ {
$rows[] = "\tPRIMARY KEY (" . implode($prim_cols) . ')'; $rows[] = "\tPRIMARY KEY (" . implode($prim_cols) . ')';
@ -1644,15 +1644,15 @@ class db2_extractor extends base_extractor
FROM SYSCAT.INDEXES FROM SYSCAT.INDEXES
WHERE TABNAME = '$table_name' WHERE TABNAME = '$table_name'
AND UNIQUERULE <> 'P'"; AND UNIQUERULE <> 'P'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$index = array(); $index = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$inds = explode('+', $row['colnames']); $inds = explode('+', $row['colnames']);
unset($inds[0]); unset($inds[0]);
$sql_data .= 'CREATE INDEX ' . $row['indname'] . ' ON ' . $table_name . ' (' . implode(', ', $inds) . ") PCTFREE 10 MINPCTUSED 10 ALLOW REVERSE SCANS PAGE SPLIT SYMMETRIC COLLECT SAMPLED DETAILED STATISTICS;\n"; $sql_data .= 'CREATE INDEX ' . $row['indname'] . ' ON ' . $table_name . ' (' . implode(', ', $inds) . ") PCTFREE 10 MINPCTUSED 10 ALLOW REVERSE SCANS PAGE SPLIT SYMMETRIC COLLECT SAMPLED DETAILED STATISTICS;\n";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$this->flush($sql_data); $this->flush($sql_data);
} }
@ -1660,24 +1660,24 @@ class db2_extractor extends base_extractor
function write_data($table_name) function write_data($table_name)
{ {
$ary_type = $ary_name = array(); $ary_type = $ary_name = array();
$result = db2_columns($db->db_connect_id, '', '%', $table_name); $result = db2_columns(phpbb::$db->db_connect_id, '', '%', $table_name);
$i = 0; $i = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ary_type[$i] = $row['type_name']; $ary_type[$i] = $row['type_name'];
$ary_name[$i++] = strtolower($row['column_name']); $ary_name[$i++] = strtolower($row['column_name']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Grab all of the data from current table. // Grab all of the data from current table.
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$sql_data = ''; $sql_data = '';
$i_num_fields = $i; $i_num_fields = $i;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$schema_vals = $schema_fields = array(); $schema_vals = $schema_fields = array();
@ -1724,7 +1724,7 @@ class db2_extractor extends base_extractor
$this->flush($sql_data); $this->flush($sql_data);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -1743,10 +1743,10 @@ class oracle_extractor extends base_extractor
$sql = "SELECT COLUMN_NAME, DATA_TYPE, DATA_PRECISION, DATA_LENGTH, NULLABLE, DATA_DEFAULT $sql = "SELECT COLUMN_NAME, DATA_TYPE, DATA_PRECISION, DATA_LENGTH, NULLABLE, DATA_DEFAULT
FROM ALL_TAB_COLS FROM ALL_TAB_COLS
WHERE table_name = '{$table_name}'"; WHERE table_name = '{$table_name}'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$rows = array(); $rows = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$line = ' "' . $row['column_name'] . '" ' . $row['data_type']; $line = ' "' . $row['column_name'] . '" ' . $row['data_type'];
@ -1773,33 +1773,33 @@ class oracle_extractor extends base_extractor
} }
$rows[] = $line; $rows[] = $line;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = "SELECT A.CONSTRAINT_NAME, A.COLUMN_NAME $sql = "SELECT A.CONSTRAINT_NAME, A.COLUMN_NAME
FROM USER_CONS_COLUMNS A, USER_CONSTRAINTS B FROM USER_CONS_COLUMNS A, USER_CONSTRAINTS B
WHERE A.CONSTRAINT_NAME = B.CONSTRAINT_NAME WHERE A.CONSTRAINT_NAME = B.CONSTRAINT_NAME
AND B.CONSTRAINT_TYPE = 'P' AND B.CONSTRAINT_TYPE = 'P'
AND A.TABLE_NAME = '{$table_name}'"; AND A.TABLE_NAME = '{$table_name}'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$rows[] = " CONSTRAINT {$row['constraint_name']} PRIMARY KEY ({$row['column_name']})"; $rows[] = " CONSTRAINT {$row['constraint_name']} PRIMARY KEY ({$row['column_name']})";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = "SELECT A.CONSTRAINT_NAME, A.COLUMN_NAME $sql = "SELECT A.CONSTRAINT_NAME, A.COLUMN_NAME
FROM USER_CONS_COLUMNS A, USER_CONSTRAINTS B FROM USER_CONS_COLUMNS A, USER_CONSTRAINTS B
WHERE A.CONSTRAINT_NAME = B.CONSTRAINT_NAME WHERE A.CONSTRAINT_NAME = B.CONSTRAINT_NAME
AND B.CONSTRAINT_TYPE = 'U' AND B.CONSTRAINT_TYPE = 'U'
AND A.TABLE_NAME = '{$table_name}'"; AND A.TABLE_NAME = '{$table_name}'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$rows[] = " CONSTRAINT {$row['constraint_name']} UNIQUE ({$row['column_name']})"; $rows[] = " CONSTRAINT {$row['constraint_name']} UNIQUE ({$row['column_name']})";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_data .= implode(",\n", $rows); $sql_data .= implode(",\n", $rows);
$sql_data .= "\n)\n\\"; $sql_data .= "\n)\n\\";
@ -1809,33 +1809,33 @@ class oracle_extractor extends base_extractor
WHERE A.REFERENCED_TYPE = 'SEQUENCE' WHERE A.REFERENCED_TYPE = 'SEQUENCE'
AND A.NAME = B.TRIGGER_NAME AND A.NAME = B.TRIGGER_NAME
AND B.TABLE_NAME = '{$table_name}'"; AND B.TABLE_NAME = '{$table_name}'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$sql_data .= "\nCREATE SEQUENCE {$row['referenced_name']}\\\n"; $sql_data .= "\nCREATE SEQUENCE {$row['referenced_name']}\\\n";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = "SELECT DESCRIPTION, WHEN_CLAUSE, TRIGGER_BODY $sql = "SELECT DESCRIPTION, WHEN_CLAUSE, TRIGGER_BODY
FROM USER_TRIGGERS FROM USER_TRIGGERS
WHERE TABLE_NAME = '{$table_name}'"; WHERE TABLE_NAME = '{$table_name}'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$sql_data .= "\nCREATE OR REPLACE TRIGGER {$row['description']}WHEN ({$row['when_clause']})\n{$row['trigger_body']}\\"; $sql_data .= "\nCREATE OR REPLACE TRIGGER {$row['description']}WHEN ({$row['when_clause']})\n{$row['trigger_body']}\\";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = "SELECT A.INDEX_NAME, B.COLUMN_NAME $sql = "SELECT A.INDEX_NAME, B.COLUMN_NAME
FROM USER_INDEXES A, USER_IND_COLUMNS B FROM USER_INDEXES A, USER_IND_COLUMNS B
WHERE A.UNIQUENESS = 'NONUNIQUE' WHERE A.UNIQUENESS = 'NONUNIQUE'
AND A.INDEX_NAME = B.INDEX_NAME AND A.INDEX_NAME = B.INDEX_NAME
AND B.TABLE_NAME = '{$table_name}'"; AND B.TABLE_NAME = '{$table_name}'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$index = array(); $index = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$index[$row['index_name']][] = $row['column_name']; $index[$row['index_name']][] = $row['column_name'];
} }
@ -1844,7 +1844,7 @@ class oracle_extractor extends base_extractor
{ {
$sql_data .= "\nCREATE INDEX $index_name ON $table_name(" . implode(', ', $column_names) . ")\n\\"; $sql_data .= "\nCREATE INDEX $index_name ON $table_name(" . implode(', ', $column_names) . ")\n\\";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$this->flush($sql_data); $this->flush($sql_data);
} }
@ -1855,7 +1855,7 @@ class oracle_extractor extends base_extractor
// Grab all of the data from current table. // Grab all of the data from current table.
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$i_num_fields = ocinumcols($result); $i_num_fields = ocinumcols($result);
@ -1867,7 +1867,7 @@ class oracle_extractor extends base_extractor
$sql_data = ''; $sql_data = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$schema_vals = $schema_fields = array(); $schema_vals = $schema_fields = array();
@ -1914,7 +1914,7 @@ class oracle_extractor extends base_extractor
$this->flush($sql_data); $this->flush($sql_data);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
function write_start($prefix) function write_start($prefix)
@ -1950,7 +1950,7 @@ class firebird_extractor extends base_extractor
// Grab all of the data from current table. // Grab all of the data from current table.
$sql = "SELECT * $sql = "SELECT *
FROM $table_name"; FROM $table_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$i_num_fields = ibase_num_fields($result); $i_num_fields = ibase_num_fields($result);
@ -1961,7 +1961,7 @@ class firebird_extractor extends base_extractor
$ary_name[$i] = $info['name']; $ary_name[$i] = $info['name'];
} }
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$schema_vals = $schema_fields = array(); $schema_vals = $schema_fields = array();
@ -2008,7 +2008,7 @@ class firebird_extractor extends base_extractor
$this->flush($sql_data); $this->flush($sql_data);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
function write_table($table_name) function write_table($table_name)
@ -2027,10 +2027,10 @@ class firebird_extractor extends base_extractor
WHERE F.RDB$SYSTEM_FLAG = 0 WHERE F.RDB$SYSTEM_FLAG = 0
AND R.RDB$RELATION_NAME = \''. $table_name . '\' AND R.RDB$RELATION_NAME = \''. $table_name . '\'
ORDER BY R.RDB$FIELD_POSITION'; ORDER BY R.RDB$FIELD_POSITION';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$rows = array(); $rows = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$line = "\t" . '"' . $row['fname'] . '" ' . $data_types[$row['ftype']]; $line = "\t" . '"' . $row['fname'] . '" ' . $data_types[$row['ftype']];
@ -2055,7 +2055,7 @@ class firebird_extractor extends base_extractor
} }
$rows[] = $line; $rows[] = $line;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_data .= implode(",\n", $rows); $sql_data .= implode(",\n", $rows);
$sql_data .= "\n);\n"; $sql_data .= "\n);\n";
@ -2067,9 +2067,9 @@ class firebird_extractor extends base_extractor
AND (IDX.RDB$INDEX_NAME = RC.RDB$INDEX_NAME) AND (IDX.RDB$INDEX_NAME = RC.RDB$INDEX_NAME)
AND (RC.RDB$RELATION_NAME = \''. $table_name . '\') AND (RC.RDB$RELATION_NAME = \''. $table_name . '\')
ORDER BY I.RDB$FIELD_POSITION'; ORDER BY I.RDB$FIELD_POSITION';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$keys[] = $row['name']; $keys[] = $row['name'];
} }
@ -2079,7 +2079,7 @@ class firebird_extractor extends base_extractor
$sql_data .= "\nALTER TABLE $table_name ADD PRIMARY KEY (" . implode(', ', $keys) . ');'; $sql_data .= "\nALTER TABLE $table_name ADD PRIMARY KEY (" . implode(', ', $keys) . ');';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT I.RDB$INDEX_NAME as INAME, I.RDB$UNIQUE_FLAG as UFLAG, S.RDB$FIELD_NAME as FNAME $sql = 'SELECT I.RDB$INDEX_NAME as INAME, I.RDB$UNIQUE_FLAG as UFLAG, S.RDB$FIELD_NAME as FNAME
FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON S.RDB$INDEX_NAME=I.RDB$INDEX_NAME FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON S.RDB$INDEX_NAME=I.RDB$INDEX_NAME
@ -2088,10 +2088,10 @@ class firebird_extractor extends base_extractor
AND I.RDB$RELATION_NAME = \''. $table_name . '\' AND I.RDB$RELATION_NAME = \''. $table_name . '\'
AND I.RDB$INDEX_NAME NOT STARTING WITH \'RDB$\' AND I.RDB$INDEX_NAME NOT STARTING WITH \'RDB$\'
ORDER BY S.RDB$FIELD_POSITION'; ORDER BY S.RDB$FIELD_POSITION';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$index = array(); $index = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$index[$row['iname']]['unique'] = !empty($row['uflag']); $index[$row['iname']]['unique'] = !empty($row['uflag']);
$index[$row['iname']]['values'][] = $row['fname']; $index[$row['iname']]['values'][] = $row['fname'];
@ -2108,7 +2108,7 @@ class firebird_extractor extends base_extractor
} }
$sql_data .= "\n"; $sql_data .= "\n";
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT D1.RDB$DEPENDENT_NAME as DNAME, D1.RDB$FIELD_NAME as FNAME, D1.RDB$DEPENDENT_TYPE, R1.RDB$RELATION_NAME $sql = 'SELECT D1.RDB$DEPENDENT_NAME as DNAME, D1.RDB$FIELD_NAME as FNAME, D1.RDB$DEPENDENT_TYPE, R1.RDB$RELATION_NAME
FROM RDB$DEPENDENCIES D1 FROM RDB$DEPENDENCIES D1
@ -2122,8 +2122,8 @@ class firebird_extractor extends base_extractor
AND (D2.RDB$DEPENDENT_NAME = F2.RDB$FIELD_SOURCE) AND (D2.RDB$DEPENDENT_NAME = F2.RDB$FIELD_SOURCE)
AND (D2.RDB$DEPENDED_ON_NAME = \'' . $table_name . '\') AND (D2.RDB$DEPENDED_ON_NAME = \'' . $table_name . '\')
ORDER BY 1, 2'; ORDER BY 1, 2';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$sql = 'SELECT T1.RDB$DEPENDED_ON_NAME as GEN, T1.RDB$FIELD_NAME, T1.RDB$DEPENDED_ON_TYPE $sql = 'SELECT T1.RDB$DEPENDED_ON_NAME as GEN, T1.RDB$FIELD_NAME, T1.RDB$DEPENDED_ON_TYPE
FROM RDB$DEPENDENCIES T1 FROM RDB$DEPENDENCIES T1
@ -2135,9 +2135,9 @@ class firebird_extractor extends base_extractor
AND (D.RDB$DEPENDENT_NAME = F.RDB$FIELD_SOURCE) AND (D.RDB$DEPENDENT_NAME = F.RDB$FIELD_SOURCE)
AND (F.RDB$RELATION_NAME = \'' . $row['dname'] . '\') AND (F.RDB$RELATION_NAME = \'' . $row['dname'] . '\')
ORDER BY 1,2'; ORDER BY 1,2';
$result2 = $db->sql_query($sql); $result2 = phpbb::$db->sql_query($sql);
$row2 = $db->sql_fetchrow($result2); $row2 = phpbb::$db->sql_fetchrow($result2);
$db->sql_freeresult($result2); phpbb::$db->sql_freeresult($result2);
$gen_name = $row2['gen']; $gen_name = $row2['gen'];
$sql_data .= "\nDROP GENERATOR " . $gen_name . ";"; $sql_data .= "\nDROP GENERATOR " . $gen_name . ";";
@ -2153,7 +2153,7 @@ class firebird_extractor extends base_extractor
$this->flush($sql_data); $this->flush($sql_data);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }

View file

@ -53,8 +53,8 @@ class acp_disallow
trigger_error(phpbb::$user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error(phpbb::$user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
$sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user)); $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy('disallowed_usernames'); phpbb::$acm->destroy('disallowed_usernames');
@ -74,7 +74,7 @@ class acp_disallow
$sql = 'DELETE FROM ' . DISALLOW_TABLE . ' $sql = 'DELETE FROM ' . DISALLOW_TABLE . '
WHERE disallow_id = ' . $disallowed_id; WHERE disallow_id = ' . $disallowed_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy('disallowed_usernames'); phpbb::$acm->destroy('disallowed_usernames');
@ -86,14 +86,14 @@ class acp_disallow
// Grab the current list of disallowed usernames... // Grab the current list of disallowed usernames...
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . DISALLOW_TABLE; FROM ' . DISALLOW_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$disallow_select = ''; $disallow_select = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>'; $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'U_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action,

View file

@ -71,7 +71,7 @@ class acp_email
// If giving usernames the admin is able to email inactive users too... // If giving usernames the admin is able to email inactive users too...
$sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang $sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', explode("\n", $usernames))) . ' WHERE ' . phpbb::$db->sql_in_set('username_clean', array_map('utf8_clean_string', explode("\n", $usernames))) . '
AND user_allow_massemail = 1 AND user_allow_massemail = 1
ORDER BY user_lang, user_notify_type'; // , SUBSTRING(user_email FROM INSTR(user_email, '@')) ORDER BY user_lang, user_notify_type'; // , SUBSTRING(user_email FROM INSTR(user_email, '@'))
} }
@ -97,12 +97,12 @@ class acp_email
ORDER BY user_lang, user_notify_type'; ORDER BY user_lang, user_notify_type';
} }
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
if (!$row) if (!$row)
{ {
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
trigger_error(phpbb::$user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error(phpbb::$user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
@ -141,8 +141,8 @@ class acp_email
$i++; $i++;
} }
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Send the messages // Send the messages
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);
@ -225,14 +225,14 @@ class acp_email
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_name_clean IN ('bots', 'guests')"; WHERE group_name_clean IN ('bots', 'guests')";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$exclude = array(); $exclude = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$exclude[] = $row['group_id']; $exclude[] = $row['group_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['ALL_USERS'] . '</option>'; $select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['ALL_USERS'] . '</option>';
$select_list .= group_select_options($group_id, $exclude); $select_list .= group_select_options($group_id, $exclude);

View file

@ -188,11 +188,11 @@ class acp_forums
{ {
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE forum_id = ' . (int) $forum_data['forum_id']; WHERE forum_id = ' . (int) $forum_data['forum_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE forum_id = ' . (int) $forum_data['forum_id']; WHERE forum_id = ' . (int) $forum_data['forum_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// From the mysql documentation: // From the mysql documentation:
@ -203,10 +203,10 @@ class acp_forums
$sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_USERS_TABLE . ' FROM ' . ACL_USERS_TABLE . '
WHERE forum_id = ' . $forum_perm_from; WHERE forum_id = ' . $forum_perm_from;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$users_sql_ary = array(); $users_sql_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$users_sql_ary[] = array( $users_sql_ary[] = array(
'user_id' => (int) $row['user_id'], 'user_id' => (int) $row['user_id'],
@ -216,16 +216,16 @@ class acp_forums
'auth_setting' => (int) $row['auth_setting'] 'auth_setting' => (int) $row['auth_setting']
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Copy permisisons from/to the acl groups table (only forum_id gets changed) // Copy permisisons from/to the acl groups table (only forum_id gets changed)
$sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_GROUPS_TABLE . ' FROM ' . ACL_GROUPS_TABLE . '
WHERE forum_id = ' . $forum_perm_from; WHERE forum_id = ' . $forum_perm_from;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$groups_sql_ary = array(); $groups_sql_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$groups_sql_ary[] = array( $groups_sql_ary[] = array(
'group_id' => (int) $row['group_id'], 'group_id' => (int) $row['group_id'],
@ -235,11 +235,11 @@ class acp_forums
'auth_setting' => (int) $row['auth_setting'] 'auth_setting' => (int) $row['auth_setting']
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Now insert the data // Now insert the data
$db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); phpbb::$db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary);
$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); phpbb::$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
cache_moderators(); cache_moderators();
} }
@ -282,9 +282,9 @@ class acp_forums
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -312,9 +312,9 @@ class acp_forums
$sql = 'SELECT forum_name, forum_topics_real $sql = 'SELECT forum_name, forum_topics_real
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -326,9 +326,9 @@ class acp_forums
$sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . $forum_id; WHERE forum_id = ' . $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row2 = $db->sql_fetchrow($result); $row2 = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Typecast to int if there is no data available // Typecast to int if there is no data available
$row2['min_topic_id'] = (int) $row2['min_topic_id']; $row2['min_topic_id'] = (int) $row2['min_topic_id'];
@ -350,9 +350,9 @@ class acp_forums
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . $forum_id . ' WHERE forum_id = ' . $forum_id . '
AND topic_id BETWEEN ' . $start . ' AND ' . $end; AND topic_id BETWEEN ' . $start . ' AND ' . $end;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topics_done = request_var('topics_done', 0) + (int) $db->sql_fetchfield('num_topics'); $topics_done = request_var('topics_done', 0) + (int) phpbb::$db->sql_fetchfield('num_topics');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$start += $batch_size; $start += $batch_size;
@ -390,9 +390,9 @@ class acp_forums
$sql = 'SELECT forum_name, forum_type $sql = 'SELECT forum_name, forum_type
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -557,15 +557,15 @@ class acp_forums
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . " WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id"; AND forum_id <> $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($db->sql_fetchrow($result)) if (phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_vars(array( $template->assign_vars(array(
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Subforum move options // Subforum move options
if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT) if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT)
@ -584,15 +584,15 @@ class acp_forums
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . " WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id"; AND forum_id <> $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($db->sql_fetchrow($result)) if (phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_vars(array( $template->assign_vars(array(
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false??? 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false???
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
@ -711,15 +711,15 @@ class acp_forums
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . " WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id"; AND forum_id <> $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($db->sql_fetchrow($result)) if (phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_vars(array( $template->assign_vars(array(
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false??? 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false???
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id; $parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id;
@ -776,9 +776,9 @@ class acp_forums
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE parent_id = $this->parent_id WHERE parent_id = $this->parent_id
ORDER BY left_id"; ORDER BY left_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
do do
{ {
@ -828,7 +828,7 @@ class acp_forums
'U_SYNC' => $url . '&amp;action=sync') 'U_SYNC' => $url . '&amp;action=sync')
); );
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
else if ($this->parent_id) else if ($this->parent_id)
{ {
@ -844,7 +844,7 @@ class acp_forums
'U_SYNC' => $url . '&amp;action=sync') 'U_SYNC' => $url . '&amp;action=sync')
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '', 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',
@ -866,9 +866,9 @@ class acp_forums
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -980,9 +980,9 @@ class acp_forums
$sql = 'SELECT left_id, right_id, forum_type $sql = 'SELECT left_id, right_id, forum_type
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $forum_data_sql['parent_id']; WHERE forum_id = ' . $forum_data_sql['parent_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -998,12 +998,12 @@ class acp_forums
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET left_id = left_id + 2, right_id = right_id + 2 SET left_id = left_id + 2, right_id = right_id + 2
WHERE left_id > ' . $row['right_id']; WHERE left_id > ' . $row['right_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET right_id = right_id + 2 SET right_id = right_id + 2
WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id'; WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$forum_data_sql['left_id'] = $row['right_id']; $forum_data_sql['left_id'] = $row['right_id'];
$forum_data_sql['right_id'] = $row['right_id'] + 1; $forum_data_sql['right_id'] = $row['right_id'] + 1;
@ -1012,18 +1012,18 @@ class acp_forums
{ {
$sql = 'SELECT MAX(right_id) AS right_id $sql = 'SELECT MAX(right_id) AS right_id
FROM ' . FORUMS_TABLE; FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$forum_data_sql['left_id'] = $row['right_id'] + 1; $forum_data_sql['left_id'] = $row['right_id'] + 1;
$forum_data_sql['right_id'] = $row['right_id'] + 2; $forum_data_sql['right_id'] = $row['right_id'] + 2;
} }
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql); $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $forum_data_sql);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$forum_data['forum_id'] = $db->sql_nextid(); $forum_data['forum_id'] = phpbb::$db->sql_nextid();
add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']); add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']);
} }
@ -1099,23 +1099,23 @@ class acp_forums
if (sizeof($forum_ids)) if (sizeof($forum_ids))
{ {
$sql = 'DELETE FROM ' . FORUMS_TABLE . ' $sql = 'DELETE FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Delete forum ids from extension groups table // Delete forum ids from extension groups table
$sql = 'SELECT group_id, allowed_forums $sql = 'SELECT group_id, allowed_forums
FROM ' . EXTENSION_GROUPS_TABLE; FROM ' . EXTENSION_GROUPS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($_row = $db->sql_fetchrow($result)) while ($_row = phpbb::$db->sql_fetchrow($result))
{ {
if (!$_row['allowed_forums']) if (!$_row['allowed_forums'])
{ {
@ -1128,9 +1128,9 @@ class acp_forums
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "'
WHERE group_id = {$_row['group_id']}"; WHERE group_id = {$_row['group_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
phpbb::$acm->destroy('extensions'); phpbb::$acm->destroy('extensions');
} }
@ -1145,9 +1145,9 @@ class acp_forums
$sql = 'SELECT forum_name $sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $subforums_to_id; WHERE forum_id = ' . $subforums_to_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$_row = $db->sql_fetchrow($result); $_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$_row) if (!$_row)
{ {
@ -1159,25 +1159,25 @@ class acp_forums
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE parent_id = {$row['forum_id']}"; WHERE parent_id = {$row['forum_id']}";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($_row = $db->sql_fetchrow($result)) while ($_row = phpbb::$db->sql_fetchrow($result))
{ {
$this->move_forum($_row['forum_id'], $subforums_to_id); $this->move_forum($_row['forum_id'], $subforums_to_id);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET parent_id = $subforums_to_id SET parent_id = $subforums_to_id
WHERE parent_id = {$row['forum_id']}"; WHERE parent_id = {$row['forum_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Adjust the left/right id // Adjust the left/right id
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET right_id = left_id + 1 SET right_id = left_id + 1
WHERE forum_id = ' . $row['forum_id']; WHERE forum_id = ' . $row['forum_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST) else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST)
@ -1223,7 +1223,7 @@ class acp_forums
// the forum name has changed, clear the parents list of all forums (for safety) // the forum name has changed, clear the parents list of all forums (for safety)
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET forum_parents = ''"; SET forum_parents = ''";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Setting the forum id to the forum id is not really received well by some dbs. ;) // Setting the forum id to the forum id is not really received well by some dbs. ;)
@ -1231,9 +1231,9 @@ class acp_forums
unset($forum_data_sql['forum_id']); unset($forum_data_sql['forum_id']);
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $forum_data_sql) . '
WHERE forum_id = ' . $forum_id; WHERE forum_id = ' . $forum_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Add it back // Add it back
$forum_data['forum_id'] = $forum_id; $forum_data['forum_id'] = $forum_id;
@ -1278,13 +1278,13 @@ class acp_forums
SET right_id = right_id - $diff, forum_parents = '' SET right_id = right_id - $diff, forum_parents = ''
WHERE left_id < " . $from_data['right_id'] . " WHERE left_id < " . $from_data['right_id'] . "
AND right_id > " . $from_data['right_id']; AND right_id > " . $from_data['right_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Resync righthand side of tree // Resync righthand side of tree
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = '' SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = ''
WHERE left_id > " . $from_data['right_id']; WHERE left_id > " . $from_data['right_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if ($to_id > 0) if ($to_id > 0)
{ {
@ -1295,15 +1295,15 @@ class acp_forums
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET right_id = right_id + $diff, forum_parents = '' SET right_id = right_id + $diff, forum_parents = ''
WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id
AND ' . $db->sql_in_set('forum_id', $moved_ids, true); AND ' . phpbb::$db->sql_in_set('forum_id', $moved_ids, true);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Resync the righthand side of the tree // Resync the righthand side of the tree
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = '' SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = ''
WHERE left_id > " . $to_data['right_id'] . ' WHERE left_id > " . $to_data['right_id'] . '
AND ' . $db->sql_in_set('forum_id', $moved_ids, true); AND ' . phpbb::$db->sql_in_set('forum_id', $moved_ids, true);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Resync moved branch // Resync moved branch
$to_data['right_id'] += $diff; $to_data['right_id'] += $diff;
@ -1321,18 +1321,18 @@ class acp_forums
{ {
$sql = 'SELECT MAX(right_id) AS right_id $sql = 'SELECT MAX(right_id) AS right_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true); WHERE ' . phpbb::$db->sql_in_set('forum_id', $moved_ids, true);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1); $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1);
} }
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = ''
WHERE " . $db->sql_in_set('forum_id', $moved_ids); WHERE " . phpbb::$db->sql_in_set('forum_id', $moved_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
return $errors; return $errors;
} }
@ -1349,7 +1349,7 @@ class acp_forums
$sql = "UPDATE $table $sql = "UPDATE $table
SET forum_id = $to_id SET forum_id = $to_id
WHERE forum_id = $from_id"; WHERE forum_id = $from_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
unset($table_ary); unset($table_ary);
@ -1359,7 +1359,7 @@ class acp_forums
{ {
$sql = "DELETE FROM $table $sql = "DELETE FROM $table
WHERE forum_id = $from_id"; WHERE forum_id = $from_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if ($sync) if ($sync)
@ -1401,9 +1401,9 @@ class acp_forums
$sql = 'SELECT forum_name $sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $posts_to_id; WHERE forum_id = ' . $posts_to_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -1441,16 +1441,16 @@ class acp_forums
$diff = sizeof($forum_ids) * 2; $diff = sizeof($forum_ids) * 2;
$sql = 'DELETE FROM ' . FORUMS_TABLE . ' $sql = 'DELETE FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else if ($action_subforums == 'move') else if ($action_subforums == 'move')
{ {
@ -1465,9 +1465,9 @@ class acp_forums
$sql = 'SELECT forum_name $sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $subforums_to_id; WHERE forum_id = ' . $subforums_to_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -1480,13 +1480,13 @@ class acp_forums
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE parent_id = $forum_id"; WHERE parent_id = $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$this->move_forum($row['forum_id'], $subforums_to_id); $this->move_forum($row['forum_id'], $subforums_to_id);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Grab new forum data for correct tree updating later // Grab new forum data for correct tree updating later
$forum_data = $this->get_forum_info($forum_id); $forum_data = $this->get_forum_info($forum_id);
@ -1494,20 +1494,20 @@ class acp_forums
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET parent_id = $subforums_to_id SET parent_id = $subforums_to_id
WHERE parent_id = $forum_id"; WHERE parent_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$diff = 2; $diff = 2;
$sql = 'DELETE FROM ' . FORUMS_TABLE . " $sql = 'DELETE FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . " $sql = 'DELETE FROM ' . ACL_USERS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1521,34 +1521,34 @@ class acp_forums
$diff = 2; $diff = 2;
$sql = 'DELETE FROM ' . FORUMS_TABLE . " $sql = 'DELETE FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . " $sql = 'DELETE FROM ' . ACL_USERS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Resync tree // Resync tree
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET right_id = right_id - $diff SET right_id = right_id - $diff
WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}"; WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET left_id = left_id - $diff, right_id = right_id - $diff SET left_id = left_id - $diff, right_id = right_id - $diff
WHERE left_id > {$forum_data['right_id']}"; WHERE left_id > {$forum_data['right_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Delete forum ids from extension groups table // Delete forum ids from extension groups table
$sql = 'SELECT group_id, allowed_forums $sql = 'SELECT group_id, allowed_forums
FROM ' . EXTENSION_GROUPS_TABLE; FROM ' . EXTENSION_GROUPS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!$row['allowed_forums']) if (!$row['allowed_forums'])
{ {
@ -1561,9 +1561,9 @@ class acp_forums
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "'
WHERE group_id = {$row['group_id']}"; WHERE group_id = {$row['group_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
phpbb::$acm->destroy('extensions'); phpbb::$acm->destroy('extensions');
@ -1618,7 +1618,7 @@ class acp_forums
{ {
include_once(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT);
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
// Select then delete all attachments // Select then delete all attachments
$sql = 'SELECT a.topic_id $sql = 'SELECT a.topic_id
@ -1626,14 +1626,14 @@ class acp_forums
WHERE p.forum_id = $forum_id WHERE p.forum_id = $forum_id
AND a.in_message = 0 AND a.in_message = 0
AND a.topic_id = p.topic_id"; AND a.topic_id = p.topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_ids = array(); $topic_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_ids[] = $row['topic_id']; $topic_ids[] = $row['topic_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
delete_attachments('topic', $topic_ids, false); delete_attachments('topic', $topic_ids, false);
@ -1643,16 +1643,16 @@ class acp_forums
WHERE forum_id = ' . $forum_id . ' WHERE forum_id = ' . $forum_id . '
AND post_postcount = 1 AND post_postcount = 1
AND post_approved = 1'; AND post_approved = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_counts = array(); $post_counts = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
switch ($db->dbms_type) switch (phpbb::$db->dbms_type)
{ {
case 'mysql': case 'mysql':
@ -1679,7 +1679,7 @@ class acp_forums
$sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field"; $sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field";
} }
$db->sql_query($sql . $sql_using . $sql_where); phpbb::$db->sql_query($sql . $sql_using . $sql_where);
break; break;
@ -1711,14 +1711,14 @@ class acp_forums
$sql = "SELECT $field $sql = "SELECT $field
FROM " . POSTS_TABLE . ' FROM " . POSTS_TABLE . '
WHERE forum_id = ' . $forum_id; WHERE forum_id = ' . $forum_id;
$result = $db->sql_query_limit($sql, 500, $start); $result = phpbb::$db->sql_query_limit($sql, 500, $start);
$ids = array(); $ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ids[] = $row[$field]; $ids[] = $row[$field];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($ids)) if (sizeof($ids))
{ {
@ -1726,7 +1726,7 @@ class acp_forums
foreach ($tables as $table) foreach ($tables as $table)
{ {
$db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids)); phpbb::$db->sql_query("DELETE FROM $table WHERE " . phpbb::$db->sql_in_set($field, $ids));
} }
} }
} }
@ -1741,7 +1741,7 @@ class acp_forums
foreach ($table_ary as $table) foreach ($table_ary as $table)
{ {
$db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); phpbb::$db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id");
} }
// Set forum ids to 0 // Set forum ids to 0
@ -1749,7 +1749,7 @@ class acp_forums
foreach ($table_ary as $table) foreach ($table_ary as $table)
{ {
$db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id"); phpbb::$db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id");
} }
// Adjust users post counts // Adjust users post counts
@ -1761,50 +1761,50 @@ class acp_forums
SET user_posts = 0 SET user_posts = 0
WHERE user_id = ' . $poster_id . ' WHERE user_id = ' . $poster_id . '
AND user_posts < ' . $substract; AND user_posts < ' . $substract;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts - ' . $substract . ' SET user_posts = user_posts - ' . $substract . '
WHERE user_id = ' . $poster_id . ' WHERE user_id = ' . $poster_id . '
AND user_posts >= ' . $substract; AND user_posts >= ' . $substract;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
// Make sure the overall post/topic count is correct... // Make sure the overall post/topic count is correct...
$sql = 'SELECT COUNT(post_id) AS stat $sql = 'SELECT COUNT(post_id) AS stat
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_approved = 1'; WHERE post_approved = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
set_config('num_posts', (int) $row['stat'], true); set_config('num_posts', (int) $row['stat'], true);
$sql = 'SELECT COUNT(topic_id) AS stat $sql = 'SELECT COUNT(topic_id) AS stat
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_approved = 1'; WHERE topic_approved = 1';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
set_config('num_topics', (int) $row['stat'], true); set_config('num_topics', (int) $row['stat'], true);
$sql = 'SELECT COUNT(attach_id) as stat $sql = 'SELECT COUNT(attach_id) as stat
FROM ' . ATTACHMENTS_TABLE; FROM ' . ATTACHMENTS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
set_config('num_files', (int) $row['stat'], true); set_config('num_files', (int) $row['stat'], true);
$sql = 'SELECT SUM(filesize) as stat $sql = 'SELECT SUM(filesize) as stat
FROM ' . ATTACHMENTS_TABLE; FROM ' . ATTACHMENTS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
set_config('upload_dir_size', (float) $row['stat'], true); set_config('upload_dir_size', (float) $row['stat'], true);
@ -1826,14 +1826,14 @@ class acp_forums
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE parent_id = {$forum_row['parent_id']} WHERE parent_id = {$forum_row['parent_id']}
AND " . (($action == 'move_up') ? "right_id < {$forum_row['right_id']} ORDER BY right_id DESC" : "left_id > {$forum_row['left_id']} ORDER BY left_id ASC"); AND " . (($action == 'move_up') ? "right_id < {$forum_row['right_id']} ORDER BY right_id DESC" : "left_id > {$forum_row['left_id']} ORDER BY left_id ASC");
$result = $db->sql_query_limit($sql, $steps); $result = phpbb::$db->sql_query_limit($sql, $steps);
$target = array(); $target = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$target = $row; $target = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($target)) if (!sizeof($target))
{ {
@ -1885,7 +1885,7 @@ class acp_forums
WHERE WHERE
left_id BETWEEN {$left_id} AND {$right_id} left_id BETWEEN {$left_id} AND {$right_id}
AND right_id BETWEEN {$left_id} AND {$right_id}"; AND right_id BETWEEN {$left_id} AND {$right_id}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
return $target['forum_name']; return $target['forum_name'];
} }

View file

@ -57,9 +57,9 @@ class acp_groups
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_row = $db->sql_fetchrow($result); $group_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$group_row) if (!$group_row)
{ {
@ -134,16 +134,16 @@ class acp_groups
FROM ' . USER_GROUP_TABLE . " FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id WHERE group_id = $group_id
ORDER BY user_id"; ORDER BY user_id";
$result = $db->sql_query_limit($sql, 200, $start); $result = phpbb::$db->sql_query_limit($sql, 200, $start);
$mark_ary = array(); $mark_ary = array();
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
do do
{ {
$mark_ary[] = $row['user_id']; $mark_ary[] = $row['user_id'];
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row); group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
@ -153,7 +153,7 @@ class acp_groups
{ {
$start = 0; $start = 0;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
while ($start); while ($start);
} }
@ -421,9 +421,9 @@ class acp_groups
$sql = 'SELECT group_founder_manage $sql = 'SELECT group_founder_manage
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . $group_perm_from; WHERE group_id = ' . $group_perm_from;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$check_row = $db->sql_fetchrow($result); $check_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Check the group if non-founder // Check the group if non-founder
if ($check_row && (phpbb::$user->is_founder || $check_row['group_founder_manage'] == 0)) if ($check_row && (phpbb::$user->is_founder || $check_row['group_founder_manage'] == 0))
@ -437,10 +437,10 @@ class acp_groups
$sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_GROUPS_TABLE . ' FROM ' . ACL_GROUPS_TABLE . '
WHERE group_id = ' . $group_perm_from; WHERE group_id = ' . $group_perm_from;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$groups_sql_ary = array(); $groups_sql_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$groups_sql_ary[] = array( $groups_sql_ary[] = array(
'group_id' => (int) $group_id, 'group_id' => (int) $group_id,
@ -450,10 +450,10 @@ class acp_groups
'auth_setting' => (int) $row['auth_setting'] 'auth_setting' => (int) $row['auth_setting']
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Now insert the data // Now insert the data
$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); phpbb::$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
phpbb::$acl->acl_clear_prefetch(); phpbb::$acl->acl_clear_prefetch();
} }
@ -502,16 +502,16 @@ class acp_groups
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
WHERE rank_special = 1 WHERE rank_special = 1
ORDER BY rank_title'; ORDER BY rank_title';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['USER_DEFAULT'] . '</option>'; $rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['USER_DEFAULT'] . '</option>';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
$rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : ''; $type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : '';
$type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : ''; $type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : '';
@ -613,9 +613,9 @@ class acp_groups
AND u.user_id = ug.user_id AND u.user_id = ug.user_id
AND ug.group_leader = 1 AND ug.group_leader = 1
ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean"; ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('leader', array( $template->assign_block_vars('leader', array(
'U_USER_EDIT' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, "i=users&amp;action=edit&amp;u={$row['user_id']}"), 'U_USER_EDIT' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, "i=users&amp;action=edit&amp;u={$row['user_id']}"),
@ -627,16 +627,16 @@ class acp_groups
'USER_ID' => $row['user_id']) 'USER_ID' => $row['user_id'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Total number of group members (non-leaders) // Total number of group members (non-leaders)
$sql = 'SELECT COUNT(user_id) AS total_members $sql = 'SELECT COUNT(user_id) AS total_members
FROM ' . USER_GROUP_TABLE . " FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id WHERE group_id = $group_id
AND group_leader = 0"; AND group_leader = 0";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$total_members = (int) $db->sql_fetchfield('total_members'); $total_members = (int) phpbb::$db->sql_fetchfield('total_members');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$s_action_options = ''; $s_action_options = '';
$options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE'); $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE');
@ -668,11 +668,11 @@ class acp_groups
AND u.user_id = ug.user_id AND u.user_id = ug.user_id
AND ug.group_leader = 0 AND ug.group_leader = 0
ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean"; ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$pending = false; $pending = false;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['user_pending'] && !$pending) if ($row['user_pending'] && !$pending)
{ {
@ -693,7 +693,7 @@ class acp_groups
'USER_ID' => $row['user_id']) 'USER_ID' => $row['user_id'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return; return;
break; break;
@ -708,10 +708,10 @@ class acp_groups
$sql = 'SELECT g.group_id, g.group_name, g.group_type $sql = 'SELECT g.group_id, g.group_name, g.group_type
FROM ' . GROUPS_TABLE . ' g FROM ' . GROUPS_TABLE . ' g
ORDER BY g.group_type ASC, g.group_name'; ORDER BY g.group_type ASC, g.group_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$lookup = $cached_group_data = array(); $lookup = $cached_group_data = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal'; $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal';
@ -722,21 +722,21 @@ class acp_groups
$cached_group_data[$type][$row['group_id']] = $row; $cached_group_data[$type][$row['group_id']] = $row;
$cached_group_data[$type][$row['group_id']]['total_members'] = 0; $cached_group_data[$type][$row['group_id']]['total_members'] = 0;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// How many people are in which group? // How many people are in which group?
$sql = 'SELECT COUNT(ug.user_id) AS total_members, ug.group_id $sql = 'SELECT COUNT(ug.user_id) AS total_members, ug.group_id
FROM ' . USER_GROUP_TABLE . ' ug FROM ' . USER_GROUP_TABLE . ' ug
WHERE ' . $db->sql_in_set('ug.group_id', array_keys($lookup)) . ' WHERE ' . phpbb::$db->sql_in_set('ug.group_id', array_keys($lookup)) . '
GROUP BY ug.group_id'; GROUP BY ug.group_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$type = $lookup[$row['group_id']]; $type = $lookup[$row['group_id']];
$cached_group_data[$type][$row['group_id']]['total_members'] = $row['total_members']; $cached_group_data[$type][$row['group_id']]['total_members'] = $row['total_members'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// The order is... normal, then special // The order is... normal, then special
ksort($cached_group_data); ksort($cached_group_data);

View file

@ -130,16 +130,16 @@ class acp_icons
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . SMILIES_TABLE . ' FROM ' . SMILIES_TABLE . '
ORDER BY smiley_order'; ORDER BY smiley_order';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (empty($smilies[$row['smiley_url']])) if (empty($smilies[$row['smiley_url']]))
{ {
$smilies[$row['smiley_url']] = $row; $smilies[$row['smiley_url']] = $row;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($smilies)) if (sizeof($smilies))
{ {
@ -169,7 +169,7 @@ class acp_icons
$sql = "SELECT * $sql = "SELECT *
FROM $table FROM $table
ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC'); ORDER BY {$fields}_order " . (($icon_id || $action == 'add') ? 'DESC' : 'ASC');
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$data = array(); $data = array();
$after = false; $after = false;
@ -178,7 +178,7 @@ class acp_icons
$add_order_lists = array('', ''); $add_order_lists = array('', '');
$display_count = 0; $display_count = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($action == 'add') if ($action == 'add')
{ {
@ -218,7 +218,7 @@ class acp_icons
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['FIRST'] . '</option>'; $order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['FIRST'] . '</option>';
$add_order_list = '<option value="1">' . phpbb::$user->lang['FIRST'] . '</option>'; $add_order_list = '<option value="1">' . phpbb::$user->lang['FIRST'] . '</option>';
@ -392,7 +392,7 @@ class acp_icons
$sql = "UPDATE $table $sql = "UPDATE $table
SET {$fields}_order = {$fields}_order + 1 SET {$fields}_order = {$fields}_order + 1
WHERE {$fields}_order >= {$image_order[$image]}"; WHERE {$fields}_order >= {$image_order[$image]}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// If we adjust the order, we need to adjust all other orders too - they became inaccurate... // If we adjust the order, we need to adjust all other orders too - they became inaccurate...
foreach ($image_order as $_image => $_order) foreach ($image_order as $_image => $_order)
@ -412,15 +412,15 @@ class acp_icons
if ($action == 'modify' && !empty($image_id[$image])) if ($action == 'modify' && !empty($image_id[$image]))
{ {
$sql = "UPDATE $table $sql = "UPDATE $table
SET " . $db->sql_build_array('UPDATE', $img_sql) . " SET " . phpbb::$db->sql_build_array('UPDATE', $img_sql) . "
WHERE {$fields}_id = " . $image_id[$image]; WHERE {$fields}_id = " . $image_id[$image];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$icons_updated++; $icons_updated++;
} }
else if ($action !== 'modify') else if ($action !== 'modify')
{ {
$sql = "INSERT INTO $table " . $db->sql_build_array('INSERT', $img_sql); $sql = "INSERT INTO $table " . phpbb::$db->sql_build_array('INSERT', $img_sql);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$icons_updated++; $icons_updated++;
} }
@ -496,13 +496,13 @@ class acp_icons
// The user has already selected a smilies_pak file // The user has already selected a smilies_pak file
if ($current == 'delete') if ($current == 'delete')
{ {
if ($db->truncate) if (phpbb::$db->truncate)
{ {
$db->sql_query('TRUNCATE TABLE ' . $table); phpbb::$db->sql_query('TRUNCATE TABLE ' . $table);
} }
else else
{ {
$db->sql_query('DELETE FROM ' . $table); phpbb::$db->sql_query('DELETE FROM ' . $table);
} }
switch ($mode) switch ($mode)
@ -512,8 +512,8 @@ class acp_icons
case 'icons': case 'icons':
// Reset all icon_ids // Reset all icon_ids
$db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET icon_id = 0'); phpbb::$db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET icon_id = 0');
$db->sql_query('UPDATE ' . POSTS_TABLE . ' SET icon_id = 0'); phpbb::$db->sql_query('UPDATE ' . POSTS_TABLE . ' SET icon_id = 0');
break; break;
} }
} }
@ -525,14 +525,14 @@ class acp_icons
$sql = "SELECT $field_sql $sql = "SELECT $field_sql
FROM $table"; FROM $table";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
++$order; ++$order;
$cur_img[$row[$field_sql]] = 1; $cur_img[$row[$field_sql]] = 1;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($pak_ary as $pak_entry) foreach ($pak_ary as $pak_entry)
@ -577,9 +577,9 @@ class acp_icons
)); ));
} }
$sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql) . " $sql = "UPDATE $table SET " . phpbb::$db->sql_build_array('UPDATE', $sql) . "
WHERE $field_sql = '" . $db->sql_escape($replace_sql) . "'"; WHERE $field_sql = '" . phpbb::$db->sql_escape($replace_sql) . "'";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
@ -600,7 +600,7 @@ class acp_icons
'emotion' => $emotion, 'emotion' => $emotion,
)); ));
} }
$db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql)); phpbb::$db->sql_query("INSERT INTO $table " . phpbb::$db->sql_build_array('INSERT', $sql));
} }
} }
} }
@ -659,10 +659,10 @@ class acp_icons
$sql = "SELECT * $sql = "SELECT *
FROM $table FROM $table
ORDER BY {$fields}_order"; ORDER BY {$fields}_order";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$pak = ''; $pak = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$pak .= "'" . addslashes($row[$fields . '_url']) . "', "; $pak .= "'" . addslashes($row[$fields . '_url']) . "', ";
$pak .= "'" . addslashes($row[$fields . '_width']) . "', "; $pak .= "'" . addslashes($row[$fields . '_width']) . "', ";
@ -677,7 +677,7 @@ class acp_icons
$pak .= "\n"; $pak .= "\n";
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($pak != '') if ($pak != '')
{ {
@ -706,7 +706,7 @@ class acp_icons
{ {
$sql = "DELETE FROM $table $sql = "DELETE FROM $table
WHERE {$fields}_id = $icon_id"; WHERE {$fields}_id = $icon_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
switch ($mode) switch ($mode)
{ {
@ -715,11 +715,11 @@ class acp_icons
case 'icons': case 'icons':
// Reset appropriate icon_ids // Reset appropriate icon_ids
$db->sql_query('UPDATE ' . TOPICS_TABLE . " phpbb::$db->sql_query('UPDATE ' . TOPICS_TABLE . "
SET icon_id = 0 SET icon_id = 0
WHERE icon_id = $icon_id"); WHERE icon_id = $icon_id");
$db->sql_query('UPDATE ' . POSTS_TABLE . " phpbb::$db->sql_query('UPDATE ' . POSTS_TABLE . "
SET icon_id = 0 SET icon_id = 0
WHERE icon_id = $icon_id"); WHERE icon_id = $icon_id");
break; break;
@ -749,9 +749,9 @@ class acp_icons
$sql = "SELECT {$fields}_order as current_order $sql = "SELECT {$fields}_order as current_order
FROM $table FROM $table
WHERE {$fields}_id = $icon_id"; WHERE {$fields}_id = $icon_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$current_order = (int) $db->sql_fetchfield('current_order'); $current_order = (int) phpbb::$db->sql_fetchfield('current_order');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($current_order == 0 && $action == 'move_up') if ($current_order == 0 && $action == 'move_up')
{ {
@ -767,16 +767,16 @@ class acp_icons
SET {$fields}_order = $current_order SET {$fields}_order = $current_order
WHERE {$fields}_order = $switch_order_id WHERE {$fields}_order = $switch_order_id
AND {$fields}_id <> $icon_id"; AND {$fields}_id <> $icon_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Only update the other entry too if the previous entry got updated // Only update the other entry too if the previous entry got updated
if ($db->sql_affectedrows()) if (phpbb::$db->sql_affectedrows())
{ {
$sql = "UPDATE $table $sql = "UPDATE $table
SET {$fields}_order = $switch_order_id SET {$fields}_order = $switch_order_id
WHERE {$fields}_order = $current_order WHERE {$fields}_order = $current_order
AND {$fields}_id = $icon_id"; AND {$fields}_id = $icon_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
phpbb::$acm->destroy('icons'); phpbb::$acm->destroy('icons');
@ -789,9 +789,9 @@ class acp_icons
$sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order $sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order
FROM $table FROM $table
ORDER BY display_on_posting DESC, {$fields}_order"; ORDER BY display_on_posting DESC, {$fields}_order";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$order = 0; $order = 0;
do do
@ -799,14 +799,14 @@ class acp_icons
++$order; ++$order;
if ($row['fields_order'] != $order) if ($row['fields_order'] != $order)
{ {
$db->sql_query("UPDATE $table phpbb::$db->sql_query("UPDATE $table
SET {$fields}_order = $order SET {$fields}_order = $order
WHERE {$fields}_id = " . $row['order_id']); WHERE {$fields}_id = " . $row['order_id']);
} }
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'L_TITLE' => phpbb::$user->lang['ACP_' . $lang], 'L_TITLE' => phpbb::$user->lang['ACP_' . $lang],
@ -833,9 +833,9 @@ class acp_icons
$sql = "SELECT * $sql = "SELECT *
FROM $table FROM $table
ORDER BY {$fields}_order ASC"; ORDER BY {$fields}_order ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$alt_text = ($mode == 'smilies') ? $row['code'] : ''; $alt_text = ($mode == 'smilies') ? $row['code'] : '';
@ -858,7 +858,7 @@ class acp_icons
$spacer = true; $spacer = true;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }

View file

@ -62,15 +62,15 @@ class acp_inactive
$sql = 'SELECT user_id, username $sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $mark); WHERE ' . phpbb::$db->sql_in_set('user_id', $mark);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_affected = array(); $user_affected = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$user_affected[$row['user_id']] = $row['username']; $user_affected[$row['user_id']] = $row['username'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($action == 'activate') if ($action == 'activate')
{ {
@ -79,16 +79,16 @@ class acp_inactive
// Get those 'being activated'... // Get those 'being activated'...
$sql = 'SELECT user_id, username, user_email, user_lang $sql = 'SELECT user_id, username, user_email, user_lang
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $mark) . ' WHERE ' . phpbb::$db->sql_in_set('user_id', $mark) . '
AND user_type = ' . phpbb::USER_INACTIVE; AND user_type = ' . phpbb::USER_INACTIVE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$inactive_users = array(); $inactive_users = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$inactive_users[] = $row; $inactive_users[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
user_active_flip('activate', $mark); user_active_flip('activate', $mark);
@ -158,10 +158,10 @@ class acp_inactive
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $mark); WHERE ' . phpbb::$db->sql_in_set('user_id', $mark);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Send the messages // Send the messages
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);
@ -186,14 +186,14 @@ class acp_inactive
$usernames[] = $row['username']; $usernames[] = $row['username'];
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
$messenger->save_queue(); $messenger->save_queue();
add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames)); add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
unset($usernames); unset($usernames);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
break; break;
} }

View file

@ -91,9 +91,9 @@ class acp_jabber
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_notify_type = ' . NOTIFY_IM; WHERE user_notify_type = ' . NOTIFY_IM;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
set_config('jab_enable', $jab_enable); set_config('jab_enable', $jab_enable);

View file

@ -171,9 +171,9 @@ class acp_language
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
WHERE lang_id = $lang_id"; WHERE lang_id = $lang_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_ary = array( $sql_ary = array(
'lang_english_name' => request_var('lang_english_name', $row['lang_english_name']), 'lang_english_name' => request_var('lang_english_name', $row['lang_english_name']),
@ -181,8 +181,8 @@ class acp_language
'lang_author' => utf8_normalize_nfc(request_var('lang_author', $row['lang_author'], true)), 'lang_author' => utf8_normalize_nfc(request_var('lang_author', $row['lang_author'], true)),
); );
$db->sql_query('UPDATE ' . LANG_TABLE . ' phpbb::$db->sql_query('UPDATE ' . LANG_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE lang_id = ' . $lang_id); WHERE lang_id = ' . $lang_id);
add_log('admin', 'LOG_LANGUAGE_PACK_UPDATED', $sql_ary['lang_english_name']); add_log('admin', 'LOG_LANGUAGE_PACK_UPDATED', $sql_ary['lang_english_name']);
@ -217,9 +217,9 @@ class acp_language
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
WHERE lang_id = $lang_id"; WHERE lang_id = $lang_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -382,9 +382,9 @@ class acp_language
$sql = 'SELECT lang_iso $sql = 'SELECT lang_iso
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
WHERE lang_id = $lang_id"; WHERE lang_id = $lang_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$file = request_var('file', ''); $file = request_var('file', '');
$dir = request_var('dir', ''); $dir = request_var('dir', '');
@ -451,9 +451,9 @@ class acp_language
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . LANG_TABLE . ' FROM ' . LANG_TABLE . '
WHERE lang_id = ' . $lang_id; WHERE lang_id = ' . $lang_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$lang_entries = $db->sql_fetchrow($result); $lang_entries = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$lang_iso = $lang_entries['lang_iso']; $lang_iso = $lang_entries['lang_iso'];
$missing_vars = $missing_files = array(); $missing_vars = $missing_files = array();
@ -769,31 +769,31 @@ class acp_language
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . LANG_TABLE . ' FROM ' . LANG_TABLE . '
WHERE lang_id = ' . $lang_id; WHERE lang_id = ' . $lang_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row['lang_iso'] == phpbb::$config['default_lang']) if ($row['lang_iso'] == phpbb::$config['default_lang'])
{ {
trigger_error(phpbb::$user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error(phpbb::$user->lang['NO_REMOVE_DEFAULT_LANG'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
$db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id); phpbb::$db->sql_query('DELETE FROM ' . LANG_TABLE . ' WHERE lang_id = ' . $lang_id);
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_lang = '" . $db->sql_escape(phpbb::$config['default_lang']) . "' SET user_lang = '" . phpbb::$db->sql_escape(phpbb::$config['default_lang']) . "'
WHERE user_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; WHERE user_lang = '" . phpbb::$db->sql_escape($row['lang_iso']) . "'";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// We also need to remove the translated entries for custom profile fields - we want clean tables, don't we? // We also need to remove the translated entries for custom profile fields - we want clean tables, don't we?
$sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id; $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' WHERE lang_id = ' . $lang_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . $db->sql_escape($row['lang_iso']) . "'"; $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_lang = '" . phpbb::$db->sql_escape($row['lang_iso']) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE);
@ -823,10 +823,10 @@ class acp_language
$sql = 'SELECT lang_iso $sql = 'SELECT lang_iso
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $db->sql_escape($lang_iso) . "'"; WHERE lang_iso = '" . phpbb::$db->sql_escape($lang_iso) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -847,8 +847,8 @@ class acp_language
'lang_author' => $lang_pack['author'] 'lang_author' => $lang_pack['author']
); );
$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
$lang_id = $db->sql_nextid(); $lang_id = phpbb::$db->sql_nextid();
$valid_localized = array( $valid_localized = array(
'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply', 'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply',
@ -858,8 +858,8 @@ class acp_language
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . STYLES_IMAGESET_TABLE; FROM ' . STYLES_IMAGESET_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($imageset_row = $db->sql_fetchrow($result)) while ($imageset_row = phpbb::$db->sql_fetchrow($result))
{ {
if (@file_exists(PHPBB_ROOT_PATH . "styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg")) if (@file_exists(PHPBB_ROOT_PATH . "styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['iso']}/imageset.cfg"))
{ {
@ -902,21 +902,21 @@ class acp_language
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE);
} }
// Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier. // Now let's copy the default language entries for custom profile fields for this new language - makes admin's life easier.
$sql = 'SELECT lang_id $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $db->sql_escape(phpbb::$config['default_lang']) . "'"; WHERE lang_iso = '" . phpbb::$db->sql_escape(phpbb::$config['default_lang']) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id'); $default_lang_id = (int) phpbb::$db->sql_fetchfield('lang_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// From the mysql documentation: // 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. // 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.
@ -925,26 +925,26 @@ class acp_language
$sql = 'SELECT field_id, lang_name, lang_explain, lang_default_value $sql = 'SELECT field_id, lang_name, lang_explain, lang_default_value
FROM ' . PROFILE_LANG_TABLE . ' FROM ' . PROFILE_LANG_TABLE . '
WHERE lang_id = ' . $default_lang_id; WHERE lang_id = ' . $default_lang_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$row['lang_id'] = $lang_id; $row['lang_id'] = $lang_id;
$db->sql_query('INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row)); phpbb::$db->sql_query('INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $row));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT field_id, option_id, field_type, lang_value $sql = 'SELECT field_id, option_id, field_type, lang_value
FROM ' . PROFILE_FIELDS_LANG_TABLE . ' FROM ' . PROFILE_FIELDS_LANG_TABLE . '
WHERE lang_id = ' . $default_lang_id; WHERE lang_id = ' . $default_lang_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$row['lang_id'] = $lang_id; $row['lang_id'] = $lang_id;
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $row)); phpbb::$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $row));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
add_log('admin', 'LOG_LANGUAGE_PACK_INSTALLED', $lang_pack['name']); add_log('admin', 'LOG_LANGUAGE_PACK_INSTALLED', $lang_pack['name']);
@ -962,9 +962,9 @@ class acp_language
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . LANG_TABLE . ' FROM ' . LANG_TABLE . '
WHERE lang_id = ' . $lang_id; WHERE lang_id = ' . $lang_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$use_method = request_var('use_method', ''); $use_method = request_var('use_method', '');
$methods = array('.tar'); $methods = array('.tar');
@ -1077,23 +1077,23 @@ class acp_language
$sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count $sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
GROUP BY user_lang'; GROUP BY user_lang';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$lang_count = array(); $lang_count = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$lang_count[$row['user_lang']] = $row['lang_count']; $lang_count[$row['user_lang']] = $row['lang_count'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . LANG_TABLE . ' FROM ' . LANG_TABLE . '
ORDER BY lang_english_name'; ORDER BY lang_english_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$installed = array(); $installed = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$installed[] = $row['lang_iso']; $installed[] = $row['lang_iso'];
$tagstyle = ($row['lang_iso'] == phpbb::$config['default_lang']) ? '*' : ''; $tagstyle = ($row['lang_iso'] == phpbb::$config['default_lang']) ? '*' : '';
@ -1110,7 +1110,7 @@ class acp_language
'USED_BY' => (isset($lang_count[$row['lang_iso']])) ? $lang_count[$row['lang_iso']] : 0, 'USED_BY' => (isset($lang_count[$row['lang_iso']])) ? $lang_count[$row['lang_iso']] : 0,
)); ));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$new_ary = $iso = array(); $new_ary = $iso = array();
$dp = @opendir(PHPBB_ROOT_PATH . 'language'); $dp = @opendir(PHPBB_ROOT_PATH . 'language');

View file

@ -57,7 +57,7 @@ class acp_logs
{ {
$sql_in[] = $mark; $sql_in[] = $mark;
} }
$where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); $where_sql = ' AND ' . phpbb::$db->sql_in_set('log_id', $sql_in);
unset($sql_in); unset($sql_in);
} }
@ -66,7 +66,7 @@ class acp_logs
$sql = 'DELETE FROM ' . LOG_TABLE . " $sql = 'DELETE FROM ' . LOG_TABLE . "
WHERE log_type = {$this->log_type} WHERE log_type = {$this->log_type}
$where_sql"; $where_sql";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_' . strtoupper($mode)); add_log('admin', 'LOG_CLEAR_' . strtoupper($mode));
} }

View file

@ -90,9 +90,9 @@ class acp_permission_roles
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ACL_ROLES_TABLE . ' FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$role_row = $db->sql_fetchrow($result); $role_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$role_row) if (!$role_row)
{ {
@ -129,9 +129,9 @@ class acp_permission_roles
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ACL_ROLES_TABLE . ' FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$role_row = $db->sql_fetchrow($result); $role_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$role_row) if (!$role_row)
{ {
@ -164,11 +164,11 @@ class acp_permission_roles
// if we add/edit a role we check the name to be unique among the settings... // if we add/edit a role we check the name to be unique among the settings...
$sql = 'SELECT role_id $sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . " FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = '" . $db->sql_escape($permission_type) . "' WHERE role_type = '" . phpbb::$db->sql_escape($permission_type) . "'
AND role_name = '" . $db->sql_escape($role_name) . "'"; AND role_name = '" . phpbb::$db->sql_escape($role_name) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Make sure we only print out the error if we add the role or change it's name // Make sure we only print out the error if we add the role or change it's name
if ($row && ($mode == 'add' || ($mode == 'edit' && $role_row['role_name'] != $role_name))) if ($row && ($mode == 'add' || ($mode == 'edit' && $role_row['role_name'] != $role_name)))
@ -185,26 +185,26 @@ class acp_permission_roles
if ($action == 'edit') if ($action == 'edit')
{ {
$sql = 'UPDATE ' . ACL_ROLES_TABLE . ' $sql = 'UPDATE ' . ACL_ROLES_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
// Get maximum role order for inserting a new role... // Get maximum role order for inserting a new role...
$sql = 'SELECT MAX(role_order) as max_order $sql = 'SELECT MAX(role_order) as max_order
FROM ' . ACL_ROLES_TABLE . " FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = '" . $db->sql_escape($permission_type) . "'"; WHERE role_type = '" . phpbb::$db->sql_escape($permission_type) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$max_order = (int) $db->sql_fetchfield('max_order'); $max_order = (int) phpbb::$db->sql_fetchfield('max_order');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_ary['role_order'] = $max_order + 1; $sql_ary['role_order'] = $max_order + 1;
$sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$role_id = $db->sql_nextid(); $role_id = phpbb::$db->sql_nextid();
} }
// Now add the auth settings // Now add the auth settings
@ -239,30 +239,30 @@ class acp_permission_roles
WHERE o.auth_option_id = p.auth_option_id WHERE o.auth_option_id = p.auth_option_id
AND p.role_id = ' . $options_from . ' AND p.role_id = ' . $options_from . '
ORDER BY p.auth_option_id'; ORDER BY p.auth_option_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$auth_options = array(); $auth_options = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$auth_options[$row['auth_option']] = $row['auth_setting']; $auth_options[$row['auth_option']] = $row['auth_setting'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
$sql = 'SELECT auth_option_id, auth_option $sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . " WHERE auth_option " . phpbb::$db->sql_like_expression($permission_type . phpbb::$db->any_char) . "
AND auth_option <> '{$permission_type}' AND auth_option <> '{$permission_type}'
ORDER BY auth_option_id"; ORDER BY auth_option_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$auth_options = array(); $auth_options = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$auth_options[$row['auth_option']] = phpbb::ACL_NO; $auth_options[$row['auth_option']] = phpbb::ACL_NO;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// no break; // no break;
@ -279,23 +279,23 @@ class acp_permission_roles
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ACL_ROLES_TABLE . ' FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$role_row = $db->sql_fetchrow($result); $role_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT p.auth_option_id, p.auth_setting, o.auth_option $sql = 'SELECT p.auth_option_id, p.auth_setting, o.auth_option
FROM ' . ACL_ROLES_DATA_TABLE . ' p, ' . ACL_OPTIONS_TABLE . ' o FROM ' . ACL_ROLES_DATA_TABLE . ' p, ' . ACL_OPTIONS_TABLE . ' o
WHERE o.auth_option_id = p.auth_option_id WHERE o.auth_option_id = p.auth_option_id
AND p.role_id = ' . $role_id . ' AND p.role_id = ' . $role_id . '
ORDER BY p.auth_option_id'; ORDER BY p.auth_option_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$auth_options = array(); $auth_options = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$auth_options[$row['auth_option']] = $row['auth_setting']; $auth_options[$row['auth_option']] = $row['auth_setting'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!$role_row) if (!$role_row)
@ -318,19 +318,19 @@ class acp_permission_roles
// We need to fill the auth options array with ACL_NO options ;) // We need to fill the auth options array with ACL_NO options ;)
$sql = 'SELECT auth_option_id, auth_option $sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . " WHERE auth_option " . phpbb::$db->sql_like_expression($permission_type . phpbb::$db->any_char) . "
AND auth_option <> '{$permission_type}' AND auth_option <> '{$permission_type}'
ORDER BY auth_option_id"; ORDER BY auth_option_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!isset($auth_options[$row['auth_option']])) if (!isset($auth_options[$row['auth_option']]))
{ {
$auth_options[$row['auth_option']] = phpbb::ACL_NO; $auth_options[$row['auth_option']] = phpbb::ACL_NO;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Unset global permission option // Unset global permission option
unset($auth_options[$permission_type]); unset($auth_options[$permission_type]);
@ -367,9 +367,9 @@ class acp_permission_roles
$sql = 'UPDATE ' . ACL_ROLES_TABLE . ' $sql = 'UPDATE ' . ACL_ROLES_TABLE . '
SET role_order = ' . $order_total . " - role_order SET role_order = ' . $order_total . " - role_order
WHERE role_type = '" . $db->sql_escape($permission_type) . "' WHERE role_type = '" . phpbb::$db->sql_escape($permission_type) . "'
AND role_order IN ($order, " . (($action == 'move_up') ? $order - 1 : $order + 1) . ')'; AND role_order IN ($order, " . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
break; break;
} }
@ -377,11 +377,11 @@ class acp_permission_roles
// By default, check that role_order is valid and fix it if necessary // By default, check that role_order is valid and fix it if necessary
$sql = 'SELECT role_id, role_order $sql = 'SELECT role_id, role_order
FROM ' . ACL_ROLES_TABLE . " FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = '" . $db->sql_escape($permission_type) . "' WHERE role_type = '" . phpbb::$db->sql_escape($permission_type) . "'
ORDER BY role_order ASC"; ORDER BY role_order ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$order = 0; $order = 0;
do do
@ -389,12 +389,12 @@ class acp_permission_roles
$order++; $order++;
if ($row['role_order'] != $order) if ($row['role_order'] != $order)
{ {
$db->sql_query('UPDATE ' . ACL_ROLES_TABLE . " SET role_order = $order WHERE role_id = {$row['role_id']}"); phpbb::$db->sql_query('UPDATE ' . ACL_ROLES_TABLE . " SET role_order = $order WHERE role_id = {$row['role_id']}");
} }
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Display assigned items? // Display assigned items?
$display_item = request_var('display_item', 0); $display_item = request_var('display_item', 0);
@ -402,12 +402,12 @@ class acp_permission_roles
// Select existing roles // Select existing roles
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ACL_ROLES_TABLE . " FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = '" . $db->sql_escape($permission_type) . "' WHERE role_type = '" . phpbb::$db->sql_escape($permission_type) . "'
ORDER BY role_order ASC"; ORDER BY role_order ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_role_options = ''; $s_role_options = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$role_name = (!empty(phpbb::$user->lang[$row['role_name']])) ? phpbb::$user->lang[$row['role_name']] : $row['role_name']; $role_name = (!empty(phpbb::$user->lang[$row['role_name']])) ? phpbb::$user->lang[$row['role_name']] : $row['role_name'];
@ -431,7 +431,7 @@ class acp_permission_roles
); );
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_ROLE_OPTIONS' => $s_role_options) 'S_ROLE_OPTIONS' => $s_role_options)
@ -499,28 +499,28 @@ class acp_permission_roles
// Get complete auth array // Get complete auth array
$sql = 'SELECT auth_option, auth_option_id $sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char); WHERE auth_option " . phpbb::$db->sql_like_expression($permission_type . phpbb::$db->any_char);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$auth_settings = array(); $auth_settings = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$auth_settings[$row['auth_option']] = phpbb::ACL_NO; $auth_settings[$row['auth_option']] = phpbb::ACL_NO;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Get the role auth settings we need to re-set... // Get the role auth settings we need to re-set...
$sql = 'SELECT o.auth_option, r.auth_setting $sql = 'SELECT o.auth_option, r.auth_setting
FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o
WHERE o.auth_option_id = r.auth_option_id WHERE o.auth_option_id = r.auth_option_id
AND r.role_id = ' . $role_id; AND r.role_id = ' . $role_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$auth_settings[$row['auth_option']] = $row['auth_setting']; $auth_settings[$row['auth_option']] = $row['auth_setting'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Get role assignments // Get role assignments
$hold_ary = $auth_admin->get_role_mask($role_id); $hold_ary = $auth_admin->get_role_mask($role_id);
@ -542,20 +542,20 @@ class acp_permission_roles
// Remove role from users and groups just to be sure (happens through acl_set) // Remove role from users and groups just to be sure (happens through acl_set)
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE auth_role_id = ' . $role_id; WHERE auth_role_id = ' . $role_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE auth_role_id = ' . $role_id; WHERE auth_role_id = ' . $role_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Remove role data and role // Remove role data and role
$sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_ROLES_TABLE . ' $sql = 'DELETE FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$auth_admin->acl_clear_prefetch(); $auth_admin->acl_clear_prefetch();
} }

View file

@ -83,13 +83,13 @@ class acp_permissions
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE group_type = ' . GROUP_SPECIAL . " WHERE group_type = ' . GROUP_SPECIAL . "
$sql_and"; $sql_and";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$group_id[] = $row['group_id']; $group_id[] = $row['group_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Map usernames to ids and vice versa // Map usernames to ids and vice versa
@ -116,14 +116,14 @@ class acp_permissions
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
ORDER BY left_id'; ORDER BY left_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_id = array(); $forum_id = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_id[] = (int) $row['forum_id']; $forum_id[] = (int) $row['forum_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else if ($subforum_id) else if ($subforum_id)
{ {
@ -439,16 +439,16 @@ class acp_permissions
{ {
$sql = 'SELECT forum_name $sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_id) . ' WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_id) . '
ORDER BY left_id ASC'; ORDER BY left_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_names = array(); $forum_names = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_names[] = $row['forum_name']; $forum_names[] = $row['forum_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_FORUM_NAMES' => (sizeof($forum_names)) ? true : false, 'S_FORUM_NAMES' => (sizeof($forum_names)) ? true : false,
@ -583,15 +583,15 @@ class acp_permissions
{ {
$sql = "SELECT $sql_id $sql = "SELECT $sql_id
FROM $table FROM $table
WHERE " . $db->sql_in_set($sql_id, $ids); WHERE " . phpbb::$db->sql_in_set($sql_id, $ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ids = array(); $ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ids[] = (int) $row[$sql_id]; $ids[] = (int) $row[$sql_id];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!sizeof($ids)) if (!sizeof($ids))
@ -756,14 +756,14 @@ class acp_permissions
FROM ' . ACL_OPTIONS_TABLE . ' o, ' . ACL_ROLES_DATA_TABLE . ' r FROM ' . ACL_OPTIONS_TABLE . ' o, ' . ACL_ROLES_DATA_TABLE . ' r
WHERE o.auth_option_id = r.auth_option_id WHERE o.auth_option_id = r.auth_option_id
AND r.role_id = ' . $role_id; AND r.role_id = ' . $role_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$test_auth_settings = array(); $test_auth_settings = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$test_auth_settings[$row['auth_option']] = $row['auth_setting']; $test_auth_settings[$row['auth_option']] = $row['auth_setting'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// We need to add any ACL_NO setting from auth_settings to compare correctly // We need to add any ACL_NO setting from auth_settings to compare correctly
foreach ($auth_settings as $option => $setting) foreach ($auth_settings as $option => $setting)
@ -826,15 +826,15 @@ class acp_permissions
// Logging ... first grab user or groupnames ... // Logging ... first grab user or groupnames ...
$sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE ' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE '; $sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE ' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE ';
$sql .= $db->sql_in_set(($ug_type == 'group') ? 'group_id' : 'user_id', array_map('intval', $ug_id)); $sql .= phpbb::$db->sql_in_set(($ug_type == 'group') ? 'group_id' : 'user_id', array_map('intval', $ug_id));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$l_ug_list = ''; $l_ug_list = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '<span class="sep">' . phpbb::$user->lang['G_' . $row['name']] . '</span>' : $row['name']); $l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '<span class="sep">' . phpbb::$user->lang['G_' . $row['name']] . '</span>' : $row['name']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$mode = str_replace('setting_', '', $mode); $mode = str_replace('setting_', '', $mode);
@ -847,15 +847,15 @@ class acp_permissions
// Grab the forum details if non-zero forum_id // Grab the forum details if non-zero forum_id
$sql = 'SELECT forum_name $sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_id); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_id);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$l_forum_list = ''; $l_forum_list = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name']; $l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
add_log('admin', 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), $l_forum_list, $l_ug_list); add_log('admin', 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), $l_forum_list, $l_ug_list);
} }
@ -871,9 +871,9 @@ class acp_permissions
$sql = 'SELECT user_id, username, user_permissions, user_type $sql = 'SELECT user_id, username, user_permissions, user_type
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$userdata = $db->sql_fetchrow($result); $userdata = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -892,9 +892,9 @@ class acp_permissions
$sql = 'SELECT forum_name $sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$result = $db->sql_query($sql, 3600); $result = phpbb::$db->sql_query($sql, 3600);
$forum_name = $db->sql_fetchfield('forum_name'); $forum_name = phpbb::$db->sql_fetchfield('forum_name');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$back = request_var('back', 0); $back = request_var('back', 0);
@ -923,17 +923,17 @@ class acp_permissions
WHERE ug.user_id = ' . $user_id . ' WHERE ug.user_id = ' . $user_id . '
AND ug.user_pending = 0 AND ug.user_pending = 0
ORDER BY g.group_type DESC, g.group_id DESC'; ORDER BY g.group_type DESC, g.group_id DESC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$groups = array(); $groups = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$groups[$row['group_id']] = array( $groups[$row['group_id']] = array(
'auth_setting' => phpbb::ACL_NO, 'auth_setting' => phpbb::ACL_NO,
'group_name' => ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name'] 'group_name' => ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$total = phpbb::ACL_NO; $total = phpbb::ACL_NO;
$add_key = (($forum_id) ? '_LOCAL' : ''); $add_key = (($forum_id) ? '_LOCAL' : '');
@ -1087,43 +1087,43 @@ class acp_permissions
*/ */
function retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type) function retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type)
{ {
$sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((sizeof($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0'); $sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((sizeof($forum_id)) ? 'AND ' . phpbb::$db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0');
// Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles // Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles
$option_ids = $role_ids = array(); $option_ids = $role_ids = array();
$sql = 'SELECT auth_option_id $sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . ' FROM ' . ACL_OPTIONS_TABLE . '
WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->any_char); WHERE auth_option ' . phpbb::$db->sql_like_expression($permission_type . phpbb::$db->any_char);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$option_ids[] = (int) $row['auth_option_id']; $option_ids[] = (int) $row['auth_option_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($option_ids)) if (sizeof($option_ids))
{ {
$sql = 'SELECT DISTINCT role_id $sql = 'SELECT DISTINCT role_id
FROM ' . ACL_ROLES_DATA_TABLE . ' FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE ' . $db->sql_in_set('auth_option_id', $option_ids); WHERE ' . phpbb::$db->sql_in_set('auth_option_id', $option_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$role_ids[] = (int) $row['role_id']; $role_ids[] = (int) $row['role_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (sizeof($option_ids) && sizeof($role_ids)) if (sizeof($option_ids) && sizeof($role_ids))
{ {
$sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')'; $sql_where = 'AND (' . phpbb::$db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . phpbb::$db->sql_in_set('a.auth_role_id', $role_ids) . ')';
} }
else else
{ {
$sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids); $sql_where = 'AND ' . phpbb::$db->sql_in_set('a.auth_option_id', $option_ids);
} }
// Not ideal, due to the filesort, non-use of indexes, etc. // Not ideal, due to the filesort, non-use of indexes, etc.
@ -1133,16 +1133,16 @@ class acp_permissions
$sql_forum_id $sql_forum_id
$sql_where $sql_where
ORDER BY u.username_clean, u.user_regdate ASC"; ORDER BY u.username_clean, u.user_regdate ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_defined_user_options = ''; $s_defined_user_options = '';
$defined_user_ids = array(); $defined_user_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$s_defined_user_options .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>'; $s_defined_user_options .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>';
$defined_user_ids[] = $row['user_id']; $defined_user_ids[] = $row['user_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT DISTINCT g.group_type, g.group_name, g.group_id $sql = 'SELECT DISTINCT g.group_type, g.group_name, g.group_id
FROM ' . GROUPS_TABLE . ' g, ' . ACL_GROUPS_TABLE . " a FROM ' . GROUPS_TABLE . ' g, ' . ACL_GROUPS_TABLE . " a
@ -1150,16 +1150,16 @@ class acp_permissions
$sql_forum_id $sql_forum_id
$sql_where $sql_where
ORDER BY g.group_type DESC, g.group_name ASC"; ORDER BY g.group_type DESC, g.group_name ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_defined_group_options = ''; $s_defined_group_options = '';
$defined_group_ids = array(); $defined_group_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$s_defined_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; $s_defined_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
$defined_group_ids[] = $row['group_id']; $defined_group_ids[] = $row['group_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return array( return array(
'group_ids' => $defined_group_ids, 'group_ids' => $defined_group_ids,

View file

@ -60,27 +60,27 @@ class acp_profile
$sql = 'SELECT lang_id, lang_iso $sql = 'SELECT lang_id, lang_iso
FROM ' . LANG_TABLE . ' FROM ' . LANG_TABLE . '
ORDER BY lang_english_name'; ORDER BY lang_english_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Make some arrays with all available languages // Make some arrays with all available languages
$this->lang_defs['id'][$row['lang_id']] = $row['lang_iso']; $this->lang_defs['id'][$row['lang_id']] = $row['lang_iso'];
$this->lang_defs['iso'][$row['lang_iso']] = $row['lang_id']; $this->lang_defs['iso'][$row['lang_iso']] = $row['lang_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT field_id, lang_id $sql = 'SELECT field_id, lang_id
FROM ' . PROFILE_LANG_TABLE . ' FROM ' . PROFILE_LANG_TABLE . '
ORDER BY lang_id'; ORDER BY lang_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Which languages are available for each item // Which languages are available for each item
$this->lang_defs['entry'][$row['field_id']][] = $row['lang_id']; $this->lang_defs['entry'][$row['field_id']][] = $row['lang_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Have some fields been defined? // Have some fields been defined?
if (isset($this->lang_defs['entry'])) if (isset($this->lang_defs['entry']))
@ -107,31 +107,31 @@ class acp_profile
$sql = 'SELECT field_ident $sql = 'SELECT field_ident
FROM ' . PROFILE_FIELDS_TABLE . " FROM ' . PROFILE_FIELDS_TABLE . "
WHERE field_id = $field_id"; WHERE field_id = $field_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$field_ident = (string) $db->sql_fetchfield('field_ident'); $field_ident = (string) phpbb::$db->sql_fetchfield('field_ident');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id"); phpbb::$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id");
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id"); phpbb::$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id"); phpbb::$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");
if ($db->dbms_type == 'sqlite') if (phpbb::$db->dbms_type == 'sqlite')
{ {
$sql = "SELECT sql $sql = "SELECT sql
FROM sqlite_master FROM sqlite_master
WHERE type = 'table' WHERE type = 'table'
AND name = '" . PROFILE_FIELDS_DATA_TABLE . "' AND name = '" . PROFILE_FIELDS_DATA_TABLE . "'
ORDER BY type DESC, name;"; ORDER BY type DESC, name;";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Create a temp table and populate it, destroy the existing one // Create a temp table and populate it, destroy the existing one
$db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . PROFILE_FIELDS_DATA_TABLE . '"?#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql'])); phpbb::$db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . PROFILE_FIELDS_DATA_TABLE . '"?#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql']));
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE); phpbb::$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE);
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE); phpbb::$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE);
preg_match('#\((.*)\)#s', $row['sql'], $matches); preg_match('#\((.*)\)#s', $row['sql'], $matches);
@ -159,13 +159,13 @@ class acp_profile
$new_table_cols = preg_replace('/' . 'pf_' . $field_ident . '[^,]+,/', '', $new_table_cols); $new_table_cols = preg_replace('/' . 'pf_' . $field_ident . '[^,]+,/', '', $new_table_cols);
// create a new table and fill it up. destroy the temp one // create a new table and fill it up. destroy the temp one
$db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');'); phpbb::$db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');');
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;'); phpbb::$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;');
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp'); phpbb::$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp');
} }
else else
{ {
$db->sql_query('ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " DROP COLUMN pf_$field_ident"); phpbb::$db->sql_query('ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " DROP COLUMN pf_$field_ident");
} }
$order = 0; $order = 0;
@ -173,9 +173,9 @@ class acp_profile
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . PROFILE_FIELDS_TABLE . ' FROM ' . PROFILE_FIELDS_TABLE . '
ORDER BY field_order'; ORDER BY field_order';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$order++; $order++;
if ($row['field_order'] != $order) if ($row['field_order'] != $order)
@ -183,12 +183,12 @@ class acp_profile
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
SET field_order = $order SET field_order = $order
WHERE field_id = {$row['field_id']}"; WHERE field_id = {$row['field_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
add_log('admin', 'LOG_PROFILE_FIELD_REMOVED', $field_ident); add_log('admin', 'LOG_PROFILE_FIELD_REMOVED', $field_ident);
trigger_error(phpbb::$user->lang['REMOVED_PROFILE_FIELD'] . adm_back_link($this->u_action)); trigger_error(phpbb::$user->lang['REMOVED_PROFILE_FIELD'] . adm_back_link($this->u_action));
@ -215,10 +215,10 @@ class acp_profile
$sql = 'SELECT lang_id $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $db->sql_escape(phpbb::$config['default_lang']) . "'"; WHERE lang_iso = '" . phpbb::$db->sql_escape(phpbb::$config['default_lang']) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id'); $default_lang_id = (int) phpbb::$db->sql_fetchfield('lang_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!in_array($default_lang_id, $this->lang_defs['entry'][$field_id])) if (!in_array($default_lang_id, $this->lang_defs['entry'][$field_id]))
{ {
@ -228,14 +228,14 @@ class acp_profile
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
SET field_active = 1 SET field_active = 1
WHERE field_id = $field_id"; WHERE field_id = $field_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'SELECT field_ident $sql = 'SELECT field_ident
FROM ' . PROFILE_FIELDS_TABLE . " FROM ' . PROFILE_FIELDS_TABLE . "
WHERE field_id = $field_id"; WHERE field_id = $field_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$field_ident = (string) $db->sql_fetchfield('field_ident'); $field_ident = (string) phpbb::$db->sql_fetchfield('field_ident');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident); add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident);
trigger_error(phpbb::$user->lang['PROFILE_FIELD_ACTIVATED'] . adm_back_link($this->u_action)); trigger_error(phpbb::$user->lang['PROFILE_FIELD_ACTIVATED'] . adm_back_link($this->u_action));
@ -253,14 +253,14 @@ class acp_profile
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
SET field_active = 0 SET field_active = 0
WHERE field_id = $field_id"; WHERE field_id = $field_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'SELECT field_ident $sql = 'SELECT field_ident
FROM ' . PROFILE_FIELDS_TABLE . " FROM ' . PROFILE_FIELDS_TABLE . "
WHERE field_id = $field_id"; WHERE field_id = $field_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$field_ident = (string) $db->sql_fetchfield('field_ident'); $field_ident = (string) phpbb::$db->sql_fetchfield('field_ident');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident); add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident);
trigger_error(phpbb::$user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action)); trigger_error(phpbb::$user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action));
@ -275,7 +275,7 @@ class acp_profile
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
SET field_order = $order_total - field_order SET field_order = $order_total - field_order
WHERE field_order IN ($field_order, " . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')'; WHERE field_order IN ($field_order, " . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
break; break;
@ -304,9 +304,9 @@ class acp_profile
WHERE l.lang_id = ' . $this->edit_lang_id . " WHERE l.lang_id = ' . $this->edit_lang_id . "
AND f.field_id = $field_id AND f.field_id = $field_id
AND l.field_id = f.field_id"; AND l.field_id = f.field_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$field_row = $db->sql_fetchrow($result); $field_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$field_row) if (!$field_row)
{ {
@ -316,9 +316,9 @@ class acp_profile
WHERE l.lang_id <> ' . $this->edit_lang_id . " WHERE l.lang_id <> ' . $this->edit_lang_id . "
AND f.field_id = $field_id AND f.field_id = $field_id
AND l.field_id = f.field_id"; AND l.field_id = f.field_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$field_row = $db->sql_fetchrow($result); $field_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$field_row) if (!$field_row)
{ {
@ -335,14 +335,14 @@ class acp_profile
WHERE lang_id = ' . $this->edit_lang_id . " WHERE lang_id = ' . $this->edit_lang_id . "
AND field_id = $field_id AND field_id = $field_id
ORDER BY option_id ASC"; ORDER BY option_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$lang_options = array(); $lang_options = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$lang_options[$row['option_id']] = $row['lang_value']; $lang_options[$row['option_id']] = $row['lang_value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$s_hidden_fields = '<input type="hidden" name="field_id" value="' . $field_id . '" />'; $s_hidden_fields = '<input type="hidden" name="field_id" value="' . $field_id . '" />';
} }
@ -531,14 +531,14 @@ class acp_profile
WHERE lang_id <> ' . $this->edit_lang_id . " WHERE lang_id <> ' . $this->edit_lang_id . "
AND field_id = $field_id AND field_id = $field_id
ORDER BY option_id ASC"; ORDER BY option_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$l_lang_options = array(); $l_lang_options = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$l_lang_options[$row['lang_id']][$row['option_id']] = $row['lang_value']; $l_lang_options[$row['lang_id']][$row['option_id']] = $row['lang_value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value $sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value
@ -546,16 +546,16 @@ class acp_profile
WHERE lang_id <> ' . $this->edit_lang_id . " WHERE lang_id <> ' . $this->edit_lang_id . "
AND field_id = $field_id AND field_id = $field_id
ORDER BY lang_id ASC"; ORDER BY lang_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$l_lang_name = $l_lang_explain = $l_lang_default_value = array(); $l_lang_name = $l_lang_explain = $l_lang_default_value = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$l_lang_name[$row['lang_id']] = $row['lang_name']; $l_lang_name[$row['lang_id']] = $row['lang_name'];
$l_lang_explain[$row['lang_id']] = $row['lang_explain']; $l_lang_explain[$row['lang_id']] = $row['lang_explain'];
$l_lang_default_value[$row['lang_id']] = $row['lang_default_value']; $l_lang_default_value[$row['lang_id']] = $row['lang_default_value'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($exclude[3] as $key) foreach ($exclude[3] as $key)
@ -619,10 +619,10 @@ class acp_profile
{ {
$sql = 'SELECT field_ident $sql = 'SELECT field_ident
FROM ' . PROFILE_FIELDS_TABLE . " FROM ' . PROFILE_FIELDS_TABLE . "
WHERE field_ident = '" . $db->sql_escape($cp->vars['field_ident']) . "'"; WHERE field_ident = '" . phpbb::$db->sql_escape($cp->vars['field_ident']) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -844,10 +844,10 @@ class acp_profile
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . PROFILE_FIELDS_TABLE . ' FROM ' . PROFILE_FIELDS_TABLE . '
ORDER BY field_order'; ORDER BY field_order';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_one_need_edit = false; $s_one_need_edit = false;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$active_lang = (!$row['field_active']) ? 'ACTIVATE' : 'DEACTIVATE'; $active_lang = (!$row['field_active']) ? 'ACTIVATE' : 'DEACTIVATE';
$active_value = (!$row['field_active']) ? 'activate' : 'deactivate'; $active_value = (!$row['field_active']) ? 'activate' : 'deactivate';
@ -875,7 +875,7 @@ class acp_profile
'S_NEED_EDIT' => $s_need_edit) 'S_NEED_EDIT' => $s_need_edit)
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// At least one option field needs editing? // At least one option field needs editing?
if ($s_one_need_edit) if ($s_one_need_edit)
@ -906,14 +906,14 @@ class acp_profile
FROM ' . LANG_TABLE . ' FROM ' . LANG_TABLE . '
WHERE lang_id <> ' . (int) $default_lang_id . ' WHERE lang_id <> ' . (int) $default_lang_id . '
ORDER BY lang_english_name'; ORDER BY lang_english_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$languages = array(); $languages = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$languages[$row['lang_id']] = $row['lang_iso']; $languages[$row['lang_id']] = $row['lang_iso'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$options = array(); $options = array();
$options['lang_name'] = 'string'; $options['lang_name'] = 'string';
@ -1029,9 +1029,9 @@ class acp_profile
{ {
$sql = 'SELECT MAX(field_order) as max_field_order $sql = 'SELECT MAX(field_order) as max_field_order
FROM ' . PROFILE_FIELDS_TABLE; FROM ' . PROFILE_FIELDS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$new_field_order = (int) $db->sql_fetchfield('max_field_order'); $new_field_order = (int) phpbb::$db->sql_fetchfield('max_field_order');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$field_ident = $cp->vars['field_ident']; $field_ident = $cp->vars['field_ident'];
} }
@ -1060,17 +1060,17 @@ class acp_profile
'field_active' => 1 'field_active' => 1
); );
$sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $db->sql_build_array('INSERT', $profile_fields); $sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $profile_fields);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$field_id = $db->sql_nextid(); $field_id = phpbb::$db->sql_nextid();
} }
else else
{ {
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $profile_fields) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $profile_fields) . "
WHERE field_id = $field_id"; WHERE field_id = $field_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if ($action == 'create') if ($action == 'create')
@ -1090,7 +1090,7 @@ class acp_profile
$sql_ary['field_id'] = $field_id; $sql_ary['field_id'] = $field_id;
$sql_ary['lang_id'] = $default_lang_id; $sql_ary['lang_id'] = $default_lang_id;
$profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
} }
else else
{ {
@ -1126,7 +1126,7 @@ class acp_profile
$sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . " $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . "
WHERE field_id = $field_id WHERE field_id = $field_id
AND lang_id = " . (int) $lang_id; AND lang_id = " . (int) $lang_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1160,7 +1160,7 @@ class acp_profile
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . "
WHERE field_id = $field_id WHERE field_id = $field_id
AND lang_id = " . (int) $default_lang_id; AND lang_id = " . (int) $default_lang_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
foreach ($cp->vars['lang_options'] as $option_id => $value) foreach ($cp->vars['lang_options'] as $option_id => $value)
@ -1176,7 +1176,7 @@ class acp_profile
$sql_ary['lang_id'] = $default_lang_id; $sql_ary['lang_id'] = $default_lang_id;
$sql_ary['option_id'] = (int) $option_id; $sql_ary['option_id'] = (int) $option_id;
$profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
} }
else else
{ {
@ -1212,7 +1212,7 @@ class acp_profile
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . "
WHERE field_id = $field_id WHERE field_id = $field_id
AND lang_id = " . (int) $lang_id; AND lang_id = " . (int) $lang_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
foreach ($lang_ary as $option_id => $value) foreach ($lang_ary as $option_id => $value)
@ -1233,7 +1233,7 @@ class acp_profile
$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . "
WHERE field_id = $field_id WHERE field_id = $field_id
AND lang_id = " . (int) $lang_id; AND lang_id = " . (int) $lang_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -1241,7 +1241,7 @@ class acp_profile
{ {
if ($action == 'create') if ($action == 'create')
{ {
$profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql); $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql);
} }
else else
{ {
@ -1258,7 +1258,7 @@ class acp_profile
{ {
if ($action == 'create') if ($action == 'create')
{ {
$profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql); $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql);
} }
else else
{ {
@ -1276,17 +1276,17 @@ class acp_profile
} }
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
if ($action == 'create') if ($action == 'create')
{ {
foreach ($profile_sql as $sql) foreach ($profile_sql as $sql)
{ {
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
if ($action == 'edit') if ($action == 'edit')
{ {
@ -1311,7 +1311,7 @@ class acp_profile
foreach ($where_fields as $key => $value) foreach ($where_fields as $key => $value)
{ {
$check_key = (!$check_key) ? $key : $check_key; $check_key = (!$check_key) ? $key : $check_key;
$where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : (int) $value); $where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . phpbb::$db->sql_escape($value) . "'" : (int) $value);
} }
if (!sizeof($where_sql)) if (!sizeof($where_sql))
@ -1322,9 +1322,9 @@ class acp_profile
$sql = "SELECT $check_key $sql = "SELECT $check_key
FROM $table FROM $table
WHERE " . implode(' AND ', $where_sql); WHERE " . implode(' AND ', $where_sql);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -1332,16 +1332,16 @@ class acp_profile
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query("INSERT INTO $table " . phpbb::$db->sql_build_array('INSERT', $sql_ary));
} }
} }
else else
{ {
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . ' $sql = "UPDATE $table SET " . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE ' . implode(' AND ', $where_sql); WHERE ' . implode(' AND ', $where_sql);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
} }
@ -1351,7 +1351,7 @@ class acp_profile
*/ */
function add_field_ident($field_ident, $field_type) function add_field_ident($field_ident, $field_type)
{ {
switch ($db->dbms_type) switch (phpbb::$db->dbms_type)
{ {
case 'mysql': case 'mysql':
@ -1428,14 +1428,14 @@ class acp_profile
WHERE type = 'table' WHERE type = 'table'
AND name = '" . PROFILE_FIELDS_DATA_TABLE . "' AND name = '" . PROFILE_FIELDS_DATA_TABLE . "'
ORDER BY type DESC, name;"; ORDER BY type DESC, name;";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Create a temp table and populate it, destroy the existing one // Create a temp table and populate it, destroy the existing one
$db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . PROFILE_FIELDS_DATA_TABLE . '"?#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql'])); phpbb::$db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . PROFILE_FIELDS_DATA_TABLE . '"?#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql']));
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE); phpbb::$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE);
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE); phpbb::$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE);
preg_match('#\((.*)\)#s', $row['sql'], $matches); preg_match('#\((.*)\)#s', $row['sql'], $matches);
@ -1458,9 +1458,9 @@ class acp_profile
$new_table_cols = $field_ident . ' ' . $type . ',' . $new_table_cols; $new_table_cols = $field_ident . ' ' . $type . ',' . $new_table_cols;
// create a new table and fill it up. destroy the temp one // create a new table and fill it up. destroy the temp one
$db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');'); phpbb::$db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');');
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;'); phpbb::$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;');
$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp'); phpbb::$db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp');
} }
else else
{ {

View file

@ -58,14 +58,14 @@ class acp_prune
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
ORDER BY left_id'; ORDER BY left_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_id = array(); $forum_id = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_id[] = $row['forum_id']; $forum_id[] = $row['forum_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if ($submit) if ($submit)
@ -89,7 +89,7 @@ class acp_prune
'S_PRUNED' => true) 'S_PRUNED' => true)
); );
$sql_forum = (sizeof($forum_id)) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : ''; $sql_forum = (sizeof($forum_id)) ? ' AND ' . phpbb::$db->sql_in_set('forum_id', $forum_id) : '';
// Get a list of forum's or the data for the forum that we are pruning. // Get a list of forum's or the data for the forum that we are pruning.
$sql = 'SELECT forum_id, forum_name $sql = 'SELECT forum_id, forum_name
@ -97,9 +97,9 @@ class acp_prune
WHERE forum_type = ' . FORUM_POST . " WHERE forum_type = ' . FORUM_POST . "
$sql_forum $sql_forum
ORDER BY left_id ASC"; ORDER BY left_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$prune_ids = array(); $prune_ids = array();
$p_result['topics'] = 0; $p_result['topics'] = 0;
@ -144,13 +144,13 @@ class acp_prune
$log_data .= (($log_data != '') ? ', ' : '') . $row['forum_name']; $log_data .= (($log_data != '') ? ', ' : '') . $row['forum_name'];
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
// Sync all pruned forums at once // Sync all pruned forums at once
sync('forum', 'forum_id', $prune_ids, true, true); sync('forum', 'forum_id', $prune_ids, true, true);
add_log('admin', 'LOG_PRUNE', $log_data); add_log('admin', 'LOG_PRUNE', $log_data);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return; return;
} }
@ -186,13 +186,13 @@ class acp_prune
{ {
$sql = 'SELECT forum_id, forum_name $sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_id); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_id);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
if (!$row) if (!$row)
{ {
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
trigger_error(phpbb::$user->lang['NO_FORUM'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error(phpbb::$user->lang['NO_FORUM'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
@ -202,9 +202,9 @@ class acp_prune
$forum_list .= (($forum_list != '') ? ', ' : '') . '<b>' . $row['forum_name'] . '</b>'; $forum_list .= (($forum_list != '') ? ', ' : '') . '<b>' . $row['forum_name'] . '</b>';
$s_hidden_fields .= '<input type="hidden" name="f[]" value="' . $row['forum_id'] . '" />'; $s_hidden_fields .= '<input type="hidden" name="f[]" value="' . $row['forum_id'] . '" />';
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$l_selected_forums = (sizeof($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS'; $l_selected_forums = (sizeof($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS';
@ -364,7 +364,7 @@ class acp_prune
if ($users) if ($users)
{ {
$users = explode("\n", $users); $users = explode("\n", $users);
$where_sql = ' AND ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', $users)); $where_sql = ' AND ' . phpbb::$db->sql_in_set('username_clean', array_map('utf8_clean_string', $users));
} }
else else
{ {
@ -391,8 +391,8 @@ class acp_prune
$sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit'); $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit');
$where_sql = ''; $where_sql = '';
$where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : ''; $where_sql .= ($username) ? ' AND username_clean ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, utf8_clean_string($username))) : '';
$where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : ''; $where_sql .= ($email) ? ' AND user_email ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, $email)) . ' ' : '';
$where_sql .= (sizeof($joined)) ? " AND user_regdate " . $key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]) : ''; $where_sql .= (sizeof($joined)) ? " AND user_regdate " . $key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]) : '';
$where_sql .= ($count !== '') ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : ''; $where_sql .= ($count !== '') ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';
@ -415,14 +415,14 @@ class acp_prune
// Get bot ids // Get bot ids
$sql = 'SELECT user_id $sql = 'SELECT user_id
FROM ' . BOTS_TABLE; FROM ' . BOTS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$bot_ids = array(); $bot_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$bot_ids[] = $row['user_id']; $bot_ids[] = $row['user_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Do not prune founder members // Do not prune founder members
$sql = 'SELECT user_id, username $sql = 'SELECT user_id, username
@ -430,12 +430,12 @@ class acp_prune
WHERE user_id <> ' . ANONYMOUS . ' WHERE user_id <> ' . ANONYMOUS . '
AND user_type <> ' . phpbb::USER_FOUNDER . " AND user_type <> ' . phpbb::USER_FOUNDER . "
$where_sql"; $where_sql";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$where_sql = ''; $where_sql = '';
$user_ids = $usernames = array(); $user_ids = $usernames = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Do not prune bots and the user currently pruning. // Do not prune bots and the user currently pruning.
if ($row['user_id'] != phpbb::$user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) if ($row['user_id'] != phpbb::$user->data['user_id'] && !in_array($row['user_id'], $bot_ids))
@ -444,7 +444,7 @@ class acp_prune
$usernames[$row['user_id']] = $row['username']; $usernames[$row['user_id']] = $row['username'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }

View file

@ -72,19 +72,19 @@ class acp_ranks
if ($rank_id) if ($rank_id)
{ {
$sql = 'UPDATE ' . RANKS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE rank_id = $rank_id"; $sql = 'UPDATE ' . RANKS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . " WHERE rank_id = $rank_id";
$message = phpbb::$user->lang['RANK_UPDATED']; $message = phpbb::$user->lang['RANK_UPDATED'];
add_log('admin', 'LOG_RANK_UPDATED', $rank_title); add_log('admin', 'LOG_RANK_UPDATED', $rank_title);
} }
else else
{ {
$sql = 'INSERT INTO ' . RANKS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $sql = 'INSERT INTO ' . RANKS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
$message = phpbb::$user->lang['RANK_ADDED']; $message = phpbb::$user->lang['RANK_ADDED'];
add_log('admin', 'LOG_RANK_ADDED', $rank_title); add_log('admin', 'LOG_RANK_ADDED', $rank_title);
} }
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy('ranks'); phpbb::$acm->destroy('ranks');
@ -104,18 +104,18 @@ class acp_ranks
$sql = 'SELECT rank_title $sql = 'SELECT rank_title
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
WHERE rank_id = ' . $rank_id; WHERE rank_id = ' . $rank_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$rank_title = (string) $db->sql_fetchfield('rank_title'); $rank_title = (string) phpbb::$db->sql_fetchfield('rank_title');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'DELETE FROM ' . RANKS_TABLE . " $sql = 'DELETE FROM ' . RANKS_TABLE . "
WHERE rank_id = $rank_id"; WHERE rank_id = $rank_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_rank = 0 SET user_rank = 0
WHERE user_rank = $rank_id"; WHERE user_rank = $rank_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy('ranks'); phpbb::$acm->destroy('ranks');
@ -141,9 +141,9 @@ class acp_ranks
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
ORDER BY rank_min ASC, rank_special ASC'; ORDER BY rank_min ASC, rank_special ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$existing_imgs[] = $row['rank_image']; $existing_imgs[] = $row['rank_image'];
@ -152,7 +152,7 @@ class acp_ranks
$ranks = $row; $ranks = $row;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$imglist = filelist(PHPBB_ROOT_PATH . phpbb::$config['ranks_path'], ''); $imglist = filelist(PHPBB_ROOT_PATH . phpbb::$config['ranks_path'], '');
$edit_img = $filename_list = ''; $edit_img = $filename_list = '';
@ -216,9 +216,9 @@ class acp_ranks
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
ORDER BY rank_special DESC, rank_min ASC, rank_title ASC'; ORDER BY rank_special DESC, rank_min ASC, rank_title ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('ranks', array( $template->assign_block_vars('ranks', array(
'S_RANK_IMAGE' => ($row['rank_image']) ? true : false, 'S_RANK_IMAGE' => ($row['rank_image']) ? true : false,
@ -232,7 +232,7 @@ class acp_ranks
'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row['rank_id']) 'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row['rank_id'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }

View file

@ -69,9 +69,9 @@ class acp_reasons
$sql = 'SELECT reason_title $sql = 'SELECT reason_title
FROM ' . REPORTS_REASONS_TABLE . " FROM ' . REPORTS_REASONS_TABLE . "
WHERE reason_id = $reason_id"; WHERE reason_id = $reason_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (strtolower($row['reason_title']) == 'other' || strtolower($reason_row['reason_title']) == 'other') if (strtolower($row['reason_title']) == 'other' || strtolower($reason_row['reason_title']) == 'other')
{ {
@ -89,10 +89,10 @@ class acp_reasons
{ {
$sql = 'SELECT reason_id $sql = 'SELECT reason_id
FROM ' . REPORTS_REASONS_TABLE . " FROM ' . REPORTS_REASONS_TABLE . "
WHERE reason_title = '" . $db->sql_escape($reason_row['reason_title']) . "'"; WHERE reason_title = '" . phpbb::$db->sql_escape($reason_row['reason_title']) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row || ($action == 'add' && strtolower($reason_row['reason_title']) == 'other')) if ($row || ($action == 'add' && strtolower($reason_row['reason_title']) == 'other'))
{ {
@ -108,9 +108,9 @@ class acp_reasons
// Get new order... // Get new order...
$sql = 'SELECT MAX(reason_order) as max_reason_order $sql = 'SELECT MAX(reason_order) as max_reason_order
FROM ' . REPORTS_REASONS_TABLE; FROM ' . REPORTS_REASONS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$max_order = (int) $db->sql_fetchfield('max_reason_order'); $max_order = (int) phpbb::$db->sql_fetchfield('max_reason_order');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_ary = array( $sql_ary = array(
'reason_title' => (string) $reason_row['reason_title'], 'reason_title' => (string) $reason_row['reason_title'],
@ -118,7 +118,7 @@ class acp_reasons
'reason_order' => $max_order + 1 'reason_order' => $max_order + 1
); );
$db->sql_query('INSERT INTO ' . REPORTS_REASONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . REPORTS_REASONS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
$log = 'ADDED'; $log = 'ADDED';
} }
@ -129,7 +129,7 @@ class acp_reasons
'reason_description' => (string) $reason_row['reason_description'], 'reason_description' => (string) $reason_row['reason_description'],
); );
$db->sql_query('UPDATE ' . REPORTS_REASONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' phpbb::$db->sql_query('UPDATE ' . REPORTS_REASONS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE reason_id = ' . $reason_id); WHERE reason_id = ' . $reason_id);
$log = 'UPDATED'; $log = 'UPDATED';
@ -144,9 +144,9 @@ class acp_reasons
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . REPORTS_REASONS_TABLE . ' FROM ' . REPORTS_REASONS_TABLE . '
WHERE reason_id = ' . $reason_id; WHERE reason_id = ' . $reason_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$reason_row = $db->sql_fetchrow($result); $reason_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$reason_row) if (!$reason_row)
{ {
@ -191,9 +191,9 @@ class acp_reasons
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . REPORTS_REASONS_TABLE . ' FROM ' . REPORTS_REASONS_TABLE . '
WHERE reason_id = ' . $reason_id; WHERE reason_id = ' . $reason_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$reason_row = $db->sql_fetchrow($result); $reason_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$reason_row) if (!$reason_row)
{ {
@ -211,22 +211,22 @@ class acp_reasons
$sql = 'SELECT reason_id, report_text $sql = 'SELECT reason_id, report_text
FROM ' . REPORTS_REASONS_TABLE . " FROM ' . REPORTS_REASONS_TABLE . "
WHERE LOWER(reason_title) = 'other'"; WHERE LOWER(reason_title) = 'other'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$other_reason_id = (int) $row['reason_id']; $other_reason_id = (int) $row['reason_id'];
$report_text = $row['report_text']; $report_text = $row['report_text'];
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$report_text .= $reason_row['reason_description'] . "\n\n"; $report_text .= $reason_row['reason_description'] . "\n\n";
$sql = 'UPDATE ' . REPORTS_TABLE . ' $sql = 'UPDATE ' . REPORTS_TABLE . '
SET reason_id = ' . $other_reason_id . ", report_text = '" . $db->sql_escape($report_text) . "' SET reason_id = ' . $other_reason_id . ", report_text = '" . phpbb::$db->sql_escape($report_text) . "'
WHERE reason_id = $reason_id"; WHERE reason_id = $reason_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$db->sql_query('DELETE FROM ' . REPORTS_REASONS_TABLE . ' WHERE reason_id = ' . $reason_id); phpbb::$db->sql_query('DELETE FROM ' . REPORTS_REASONS_TABLE . ' WHERE reason_id = ' . $reason_id);
add_log('admin', 'LOG_REASON_REMOVED', $reason_row['reason_title']); add_log('admin', 'LOG_REASON_REMOVED', $reason_row['reason_title']);
trigger_error(phpbb::$user->lang['REASON_REMOVED'] . adm_back_link($this->u_action)); trigger_error(phpbb::$user->lang['REASON_REMOVED'] . adm_back_link($this->u_action));
@ -252,7 +252,7 @@ class acp_reasons
$sql = 'UPDATE ' . REPORTS_REASONS_TABLE . ' $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . '
SET reason_order = ' . $order_total . ' - reason_order SET reason_order = ' . $order_total . ' - reason_order
WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')'; WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
break; break;
} }
@ -261,9 +261,9 @@ class acp_reasons
$sql = 'SELECT reason_id, reason_order $sql = 'SELECT reason_id, reason_order
FROM ' . REPORTS_REASONS_TABLE . ' FROM ' . REPORTS_REASONS_TABLE . '
ORDER BY reason_order'; ORDER BY reason_order';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$order = 0; $order = 0;
do do
@ -275,12 +275,12 @@ class acp_reasons
$sql = 'UPDATE ' . REPORTS_REASONS_TABLE . " $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . "
SET reason_order = $order SET reason_order = $order
WHERE reason_id = {$row['reason_id']}"; WHERE reason_id = {$row['reason_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'U_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action,
@ -291,21 +291,21 @@ class acp_reasons
$sql = 'SELECT reason_id, COUNT(reason_id) AS reason_count $sql = 'SELECT reason_id, COUNT(reason_id) AS reason_count
FROM ' . REPORTS_TABLE . ' FROM ' . REPORTS_TABLE . '
GROUP BY reason_id'; GROUP BY reason_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$reason_count = array(); $reason_count = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$reason_count[$row['reason_id']] = $row['reason_count']; $reason_count[$row['reason_id']] = $row['reason_count'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . REPORTS_REASONS_TABLE . ' FROM ' . REPORTS_REASONS_TABLE . '
ORDER BY reason_order ASC'; ORDER BY reason_order ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$translated = false; $translated = false;
$other_reason = ($row['reason_title'] == 'other') ? true : false; $other_reason = ($row['reason_title'] == 'other') ? true : false;
@ -333,7 +333,7 @@ class acp_reasons
'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;order=' . $row['reason_order']) 'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;order=' . $row['reason_order'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }

View file

@ -307,16 +307,16 @@ class acp_search
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_id >= ' . (int) ($post_counter + 1) . ' WHERE post_id >= ' . (int) ($post_counter + 1) . '
AND post_id <= ' . (int) ($post_counter + $this->batch_size); AND post_id <= ' . (int) ($post_counter + $this->batch_size);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ids = $posters = $forum_ids = array(); $ids = $posters = $forum_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ids[] = $row['post_id']; $ids[] = $row['post_id'];
$posters[] = $row['poster_id']; $posters[] = $row['poster_id'];
$forum_ids[] = $row['forum_id']; $forum_ids[] = $row['forum_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$row_count += sizeof($ids); $row_count += sizeof($ids);
if (sizeof($ids)) if (sizeof($ids))
@ -363,13 +363,13 @@ class acp_search
{ {
$sql = 'SELECT forum_id, enable_indexing $sql = 'SELECT forum_id, enable_indexing
FROM ' . FORUMS_TABLE; FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql, 3600); $result = phpbb::$db->sql_query($sql, 3600);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forums[$row['forum_id']] = (bool) $row['enable_indexing']; $forums[$row['forum_id']] = (bool) $row['enable_indexing'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$starttime = explode(' ', microtime()); $starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0]; $starttime = $starttime[1] + $starttime[0];
@ -380,9 +380,9 @@ class acp_search
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_id >= ' . (int) ($post_counter + 1) . ' WHERE post_id >= ' . (int) ($post_counter + 1) . '
AND post_id <= ' . (int) ($post_counter + $this->batch_size); AND post_id <= ' . (int) ($post_counter + $this->batch_size);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Indexing enabled for this forum or global announcement? // Indexing enabled for this forum or global announcement?
// Global announcements get indexed by default. // Global announcements get indexed by default.
@ -392,7 +392,7 @@ class acp_search
} }
$row_count++; $row_count++;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$post_counter += $this->batch_size; $post_counter += $this->batch_size;
} }
@ -561,9 +561,9 @@ class acp_search
{ {
$sql = 'SELECT MAX(post_id) as max_post_id $sql = 'SELECT MAX(post_id) as max_post_id
FROM '. POSTS_TABLE; FROM '. POSTS_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$max_post_id = (int) $db->sql_fetchfield('max_post_id'); $max_post_id = (int) phpbb::$db->sql_fetchfield('max_post_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return $max_post_id; return $max_post_id;
} }

View file

@ -198,7 +198,7 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'UPDATE ' . STYLES_TABLE . ' $sql = 'UPDATE ' . STYLES_TABLE . '
SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' SET style_active = ' . (($action == 'activate') ? 1 : 0) . '
WHERE style_id = ' . $style_id; WHERE style_id = ' . $style_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Set style to default for any member using deactivated style // Set style to default for any member using deactivated style
if ($action == 'deactivate') if ($action == 'deactivate')
@ -206,12 +206,12 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_style = ' . phpbb::$config['default_style'] . " SET user_style = ' . phpbb::$config['default_style'] . "
WHERE user_style = $style_id"; WHERE user_style = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_style = 0 SET forum_style = 0
WHERE forum_style = ' . $style_id; WHERE forum_style = ' . $style_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
break; break;
} }
@ -229,9 +229,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . STYLES_TEMPLATE_TABLE . " FROM ' . STYLES_TEMPLATE_TABLE . "
WHERE template_id = $style_id"; WHERE template_id = $style_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$template_row = $db->sql_fetchrow($result); $template_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$template_row) if (!$template_row)
{ {
@ -270,9 +270,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . STYLES_THEME_TABLE . " FROM ' . STYLES_THEME_TABLE . "
WHERE theme_id = $style_id"; WHERE theme_id = $style_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$theme_row = $db->sql_fetchrow($result); $theme_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$theme_row) if (!$theme_row)
{ {
@ -294,9 +294,9 @@ parse_css_file = {PARSE_CSS_FILE}
'theme_data' => self::db_theme_data($theme_row) 'theme_data' => self::db_theme_data($theme_row)
); );
$sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE theme_id = $style_id"; WHERE theme_id = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); phpbb::$acm->destroy_sql(STYLES_THEME_TABLE);
@ -328,9 +328,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . STYLES_IMAGESET_TABLE . " FROM ' . STYLES_IMAGESET_TABLE . "
WHERE imageset_id = $style_id"; WHERE imageset_id = $style_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$imageset_row = $db->sql_fetchrow($result); $imageset_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$imageset_row) if (!$imageset_row)
{ {
@ -349,11 +349,11 @@ parse_css_file = {PARSE_CSS_FILE}
$cfg_data_imageset = parse_cfg_file(PHPBB_ROOT_PATH . "styles/{$imageset_row['imageset_path']}/imageset/imageset.cfg"); $cfg_data_imageset = parse_cfg_file(PHPBB_ROOT_PATH . "styles/{$imageset_row['imageset_path']}/imageset/imageset.cfg");
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . ' $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . '
WHERE imageset_id = ' . $style_id; WHERE imageset_id = ' . $style_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
foreach ($cfg_data_imageset as $image_name => $value) foreach ($cfg_data_imageset as $image_name => $value)
{ {
@ -394,9 +394,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT lang_dir $sql = 'SELECT lang_dir
FROM ' . LANG_TABLE; FROM ' . LANG_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (@file_exists(PHPBB_ROOT_PATH . "styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg")) if (@file_exists(PHPBB_ROOT_PATH . "styles/{$imageset_row['imageset_path']}/imageset/{$row['lang_dir']}/imageset.cfg"))
{ {
@ -439,11 +439,11 @@ parse_css_file = {PARSE_CSS_FILE}
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE);
@ -483,13 +483,13 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT user_style, COUNT(user_style) AS style_count $sql = 'SELECT user_style, COUNT(user_style) AS style_count
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
GROUP BY user_style'; GROUP BY user_style';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$style_count[$row['user_style']] = $row['style_count']; $style_count[$row['user_style']] = $row['style_count'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
break; break;
@ -528,12 +528,12 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT * $sql = "SELECT *
FROM $sql_from"; FROM $sql_from";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$installed = array(); $installed = array();
$basis_options = '<option class="sep" value="">' . phpbb::$user->lang['OPTIONAL_BASIS'] . '</option>'; $basis_options = '<option class="sep" value="">' . phpbb::$user->lang['OPTIONAL_BASIS'] . '</option>';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$installed[] = $row[$mode . '_name']; $installed[] = $row[$mode . '_name'];
$basis_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>'; $basis_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>';
@ -566,7 +566,7 @@ parse_css_file = {PARSE_CSS_FILE}
) )
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Grab uninstalled items // Grab uninstalled items
$new_ary = $cfg = array(); $new_ary = $cfg = array();
@ -651,9 +651,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT template_path, template_name $sql = 'SELECT template_path, template_name
FROM ' . STYLES_TEMPLATE_TABLE . " FROM ' . STYLES_TEMPLATE_TABLE . "
WHERE template_id = $template_id"; WHERE template_id = $template_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$template_info = $db->sql_fetchrow($result); $template_info = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$template_info) if (!$template_info)
{ {
@ -804,9 +804,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . STYLES_TEMPLATE_TABLE . " FROM ' . STYLES_TEMPLATE_TABLE . "
WHERE template_id = $template_id"; WHERE template_id = $template_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$template_row = $db->sql_fetchrow($result); $template_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$template_row) if (!$template_row)
{ {
@ -933,13 +933,13 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT theme_storedb, theme_path, theme_name, theme_data $sql = 'SELECT theme_storedb, theme_path, theme_name, theme_data
FROM ' . STYLES_THEME_TABLE . " FROM ' . STYLES_THEME_TABLE . "
WHERE theme_id = $theme_id"; WHERE theme_id = $theme_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if (!($theme_info = $db->sql_fetchrow($result))) if (!($theme_info = phpbb::$db->sql_fetchrow($result)))
{ {
trigger_error(phpbb::$user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error(phpbb::$user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$theme_info['theme_id'] = $theme_id; $theme_info['theme_id'] = $theme_id;
self::generate_stylesheets($theme_info); self::generate_stylesheets($theme_info);
@ -971,9 +971,9 @@ parse_css_file = {PARSE_CSS_FILE}
'theme_data' => self::db_theme_data($theme_info, $theme_data), 'theme_data' => self::db_theme_data($theme_info, $theme_data),
); );
$sql = 'UPDATE ' . STYLES_THEME_TABLE . ' $sql = 'UPDATE ' . STYLES_THEME_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE theme_id = ' . $theme_id; WHERE theme_id = ' . $theme_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy_sql(STYLES_THEME_TABLE); phpbb::$acm->destroy_sql(STYLES_THEME_TABLE);
@ -1119,9 +1119,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT imageset_path, imageset_name $sql = 'SELECT imageset_path, imageset_name
FROM ' . STYLES_IMAGESET_TABLE . " FROM ' . STYLES_IMAGESET_TABLE . "
WHERE imageset_id = $imageset_id"; WHERE imageset_id = $imageset_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$imageset_row = $db->sql_fetchrow($result); $imageset_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$imageset_path = $imageset_row['imageset_path']; $imageset_path = $imageset_row['imageset_path'];
$imageset_name = $imageset_row['imageset_name']; $imageset_name = $imageset_row['imageset_name'];
@ -1130,16 +1130,16 @@ parse_css_file = {PARSE_CSS_FILE}
if (strpos($imgname, '-') !== false) if (strpos($imgname, '-') !== false)
{ {
list($imgname, $imgnamelang) = explode('-', $imgname); list($imgname, $imgnamelang) = explode('-', $imgname);
$sql_extra = " AND image_lang IN ('" . $db->sql_escape($imgnamelang) . "', '')"; $sql_extra = " AND image_lang IN ('" . phpbb::$db->sql_escape($imgnamelang) . "', '')";
} }
$sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id
FROM ' . STYLES_IMAGESET_DATA_TABLE . " FROM ' . STYLES_IMAGESET_DATA_TABLE . "
WHERE imageset_id = $imageset_id WHERE imageset_id = $imageset_id
AND image_name = '" . $db->sql_escape($imgname) . "'$sql_extra"; AND image_name = '" . phpbb::$db->sql_escape($imgname) . "'$sql_extra";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$imageset_data_row = $db->sql_fetchrow($result); $imageset_data_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$image_filename = $imageset_data_row['image_filename']; $image_filename = $imageset_data_row['image_filename'];
$image_width = $imageset_data_row['image_width']; $image_width = $imageset_data_row['image_width'];
@ -1212,16 +1212,16 @@ parse_css_file = {PARSE_CSS_FILE}
if ($imageset_data_row) if ($imageset_data_row)
{ {
$sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . ' $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE image_id = $image_id"; WHERE image_id = $image_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// does not exist // does not exist
else if (!$imageset_data_row) else if (!$imageset_data_row)
{ {
$sql_ary['image_name'] = $imgname; $sql_ary['image_name'] = $imgname;
$sql_ary['imageset_id'] = (int) $imageset_id; $sql_ary['imageset_id'] = (int) $imageset_id;
$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
} }
phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE);
@ -1401,9 +1401,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT $sql_select $sql = "SELECT $sql_select
FROM $sql_from FROM $sql_from
WHERE {$mode}_id = $style_id"; WHERE {$mode}_id = $style_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$style_row = $db->sql_fetchrow($result); $style_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$style_row) if (!$style_row)
{ {
@ -1415,41 +1415,41 @@ parse_css_file = {PARSE_CSS_FILE}
WHERE {$mode}_id <> $style_id WHERE {$mode}_id <> $style_id
$sql_where $sql_where
ORDER BY {$mode}_name ASC"; ORDER BY {$mode}_name ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_options = ''; $s_options = '';
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
do do
{ {
$s_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>'; $s_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>';
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
else else
{ {
trigger_error(phpbb::$user->lang['ONLY_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error(phpbb::$user->lang['ONLY_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($update) if ($update)
{ {
$sql = "DELETE FROM $sql_from $sql = "DELETE FROM $sql_from
WHERE {$mode}_id = $style_id"; WHERE {$mode}_id = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if ($mode == 'style') if ($mode == 'style')
{ {
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_style = $new_id SET user_style = $new_id
WHERE user_style = $style_id"; WHERE user_style = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET forum_style = $new_id SET forum_style = $new_id
WHERE forum_style = $style_id"; WHERE forum_style = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if ($style_id == phpbb::$config['default_style']) if ($style_id == phpbb::$config['default_style'])
{ {
@ -1462,12 +1462,12 @@ parse_css_file = {PARSE_CSS_FILE}
{ {
$sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . "
WHERE imageset_id = $style_id"; WHERE imageset_id = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$sql = 'UPDATE ' . STYLES_TABLE . " $sql = 'UPDATE ' . STYLES_TABLE . "
SET {$mode}_id = $new_id SET {$mode}_id = $new_id
WHERE {$mode}_id = $style_id"; WHERE {$mode}_id = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
phpbb::$acm->destroy_sql(STYLES_TABLE); phpbb::$acm->destroy_sql(STYLES_TABLE);
@ -1585,9 +1585,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT $sql_select $sql = "SELECT $sql_select
FROM $sql_from FROM $sql_from
WHERE $sql_where"; WHERE $sql_where";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$style_row = $db->sql_fetchrow($result); $style_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$style_row) if (!$style_row)
{ {
@ -1691,12 +1691,12 @@ parse_css_file = {PARSE_CSS_FILE}
FROM ' . STYLES_IMAGESET_DATA_TABLE . " FROM ' . STYLES_IMAGESET_DATA_TABLE . "
WHERE imageset_id = $style_id WHERE imageset_id = $style_id
AND image_lang = ''"; AND image_lang = ''";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$imageset_main[$row['image_name']] = $row['image_filename'] . ($row['image_height'] ? '*' . $row['image_height']: '') . ($row['image_width'] ? '*' . $row['image_width']: ''); $imageset_main[$row['image_name']] = $row['image_filename'] . ($row['image_height'] ? '*' . $row['image_height']: '') . ($row['image_width'] ? '*' . $row['image_width']: '');
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($this->imageset_keys as $topic => $key_array) foreach ($this->imageset_keys as $topic => $key_array)
{ {
@ -1743,12 +1743,12 @@ parse_css_file = {PARSE_CSS_FILE}
FROM ' . STYLES_IMAGESET_DATA_TABLE . " FROM ' . STYLES_IMAGESET_DATA_TABLE . "
WHERE imageset_id = $style_id WHERE imageset_id = $style_id
AND image_lang <> ''"; AND image_lang <> ''";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$imageset_lang[$row['image_lang']][$row['image_name']] = $row['image_filename'] . ($row['image_height'] ? '*' . $row['image_height']: '') . ($row['image_width'] ? '*' . $row['image_width']: ''); $imageset_lang[$row['image_lang']][$row['image_name']] = $row['image_filename'] . ($row['image_height'] ? '*' . $row['image_height']: '') . ($row['image_width'] ? '*' . $row['image_width']: '');
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($imageset_lang as $lang => $imageset_localized) foreach ($imageset_lang as $lang => $imageset_localized)
{ {
@ -1857,9 +1857,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT {$mode}_id, {$mode}_name $sql = "SELECT {$mode}_id, {$mode}_name
FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . " FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . "
WHERE {$mode}_id = $style_id"; WHERE {$mode}_id = $style_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$style_row = $db->sql_fetchrow($result); $style_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$style_row) if (!$style_row)
{ {
@ -1927,9 +1927,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT * $sql = "SELECT *
FROM $sql_from FROM $sql_from
WHERE {$mode}_id = $style_id"; WHERE {$mode}_id = $style_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$style_row = $db->sql_fetchrow($result); $style_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$style_row) if (!$style_row)
{ {
@ -1953,10 +1953,10 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT {$mode}_id $sql = "SELECT {$mode}_id
FROM $sql_from FROM $sql_from
WHERE {$mode}_id <> $style_id WHERE {$mode}_id <> $style_id
AND {$mode}_name = '" . $db->sql_escape(strtolower($name)) . "'"; AND {$mode}_name = '" . phpbb::$db->sql_escape(strtolower($name)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$conflict = $db->sql_fetchrow($result); $conflict = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($mode == 'style' && (!$template_id || !$theme_id || !$imageset_id)) if ($mode == 'style' && (!$template_id || !$theme_id || !$imageset_id))
{ {
@ -2033,9 +2033,9 @@ parse_css_file = {PARSE_CSS_FILE}
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$sql = "UPDATE $sql_from $sql = "UPDATE $sql_from
SET " . $db->sql_build_array('UPDATE', $sql_ary) . " SET " . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE {$mode}_id = $style_id"; WHERE {$mode}_id = $style_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Making this the default style? // Making this the default style?
if ($mode == 'style' && $style_default) if ($mode == 'style' && $style_default)
@ -2064,15 +2064,15 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT {$element}_id, {$element}_name $sql = "SELECT {$element}_id, {$element}_name
FROM $table FROM $table
ORDER BY {$element}_id ASC"; ORDER BY {$element}_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
${$element . '_options'} = ''; ${$element . '_options'} = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$selected = ($row[$element . '_id'] == $style_row[$element . '_id']) ? ' selected="selected"' : ''; $selected = ($row[$element . '_id'] == $style_row[$element . '_id']) ? ' selected="selected"' : '';
${$element . '_options'} .= '<option value="' . $row[$element . '_id'] . '"' . $selected . '>' . $row[$element . '_name'] . '</option>'; ${$element . '_options'} .= '<option value="' . $row[$element . '_id'] . '"' . $selected . '>' . $row[$element . '_name'] . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -2442,9 +2442,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT $sql_select $sql = "SELECT $sql_select
FROM $sql_from FROM $sql_from
WHERE {$mode}_id = $basis"; WHERE {$mode}_id = $basis";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -2496,15 +2496,15 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT {$element}_id, {$element}_name $sql = "SELECT {$element}_id, {$element}_name
FROM $table FROM $table
ORDER BY {$element}_id ASC"; ORDER BY {$element}_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
${$element . '_options'} = ''; ${$element . '_options'} = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$selected = ($row[$element . '_id'] == $style_row[$element . '_id']) ? ' selected="selected"' : ''; $selected = ($row[$element . '_id'] == $style_row[$element . '_id']) ? ' selected="selected"' : '';
${$element . '_options'} .= '<option value="' . $row[$element . '_id'] . '"' . $selected . '>' . $row[$element . '_name'] . '</option>'; ${$element . '_options'} .= '<option value="' . $row[$element . '_id'] . '"' . $selected . '>' . $row[$element . '_name'] . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -2546,12 +2546,12 @@ parse_css_file = {PARSE_CSS_FILE}
// get all the lang_dirs // get all the lang_dirs
$sql = 'SELECT lang_dir $sql = 'SELECT lang_dir
FROM ' . LANG_TABLE; FROM ' . LANG_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$lang_dirs[] = $row['lang_dir']; $lang_dirs[] = $row['lang_dir'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// get all imagesets this theme is associated with // get all imagesets this theme is associated with
$sql = 'SELECT si.imageset_id, si.imageset_path, st.template_path $sql = 'SELECT si.imageset_id, si.imageset_path, st.template_path
@ -2559,8 +2559,8 @@ parse_css_file = {PARSE_CSS_FILE}
WHERE s.theme_id = ' . (int) $theme['theme_id'] . ' WHERE s.theme_id = ' . (int) $theme['theme_id'] . '
AND s.imageset_id = si.imageset_id AND s.imageset_id = si.imageset_id
AND s.template_id = st.template_id'; AND s.template_id = st.template_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($theme_row = $db->sql_fetchrow($result)) while ($theme_row = phpbb::$db->sql_fetchrow($result))
{ {
foreach ($lang_dirs as $lang_dir) foreach ($lang_dirs as $lang_dir)
{ {
@ -2584,15 +2584,15 @@ parse_css_file = {PARSE_CSS_FILE}
FROM ' . STYLES_IMAGESET_DATA_TABLE . ' FROM ' . STYLES_IMAGESET_DATA_TABLE . '
WHERE imageset_id = ' . $theme['imageset_id'] . " WHERE imageset_id = ' . $theme['imageset_id'] . "
AND image_filename <> '' AND image_filename <> ''
AND image_lang IN ('" . $db->sql_escape($user_image_lang) . "', '')"; AND image_lang IN ('" . phpbb::$db->sql_escape($user_image_lang) . "', '')";
$result2 = $db->sql_query($sql); $result2 = phpbb::$db->sql_query($sql);
$img_array = array(); $img_array = array();
while ($row = $db->sql_fetchrow($result2)) while ($row = phpbb::$db->sql_fetchrow($result2))
{ {
$img_array[$row['image_name']] = $row; $img_array[$row['image_name']] = $row;
} }
$db->sql_freeresult($result2); phpbb::$db->sql_freeresult($result2);
$specific_theme_data = str_replace(array_keys($replace), array_values($replace), $theme['theme_data']); $specific_theme_data = str_replace(array_keys($replace), array_values($replace), $theme['theme_data']);
@ -2651,7 +2651,7 @@ parse_css_file = {PARSE_CSS_FILE}
file_put_contents(PHPBB_ROOT_PATH . '/store/' . $theme['theme_id'] . '_' . $theme['imageset_id'] . '_' . $lang_dir . '.css', $specific_theme_data, LOCK_EX); file_put_contents(PHPBB_ROOT_PATH . '/store/' . $theme['theme_id'] . '_' . $theme['imageset_id'] . '_' . $lang_dir . '.css', $specific_theme_data, LOCK_EX);
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -2694,10 +2694,10 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = "SELECT {$element}_id, {$element}_name $sql = "SELECT {$element}_id, {$element}_name
FROM $sql_from FROM $sql_from
WHERE {$element}_name = '" . $db->sql_escape($chk_name) . "'"; WHERE {$element}_name = '" . phpbb::$db->sql_escape($chk_name) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$name = $row[$element . '_name']; $name = $row[$element . '_name'];
$id = $row[$element . '_id']; $id = $row[$element . '_id'];
@ -2718,7 +2718,7 @@ parse_css_file = {PARSE_CSS_FILE}
unset($cfg); unset($cfg);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -2747,10 +2747,10 @@ parse_css_file = {PARSE_CSS_FILE}
// Check if the name already exist // Check if the name already exist
$sql = 'SELECT style_id $sql = 'SELECT style_id
FROM ' . STYLES_TABLE . " FROM ' . STYLES_TABLE . "
WHERE style_name = '" . $db->sql_escape($name) . "'"; WHERE style_name = '" . phpbb::$db->sql_escape($name) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -2782,7 +2782,7 @@ parse_css_file = {PARSE_CSS_FILE}
return false; return false;
} }
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$sql_ary = array( $sql_ary = array(
'style_name' => $name, 'style_name' => $name,
@ -2794,22 +2794,22 @@ parse_css_file = {PARSE_CSS_FILE}
); );
$sql = 'INSERT INTO ' . STYLES_TABLE . ' $sql = 'INSERT INTO ' . STYLES_TABLE . '
' . $db->sql_build_array('INSERT', $sql_ary); ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$id = $db->sql_nextid(); $id = phpbb::$db->sql_nextid();
if ($default) if ($default)
{ {
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_style = $id SET user_style = $id
WHERE user_style = " . phpbb::$config['default_style']; WHERE user_style = " . phpbb::$config['default_style'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
set_config('default_style', $id); set_config('default_style', $id);
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
add_log('admin', 'LOG_STYLE_ADD', $name); add_log('admin', 'LOG_STYLE_ADD', $name);
} }
@ -2855,10 +2855,10 @@ parse_css_file = {PARSE_CSS_FILE}
// Check if the name already exist // Check if the name already exist
$sql = "SELECT {$mode}_id $sql = "SELECT {$mode}_id
FROM $sql_from FROM $sql_from
WHERE {$mode}_name = '" . $db->sql_escape($name) . "'"; WHERE {$mode}_name = '" . phpbb::$db->sql_escape($name) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
@ -2921,13 +2921,13 @@ parse_css_file = {PARSE_CSS_FILE}
break; break;
} }
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$sql = "INSERT INTO $sql_from $sql = "INSERT INTO $sql_from
" . $db->sql_build_array('INSERT', $sql_ary); " . phpbb::$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$id = $db->sql_nextid(); $id = phpbb::$db->sql_nextid();
if ($mode == 'imageset') if ($mode == 'imageset')
{ {
@ -2972,7 +2972,7 @@ parse_css_file = {PARSE_CSS_FILE}
'imageset_id' => (int) $id, 'imageset_id' => (int) $id,
'image_lang' => '', 'image_lang' => '',
); );
$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
} }
} }
} }
@ -2980,9 +2980,9 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT lang_dir $sql = 'SELECT lang_dir
FROM ' . LANG_TABLE; FROM ' . LANG_TABLE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (@file_exists("$root_path$mode/{$row['lang_dir']}/imageset.cfg")) if (@file_exists("$root_path$mode/{$row['lang_dir']}/imageset.cfg"))
{ {
@ -3020,17 +3020,17 @@ parse_css_file = {PARSE_CSS_FILE}
'imageset_id' => (int) $id, 'imageset_id' => (int) $id,
'image_lang' => $row['lang_dir'], 'image_lang' => $row['lang_dir'],
); );
$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
} }
} }
} }
unset($cfg_data_imageset_data); unset($cfg_data_imageset_data);
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
$log = ($store_db) ? 'LOG_' . $l_type . '_ADD_DB' : 'LOG_' . $l_type . '_ADD_FS'; $log = ($store_db) ? 'LOG_' . $l_type . '_ADD_DB' : 'LOG_' . $l_type . '_ADD_FS';
add_log('admin', $log, $name); add_log('admin', $log, $name);

View file

@ -51,9 +51,9 @@ class acp_update
$sql = 'SELECT config_value $sql = 'SELECT config_value
FROM ' . CONFIG_TABLE . " FROM ' . CONFIG_TABLE . "
WHERE config_name = 'version_update_from'"; WHERE config_name = 'version_update_from'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$version_update_from = (string) $db->sql_fetchfield('config_value'); $version_update_from = (string) phpbb::$db->sql_fetchfield('config_value');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$current_version = (!empty($version_update_from)) ? $version_update_from : phpbb::$config['version']; $current_version = (!empty($version_update_from)) ? $version_update_from : phpbb::$config['version'];

View file

@ -87,10 +87,10 @@ class acp_users
{ {
$sql = 'SELECT user_id $sql = 'SELECT user_id
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; WHERE username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_id = (int) $db->sql_fetchfield('user_id'); $user_id = (int) phpbb::$db->sql_fetchfield('user_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$user_id) if (!$user_id)
{ {
@ -104,9 +104,9 @@ class acp_users
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
WHERE u.user_id = ' . $user_id . ' WHERE u.user_id = ' . $user_id . '
ORDER BY s.session_time DESC'; ORDER BY s.session_time DESC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$user_row) if (!$user_row)
{ {
@ -123,10 +123,10 @@ class acp_users
AND module_enabled = 1 AND module_enabled = 1
AND module_class = 'acp' AND module_class = 'acp'
ORDER BY left_id, module_mode"; ORDER BY left_id, module_mode";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$dropdown_modes = array(); $dropdown_modes = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!$this->p_master->module_auth($row['module_auth'])) if (!$this->p_master->module_auth($row['module_auth']))
{ {
@ -135,7 +135,7 @@ class acp_users
$dropdown_modes[$row['module_mode']] = true; $dropdown_modes[$row['module_mode']] = true;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($dropdown_modes as $module_mode => $null) foreach ($dropdown_modes as $module_mode => $null)
{ {
@ -255,13 +255,13 @@ class acp_users
$sql = 'SELECT DISTINCT poster_ip $sql = 'SELECT DISTINCT poster_ip
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE poster_id = $user_id"; WHERE poster_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ban[] = $row['poster_ip']; $ban[] = $row['poster_ip'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$reason = 'USER_ADMIN_BAN_IP_REASON'; $reason = 'USER_ADMIN_BAN_IP_REASON';
$log = 'LOG_USER_BAN_IP'; $log = 'LOG_USER_BAN_IP';
@ -317,9 +317,9 @@ class acp_users
user_active_flip('deactivate', $user_id, INACTIVE_REMIND); user_active_flip('deactivate', $user_id, INACTIVE_REMIND);
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_actkey = '" . $db->sql_escape($user_actkey) . "' SET user_actkey = '" . phpbb::$db->sql_escape($user_actkey) . "'
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
@ -327,9 +327,9 @@ class acp_users
$sql = 'SELECT user_actkey $sql = 'SELECT user_actkey
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_actkey = (string) $db->sql_fetchfield('user_actkey'); $user_actkey = (string) phpbb::$db->sql_fetchfield('user_actkey');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$messenger = new messenger(false); $messenger = new messenger(false);
@ -407,9 +407,9 @@ class acp_users
'user_sig_bbcode_bitfield' => '' 'user_sig_bbcode_bitfield' => ''
); );
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']); add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER'); add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER');
@ -433,9 +433,9 @@ class acp_users
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Delete old avatar if present // Delete old avatar if present
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY)
@ -523,9 +523,9 @@ class acp_users
$sql = 'SELECT forum_name, forum_type $sql = 'SELECT forum_name, forum_type
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id = $new_forum_id"; WHERE forum_id = $new_forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_info = $db->sql_fetchrow($result); $forum_info = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$forum_info) if (!$forum_info)
{ {
@ -547,22 +547,22 @@ class acp_users
WHERE poster_id = $user_id WHERE poster_id = $user_id
AND forum_id <> $new_forum_id AND forum_id <> $new_forum_id
GROUP BY topic_id"; GROUP BY topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_id_ary[$row['topic_id']] = $row['total_posts']; $topic_id_ary[$row['topic_id']] = $row['total_posts'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($topic_id_ary)) if (sizeof($topic_id_ary))
{ {
$sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real, topic_attachment $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real, topic_attachment
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); WHERE ' . phpbb::$db->sql_in_set('topic_id', array_keys($topic_id_ary));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']])
{ {
@ -576,7 +576,7 @@ class acp_users
$forum_id_ary[] = $row['forum_id']; $forum_id_ary[] = $row['forum_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Entire topic comprises posts by this user, move these topics // Entire topic comprises posts by this user, move these topics
@ -592,7 +592,7 @@ class acp_users
foreach ($move_post_ary as $topic_id => $post_ary) foreach ($move_post_ary as $topic_id => $post_ary)
{ {
// Create new topic // Create new topic
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'topic_poster' => $user_id, 'topic_poster' => $user_id,
'topic_time' => time(), 'topic_time' => time(),
'forum_id' => $new_forum_id, 'forum_id' => $new_forum_id,
@ -604,16 +604,16 @@ class acp_users
'topic_time_limit' => 0, 'topic_time_limit' => 0,
'topic_attachment' => $post_ary['attach']) 'topic_attachment' => $post_ary['attach'])
); );
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$new_topic_id = $db->sql_nextid(); $new_topic_id = phpbb::$db->sql_nextid();
// Move posts // Move posts
$sql = 'UPDATE ' . POSTS_TABLE . " $sql = 'UPDATE ' . POSTS_TABLE . "
SET forum_id = $new_forum_id, topic_id = $new_topic_id SET forum_id = $new_forum_id, topic_id = $new_topic_id
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
AND poster_id = $user_id"; AND poster_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if ($post_ary['attach']) if ($post_ary['attach'])
{ {
@ -621,7 +621,7 @@ class acp_users
SET topic_id = $new_topic_id SET topic_id = $new_topic_id
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
AND poster_id = $user_id"; AND poster_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$new_topic_id_ary[] = $new_topic_id; $new_topic_id_ary[] = $new_topic_id;
@ -746,9 +746,9 @@ class acp_users
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_type = ' . phpbb::USER_FOUNDER . ' WHERE user_type = ' . phpbb::USER_FOUNDER . '
AND user_id <> ' . $user_id; AND user_id <> ' . $user_id;
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -795,9 +795,9 @@ class acp_users
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if ($update_username) if ($update_username)
@ -854,9 +854,9 @@ class acp_users
$sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
FROM ' . SESSIONS_TABLE . " FROM ' . SESSIONS_TABLE . "
WHERE session_user_id = $user_id"; WHERE session_user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; $user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
$user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; $user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
@ -895,9 +895,9 @@ class acp_users
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $user_id . ' WHERE poster_id = ' . $user_id . '
AND post_approved = 0'; AND post_approved = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $user_row['posts_in_queue'] = (int) phpbb::$db->sql_fetchfield('posts_in_queue');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'L_NAME_CHARS_EXPLAIN' => sprintf(phpbb::$user->lang[phpbb::$config['allow_name_chars'] . '_EXPLAIN'], phpbb::$config['min_name_chars'], phpbb::$config['max_name_chars']), 'L_NAME_CHARS_EXPLAIN' => sprintf(phpbb::$user->lang[phpbb::$config['allow_name_chars'] . '_EXPLAIN'], phpbb::$config['min_name_chars'], phpbb::$config['max_name_chars']),
@ -963,7 +963,7 @@ class acp_users
{ {
$sql_in[] = $mark; $sql_in[] = $mark;
} }
$where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); $where_sql = ' AND ' . phpbb::$db->sql_in_set('log_id', $sql_in);
unset($sql_in); unset($sql_in);
} }
@ -972,7 +972,7 @@ class acp_users
$sql = 'DELETE FROM ' . LOG_TABLE . ' $sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_USERS . " WHERE log_type = ' . LOG_USERS . "
$where_sql"; $where_sql";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_USER', $user_row['username']); add_log('admin', 'LOG_CLEAR_USER', $user_row['username']);
} }
@ -1044,10 +1044,10 @@ class acp_users
$sql = 'SELECT lang_id $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $db->sql_escape(phpbb::$user->data['user_lang']) . "'"; WHERE lang_iso = '" . phpbb::$db->sql_escape(phpbb::$user->data['user_lang']) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$user_row['iso_lang_id'] = $row['lang_id']; $user_row['iso_lang_id'] = $row['lang_id'];
@ -1129,14 +1129,14 @@ class acp_users
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Update Custom Fields // Update Custom Fields
if (sizeof($cp_data)) if (sizeof($cp_data))
{ {
switch ($db->dbms_type) switch (phpbb::$db->dbms_type)
{ {
case 'oracle': case 'oracle':
case 'firebird': case 'firebird':
@ -1163,20 +1163,20 @@ class acp_users
} }
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $cp_data) . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (!$db->sql_affectedrows()) if (!phpbb::$db->sql_affectedrows())
{ {
$cp_data['user_id'] = (int) $user_id; $cp_data['user_id'] = (int) $user_id;
$db->sql_return_on_error(true); phpbb::$db->sql_return_on_error(true);
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $cp_data);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$db->sql_return_on_error(false); phpbb::$db->sql_return_on_error(false);
} }
} }
@ -1334,9 +1334,9 @@ class acp_users
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
trigger_error(phpbb::$user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id)); trigger_error(phpbb::$user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
} }
@ -1514,7 +1514,7 @@ class acp_users
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_rank = $rank_id SET user_rank = $rank_id
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
trigger_error(phpbb::$user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id)); trigger_error(phpbb::$user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
} }
@ -1523,16 +1523,16 @@ class acp_users
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
WHERE rank_special = 1 WHERE rank_special = 1
ORDER BY rank_title'; ORDER BY rank_title';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_rank_options = '<option value="0"' . ((!$user_row['user_rank']) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['NO_SPECIAL_RANK'] . '</option>'; $s_rank_options = '<option value="0"' . ((!$user_row['user_rank']) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['NO_SPECIAL_RANK'] . '</option>';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : ''; $selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : '';
$s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_RANK' => true, 'S_RANK' => true,
@ -1581,9 +1581,9 @@ class acp_users
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
trigger_error(phpbb::$user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id)); trigger_error(phpbb::$user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
} }
@ -1649,15 +1649,15 @@ class acp_users
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE poster_id = ' . $user_id . ' WHERE poster_id = ' . $user_id . '
AND is_orphan = 0 AND is_orphan = 0
AND ' . $db->sql_in_set('attach_id', $marked); AND ' . phpbb::$db->sql_in_set('attach_id', $marked);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$marked = array(); $marked = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$marked[] = $row['attach_id']; $marked[] = $row['attach_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if ($deletemark && sizeof($marked)) if ($deletemark && sizeof($marked))
@ -1666,15 +1666,15 @@ class acp_users
{ {
$sql = 'SELECT real_filename $sql = 'SELECT real_filename
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', $marked); WHERE ' . phpbb::$db->sql_in_set('attach_id', $marked);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$log_attachments = array(); $log_attachments = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$log_attachments[] = $row['real_filename']; $log_attachments[] = $row['real_filename'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
delete_attachments('attach', $marked); delete_attachments('attach', $marked);
@ -1726,9 +1726,9 @@ class acp_users
FROM ' . ATTACHMENTS_TABLE . " FROM ' . ATTACHMENTS_TABLE . "
WHERE poster_id = $user_id WHERE poster_id = $user_id
AND is_orphan = 0"; AND is_orphan = 0";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$num_attachments = (int) $db->sql_fetchfield('num_attachments'); $num_attachments = (int) phpbb::$db->sql_fetchfield('num_attachments');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
FROM ' . ATTACHMENTS_TABLE . ' a FROM ' . ATTACHMENTS_TABLE . ' a
@ -1739,9 +1739,9 @@ class acp_users
WHERE a.poster_id = ' . $user_id . " WHERE a.poster_id = ' . $user_id . "
AND a.is_orphan = 0 AND a.is_orphan = 0
ORDER BY $order_by"; ORDER BY $order_by";
$result = $db->sql_query_limit($sql, phpbb::$config['posts_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['posts_per_page'], $start);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['in_message']) if ($row['in_message'])
{ {
@ -1771,7 +1771,7 @@ class acp_users
'U_VIEW_TOPIC' => $view_topic) 'U_VIEW_TOPIC' => $view_topic)
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_ATTACHMENTS' => true, 'S_ATTACHMENTS' => true,
@ -1797,9 +1797,9 @@ class acp_users
$sql = 'SELECT group_founder_manage $sql = 'SELECT group_founder_manage
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . $group_id; WHERE group_id = ' . $group_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); $founder_manage = (int) phpbb::$db->sql_fetchfield('group_founder_manage');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!phpbb::$user->is_founder && $founder_manage) if (!phpbb::$user->is_founder && $founder_manage)
{ {
@ -1887,11 +1887,11 @@ class acp_users
WHERE ug.user_id = $user_id WHERE ug.user_id = $user_id
AND g.group_id = ug.group_id AND g.group_id = ug.group_id
ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name"; ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$i = 0; $i = 0;
$group_data = $id_ary = array(); $group_data = $id_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal'); $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal');
@ -1903,17 +1903,17 @@ class acp_users
$i++; $i++;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Select box for other groups // Select box for other groups
$sql = 'SELECT group_id, group_name, group_type, group_founder_manage $sql = 'SELECT group_id, group_name, group_type, group_founder_manage
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
' . ((sizeof($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . ' ' . ((sizeof($id_ary)) ? 'WHERE ' . phpbb::$db->sql_in_set('group_id', $id_ary, true) : '') . '
ORDER BY group_type DESC, group_name ASC'; ORDER BY group_type DESC, group_name ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_group_options = ''; $s_group_options = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if (!phpbb::$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA') if (!phpbb::$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA')
{ {
@ -1928,7 +1928,7 @@ class acp_users
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; $s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$current_type = ''; $current_type = '';
foreach ($group_data as $group_type => $data_ary) foreach ($group_data as $group_type => $data_ary)
@ -1983,19 +1983,19 @@ class acp_users
// Select auth options // Select auth options
$sql = 'SELECT auth_option, is_local, is_global $sql = 'SELECT auth_option, is_local, is_global
FROM ' . ACL_OPTIONS_TABLE . ' FROM ' . ACL_OPTIONS_TABLE . '
WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . ' WHERE auth_option ' . phpbb::$db->sql_like_expression(phpbb::$db->any_char . '_') . '
AND is_global = 1 AND is_global = 1
ORDER BY auth_option'; ORDER BY auth_option';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$hold_ary = array(); $hold_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', phpbb::ACL_NEVER); $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', phpbb::ACL_NEVER);
$auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
unset($hold_ary); unset($hold_ary);
} }
@ -2003,17 +2003,17 @@ class acp_users
{ {
$sql = 'SELECT auth_option, is_local, is_global $sql = 'SELECT auth_option, is_local, is_global
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . " WHERE auth_option " . phpbb::$db->sql_like_expression(phpbb::$db->any_char . '_') . "
AND is_local = 1 AND is_local = 1
ORDER BY is_global DESC, auth_option"; ORDER BY is_global DESC, auth_option";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', phpbb::ACL_NEVER); $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', phpbb::ACL_NEVER);
$auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$s_forum_options = '<option value="0"' . ((!$forum_id) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['VIEW_GLOBAL_PERMS'] . '</option>'; $s_forum_options = '<option value="0"' . ((!$forum_id) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['VIEW_GLOBAL_PERMS'] . '</option>';

View file

@ -54,9 +54,9 @@ class acp_words
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . WORDS_TABLE . " FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id"; WHERE word_id = $word_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$word_info = $db->sql_fetchrow($result); $word_info = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />'; $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
@ -97,11 +97,11 @@ class acp_words
if ($word_id) if ($word_id)
{ {
$db->sql_query('UPDATE ' . WORDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE word_id = ' . $word_id); phpbb::$db->sql_query('UPDATE ' . WORDS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . ' WHERE word_id = ' . $word_id);
} }
else else
{ {
$db->sql_query('INSERT INTO ' . WORDS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . WORDS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
} }
phpbb::$acm->destroy('word_censors'); phpbb::$acm->destroy('word_censors');
@ -128,13 +128,13 @@ class acp_words
$sql = 'SELECT word $sql = 'SELECT word
FROM ' . WORDS_TABLE . " FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id"; WHERE word_id = $word_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$deleted_word = $db->sql_fetchfield('word'); $deleted_word = phpbb::$db->sql_fetchfield('word');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'DELETE FROM ' . WORDS_TABLE . " $sql = 'DELETE FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id"; WHERE word_id = $word_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$acm->destroy('word_censors'); phpbb::$acm->destroy('word_censors');
@ -164,9 +164,9 @@ class acp_words
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . WORDS_TABLE . ' FROM ' . WORDS_TABLE . '
ORDER BY word'; ORDER BY word';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('words', array( $template->assign_block_vars('words', array(
'WORD' => $row['word'], 'WORD' => $row['word'],
@ -175,7 +175,7 @@ class acp_words
'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row['word_id']) 'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row['word_id'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }

View file

@ -32,11 +32,11 @@ class auth_admin extends auth
$sql = 'SELECT auth_option_id, auth_option, is_global, is_local $sql = 'SELECT auth_option_id, auth_option, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . ' FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id'; ORDER BY auth_option_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$global = $local = 0; $global = $local = 0;
$this->acl_options = array(); $this->acl_options = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['is_global']) if ($row['is_global'])
{ {
@ -51,7 +51,7 @@ class auth_admin extends auth
$this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id']; $this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id'];
$this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option']; $this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
phpbb::$acm->put('acl_options', $this->acl_options); phpbb::$acm->put('acl_options', $this->acl_options);
} }
@ -105,13 +105,13 @@ class auth_admin extends auth
{ {
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE; FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql, 120); $result = phpbb::$db->sql_query($sql, 120);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_ids[] = (int) $row['forum_id']; $forum_ids[] = (int) $row['forum_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if ($view_user_mask) if ($view_user_mask)
@ -120,10 +120,10 @@ class auth_admin extends auth
$sql = 'SELECT user_id, user_permissions, user_type $sql = 'SELECT user_id, user_permissions, user_type
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $ug_id); WHERE ' . phpbb::$db->sql_in_set('user_id', $ug_id);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($userdata = $db->sql_fetchrow($result)) while ($userdata = phpbb::$db->sql_fetchrow($result))
{ {
if (phpbb::$user->data['user_id'] != $userdata['user_id']) if (phpbb::$user->data['user_id'] != $userdata['user_id'])
{ {
@ -147,7 +147,7 @@ class auth_admin extends auth
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
unset($userdata); unset($userdata);
unset($auth2); unset($auth2);
@ -227,26 +227,26 @@ class auth_admin extends auth
FROM ' . ACL_USERS_TABLE . ' FROM ' . ACL_USERS_TABLE . '
WHERE auth_role_id = ' . $role_id . ' WHERE auth_role_id = ' . $role_id . '
ORDER BY forum_id'; ORDER BY forum_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$hold_ary[$row['forum_id']]['users'][] = $row['user_id']; $hold_ary[$row['forum_id']]['users'][] = $row['user_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Now grab groups... // Now grab groups...
$sql = 'SELECT group_id, forum_id $sql = 'SELECT group_id, forum_id
FROM ' . ACL_GROUPS_TABLE . ' FROM ' . ACL_GROUPS_TABLE . '
WHERE auth_role_id = ' . $role_id . ' WHERE auth_role_id = ' . $role_id . '
ORDER BY forum_id'; ORDER BY forum_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$hold_ary[$row['forum_id']]['groups'][] = $row['group_id']; $hold_ary[$row['forum_id']]['groups'][] = $row['group_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
return $hold_ary; return $hold_ary;
} }
@ -272,24 +272,24 @@ class auth_admin extends auth
{ {
$sql = 'SELECT user_id as ug_id, username as ug_name $sql = 'SELECT user_id as ug_id, username as ug_name
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary)) . ' WHERE ' . phpbb::$db->sql_in_set('user_id', array_keys($hold_ary)) . '
ORDER BY username_clean ASC'; ORDER BY username_clean ASC';
} }
else else
{ {
$sql = 'SELECT group_id as ug_id, group_name as ug_name, group_type $sql = 'SELECT group_id as ug_id, group_name as ug_name, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE ' . $db->sql_in_set('group_id', array_keys($hold_ary)) . ' WHERE ' . phpbb::$db->sql_in_set('group_id', array_keys($hold_ary)) . '
ORDER BY group_type DESC, group_name ASC'; ORDER BY group_type DESC, group_name ASC';
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$ug_names_ary = array(); $ug_names_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$ug_names_ary[$row['ug_id']] = ($user_mode == 'user') ? $row['ug_name'] : (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['ug_name']] : $row['ug_name']); $ug_names_ary[$row['ug_id']] = ($user_mode == 'user') ? $row['ug_name'] : (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['ug_name']] : $row['ug_name']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Get used forums // Get used forums
$forum_ids = array(); $forum_ids = array();
@ -322,16 +322,16 @@ class auth_admin extends auth
// Get available roles // Get available roles
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ACL_ROLES_TABLE . " FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = '" . $db->sql_escape($permission_type) . "' WHERE role_type = '" . phpbb::$db->sql_escape($permission_type) . "'
ORDER BY role_order ASC"; ORDER BY role_order ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$roles = array(); $roles = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$roles[$row['role_id']] = $row; $roles[$row['role_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cur_roles = $this->acl_role_data($user_mode, $permission_type, array_keys($hold_ary)); $cur_roles = $this->acl_role_data($user_mode, $permission_type, array_keys($hold_ary));
@ -351,10 +351,10 @@ class auth_admin extends auth
$sql = 'SELECT r.role_id, o.auth_option, r.auth_setting $sql = 'SELECT r.role_id, o.auth_option, r.auth_setting
FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o
WHERE o.auth_option_id = r.auth_option_id WHERE o.auth_option_id = r.auth_option_id
AND ' . $db->sql_in_set('r.role_id', array_keys($roles)); AND ' . phpbb::$db->sql_in_set('r.role_id', array_keys($roles));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$flag = substr($row['auth_option'], 0, strpos($row['auth_option'], '_') + 1); $flag = substr($row['auth_option'], 0, strpos($row['auth_option'], '_') + 1);
if ($flag == $row['auth_option']) if ($flag == $row['auth_option'])
@ -364,7 +364,7 @@ class auth_admin extends auth
$s_role_js_array[$row['role_id']] .= 'role_options[' . $row['role_id'] . '][\'' . addslashes($row['auth_option']) . '\'] = ' . $row['auth_setting'] . '; '; $s_role_js_array[$row['role_id']] .= 'role_options[' . $row['role_id'] . '][\'' . addslashes($row['auth_option']) . '\'] = ' . $row['auth_setting'] . '; ';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$s_role_js_array = implode('', $s_role_js_array); $s_role_js_array = implode('', $s_role_js_array);
} }
@ -379,14 +379,14 @@ class auth_admin extends auth
$sql = 'SELECT group_id, group_name, group_type $sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_type DESC, group_name ASC'; ORDER BY group_type DESC, group_name ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$groups = array(); $groups = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$groups[$row['group_id']] = $row; $groups[$row['group_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$memberships = group_memberships(false, array_keys($hold_ary), false); $memberships = group_memberships(false, array_keys($hold_ary), false);
@ -606,17 +606,17 @@ class auth_admin extends auth
// Get forum names // Get forum names
$sql = 'SELECT forum_id, forum_name $sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', array_keys($hold_ary)) . ' WHERE ' . phpbb::$db->sql_in_set('forum_id', array_keys($hold_ary)) . '
ORDER BY left_id'; ORDER BY left_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
// If the role is used globally, then reflect that // If the role is used globally, then reflect that
$forum_names = (isset($hold_ary[0])) ? array(0 => '') : array(); $forum_names = (isset($hold_ary[0])) ? array(0 => '') : array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_names[$row['forum_id']] = $row['forum_name']; $forum_names[$row['forum_id']] = $row['forum_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($forum_names as $forum_id => $forum_name) foreach ($forum_names as $forum_id => $forum_name)
{ {
@ -631,11 +631,11 @@ class auth_admin extends auth
{ {
$sql = 'SELECT user_id, username $sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $auth_ary['users']) . ' WHERE ' . phpbb::$db->sql_in_set('user_id', $auth_ary['users']) . '
ORDER BY username_clean ASC'; ORDER BY username_clean ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('role_mask.users', array( $template->assign_block_vars('role_mask.users', array(
'USER_ID' => $row['user_id'], 'USER_ID' => $row['user_id'],
@ -643,18 +643,18 @@ class auth_admin extends auth
'U_PROFILE' => append_sid('memberlist', "mode=viewprofile&amp;u={$row['user_id']}")) 'U_PROFILE' => append_sid('memberlist', "mode=viewprofile&amp;u={$row['user_id']}"))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (isset($auth_ary['groups']) && sizeof($auth_ary['groups'])) if (isset($auth_ary['groups']) && sizeof($auth_ary['groups']))
{ {
$sql = 'SELECT group_id, group_name, group_type $sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE ' . $db->sql_in_set('group_id', $auth_ary['groups']) . ' WHERE ' . phpbb::$db->sql_in_set('group_id', $auth_ary['groups']) . '
ORDER BY group_type ASC, group_name'; ORDER BY group_type ASC, group_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('role_mask.groups', array( $template->assign_block_vars('role_mask.groups', array(
'GROUP_ID' => $row['group_id'], 'GROUP_ID' => $row['group_id'],
@ -662,7 +662,7 @@ class auth_admin extends auth
'U_PROFILE' => append_sid('memberlist', "mode=group&amp;g={$row['group_id']}")) 'U_PROFILE' => append_sid('memberlist', "mode=group&amp;g={$row['group_id']}"))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
} }
@ -682,9 +682,9 @@ class auth_admin extends auth
$sql = 'SELECT auth_option, is_global, is_local $sql = 'SELECT auth_option, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . ' FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id'; ORDER BY auth_option_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['is_global']) if ($row['is_global'])
{ {
@ -696,7 +696,7 @@ class auth_admin extends auth
$cur_options['local'][] = $row['auth_option']; $cur_options['local'][] = $row['auth_option'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Here we need to insert new options ... this requires discovering whether // Here we need to insert new options ... this requires discovering whether
// an options is global, local or both and whether we need to add an permission // an options is global, local or both and whether we need to add an permission
@ -743,7 +743,7 @@ class auth_admin extends auth
} }
} }
$db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary);
phpbb::$acm->destroy('acl_options'); phpbb::$acm->destroy('acl_options');
$this->acl_clear_prefetch(); $this->acl_clear_prefetch();
@ -772,8 +772,8 @@ class auth_admin extends auth
$ug_id = array($ug_id); $ug_id = array($ug_id);
} }
$ug_id_sql = $db->sql_in_set($ug_type . '_id', array_map('intval', $ug_id)); $ug_id_sql = phpbb::$db->sql_in_set($ug_type . '_id', array_map('intval', $ug_id));
$forum_sql = $db->sql_in_set('forum_id', array_map('intval', $forum_id)); $forum_sql = phpbb::$db->sql_in_set('forum_id', array_map('intval', $forum_id));
// Instead of updating, inserting, removing we just remove all current settings and re-set everything... // Instead of updating, inserting, removing we just remove all current settings and re-set everything...
$table = ($ug_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE; $table = ($ug_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE;
@ -803,21 +803,21 @@ class auth_admin extends auth
$sql = "DELETE FROM $table $sql = "DELETE FROM $table
WHERE $forum_sql WHERE $forum_sql
AND $ug_id_sql AND $ug_id_sql
AND " . $db->sql_in_set('auth_option_id', $auth_option_ids); AND " . phpbb::$db->sql_in_set('auth_option_id', $auth_option_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Remove those having a role assigned... the correct type of course... // Remove those having a role assigned... the correct type of course...
$sql = 'SELECT role_id $sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . " FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = '" . $db->sql_escape($flag) . "'"; WHERE role_type = '" . phpbb::$db->sql_escape($flag) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$role_ids = array(); $role_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$role_ids[] = $row['role_id']; $role_ids[] = $row['role_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($role_ids)) if (sizeof($role_ids))
{ {
@ -825,8 +825,8 @@ class auth_admin extends auth
WHERE $forum_sql WHERE $forum_sql
AND $ug_id_sql AND $ug_id_sql
AND auth_option_id = 0 AND auth_option_id = 0
AND " . $db->sql_in_set('auth_role_id', $role_ids); AND " . phpbb::$db->sql_in_set('auth_role_id', $role_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Ok, include the any-flag if one or more auth options are set to yes... // Ok, include the any-flag if one or more auth options are set to yes...
@ -878,7 +878,7 @@ class auth_admin extends auth
} }
} }
$db->sql_multi_insert($table, $sql_ary); phpbb::$db->sql_multi_insert($table, $sql_ary);
if ($clear_prefetch) if ($clear_prefetch)
{ {
@ -939,10 +939,10 @@ class auth_admin extends auth
// Remove current auth options... // Remove current auth options...
$sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Now insert the new values // Now insert the new values
$db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary);
$this->acl_clear_prefetch(); $this->acl_clear_prefetch();
} }
@ -965,12 +965,12 @@ class auth_admin extends auth
if ($forum_id !== false) if ($forum_id !== false)
{ {
$where_sql[] = (!is_array($forum_id)) ? 'forum_id = ' . (int) $forum_id : $db->sql_in_set('forum_id', array_map('intval', $forum_id)); $where_sql[] = (!is_array($forum_id)) ? 'forum_id = ' . (int) $forum_id : phpbb::$db->sql_in_set('forum_id', array_map('intval', $forum_id));
} }
if ($ug_id !== false) if ($ug_id !== false)
{ {
$where_sql[] = (!is_array($ug_id)) ? $id_field . ' = ' . (int) $ug_id : $db->sql_in_set($id_field, array_map('intval', $ug_id)); $where_sql[] = (!is_array($ug_id)) ? $id_field . ' = ' . (int) $ug_id : phpbb::$db->sql_in_set($id_field, array_map('intval', $ug_id));
} }
// There seem to be auth options involved, therefore we need to go through the list and make sure we capture roles correctly // There seem to be auth options involved, therefore we need to go through the list and make sure we capture roles correctly
@ -979,16 +979,16 @@ class auth_admin extends auth
// Get permission type // Get permission type
$sql = 'SELECT auth_option, auth_option_id $sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . " FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char); WHERE auth_option " . phpbb::$db->sql_like_expression($permission_type . phpbb::$db->any_char);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$auth_id_ary = array(); $auth_id_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$option_id_ary[] = $row['auth_option_id']; $option_id_ary[] = $row['auth_option_id'];
$auth_id_ary[$row['auth_option']] = phpbb::ACL_NO; $auth_id_ary[$row['auth_option']] = phpbb::ACL_NO;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// First of all, lets grab the items having roles with the specified auth options assigned // First of all, lets grab the items having roles with the specified auth options assigned
$sql = "SELECT auth_role_id, $id_field, forum_id $sql = "SELECT auth_role_id, $id_field, forum_id
@ -998,14 +998,14 @@ class auth_admin extends auth
AND r.role_type = '{$permission_type}' AND r.role_type = '{$permission_type}'
AND " . implode(' AND ', $where_sql) . ' AND " . implode(' AND ', $where_sql) . '
ORDER BY auth_role_id'; ORDER BY auth_role_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$cur_role_auth = array(); $cur_role_auth = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$cur_role_auth[$row['auth_role_id']][$row['forum_id']][] = $row[$id_field]; $cur_role_auth[$row['auth_role_id']][$row['forum_id']][] = $row[$id_field];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Get role data for resetting data // Get role data for resetting data
if (sizeof($cur_role_auth)) if (sizeof($cur_role_auth))
@ -1013,11 +1013,11 @@ class auth_admin extends auth
$sql = 'SELECT ao.auth_option, rd.role_id, rd.auth_setting $sql = 'SELECT ao.auth_option, rd.role_id, rd.auth_setting
FROM ' . ACL_OPTIONS_TABLE . ' ao, ' . ACL_ROLES_DATA_TABLE . ' rd FROM ' . ACL_OPTIONS_TABLE . ' ao, ' . ACL_ROLES_DATA_TABLE . ' rd
WHERE ao.auth_option_id = rd.auth_option_id WHERE ao.auth_option_id = rd.auth_option_id
AND ' . $db->sql_in_set('rd.role_id', array_keys($cur_role_auth)); AND ' . phpbb::$db->sql_in_set('rd.role_id', array_keys($cur_role_auth));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$auth_settings = array(); $auth_settings = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// We need to fill all auth_options, else setting it will fail... // We need to fill all auth_options, else setting it will fail...
if (!isset($auth_settings[$row['role_id']])) if (!isset($auth_settings[$row['role_id']]))
@ -1026,7 +1026,7 @@ class auth_admin extends auth
} }
$auth_settings[$row['role_id']][$row['auth_option']] = $row['auth_setting']; $auth_settings[$row['role_id']][$row['auth_option']] = $row['auth_setting'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Set the options // Set the options
foreach ($cur_role_auth as $role_id => $auth_row) foreach ($cur_role_auth as $role_id => $auth_row)
@ -1042,12 +1042,12 @@ class auth_admin extends auth
// Now, normally remove permissions... // Now, normally remove permissions...
if ($permission_type !== false) if ($permission_type !== false)
{ {
$where_sql[] = $db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary)); $where_sql[] = phpbb::$db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary));
} }
$sql = "DELETE FROM $table $sql = "DELETE FROM $table
WHERE " . implode(' AND ', $where_sql); WHERE " . implode(' AND ', $where_sql);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$this->acl_clear_prefetch(); $this->acl_clear_prefetch();
} }
@ -1224,10 +1224,10 @@ class auth_admin extends auth
} }
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_permissions = '" . $db->sql_escape($user_permissions) . "', SET user_permissions = '" . phpbb::$db->sql_escape($user_permissions) . "',
user_perm_from = $from_user_id user_perm_from = $from_user_id
WHERE user_id = " . $to_user_id; WHERE user_id = " . $to_user_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
return true; return true;
} }

View file

@ -163,22 +163,22 @@ class mcp_ban
$sql = 'SELECT username, user_email, user_ip $sql = 'SELECT username, user_email, user_ip
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id; WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
switch ($mode) switch ($mode)
{ {
case 'user': case 'user':
$pre_fill = (string) $db->sql_fetchfield('username'); $pre_fill = (string) phpbb::$db->sql_fetchfield('username');
break; break;
case 'ip': case 'ip':
$pre_fill = (string) $db->sql_fetchfield('user_ip'); $pre_fill = (string) phpbb::$db->sql_fetchfield('user_ip');
break; break;
case 'email': case 'email':
$pre_fill = (string) $db->sql_fetchfield('user_email'); $pre_fill = (string) phpbb::$db->sql_fetchfield('user_email');
break; break;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else if ($post_id) else if ($post_id)
{ {

View file

@ -154,26 +154,26 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
" . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " " . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
$limit_time_sql $limit_time_sql
ORDER BY t.topic_type DESC, $sort_order_sql"; ORDER BY t.topic_type DESC, $sort_order_sql";
$result = $db->sql_query_limit($sql, $topics_per_page, $start); $result = phpbb::$db->sql_query_limit($sql, $topics_per_page, $start);
$topic_list = $topic_tracking_info = array(); $topic_list = $topic_tracking_info = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_list[] = $row['topic_id']; $topic_list[] = $row['topic_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = "SELECT t.*$read_tracking_select $sql = "SELECT t.*$read_tracking_select
FROM " . TOPICS_TABLE . " t $read_tracking_join FROM " . TOPICS_TABLE . " t $read_tracking_join
WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true); WHERE " . phpbb::$db->sql_in_set('t.topic_id', $topic_list, false, true);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_rows[$row['topic_id']] = $row; $topic_rows[$row['topic_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
if (!sizeof($topic_list) && $forum_topics && $start > 0) if (!sizeof($topic_list) && $forum_topics && $start > 0)
@ -312,15 +312,15 @@ function mcp_resync_topics($topic_ids)
$sql = 'SELECT topic_id, forum_id, topic_title $sql = 'SELECT topic_id, forum_id, topic_title
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
// Log this action // Log this action
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']); add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$msg = (sizeof($topic_ids) == 1) ? phpbb::$user->lang['TOPIC_RESYNC_SUCCESS'] : phpbb::$user->lang['TOPICS_RESYNC_SUCCESS']; $msg = (sizeof($topic_ids) == 1) ? phpbb::$user->lang['TOPIC_RESYNC_SUCCESS'] : phpbb::$user->lang['TOPICS_RESYNC_SUCCESS'];
@ -365,15 +365,15 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
{ {
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_id_list = array(); $post_id_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_id_list[] = $row['post_id']; $post_id_list[] = $row['post_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!sizeof($post_id_list)) if (!sizeof($post_id_list))
@ -414,11 +414,11 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
// If the topic no longer exist, we will update the topic watch table. // If the topic no longer exist, we will update the topic watch table.
// To not let it error out on users watching both topics, we just return on an error... // To not let it error out on users watching both topics, we just return on an error...
$db->sql_return_on_error(true); phpbb::$db->sql_return_on_error(true);
$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); phpbb::$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids));
$db->sql_return_on_error(false); phpbb::$db->sql_return_on_error(false);
$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); phpbb::$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids));
// Link to the new topic // Link to the new topic
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf(phpbb::$user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid('viewtopic', 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>'); $return_link .= (($return_link) ? '<br /><br />' : '') . sprintf(phpbb::$user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid('viewtopic', 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');

View file

@ -40,9 +40,9 @@ function mcp_front_view($id, $mode, $action)
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
AND post_approved = 0'; AND post_approved = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total'); $total = (int) phpbb::$db->sql_fetchfield('total');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($total) if ($total)
{ {
@ -50,27 +50,27 @@ function mcp_front_view($id, $mode, $action)
$sql = 'SELECT forum_id, forum_name $sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_list);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_names[$row['forum_id']] = $row['forum_name']; $forum_names[$row['forum_id']] = $row['forum_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
AND post_approved = 0 AND post_approved = 0
ORDER BY post_time DESC'; ORDER BY post_time DESC';
$result = $db->sql_query_limit($sql, 5); $result = phpbb::$db->sql_query_limit($sql, 5);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_list[] = $row['post_id']; $post_list[] = $row['post_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (empty($post_list)) if (empty($post_list))
{ {
@ -82,13 +82,13 @@ 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, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
WHERE ' . $db->sql_in_set('p.post_id', $post_list) . ' WHERE ' . phpbb::$db->sql_in_set('p.post_id', $post_list) . '
AND t.topic_id = p.topic_id AND t.topic_id = p.topic_id
AND p.poster_id = u.user_id AND p.poster_id = u.user_id
ORDER BY p.post_time DESC'; ORDER BY p.post_time DESC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$global_topic = ($row['forum_id']) ? false : true; $global_topic = ($row['forum_id']) ? false : true;
if ($global_topic) if ($global_topic)
@ -115,7 +115,7 @@ function mcp_front_view($id, $mode, $action)
'POST_TIME' => phpbb::$user->format_date($row['post_time'])) 'POST_TIME' => phpbb::$user->format_date($row['post_time']))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$template->assign_vars(array( $template->assign_vars(array(
@ -153,15 +153,15 @@ function mcp_front_view($id, $mode, $action)
WHERE r.post_id = p.post_id WHERE r.post_id = p.post_id
AND r.report_closed = 0 AND r.report_closed = 0
AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total'); $total = (int) phpbb::$db->sql_fetchfield('total');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($total) if ($total)
{ {
$global_id = $forum_list[0]; $global_id = $forum_list[0];
$sql = $db->sql_build_query('SELECT', array( $sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', 'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
'FROM' => array( 'FROM' => array(
@ -189,9 +189,9 @@ function mcp_front_view($id, $mode, $action)
'ORDER_BY' => 'p.post_time DESC' 'ORDER_BY' => 'p.post_time DESC'
)); ));
$result = $db->sql_query_limit($sql, 5); $result = phpbb::$db->sql_query_limit($sql, 5);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$global_topic = ($row['forum_id']) ? false : true; $global_topic = ($row['forum_id']) ? false : true;
if ($global_topic) if ($global_topic)

View file

@ -87,9 +87,9 @@ class mcp_logs
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id; WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_id = (int) $db->sql_fetchfield('forum_id'); $forum_id = (int) phpbb::$db->sql_fetchfield('forum_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!in_array($forum_id, $forum_list)) if (!in_array($forum_id, $forum_list))
{ {
@ -109,9 +109,9 @@ class mcp_logs
{ {
$sql = 'DELETE FROM ' . LOG_TABLE . ' $sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_MOD . ' WHERE log_type = ' . LOG_MOD . '
AND ' . $db->sql_in_set('forum_id', $forum_list) . ' AND ' . phpbb::$db->sql_in_set('forum_id', $forum_list) . '
AND ' . $db->sql_in_set('log_id', $marked); AND ' . phpbb::$db->sql_in_set('log_id', $marked);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_MOD'); add_log('admin', 'LOG_CLEAR_MOD');
} }
@ -119,13 +119,13 @@ class mcp_logs
{ {
$sql = 'DELETE FROM ' . LOG_TABLE . ' $sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_MOD . ' WHERE log_type = ' . LOG_MOD . '
AND ' . $db->sql_in_set('forum_id', $forum_list); AND ' . phpbb::$db->sql_in_set('forum_id', $forum_list);
if ($mode == 'topic_logs') if ($mode == 'topic_logs')
{ {
$sql .= ' AND topic_id = ' . $topic_id; $sql .= ' AND topic_id = ' . $topic_id;
} }
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_MOD'); add_log('admin', 'LOG_CLEAR_MOD');
} }

View file

@ -245,8 +245,8 @@ function lock_unlock($action, $ids)
{ {
$sql = "UPDATE $table $sql = "UPDATE $table
SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . ' SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . '
WHERE ' . $db->sql_in_set($sql_id, $ids); WHERE ' . phpbb::$db->sql_in_set($sql_id, $ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$data = ($action == 'lock' || $action == 'unlock') ? get_topic_data($ids) : get_post_data($ids); $data = ($action == 'lock' || $action == 'unlock') ? get_topic_data($ids) : get_post_data($ids);
@ -332,9 +332,9 @@ function change_topic_type($action, $topic_ids)
{ {
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type SET topic_type = $new_topic_type
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' WHERE " . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id <> 0'; AND forum_id <> 0';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Reset forum id if a global topic is within the array // Reset forum id if a global topic is within the array
$to_forum_id = request_var('to_forum_id', 0); $to_forum_id = request_var('to_forum_id', 0);
@ -343,24 +343,24 @@ function change_topic_type($action, $topic_ids)
{ {
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type, forum_id = $to_forum_id SET topic_type = $new_topic_type, forum_id = $to_forum_id
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' WHERE " . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id = 0'; AND forum_id = 0';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Update forum_ids for all posts // Update forum_ids for all posts
$sql = 'UPDATE ' . POSTS_TABLE . " $sql = 'UPDATE ' . POSTS_TABLE . "
SET forum_id = $to_forum_id SET forum_id = $to_forum_id
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' WHERE " . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id = 0'; AND forum_id = 0';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Do a little forum sync stuff // Do a little forum sync stuff
$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
FROM ' . TOPICS_TABLE . ' t FROM ' . TOPICS_TABLE . ' t
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('t.topic_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row_data = $db->sql_fetchrow($result); $row_data = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sync_sql = array(); $sync_sql = array();
@ -381,7 +381,7 @@ function change_topic_type($action, $topic_ids)
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . implode(', ', $array) . ' SET ' . implode(', ', $array) . '
WHERE forum_id = ' . $forum_id_key; WHERE forum_id = ' . $forum_id_key;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
sync('forum', 'forum_id', $to_forum_id); sync('forum', 'forum_id', $to_forum_id);
@ -392,42 +392,42 @@ function change_topic_type($action, $topic_ids)
// Get away with those topics already being a global announcement by re-calculating $topic_ids // Get away with those topics already being a global announcement by re-calculating $topic_ids
$sql = 'SELECT topic_id $sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id <> 0'; AND forum_id <> 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_ids = array(); $topic_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_ids[] = $row['topic_id']; $topic_ids[] = $row['topic_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($topic_ids)) if (sizeof($topic_ids))
{ {
// Delete topic shadows for global announcements // Delete topic shadows for global announcements
$sql = 'DELETE FROM ' . TOPICS_TABLE . ' $sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('topic_moved_id', $topic_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type, forum_id = 0 SET topic_type = $new_topic_type, forum_id = 0
WHERE " . $db->sql_in_set('topic_id', $topic_ids); WHERE " . phpbb::$db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Update forum_ids for all posts // Update forum_ids for all posts
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = 0 SET forum_id = 0
WHERE ' . $db->sql_in_set('topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Do a little forum sync stuff // Do a little forum sync stuff
$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
FROM ' . TOPICS_TABLE . ' t FROM ' . TOPICS_TABLE . ' t
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('t.topic_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row_data = $db->sql_fetchrow($result); $row_data = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sync_sql = array(); $sync_sql = array();
@ -448,7 +448,7 @@ function change_topic_type($action, $topic_ids)
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . implode(', ', $array) . ' SET ' . implode(', ', $array) . '
WHERE forum_id = ' . $forum_id_key; WHERE forum_id = ' . $forum_id_key;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
sync('forum', 'forum_id', $forum_id); sync('forum', 'forum_id', $forum_id);
@ -476,11 +476,11 @@ function change_topic_type($action, $topic_ids)
{ {
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
AND forum_id = 0'; AND forum_id = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -593,14 +593,14 @@ function mcp_move_topic($topic_ids)
} }
} }
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts
FROM ' . TOPICS_TABLE . ' t FROM ' . TOPICS_TABLE . ' t
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); WHERE ' . phpbb::$db->sql_in_set('t.topic_id', $topic_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row_data = $db->sql_fetchrow($result); $row_data = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sync_sql = array(); $sync_sql = array();
@ -633,7 +633,7 @@ function mcp_move_topic($topic_ids)
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_type = ' . POST_ANNOUNCE . ' SET topic_type = ' . POST_ANNOUNCE . '
WHERE topic_id = ' . (int) $row['topic_id']; WHERE topic_id = ' . (int) $row['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Leave a redirection if required and only if the topic is visible to users // Leave a redirection if required and only if the topic is visible to users
@ -674,7 +674,7 @@ function mcp_move_topic($topic_ids)
'poll_last_vote' => (int) $row['poll_last_vote'] 'poll_last_vote' => (int) $row['poll_last_vote']
); );
$db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow)); phpbb::$db->sql_query('INSERT INTO ' . TOPICS_TABLE . phpbb::$db->sql_build_array('INSERT', $shadow));
$topics_authed_moved--; $topics_authed_moved--;
$topics_moved--; $topics_moved--;
@ -696,10 +696,10 @@ function mcp_move_topic($topic_ids)
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . implode(', ', $array) . ' SET ' . implode(', ', $array) . '
WHERE forum_id = ' . $forum_id_key; WHERE forum_id = ' . $forum_id_key;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
sync('forum', 'forum_id', array($forum_id, $to_forum_id)); sync('forum', 'forum_id', array($forum_id, $to_forum_id));
} }
@ -830,16 +830,16 @@ function mcp_delete_post($post_ids)
$sql = 'SELECT DISTINCT topic_id $sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('post_id', $post_ids); WHERE ' . phpbb::$db->sql_in_set('post_id', $post_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_id_list = array(); $topic_id_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_id_list[] = $row['topic_id']; $topic_id_list[] = $row['topic_id'];
} }
$affected_topics = sizeof($topic_id_list); $affected_topics = sizeof($topic_id_list);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$post_data = get_post_data($post_ids); $post_data = get_post_data($post_ids);
@ -853,11 +853,11 @@ function mcp_delete_post($post_ids)
$sql = 'SELECT COUNT(topic_id) AS topics_left $sql = 'SELECT COUNT(topic_id) AS topics_left
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_id_list); WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_id_list);
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics; $deleted_topics = ($row = phpbb::$db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics;
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$topic_id = request_var('t', 0); $topic_id = request_var('t', 0);
@ -1001,8 +1001,8 @@ function mcp_fork_topic($topic_ids)
'poll_length' => (int) $topic_row['poll_length'] 'poll_length' => (int) $topic_row['poll_length']
); );
$db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
$new_topic_id = $db->sql_nextid(); $new_topic_id = phpbb::$db->sql_nextid();
$new_topic_id_list[$topic_id] = $new_topic_id; $new_topic_id_list[$topic_id] = $new_topic_id;
if ($topic_row['poll_start']) if ($topic_row['poll_start'])
@ -1012,9 +1012,9 @@ function mcp_fork_topic($topic_ids)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . POLL_OPTIONS_TABLE . " FROM ' . POLL_OPTIONS_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$sql_ary = array( $sql_ary = array(
'poll_option_id' => (int) $row['poll_option_id'], 'poll_option_id' => (int) $row['poll_option_id'],
@ -1023,7 +1023,7 @@ function mcp_fork_topic($topic_ids)
'poll_option_total' => 0 'poll_option_total' => 0
); );
$db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
} }
} }
@ -1031,14 +1031,14 @@ function mcp_fork_topic($topic_ids)
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
ORDER BY post_time ASC"; ORDER BY post_time ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_rows = array(); $post_rows = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_rows[] = $row; $post_rows[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($post_rows)) if (!sizeof($post_rows))
{ {
@ -1076,8 +1076,8 @@ function mcp_fork_topic($topic_ids)
'post_postcount' => 0, 'post_postcount' => 0,
); );
$db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
$new_post_id = $db->sql_nextid(); $new_post_id = phpbb::$db->sql_nextid();
// Copy whether the topic is dotted // Copy whether the topic is dotted
markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']);
@ -1089,10 +1089,10 @@ function mcp_fork_topic($topic_ids)
WHERE post_msg_id = {$row['post_id']} WHERE post_msg_id = {$row['post_id']}
AND topic_id = $topic_id AND topic_id = $topic_id
AND in_message = 0"; AND in_message = 0";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$sql_ary = array(); $sql_ary = array();
while ($attach_row = $db->sql_fetchrow($result)) while ($attach_row = phpbb::$db->sql_fetchrow($result))
{ {
$sql_ary[] = array( $sql_ary[] = array(
'post_msg_id' => (int) $new_post_id, 'post_msg_id' => (int) $new_post_id,
@ -1111,11 +1111,11 @@ function mcp_fork_topic($topic_ids)
'thumbnail' => (int) $attach_row['thumbnail'] 'thumbnail' => (int) $attach_row['thumbnail']
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$db->sql_multi_insert(ATTACHMENTS_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(ATTACHMENTS_TABLE, $sql_ary);
} }
} }
} }
@ -1123,10 +1123,10 @@ function mcp_fork_topic($topic_ids)
$sql = 'SELECT user_id, notify_status $sql = 'SELECT user_id, notify_status
FROM ' . TOPICS_WATCH_TABLE . ' FROM ' . TOPICS_WATCH_TABLE . '
WHERE topic_id = ' . $topic_id; WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$sql_ary = array(); $sql_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$sql_ary[] = array( $sql_ary[] = array(
'topic_id' => (int) $new_topic_id, 'topic_id' => (int) $new_topic_id,
@ -1134,11 +1134,11 @@ function mcp_fork_topic($topic_ids)
'notify_status' => (int) $row['notify_status'], 'notify_status' => (int) $row['notify_status'],
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
} }
} }
@ -1156,7 +1156,7 @@ function mcp_fork_topic($topic_ids)
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . implode(', ', $array) . ' SET ' . implode(', ', $array) . '
WHERE forum_id = ' . $forum_id_key; WHERE forum_id = ' . $forum_id_key;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
sync('forum', 'forum_id', $to_forum_id); sync('forum', 'forum_id', $to_forum_id);

View file

@ -78,14 +78,14 @@ class mcp_notes
add_form_key('mcp_notes'); add_form_key('mcp_notes');
$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE $sql_where"; WHERE $sql_where";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$userrow = $db->sql_fetchrow($result); $userrow = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$userrow) if (!$userrow)
{ {
@ -119,7 +119,7 @@ class mcp_notes
{ {
$sql_in[] = $mark; $sql_in[] = $mark;
} }
$where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); $where_sql = ' AND ' . phpbb::$db->sql_in_set('log_id', $sql_in);
unset($sql_in); unset($sql_in);
} }
@ -131,7 +131,7 @@ class mcp_notes
WHERE log_type = ' . LOG_USERS . " WHERE log_type = ' . LOG_USERS . "
AND reportee_id = $user_id AND reportee_id = $user_id
$where_sql"; $where_sql";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_USER', $userrow['username']); add_log('admin', 'LOG_CLEAR_USER', $userrow['username']);

View file

@ -68,7 +68,7 @@ function mcp_post_details($id, $mode, $action)
if ($action == 'chgposter') if ($action == 'chgposter')
{ {
$username = request_var('username', '', true); $username = request_var('username', '', true);
$sql_where = "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; $sql_where = "username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
} }
else else
{ {
@ -79,9 +79,9 @@ function mcp_post_details($id, $mode, $action)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $sql_where; WHERE ' . $sql_where;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -145,13 +145,13 @@ function mcp_post_details($id, $mode, $action)
WHERE post_msg_id = ' . $post_id . ' WHERE post_msg_id = ' . $post_id . '
AND in_message = 0 AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC'; ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[] = $row; $attachments[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($attachments)) if (sizeof($attachments))
{ {
@ -252,9 +252,9 @@ function mcp_post_details($id, $mode, $action)
AND r.reason_id = re.reason_id AND r.reason_id = re.reason_id
AND u.user_id = r.user_id AND u.user_id = r.user_id
ORDER BY r.report_time DESC"; ORDER BY r.report_time DESC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_var('S_SHOW_REPORTS', true); $template->assign_var('S_SHOW_REPORTS', true);
@ -278,9 +278,9 @@ function mcp_post_details($id, $mode, $action)
'REPORT_TEXT' => bbcode_nl2br(trim($row['report_text'])), 'REPORT_TEXT' => bbcode_nl2br(trim($row['report_text'])),
)); ));
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Get IP // Get IP
@ -298,12 +298,12 @@ function mcp_post_details($id, $mode, $action)
// Get other users who've posted under this IP // Get other users who've posted under this IP
$sql = 'SELECT poster_id, COUNT(poster_id) as postings $sql = 'SELECT poster_id, COUNT(poster_id) as postings
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "' WHERE poster_ip = '" . phpbb::$db->sql_escape($post_info['poster_ip']) . "'
GROUP BY poster_id GROUP BY poster_id
ORDER BY postings DESC"; ORDER BY postings DESC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Fill the user select list with users who have posted under this IP // Fill the user select list with users who have posted under this IP
if ($row['poster_id'] != $post_info['poster_id']) if ($row['poster_id'] != $post_info['poster_id'])
@ -311,22 +311,22 @@ function mcp_post_details($id, $mode, $action)
$users_ary[$row['poster_id']] = $row; $users_ary[$row['poster_id']] = $row;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($users_ary)) if (sizeof($users_ary))
{ {
// Get the usernames // Get the usernames
$sql = 'SELECT user_id, username $sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_keys($users_ary)); WHERE ' . phpbb::$db->sql_in_set('user_id', array_keys($users_ary));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$users_ary[$row['user_id']]['username'] = $row['username']; $users_ary[$row['user_id']]['username'] = $row['username'];
$usernames_ary[utf8_clean_string($row['username'])] = $users_ary[$row['user_id']]; $usernames_ary[utf8_clean_string($row['username'])] = $users_ary[$row['user_id']];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($users_ary as $user_id => $user_row) foreach ($users_ary as $user_id => $user_row)
{ {
@ -352,9 +352,9 @@ function mcp_post_details($id, $mode, $action)
WHERE poster_id = ' . $post_info['poster_id'] . " WHERE poster_id = ' . $post_info['poster_id'] . "
GROUP BY poster_ip GROUP BY poster_ip
ORDER BY postings DESC"; ORDER BY postings DESC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$hostname = (($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip']) ? @gethostbyaddr($row['poster_ip']) : ''; $hostname = (($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip']) ? @gethostbyaddr($row['poster_ip']) : '';
@ -368,7 +368,7 @@ function mcp_post_details($id, $mode, $action)
'U_WHOIS' => append_sid('mcp', "i=$id&amp;mode=$mode&amp;action=whois&amp;p=$post_id&amp;ip={$row['poster_ip']}")) 'U_WHOIS' => append_sid('mcp', "i=$id&amp;mode=$mode&amp;action=whois&amp;p=$post_id&amp;ip={$row['poster_ip']}"))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$user_select = ''; $user_select = '';
@ -402,7 +402,7 @@ function change_poster(&$post_info, $userdata)
$sql = 'UPDATE ' . POSTS_TABLE . " $sql = 'UPDATE ' . POSTS_TABLE . "
SET poster_id = {$userdata['user_id']} SET poster_id = {$userdata['user_id']}
WHERE post_id = $post_id"; WHERE post_id = $post_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Resync topic/forum if needed // Resync topic/forum if needed
if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id || $post_info['topic_first_post_id'] == $post_id) if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id || $post_info['topic_first_post_id'] == $post_id)
@ -418,12 +418,12 @@ function change_poster(&$post_info, $userdata)
SET user_posts = user_posts - 1 SET user_posts = user_posts - 1
WHERE user_id = ' . $post_info['user_id'] .' WHERE user_id = ' . $post_info['user_id'] .'
AND user_posts > 0'; AND user_posts > 0';
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + 1 SET user_posts = user_posts + 1
WHERE user_id = ' . $userdata['user_id']; WHERE user_id = ' . $userdata['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Add posted to information for this topic for the new user // Add posted to information for this topic for the new user
@ -436,16 +436,16 @@ function change_poster(&$post_info, $userdata)
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . $post_info['topic_id'] . ' WHERE topic_id = ' . $post_info['topic_id'] . '
AND poster_id = ' . $post_info['user_id']; AND poster_id = ' . $post_info['user_id'];
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$topic_id = (int) $db->sql_fetchfield('topic_id'); $topic_id = (int) phpbb::$db->sql_fetchfield('topic_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$topic_id) if (!$topic_id)
{ {
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . ' $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
WHERE user_id = ' . $post_info['user_id'] . ' WHERE user_id = ' . $post_info['user_id'] . '
AND topic_id = ' . $post_info['topic_id']; AND topic_id = ' . $post_info['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -457,7 +457,7 @@ function change_poster(&$post_info, $userdata)
WHERE poster_id = ' . $post_info['user_id'] . ' WHERE poster_id = ' . $post_info['user_id'] . '
AND post_msg_id = ' . $post_info['post_id'] . ' AND post_msg_id = ' . $post_info['post_id'] . '
AND topic_id = ' . $post_info['topic_id']; AND topic_id = ' . $post_info['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// refresh search cache of this post // refresh search cache of this post

View file

@ -146,13 +146,13 @@ class mcp_queue
WHERE post_msg_id = ' . $post_id . ' WHERE post_msg_id = ' . $post_id . '
AND in_message = 0 AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC'; ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[] = $row; $attachments[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($attachments)) if (sizeof($attachments))
{ {
@ -273,9 +273,9 @@ class mcp_queue
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics $sql = 'SELECT SUM(forum_topics) as sum_forum_topics
FROM ' . FORUMS_TABLE . " FROM ' . FORUMS_TABLE . "
WHERE forum_id IN (0, $forum_list)"; WHERE forum_id IN (0, $forum_list)";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $forum_info['forum_topics'] = (int) phpbb::$db->sql_fetchfield('sum_forum_topics');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -319,29 +319,29 @@ class mcp_queue
AND t.topic_first_post_id <> p.post_id AND t.topic_first_post_id <> p.post_id
$limit_time_sql $limit_time_sql
ORDER BY $sort_order_sql"; ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$i = 0; $i = 0;
$post_ids = array(); $post_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_ids[] = $row['post_id']; $post_ids[] = $row['post_id'];
$row_num[$row['post_id']] = $i++; $row_num[$row['post_id']] = $i++;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($post_ids)) 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, u.username_clean, u.user_colour $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, u.username_clean, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' WHERE ' . phpbb::$db->sql_in_set('p.post_id', $post_ids) . '
AND t.topic_id = p.topic_id AND t.topic_id = p.topic_id
AND u.user_id = p.poster_id AND u.user_id = p.poster_id
ORDER BY ' . $sort_order_sql; ORDER BY ' . $sort_order_sql;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_data = $rowset = array(); $post_data = $rowset = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['forum_id']) if ($row['forum_id'])
{ {
@ -349,7 +349,7 @@ class mcp_queue
} }
$post_data[$row['post_id']] = $row; $post_data[$row['post_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
foreach ($post_ids as $post_id) foreach ($post_ids as $post_id)
{ {
@ -370,10 +370,10 @@ class mcp_queue
AND topic_approved = 0 AND topic_approved = 0
$limit_time_sql $limit_time_sql
ORDER BY $sort_order_sql"; ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$rowset = array(); $rowset = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['forum_id']) if ($row['forum_id'])
{ {
@ -381,7 +381,7 @@ class mcp_queue
} }
$rowset[] = $row; $rowset[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (sizeof($forum_names)) if (sizeof($forum_names))
@ -389,15 +389,15 @@ class mcp_queue
// Select the names for the forum_ids // Select the names for the forum_ids
$sql = 'SELECT forum_id, forum_name $sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_names); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_names);
$result = $db->sql_query($sql, 3600); $result = phpbb::$db->sql_query($sql, 3600);
$forum_names = array(); $forum_names = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_names[$row['forum_id']] = $row['forum_name']; $forum_names[$row['forum_id']] = $row['forum_name'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
foreach ($rowset as $row) foreach ($rowset as $row)
@ -584,16 +584,16 @@ function approve_post($post_id_list, $id, $mode)
{ {
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_approved = 1 SET topic_approved = 1
WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_approve_sql);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if (sizeof($post_approve_sql)) if (sizeof($post_approve_sql))
{ {
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET post_approved = 1 SET post_approved = 1
WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); WHERE ' . phpbb::$db->sql_in_set('post_id', $post_approve_sql);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
foreach ($approve_log as $log_data) foreach ($approve_log as $log_data)
@ -608,7 +608,7 @@ function approve_post($post_id_list, $id, $mode)
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_replies = topic_replies + $num_replies SET topic_replies = topic_replies + $num_replies
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -623,7 +623,7 @@ function approve_post($post_id_list, $id, $mode)
$sql .= ($row['forum_posts']) ? "forum_posts = forum_posts + {$row['forum_posts']}" : ''; $sql .= ($row['forum_posts']) ? "forum_posts = forum_posts + {$row['forum_posts']}" : '';
$sql .= " WHERE forum_id = $forum_id"; $sql .= " WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -641,8 +641,8 @@ function approve_post($post_id_list, $id, $mode)
{ {
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + ' . $user_posts . ' SET user_posts = user_posts + ' . $user_posts . '
WHERE ' . $db->sql_in_set('user_id', $user_id_ary); WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -810,9 +810,9 @@ function disapprove_post($post_id_list, $id, $mode)
$sql = 'SELECT reason_title, reason_description $sql = 'SELECT reason_title, reason_description
FROM ' . REPORTS_REASONS_TABLE . " FROM ' . REPORTS_REASONS_TABLE . "
WHERE reason_id = $reason_id"; WHERE reason_id = $reason_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row || (!$reason && strtolower($row['reason_title']) == 'other')) if (!$row || (!$reason && strtolower($row['reason_title']) == 'other'))
{ {
@ -904,7 +904,7 @@ function disapprove_post($post_id_list, $id, $mode)
$sql = 'UPDATE ' . FORUMS_TABLE . " $sql = 'UPDATE ' . FORUMS_TABLE . "
SET forum_topics_real = forum_topics_real - $topics_real SET forum_topics_real = forum_topics_real - $topics_real
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -915,7 +915,7 @@ function disapprove_post($post_id_list, $id, $mode)
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_replies_real = topic_replies_real - $num_replies SET topic_replies_real = topic_replies_real - $num_replies
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }

View file

@ -77,9 +77,9 @@ class mcp_reports
AND rr.reason_id = r.reason_id AND rr.reason_id = r.reason_id
AND r.user_id = u.user_id AND r.user_id = u.user_id
ORDER BY report_closed ASC'; ORDER BY report_closed ASC';
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$report = $db->sql_fetchrow($result); $report = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$report) if (!$report)
{ {
@ -155,13 +155,13 @@ class mcp_reports
WHERE post_msg_id = ' . $post_id . ' WHERE post_msg_id = ' . $post_id . '
AND in_message = 0 AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC'; ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[] = $row; $attachments[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($attachments)) if (sizeof($attachments))
{ {
@ -292,10 +292,10 @@ class mcp_reports
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics $sql = 'SELECT SUM(forum_topics) as sum_forum_topics
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list); WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_list);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $forum_info['forum_topics'] = (int) phpbb::$db->sql_fetchfield('sum_forum_topics');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -341,7 +341,7 @@ class mcp_reports
$sql = 'SELECT r.report_id $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' : '') . ' 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) . " WHERE ' . phpbb::$db->sql_in_set('p.forum_id', $forum_list) . "
$report_state $report_state
AND r.post_id = p.post_id AND r.post_id = p.post_id
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
@ -350,31 +350,31 @@ class mcp_reports
AND t.topic_id = p.topic_id AND t.topic_id = p.topic_id
$limit_time_sql $limit_time_sql
ORDER BY $sort_order_sql"; ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$i = 0; $i = 0;
$report_ids = array(); $report_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$report_ids[] = $row['report_id']; $report_ids[] = $row['report_id'];
$row_num[$row['report_id']] = $i++; $row_num[$row['report_id']] = $i++;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($report_ids)) 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, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id $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, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru 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) . ' WHERE ' . phpbb::$db->sql_in_set('r.report_id', $report_ids) . '
AND t.topic_id = p.topic_id AND t.topic_id = p.topic_id
AND r.post_id = p.post_id AND r.post_id = p.post_id
AND u.user_id = p.poster_id AND u.user_id = p.poster_id
AND ru.user_id = r.user_id AND ru.user_id = r.user_id
ORDER BY ' . $sort_order_sql; ORDER BY ' . $sort_order_sql;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$report_data = $rowset = array(); $report_data = $rowset = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$global_topic = ($row['forum_id']) ? false : true; $global_topic = ($row['forum_id']) ? false : true;
if ($global_topic) if ($global_topic)
@ -406,7 +406,7 @@ class mcp_reports
'TOPIC_TITLE' => $row['topic_title']) 'TOPIC_TITLE' => $row['topic_title'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
unset($report_ids, $row); unset($report_ids, $row);
} }
@ -441,11 +441,11 @@ function close_report($report_id_list, $mode, $action)
{ {
$sql = 'SELECT r.post_id $sql = 'SELECT r.post_id
FROM ' . REPORTS_TABLE . ' r FROM ' . REPORTS_TABLE . ' r
WHERE ' . $db->sql_in_set('r.report_id', $report_id_list); WHERE ' . phpbb::$db->sql_in_set('r.report_id', $report_id_list);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_id_list = array(); $post_id_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_id_list[] = $row['post_id']; $post_id_list[] = $row['post_id'];
} }
@ -486,13 +486,13 @@ function close_report($report_id_list, $mode, $action)
$sql = 'SELECT r.report_id, r.post_id, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type $sql = 'SELECT r.report_id, r.post_id, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type
FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u
WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' WHERE ' . phpbb::$db->sql_in_set('r.report_id', $report_id_list) . '
' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . '
AND r.user_id = u.user_id'; AND r.user_id = u.user_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array(); $reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array();
while ($report = $db->sql_fetchrow($result)) while ($report = phpbb::$db->sql_fetchrow($result))
{ {
$reports[$report['report_id']] = $report; $reports[$report['report_id']] = $report;
$report_id_list[] = $report['report_id']; $report_id_list[] = $report['report_id'];
@ -508,7 +508,7 @@ function close_report($report_id_list, $mode, $action)
$notify_reporters[$report['report_id']] = &$reports[$report['report_id']]; $notify_reporters[$report['report_id']] = &$reports[$report['report_id']];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($reports)) if (sizeof($reports))
{ {
@ -520,56 +520,56 @@ function close_report($report_id_list, $mode, $action)
// Get a list of topics that still contain reported posts // Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id $sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $close_report_topics) . '
AND post_reported = 1 AND post_reported = 1
AND ' . $db->sql_in_set('post_id', $close_report_posts, true); AND ' . phpbb::$db->sql_in_set('post_id', $close_report_posts, true);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$keep_report_topics = array(); $keep_report_topics = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$keep_report_topics[] = $row['topic_id']; $keep_report_topics[] = $row['topic_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$close_report_topics = array_diff($close_report_topics, $keep_report_topics); $close_report_topics = array_diff($close_report_topics, $keep_report_topics);
unset($keep_report_topics); unset($keep_report_topics);
} }
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
if ($action == 'close') if ($action == 'close')
{ {
$sql = 'UPDATE ' . REPORTS_TABLE . ' $sql = 'UPDATE ' . REPORTS_TABLE . '
SET report_closed = 1 SET report_closed = 1
WHERE ' . $db->sql_in_set('report_id', $report_id_list); WHERE ' . phpbb::$db->sql_in_set('report_id', $report_id_list);
} }
else else
{ {
$sql = 'DELETE FROM ' . REPORTS_TABLE . ' $sql = 'DELETE FROM ' . REPORTS_TABLE . '
WHERE ' . $db->sql_in_set('report_id', $report_id_list); WHERE ' . phpbb::$db->sql_in_set('report_id', $report_id_list);
} }
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (sizeof($close_report_posts)) if (sizeof($close_report_posts))
{ {
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0 SET post_reported = 0
WHERE ' . $db->sql_in_set('post_id', $close_report_posts); WHERE ' . phpbb::$db->sql_in_set('post_id', $close_report_posts);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (sizeof($close_report_topics)) if (sizeof($close_report_topics))
{ {
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0 SET topic_reported = 0
WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $close_report_topics) . '
OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); OR ' . phpbb::$db->sql_in_set('topic_moved_id', $close_report_topics);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
} }
unset($close_report_posts, $close_report_topics); unset($close_report_posts, $close_report_topics);

View file

@ -131,17 +131,17 @@ function mcp_topic_view($id, $mode, $action)
AND p.poster_id = u.user_id ' . AND p.poster_id = u.user_id ' .
$limit_time_sql . ' $limit_time_sql . '
ORDER BY ' . $sort_order_sql; ORDER BY ' . $sort_order_sql;
$result = $db->sql_query_limit($sql, $posts_per_page, $start); $result = phpbb::$db->sql_query_limit($sql, $posts_per_page, $start);
$rowset = $post_id_list = array(); $rowset = $post_id_list = array();
$bbcode_bitfield = ''; $bbcode_bitfield = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$rowset[] = $row; $rowset[] = $row;
$post_id_list[] = $row['post_id']; $post_id_list[] = $row['post_id'];
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($bbcode_bitfield !== '') if ($bbcode_bitfield !== '')
{ {
@ -176,16 +176,16 @@ function mcp_topic_view($id, $mode, $action)
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' WHERE ' . phpbb::$db->sql_in_set('post_msg_id', $post_id_list) . '
AND in_message = 0 AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC'; ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[$row['post_msg_id']][] = $row; $attachments[$row['post_msg_id']][] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -435,11 +435,11 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
$limit_time_sql $limit_time_sql
ORDER BY $sort_order_sql"; ORDER BY $sort_order_sql";
} }
$result = $db->sql_query_limit($sql, 0, $start); $result = phpbb::$db->sql_query_limit($sql, 0, $start);
$store = false; $store = false;
$post_id_list = array(); $post_id_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// If split from selected post (split_beyond), we split the unapproved items too. // If split from selected post (split_beyond), we split the unapproved items too.
if (!$row['post_approved'] && !phpbb::$acl->acl_get('m_approve', $row['forum_id'])) if (!$row['post_approved'] && !phpbb::$acl->acl_get('m_approve', $row['forum_id']))
@ -458,7 +458,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
$post_id_list[] = $row['post_id']; $post_id_list[] = $row['post_id'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!sizeof($post_id_list)) if (!sizeof($post_id_list))
@ -475,10 +475,10 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
'topic_approved'=> 1 'topic_approved'=> 1
); );
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$to_topic_id = $db->sql_nextid(); $to_topic_id = phpbb::$db->sql_nextid();
move_posts($post_id_list, $to_topic_id); move_posts($post_id_list, $to_topic_id);
$topic_info = get_topic_data(array($topic_id)); $topic_info = get_topic_data(array($topic_id));
@ -489,9 +489,9 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
// Change topic title of first post // Change topic title of first post
$sql = 'UPDATE ' . POSTS_TABLE . " $sql = 'UPDATE ' . POSTS_TABLE . "
SET post_subject = '" . $db->sql_escape($subject) . "' SET post_subject = '" . phpbb::$db->sql_escape($subject) . "'
WHERE post_id = {$post_id_list[0]}"; WHERE post_id = {$post_id_list[0]}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$success_msg = 'TOPIC_SPLIT_SUCCESS'; $success_msg = 'TOPIC_SPLIT_SUCCESS';
@ -583,9 +583,9 @@ function merge_posts($topic_id, $to_topic_id)
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id; WHERE topic_id = ' . $topic_id;
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -595,11 +595,11 @@ function merge_posts($topic_id, $to_topic_id)
{ {
// If the topic no longer exist, we will update the topic watch table. // If the topic no longer exist, we will update the topic watch table.
// To not let it error out on users watching both topics, we just return on an error... // To not let it error out on users watching both topics, we just return on an error...
$db->sql_return_on_error(true); phpbb::$db->sql_return_on_error(true);
$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id); phpbb::$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id);
$db->sql_return_on_error(false); phpbb::$db->sql_return_on_error(false);
$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . (int) $topic_id); phpbb::$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . (int) $topic_id);
} }
// Link to the new topic // Link to the new topic

View file

@ -105,9 +105,9 @@ class mcp_warn
FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w
WHERE u.user_id = w.user_id WHERE u.user_id = w.user_id
ORDER BY w.warning_time DESC'; ORDER BY w.warning_time DESC';
$result = $db->sql_query_limit($sql, 5); $result = phpbb::$db->sql_query_limit($sql, 5);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('latest', array( $template->assign_block_vars('latest', array(
'U_NOTES' => append_sid('mcp', 'i=notes&amp;mode=user_notes&amp;u=' . $row['user_id']), 'U_NOTES' => append_sid('mcp', 'i=notes&amp;mode=user_notes&amp;u=' . $row['user_id']),
@ -121,7 +121,7 @@ class mcp_warn
'WARNINGS' => $row['user_warnings'], 'WARNINGS' => $row['user_warnings'],
)); ));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**
@ -194,9 +194,9 @@ class mcp_warn
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
WHERE post_id = $post_id WHERE post_id = $post_id
AND u.user_id = p.poster_id"; AND u.user_id = p.poster_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$user_row) if (!$user_row)
{ {
@ -220,9 +220,9 @@ class mcp_warn
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . WARNINGS_TABLE . " FROM ' . WARNINGS_TABLE . "
WHERE post_id = $post_id"; WHERE post_id = $post_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -331,14 +331,14 @@ class mcp_warn
$notify = phpbb_request::is_set('notify_user'); $notify = phpbb_request::is_set('notify_user');
$warning = utf8_normalize_nfc(request_var('warning', '', true)); $warning = utf8_normalize_nfc(request_var('warning', '', true));
$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $sql_where; WHERE ' . $sql_where;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$user_row) if (!$user_row)
{ {
@ -470,21 +470,21 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
'warning_time' => time(), 'warning_time' => time(),
); );
$db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); phpbb::$db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_warnings = user_warnings + 1, SET user_warnings = user_warnings + 1,
user_last_warning = ' . time() . ' user_last_warning = ' . time() . '
WHERE user_id = ' . $user_row['user_id']; WHERE user_id = ' . $user_row['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// We add this to the mod log too for moderators to see that a specific user got warned. // We add this to the mod log too for moderators to see that a specific user got warned.
$sql = 'SELECT forum_id, topic_id $sql = 'SELECT forum_id, topic_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
WHERE post_id = ' . $post_id; WHERE post_id = ' . $post_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_USER_WARNING', $user_row['username']); add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_USER_WARNING', $user_row['username']);
} }

View file

@ -33,9 +33,9 @@ class ucp_activate
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$user_row) if (!$user_row)
{ {
@ -66,9 +66,9 @@ class ucp_activate
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_row['user_id']; WHERE user_id = ' . $user_row['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if (!$update_password) if (!$update_password)
@ -80,7 +80,7 @@ class ucp_activate
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_actkey = '' SET user_actkey = ''
WHERE user_id = {$user_row['user_id']}"; WHERE user_id = {$user_row['user_id']}";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if (phpbb::$config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password) if (phpbb::$config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password)

View file

@ -42,15 +42,15 @@ class ucp_attachments
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE poster_id = ' . phpbb::$user->data['user_id'] . ' WHERE poster_id = ' . phpbb::$user->data['user_id'] . '
AND is_orphan = 0 AND is_orphan = 0
AND ' . $db->sql_in_set('attach_id', $delete_ids); AND ' . phpbb::$db->sql_in_set('attach_id', $delete_ids);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$delete_ids = array(); $delete_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$delete_ids[] = $row['attach_id']; $delete_ids[] = $row['attach_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if ($delete && sizeof($delete_ids)) if ($delete && sizeof($delete_ids))
@ -114,9 +114,9 @@ class ucp_attachments
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE poster_id = ' . phpbb::$user->data['user_id'] . ' WHERE poster_id = ' . phpbb::$user->data['user_id'] . '
AND is_orphan = 0'; AND is_orphan = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$num_attachments = $db->sql_fetchfield('num_attachments'); $num_attachments = phpbb::$db->sql_fetchfield('num_attachments');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
FROM ' . ATTACHMENTS_TABLE . ' a FROM ' . ATTACHMENTS_TABLE . ' a
@ -125,10 +125,10 @@ class ucp_attachments
WHERE a.poster_id = ' . phpbb::$user->data['user_id'] . " WHERE a.poster_id = ' . phpbb::$user->data['user_id'] . "
AND a.is_orphan = 0 AND a.is_orphan = 0
ORDER BY $order_by"; ORDER BY $order_by";
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$row_count = 0; $row_count = 0;
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_var('S_ATTACHMENT_ROWS', true); $template->assign_var('S_ATTACHMENT_ROWS', true);
@ -165,9 +165,9 @@ class ucp_attachments
$row_count++; $row_count++;
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'PAGE_NUMBER' => on_page($num_attachments, phpbb::$config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($num_attachments, phpbb::$config['topics_per_page'], $start),

View file

@ -54,15 +54,15 @@ class ucp_groups
$sql = 'SELECT group_id, group_name, group_type $sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE group_id IN (' . $group_id . ', ' . phpbb::$user->data['group_id'] . ')'; WHERE group_id IN (' . $group_id . ', ' . phpbb::$user->data['group_id'] . ')';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_row = array(); $group_row = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']; $row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name'];
$group_row[$row['group_id']] = $row; $group_row[$row['group_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($group_row)) if (!sizeof($group_row))
{ {
@ -127,9 +127,9 @@ class ucp_groups
$sql = 'SELECT group_type $sql = 'SELECT group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . $group_id; WHERE group_id = ' . $group_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_type = (int) $db->sql_fetchfield('group_type'); $group_type = (int) phpbb::$db->sql_fetchfield('group_type');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($group_type != GROUP_OPEN && $group_type != GROUP_FREE) if ($group_type != GROUP_OPEN && $group_type != GROUP_FREE)
{ {
@ -165,9 +165,9 @@ class ucp_groups
WHERE ug.user_id = u.user_id WHERE ug.user_id = u.user_id
AND ug.group_id = ' . $group_id . ' AND ug.group_id = ' . $group_id . '
AND ug.user_id = ' . phpbb::$user->data['user_id']; AND ug.user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -208,9 +208,9 @@ class ucp_groups
WHERE ug.user_id = u.user_id WHERE ug.user_id = u.user_id
AND ' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'ug.user_id = ' . phpbb::$user->data['user_id'] : 'ug.group_leader = 1') . " AND ' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'ug.user_id = ' . phpbb::$user->data['user_id'] : 'ug.group_leader = 1') . "
AND ug.group_id = $group_id"; AND ug.group_id = $group_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$messenger->template($email_template, $row['user_lang']); $messenger->template($email_template, $row['user_lang']);
@ -228,7 +228,7 @@ class ucp_groups
$messenger->send($row['user_notify_type']); $messenger->send($row['user_notify_type']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$messenger->save_queue(); $messenger->save_queue();
@ -292,11 +292,11 @@ class ucp_groups
WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . ' WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . '
AND g.group_id = ug.group_id AND g.group_id = ug.group_id
ORDER BY g.group_type DESC, g.group_name'; ORDER BY g.group_type DESC, g.group_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_id_ary = array(); $group_id_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$block = ($row['group_leader']) ? 'leader' : (($row['user_pending']) ? 'pending' : 'member'); $block = ($row['group_leader']) ? 'leader' : (($row['user_pending']) ? 'pending' : 'member');
@ -338,19 +338,19 @@ class ucp_groups
$group_id_ary[] = $row['group_id']; $group_id_ary[] = $row['group_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Hide hidden groups unless user is an admin with group privileges // Hide hidden groups unless user is an admin with group privileges
$sql_and = (phpbb::$acl->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? '<> ' . GROUP_SPECIAL : 'NOT IN (' . GROUP_SPECIAL . ', ' . GROUP_HIDDEN . ')'; $sql_and = (phpbb::$acl->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? '<> ' . GROUP_SPECIAL : 'NOT IN (' . GROUP_SPECIAL . ', ' . GROUP_HIDDEN . ')';
$sql = 'SELECT group_id, group_name, group_colour, group_desc, group_desc_uid, group_desc_bitfield, group_desc_options, group_type, group_founder_manage $sql = 'SELECT group_id, group_name, group_colour, group_desc, group_desc_uid, group_desc_bitfield, group_desc_options, group_type, group_founder_manage
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE ' . ((sizeof($group_id_ary)) ? $db->sql_in_set('group_id', $group_id_ary, true) . ' AND ' : '') . " WHERE ' . ((sizeof($group_id_ary)) ? phpbb::$db->sql_in_set('group_id', $group_id_ary, true) . ' AND ' : '') . "
group_type $sql_and group_type $sql_and
ORDER BY group_type DESC, group_name"; ORDER BY group_type DESC, group_name";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
switch ($row['group_type']) switch ($row['group_type'])
{ {
@ -388,7 +388,7 @@ class ucp_groups
'U_VIEW_GROUP' => append_sid('memberlist', 'mode=group&amp;g=' . $row['group_id'])) 'U_VIEW_GROUP' => append_sid('memberlist', 'mode=group&amp;g=' . $row['group_id']))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_CHANGE_DEFAULT' => (phpbb::$acl->acl_get('u_chggrp')) ? true : false, 'S_CHANGE_DEFAULT' => (phpbb::$acl->acl_get('u_chggrp')) ? true : false,
@ -417,9 +417,9 @@ class ucp_groups
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id"; WHERE group_id = $group_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_row = $db->sql_fetchrow($result); $group_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$group_row) if (!$group_row)
{ {
@ -651,15 +651,15 @@ class ucp_groups
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
WHERE rank_special = 1 WHERE rank_special = 1
ORDER BY rank_title'; ORDER BY rank_title';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['USER_DEFAULT'] . '</option>'; $rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['USER_DEFAULT'] . '</option>';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
$rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : ''; $type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : '';
$type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : ''; $type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : '';
@ -745,9 +745,9 @@ class ucp_groups
AND u.user_id = ug.user_id AND u.user_id = ug.user_id
AND ug.group_leader = 1 AND ug.group_leader = 1
ORDER BY ug.user_pending DESC, u.username_clean"; ORDER BY ug.user_pending DESC, u.username_clean";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('leader', array( $template->assign_block_vars('leader', array(
'USERNAME' => $row['username'], 'USERNAME' => $row['username'],
@ -760,16 +760,16 @@ class ucp_groups
'USER_ID' => $row['user_id']) 'USER_ID' => $row['user_id'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Total number of group members (non-leaders) // Total number of group members (non-leaders)
$sql = 'SELECT COUNT(user_id) AS total_members $sql = 'SELECT COUNT(user_id) AS total_members
FROM ' . USER_GROUP_TABLE . " FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id WHERE group_id = $group_id
AND group_leader = 0"; AND group_leader = 0";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$total_members = (int) $db->sql_fetchfield('total_members'); $total_members = (int) phpbb::$db->sql_fetchfield('total_members');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Grab the members // Grab the members
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
@ -778,12 +778,12 @@ class ucp_groups
AND u.user_id = ug.user_id AND u.user_id = ug.user_id
AND ug.group_leader = 0 AND ug.group_leader = 0
ORDER BY ug.user_pending DESC, u.username_clean"; ORDER BY ug.user_pending DESC, u.username_clean";
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$pending = false; $pending = false;
$approved = false; $approved = false;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['user_pending'] && !$pending) if ($row['user_pending'] && !$pending)
{ {
@ -815,7 +815,7 @@ class ucp_groups
'USER_ID' => $row['user_id']) 'USER_ID' => $row['user_id'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$s_action_options = ''; $s_action_options = '';
$options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'deleteusers' => 'DELETE'); $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'deleteusers' => 'DELETE');
@ -896,16 +896,16 @@ class ucp_groups
FROM ' . USER_GROUP_TABLE . " FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id WHERE group_id = $group_id
ORDER BY user_id"; ORDER BY user_id";
$result = $db->sql_query_limit($sql, 200, $start); $result = phpbb::$db->sql_query_limit($sql, 200, $start);
$mark_ary = array(); $mark_ary = array();
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
do do
{ {
$mark_ary[] = $row['user_id']; $mark_ary[] = $row['user_id'];
} }
while ($row = $db->sql_fetchrow($result)); while ($row = phpbb::$db->sql_fetchrow($result));
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
@ -915,7 +915,7 @@ class ucp_groups
{ {
$start = 0; $start = 0;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
while ($start); while ($start);
} }
@ -1057,9 +1057,9 @@ class ucp_groups
AND g.group_id = ug.group_id AND g.group_id = ug.group_id
AND ug.group_leader = 1 AND ug.group_leader = 1
ORDER BY g.group_type DESC, g.group_name'; ORDER BY g.group_type DESC, g.group_name';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($value = $db->sql_fetchrow($result)) while ($value = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('leader', array( $template->assign_block_vars('leader', array(
'GROUP_NAME' => ($value['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $value['group_name']] : $value['group_name'], 'GROUP_NAME' => ($value['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $value['group_name']] : $value['group_name'],
@ -1072,7 +1072,7 @@ class ucp_groups
'U_EDIT' => $this->u_action . "&amp;action=edit&amp;g={$value['group_id']}") 'U_EDIT' => $this->u_action . "&amp;action=edit&amp;g={$value['group_id']}")
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
break; break;
} }

View file

@ -71,11 +71,11 @@ class ucp_main
if (sizeof($forum_ary)) if (sizeof($forum_ary))
{ {
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); $sql .= ' AND ' . phpbb::$db->sql_in_set('forum_id', $forum_ary, true);
} }
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$g_forum_id = (int) $db->sql_fetchfield('forum_id'); $g_forum_id = (int) phpbb::$db->sql_fetchfield('forum_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = "SELECT t.* $sql_select $sql = "SELECT t.* $sql_select
FROM $sql_from FROM $sql_from
@ -87,14 +87,14 @@ class ucp_main
// If the user can't see any forums, he can't read any posts because fid of 0 is invalid // If the user can't see any forums, he can't read any posts because fid of 0 is invalid
if ($g_forum_id) if ($g_forum_id)
{ {
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_list[] = $row['topic_id']; $topic_list[] = $row['topic_id'];
$rowset[$row['topic_id']] = $row; $rowset[$row['topic_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$topic_tracking_info = array(); $topic_tracking_info = array();
@ -218,9 +218,9 @@ class ucp_main
if (sizeof($forums)) if (sizeof($forums))
{ {
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . ' $sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forums) . ' WHERE ' . phpbb::$db->sql_in_set('forum_id', $forums) . '
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$l_unwatch .= '_FORUMS'; $l_unwatch .= '_FORUMS';
} }
@ -228,9 +228,9 @@ class ucp_main
if (sizeof($topics)) if (sizeof($topics))
{ {
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topics) . ' WHERE ' . phpbb::$db->sql_in_set('topic_id', $topics) . '
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$l_unwatch .= '_TOPICS'; $l_unwatch .= '_TOPICS';
} }
@ -267,7 +267,7 @@ class ucp_main
'WHERE' => 'fw.user_id = ' . phpbb::$user->data['user_id'] . ' 'WHERE' => 'fw.user_id = ' . phpbb::$user->data['user_id'] . '
AND f.forum_id = fw.forum_id AND f.forum_id = fw.forum_id
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true), AND ' . phpbb::$db->sql_in_set('f.forum_id', $forbidden_forums, true, true),
'ORDER_BY' => 'left_id' 'ORDER_BY' => 'left_id'
); );
@ -289,10 +289,10 @@ class ucp_main
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
} }
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = phpbb::$db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_id = $row['forum_id']; $forum_id = $row['forum_id'];
@ -350,7 +350,7 @@ class ucp_main
'U_VIEWFORUM' => append_sid('viewforum', 'f=' . $row['forum_id'])) 'U_VIEWFORUM' => append_sid('viewforum', 'f=' . $row['forum_id']))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Subscribed Topics // Subscribed Topics
@ -405,8 +405,8 @@ class ucp_main
{ {
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . ' $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . ' WHERE user_id = ' . phpbb::$user->data['user_id'] . '
AND ' . $db->sql_in_set('topic_id', $topics); AND ' . phpbb::$db->sql_in_set('topic_id', $topics);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
meta_refresh(3, $url); meta_refresh(3, $url);
$message = phpbb::$user->lang['BOOKMARKS_REMOVED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>'); $message = phpbb::$user->lang['BOOKMARKS_REMOVED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
@ -449,9 +449,9 @@ class ucp_main
if (sizeof($drafts)) if (sizeof($drafts))
{ {
$sql = 'DELETE FROM ' . DRAFTS_TABLE . ' $sql = 'DELETE FROM ' . DRAFTS_TABLE . '
WHERE ' . $db->sql_in_set('draft_id', $drafts) . ' WHERE ' . phpbb::$db->sql_in_set('draft_id', $drafts) . '
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$msg = phpbb::$user->lang['DRAFTS_DELETED']; $msg = phpbb::$user->lang['DRAFTS_DELETED'];
unset($drafts); unset($drafts);
@ -479,10 +479,10 @@ class ucp_main
); );
$sql = 'UPDATE ' . DRAFTS_TABLE . ' $sql = 'UPDATE ' . DRAFTS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $draft_row) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $draft_row) . "
WHERE draft_id = $draft_id WHERE draft_id = $draft_id
AND user_id = " . phpbb::$user->data['user_id']; AND user_id = " . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$message = phpbb::$user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); $message = phpbb::$user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
@ -518,11 +518,11 @@ class ucp_main
AND topic_id = 0 AND topic_id = 0
ORDER BY save_time DESC'; ORDER BY save_time DESC';
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$draftrows = $topic_ids = array(); $draftrows = $topic_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['topic_id']) if ($row['topic_id'])
{ {
@ -530,20 +530,20 @@ class ucp_main
} }
$draftrows[] = $row; $draftrows[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($topic_ids)) if (sizeof($topic_ids))
{ {
$sql = 'SELECT topic_id, forum_id, topic_title $sql = 'SELECT topic_id, forum_id, topic_title
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids)); WHERE ' . phpbb::$db->sql_in_set('topic_id', array_unique($topic_ids));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_rows[$row['topic_id']] = $row; $topic_rows[$row['topic_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
unset($topic_ids); unset($topic_ids);
@ -644,12 +644,12 @@ class ucp_main
'WHERE' => 'i.topic_id = t.topic_id 'WHERE' => 'i.topic_id = t.topic_id
AND i.user_id = ' . phpbb::$user->data['user_id'] . ' AND i.user_id = ' . phpbb::$user->data['user_id'] . '
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), AND ' . phpbb::$db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
); );
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = phpbb::$db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topics_count = (int) $db->sql_fetchfield('topics_count'); $topics_count = (int) phpbb::$db->sql_fetchfield('topics_count');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($topics_count) if ($topics_count)
{ {
@ -672,7 +672,7 @@ class ucp_main
'WHERE' => 'tw.user_id = ' . phpbb::$user->data['user_id'] . ' 'WHERE' => 'tw.user_id = ' . phpbb::$user->data['user_id'] . '
AND t.topic_id = tw.topic_id AND t.topic_id = tw.topic_id
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), AND ' . phpbb::$db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
'ORDER_BY' => 't.topic_last_post_time DESC' 'ORDER_BY' => 't.topic_last_post_time DESC'
@ -690,7 +690,7 @@ class ucp_main
), ),
'WHERE' => 'b.user_id = ' . phpbb::$user->data['user_id'] . ' 'WHERE' => 'b.user_id = ' . phpbb::$user->data['user_id'] . '
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true), AND ' . phpbb::$db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true),
'ORDER_BY' => 't.topic_last_post_time DESC' 'ORDER_BY' => 't.topic_last_post_time DESC'
); );
@ -714,11 +714,11 @@ class ucp_main
$sql_array['SELECT'] .= ', tp.topic_posted'; $sql_array['SELECT'] .= ', tp.topic_posted';
} }
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = phpbb::$db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start); $result = phpbb::$db->sql_query_limit($sql, phpbb::$config['topics_per_page'], $start);
$topic_list = $topic_forum_list = $global_announce_list = $rowset = array(); $topic_list = $topic_forum_list = $global_announce_list = $rowset = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id']; $topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
@ -733,7 +733,7 @@ class ucp_main
$global_announce_list[] = $topic_id; $global_announce_list[] = $topic_id;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$topic_tracking_info = array(); $topic_tracking_info = array();
if (phpbb::$config['load_db_lastread']) if (phpbb::$config['load_db_lastread'])

View file

@ -252,9 +252,9 @@ class ucp_pm
WHERE msg_id = $msg_id WHERE msg_id = $msg_id
AND folder_id <> " . PRIVMSGS_NO_BOX . ' AND folder_id <> " . PRIVMSGS_NO_BOX . '
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -280,9 +280,9 @@ class ucp_pm
AND t.msg_id = p.msg_id AND t.msg_id = p.msg_id
AND p.message_time $sql_condition p2.message_time AND p.message_time $sql_condition p2.message_time
ORDER BY p.message_time $sql_ordering"; ORDER BY p.message_time $sql_ordering";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -302,9 +302,9 @@ class ucp_pm
AND t.folder_id = $folder_id AND t.folder_id = $folder_id
AND t.msg_id = p.msg_id AND t.msg_id = p.msg_id
AND p.msg_id = $msg_id"; AND p.msg_id = $msg_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$message_row = $db->sql_fetchrow($result); $message_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$message_row) if (!$message_row)
{ {

View file

@ -99,14 +99,14 @@ function compose_pm($id, $mode, $action)
$sql .= 'g.group_receive_pm = 1 $sql .= 'g.group_receive_pm = 1
ORDER BY g.group_type DESC, g.group_name ASC'; ORDER BY g.group_type DESC, g.group_name ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$group_options = ''; $group_options = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; $group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$template->assign_vars(array( $template->assign_vars(array(
@ -216,9 +216,9 @@ function compose_pm($id, $mode, $action)
if ($sql) if ($sql)
{ {
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post = $db->sql_fetchrow($result); $post = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$post) if (!$post)
{ {
@ -230,9 +230,9 @@ function compose_pm($id, $mode, $action)
WHERE t.user_id = ' . phpbb::$user->data['user_id'] . " WHERE t.user_id = ' . phpbb::$user->data['user_id'] . "
AND t.msg_id = $msg_id AND t.msg_id = $msg_id
AND t.msg_id = p.msg_id"; AND t.msg_id = p.msg_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post = $db->sql_fetchrow($result); $post = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($post) if ($post)
{ {
@ -256,9 +256,9 @@ function compose_pm($id, $mode, $action)
$sql = 'SELECT forum_password $sql = 'SELECT forum_password
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $post['forum_id']; WHERE forum_id = ' . (int) $post['forum_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_password = (string) $db->sql_fetchfield('forum_password'); $forum_password = (string) phpbb::$db->sql_fetchfield('forum_password');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($forum_password) if ($forum_password)
{ {
@ -422,9 +422,9 @@ function compose_pm($id, $mode, $action)
WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . ' WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . '
AND ug.user_pending = 0 AND ug.user_pending = 0
AND ug.group_id = g.group_id'; AND ug.group_id = g.group_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$max_recipients = (int) $db->sql_fetchfield('max_recipients'); $max_recipients = (int) phpbb::$db->sql_fetchfield('max_recipients');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$max_recipients = (!$max_recipients) ? phpbb::$config['pm_max_recipients'] : $max_recipients; $max_recipients = (!$max_recipients) ? phpbb::$config['pm_max_recipients'] : $max_recipients;
@ -485,9 +485,9 @@ function compose_pm($id, $mode, $action)
AND in_message = 1 AND in_message = 1
AND is_orphan = 0 AND is_orphan = 0
ORDER BY filetime DESC"; ORDER BY filetime DESC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); $message_parser->attachment_data = array_merge($message_parser->attachment_data, phpbb::$db->sql_fetchrowset($result));
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!in_array($action, array('quote', 'edit', 'delete', 'forward'))) if (!in_array($action, array('quote', 'edit', 'delete', 'forward')))
@ -509,9 +509,9 @@ function compose_pm($id, $mode, $action)
AND topic_id = 0 AND topic_id = 0
AND user_id = ' . phpbb::$user->data['user_id'] . AND user_id = ' . phpbb::$user->data['user_id'] .
(($draft_id) ? " AND draft_id <> $draft_id" : ''); (($draft_id) ? " AND draft_id <> $draft_id" : '');
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -541,7 +541,7 @@ function compose_pm($id, $mode, $action)
{ {
if (confirm_box(true)) if (confirm_box(true))
{ {
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'user_id' => phpbb::$user->data['user_id'], 'user_id' => phpbb::$user->data['user_id'],
'topic_id' => 0, 'topic_id' => 0,
'forum_id' => 0, 'forum_id' => 0,
@ -550,7 +550,7 @@ function compose_pm($id, $mode, $action)
'draft_message' => $message 'draft_message' => $message
) )
); );
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$redirect_url = append_sid('ucp', "i=pm&amp;mode=$mode"); $redirect_url = append_sid('ucp', "i=pm&amp;mode=$mode");
@ -602,9 +602,9 @@ function compose_pm($id, $mode, $action)
AND topic_id = 0 AND topic_id = 0
AND forum_id = 0 AND forum_id = 0
AND user_id = " . phpbb::$user->data['user_id']; AND user_id = " . phpbb::$user->data['user_id'];
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$message_parser->message = $row['draft_message']; $message_parser->message = $row['draft_message'];
$message_subject = $row['draft_subject']; $message_subject = $row['draft_subject'];
@ -615,7 +615,7 @@ function compose_pm($id, $mode, $action)
{ {
$draft_id = 0; $draft_id = 0;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Load Drafts // Load Drafts
@ -877,9 +877,9 @@ function compose_pm($id, $mode, $action)
{ {
$sql = 'SELECT user_id as id, username as name, user_colour as colour $sql = 'SELECT user_id as id, username as name, user_colour as colour
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($address_list['u']))) . ' WHERE ' . phpbb::$db->sql_in_set('user_id', array_map('intval', array_keys($address_list['u']))) . '
ORDER BY username_clean ASC'; ORDER BY username_clean ASC';
$result['u'] = $db->sql_query($sql); $result['u'] = phpbb::$db->sql_query($sql);
} }
if (!empty($address_list['g'])) if (!empty($address_list['g']))
@ -901,10 +901,10 @@ function compose_pm($id, $mode, $action)
$sql .= (phpbb::$acl->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' WHERE ' : ' AND '; $sql .= (phpbb::$acl->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' WHERE ' : ' AND ';
$sql .= 'g.group_receive_pm = 1 $sql .= 'g.group_receive_pm = 1
AND ' . $db->sql_in_set('g.group_id', array_map('intval', array_keys($address_list['g']))) . ' AND ' . phpbb::$db->sql_in_set('g.group_id', array_map('intval', array_keys($address_list['g']))) . '
ORDER BY g.group_name ASC'; ORDER BY g.group_name ASC';
$result['g'] = $db->sql_query($sql); $result['g'] = phpbb::$db->sql_query($sql);
} }
$u = $g = array(); $u = $g = array();
@ -913,7 +913,7 @@ function compose_pm($id, $mode, $action)
{ {
if (isset($result[$type]) && $result[$type]) if (isset($result[$type]) && $result[$type])
{ {
while ($row = $db->sql_fetchrow($result[$type])) while ($row = phpbb::$db->sql_fetchrow($result[$type]))
{ {
if ($type == 'g') if ($type == 'g')
{ {
@ -922,7 +922,7 @@ function compose_pm($id, $mode, $action)
${$type}[$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); ${$type}[$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']);
} }
$db->sql_freeresult($result[$type]); phpbb::$db->sql_freeresult($result[$type]);
} }
} }
@ -1176,17 +1176,17 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
{ {
$sql = 'SELECT user_id $sql = 'SELECT user_id
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . ' WHERE ' . phpbb::$db->sql_in_set('user_id', array_keys($address_list['u'])) . '
AND user_allow_pm = 0'; AND user_allow_pm = 0';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$removed = false; $removed = false;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$removed = true; $removed = true;
unset($address_list['u'][$row['user_id']]); unset($address_list['u'][$row['user_id']]);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// print a notice about users not being added who do not want to receive pms // print a notice about users not being added who do not want to receive pms
if ($removed) if ($removed)

View file

@ -55,7 +55,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_full_folder = ' . $set_folder_id . ' SET user_full_folder = ' . $set_folder_id . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$user->data['user_full_folder'] = $set_folder_id; phpbb::$user->data['user_full_folder'] = $set_folder_id;
@ -77,11 +77,11 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
{ {
$sql = 'SELECT folder_name $sql = 'SELECT folder_name
FROM ' . PRIVMSGS_FOLDER_TABLE . " FROM ' . PRIVMSGS_FOLDER_TABLE . "
WHERE folder_name = '" . $db->sql_escape($folder_name) . "' WHERE folder_name = '" . phpbb::$db->sql_escape($folder_name) . "'
AND user_id = " . phpbb::$user->data['user_id']; AND user_id = " . phpbb::$user->data['user_id'];
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -91,20 +91,20 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'SELECT COUNT(folder_id) as num_folder $sql = 'SELECT COUNT(folder_id) as num_folder
FROM ' . PRIVMSGS_FOLDER_TABLE . ' FROM ' . PRIVMSGS_FOLDER_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$num_folder = (int) $db->sql_fetchfield('num_folder'); $num_folder = (int) phpbb::$db->sql_fetchfield('num_folder');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($num_folder >= phpbb::$config['pm_max_boxes']) if ($num_folder >= phpbb::$config['pm_max_boxes'])
{ {
trigger_error('MAX_FOLDER_REACHED'); trigger_error('MAX_FOLDER_REACHED');
} }
$sql = 'INSERT INTO ' . PRIVMSGS_FOLDER_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . PRIVMSGS_FOLDER_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'user_id' => (int) phpbb::$user->data['user_id'], 'user_id' => (int) phpbb::$user->data['user_id'],
'folder_name' => $folder_name) 'folder_name' => $folder_name)
); );
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$msg = phpbb::$user->lang['FOLDER_ADDED']; $msg = phpbb::$user->lang['FOLDER_ADDED'];
} }
} }
@ -135,9 +135,9 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
FROM ' . PRIVMSGS_FOLDER_TABLE . ' FROM ' . PRIVMSGS_FOLDER_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . " WHERE user_id = ' . phpbb::$user->data['user_id'] . "
AND folder_id = $rename_folder_id"; AND folder_id = $rename_folder_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$folder_row = $db->sql_fetchrow($result); $folder_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$folder_row) if (!$folder_row)
{ {
@ -145,10 +145,10 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
} }
$sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . " $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . "
SET folder_name = '" . $db->sql_escape($new_folder_name) . "' SET folder_name = '" . phpbb::$db->sql_escape($new_folder_name) . "'
WHERE folder_id = $rename_folder_id WHERE folder_id = $rename_folder_id
AND user_id = " . phpbb::$user->data['user_id']; AND user_id = " . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$msg = phpbb::$user->lang['FOLDER_RENAMED']; $msg = phpbb::$user->lang['FOLDER_RENAMED'];
} }
else else
@ -182,9 +182,9 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
FROM ' . PRIVMSGS_FOLDER_TABLE . ' FROM ' . PRIVMSGS_FOLDER_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . " WHERE user_id = ' . phpbb::$user->data['user_id'] . "
AND folder_id = $remove_folder_id"; AND folder_id = $remove_folder_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$folder_row = $db->sql_fetchrow($result); $folder_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$folder_row) if (!$folder_row)
{ {
@ -206,14 +206,14 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
FROM ' . PRIVMSGS_TO_TABLE . ' FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . " WHERE user_id = ' . phpbb::$user->data['user_id'] . "
AND folder_id = $remove_folder_id"; AND folder_id = $remove_folder_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$msg_ids = array(); $msg_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$msg_ids[] = (int) $row['msg_id']; $msg_ids[] = (int) $row['msg_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// First of all, copy all messages to another folder... or delete all messages // First of all, copy all messages to another folder... or delete all messages
switch ($remove_action) switch ($remove_action)
@ -239,7 +239,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'DELETE FROM ' . PRIVMSGS_FOLDER_TABLE . ' $sql = 'DELETE FROM ' . PRIVMSGS_FOLDER_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . " WHERE user_id = ' . phpbb::$user->data['user_id'] . "
AND folder_id = $remove_folder_id"; AND folder_id = $remove_folder_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Check full folder option. If the removed folder has been specified as destination switch back to inbox // Check full folder option. If the removed folder has been specified as destination switch back to inbox
if (phpbb::$user->data['user_full_folder'] == $remove_folder_id) if (phpbb::$user->data['user_full_folder'] == $remove_folder_id)
@ -247,7 +247,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_full_folder = ' . PRIVMSGS_INBOX . ' SET user_full_folder = ' . PRIVMSGS_INBOX . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
phpbb::$user->data['user_full_folder'] = PRIVMSGS_INBOX; phpbb::$user->data['user_full_folder'] = PRIVMSGS_INBOX;
} }
@ -258,7 +258,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql .= ($remove_action == 1) ? $move_to : PRIVMSGS_INBOX; $sql .= ($remove_action == 1) ? $move_to : PRIVMSGS_INBOX;
$sql .= ' WHERE rule_folder_id = ' . $remove_folder_id; $sql .= ' WHERE rule_folder_id = ' . $remove_folder_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$meta_info = append_sid('ucp', "i=pm&amp;mode=$mode"); $meta_info = append_sid('ucp', "i=pm&amp;mode=$mode");
$message = phpbb::$user->lang['FOLDER_REMOVED']; $message = phpbb::$user->lang['FOLDER_REMOVED'];
@ -312,24 +312,24 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'SELECT rule_id $sql = 'SELECT rule_id
FROM ' . PRIVMSGS_RULES_TABLE . ' FROM ' . PRIVMSGS_RULES_TABLE . '
WHERE ' . $db->sql_build_array('SELECT', $rule_ary); WHERE ' . phpbb::$db->sql_build_array('SELECT', $rule_ary);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
trigger_error('RULE_ALREADY_DEFINED'); trigger_error('RULE_ALREADY_DEFINED');
} }
$sql = 'INSERT INTO ' . PRIVMSGS_RULES_TABLE . ' ' . $db->sql_build_array('INSERT', $rule_ary); $sql = 'INSERT INTO ' . PRIVMSGS_RULES_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $rule_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Update users message rules // Update users message rules
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_message_rules = 1 SET user_message_rules = 1
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$msg = phpbb::$user->lang['RULE_ADDED']; $msg = phpbb::$user->lang['RULE_ADDED'];
} }
@ -359,7 +359,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'DELETE FROM ' . PRIVMSGS_RULES_TABLE . ' $sql = 'DELETE FROM ' . PRIVMSGS_RULES_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . " WHERE user_id = ' . phpbb::$user->data['user_id'] . "
AND rule_id = $delete_id"; AND rule_id = $delete_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$meta_info = append_sid('ucp', 'i=pm&amp;mode=' . $mode); $meta_info = append_sid('ucp', 'i=pm&amp;mode=' . $mode);
$message = phpbb::$user->lang['RULE_DELETED']; $message = phpbb::$user->lang['RULE_DELETED'];
@ -368,9 +368,9 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'SELECT rule_id $sql = 'SELECT rule_id
FROM ' . PRIVMSGS_RULES_TABLE . ' FROM ' . PRIVMSGS_RULES_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Update users message rules // Update users message rules
if (!$row) if (!$row)
@ -378,7 +378,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_message_rules = 0 SET user_message_rules = 0
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
meta_refresh(3, $meta_info); meta_refresh(3, $meta_info);
@ -397,9 +397,9 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
FROM ' . PRIVMSGS_TO_TABLE . ' FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . ' WHERE user_id = ' . phpbb::$user->data['user_id'] . '
AND folder_id = ' . PRIVMSGS_INBOX; AND folder_id = ' . PRIVMSGS_INBOX;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$num_messages = (int) $db->sql_fetchfield('num_messages'); $num_messages = (int) phpbb::$db->sql_fetchfield('num_messages');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$folder[PRIVMSGS_INBOX] = array( $folder[PRIVMSGS_INBOX] = array(
'folder_name' => phpbb::$user->lang['PM_INBOX'], 'folder_name' => phpbb::$user->lang['PM_INBOX'],
@ -409,10 +409,10 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$sql = 'SELECT folder_id, folder_name, pm_count $sql = 'SELECT folder_id, folder_name, pm_count
FROM ' . PRIVMSGS_FOLDER_TABLE . ' FROM ' . PRIVMSGS_FOLDER_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$num_user_folder = 0; $num_user_folder = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$num_user_folder++; $num_user_folder++;
$folder[$row['folder_id']] = array( $folder[$row['folder_id']] = array(
@ -420,7 +420,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
'message_status' => sprintf(phpbb::$user->lang['FOLDER_MESSAGE_STATUS'], $row['pm_count'], phpbb::$user->data['message_limit']) 'message_status' => sprintf(phpbb::$user->lang['FOLDER_MESSAGE_STATUS'], $row['pm_count'], phpbb::$user->data['message_limit'])
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$s_full_folder_options = $s_to_folder_options = $s_folder_options = ''; $s_full_folder_options = $s_to_folder_options = $s_folder_options = '';
@ -691,10 +691,10 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule
{ {
$sql = 'SELECT user_id $sql = 'SELECT user_id
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($rule_string)) . "'"; WHERE username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($rule_string)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$rule_user_id = (int) $db->sql_fetchfield('user_id'); $rule_user_id = (int) phpbb::$db->sql_fetchfield('user_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$rule_user_id) if (!$rule_user_id)
{ {
@ -706,9 +706,9 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule
$sql = 'SELECT username $sql = 'SELECT username
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE user_id = $rule_user_id"; WHERE user_id = $rule_user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$rule_string = $db->sql_fetchfield('username'); $rule_string = phpbb::$db->sql_fetchfield('username');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$rule_string) if (!$rule_string)
{ {
@ -752,10 +752,10 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule
$sql .= " (g.group_name NOT IN ('GUESTS', 'BOTS') OR g.group_type <> " . GROUP_SPECIAL . ') $sql .= " (g.group_name NOT IN ('GUESTS', 'BOTS') OR g.group_type <> " . GROUP_SPECIAL . ')
ORDER BY g.group_type DESC, g.group_name ASC'; ORDER BY g.group_type DESC, g.group_name ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_group_options = ''; $s_group_options = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($rule_group_id && ($row['group_id'] == $rule_group_id)) if ($rule_group_id && ($row['group_id'] == $rule_group_id))
{ {
@ -767,7 +767,7 @@ function define_cond_option($hardcoded, $cond_option, $rule_option, $global_rule
$s_group_options .= '<option value="' . $row['group_id'] . '"' . $s_class . $s_selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; $s_group_options .= '<option value="' . $row['group_id'] . '"' . $s_class . $s_selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_GROUP_CONDITION' => true, 'S_GROUP_CONDITION' => true,
@ -799,10 +799,10 @@ function show_defined_rules($user_id, $check_lang, $rule_lang, $action_lang, $fo
FROM ' . PRIVMSGS_RULES_TABLE . ' FROM ' . PRIVMSGS_RULES_TABLE . '
WHERE user_id = ' . $user_id . ' WHERE user_id = ' . $user_id . '
ORDER BY rule_id ASC'; ORDER BY rule_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$count = 0; $count = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_block_vars('rule', array( $template->assign_block_vars('rule', array(
'COUNT' => ++$count, 'COUNT' => ++$count,
@ -814,7 +814,7 @@ function show_defined_rules($user_id, $check_lang, $rule_lang, $action_lang, $fo
'FOLDER' => ($row['rule_action'] == ACTION_PLACE_INTO_FOLDER) ? $folder[$row['rule_folder_id']]['folder_name'] : '') 'FOLDER' => ($row['rule_action'] == ACTION_PLACE_INTO_FOLDER) ? $folder[$row['rule_folder_id']]['folder_name'] : '')
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
?> ?>

View file

@ -90,14 +90,14 @@ function view_folder($id, $mode, $folder_id, $folder)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ZEBRA_TABLE . ' FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$friend[$row['zebra_id']] = $row['friend']; $friend[$row['zebra_id']] = $row['friend'];
$foe[$row['zebra_id']] = $row['foe']; $foe[$row['zebra_id']] = $row['foe'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'S_MARK_OPTIONS' => $s_mark_options, 'S_MARK_OPTIONS' => $s_mark_options,
@ -147,11 +147,11 @@ function view_folder($id, $mode, $folder_id, $folder)
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE '; WHERE ';
} }
$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); $sql .= phpbb::$db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type])));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($ug_type == 'g') if ($ug_type == 'g')
{ {
@ -160,7 +160,7 @@ function view_folder($id, $mode, $folder_id, $folder)
$recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -286,9 +286,9 @@ function view_folder($id, $mode, $folder_id, $folder)
AND t.folder_id = $folder_id AND t.folder_id = $folder_id
AND t.msg_id = p.msg_id AND t.msg_id = p.msg_id
AND p.msg_id = $message_id"; AND p.msg_id = $message_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$message_row = $db->sql_fetchrow($result); $message_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$_types = array('u', 'g'); $_types = array('u', 'g');
foreach ($_types as $ug_type) foreach ($_types as $ug_type)
@ -307,16 +307,16 @@ function view_folder($id, $mode, $folder_id, $folder)
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE '; WHERE ';
} }
$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address[$message_id][$ug_type]))); $sql .= phpbb::$db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address[$message_id][$ug_type])));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($info_row = $db->sql_fetchrow($result)) while ($info_row = phpbb::$db->sql_fetchrow($result))
{ {
$address[$message_id][$ug_type][$address[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; $address[$message_id][$ug_type][$address[$message_id][$ug_type][$info_row['id']]][] = $info_row['name'];
unset($address[$message_id][$ug_type][$info_row['id']]); unset($address[$message_id][$ug_type][$info_row['id']]);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -480,9 +480,9 @@ function get_pm_from($folder_id, $folder, $user_id)
AND t.user_id = $user_id AND t.user_id = $user_id
AND t.msg_id = p.msg_id AND t.msg_id = p.msg_id
AND p.message_time >= $min_post_time"; AND p.message_time >= $min_post_time";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$pm_count = (int) $db->sql_fetchfield('pm_count'); $pm_count = (int) phpbb::$db->sql_fetchfield('pm_count');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql_limit_time = "AND p.message_time >= $min_post_time"; $sql_limit_time = "AND p.message_time >= $min_post_time";
} }
@ -544,14 +544,14 @@ function get_pm_from($folder_id, $folder, $user_id)
AND t.msg_id = p.msg_id AND t.msg_id = p.msg_id
$sql_limit_time $sql_limit_time
ORDER BY $sql_sort_order"; ORDER BY $sql_sort_order";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $result = phpbb::$db->sql_query_limit($sql, $sql_limit, $sql_start);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$rowset[$row['msg_id']] = $row; $rowset[$row['msg_id']] = $row;
$pm_list[] = $row['msg_id']; $pm_list[] = $row['msg_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list; $pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list;

View file

@ -102,13 +102,13 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
WHERE post_msg_id = $msg_id WHERE post_msg_id = $msg_id
AND in_message = 1 AND in_message = 1
ORDER BY filetime DESC, post_msg_id ASC"; ORDER BY filetime DESC, post_msg_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[] = $row; $attachments[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// No attachments exist, but message table thinks they do so go ahead and reset attach flags // No attachments exist, but message table thinks they do so go ahead and reset attach flags
if (!sizeof($attachments)) if (!sizeof($attachments))
@ -116,7 +116,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
$sql = 'UPDATE ' . PRIVMSGS_TABLE . " $sql = 'UPDATE ' . PRIVMSGS_TABLE . "
SET message_attachment = 0 SET message_attachment = 0
WHERE msg_id = $msg_id"; WHERE msg_id = $msg_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
else else
@ -136,8 +136,8 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
{ {
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
SET download_count = download_count + 1 SET download_count = download_count + 1
WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); WHERE ' . phpbb::$db->sql_in_set('attach_id', array_unique($update_count));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -261,9 +261,9 @@ function get_user_information($user_id, $user_row)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $user_id; WHERE user_id = ' . (int) $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Some standard values // Some standard values
@ -277,9 +277,9 @@ function get_user_information($user_id, $user_row)
FROM ' . SESSIONS_TABLE . " FROM ' . SESSIONS_TABLE . "
WHERE session_user_id = $user_id WHERE session_user_id = $user_id
GROUP BY session_user_id"; GROUP BY session_user_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$update_time = phpbb::$config['load_online_time'] * 60; $update_time = phpbb::$config['load_online_time'] * 60;
if ($row) if ($row)

View file

@ -93,9 +93,9 @@ class ucp_prefs
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
meta_refresh(3, $this->u_action); meta_refresh(3, $this->u_action);
$message = phpbb::$user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); $message = phpbb::$user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
@ -215,9 +215,9 @@ class ucp_prefs
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
meta_refresh(3, $this->u_action); meta_refresh(3, $this->u_action);
$message = phpbb::$user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); $message = phpbb::$user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
@ -316,9 +316,9 @@ class ucp_prefs
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$msg = phpbb::$user->lang['PREFERENCES_UPDATED']; $msg = phpbb::$user->lang['PREFERENCES_UPDATED'];
} }

View file

@ -174,15 +174,15 @@ class ucp_profile
if (sizeof($admin_ary)) if (sizeof($admin_ary))
{ {
$where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary); $where_sql .= ' OR ' . phpbb::$db->sql_in_set('user_id', $admin_ary);
} }
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
FROM ' . USERS_TABLE . ' ' . FROM ' . USERS_TABLE . ' ' .
$where_sql; $where_sql;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$messenger->template('admin_activate', $row['user_lang']); $messenger->template('admin_activate', $row['user_lang']);
$messenger->to($row['user_email'], $row['username']); $messenger->to($row['user_email'], $row['username']);
@ -196,7 +196,7 @@ class ucp_profile
$messenger->send($row['user_notify_type']); $messenger->send($row['user_notify_type']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
user_active_flip('deactivate', phpbb::$user->data['user_id'], INACTIVE_PROFILE); user_active_flip('deactivate', phpbb::$user->data['user_id'], INACTIVE_PROFILE);
@ -209,9 +209,9 @@ class ucp_profile
if (sizeof($sql_ary)) if (sizeof($sql_ary))
{ {
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// Need to update config, forum, topic, posting, messages, etc. // Need to update config, forum, topic, posting, messages, etc.
@ -373,28 +373,28 @@ class ucp_profile
} }
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Update Custom Fields // Update Custom Fields
if (sizeof($cp_data)) if (sizeof($cp_data))
{ {
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $cp_data) . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (!$db->sql_affectedrows()) if (!phpbb::$db->sql_affectedrows())
{ {
$cp_data['user_id'] = (int) phpbb::$user->data['user_id']; $cp_data['user_id'] = (int) phpbb::$user->data['user_id'];
$db->sql_return_on_error(true); phpbb::$db->sql_return_on_error(true);
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $cp_data);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$db->sql_return_on_error(false); phpbb::$db->sql_return_on_error(false);
} }
} }
@ -510,9 +510,9 @@ class ucp_profile
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$message = phpbb::$user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); $message = phpbb::$user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message); trigger_error($message);

View file

@ -253,11 +253,11 @@ class ucp_register
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . "
WHERE group_name = '" . $db->sql_escape($group_name) . "' WHERE group_name = '" . phpbb::$db->sql_escape($group_name) . "'
AND group_type = " . GROUP_SPECIAL; AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -377,15 +377,15 @@ class ucp_register
if (sizeof($admin_ary)) if (sizeof($admin_ary))
{ {
$where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary); $where_sql .= ' OR ' . phpbb::$db->sql_in_set('user_id', $admin_ary);
} }
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
FROM ' . USERS_TABLE . ' ' . FROM ' . USERS_TABLE . ' ' .
$where_sql; $where_sql;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$messenger->template('admin_activate', $row['user_lang']); $messenger->template('admin_activate', $row['user_lang']);
$messenger->to($row['user_email'], $row['username']); $messenger->to($row['user_email'], $row['username']);
@ -399,7 +399,7 @@ class ucp_register
$messenger->send($row['user_notify_type']); $messenger->send($row['user_notify_type']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }

View file

@ -35,11 +35,11 @@ class ucp_remind
{ {
$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason $sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE user_email = '" . $db->sql_escape($email) . "' WHERE user_email = '" . phpbb::$db->sql_escape($email) . "'
AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; AND username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$user_row) if (!$user_row)
{ {
@ -81,9 +81,9 @@ class ucp_remind
$user_password = gen_rand_string(8); $user_password = gen_rand_string(8);
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "' SET user_newpasswd = '" . phpbb::$db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . phpbb::$db->sql_escape($user_actkey) . "'
WHERE user_id = " . $user_row['user_id']; WHERE user_id = " . $user_row['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT); include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);

View file

@ -42,11 +42,11 @@ class ucp_resend
$sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason $sql = 'SELECT user_id, group_id, username, user_email, user_type, user_lang, user_actkey, user_inactive_reason
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE user_email = '" . $db->sql_escape($email) . "' WHERE user_email = '" . phpbb::$db->sql_escape($email) . "'
AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; AND username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$user_row) if (!$user_row)
{ {
@ -72,9 +72,9 @@ class ucp_resend
$sql = 'SELECT group_name, group_type $sql = 'SELECT group_name, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . $user_row['group_id']; WHERE group_id = ' . $user_row['group_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -121,10 +121,10 @@ class ucp_resend
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); WHERE ' . phpbb::$db->sql_in_set('user_id', $admin_ary[0]['a_user']);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$messenger->template('admin_activate', $row['user_lang']); $messenger->template('admin_activate', $row['user_lang']);
$messenger->to($row['user_email'], $row['username']); $messenger->to($row['user_email'], $row['username']);
@ -138,7 +138,7 @@ class ucp_resend
$messenger->send($row['user_notify_type']); $messenger->send($row['user_notify_type']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
meta_refresh(3, append_sid('index')); meta_refresh(3, append_sid('index'));

View file

@ -62,10 +62,10 @@ class ucp_zebra
FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u
WHERE z.user_id = ' . phpbb::$user->data['user_id'] . ' WHERE z.user_id = ' . phpbb::$user->data['user_id'] . '
AND u.user_id = z.zebra_id'; AND u.user_id = z.zebra_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$friends = $foes = array(); $friends = $foes = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['friend']) if ($row['friend'])
{ {
@ -76,7 +76,7 @@ class ucp_zebra
$foes[] = utf8_clean_string($row['username']); $foes[] = utf8_clean_string($row['username']);
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// remove friends from the username array // remove friends from the username array
$n = sizeof($data['add']); $n = sizeof($data['add']);
@ -111,12 +111,12 @@ class ucp_zebra
{ {
$sql = 'SELECT user_id, user_type $sql = 'SELECT user_id, user_type
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('username_clean', $data['add']) . ' WHERE ' . phpbb::$db->sql_in_set('username_clean', $data['add']) . '
AND user_type <> ' . phpbb::USER_INACTIVE; AND user_type <> ' . phpbb::USER_INACTIVE;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_id_ary = array(); $user_id_ary = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['user_id'] != ANONYMOUS && $row['user_type'] != phpbb::USER_IGNORE) if ($row['user_id'] != ANONYMOUS && $row['user_type'] != phpbb::USER_IGNORE)
{ {
@ -127,7 +127,7 @@ class ucp_zebra
$error[] = phpbb::$user->lang['NOT_ADDED_' . $l_mode . '_ANONYMOUS']; $error[] = phpbb::$user->lang['NOT_ADDED_' . $l_mode . '_ANONYMOUS'];
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (sizeof($user_id_ary)) if (sizeof($user_id_ary))
{ {
@ -169,7 +169,7 @@ class ucp_zebra
); );
} }
$db->sql_multi_insert(ZEBRA_TABLE, $sql_ary); phpbb::$db->sql_multi_insert(ZEBRA_TABLE, $sql_ary);
$updated = true; $updated = true;
} }
@ -188,8 +188,8 @@ class ucp_zebra
$sql = 'DELETE FROM ' . ZEBRA_TABLE . ' $sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . ' WHERE user_id = ' . phpbb::$user->data['user_id'] . '
AND ' . $db->sql_in_set('zebra_id', $data['usernames']); AND ' . phpbb::$db->sql_in_set('zebra_id', $data['usernames']);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$updated = true; $updated = true;
} }
@ -224,14 +224,14 @@ class ucp_zebra
AND $sql_and AND $sql_and
AND u.user_id = z.zebra_id AND u.user_id = z.zebra_id
ORDER BY u.username_clean ASC"; ORDER BY u.username_clean ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$s_username_options = ''; $s_username_options = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$s_username_options .= '<option value="' . $row['zebra_id'] . '">' . $row['username'] . '</option>'; $s_username_options .= '<option value="' . $row['zebra_id'] . '">' . $row['username'] . '</option>';
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'L_TITLE' => phpbb::$user->lang['UCP_ZEBRA_' . $l_mode], 'L_TITLE' => phpbb::$user->lang['UCP_ZEBRA_' . $l_mode],

View file

@ -135,8 +135,8 @@ if (!$sql)
trigger_error('NO_POST_MODE'); trigger_error('NO_POST_MODE');
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_data = $db->sql_fetchrow($result); $post_data = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$post_data) if (!$post_data)
@ -291,29 +291,29 @@ if ($mode == 'bump')
if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id'])
&& check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}"))
{ {
$db->sql_transaction('begin'); phpbb::$db->sql_transaction('begin');
$sql = 'UPDATE ' . POSTS_TABLE . " $sql = 'UPDATE ' . POSTS_TABLE . "
SET post_time = $current_time SET post_time = $current_time
WHERE post_id = {$post_data['topic_last_post_id']} WHERE post_id = {$post_data['topic_last_post_id']}
AND topic_id = $topic_id"; AND topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_last_post_time = $current_time, SET topic_last_post_time = $current_time,
topic_bumped = 1, topic_bumped = 1,
topic_bumper = " . phpbb::$user->data['user_id'] . " topic_bumper = " . phpbb::$user->data['user_id'] . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
update_post_information('forum', $forum_id); update_post_information('forum', $forum_id);
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_lastpost_time = $current_time SET user_lastpost_time = $current_time
WHERE user_id = " . phpbb::$user->data['user_id']; WHERE user_id = " . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$db->sql_transaction('commit'); phpbb::$db->sql_transaction('commit');
markread('post', $forum_id, $topic_id, $current_time); markread('post', $forum_id, $topic_id, $current_time);
@ -362,13 +362,13 @@ if ($post_data['poll_start'])
FROM ' . POLL_OPTIONS_TABLE . " FROM ' . POLL_OPTIONS_TABLE . "
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
ORDER BY poll_option_id"; ORDER BY poll_option_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_data['poll_options'][] = trim($row['poll_option_text']); $post_data['poll_options'][] = trim($row['poll_option_text']);
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$orig_poll_options_size = sizeof($post_data['poll_options']); $orig_poll_options_size = sizeof($post_data['poll_options']);
@ -406,9 +406,9 @@ if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode
AND in_message = 0 AND in_message = 0
AND is_orphan = 0 AND is_orphan = 0
ORDER BY filetime DESC"; ORDER BY filetime DESC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); $message_parser->attachment_data = array_merge($message_parser->attachment_data, phpbb::$db->sql_fetchrowset($result));
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if ($post_data['poster_id'] == ANONYMOUS) if ($post_data['poster_id'] == ANONYMOUS)
@ -441,13 +441,13 @@ if (phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') && ($mod
(($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') .
(($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') .
(($draft_id) ? " AND draft_id <> $draft_id" : ''); (($draft_id) ? " AND draft_id <> $draft_id" : '');
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
if ($db->sql_fetchrow($result)) if (phpbb::$db->sql_fetchrow($result))
{ {
$post_data['drafts'] = true; $post_data['drafts'] = true;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
$check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); $check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1);
@ -459,9 +459,9 @@ if ($mode != 'post' && phpbb::$config['allow_topic_notify'] && phpbb::$user->is_
FROM ' . TOPICS_WATCH_TABLE . ' FROM ' . TOPICS_WATCH_TABLE . '
WHERE topic_id = ' . $topic_id . ' WHERE topic_id = ' . $topic_id . '
AND user_id = ' . phpbb::$user->data['user_id']; AND user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); $post_data['notify_set'] = (int) phpbb::$db->sql_fetchfield('topic_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Do we want to edit our post ? // Do we want to edit our post ?
@ -489,7 +489,7 @@ if ($save && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts')
{ {
if (confirm_box(true)) if (confirm_box(true))
{ {
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'user_id' => (int) phpbb::$user->data['user_id'], 'user_id' => (int) phpbb::$user->data['user_id'],
'topic_id' => (int) $topic_id, 'topic_id' => (int) $topic_id,
'forum_id' => (int) $forum_id, 'forum_id' => (int) $forum_id,
@ -497,7 +497,7 @@ if ($save && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts')
'draft_subject' => (string) $subject, 'draft_subject' => (string) $subject,
'draft_message' => (string) $message) 'draft_message' => (string) $message)
); );
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$meta_info = ($mode == 'post') ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id"); $meta_info = ($mode == 'post') ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id");
@ -547,9 +547,9 @@ if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && ph
FROM ' . DRAFTS_TABLE . " FROM ' . DRAFTS_TABLE . "
WHERE draft_id = $draft_id WHERE draft_id = $draft_id
AND user_id = " . phpbb::$user->data['user_id']; AND user_id = " . phpbb::$user->data['user_id'];
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row) if ($row)
{ {
@ -624,11 +624,11 @@ if ($submit || $preview || $refresh)
{ {
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$topic_sql = array( $topic_sql = array(
'poll_title' => '', 'poll_title' => '',
@ -640,9 +640,9 @@ if ($submit || $preview || $refresh)
); );
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $topic_sql) . " SET ' . phpbb::$db->sql_build_array('UPDATE', $topic_sql) . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$post_data['poll_title'] = $post_data['poll_option_text'] = ''; $post_data['poll_title'] = $post_data['poll_option_text'] = '';
@ -721,12 +721,12 @@ if ($submit || $preview || $refresh)
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE poster_ip = '" . phpbb::$user->ip . "' WHERE poster_ip = '" . phpbb::$user->ip . "'
AND post_time > " . ($current_time - phpbb::$config['flood_interval']); AND post_time > " . ($current_time - phpbb::$config['flood_interval']);
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$last_post_time = $row['last_post_time']; $last_post_time = $row['last_post_time'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if ($last_post_time && ($current_time - $last_post_time) < intval(phpbb::$config['flood_interval'])) if ($last_post_time && ($current_time - $last_post_time) < intval(phpbb::$config['flood_interval']))
@ -866,9 +866,9 @@ if ($submit || $preview || $refresh)
$sql = 'SELECT topic_type, forum_id $sql = 'SELECT topic_type, forum_id
FROM ' . TOPICS_TABLE . " FROM ' . TOPICS_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL)
{ {
@ -879,9 +879,9 @@ if ($submit || $preview || $refresh)
$sql = 'SELECT forum_type $sql = 'SELECT forum_type
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $to_forum_id; WHERE forum_id = ' . $to_forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_type = (int) $db->sql_fetchfield('forum_type'); $forum_type = (int) phpbb::$db->sql_fetchfield('forum_type');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if ($forum_type != FORUM_POST || !phpbb::$acl->acl_get('f_post', $to_forum_id)) if ($forum_type != FORUM_POST || !phpbb::$acl->acl_get('f_post', $to_forum_id))
{ {
@ -935,7 +935,7 @@ if ($submit || $preview || $refresh)
SET topic_status = $change_topic_status SET topic_status = $change_topic_status
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
AND topic_moved_id = 0"; AND topic_moved_id = 0";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$user_lock = (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && phpbb::$user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; $user_lock = (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && phpbb::$user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : '';

View file

@ -48,8 +48,8 @@ $sql = 'SELECT t.*, p.*
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE p.post_id = $post_id WHERE p.post_id = $post_id
AND p.topic_id = t.topic_id"; AND p.topic_id = t.topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$report_data = $db->sql_fetchrow($result); $report_data = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$report_data) if (!$report_data)
@ -63,8 +63,8 @@ $topic_id = (int) $report_data['topic_id'];
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $forum_id; WHERE forum_id = ' . $forum_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_data = $db->sql_fetchrow($result); $forum_data = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$forum_data) if (!$forum_data)
@ -97,9 +97,9 @@ if ($submit && $reason_id)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . REPORTS_REASONS_TABLE . " FROM ' . REPORTS_REASONS_TABLE . "
WHERE reason_id = $reason_id"; WHERE reason_id = $reason_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other')) if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
{ {
@ -116,16 +116,16 @@ if ($submit && $reason_id)
'report_text' => (string) $report_text 'report_text' => (string) $report_text
); );
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$report_id = $db->sql_nextid(); $report_id = phpbb::$db->sql_nextid();
if (!$report_data['post_reported']) if (!$report_data['post_reported'])
{ {
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 1 SET post_reported = 1
WHERE post_id = ' . $post_id; WHERE post_id = ' . $post_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
if (!$report_data['topic_reported']) if (!$report_data['topic_reported'])
@ -134,7 +134,7 @@ if ($submit && $reason_id)
SET topic_reported = 1 SET topic_reported = 1
WHERE topic_id = ' . $report_data['topic_id'] . ' WHERE topic_id = ' . $report_data['topic_id'] . '
OR topic_moved_id = ' . $report_data['topic_id']; OR topic_moved_id = ' . $report_data['topic_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
meta_refresh(3, $redirect_url); meta_refresh(3, $redirect_url);

View file

@ -108,19 +108,19 @@ if ($keywords || $author || $author_id || $search_id || $submit)
trigger_error(sprintf(phpbb::$user->lang['TOO_FEW_AUTHOR_CHARS'], phpbb::$config['min_search_author_chars'])); trigger_error(sprintf(phpbb::$user->lang['TOO_FEW_AUTHOR_CHARS'], phpbb::$config['min_search_author_chars']));
} }
$sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; $sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . phpbb::$db->sql_like_expression(str_replace('*', phpbb::$db->any_char, utf8_clean_string($author))) : " username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($author)) . "'";
$sql = 'SELECT user_id $sql = 'SELECT user_id
FROM ' . USERS_TABLE . " FROM ' . USERS_TABLE . "
WHERE $sql_where WHERE $sql_where
AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')'; AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query_limit($sql, 100); $result = phpbb::$db->sql_query_limit($sql, 100);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$author_id_ary[] = (int) $row['user_id']; $author_id_ary[] = (int) $row['user_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!sizeof($author_id_ary)) if (!sizeof($author_id_ary))
{ {
@ -153,19 +153,19 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$ex_fid_ary = array_unique(array_merge(array_keys(phpbb::$acl->acl_getf('!f_read', true)), array_keys(phpbb::$acl->acl_getf('!f_search', true)))); $ex_fid_ary = array_unique(array_merge(array_keys(phpbb::$acl->acl_getf('!f_read', true)), array_keys(phpbb::$acl->acl_getf('!f_search', true))));
} }
$not_in_fid = (sizeof($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) phpbb::$user->data['user_id'] . ')' : ""; $not_in_fid = (sizeof($ex_fid_ary)) ? 'WHERE ' . phpbb::$db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) phpbb::$user->data['user_id'] . ')' : "";
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id
FROM ' . FORUMS_TABLE . ' f FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
AND fa.session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "') AND fa.session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "')
$not_in_fid $not_in_fid
ORDER BY f.left_id"; ORDER BY f.left_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$right_id = 0; $right_id = 0;
$reset_search_forum = true; $reset_search_forum = true;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['forum_password'] && $row['user_id'] != phpbb::$user->data['user_id']) if ($row['forum_password'] && $row['user_id'] != phpbb::$user->data['user_id'])
{ {
@ -194,7 +194,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
} }
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// find out in which forums the user is allowed to view approved posts // find out in which forums the user is allowed to view approved posts
if (phpbb::$acl->acl_get('m_approve')) if (phpbb::$acl->acl_get('m_approve'))
@ -205,7 +205,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
else if (phpbb::$acl->acl_getf_global('m_approve')) else if (phpbb::$acl->acl_getf_global('m_approve'))
{ {
$m_approve_fid_ary = array_diff(array_keys(phpbb::$acl->acl_getf('!m_approve', true)), $ex_fid_ary); $m_approve_fid_ary = array_diff(array_keys(phpbb::$acl->acl_getf('!m_approve', true)), $ex_fid_ary);
$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')'; $m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . phpbb::$db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
} }
else else
{ {
@ -283,7 +283,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
WHERE t.topic_moved_id = 0 WHERE t.topic_moved_id = 0
$last_post_time_sql $last_post_time_sql
" . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' " . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . ' ' . ((sizeof($ex_fid_ary)) ? ' AND ' . phpbb::$db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . '
ORDER BY t.topic_last_post_time DESC'; ORDER BY t.topic_last_post_time DESC';
$field = 'topic_id'; $field = 'topic_id';
break; break;
@ -322,7 +322,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
AND p.topic_id = t.topic_id AND p.topic_id = t.topic_id
$last_post_time $last_post_time
$m_approve_fid_sql $m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " " . ((sizeof($ex_fid_ary)) ? ' AND ' . phpbb::$db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort"; $sql_sort";
$field = 'post_id'; $field = 'post_id';
} }
@ -335,7 +335,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
AND p.topic_id = t.topic_id AND p.topic_id = t.topic_id
$last_post_time $last_post_time
$m_approve_fid_sql $m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " " . ((sizeof($ex_fid_ary)) ? ' AND ' . phpbb::$db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort"; $sql_sort";
$field = 'topic_id'; $field = 'topic_id';
} }
@ -359,7 +359,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
FROM ' . POSTS_TABLE . ' p FROM ' . POSTS_TABLE . ' p
WHERE p.post_time > ' . phpbb::$user->data['user_lastvisit'] . " WHERE p.post_time > ' . phpbb::$user->data['user_lastvisit'] . "
$m_approve_fid_sql $m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " " . ((sizeof($ex_fid_ary)) ? ' AND ' . phpbb::$db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort"; $sql_sort";
$field = 'post_id'; $field = 'post_id';
} }
@ -370,7 +370,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
WHERE t.topic_last_post_time > ' . phpbb::$user->data['user_lastvisit'] . ' WHERE t.topic_last_post_time > ' . phpbb::$user->data['user_lastvisit'] . '
AND t.topic_moved_id = 0 AND t.topic_moved_id = 0
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . " ' . ((sizeof($ex_fid_ary)) ? 'AND ' . phpbb::$db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort"; $sql_sort";
$field = 'topic_id'; $field = 'topic_id';
} }
@ -391,13 +391,13 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if ($sql) if ($sql)
{ {
// only return up to 1000 ids (the last one will be removed later) // only return up to 1000 ids (the last one will be removed later)
$result = $db->sql_query_limit($sql, 1001 - $start, $start); $result = phpbb::$db->sql_query_limit($sql, 1001 - $start, $start);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$id_ary[] = $row[$field]; $id_ary[] = $row[$field];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$total_match_count = sizeof($id_ary) + $start; $total_match_count = sizeof($id_ary) + $start;
$id_ary = array_slice($id_ary, 0, $per_page); $id_ary = array_slice($id_ary, 0, $per_page);
@ -433,8 +433,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if (sizeof($id_ary)) if (sizeof($id_ary))
{ {
$sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary); $sql_where .= phpbb::$db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary);
$sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : ''; $sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . phpbb::$db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : '';
$sql_where .= ($show_results == 'posts') ? $m_approve_fid_sql : str_replace(array('p.post_approved', 'p.forum_id'), array('t.topic_approved', 't.forum_id'), $m_approve_fid_sql); $sql_where .= ($show_results == 'posts') ? $m_approve_fid_sql : str_replace(array('p.post_approved', 'p.forum_id'), array('t.topic_approved', 't.forum_id'), $m_approve_fid_sql);
} }
@ -518,14 +518,14 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$sql = 'SELECT zebra_id, friend, foe $sql = 'SELECT zebra_id, friend, foe
FROM ' . ZEBRA_TABLE . ' FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id']; WHERE user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$zebra = array(); $zebra = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$zebra[($row['friend']) ? 'friend' : 'foe'][] = $row['zebra_id']; $zebra[($row['friend']) ? 'friend' : 'foe'][] = $row['zebra_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_colour $sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_colour
FROM ' . POSTS_TABLE . ' p FROM ' . POSTS_TABLE . ' p
@ -571,7 +571,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
WHERE $sql_where"; WHERE $sql_where";
} }
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); $sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$result_topic_id = 0; $result_topic_id = 0;
$rowset = array(); $rowset = array();
@ -579,7 +579,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if ($show_results == 'topics') if ($show_results == 'topics')
{ {
$forums = $rowset = $shadow_topic_list = array(); $forums = $rowset = $shadow_topic_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['topic_status'] == ITEM_MOVED) if ($row['topic_status'] == ITEM_MOVED)
{ {
@ -595,17 +595,17 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; $forums[$row['forum_id']]['topic_list'][] = $row['topic_id'];
$forums[$row['forum_id']]['rowset'][$row['topic_id']] = &$rowset[$row['topic_id']]; $forums[$row['forum_id']]['rowset'][$row['topic_id']] = &$rowset[$row['topic_id']];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// If we have some shadow topics, update the rowset to reflect their topic information // If we have some shadow topics, update the rowset to reflect their topic information
if (sizeof($shadow_topic_list)) if (sizeof($shadow_topic_list))
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); WHERE ' . phpbb::$db->sql_in_set('topic_id', array_keys($shadow_topic_list));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$orig_topic_id = $shadow_topic_list[$row['topic_id']]; $orig_topic_id = $shadow_topic_list[$row['topic_id']];
@ -618,7 +618,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$rowset[$orig_topic_id] = $row; $rowset[$orig_topic_id] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
unset($shadow_topic_list); unset($shadow_topic_list);
@ -645,7 +645,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$bbcode_bitfield = $text_only_message = ''; $bbcode_bitfield = $text_only_message = '';
$attach_list = array(); $attach_list = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// We pre-process some variables here for later usage // We pre-process some variables here for later usage
$row['post_text'] = censor_text($row['post_text']); $row['post_text'] = censor_text($row['post_text']);
@ -678,7 +678,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$rowset[] = $row; $rowset[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
unset($text_only_message); unset($text_only_message);
@ -708,16 +708,16 @@ if ($keywords || $author || $author_id || $search_id || $submit)
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' WHERE ' . phpbb::$db->sql_in_set('post_msg_id', $attach_list) . '
AND in_message = 0 AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC'; ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[$row['post_msg_id']][] = $row; $attachments[$row['post_msg_id']][] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
} }
@ -754,11 +754,11 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if (sizeof($forum_ary)) if (sizeof($forum_ary))
{ {
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); $sql .= ' AND ' . phpbb::$db->sql_in_set('forum_id', $forum_ary, true);
} }
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$g_forum_id = (int) $db->sql_fetchfield('forum_id'); $g_forum_id = (int) phpbb::$db->sql_fetchfield('forum_id');
} }
$u_forum_id = $g_forum_id; $u_forum_id = $g_forum_id;
} }
@ -936,15 +936,15 @@ $s_forums = '';
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id
FROM ' . FORUMS_TABLE . ' f FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
AND fa.session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "') AND fa.session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "')
ORDER BY f.left_id ASC"; ORDER BY f.left_id ASC";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$right = $cat_right = $padding_inc = 0; $right = $cat_right = $padding_inc = 0;
$padding = $forum_list = $holding = ''; $padding = $forum_list = $holding = '';
$pad_store = array('0' => ''); $pad_store = array('0' => '');
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
{ {
@ -1074,11 +1074,11 @@ if (phpbb::$acl->acl_get('a_search'))
{ {
$sql = 'SELECT search_time, search_keywords $sql = 'SELECT search_time, search_keywords
FROM ' . SEARCH_RESULTS_TABLE . ' FROM ' . SEARCH_RESULTS_TABLE . '
WHERE ' . $db->sql_function('length_text', 'search_keywords') . ' > 0 WHERE ' . phpbb::$db->sql_function('length_text', 'search_keywords') . ' > 0
ORDER BY search_time DESC'; ORDER BY search_time DESC';
$result = $db->sql_query_limit($sql, 5); $result = phpbb::$db->sql_query_limit($sql, 5);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$keywords = $row['search_keywords']; $keywords = $row['search_keywords'];
@ -1089,7 +1089,7 @@ if (phpbb::$acl->acl_get('a_search'))
'U_KEYWORDS' => append_sid('search', 'keywords=' . urlencode(htmlspecialchars_decode($keywords))) 'U_KEYWORDS' => append_sid('search', 'keywords=' . urlencode(htmlspecialchars_decode($keywords)))
)); ));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Output the basic page // Output the basic page

View file

@ -182,9 +182,9 @@ switch ($mode)
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $user_id; WHERE user_id = ' . (int) $user_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$user_row = $db->sql_fetchrow($result); $user_row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!phpbb::$acl->acl_get('a_switchperm') || !$user_row || $user_id == phpbb::$user->data['user_id']) if (!phpbb::$acl->acl_get('a_switchperm') || !$user_row || $user_id == phpbb::$user->data['user_id'])
{ {
@ -218,14 +218,14 @@ switch ($mode)
$sql = 'UPDATE ' . USERS_TABLE . " $sql = 'UPDATE ' . USERS_TABLE . "
SET user_perm_from = 0 SET user_perm_from = 0
WHERE user_id = " . phpbb::$user->data['user_id']; WHERE user_id = " . phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$sql = 'SELECT username $sql = 'SELECT username
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_perm_from']; WHERE user_id = ' . phpbb::$user->data['user_perm_from'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$username = $db->sql_fetchfield('username'); $username = phpbb::$db->sql_fetchfield('username');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
add_log('admin', 'LOG_ACL_RESTORE_PERMISSIONS', $username); add_log('admin', 'LOG_ACL_RESTORE_PERMISSIONS', $username);
@ -284,7 +284,7 @@ function _display_friends()
{ {
$update_time = phpbb::$config['load_online_time'] * 60; $update_time = phpbb::$config['load_online_time'] * 60;
$sql = $db->sql_build_query('SELECT_DISTINCT', array( $sql = phpbb::$db->sql_build_query('SELECT_DISTINCT', array(
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
'FROM' => array( 'FROM' => array(
@ -308,9 +308,9 @@ function _display_friends()
'ORDER_BY' => 'u.username_clean ASC', 'ORDER_BY' => 'u.username_clean ASC',
)); ));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || phpbb::$acl->acl_get('u_viewonline'))) ? 'online' : 'offline'; $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || phpbb::$acl->acl_get('u_viewonline'))) ? 'online' : 'offline';
@ -323,7 +323,7 @@ function _display_friends()
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])) 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
); );
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
/** /**

View file

@ -61,8 +61,8 @@ if (phpbb::$user->is_registered)
$sql = "SELECT f.* $lastread_select $sql = "SELECT f.* $lastread_select
FROM $sql_from FROM $sql_from
WHERE f.forum_id = $forum_id"; WHERE f.forum_id = $forum_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_data = $db->sql_fetchrow($result); $forum_data = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$forum_data) if (!$forum_data)
@ -108,7 +108,7 @@ if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'])
$sql = 'UPDATE ' . FORUMS_TABLE . ' $sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_posts = forum_posts + 1 SET forum_posts = forum_posts + 1
WHERE forum_id = ' . $forum_id; WHERE forum_id = ' . $forum_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
// We redirect to the url. The third parameter indicates that external redirects are allowed. // We redirect to the url. The third parameter indicates that external redirects are allowed.
@ -234,9 +234,9 @@ if ($sort_days)
AND ((topic_type <> " . POST_GLOBAL . " AND topic_last_post_time >= $min_post_time) AND ((topic_type <> " . POST_GLOBAL . " AND topic_last_post_time >= $min_post_time)
OR topic_type = " . POST_ANNOUNCE . ") OR topic_type = " . POST_ANNOUNCE . ")
" . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); " . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1');
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topics_count = (int) $db->sql_fetchfield('num_topics'); $topics_count = (int) phpbb::$db->sql_fetchfield('num_topics');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (phpbb_request::is_set_post('sort')) if (phpbb_request::is_set_post('sort'))
{ {
@ -353,7 +353,7 @@ if (phpbb::$user->is_registered)
if ($forum_data['forum_type'] == FORUM_POST) if ($forum_data['forum_type'] == FORUM_POST)
{ {
// Obtain announcements ... removed sort ordering, sort by time in all cases // Obtain announcements ... removed sort ordering, sort by time in all cases
$sql = $db->sql_build_query('SELECT', array( $sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => $sql_array['SELECT'], 'SELECT' => $sql_array['SELECT'],
'FROM' => $sql_array['FROM'], 'FROM' => $sql_array['FROM'],
'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'],
@ -363,9 +363,9 @@ if ($forum_data['forum_type'] == FORUM_POST)
'ORDER_BY' => 't.topic_time DESC', 'ORDER_BY' => 't.topic_time DESC',
)); ));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$rowset[$row['topic_id']] = $row; $rowset[$row['topic_id']] = $row;
$announcement_list[] = $row['topic_id']; $announcement_list[] = $row['topic_id'];
@ -379,7 +379,7 @@ if ($forum_data['forum_type'] == FORUM_POST)
$topics_count--; $topics_count--;
} }
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// If the user is trying to reach late pages, start searching from the end // If the user is trying to reach late pages, start searching from the end
@ -411,12 +411,12 @@ if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary))
} }
else if (empty($active_forum_ary['exclude_forum_id'])) else if (empty($active_forum_ary['exclude_forum_id']))
{ {
$sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']); $sql_where = phpbb::$db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']);
} }
else else
{ {
$get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']); $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']);
$sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id; $sql_where = (sizeof($get_forum_ids)) ? phpbb::$db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;
} }
// Grab just the sorted topic ids // Grab just the sorted topic ids
@ -427,9 +427,9 @@ $sql = 'SELECT t.topic_id
$sql_approved $sql_approved
$sql_limit_time $sql_limit_time
ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order; ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $result = phpbb::$db->sql_query_limit($sql, $sql_limit, $sql_start);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$topic_list[] = (int) $row['topic_id']; $topic_list[] = (int) $row['topic_id'];
} }
@ -446,16 +446,16 @@ if (sizeof($topic_list))
'FROM' => $sql_array['FROM'], 'FROM' => $sql_array['FROM'],
'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'],
'WHERE' => $db->sql_in_set('t.topic_id', $topic_list), 'WHERE' => phpbb::$db->sql_in_set('t.topic_id', $topic_list),
); );
// If store_reverse, then first obtain topics, then stickies, else the other way around... // If store_reverse, then first obtain topics, then stickies, else the other way around...
// Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because
// the number of stickies are not known // the number of stickies are not known
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = phpbb::$db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['topic_status'] == ITEM_MOVED) if ($row['topic_status'] == ITEM_MOVED)
{ {
@ -464,7 +464,7 @@ if (sizeof($topic_list))
$rowset[$row['topic_id']] = $row; $rowset[$row['topic_id']] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// If we have some shadow topics, update the rowset to reflect their topic information // If we have some shadow topics, update the rowset to reflect their topic information
@ -472,10 +472,10 @@ if (sizeof($shadow_topic_list))
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); WHERE ' . phpbb::$db->sql_in_set('topic_id', array_keys($shadow_topic_list));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$orig_topic_id = $shadow_topic_list[$row['topic_id']]; $orig_topic_id = $shadow_topic_list[$row['topic_id']];
@ -513,7 +513,7 @@ if (sizeof($shadow_topic_list))
$rowset[$orig_topic_id] = $row; $rowset[$orig_topic_id] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
unset($shadow_topic_list); unset($shadow_topic_list);

View file

@ -58,15 +58,15 @@ if ($mode == 'whois' && phpbb::$acl->acl_get('a_') && $session_id)
$sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip $sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s
WHERE s.session_id = '" . $db->sql_escape($session_id) . "' WHERE s.session_id = '" . phpbb::$db->sql_escape($session_id) . "'
AND u.user_id = s.session_user_id"; AND u.user_id = s.session_user_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = phpbb::$db->sql_fetchrow($result))
{ {
$template->assign_var('WHOIS', user_ipwhois($row['session_ip'])); $template->assign_var('WHOIS', user_ipwhois($row['session_ip']));
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// Output the page // Output the page
page_header(phpbb::$user->lang['WHO_IS_ONLINE']); page_header(phpbb::$user->lang['WHO_IS_ONLINE']);
@ -83,10 +83,10 @@ if ($mode == 'whois' && phpbb::$acl->acl_get('a_') && $session_id)
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC'; ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600); $result = phpbb::$db->sql_query($sql, 600);
$forum_data = array(); $forum_data = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$forum_data[$row['forum_id']] = $row; $forum_data[$row['forum_id']] = $row;
} }
@ -97,7 +97,7 @@ $guest_counter = 0;
// Get number of online guests (if we do not display them) // Get number of online guests (if we do not display them)
if (!$show_guests) if (!$show_guests)
{ {
if ($db->count_distinct) if (phpbb::$db->features['count_distinct'])
{ {
$sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests $sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests
FROM ' . SESSIONS_TABLE . ' FROM ' . SESSIONS_TABLE . '
@ -115,9 +115,9 @@ if (!$show_guests)
')'; ')';
break; break;
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$guest_counter = (int) $db->sql_fetchfield('num_guests'); $guest_counter = (int) phpbb::$db->sql_fetchfield('num_guests');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
// Get user list // Get user list
@ -127,12 +127,12 @@ $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_type, u.user_colo
AND s.session_time >= ' . (time() - (phpbb::$config['load_online_time'] * 60)) . AND s.session_time >= ' . (time() - (phpbb::$config['load_online_time'] * 60)) .
((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . ' ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . '
ORDER BY ' . $order_by; ORDER BY ' . $order_by;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$prev_id = $prev_ip = $user_list = array(); $prev_id = $prev_ip = $user_list = array();
$logged_visible_online = $logged_hidden_online = $counter = 0; $logged_visible_online = $logged_hidden_online = $counter = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']])) if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']]))
{ {
@ -393,10 +393,10 @@ else
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . phpbb::$user->data['user_id'] . ') AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . phpbb::$user->data['user_id'] . ')
ORDER BY g.group_name ASC'; ORDER BY g.group_name ASC';
} }
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$legend = ''; $legend = '';
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
if ($row['group_name'] == 'BOTS') if ($row['group_name'] == 'BOTS')
{ {

View file

@ -60,9 +60,9 @@ if ($view && !$post_id)
$sql = 'SELECT forum_id $sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . " FROM ' . TOPICS_TABLE . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$forum_id = (int) $db->sql_fetchfield('forum_id'); $forum_id = (int) phpbb::$db->sql_fetchfield('forum_id');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$forum_id) if (!$forum_id)
{ {
@ -83,18 +83,18 @@ if ($view && !$post_id)
" . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " " . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "
AND post_time > $topic_last_read AND post_time > $topic_last_read
ORDER BY post_time ASC"; ORDER BY post_time ASC";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
$sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id; WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
if (!$row) if (!$row)
@ -116,9 +116,9 @@ if ($view && !$post_id)
$sql = 'SELECT forum_id, topic_last_post_time $sql = 'SELECT forum_id, topic_last_post_time
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id; WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -135,9 +135,9 @@ if ($view && !$post_id)
AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
" . ((phpbb::$acl->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . " " . ((phpbb::$acl->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
ORDER BY topic_last_post_time $sql_ordering"; ORDER BY topic_last_post_time $sql_ordering";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
@ -254,9 +254,9 @@ $sql_array['WHERE'] .= ')';
// whereupon we join on the forum_id passed as a parameter ... this // whereupon we join on the forum_id passed as a parameter ... this
// is done so navigation, forum name, etc. remain consistent with where // is done so navigation, forum name, etc. remain consistent with where
// user clicked to view a global topic // user clicked to view a global topic
$sql = $db->sql_build_query('SELECT', $sql_array); $sql = phpbb::$db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$topic_data = $db->sql_fetchrow($result); $topic_data = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$topic_data) if (!$topic_data)
@ -295,9 +295,9 @@ if ($post_id)
" . ((!phpbb::$acl->acl_get('m_approve', $forum_id)) ? 'AND p1.post_approved = 1' : '') . ' " . ((!phpbb::$acl->acl_get('m_approve', $forum_id)) ? 'AND p1.post_approved = 1' : '') . '
AND ' . (($sort_dir == 'd') ? 'p1.post_time >= p2.post_time' : 'p1.post_time <= p2.post_time'); AND ' . (($sort_dir == 'd') ? 'p1.post_time >= p2.post_time' : 'p1.post_time <= p2.post_time');
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$topic_data['prev_posts'] = $row['prev_posts'] - 1; $topic_data['prev_posts'] = $row['prev_posts'] - 1;
} }
@ -315,7 +315,7 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0 SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0
WHERE topic_id = ' . $topic_id; WHERE topic_id = ' . $topic_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$topic_data['topic_type'] = POST_NORMAL; $topic_data['topic_type'] = POST_NORMAL;
$topic_data['topic_time_limit'] = 0; $topic_data['topic_time_limit'] = 0;
@ -411,9 +411,9 @@ if ($sort_days)
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
AND post_time >= $min_post_time AND post_time >= $min_post_time
" . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1'); " . ((phpbb::$acl->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1');
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$total_posts = (int) $db->sql_fetchfield('num_posts'); $total_posts = (int) phpbb::$db->sql_fetchfield('num_posts');
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$limit_posts_time = "AND p.post_time >= $min_post_time "; $limit_posts_time = "AND p.post_time >= $min_post_time ";
@ -480,18 +480,18 @@ if (phpbb::$config['allow_bookmarks'] && phpbb::$user->is_registered && request_
{ {
if (!$topic_data['bookmarked']) if (!$topic_data['bookmarked'])
{ {
$sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array( $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'user_id' => phpbb::$user->data['user_id'], 'user_id' => phpbb::$user->data['user_id'],
'topic_id' => $topic_id, 'topic_id' => $topic_id,
)); ));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
else else
{ {
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . ' $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . ' WHERE user_id = ' . phpbb::$user->data['user_id'] . '
AND topic_id = ' . $topic_id; AND topic_id = ' . $topic_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
$message = (($topic_data['bookmarked']) ? phpbb::$user->lang['BOOKMARK_REMOVED'] : phpbb::$user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>'); $message = (($topic_data['bookmarked']) ? phpbb::$user->lang['BOOKMARK_REMOVED'] : phpbb::$user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
} }
@ -644,14 +644,14 @@ if (!empty($topic_data['poll_start']))
AND p.post_id = {$topic_data['topic_first_post_id']} AND p.post_id = {$topic_data['topic_first_post_id']}
AND p.topic_id = o.topic_id AND p.topic_id = o.topic_id
ORDER BY o.poll_option_id"; ORDER BY o.poll_option_id";
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$poll_info = array(); $poll_info = array();
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$poll_info[] = $row; $poll_info[] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
$cur_voted_id = array(); $cur_voted_id = array();
if (phpbb::$user->is_registered) if (phpbb::$user->is_registered)
@ -660,13 +660,13 @@ if (!empty($topic_data['poll_start']))
FROM ' . POLL_VOTES_TABLE . ' FROM ' . POLL_VOTES_TABLE . '
WHERE topic_id = ' . $topic_id . ' WHERE topic_id = ' . $topic_id . '
AND vote_user_id = ' . phpbb::$user->data['user_id']; AND vote_user_id = ' . phpbb::$user->data['user_id'];
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$cur_voted_id[] = $row['poll_option_id']; $cur_voted_id[] = $row['poll_option_id'];
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
else else
{ {
@ -723,7 +723,7 @@ if (!empty($topic_data['poll_start']))
SET poll_option_total = poll_option_total + 1 SET poll_option_total = poll_option_total + 1
WHERE poll_option_id = ' . (int) $option . ' WHERE poll_option_id = ' . (int) $option . '
AND topic_id = ' . (int) $topic_id; AND topic_id = ' . (int) $topic_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (phpbb::$user->is_registered) if (phpbb::$user->is_registered)
{ {
@ -734,8 +734,8 @@ if (!empty($topic_data['poll_start']))
'vote_user_ip' => (string) phpbb::$user->ip, 'vote_user_ip' => (string) phpbb::$user->ip,
); );
$sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
@ -747,7 +747,7 @@ if (!empty($topic_data['poll_start']))
SET poll_option_total = poll_option_total - 1 SET poll_option_total = poll_option_total - 1
WHERE poll_option_id = ' . (int) $option . ' WHERE poll_option_id = ' . (int) $option . '
AND topic_id = ' . (int) $topic_id; AND topic_id = ' . (int) $topic_id;
$db->sql_query($sql); phpbb::$db->sql_query($sql);
if (phpbb::$user->is_registered) if (phpbb::$user->is_registered)
{ {
@ -755,7 +755,7 @@ if (!empty($topic_data['poll_start']))
WHERE topic_id = ' . (int) $topic_id . ' WHERE topic_id = ' . (int) $topic_id . '
AND poll_option_id = ' . (int) $option . ' AND poll_option_id = ' . (int) $option . '
AND vote_user_id = ' . (int) phpbb::$user->data['user_id']; AND vote_user_id = ' . (int) phpbb::$user->data['user_id'];
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
} }
@ -769,7 +769,7 @@ if (!empty($topic_data['poll_start']))
SET poll_last_vote = ' . time() . " SET poll_last_vote = ' . time() . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$redirect_url = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;start=$start"); $redirect_url = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;start=$start");
@ -894,10 +894,10 @@ $sql = 'SELECT p.post_id
" . (($sort_by_sql[$sort_key][0] == 'u') ? 'AND u.user_id = p.poster_id': '') . " " . (($sort_by_sql[$sort_key][0] == 'u') ? 'AND u.user_id = p.poster_id': '') . "
$limit_posts_time $limit_posts_time
ORDER BY $sql_sort_order"; ORDER BY $sql_sort_order";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $result = phpbb::$db->sql_query_limit($sql, $sql_limit, $sql_start);
$i = ($store_reverse) ? $sql_limit - 1 : 0; $i = ($store_reverse) ? $sql_limit - 1 : 0;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$post_list[$i] = $row['post_id']; $post_list[$i] = $row['post_id'];
($store_reverse) ? $i-- : $i++; ($store_reverse) ? $i-- : $i++;
@ -920,7 +920,7 @@ if (!sizeof($post_list))
// We need to grab it because we do reverse ordering sometimes // We need to grab it because we do reverse ordering sometimes
$max_post_time = 0; $max_post_time = 0;
$sql = $db->sql_build_query('SELECT', array( $sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => 'u.*, z.friend, z.foe, p.*', 'SELECT' => 'u.*, z.friend, z.foe, p.*',
'FROM' => array( 'FROM' => array(
@ -935,17 +935,17 @@ $sql = $db->sql_build_query('SELECT', array(
) )
), ),
'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' 'WHERE' => phpbb::$db->sql_in_set('p.post_id', $post_list) . '
AND u.user_id = p.poster_id' AND u.user_id = p.poster_id'
)); ));
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$now = getdate(time() + phpbb::$user->timezone + phpbb::$user->dst - date('Z')); $now = getdate(time() + phpbb::$user->timezone + phpbb::$user->dst - date('Z'));
// Posts are stored in the $rowset array while $attach_list, $user_cache // Posts are stored in the $rowset array while $attach_list, $user_cache
// and the global bbcode_bitfield are built // and the global bbcode_bitfield are built
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
// Set max_post_time // Set max_post_time
if ($row['post_time'] > $max_post_time) if ($row['post_time'] > $max_post_time)
@ -1156,16 +1156,16 @@ if (phpbb::$config['load_onlinetrack'] && sizeof($id_cache))
{ {
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
FROM ' . SESSIONS_TABLE . ' FROM ' . SESSIONS_TABLE . '
WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . ' WHERE ' . phpbb::$db->sql_in_set('session_user_id', $id_cache) . '
GROUP BY session_user_id'; GROUP BY session_user_id';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
$update_time = phpbb::$config['load_online_time'] * 60; $update_time = phpbb::$config['load_online_time'] * 60;
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || phpbb::$acl->acl_get('u_viewonline'))) ? true : false; $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || phpbb::$acl->acl_get('u_viewonline'))) ? true : false;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
} }
unset($id_cache); unset($id_cache);
@ -1176,24 +1176,24 @@ if (sizeof($attach_list))
{ {
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' WHERE ' . phpbb::$db->sql_in_set('post_msg_id', $attach_list) . '
AND in_message = 0 AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC'; ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql); $result = phpbb::$db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = phpbb::$db->sql_fetchrow($result))
{ {
$attachments[$row['post_msg_id']][] = $row; $attachments[$row['post_msg_id']][] = $row;
} }
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
// No attachments exist, but post table thinks they do so go ahead and reset post_attach flags // No attachments exist, but post table thinks they do so go ahead and reset post_attach flags
if (!sizeof($attachments)) if (!sizeof($attachments))
{ {
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 0 SET post_attachment = 0
WHERE ' . $db->sql_in_set('post_id', $attach_list); WHERE ' . phpbb::$db->sql_in_set('post_id', $attach_list);
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// We need to update the topic indicator too if the complete topic is now without an attachment // We need to update the topic indicator too if the complete topic is now without an attachment
if (sizeof($rowset) != $total_posts) if (sizeof($rowset) != $total_posts)
@ -1204,16 +1204,16 @@ if (sizeof($attach_list))
WHERE p.topic_id = $topic_id WHERE p.topic_id = $topic_id
AND p.post_approved = 1 AND p.post_approved = 1
AND p.topic_id = a.topic_id"; AND p.topic_id = a.topic_id";
$result = $db->sql_query_limit($sql, 1); $result = phpbb::$db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = phpbb::$db->sql_fetchrow($result);
$db->sql_freeresult($result); phpbb::$db->sql_freeresult($result);
if (!$row) if (!$row)
{ {
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_attachment = 0 SET topic_attachment = 0
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
else else
@ -1221,7 +1221,7 @@ if (sizeof($attach_list))
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_attachment = 0 SET topic_attachment = 0
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }
else if ($has_attachments && !$topic_data['topic_attachment']) else if ($has_attachments && !$topic_data['topic_attachment'])
@ -1230,7 +1230,7 @@ if (sizeof($attach_list))
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_attachment = 1 SET topic_attachment = 1
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
$topic_data['topic_attachment'] = 1; $topic_data['topic_attachment'] = 1;
} }
@ -1321,16 +1321,16 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
$sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . ' WHERE ' . phpbb::$db->sql_in_set('p.post_id', $post_storage_list) . '
AND p.post_edit_count <> 0 AND p.post_edit_count <> 0
AND p.post_edit_user <> 0 AND p.post_edit_user <> 0
AND p.post_edit_user = u.user_id'; AND p.post_edit_user = u.user_id';
$result2 = $db->sql_query($sql); $result2 = phpbb::$db->sql_query($sql);
while ($user_edit_row = $db->sql_fetchrow($result2)) while ($user_edit_row = phpbb::$db->sql_fetchrow($result2))
{ {
$post_edit_list[$user_edit_row['user_id']] = $user_edit_row; $post_edit_list[$user_edit_row['user_id']] = $user_edit_row;
} }
$db->sql_freeresult($result2); phpbb::$db->sql_freeresult($result2);
unset($post_storage_list); unset($post_storage_list);
} }
@ -1520,15 +1520,15 @@ if (isset(phpbb::$user->data['session_page']) && !phpbb::$user->is_bot && strpos
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . " SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); phpbb::$db->sql_query($sql);
// Update the attachment download counts // Update the attachment download counts
if (sizeof($update_count)) if (sizeof($update_count))
{ {
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
SET download_count = download_count + 1 SET download_count = download_count + 1
WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); WHERE ' . phpbb::$db->sql_in_set('attach_id', array_unique($update_count));
$db->sql_query($sql); phpbb::$db->sql_query($sql);
} }
} }