aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acm/acm_apc.php4
-rw-r--r--phpBB/includes/acm/acm_eaccelerator.php4
-rw-r--r--phpBB/includes/acm/acm_memcache.php4
-rw-r--r--phpBB/includes/acm/acm_xcache.php4
-rw-r--r--phpBB/includes/auth/auth_apache.php32
-rw-r--r--phpBB/includes/auth/auth_ldap.php16
-rw-r--r--phpBB/includes/bbcode.php8
-rw-r--r--phpBB/includes/captcha/plugins/captcha_abstract.php44
-rw-r--r--phpBB/includes/db/dbal.php2
-rw-r--r--phpBB/includes/formatted_text.php6
-rw-r--r--phpBB/includes/functions_admin.php578
-rw-r--r--phpBB/includes/functions_display.php62
-rw-r--r--phpBB/includes/functions_posting.php371
-rw-r--r--phpBB/includes/functions_privmsgs.php310
-rw-r--r--phpBB/includes/functions_profile_fields.php40
-rw-r--r--phpBB/includes/message_parser.php46
-rw-r--r--phpBB/includes/search/fulltext_mysql.php70
17 files changed, 800 insertions, 801 deletions
diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php
index e0714b1f0a..fa92de2b50 100644
--- a/phpBB/includes/acm/acm_apc.php
+++ b/phpBB/includes/acm/acm_apc.php
@@ -295,11 +295,11 @@ class acm
$this->sql_rowset[$query_id] = array();
$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;
}
- $db->sql_freeresult($query_result);
+ phpbb::$db->sql_freeresult($query_result);
apc_store('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);
diff --git a/phpBB/includes/acm/acm_eaccelerator.php b/phpBB/includes/acm/acm_eaccelerator.php
index a1bc59d803..c6d83da049 100644
--- a/phpBB/includes/acm/acm_eaccelerator.php
+++ b/phpBB/includes/acm/acm_eaccelerator.php
@@ -273,11 +273,11 @@ class acm
$this->sql_rowset[$query_id] = array();
$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;
}
- $db->sql_freeresult($query_result);
+ phpbb::$db->sql_freeresult($query_result);
eaccelerator_put('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);
diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php
index a89657b04e..175d0663a0 100644
--- a/phpBB/includes/acm/acm_memcache.php
+++ b/phpBB/includes/acm/acm_memcache.php
@@ -299,11 +299,11 @@ class acm
$this->sql_rowset[$query_id] = array();
$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;
}
- $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);
diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php
index 9531f5e03d..e2bf21748a 100644
--- a/phpBB/includes/acm/acm_xcache.php
+++ b/phpBB/includes/acm/acm_xcache.php
@@ -257,11 +257,11 @@ class acm
$this->sql_rowset[$query_id] = array();
$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;
}
- $db->sql_freeresult($query_result);
+ phpbb::$db->sql_freeresult($query_result);
xcache_set('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);
diff --git a/phpBB/includes/auth/auth_apache.php b/phpBB/includes/auth/auth_apache.php
index 97112913cf..5c34d7f768 100644
--- a/phpBB/includes/auth/auth_apache.php
+++ b/phpBB/includes/auth/auth_apache.php
@@ -84,10 +84,10 @@ function login_apache(&$username, &$password)
$sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type
FROM ' . USERS_TABLE . "
- WHERE username = '" . $db->sql_escape($php_auth_user) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE username = '" . phpbb::$db->sql_escape($php_auth_user) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -147,10 +147,10 @@ function autologin_apache()
$sql = 'SELECT *
FROM ' . USERS_TABLE . "
- WHERE username = '" . $db->sql_escape($php_auth_user) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE username = '" . phpbb::$db->sql_escape($php_auth_user) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -167,10 +167,10 @@ function autologin_apache()
$sql = 'SELECT *
FROM ' . USERS_TABLE . "
- WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($php_auth_user)) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($php_auth_user)) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -189,11 +189,11 @@ function user_row_apache($username, $password)
// first retrieve default group id
$sql = 'SELECT group_id
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;
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if (!$row)
{
diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php
index 84eb6f33d4..6dd9abda03 100644
--- a/phpBB/includes/auth/auth_ldap.php
+++ b/phpBB/includes/auth/auth_ldap.php
@@ -173,10 +173,10 @@ function login_ldap(&$username, &$password)
$sql ='SELECT user_id, username, user_password, user_passchg, user_email, user_type
FROM ' . USERS_TABLE . "
- WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE username_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($username)) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -204,11 +204,11 @@ function login_ldap(&$username, &$password)
// retrieve default group id
$sql = 'SELECT group_id
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;
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if (!$row)
{
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index bea6d967ae..d0cfd2f044 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -163,10 +163,10 @@ class bbcode
{
$sql = 'SELECT *
FROM ' . BBCODES_TABLE . '
- WHERE ' . $db->sql_in_set('bbcode_id', $sql);
- $result = $db->sql_query($sql, 3600);
+ WHERE ' . phpbb::$db->sql_in_set('bbcode_id', $sql);
+ $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,
// we use carriage returns here. They are later changed back to newlines
@@ -175,7 +175,7 @@ class bbcode
$rowset[$row['bbcode_id']] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
foreach ($bbcode_ids as $bbcode_id)
diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php
index adbb06e7db..8170b69356 100644
--- a/phpBB/includes/captcha/plugins/captcha_abstract.php
+++ b/phpBB/includes/captcha/plugins/captcha_abstract.php
@@ -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)
WHERE s.session_id IS NULL' .
((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();
do
{
$sql_in[] = (string) $row['session_id'];
}
- while ($row = $db->sql_fetchrow($result));
+ while ($row = phpbb::$db->sql_fetchrow($result));
if (sizeof($sql_in))
{
$sql = 'DELETE FROM ' . CONFIRM_TABLE . '
- WHERE ' . $db->sql_in_set('session_id', $sql_in);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('session_id', $sql_in);
+ phpbb::$db->sql_query($sql);
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
function uninstall()
@@ -195,14 +195,14 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
// compute $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,
'session_id' => (string) phpbb::$user->session_id,
'confirm_type' => (int) $this->type,
'code' => (string) $this->code,
'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
FROM ' . CONFIRM_TABLE . "
- WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
- AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
+ WHERE confirm_id = '" . phpbb::$db->sql_escape($this->confirm_id) . "'
+ AND session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type;
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
$this->code = $row['code'];
@@ -243,21 +243,21 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
protected function delete_code()
{
$sql = 'DELETE FROM ' . CONFIRM_TABLE . "
- WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
- AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
+ WHERE confirm_id = '" . phpbb::$db->sql_escape($this->confirm_id) . "'
+ AND session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'
AND confirm_type = " . $this->type;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
function get_attempt_count()
{
$sql = 'SELECT COUNT(session_id) AS attempts
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;
- $result = $db->sql_query($sql);
- $attempts = (int) $db->sql_fetchfield('attempts');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $attempts = (int) phpbb::$db->sql_fetchfield('attempts');
+ phpbb::$db->sql_freeresult($result);
return $attempts;
}
@@ -266,9 +266,9 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
function reset()
{
$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;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// we leave the class usable by generating a new question
$this->generate_code();
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 5e8e0c9fdd..15127509cc 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -364,7 +364,7 @@ abstract class phpbb_dbal
if ($type === 'UPDATE')
{
$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
{
diff --git a/phpBB/includes/formatted_text.php b/phpBB/includes/formatted_text.php
index 418c886998..ca801bfea7 100644
--- a/phpBB/includes/formatted_text.php
+++ b/phpBB/includes/formatted_text.php
@@ -150,9 +150,9 @@ class formatted_text
{
$this->changed = false;
- $sql = 'UPDATE ' . $table . ' SET ' . $db->sql_build_query('UPDATE', $this->to_db_data($column))
- . ' WHERE ' . $where;
- return (bool) $db->sql_query($sql);
+ $sql = 'UPDATE ' . $table . ' SET ' . phpbb::$db->sql_build_query('UPDATE', $this->to_db_data($column))
+ . ' WHERE ' . $where;
+ return (bool) phpbb::$db->sql_query($sql);
}
/**
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index d56e296f32..9b81ee09dd 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -25,15 +25,15 @@ function recalc_btree($sql_id, $sql_table, $module_class = '')
return;
}
- $sql_where = ($module_class) ? " WHERE module_class = '" . $db->sql_escape($module_class) . "'" : '';
+ $sql_where = ($module_class) ? " WHERE module_class = '" . phpbb::$db->sql_escape($module_class) . "'" : '';
// Reset to minimum possible left and right id
$sql = "SELECT MIN(left_id) as min_left_id, MIN(right_id) as min_right_id
FROM $sql_table
$sql_where";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$substract = (int) (min($row['min_left_id'], $row['min_right_id']) - 1);
@@ -42,16 +42,16 @@ function recalc_btree($sql_id, $sql_table, $module_class = '')
$sql = "UPDATE $sql_table
SET left_id = left_id - $substract, right_id = right_id - $substract
$sql_where";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
$sql = "SELECT $sql_id, parent_id, left_id, right_id
FROM $sql_table
$sql_where
ORDER BY left_id ASC, parent_id ASC, $sql_id ASC";
- $f_result = $db->sql_query($sql);
+ $f_result = phpbb::$db->sql_query($sql);
- while ($item_data = $db->sql_fetchrow($f_result))
+ while ($item_data = phpbb::$db->sql_fetchrow($f_result))
{
if ($item_data['parent_id'])
{
@@ -59,26 +59,26 @@ function recalc_btree($sql_id, $sql_table, $module_class = '')
FROM $sql_table
$sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
$sql_id = {$item_data['parent_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))
{
$sql = "UPDATE $sql_table SET parent_id = 0 WHERE $sql_id = " . $item_data[$sql_id];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = "UPDATE $sql_table
SET left_id = left_id + 2, right_id = right_id + 2
$sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
left_id > {$row['right_id']}";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = "UPDATE $sql_table
SET right_id = right_id + 2
$sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
{$row['left_id']} BETWEEN left_id AND right_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$item_data['left_id'] = $row['right_id'];
$item_data['right_id'] = $row['right_id'] + 1;
@@ -88,9 +88,9 @@ function recalc_btree($sql_id, $sql_table, $module_class = '')
$sql = "SELECT MAX(right_id) AS right_id
FROM $sql_table
$sql_where";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$item_data['left_id'] = $row['right_id'] + 1;
$item_data['right_id'] = $row['right_id'] + 2;
@@ -99,9 +99,9 @@ function recalc_btree($sql_id, $sql_table, $module_class = '')
$sql = "UPDATE $sql_table
SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']}
WHERE $sql_id = " . $item_data[$sql_id];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
- $db->sql_freeresult($f_result);
+ phpbb::$db->sql_freeresult($f_result);
}
*/
@@ -116,7 +116,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
- $result = $db->sql_query($sql, 600);
+ $result = phpbb::$db->sql_query($sql, 600);
$right = 0;
$padding_store = array('0' => '');
@@ -127,7 +127,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
// This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
// If this happens, the padding could be "broken"
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if ($row['left_id'] < $right)
{
@@ -179,7 +179,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
$forum_list .= '<option value="' . $row['forum_id'] . '"' . (($disabled) ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . $row['forum_name'] . '</option>';
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
unset($padding_store);
return $forum_list;
@@ -215,7 +215,7 @@ function size_select_options($size_compare)
*/
function group_select_options($group_id, $exclude_ids = false, $manage_founder = false)
{
- $exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
+ $exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . phpbb::$db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
$sql_and = (!phpbb::$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';
@@ -225,15 +225,15 @@ function group_select_options($group_id, $exclude_ids = false, $manage_founder =
$sql_and
$sql_founder
ORDER BY group_type DESC, group_name ASC";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$s_group_options = '';
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$selected = ($row['group_id'] == $group_id) ? ' selected="selected"' : '';
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $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);
return $s_group_options;
}
@@ -253,14 +253,14 @@ function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only =
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
- $result = $db->sql_query($sql, $expire_time);
+ $result = phpbb::$db->sql_query($sql, $expire_time);
$forum_rows = array();
$right = $padding = 0;
$padding_store = array('0' => 0);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if ($row['left_id'] < $right)
{
@@ -279,7 +279,7 @@ function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only =
$forum_rows[] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
unset($padding_store);
}
@@ -327,9 +327,9 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl
LEFT JOIN ' . FORUMS_TABLE . " f2 ON ($condition)
WHERE f1.forum_id = $forum_id
ORDER BY f2.left_id " . (($order == 'descending') ? 'ASC' : '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 (!$include_forum && $row['forum_id'] == $forum_id)
{
@@ -338,7 +338,7 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl
$rows[] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return $rows;
}
@@ -409,22 +409,22 @@ function move_topics($topic_ids, $forum_id, $auto_sync = true)
}
$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) . '
AND forum_id = ' . $forum_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
if ($auto_sync)
{
$sql = 'SELECT DISTINCT forum_id
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
@@ -432,8 +432,8 @@ function move_topics($topic_ids, $forum_id, $auto_sync = true)
{
$sql = "UPDATE $table
SET forum_id = $forum_id
- WHERE " . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE " . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
}
unset($table_ary);
@@ -459,22 +459,22 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
$sql = 'SELECT DISTINCT topic_id, forum_id
FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('post_id', $post_ids);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('post_id', $post_ids);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
$topic_ids[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
- $result = $db->sql_query($sql);
- $forum_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $forum_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if (!$forum_row)
{
@@ -483,13 +483,13 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
$sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = ' . $forum_row['forum_id'] . ", topic_id = $topic_id
- WHERE " . $db->sql_in_set('post_id', $post_ids);
- $db->sql_query($sql);
+ WHERE " . phpbb::$db->sql_in_set('post_id', $post_ids);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
SET topic_id = $topic_id, in_message = 0
- WHERE " . $db->sql_in_set('post_msg_id', $post_ids);
- $db->sql_query($sql);
+ WHERE " . phpbb::$db->sql_in_set('post_msg_id', $post_ids);
+ phpbb::$db->sql_query($sql);
if ($auto_sync)
{
@@ -526,7 +526,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
return array('topics' => 0, 'posts' => 0);
}
- $where_clause = $db->sql_in_set($where_type, $where_ids);
+ $where_clause = phpbb::$db->sql_in_set($where_type, $where_ids);
}
// Making sure that delete_posts does not call delete_topics again...
@@ -537,9 +537,9 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
$sql = 'SELECT topic_id, forum_id, topic_approved, topic_moved_id
FROM ' . TOPICS_TABLE . '
WHERE ' . $where_clause;
- $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_ids[] = $row['forum_id'];
$topic_ids[] = $row['topic_id'];
@@ -549,7 +549,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
$approved_topics++;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$return['topics'] = sizeof($topic_ids);
@@ -558,15 +558,15 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
return $return;
}
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
$table_ary = array(TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
foreach ($table_ary as $table)
{
$sql = "DELETE FROM $table
- WHERE " . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE " . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
}
unset($table_ary);
@@ -575,24 +575,24 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
// update the other forums
$sql = 'SELECT topic_id, forum_id
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_moved_id', $topic_ids);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
$moved_topic_ids[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($moved_topic_ids))
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $moved_topic_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $moved_topic_ids);
+ phpbb::$db->sql_query($sql);
}
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
if ($auto_sync)
{
@@ -633,7 +633,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
return false;
}
- $where_clause = $db->sql_in_set($where_type, array_map('intval', $where_ids));
+ $where_clause = phpbb::$db->sql_in_set($where_type, array_map('intval', $where_ids));
}
$approved_posts = 0;
@@ -642,9 +642,9 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
$sql = 'SELECT post_id, poster_id, post_approved, post_postcount, topic_id, forum_id
FROM ' . POSTS_TABLE . '
WHERE ' . $where_clause;
- $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_ids[] = $row['post_id'];
$poster_ids[] = $row['poster_id'];
@@ -661,22 +661,22 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
$approved_posts++;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (!sizeof($post_ids))
{
return false;
}
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
$table_ary = array(POSTS_TABLE, REPORTS_TABLE);
foreach ($table_ary as $table)
{
$sql = "DELETE FROM $table
- WHERE " . $db->sql_in_set('post_id', $post_ids);
- $db->sql_query($sql);
+ WHERE " . phpbb::$db->sql_in_set('post_id', $post_ids);
+ phpbb::$db->sql_query($sql);
}
unset($table_ary);
@@ -689,13 +689,13 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
SET user_posts = 0
WHERE user_id = ' . $poster_id . '
AND user_posts < ' . $substract;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts - ' . $substract . '
WHERE user_id = ' . $poster_id . '
AND user_posts >= ' . $substract;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
}
@@ -704,15 +704,15 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
{
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
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))
{
$remove_topics[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Actually, those not within remove_topics should be removed. ;)
$remove_topics = array_diff($topic_ids, $remove_topics);
@@ -740,7 +740,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
delete_attachments('post', $post_ids, false);
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
// Resync topics_posted table
if ($posted_sync)
@@ -820,10 +820,10 @@ function delete_attachments($mode, $ids, $resync = true)
// Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled)
$sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan
FROM ' . ATTACHMENTS_TABLE . '
- WHERE ' . $db->sql_in_set($sql_id, $ids);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set($sql_id, $ids);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
// We only need to store post/message/topic ids if resync is enabled and the file is not orphaned
if ($resync && !$row['is_orphan'])
@@ -841,13 +841,13 @@ function delete_attachments($mode, $ids, $resync = true)
$physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize'], 'is_orphan' => $row['is_orphan']);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Delete attachments
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
- WHERE ' . $db->sql_in_set($sql_id, $ids);
- $db->sql_query($sql);
- $num_deleted = $db->sql_affectedrows();
+ WHERE ' . phpbb::$db->sql_in_set($sql_id, $ids);
+ phpbb::$db->sql_query($sql);
+ $num_deleted = phpbb::$db->sql_affectedrows();
if (!$num_deleted)
{
@@ -896,8 +896,8 @@ function delete_attachments($mode, $ids, $resync = true)
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 0
- WHERE ' . $db->sql_in_set('post_id', $post_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('post_id', $post_ids);
+ phpbb::$db->sql_query($sql);
}
// Update message table if messages are affected
@@ -905,8 +905,8 @@ function delete_attachments($mode, $ids, $resync = true)
{
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET message_attachment = 0
- WHERE ' . $db->sql_in_set('msg_id', $message_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('msg_id', $message_ids);
+ phpbb::$db->sql_query($sql);
}
// Now update the topics. This is a bit trickier, because there could be posts still having attachments within the topic
@@ -915,16 +915,16 @@ function delete_attachments($mode, $ids, $resync = true)
// Just check which topics are still having an assigned attachment not orphaned by querying the attachments table (much less entries expected)
$sql = 'SELECT topic_id
FROM ' . ATTACHMENTS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
AND is_orphan = 0';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$remaining_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$remaining_ids[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Now only unset those ids remaining
$topic_ids = array_diff($topic_ids, $remaining_ids);
@@ -933,8 +933,8 @@ function delete_attachments($mode, $ids, $resync = true)
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_attachment = 0
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
}
}
@@ -946,16 +946,16 @@ function delete_attachments($mode, $ids, $resync = true)
*/
function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true)
{
- $where = (is_array($forum_id)) ? 'AND ' . $db->sql_in_set('t.forum_id', array_map('intval', $forum_id)) : (($forum_id) ? 'AND t.forum_id = ' . (int) $forum_id : '');
+ $where = (is_array($forum_id)) ? 'AND ' . phpbb::$db->sql_in_set('t.forum_id', array_map('intval', $forum_id)) : (($forum_id) ? 'AND t.forum_id = ' . (int) $forum_id : '');
- if ($db->multi_table_deletion)
+ if (phpbb::$db->features['multi_table_deletion'])
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . ' t
USING ' . TOPICS_TABLE . ' t2
WHERE t.topic_moved_id = t2.topic_id
AND t.topic_time < ' . (time() - $max_age)
. $where;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
else
{
@@ -964,20 +964,20 @@ function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true)
WHERE t.topic_moved_id = t2.topic_id
AND t.topic_time < ' . (time() - $max_age)
. $where;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$topic_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_ids[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($topic_ids))
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
}
}
@@ -1000,24 +1000,24 @@ function update_posted_info(&$topic_ids)
// First of all, let us remove any posted information for these topics
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
// Now, let us collect the user/topic combos for rebuilding the information
$sql = 'SELECT poster_id, topic_id
FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids) . '
AND poster_id <> ' . ANONYMOUS . '
GROUP BY poster_id, topic_id';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$posted = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
// Add as key to make them unique (grouping by) and circumvent empty keys on array_unique
$posted[$row['poster_id']][] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Now add the information...
$sql_ary = array();
@@ -1034,7 +1034,7 @@ function update_posted_info(&$topic_ids)
}
unset($posted);
- $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
+ phpbb::$db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
}
/**
@@ -1045,10 +1045,10 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
// Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself.
$sql = 'SELECT COUNT(attach_id) AS num_entries
FROM ' . ATTACHMENTS_TABLE . "
- WHERE physical_filename = '" . $db->sql_escape(basename($filename)) . "'";
- $result = $db->sql_query($sql);
- $num_entries = (int) $db->sql_fetchfield('num_entries');
- $db->sql_freeresult($result);
+ WHERE physical_filename = '" . phpbb::$db->sql_escape(basename($filename)) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $num_entries = (int) phpbb::$db->sql_fetchfield('num_entries');
+ phpbb::$db->sql_freeresult($result);
// Do not remove file if at least one additional entry with the same name exist.
if (($entry_removed && $num_entries > 0) || (!$entry_removed && $num_entries > 1))
@@ -1119,7 +1119,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// Limit the topics/forums we are syncing, use specific topic/forum IDs.
// $where_type contains the field for the where clause (forum_id, topic_id)
- $where_sql = 'WHERE ' . $db->sql_in_set($mode[0] . '.' . $where_type, $where_ids);
+ $where_sql = 'WHERE ' . phpbb::$db->sql_in_set($mode[0] . '.' . $where_type, $where_ids);
$where_sql_and = $where_sql . "\n\tAND";
}
}
@@ -1131,20 +1131,20 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
// $where_type contains the field for the where clause (forum_id, topic_id)
- $where_sql = 'WHERE ' . $db->sql_in_set($mode[0] . '.' . $where_type, $where_ids);
+ $where_sql = 'WHERE ' . phpbb::$db->sql_in_set($mode[0] . '.' . $where_type, $where_ids);
$where_sql_and = $where_sql . "\n\tAND";
}
switch ($mode)
{
case 'topic_moved':
- if ($db->multi_table_deletion)
+ if (phpbb::$db->features['multi_table_deletion'])
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
USING ' . TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2
WHERE t1.topic_moved_id = t2.topic_id
AND t1.forum_id = t2.forum_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
else
{
@@ -1152,14 +1152,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' .TOPICS_TABLE . ' t1, ' . TOPICS_TABLE . " t2
WHERE t1.topic_moved_id = t2.topic_id
AND t1.forum_id = t2.forum_id";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$topic_id_ary = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_id_ary[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (!sizeof($topic_id_ary))
{
@@ -1167,18 +1167,18 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_id_ary);
+ phpbb::$db->sql_query($sql);
}
break;
case 'topic_approved':
- if ($db->dbms_type == 'mysql')
+ if (phpbb::$db->dbms_type == 'mysql')
{
$sql = 'UPDATE ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
SET t.topic_approved = p.post_approved
$where_sql_and t.topic_first_post_id = p.post_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
else
{
@@ -1186,14 +1186,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
$where_sql_and p.post_id = t.topic_first_post_id
AND p.post_approved <> t.topic_approved";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$topic_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_ids[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (!sizeof($topic_ids))
{
@@ -1202,8 +1202,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_approved = 1 - topic_approved
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
}
break;
@@ -1214,9 +1214,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' . POSTS_TABLE . " p
$where_sql
GROUP BY p.post_id, p.post_reported";
- $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_ids[$row['post_id']] = $row['post_id'];
if ($row['post_reported'])
@@ -1224,16 +1224,16 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$post_reported[$row['post_id']] = 1;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'SELECT DISTINCT(post_id)
FROM ' . REPORTS_TABLE . '
- WHERE ' . $db->sql_in_set('post_id', $post_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('post_id', $post_ids) . '
AND report_closed = 0';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$post_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (!isset($post_reported[$row['post_id']]))
{
@@ -1244,7 +1244,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
unset($post_reported[$row['post_id']]);
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// $post_reported should be empty by now, if it's not it contains
// posts that are falsely flagged as reported
@@ -1257,8 +1257,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 1 - post_reported
- WHERE ' . $db->sql_in_set('post_id', $post_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('post_id', $post_ids);
+ phpbb::$db->sql_query($sql);
}
break;
@@ -1273,34 +1273,34 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT DISTINCT(t.topic_id)
FROM ' . POSTS_TABLE . " t
$where_sql_and t.post_reported = 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))
{
$topic_reported[$row['topic_id']] = 1;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'SELECT t.topic_id, t.topic_reported
FROM ' . TOPICS_TABLE . " t
$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))
{
if ($row['topic_reported'] ^ isset($topic_reported[$row['topic_id']]))
{
$topic_ids[] = $row['topic_id'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($topic_ids))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 1 - topic_reported
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
}
break;
@@ -1311,9 +1311,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' . POSTS_TABLE . " p
$where_sql
GROUP BY p.post_id, p.post_attachment";
- $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_ids[$row['post_id']] = $row['post_id'];
if ($row['post_attachment'])
@@ -1321,16 +1321,16 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$post_attachment[$row['post_id']] = 1;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'SELECT DISTINCT(post_msg_id)
FROM ' . ATTACHMENTS_TABLE . '
- WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('post_msg_id', $post_ids) . '
AND in_message = 0';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$post_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (!isset($post_attachment[$row['post_msg_id']]))
{
@@ -1341,7 +1341,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
unset($post_attachment[$row['post_msg_id']]);
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// $post_attachment should be empty by now, if it's not it contains
// posts that are falsely flagged as having attachments
@@ -1354,8 +1354,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 1 - post_attachment
- WHERE ' . $db->sql_in_set('post_id', $post_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('post_id', $post_ids);
+ phpbb::$db->sql_query($sql);
}
break;
@@ -1370,34 +1370,34 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT DISTINCT(t.topic_id)
FROM ' . POSTS_TABLE . " t
$where_sql_and t.post_attachment = 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))
{
$topic_attachment[$row['topic_id']] = 1;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'SELECT t.topic_id, t.topic_attachment
FROM ' . TOPICS_TABLE . " t
$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))
{
if ($row['topic_attachment'] ^ isset($topic_attachment[$row['topic_id']]))
{
$topic_ids[] = $row['topic_id'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($topic_ids))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_attachment = 1 - topic_attachment
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $topic_ids);
+ phpbb::$db->sql_query($sql);
}
break;
@@ -1407,10 +1407,10 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT f.*
FROM ' . FORUMS_TABLE . " f
$where_sql";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$forum_data = $forum_ids = $post_ids = $last_post_id = $post_info = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if ($row['forum_type'] == FORUM_LINK)
{
@@ -1434,7 +1434,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$forum_data[$forum_id]['last_poster_name'] = '';
$forum_data[$forum_id]['last_poster_colour'] = '';
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (!sizeof($forum_ids))
{
@@ -1448,11 +1448,11 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$sql = 'SELECT forum_id, topic_approved, COUNT(topic_id) AS forum_topics
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids) . '
GROUP BY forum_id, topic_approved';
- $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_data[$forum_id]['topics_real'] += $row['forum_topics'];
@@ -1462,7 +1462,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$forum_data[$forum_id]['topics'] = $row['forum_topics'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
// 3: Get post count for each forum (optional)
@@ -1472,7 +1472,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$sql = 'SELECT SUM(t.topic_replies + 1) AS forum_posts
FROM ' . TOPICS_TABLE . ' t
- WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('t.forum_id', $forum_ids) . '
AND t.topic_approved = 1
AND t.topic_status <> ' . ITEM_MOVED;
}
@@ -1480,21 +1480,21 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$sql = 'SELECT t.forum_id, SUM(t.topic_replies + 1) AS forum_posts
FROM ' . TOPICS_TABLE . ' t
- WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('t.forum_id', $forum_ids) . '
AND t.topic_approved = 1
AND t.topic_status <> ' . ITEM_MOVED . '
GROUP BY t.forum_id';
}
- $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 = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];
$forum_data[$forum_id]['posts'] = (int) $row['forum_posts'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
// 4: Get last_post_id for each forum
@@ -1502,21 +1502,21 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id
FROM ' . TOPICS_TABLE . ' t
- WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('t.forum_id', $forum_ids) . '
AND t.topic_approved = 1';
}
else
{
$sql = 'SELECT t.forum_id, MAX(t.topic_last_post_id) as last_post_id
FROM ' . TOPICS_TABLE . ' t
- WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . '
+ WHERE ' . phpbb::$db->sql_in_set('t.forum_id', $forum_ids) . '
AND t.topic_approved = 1
GROUP BY t.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))
{
$forum_id = (sizeof($forum_ids) == 1) ? (int) $forum_ids[0] : (int) $row['forum_id'];
@@ -1524,22 +1524,22 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$post_ids[] = $row['last_post_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// 5: Retrieve last_post infos
if (sizeof($post_ids))
{
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . 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 p.poster_id = u.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))
{
$post_info[$row['post_id']] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
foreach ($forum_data as $forum_id => $data)
{
@@ -1598,9 +1598,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
if (sizeof($sql_ary))
{
$sql = 'UPDATE ' . FORUMS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE forum_id = ' . $forum_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
}
break;
@@ -1611,9 +1611,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time
FROM ' . TOPICS_TABLE . " t
$where_sql";
- $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_moved_id'])
{
@@ -1638,7 +1638,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$topic_data[$topic_id]['attachment'] = 0;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Use "t" as table alias because of the $where_sql clause
// NOTE: 't.post_approved' in the GROUP BY is causing a major slowdown.
@@ -1646,9 +1646,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' . POSTS_TABLE . " t
$where_sql
GROUP BY t.topic_id, t.post_approved";
- $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 = (int) $row['topic_id'];
@@ -1676,7 +1676,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
foreach ($topic_data as $topic_id => $row)
{
@@ -1716,12 +1716,12 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . 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 u.user_id = p.poster_id';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$post_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_id = intval($row['topic_id']);
@@ -1746,7 +1746,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$topic_data[$topic_id]['last_poster_colour'] = $row['user_colour'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Make sure shadow topics do link to existing topics
if (sizeof($moved_topics))
@@ -1756,15 +1756,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT t1.topic_id, t1.topic_moved_id
FROM ' . TOPICS_TABLE . ' t1
LEFT JOIN ' . TOPICS_TABLE . ' t2 ON (t2.topic_id = t1.topic_moved_id)
- WHERE ' . $db->sql_in_set('t1.topic_id', $moved_topics) . '
+ WHERE ' . phpbb::$db->sql_in_set('t1.topic_id', $moved_topics) . '
AND t2.topic_id IS NULL';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$delete_topics[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($delete_topics))
{
@@ -1775,30 +1775,30 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// Make sure shadow topics having no last post data being updated (this only rarely happens...)
$sql = 'SELECT topic_id, topic_moved_id, topic_last_post_id, topic_first_post_id
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $moved_topics) . '
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $moved_topics) . '
AND topic_last_post_time = 0';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$shadow_topic_data = $post_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$shadow_topic_data[$row['topic_moved_id']] = $row;
$post_ids[] = $row['topic_last_post_id'];
$post_ids[] = $row['topic_first_post_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sync_shadow_topics = array();
if (sizeof($post_ids))
{
$sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . 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 u.user_id = p.poster_id';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$post_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_id = (int) $row['topic_id'];
@@ -1838,7 +1838,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
}
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$shadow_topic_data = array();
@@ -1848,9 +1848,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
foreach ($sync_shadow_topics as $sync_topic_id => $sql_ary)
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE topic_id = ' . $sync_topic_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
}
}
@@ -1863,8 +1863,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_approved = 1 - topic_approved
- WHERE ' . $db->sql_in_set('topic_id', $approved_unapproved_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $approved_unapproved_ids);
+ phpbb::$db->sql_query($sql);
}
unset($approved_unapproved_ids);
@@ -1880,14 +1880,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$where_sql_and p.topic_id = t.topic_id
AND p.post_reported = 1
GROUP BY t.topic_id, p.post_id";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$fieldnames[] = 'reported';
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_data[intval($row['topic_id'])]['reported'] = 1;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// This routine assumes that post_attachment values are correct
// if they are not, use sync('post_attachment') first
@@ -1896,14 +1896,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$where_sql_and p.topic_id = t.topic_id
AND p.post_attachment = 1
GROUP BY t.topic_id, p.post_id";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$fieldnames[] = 'attachment';
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_data[intval($row['topic_id'])]['attachment'] = 1;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
foreach ($topic_data as $topic_id => $row)
@@ -1921,9 +1921,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
if (sizeof($sql_ary))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE topic_id = ' . $topic_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$resync_forums[$row['forum_id']] = $row['forum_id'];
}
@@ -1982,33 +1982,33 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync
$sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_id) . "
+ WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_id) . "
AND poll_start = 0
$sql_and";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$topic_list = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$topic_list[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if ($prune_flags & FORUM_FLAG_PRUNE_POLL)
{
$sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_id) . "
+ WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_id) . "
AND poll_start > 0
AND poll_last_vote < $prune_date
$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))
{
$topic_list[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$topic_list = array_unique($topic_list);
}
@@ -2024,9 +2024,9 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
- $result = $db->sql_query($sql, 3600);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql, 3600);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -2038,7 +2038,7 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
$sql = 'UPDATE ' . FORUMS_TABLE . "
SET prune_next = $next_prune
WHERE forum_id = $forum_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
}
@@ -2091,13 +2091,13 @@ function cache_moderators()
phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE);
// Clear table
- if ($db->truncate)
+ if (phpbb::$db->features['truncate'])
{
- $db->sql_query('TRUNCATE TABLE ' . MODERATOR_CACHE_TABLE);
+ phpbb::$db->sql_query('TRUNCATE TABLE ' . MODERATOR_CACHE_TABLE);
}
else
{
- $db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE);
+ phpbb::$db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE);
}
// We add moderators who have forum moderator permissions without an explicit ACL_NEVER setting
@@ -2113,7 +2113,7 @@ function cache_moderators()
$ug_id_ary = array_keys($hold_ary);
// Remove users who have group memberships with DENY moderator permissions
- $sql = $db->sql_build_query('SELECT', array(
+ $sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => 'a.forum_id, ug.user_id',
'FROM' => array(
@@ -2133,31 +2133,31 @@ function cache_moderators()
AND ((a.auth_setting = ' . phpbb::ACL_NEVER . ' AND r.auth_setting IS NULL)
OR r.auth_setting = ' . phpbb::ACL_NEVER . ')
AND a.group_id = ug.group_id
- AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . "
+ AND ' . phpbb::$db->sql_in_set('ug.user_id', $ug_id_ary) . "
AND ug.user_pending = 0
- AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char),
+ AND o.auth_option " . phpbb::$db->sql_like_expression('m_' . 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))
{
if (isset($hold_ary[$row['user_id']][$row['forum_id']]))
{
unset($hold_ary[$row['user_id']][$row['forum_id']]);
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($hold_ary))
{
// Get usernames...
$sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary));
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', array_keys($hold_ary));
+ $result = phpbb::$db->sql_query($sql);
$usernames_ary = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$usernames_ary[$row['user_id']] = $row['username'];
}
@@ -2194,11 +2194,11 @@ function cache_moderators()
// Make sure not hidden or special groups are involved...
$sql = 'SELECT group_name, group_id, group_type
FROM ' . GROUPS_TABLE . '
- WHERE ' . $db->sql_in_set('group_id', $ug_id_ary);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('group_id', $ug_id_ary);
+ $result = phpbb::$db->sql_query($sql);
$groupnames_ary = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if ($row['group_type'] == GROUP_HIDDEN || $row['group_type'] == GROUP_SPECIAL)
{
@@ -2207,7 +2207,7 @@ function cache_moderators()
$groupnames_ary[$row['group_id']] = $row['group_name'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
foreach ($hold_ary as $group_id => $forum_id_ary)
{
@@ -2246,7 +2246,7 @@ function cache_moderators()
}
}
- $db->sql_multi_insert(MODERATOR_CACHE_TABLE, $sql_ary);
+ phpbb::$db->sql_multi_insert(MODERATOR_CACHE_TABLE, $sql_ary);
}
/**
@@ -2487,9 +2487,9 @@ function update_foes($group_id = false, $user_id = false)
if (is_array($user_id) && sizeof($user_id))
{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
- WHERE ' . $db->sql_in_set('zebra_id', $user_id) . '
+ WHERE ' . phpbb::$db->sql_in_set('zebra_id', $user_id) . '
AND foe = 1';
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
return;
}
@@ -2497,7 +2497,7 @@ function update_foes($group_id = false, $user_id = false)
if (is_array($group_id) && sizeof($group_id))
{
// Grab group settings...
- $sql = $db->sql_build_query('SELECT', array(
+ $sql = phpbb::$db->sql_build_query('SELECT', array(
'SELECT' => 'a.group_id',
'FROM' => array(
@@ -2513,54 +2513,54 @@ function update_foes($group_id = false, $user_id = false)
),
'WHERE' => '(ao.auth_option_id = a.auth_option_id OR ao.auth_option_id = r.auth_option_id)
- AND ' . $db->sql_in_set('a.group_id', $group_id) . "
+ AND ' . phpbb::$db->sql_in_set('a.group_id', $group_id) . "
AND ao.auth_option IN ('a_', 'm_')",
'GROUP_BY' => 'a.group_id'
));
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$groups = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$groups[] = (int) $row['group_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (!sizeof($groups))
{
return;
}
- if ($db->multi_table_deletion)
+ if (phpbb::$db->features['multi_table_deletion'])
{
$sql = 'DELETE FROM' . ZEBRA_TABLE . ' z
USING ' . USER_GROUP_TABLE . ' ug
WHERE z.zebra_id = ug.user_id
AND z.foe = 1
- AND ' . $db->sql_in_set('ug.group_id', $groups);
- $db->sql_query($sql);
+ AND ' . phpbb::$db->sql_in_set('ug.group_id', $groups);
+ phpbb::$db->sql_query($sql);
}
else
{
$sql = 'SELECT user_id
FROM ' . USER_GROUP_TABLE . '
- WHERE ' . $db->sql_in_set('group_id', $groups);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('group_id', $groups);
+ $result = phpbb::$db->sql_query($sql);
$users = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$users[] = (int) $row['user_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($users))
{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
- WHERE ' . $db->sql_in_set('zebra_id', $users) . '
+ WHERE ' . phpbb::$db->sql_in_set('zebra_id', $users) . '
AND foe = 1';
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
}
@@ -2580,9 +2580,9 @@ function update_foes($group_id = false, $user_id = false)
if (sizeof($perms))
{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
- WHERE ' . $db->sql_in_set('zebra_id', array_unique($perms)) . '
+ WHERE ' . phpbb::$db->sql_in_set('zebra_id', array_unique($perms)) . '
AND foe = 1';
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
unset($perms);
}
@@ -2650,17 +2650,17 @@ function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limi
WHERE user_warnings > 0
' . (($limit_days) ? "AND user_last_warning >= $limit_days" : '') . "
ORDER BY $sort_by";
- $result = $db->sql_query_limit($sql, $limit, $offset);
- $users = $db->sql_fetchrowset($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, $limit, $offset);
+ $users = phpbb::$db->sql_fetchrowset($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'SELECT count(user_id) AS user_count
FROM ' . USERS_TABLE . '
WHERE user_warnings > 0
' . (($limit_days) ? "AND user_last_warning >= $limit_days" : '');
- $result = $db->sql_query($sql);
- $user_count = (int) $db->sql_fetchfield('user_count');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $user_count = (int) phpbb::$db->sql_fetchfield('user_count');
+ phpbb::$db->sql_freeresult($result);
return;
}
@@ -2860,31 +2860,31 @@ function tidy_warnings()
$sql = 'SELECT * FROM ' . WARNINGS_TABLE . "
WHERE warning_time < $expire_date";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$warning_list[] = $row['warning_id'];
$user_list[$row['user_id']] = isset($user_list[$row['user_id']]) ? ++$user_list[$row['user_id']] : 1;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($warning_list))
{
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
$sql = 'DELETE FROM ' . WARNINGS_TABLE . '
- WHERE ' . $db->sql_in_set('warning_id', $warning_list);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('warning_id', $warning_list);
+ phpbb::$db->sql_query($sql);
foreach ($user_list as $user_id => $value)
{
$sql = 'UPDATE ' . USERS_TABLE . " SET user_warnings = user_warnings - $value
WHERE user_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
}
set_config('warnings_last_gc', time(), true);
@@ -2900,23 +2900,23 @@ function tidy_database()
// Sometimes, it can happen permission tables having forums listed which do not exist
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$forum_ids = array(0);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Delete those rows from the acl tables not having listed the forums above
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids, true);
+ phpbb::$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('forum_id', $forum_ids, true);
+ phpbb::$db->sql_query($sql);
set_config('database_last_gc', time(), true);
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 15c73e45c1..d5045dfb12 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -79,7 +79,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
{
$sql_array['LEFT_JOIN'][] = array(
'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';
@@ -573,20 +573,20 @@ function get_forum_parents(&$forum_data)
WHERE left_id < ' . $forum_data['left_id'] . '
AND right_id > ' . $forum_data['right_id'] . '
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']);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$forum_data['forum_parents'] = serialize($forum_parents);
$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'];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
else
{
@@ -833,10 +833,10 @@ function display_custom_bbcodes()
FROM ' . BBCODES_TABLE . '
WHERE display_on_posting = 1
ORDER BY bbcode_tag';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$i = 0;
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$template->assign_block_vars('custom_tags', array(
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
@@ -848,7 +848,7 @@ function display_custom_bbcodes()
$i++;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
/**
@@ -859,9 +859,9 @@ function display_reasons($reason_id = 0)
$sql = 'SELECT *
FROM ' . REPORTS_REASONS_TABLE . '
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 (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)
);
}
- $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_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
$sql = 'SELECT forum_id, COUNT(post_id) AS num_posts
@@ -915,18 +915,18 @@ function display_user_activity(&$userdata)
$forum_sql
GROUP BY forum_id
ORDER BY num_posts DESC";
- $result = $db->sql_query_limit($sql, 1);
- $active_f_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $active_f_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if (!empty($active_f_row))
{
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $active_f_row['forum_id'];
- $result = $db->sql_query($sql, 3600);
- $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql, 3600);
+ $active_f_row['forum_name'] = (string) phpbb::$db->sql_fetchfield('forum_name');
+ phpbb::$db->sql_freeresult($result);
}
// Obtain active topic
@@ -937,18 +937,18 @@ function display_user_activity(&$userdata)
$forum_sql
GROUP BY topic_id
ORDER BY num_posts DESC";
- $result = $db->sql_query_limit($sql, 1);
- $active_t_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $active_t_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if (!empty($active_t_row))
{
$sql = 'SELECT topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $active_t_row['topic_id'];
- $result = $db->sql_query($sql);
- $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $active_t_row['topic_title'] = (string) phpbb::$db->sql_fetchfield('topic_title');
+ phpbb::$db->sql_freeresult($result);
}
$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
WHERE $where_sql = $match_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;
- $db->sql_freeresult($result);
+ $notify_status = ($row = phpbb::$db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
+ phpbb::$db->sql_freeresult($result);
}
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 . "
WHERE $where_sql = $match_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");
@@ -1056,7 +1056,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
SET notify_status = 0
WHERE $where_sql = $match_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)
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>');
}
else
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 8da8f9b0ab..c5659c1451 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -28,9 +28,9 @@ function generate_smilies($mode, $forum_id)
$sql = 'SELECT forum_style
FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
- $result = $db->sql_query_limit($sql, 1);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
phpbb::$user->setup('posting', (int) $row['forum_style']);
}
@@ -52,13 +52,13 @@ function generate_smilies($mode, $forum_id)
$sql = 'SELECT smiley_id
FROM ' . SMILIES_TABLE . '
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;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
$last_url = '';
@@ -67,17 +67,17 @@ function generate_smilies($mode, $forum_id)
FROM ' . SMILIES_TABLE .
(($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . '
ORDER BY smiley_order';
- $result = $db->sql_query($sql, 3600);
+ $result = phpbb::$db->sql_query($sql, 3600);
$smilies = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (empty($smilies[$row['smiley_url']]))
{
$smilies[$row['smiley_url']] = $row;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
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
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
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
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
AND p.post_approved = 1
GROUP BY p.{$type}_id";
}
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$last_post_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
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'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
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
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id
- AND ' . $db->sql_in_set('p.post_id', $last_post_ids);
- $result = $db->sql_query($sql);
+ AND ' . phpbb::$db->sql_in_set('p.post_id', $last_post_ids);
+ $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_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_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_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
+ $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) ? 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);
@@ -230,7 +230,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
$sql = "UPDATE $table
SET " . implode(', ', $update_sql_ary) . "
WHERE {$type}_id = $update_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
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'] . "
$sql_and
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'])
{
@@ -833,7 +833,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
}
$draft_rows[] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
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
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids));
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', array_unique($topic_ids));
+ $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;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
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" : '') . '
ORDER BY p.post_time ';
$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();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$post_list[] = $row['post_id'];
}
-
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (!sizeof($post_list))
{
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.*',
'FROM' => array(
@@ -948,16 +947,16 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
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'
));
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$bbcode_bitfield = '';
$rowset = array();
$has_attachments = false;
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$rowset[$row['post_id']] = $row;
$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;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Instantiate BBCode class
if (!isset($bbcode) && $bbcode_bitfield !== '')
@@ -985,16 +984,16 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
// Get attachments...
$sql = 'SELECT *
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
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;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
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 . '
WHERE ban_userid <> 0
AND ban_exclude <> 1';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$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'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$notify_rows = array();
@@ -1124,9 +1123,9 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
AND w.notify_status = 0
AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
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(
'user_id' => $row['user_id'],
@@ -1140,7 +1139,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
'allowed' => false
);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// forum notification is sent to those not already receiving topic notifications
if ($topic_notification)
@@ -1157,9 +1156,9 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
AND fw.notify_status = 0
AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
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(
'user_id' => $row['user_id'],
@@ -1173,7 +1172,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
'allowed' => false
);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
if (!sizeof($notify_rows))
@@ -1260,15 +1259,15 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
}
// Handle the DB updates
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
if (!empty($update_notification['topic']))
{
$sql = 'UPDATE ' . TOPICS_WATCH_TABLE . "
SET notify_status = 1
WHERE topic_id = $topic_id
- AND " . $db->sql_in_set('user_id', $update_notification['topic']);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('user_id', $update_notification['topic']);
+ phpbb::$db->sql_query($sql);
}
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 . "
SET notify_status = 1
WHERE forum_id = $forum_id
- AND " . $db->sql_in_set('user_id', $update_notification['forum']);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('user_id', $update_notification['forum']);
+ phpbb::$db->sql_query($sql);
}
// 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 . "
WHERE topic_id = $topic_id
- AND " . $db->sql_in_set('user_id', $delete_ids['topic']);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('user_id', $delete_ids['topic']);
+ phpbb::$db->sql_query($sql);
}
if (!empty($delete_ids['forum']))
{
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . "
WHERE forum_id = $forum_id
- AND " . $db->sql_in_set('user_id', $delete_ids['forum']);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('user_id', $delete_ids['forum']);
+ 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);
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
// we must make sure to update forums that contain the shadow'd topic
if ($post_mode == 'delete_topic')
@@ -1337,9 +1336,9 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_moved_id', $topic_id);
- $result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ WHERE ' . phpbb::$db->sql_in_set('topic_moved_id', $topic_id);
+ $result = phpbb::$db->sql_query($sql);
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
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']]++;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
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');
}
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
// Collect the necessary information for updating the tables
$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,
// 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);
}
@@ -1401,16 +1400,16 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id
ORDER BY p.post_time ASC";
- $result = $db->sql_query_limit($sql, 1);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($data['topic_type'] != POST_GLOBAL)
{
$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"
$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 . "
WHERE topic_id = $topic_id " .
((!phpbb::$acl->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '');
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$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' : '') . '
AND post_time > ' . $data['post_time'] . '
ORDER BY post_time ASC';
- $result = $db->sql_query_limit($sql, 1);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
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' : '';
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
$where_sql = array(
FORUMS_TABLE => "forum_id = $forum_id",
@@ -1488,7 +1487,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
{
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 . '
WHERE topic_id = ' . $topic_id . '
AND poster_id = ' . $data['poster_id'];
- $result = $db->sql_query_limit($sql, 1);
- $poster_id = (int) $db->sql_fetchfield('poster_id');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $poster_id = (int) phpbb::$db->sql_fetchfield('poster_id');
+ phpbb::$db->sql_freeresult($result);
// The user is not having any more posts within this topic
if (!$poster_id)
@@ -1509,11 +1508,11 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
WHERE topic_id = ' . $topic_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'))
{
@@ -1567,9 +1566,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
WHERE t.topic_id = p.topic_id
AND p.post_id = ' . $data['post_id'];
- $result = $db->sql_query($sql);
- $topic_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $topic_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$data['topic_approved'] = $topic_row['topic_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
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
// Collect Information
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
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $data['topic_id'];
- $result = $db->sql_query($sql);
- $topic_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $topic_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
}
// 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')
{
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' .
- $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']);
- $db->sql_query($sql);
+ phpbb::$db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['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(
'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']);
- $db->sql_query($sql);
- $data['post_id'] = $db->sql_nextid();
+ $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']);
+ phpbb::$db->sql_query($sql);
+ $data['post_id'] = phpbb::$db->sql_nextid();
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
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $data['topic_id'];
- $result = $db->sql_query($sql);
- $topic_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $topic_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
}
// 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']))
{
- $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;
@@ -1896,7 +1895,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = 0
WHERE topic_id = ' . $data['topic_id'];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// unglobalise
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 . '
SET forum_id = ' . $data['forum_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']))
{
$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'];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// Update the posts table
if (isset($sql_data[POSTS_TABLE]['sql']))
{
$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'];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// Update Poll Tables
@@ -1942,14 +1941,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POLL_OPTIONS_TABLE . '
WHERE topic_id = ' . $data['topic_id'] . '
ORDER BY poll_option_id';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$cur_poll_options = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$cur_poll_options[] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
$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])
{
$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'] . '
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))
{
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . '
WHERE poll_option_id > ' . sizeof($poll['poll_options']) . '
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 ($mode == 'edit' && sizeof($poll['poll_options']) != sizeof($cur_poll_options))
{
- $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('DELETE FROM ' . POLL_VOTES_TABLE . ' 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
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 poster_id = ' . phpbb::$user->data['user_id'];
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$orphan_rows = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$orphan_rows[$row['attach_id']] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
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
$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'] . '
AND is_orphan = 0';
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
else
{
@@ -2059,11 +2058,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'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'] . '
AND is_orphan = 1
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)
{
$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_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_colour = '" . $db->sql_escape(phpbb::$user->data['user_colour']) . "'";
+ $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 = '" . 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']))
{
@@ -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
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// this post is the latest post in the forum, better update
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
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
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)
@@ -2130,9 +2129,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id'] . '
AND topic_approved = 1';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// any posts left in this forum?
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
WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $row['last_post_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// 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_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_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_colour = '" . $db->sql_escape($row['user_colour']) . "'";
+ $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 = '" . phpbb::$db->sql_escape($row['user_colour']) . "'";
}
else
{
@@ -2173,9 +2172,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$sql = 'SELECT forum_last_post_id
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id'];
- $result = $db->sql_query($sql);
- $forum_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $forum_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// 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'])
@@ -2185,9 +2184,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . TOPICS_TABLE . '
WHERE forum_id = ' . (int) $data['forum_id'] . '
AND topic_approved = 1';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// any posts left in this forum?
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
WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $row['last_post_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// 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_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_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_colour = '" . $db->sql_escape($row['user_colour']) . "'";
+ $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 = '" . phpbb::$db->sql_escape($row['user_colour']) . "'";
}
else
{
@@ -2226,17 +2225,17 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $topic_row['topic_last_post_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// 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_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_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_colour = '" . $db->sql_escape($row['user_colour']) . "'";
+ $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 = '" . 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_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_colour = '" . ((!phpbb::$user->is_guest) ? $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_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) ? phpbb::$db->sql_escape(phpbb::$user->data['user_colour']) : '') . "'";
+ $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;
}
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
- $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. ;)
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 . '
WHERE topic_id = ' . (int) $data['topic_id'] . '
AND post_approved = 1';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// any posts left in this forum?
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
WHERE p.poster_id = u.user_id
AND p.post_id = ' . (int) $row['last_post_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
// 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_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_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_colour = '" . $db->sql_escape($row['user_colour']) . "'";
+ $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 = '" . 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']))
{
$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 . '
WHERE topic_moved_id = ' . $data['topic_id'];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// Committing the transaction before updating search index
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
// Delete draft if post was loaded...
$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 . "
WHERE draft_id = $draft_id
AND user_id = " . phpbb::$user->data['user_id'];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// 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)
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'])
{
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
WHERE user_id = ' . phpbb::$user->data['user_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 . '
WHERE user_id = ' . phpbb::$user->data['user_id'] . '
AND forum_id = ' . $data['forum_id'];
- $result = $db->sql_query($sql);
- $f_mark_time = (int) $db->sql_fetchfield('mark_time');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $f_mark_time = (int) phpbb::$db->sql_fetchfield('mark_time');
+ phpbb::$db->sql_freeresult($result);
}
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
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $data['forum_id'];
- $result = $db->sql_query($sql);
- $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $forum_last_post_time = (int) phpbb::$db->sql_fetchfield('forum_last_post_time');
+ phpbb::$db->sql_freeresult($result);
update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false);
}
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 340dfbc0e6..591eefdaba 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -123,15 +123,15 @@ function get_folder($user_id, $folder_id = false)
WHERE user_id = $user_id
AND folder_id <> " . PRIVMSGS_NO_BOX . '
GROUP BY folder_id';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$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_unread[(int) $row['folder_id']] = $row['num_unread'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Make sure the default boxes are defined
$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
FROM ' . PRIVMSGS_FOLDER_TABLE . "
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_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)
);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$folder[PRIVMSGS_OUTBOX] = array(
'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.folder_id = ' . PRIVMSGS_SENTBOX . '
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();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$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);
}
}
@@ -286,9 +286,9 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
$sql = 'SELECT user_id, user_type, user_permissions
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $message_row['author_id'];
- $result = $db->sql_query($sql);
- $userdata = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $userdata = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$auth2 = new auth();
$auth2->acl($userdata);
@@ -319,9 +319,9 @@ function update_pm_counts()
WHERE pm_unread = 1
AND folder_id <> ' . PRIVMSGS_OUTBOX . '
AND user_id = ' . phpbb::$user->data['user_id'];
- $result = $db->sql_query($sql);
- phpbb::$user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ phpbb::$user->data['user_unread_privmsg'] = (int) phpbb::$db->sql_fetchfield('num_messages');
+ phpbb::$db->sql_freeresult($result);
// Update new pm count
$sql = 'SELECT COUNT(msg_id) as num_messages
@@ -329,11 +329,11 @@ function update_pm_counts()
WHERE pm_new = 1
AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND user_id = ' . phpbb::$user->data['user_id'];
- $result = $db->sql_query($sql);
- phpbb::$user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ phpbb::$user->data['user_new_privmsg'] = (int) phpbb::$db->sql_fetchfield('num_messages');
+ 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_new_privmsg' => (int) phpbb::$user->data['user_new_privmsg'],
)) . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
@@ -346,7 +346,7 @@ function update_pm_counts()
WHERE pm_new = 1
AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
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 . '
WHERE folder_id = ' . PRIVMSGS_HOLD_BOX . "
AND user_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// 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
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);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
else
{
@@ -404,28 +404,28 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$sql = 'SELECT *
FROM ' . PRIVMSGS_RULES_TABLE . "
WHERE user_id = $user_id";
- $result = $db->sql_query($sql);
- $user_rules = $db->sql_fetchrowset($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $user_rules = phpbb::$db->sql_fetchrowset($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($user_rules))
{
$sql = 'SELECT zebra_id, friend, foe
FROM ' . ZEBRA_TABLE . "
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;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
// 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(
'to' => explode(':', $row['to_address']),
@@ -438,22 +438,22 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$user_ids[] = $row['user_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Retrieve user memberships
if (sizeof($user_ids))
{
$sql = 'SELECT *
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';
- $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'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
// 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 . '
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 folder_id = " . PRIVMSGS_NO_BOX;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// mark messages as important
@@ -566,8 +566,8 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
SET pm_marked = 1 - pm_marked
WHERE folder_id = ' . PRIVMSGS_NO_BOX . "
AND user_id = $user_id
- AND " . $db->sql_in_set('msg_id', $important_ids);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('msg_id', $important_ids);
+ phpbb::$db->sql_query($sql);
}
// Move into folder
@@ -586,15 +586,15 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
$sql = 'SELECT folder_id, pm_count
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";
- $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'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
unset($sql_folder);
@@ -604,9 +604,9 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id
AND folder_id = " . PRIVMSGS_INBOX;
- $result = $db->sql_query($sql);
- $folder[PRIVMSGS_INBOX] = (int) $db->sql_fetchfield('num_messages');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $folder[PRIVMSGS_INBOX] = (int) phpbb::$db->sql_fetchfield('num_messages');
+ phpbb::$db->sql_freeresult($result);
}
}
@@ -641,14 +641,14 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
WHERE user_id = $user_id
AND folder_id = $dest_folder
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();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$delete_ids[] = $row['msg_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$num_removed += sizeof($delete_ids);
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 . '
WHERE folder_id = ' . PRIVMSGS_NO_BOX . "
AND user_id = $user_id
- AND " . $db->sql_in_set('msg_id', $msg_ary);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('msg_id', $msg_ary);
+ phpbb::$db->sql_query($sql);
}
else
{
@@ -672,16 +672,16 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
WHERE folder_id = " . PRIVMSGS_NO_BOX . "
AND user_id = $user_id
AND pm_new = 1
- AND " . $db->sql_in_set('msg_id', $msg_ary);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('msg_id', $msg_ary);
+ phpbb::$db->sql_query($sql);
if ($dest_folder != PRIVMSGS_INBOX)
{
$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
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 . '
SET folder_id = ' . PRIVMSGS_SENTBOX . '
WHERE folder_id = ' . PRIVMSGS_OUTBOX . '
- AND ' . $db->sql_in_set('msg_id', array_keys($action_ary));
- $db->sql_query($sql);
+ AND ' . phpbb::$db->sql_in_set('msg_id', array_keys($action_ary));
+ phpbb::$db->sql_query($sql);
}
// Update new/unread count
@@ -705,9 +705,9 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id
AND folder_id = " . PRIVMSGS_HOLD_BOX;
- $result = $db->sql_query($sql);
- $num_not_moved = (int) $db->sql_fetchfield('num_messages');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $num_not_moved = (int) phpbb::$db->sql_fetchfield('num_messages');
+ phpbb::$db->sql_freeresult($result);
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 . "
WHERE folder_id = $dest_folder
AND user_id = $user_id";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if (!$row)
{
@@ -756,9 +756,9 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE folder_id = ' . PRIVMSGS_INBOX . "
AND user_id = $user_id";
- $result = $db->sql_query($sql);
- $num_messages = (int) $db->sql_fetchfield('num_messages');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $num_messages = (int) phpbb::$db->sql_fetchfield('num_messages');
+ phpbb::$db->sql_freeresult($result);
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
WHERE folder_id = $cur_folder_id
AND user_id = $user_id
- AND " . $db->sql_in_set('msg_id', $move_msg_ids);
- $db->sql_query($sql);
- $num_moved = $db->sql_affectedrows();
+ AND " . phpbb::$db->sql_in_set('msg_id', $move_msg_ids);
+ phpbb::$db->sql_query($sql);
+ $num_moved = phpbb::$db->sql_affectedrows();
// Update pm counts
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
WHERE folder_id = $cur_folder_id
AND user_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
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
WHERE folder_id = $dest_folder
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
AND user_id = $user_id
AND folder_id = $folder_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_unread_privmsg = user_unread_privmsg - 1
WHERE user_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
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 . "
SET user_unread_privmsg = 0
WHERE user_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
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
WHERE folder_id = $cur_folder_id
AND user_id = $user_id
- AND " . $db->sql_in_set('msg_id', $msg_ids);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('msg_id', $msg_ids);
+ phpbb::$db->sql_query($sql);
break;
@@ -935,21 +935,21 @@ function delete_pm($user_id, $msg_ids, $folder_id)
// Get PM Information for later deleting
$sql = 'SELECT msg_id, pm_unread, pm_new
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 user_id = $user_id";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$delete_rows = array();
$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_new += (int) $row['pm_new'];
$delete_rows[$row['msg_id']] = 1;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
unset($msg_ids);
if (!sizeof($delete_rows))
@@ -957,7 +957,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
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)
// then mark the message as deleted...
@@ -966,22 +966,22 @@ function delete_pm($user_id, $msg_ids, $folder_id)
// Remove PM from Outbox
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id AND folder_id = " . PRIVMSGS_OUTBOX . '
- AND ' . $db->sql_in_set('msg_id', array_keys($delete_rows));
- $db->sql_query($sql);
+ AND ' . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
+ phpbb::$db->sql_query($sql);
// Update PM Information for safety
$sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = ''
- WHERE " . $db->sql_in_set('msg_id', array_keys($delete_rows));
- $db->sql_query($sql);
+ WHERE " . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
+ phpbb::$db->sql_query($sql);
// 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)
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_deleted = 1
- WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows));
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
+ phpbb::$db->sql_query($sql);
- $num_deleted = $db->sql_affectedrows();
+ $num_deleted = phpbb::$db->sql_affectedrows();
}
else
{
@@ -989,9 +989,9 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "
WHERE user_id = $user_id
AND folder_id = $folder_id
- AND " . $db->sql_in_set('msg_id', array_keys($delete_rows));
- $db->sql_query($sql);
- $num_deleted = $db->sql_affectedrows();
+ AND " . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
+ phpbb::$db->sql_query($sql);
+ $num_deleted = phpbb::$db->sql_affectedrows();
}
// 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 . "
SET pm_count = pm_count - $num_deleted
WHERE folder_id = $folder_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// 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;
}
- $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_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
$sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows));
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('msg_id', array_keys($delete_rows));
+ $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']]);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$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);
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('msg_id', $delete_ids);
+ phpbb::$db->sql_query($sql);
}
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
return true;
}
@@ -1119,11 +1119,11 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
{
$sql = 'SELECT user_id, username, user_colour
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 . ')';
- $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'])
{
@@ -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))
@@ -1146,28 +1146,28 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
{
$sql = 'SELECT group_name, group_type
FROM ' . GROUPS_TABLE . '
- WHERE ' . $db->sql_in_set('group_id', $g);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('group_id', $g);
+ $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'])
{
$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
{
$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
- 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 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']]))
{
@@ -1183,7 +1183,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
$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
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 u.user_id = ug.user_id
AND u.user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')' .
$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';
$recipients[$row['user_id']] = $field;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
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 = '';
@@ -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')
{
- $db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data));
- $data['msg_id'] = $db->sql_nextid();
+ phpbb::$db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_data));
+ $data['msg_id'] = phpbb::$db->sql_nextid();
}
else if ($mode == 'edit')
{
$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'];
- $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)
{
- $db->sql_query($sql);
+ phpbb::$db->sql_query($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 . '
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));
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', array_keys($recipients));
+ phpbb::$db->sql_query($sql);
// Put PM into 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'],
'user_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 . "
SET user_lastpost_time = $current_time
WHERE user_id = " . $data['from_user_id'];
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
// Submit Attachments
@@ -1482,18 +1482,18 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
{
$sql = 'SELECT attach_id, filesize, physical_filename
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 is_orphan = 1
AND poster_id = ' . phpbb::$user->data['user_id'];
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$orphan_rows = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$orphan_rows[$row['attach_id']] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
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
$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'] . '
AND is_orphan = 0';
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
else
{
@@ -1531,11 +1531,11 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
'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'] . '
AND is_orphan = 1
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 . "
WHERE draft_id = $draft_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
if ($mode != 'edit')
@@ -1584,15 +1584,15 @@ function pm_notification($mode, $author, $recipients, $subject, $message)
// Get banned User ID's
$sql = 'SELECT ban_userid
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';
- $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']]);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
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
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($recipients)));
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', array_map('intval', array_keys($recipients)));
+ $result = phpbb::$db->sql_query($sql);
$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']))
{
@@ -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))
{
@@ -1677,12 +1677,12 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
}
$sql .= ' ORDER BY p.message_time DESC';
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
if (!$row)
{
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
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']);
}
}
- while ($row = $db->sql_fetchrow($result));
- $db->sql_freeresult($result);
+ while ($row = phpbb::$db->sql_fetchrow($result));
+ phpbb::$db->sql_freeresult($result);
$title = $row['message_subject'];
@@ -1817,9 +1817,9 @@ function set_user_message_limit()
WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . '
AND ug.user_pending = 0
AND ug.group_id = g.group_id';
- $result = $db->sql_query($sql);
- $message_limit = (int) $db->sql_fetchfield('max_message_limit');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $message_limit = (int) phpbb::$db->sql_fetchfield('max_message_limit');
+ phpbb::$db->sql_freeresult($result);
phpbb::$user->data['message_limit'] = (!$message_limit) ? phpbb::$config['pm_max_msgs'] : $message_limit;
}
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index 28374bf567..12cecbf486 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -61,9 +61,9 @@ class custom_profile
AND l.lang_id = $lang_id
AND l.field_id = f.field_id
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
$tpl_snippet = $this->process_field_row('change', $row);
@@ -79,7 +79,7 @@ class custom_profile
'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 l.field_id = f.field_id
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;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
/**
@@ -243,14 +243,14 @@ class custom_profile
AND lang_id = $lang_id
AND field_type = $field_type
ORDER BY option_id";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
// @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'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
}
@@ -288,9 +288,9 @@ class custom_profile
$sql_where
AND l.field_id = f.field_id
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);
$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 *
FROM ' . PROFILE_FIELDS_DATA_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', array_map('intval', $user_id));
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', array_map('intval', $user_id));
+ $result = phpbb::$db->sql_query($sql);
$field_data = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$field_data[$row['user_id']] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$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
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
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';
- $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)
{
@@ -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'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return $cp_data;
}
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index aef9e40bc1..dd44e403f4 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -137,13 +137,13 @@ class bbcode_firstpass extends bbcode
$sql = 'SELECT *
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;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
foreach ($rowset as $row)
@@ -1250,10 +1250,10 @@ class parse_message extends bbcode_firstpass
// For now setting the ttl to 10 minutes
$sql = 'SELECT *
FROM ' . SMILIES_TABLE . '
- ORDER BY ' . $db->sql_function('length_varchar', 'code') . ' DESC';
- $result = $db->sql_query($sql, 600);
+ ORDER BY ' . phpbb::$db->sql_function('length_varchar', 'code') . ' DESC';
+ $result = phpbb::$db->sql_query($sql, 600);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (empty($row['code']))
{
@@ -1264,7 +1264,7 @@ class parse_message extends bbcode_firstpass
$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'] . ' -->';
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
if (sizeof($match))
@@ -1343,10 +1343,10 @@ class parse_message extends bbcode_firstpass
'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(
- 'attach_id' => $db->sql_nextid(),
+ 'attach_id' => phpbb::$db->sql_nextid(),
'is_orphan' => 1,
'real_filename' => $filedata['real_filename'],
'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'] . '
AND is_orphan = 1
AND poster_id = ' . phpbb::$user->data['user_id'];
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -1407,7 +1407,7 @@ class parse_message extends bbcode_firstpass
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
@@ -1445,10 +1445,10 @@ class parse_message extends bbcode_firstpass
'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(
- 'attach_id' => $db->sql_nextid(),
+ 'attach_id' => phpbb::$db->sql_nextid(),
'is_orphan' => 1,
'real_filename' => $filedata['real_filename'],
'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...
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment
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;
- $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']];
$this->attachment_data[$pos] = $row;
@@ -1520,7 +1520,7 @@ class parse_message extends bbcode_firstpass
unset($not_orphan[(int) $row['attach_id']]);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
if (sizeof($not_orphan))
@@ -1533,12 +1533,12 @@ class parse_message extends bbcode_firstpass
{
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment
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 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']];
$this->attachment_data[$pos] = $row;
@@ -1546,7 +1546,7 @@ class parse_message extends bbcode_firstpass
unset($orphan[(int) $row['attach_id']]);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
if (sizeof($orphan))
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index cda1c9f437..6430e3b0b8 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -46,9 +46,9 @@ class fulltext_mysql extends search_backend
*/
public function init()
{
- $result = $db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\'');
- $info = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\'');
+ $info = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$engine = '';
if (isset($info['Engine']))
@@ -67,14 +67,14 @@ class fulltext_mysql extends search_backend
$sql = 'SHOW VARIABLES
LIKE \'ft\_%\'';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$mysql_info = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$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_min_word_len', $mysql_info['ft_min_word_len']);
@@ -336,7 +336,7 @@ class fulltext_mysql extends search_backend
}
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 ' : '';
@@ -348,7 +348,7 @@ class fulltext_mysql extends search_backend
$sql_where_options = $sql_sort_join;
$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 .= (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 .= (sizeof($author_ary)) ? ' AND p.poster_id ' . $sql_author : '';
$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
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
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];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
@@ -378,9 +378,9 @@ class fulltext_mysql extends search_backend
if (!$result_count)
{
$sql = 'SELECT FOUND_ROWS() as result_count';
- $result = $db->sql_query($sql);
- $result_count = (int) $db->sql_fetchfield('result_count');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $result_count = (int) phpbb::$db->sql_fetchfield('result_count');
+ phpbb::$db->sql_freeresult($result);
if (!$result_count)
{
@@ -436,8 +436,8 @@ class fulltext_mysql extends search_backend
$id_ary = array();
// Create some display specific sql strings
- $sql_author = $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_author = phpbb::$db->sql_in_set('p.poster_id', $author_ary);
+ $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_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@@ -473,7 +473,7 @@ class fulltext_mysql extends search_backend
}
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
@@ -512,21 +512,21 @@ class fulltext_mysql extends search_backend
}
// 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];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// retrieve the total result count if needed
if (!$result_count)
{
$sql = 'SELECT FOUND_ROWS() as result_count';
- $result = $db->sql_query($sql);
- $result_count = (int) $db->sql_fetchfield('result_count');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $result_count = (int) phpbb::$db->sql_fetchfield('result_count');
+ phpbb::$db->sql_freeresult($result);
if (!$result_count)
{
@@ -622,10 +622,10 @@ class fulltext_mysql extends search_backend
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;
}
@@ -665,10 +665,10 @@ class fulltext_mysql extends search_backend
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;
}
@@ -703,7 +703,7 @@ class fulltext_mysql extends search_backend
private function get_stats()
{
- if ($db->dbms_type !== 'mysql')
+ if (phpbb::$db->dbms_type !== 'mysql')
{
$this->stats = array();
return;
@@ -711,9 +711,9 @@ class fulltext_mysql extends search_backend
$sql = 'SHOW INDEX
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
$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
FROM ' . POSTS_TABLE;
- $result = $db->sql_query($sql);
- $this->stats['total_posts'] = (int) $db->sql_fetchfield('total_posts');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $this->stats['total_posts'] = (int) phpbb::$db->sql_fetchfield('total_posts');
+ phpbb::$db->sql_freeresult($result);
}
/**