aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-01-16 17:41:04 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-01-16 17:41:04 +0000
commit57aea7e62f7df2424ffbd1adc90941bff482d7ea (patch)
tree5b6e3c5c11c66509a9f600ce448a82d7fbd7b346 /phpBB/includes
parent0df7a9b3e38773207441fac64c5e5c6323e59d6f (diff)
downloadforums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar
forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar.gz
forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar.bz2
forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar.xz
forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.zip
modified some files to get the admin index page working, as well as index page in logged in state and not logged in state
additionally prepare for a working installation git-svn-id: file:///svn/phpbb/trunk@9272 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php410
-rw-r--r--phpBB/includes/functions_admin.php130
-rw-r--r--phpBB/includes/functions_display.php20
-rw-r--r--phpBB/includes/functions_module.php54
-rw-r--r--phpBB/includes/functions_user.php532
5 files changed, 540 insertions, 606 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 1787ec8df1..ab62308ad7 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -277,20 +277,18 @@ function phpbb_chmod($filename, $perms = phpbb::CHMOD_READ)
* @return string the hash
*/
/*
- should use our hashing instead of a "custom" one
-
+@todo should use our hashing instead of a "custom" one
+*/
function generate_link_hash($link_name)
{
- global $user;
-
- if (!isset($user->data["hash_$link_name"]))
+ if (!isset(phpbb::$user->data["hash_$link_name"]))
{
- $user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8);
+ phpbb::$user->data["hash_$link_name"] = substr(sha1(phpbb::$user->data['user_form_salt'] . $link_name), 0, 8);
}
- return $user->data["hash_$link_name"];
+ return phpbb::$user->data["hash_$link_name"];
}
-*/
+
/**
* checks a link hash - for GET requests
@@ -298,12 +296,12 @@ function phpbb_chmod($filename, $perms = phpbb::CHMOD_READ)
* @param string $link_name The name of the link
* @return boolean true if all is fine
*/
-/*
+
function check_link_hash($token, $link_name)
{
return $token === generate_link_hash($link_name);
}
-*/
+
// functions used for building option fields
/**
@@ -311,20 +309,18 @@ function phpbb_chmod($filename, $perms = phpbb::CHMOD_READ)
*/
function language_select($default = '')
{
- global $db;
-
$sql = 'SELECT lang_iso, lang_local_name
FROM ' . LANG_TABLE . '
ORDER BY lang_english_name';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$lang_options = '';
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$selected = ($row['lang_iso'] == $default) ? ' selected="selected"' : '';
$lang_options .= '<option value="' . $row['lang_iso'] . '"' . $selected . '>' . $row['lang_local_name'] . '</option>';
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return $lang_options;
}
@@ -334,22 +330,20 @@ function language_select($default = '')
*/
function style_select($default = '', $all = false)
{
- global $db;
-
$sql_where = (!$all) ? 'WHERE style_active = 1 ' : '';
$sql = 'SELECT style_id, style_name
FROM ' . STYLES_TABLE . "
$sql_where
ORDER BY style_name";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$style_options = '';
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$selected = ($row['style_id'] == $default) ? ' selected="selected"' : '';
$style_options .= '<option value="' . $row['style_id'] . '"' . $selected . '>' . $row['style_name'] . '</option>';
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return $style_options;
}
@@ -359,10 +353,8 @@ function style_select($default = '', $all = false)
*/
function tz_select($default = '', $truncate = false)
{
- global $user;
-
$tz_select = '';
- foreach ($user->lang['tz_zones'] as $offset => $zone)
+ foreach (phpbb::$user->lang['tz_zones'] as $offset => $zone)
{
if ($truncate)
{
@@ -393,20 +385,18 @@ function tz_select($default = '', $truncate = false)
*/
function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0)
{
- global $db, $user;
-
if ($mode == 'all')
{
if ($forum_id === false || !sizeof($forum_id))
{
- if (phpbb::$config['load_db_lastread'] && $user->data['is_registered'])
+ if (phpbb::$config['load_db_lastread'] && phpbb::$user->data['is_registered'])
{
// Mark all forums read (index page)
- $db->sql_query('DELETE FROM ' . TOPICS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']}");
- $db->sql_query('DELETE FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']}");
- $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . " WHERE user_id = {$user->data['user_id']}");
+ phpbb::$db->sql_query('DELETE FROM ' . TOPICS_TRACK_TABLE . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
+ phpbb::$db->sql_query('DELETE FROM ' . FORUMS_TRACK_TABLE . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
+ phpbb::$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
}
- else if (phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
+ else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->data['is_registered'])
{
$tracking_topics = phpbb_request::variable(phpbb::$config['cookie_name'] . '_track', '', false, phpbb_request::COOKIE);
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
@@ -416,14 +406,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
unset($tracking_topics['f']);
$tracking_topics['l'] = base_convert(time() - phpbb::$config['board_startdate'], 10, 36);
- $user->set_cookie('track', tracking_serialize($tracking_topics), time() + 31536000);
+ phpbb::$user->set_cookie('track', tracking_serialize($tracking_topics), time() + 31536000);
phpbb_request::overwrite(phpbb::$config['cookie_name'] . '_track', tracking_serialize($tracking_topics), phpbb_request::COOKIE);
unset($tracking_topics);
- if ($user->data['is_registered'])
+ if (phpbb::$user->data['is_registered'])
{
- $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . " WHERE user_id = {$user->data['user_id']}");
+ phpbb::$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
}
}
}
@@ -441,33 +431,33 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
// Add 0 to forums array to mark global announcements correctly
$forum_id[] = 0;
- if (phpbb::$config['load_db_lastread'] && $user->data['is_registered'])
+ if (phpbb::$config['load_db_lastread'] && phpbb::$user->data['is_registered'])
{
- $sql = 'DELETE FROM ' . TOPICS_TRACK_TABLE . "
- WHERE user_id = {$user->data['user_id']}
- AND " . $db->sql_in_set('forum_id', $forum_id);
- $db->sql_query($sql);
+ $sql = 'DELETE FROM ' . TOPICS_TRACK_TABLE . '
+ WHERE user_id = ' . phpbb::$user->data['user_id'] . '
+ AND ' . phpbb::$db->sql_in_set('forum_id', $forum_id);
+ phpbb::$db->sql_query($sql);
$sql = 'SELECT forum_id
- FROM ' . FORUMS_TRACK_TABLE . "
- WHERE user_id = {$user->data['user_id']}
- AND " . $db->sql_in_set('forum_id', $forum_id);
- $result = $db->sql_query($sql);
+ FROM ' . FORUMS_TRACK_TABLE . '
+ WHERE user_id = ' . phpbb::$user->data['user_id'] . '
+ AND ' . phpbb::$db->sql_in_set('forum_id', $forum_id);
+ $result = phpbb::$db->sql_query($sql);
$sql_update = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$sql_update[] = $row['forum_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($sql_update))
{
$sql = 'UPDATE ' . FORUMS_TRACK_TABLE . '
- SET mark_time = ' . time() . "
- WHERE user_id = {$user->data['user_id']}
- AND " . $db->sql_in_set('forum_id', $sql_update);
- $db->sql_query($sql);
+ SET mark_time = ' . time() . '
+ WHERE user_id = ' . phpbb::$user->data['user_id'] . '
+ AND ' . phpbb::$db->sql_in_set('forum_id', $sql_update);
+ phpbb::$db->sql_query($sql);
}
if ($sql_insert = array_diff($forum_id, $sql_update))
@@ -476,16 +466,16 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
foreach ($sql_insert as $f_id)
{
$sql_ary[] = array(
- 'user_id' => (int) $user->data['user_id'],
+ 'user_id' => (int) phpbb::$user->data['user_id'],
'forum_id' => (int) $f_id,
'mark_time' => time()
);
}
- $db->sql_multi_insert(FORUMS_TRACK_TABLE, $sql_ary);
+ phpbb::$db->sql_multi_insert(FORUMS_TRACK_TABLE, $sql_ary);
}
}
- else if (phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
+ else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->data['is_registered'])
{
$tracking = phpbb_request::variable(phpbb::$config['cookie_name'] . '_track', '', false, phpbb_request::COOKIE);
$tracking = ($tracking) ? tracking_unserialize($tracking) : array();
@@ -517,7 +507,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
unset($tracking['tf']);
}
- $user->set_cookie('track', tracking_serialize($tracking), time() + 31536000);
+ phpbb::$user->set_cookie('track', tracking_serialize($tracking), time() + 31536000);
phpbb_request::overwrite(phpbb::$config['cookie_name'] . '_track', tracking_serialize($tracking), phpbb_request::COOKIE);
unset($tracking);
@@ -532,32 +522,32 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
return;
}
- if (phpbb::$config['load_db_lastread'] && $user->data['is_registered'])
+ if (phpbb::$config['load_db_lastread'] && phpbb::$user->data['is_registered'])
{
$sql = 'UPDATE ' . TOPICS_TRACK_TABLE . '
- SET mark_time = ' . (($post_time) ? $post_time : time()) . "
- WHERE user_id = {$user->data['user_id']}
- AND topic_id = $topic_id";
- $db->sql_query($sql);
+ SET mark_time = ' . (($post_time) ? $post_time : time()) . '
+ WHERE user_id = ' . phpbb::$user->data['user_id'] . '
+ AND topic_id = ' . $topic_id;
+ phpbb::$db->sql_query($sql);
// insert row
- if (!$db->sql_affectedrows())
+ if (!phpbb::$db->sql_affectedrows())
{
- $db->sql_return_on_error(true);
+ phpbb::$db->sql_return_on_error(true);
$sql_ary = array(
- 'user_id' => (int) $user->data['user_id'],
+ 'user_id' => (int) phpbb::$user->data['user_id'],
'topic_id' => (int) $topic_id,
'forum_id' => (int) $forum_id,
'mark_time' => ($post_time) ? (int) $post_time : time(),
);
- $db->sql_query('INSERT INTO ' . TOPICS_TRACK_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
+ phpbb::$db->sql_query('INSERT INTO ' . TOPICS_TRACK_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
- $db->sql_return_on_error(false);
+ phpbb::$db->sql_return_on_error(false);
}
}
- else if (phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
+ else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->data['is_registered'])
{
$tracking = phpbb_request::variable(phpbb::$config['cookie_name'] . '_track', '', false, phpbb_request::COOKIE);
$tracking = ($tracking) ? tracking_unserialize($tracking) : array();
@@ -602,10 +592,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
}
}
- if ($user->data['is_registered'])
+ if (phpbb::$user->data['is_registered'])
{
- $user->data['user_lastmark'] = intval(base_convert(max($time_keys) + phpbb::$config['board_startdate'], 36, 10));
- $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . $user->data['user_lastmark'] . " WHERE user_id = {$user->data['user_id']}");
+ phpbb::$user->data['user_lastmark'] = intval(base_convert(max($time_keys) + phpbb::$config['board_startdate'], 36, 10));
+ phpbb::$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . phpbb::$user->data['user_lastmark'] . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
}
else
{
@@ -613,7 +603,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
}
}
- $user->set_cookie('track', tracking_serialize($tracking), time() + 31536000);
+ phpbb::$user->set_cookie('track', tracking_serialize($tracking), time() + 31536000);
phpbb_request::overwrite(phpbb::$config['cookie_name'] . '_track', tracking_serialize($tracking));
}
@@ -626,11 +616,11 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
return;
}
- $use_user_id = (!$user_id) ? $user->data['user_id'] : $user_id;
+ $use_user_id = (!$user_id) ? phpbb::$user->data['user_id'] : $user_id;
if (phpbb::$config['load_db_track'] && $use_user_id != ANONYMOUS)
{
- $db->sql_return_on_error(true);
+ phpbb::$db->sql_return_on_error(true);
$sql_ary = array(
'user_id' => (int) $use_user_id,
@@ -638,9 +628,9 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
'topic_posted' => 1
);
- $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
+ phpbb::$db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
- $db->sql_return_on_error(false);
+ phpbb::$db->sql_return_on_error(false);
}
return;
@@ -652,8 +642,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
*/
function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $global_announce_list = false)
{
- global $user;
-
$last_read = array();
if (!is_array($topic_ids))
@@ -680,15 +668,13 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
{
if (!isset($forum_mark_time[0]))
{
- global $db;
-
$sql = 'SELECT mark_time
- FROM ' . FORUMS_TRACK_TABLE . "
- WHERE user_id = {$user->data['user_id']}
- AND forum_id = 0";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ FROM ' . FORUMS_TRACK_TABLE . '
+ WHERE user_id = ' . phpbb::$user->data['user_id'] . '
+ AND forum_id = 0';
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -709,7 +695,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
$mark_time[$forum_id] = $forum_mark_time[$forum_id];
}
- $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark'];
+ $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : phpbb::$user->data['user_lastmark'];
foreach ($topic_ids as $topic_id)
{
@@ -732,8 +718,6 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
*/
function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false)
{
- global $user;
-
$last_read = array();
if (!is_array($topic_ids))
@@ -741,41 +725,39 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
$topic_ids = array($topic_ids);
}
- if (phpbb::$config['load_db_lastread'] && $user->data['is_registered'])
+ if (phpbb::$config['load_db_lastread'] && phpbb::$user->data['is_registered'])
{
- global $db;
-
$sql = 'SELECT topic_id, mark_time
- FROM ' . TOPICS_TRACK_TABLE . "
- WHERE user_id = {$user->data['user_id']}
- AND " . $db->sql_in_set('topic_id', $topic_ids);
- $result = $db->sql_query($sql);
+ FROM ' . TOPICS_TRACK_TABLE . '
+ WHERE user_id = ' . phpbb::$user->data['user_id'] . '
+ AND ' . 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))
{
$last_read[$row['topic_id']] = $row['mark_time'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$topic_ids = array_diff($topic_ids, array_keys($last_read));
if (sizeof($topic_ids))
{
$sql = 'SELECT forum_id, mark_time
- FROM ' . FORUMS_TRACK_TABLE . "
- WHERE user_id = {$user->data['user_id']}
- AND forum_id " .
+ FROM ' . FORUMS_TRACK_TABLE . '
+ WHERE user_id = ' . phpbb::$user->data['user_id'] . '
+ AND forum_id ' .
(($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id");
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$mark_time = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$mark_time[$row['forum_id']] = $row['mark_time'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
- $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark'];
+ $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : phpbb::$user->data['user_lastmark'];
foreach ($topic_ids as $topic_id)
{
@@ -790,7 +772,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
}
}
}
- else if (phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
+ else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->data['is_registered'])
{
global $tracking_topics;
@@ -800,13 +782,13 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
}
- if (!$user->data['is_registered'])
+ if (!phpbb::$user->data['is_registered'])
{
$user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + phpbb::$config['board_startdate'] : 0;
}
else
{
- $user_lastmark = $user->data['user_lastmark'];
+ $user_lastmark = phpbb::$user->data['user_lastmark'];
}
foreach ($topic_ids as $topic_id)
@@ -868,32 +850,32 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
*/
function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false)
{
- global $db, $tracking_topics, $user;
+ global $tracking_topics;
// Determine the users last forum mark time if not given.
if ($mark_time_forum === false)
{
- if (phpbb::$config['load_db_lastread'] && $user->data['is_registered'])
+ if (phpbb::$config['load_db_lastread'] && phpbb::$user->data['is_registered'])
{
- $mark_time_forum = (!empty($f_mark_time)) ? $f_mark_time : $user->data['user_lastmark'];
+ $mark_time_forum = (!empty($f_mark_time)) ? $f_mark_time : phpbb::$user->data['user_lastmark'];
}
- else if (phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
+ else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->data['is_registered'])
{
$tracking_topics = phpbb_request::variable(phpbb::$config['cookie_name'] . '_track', '', false, phpbb_request::COOKIE);
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
- if (!$user->data['is_registered'])
+ if (!phpbb::$user->data['is_registered'])
{
- $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + phpbb::$config['board_startdate']) : 0;
+ phpbb::$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + phpbb::$config['board_startdate']) : 0;
}
- $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + phpbb::$config['board_startdate']) : $user->data['user_lastmark'];
+ $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + phpbb::$config['board_startdate']) : phpbb::$user->data['user_lastmark'];
}
}
// Check the forum for any left unread topics.
// If there are none, we mark the forum as read.
- if (phpbb::$config['load_db_lastread'] && $user->data['is_registered'])
+ if (phpbb::$config['load_db_lastread'] && phpbb::$user->data['is_registered'])
{
if ($mark_time_forum >= $forum_last_post_time)
{
@@ -903,18 +885,18 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
else
{
$sql = 'SELECT t.forum_id FROM ' . TOPICS_TABLE . ' t
- LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')
+ LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . phpbb::$user->data['user_id'] . ')
WHERE t.forum_id = ' . $forum_id . '
AND t.topic_last_post_time > ' . $mark_time_forum . '
AND t.topic_moved_id = 0
AND (tt.topic_id IS NULL OR tt.mark_time < t.topic_last_post_time)
GROUP BY t.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);
}
}
- else if (phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
+ else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->data['is_registered'])
{
// Get information from cookie
$row = false;
@@ -931,12 +913,12 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
WHERE forum_id = ' . $forum_id . '
AND topic_last_post_time > ' . $mark_time_forum . '
AND topic_moved_id = 0';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$check_forum = $tracking_topics['tf'][$forum_id];
$unread = false;
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (!isset($check_forum[base_convert($row['topic_id'], 10, 36)]))
{
@@ -944,7 +926,7 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
break;
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$row = $unread;
}
@@ -1092,12 +1074,12 @@ function tracking_unserialize($string, $max_depth = 3)
*/
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = false, $tpl_prefix = '')
{
- global $template, $user;
+ global $template;
// Make sure $per_page is a valid value
$per_page = ($per_page <= 0) ? 1 : $per_page;
- $seperator = '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
+ $seperator = '<span class="page-sep">' . phpbb::$user->lang['COMMA_SEPARATOR'] . '</span>';
$total_pages = ceil($num_items / $per_page);
if ($total_pages == 1 || !$num_items)
@@ -1148,12 +1130,12 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
{
if ($on_page != 1)
{
- $page_string = '<a href="' . $base_url . "{$url_delim}start=" . (($on_page - 2) * $per_page) . '">' . $user->lang['PREVIOUS'] . '</a>&nbsp;&nbsp;' . $page_string;
+ $page_string = '<a href="' . $base_url . "{$url_delim}start=" . (($on_page - 2) * $per_page) . '">' . phpbb::$user->lang['PREVIOUS'] . '</a>&nbsp;&nbsp;' . $page_string;
}
if ($on_page != $total_pages)
{
- $page_string .= '&nbsp;&nbsp;<a href="' . $base_url . "{$url_delim}start=" . ($on_page * $per_page) . '">' . $user->lang['NEXT'] . '</a>';
+ $page_string .= '&nbsp;&nbsp;<a href="' . $base_url . "{$url_delim}start=" . ($on_page * $per_page) . '">' . phpbb::$user->lang['NEXT'] . '</a>';
}
}
@@ -1175,7 +1157,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
*/
function on_page($num_items, $per_page, $start)
{
- global $template, $user;
+ global $template;
// Make sure $per_page is a valid value
$per_page = ($per_page <= 0) ? 1 : $per_page;
@@ -1186,7 +1168,7 @@ function on_page($num_items, $per_page, $start)
'ON_PAGE' => $on_page)
);
- return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1));
+ return phpbb::$user->lang('PAGE_OF', $on_page, max(ceil($num_items / $per_page), 1));
}
@@ -1200,11 +1182,11 @@ function on_page($num_items, $per_page, $start)
*/
function add_form_key($form_name)
{
- global $template, $user;
+ global $template;
$now = time();
- $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty(phpbb::$config['form_token_sid_guests'])) ? $user->session_id : '';
- $token = sha1($now . $user->data['user_form_salt'] . $form_name . $token_sid);
+ $token_sid = (phpbb::$user->data['user_id'] == ANONYMOUS && !empty(phpbb::$config['form_token_sid_guests'])) ? phpbb::$user->session_id : '';
+ $token = sha1($now . phpbb::$user->data['user_form_salt'] . $form_name . $token_sid);
$s_fields = build_hidden_fields(array(
'creation_time' => $now,
@@ -1225,8 +1207,6 @@ function add_form_key($form_name)
*/
function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false)
{
- global $user;
-
if ($timespan === false)
{
// we enforce a minimum value of half a minute here.
@@ -1243,8 +1223,8 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
// If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)...
if ($diff && ($diff <= $timespan || $timespan === -1))
{
- $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty(phpbb::$config['form_token_sid_guests'])) ? $user->session_id : '';
- $key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid);
+ $token_sid = (phpbb::$user->data['user_id'] == ANONYMOUS && !empty(phpbb::$config['form_token_sid_guests'])) ? phpbb::$user->session_id : '';
+ $key = sha1($creation_time . phpbb::$user->data['user_form_salt'] . $form_name . $token_sid);
if ($key === $token)
{
@@ -1255,7 +1235,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
if ($trigger)
{
- trigger_error($user->lang['FORM_INVALID'] . $return_page);
+ trigger_error(phpbb::$user->lang['FORM_INVALID'] . $return_page);
}
return false;
@@ -1276,7 +1256,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
*/
function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '')
{
- global $user, $template, $db;
+ global $template;
if (phpbb_request::is_set_post('cancel'))
{
@@ -1287,7 +1267,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
if (phpbb_request::is_set_post('confirm'))
{
// language frontier
- if (request_var('confirm', '') === $user->lang['YES'])
+ if (request_var('confirm', '') === phpbb::$user->lang['YES'])
{
$confirm = true;
}
@@ -1299,15 +1279,15 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
$session_id = request_var('sess', '');
$confirm_key = request_var('confirm_key', '');
- if ($user_id != $user->data['user_id'] || $session_id != $user->session_id || !$confirm_key || !$user->data['user_last_confirm_key'] || $confirm_key != $user->data['user_last_confirm_key'])
+ if ($user_id != phpbb::$user->data['user_id'] || $session_id != phpbb::$user->session_id || !$confirm_key || !phpbb::$user->data['user_last_confirm_key'] || $confirm_key != phpbb::$user->data['user_last_confirm_key'])
{
return false;
}
// Reset user_last_confirm_key
$sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = ''
- WHERE user_id = " . $user->data['user_id'];
- $db->sql_query($sql);
+ WHERE user_id = " . phpbb::$user->data['user_id'];
+ phpbb::$db->sql_query($sql);
return true;
}
@@ -1317,21 +1297,21 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
}
$s_hidden_fields = build_hidden_fields(array(
- 'user_id' => $user->data['user_id'],
- 'sess' => $user->session_id,
- 'sid' => $user->session_id)
- );
+ 'user_id' => phpbb::$user->data['user_id'],
+ 'sess' => phpbb::$user->session_id,
+ 'sid' => phpbb::$user->session_id,
+ ));
// generate activation key
$confirm_key = gen_rand_string(10);
- if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
+ if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin'])
{
- adm_page_header((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]);
+ adm_page_header((!isset(phpbb::$user->lang[$title])) ? phpbb::$user->lang['CONFIRM'] : phpbb::$user->lang[$title]);
}
else
{
- page_header((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]);
+ page_header((!isset(phpbb::$user->lang[$title])) ? phpbb::$user->lang['CONFIRM'] : phpbb::$user->lang[$title]);
}
$template->set_filenames(array(
@@ -1346,24 +1326,24 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
}
// re-add sid / transform & to &amp; for user->page (user->page is always using &)
- $use_page = ($u_action) ? PHPBB_ROOT_PATH . $u_action : PHPBB_ROOT_PATH . str_replace('&', '&amp;', $user->page['page']);
+ $use_page = ($u_action) ? PHPBB_ROOT_PATH . $u_action : PHPBB_ROOT_PATH . str_replace('&', '&amp;', phpbb::$user->page['page']);
$u_action = reapply_sid($use_page);
$u_action .= ((strpos($u_action, '?') === false) ? '?' : '&amp;') . 'confirm_key=' . $confirm_key;
$template->assign_vars(array(
- 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title],
- 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'],
+ 'MESSAGE_TITLE' => (!isset(phpbb::$user->lang[$title])) ? phpbb::$user->lang['CONFIRM'] : phpbb::$user->lang[$title],
+ 'MESSAGE_TEXT' => (!isset(phpbb::$user->lang[$title . '_CONFIRM'])) ? $title : phpbb::$user->lang[$title . '_CONFIRM'],
- 'YES_VALUE' => $user->lang['YES'],
+ 'YES_VALUE' => phpbb::$user->lang['YES'],
'S_CONFIRM_ACTION' => $u_action,
'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields)
);
- $sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = '" . $db->sql_escape($confirm_key) . "'
- WHERE user_id = " . $user->data['user_id'];
- $db->sql_query($sql);
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_last_confirm_key = '" . phpbb::$db->sql_escape($confirm_key) . "'
+ WHERE user_id = " . phpbb::$user->data['user_id'];
+ phpbb::$db->sql_query($sql);
- if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
+ if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin'])
{
adm_page_footer();
}
@@ -1378,16 +1358,16 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
*/
function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true)
{
- global $db, $user, $template, $auth;
+ global $template, $auth;
include(PHPBB_ROOT_PATH . 'includes/captcha/captcha_factory.' . PHP_EXT);
$err = '';
// Make sure user->setup() has been called
- if (empty($user->lang))
+ if (empty(phpbb::$user->lang))
{
- $user->setup();
+ phpbb::$user->setup();
}
if (defined('ADMIN_START'))
@@ -1402,7 +1382,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
{
// Not authd
// anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions
- if ($user->data['is_registered'])
+ if (phpbb::$user->data['is_registered'])
{
add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
}
@@ -1418,7 +1398,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32)
{
- if ($user->data['is_registered'])
+ if (phpbb::$user->data['is_registered'])
{
add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
}
@@ -1436,10 +1416,10 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
$autologin = phpbb_request::variable('autologin', false, false, phpbb_request::POST);
$viewonline = (phpbb_request::variable('viewonline', false, false, phpbb_request::POST)) ? 0 : 1;
$admin = ($admin) ? 1 : 0;
- $viewonline = ($admin) ? $user->data['session_viewonline'] : $viewonline;
+ $viewonline = ($admin) ? phpbb::$user->data['session_viewonline'] : $viewonline;
// Check if the supplied username is equal to the one stored within the database if re-authenticating
- if ($admin && utf8_clean_string($username) != utf8_clean_string($user->data['username']))
+ if ($admin && utf8_clean_string($username) != utf8_clean_string(phpbb::$user->data['username']))
{
// We log the attempt to use a different username...
add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
@@ -1447,7 +1427,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
}
// If authentication is successful we redirect user to previous page
- $result = $auth->login($username, $password, $autologin, $viewonline, $admin);
+ $result = phpbb::$user->login($username, $password, $autologin, $viewonline, $admin);
// If admin authentication and login, we will log if it was a success or not...
// We also break the operation on the first non-success login - it could be argued that the user already knows
@@ -1461,7 +1441,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
{
// Only log the failed attempt if a real user tried to.
// anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions
- if ($user->data['is_registered'])
+ if (phpbb::$user->data['is_registered'])
{
add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
}
@@ -1472,11 +1452,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
if ($result['status'] == LOGIN_SUCCESS)
{
$redirect = request_var('redirect', PHPBB_ROOT_PATH . 'index.' . PHP_EXT);
- $message = ($l_success) ? $l_success : $user->lang['LOGIN_REDIRECT'];
- $l_redirect = ($admin) ? $user->lang['PROCEED_TO_ACP'] : (($redirect === PHPBB_ROOT_PATH . 'index.' . PHP_EXT || $redirect === "index." . PHP_EXT) ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE']);
+ $message = ($l_success) ? $l_success : phpbb::$user->lang['LOGIN_REDIRECT'];
+ $l_redirect = ($admin) ? phpbb::$user->lang['PROCEED_TO_ACP'] : (($redirect === PHPBB_ROOT_PATH . 'index.' . PHP_EXT || $redirect === "index." . PHP_EXT) ? phpbb::$user->lang['RETURN_INDEX'] : phpbb::$user->lang['RETURN_PAGE']);
// append/replace SID (may change during the session for AOL users)
- $redirect = reapply_sid($redirect);
+ $redirect = phpbb::$url->reapply_sid($redirect);
// Special case... the user is effectively banned, but we allow founders to login
if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != phpbb::USER_FOUNDER)
@@ -1484,7 +1464,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
return;
}
- $redirect = meta_refresh(3, $redirect);
+ $redirect = phpbb::$url->meta_refresh(3, $redirect);
trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>'));
}
@@ -1508,13 +1488,13 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'CONFIRM' => $captcha->get_template(''),
));
- $err = $user->lang[$result['error_msg']];
+ $err = phpbb::$user->lang[$result['error_msg']];
break;
case LOGIN_ERROR_PASSWORD_CONVERT:
$err = sprintf(
- $user->lang[$result['error_msg']],
+ phpbb::$user->lang[$result['error_msg']],
(phpbb::$config['email_enable']) ? '<a href="' . append_sid('ucp', 'mode=sendpassword') . '">' : '',
(phpbb::$config['email_enable']) ? '</a>' : '',
(phpbb::$config['board_contact']) ? '<a href="mailto:' . utf8_htmlspecialchars(phpbb::$config['board_contact']) . '">' : '',
@@ -1524,12 +1504,12 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
// Username, password, etc...
default:
- $err = $user->lang[$result['error_msg']];
+ $err = phpbb::$user->lang[$result['error_msg']];
// Assign admin contact to some error messages
if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD')
{
- $err = (!phpbb::$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . utf8_htmlspecialchars(phpbb::$config['board_contact']) . '">', '</a>');
+ $err = (!phpbb::$config['board_contact']) ? sprintf(phpbb::$user->lang[$result['error_msg']], '', '') : sprintf(phpbb::$user->lang[$result['error_msg']], '<a href="mailto:' . utf8_htmlspecialchars(phpbb::$config['board_contact']) . '">', '</a>');
}
break;
@@ -1544,10 +1524,10 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
if (!$admin && !defined('ADMIN_START'))
{
- $redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '';
+ $redirect .= (phpbb::$user->page['page_dir']) ? phpbb::$user->page['page_dir'] . '/' : '';
}
- $redirect .= $user->page['page_name'] . (($user->page['query_string']) ? '?' . utf8_htmlspecialchars($user->page['query_string']) : '');
+ $redirect .= phpbb::$user->page['page_name'] . ((phpbb::$user->page['query_string']) ? '?' . utf8_htmlspecialchars(phpbb::$user->page['query_string']) : '');
}
// Assign credential for username/password pair
@@ -1555,7 +1535,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
$s_hidden_fields = array(
'redirect' => $redirect,
- 'sid' => $user->session_id,
+ 'sid' => phpbb::$user->session_id,
);
if ($admin)
@@ -1575,12 +1555,12 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'U_PRIVACY' => append_sid('ucp', 'mode=privacy'),
'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false,
- 'S_LOGIN_ACTION' => (!$admin && !defined('ADMIN_START')) ? append_sid('ucp', 'mode=login') : append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, false, true, $user->session_id),
+ 'S_LOGIN_ACTION' => (!$admin && !defined('ADMIN_START')) ? append_sid('ucp', 'mode=login') : append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, false, true, phpbb::$user->session_id),
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_ADMIN_AUTH' => $admin,
'S_ACP_LOGIN' => defined('ADMIN_START'),
- 'USERNAME' => ($admin) ? $user->data['username'] : '',
+ 'USERNAME' => ($admin) ? phpbb::$user->data['username'] : '',
'USERNAME_CREDENTIAL' => 'username',
'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password',
@@ -1592,22 +1572,22 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'body' => 'acp_login.html')
);
$template->assign_block_vars('t_block1', array(
- 'L_TITLE' => $user->lang['LOGIN'],
+ 'L_TITLE' => phpbb::$user->lang['LOGIN'],
'S_SELECTED' => true,
'U_TITLE' => '',
));
- adm_page_header($user->lang['LOGIN'], false);
+ adm_page_header(phpbb::$user->lang['LOGIN'], false);
}
else
{
$template->set_filenames(array(
'body' => 'login_body.html')
);
- page_header($user->lang['LOGIN'], false);
+ page_header(phpbb::$user->lang['LOGIN'], false);
}
make_jumpbox(append_sid('viewforum'));
- if (defined('ADMIN_START') && isset($user->data['session_admin']) && $user->data['session_admin'])
+ if (defined('ADMIN_START') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin'])
{
adm_page_footer();
}
@@ -1623,18 +1603,18 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
*/
function login_forum_box($forum_data)
{
- global $db, $user, $template;
+ global $template;
$password = request_var('password', '', true);
$sql = 'SELECT forum_id
FROM ' . FORUMS_ACCESS_TABLE . '
WHERE forum_id = ' . $forum_data['forum_id'] . '
- AND user_id = ' . $user->data['user_id'] . "
- AND session_id = '" . $db->sql_escape($user->session_id) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ AND user_id = ' . phpbb::$user->data['user_id'] . "
+ AND session_id = '" . phpbb::$db->sql_escape(phpbb::$user->session_id) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -1648,41 +1628,41 @@ function login_forum_box($forum_data)
FROM ' . FORUMS_ACCESS_TABLE . ' f
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (f.session_id = s.session_id)
WHERE s.session_id IS NULL';
- $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));
// Remove expired sessions
$sql = 'DELETE FROM ' . FORUMS_ACCESS_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);
if (phpbb_check_hash($password, $forum_data['forum_password']))
{
$sql_ary = array(
'forum_id' => (int) $forum_data['forum_id'],
- 'user_id' => (int) $user->data['user_id'],
- 'session_id' => (string) $user->session_id,
+ 'user_id' => (int) phpbb::$user->data['user_id'],
+ 'session_id' => (string) phpbb::$user->session_id,
);
- $db->sql_query('INSERT INTO ' . FORUMS_ACCESS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
+ phpbb::$db->sql_query('INSERT INTO ' . FORUMS_ACCESS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
return true;
}
- $template->assign_var('LOGIN_ERROR', $user->lang['WRONG_PASSWORD']);
+ $template->assign_var('LOGIN_ERROR', phpbb::$user->lang['WRONG_PASSWORD']);
}
- page_header($user->lang['LOGIN']);
+ page_header(phpbb::$user->lang['LOGIN']);
$template->assign_vars(array(
'S_HIDDEN_FIELDS' => build_hidden_fields(array('f' => $forum_data['forum_id'])))
@@ -1802,8 +1782,6 @@ function parse_cfg_file($filename, $lines = false)
*/
function add_log()
{
- global $db, $user;
-
$args = func_get_args();
$mode = array_shift($args);
@@ -1814,8 +1792,8 @@ function add_log()
$data = (!sizeof($args)) ? '' : serialize($args);
$sql_ary = array(
- 'user_id' => (empty($user->data)) ? ANONYMOUS : $user->data['user_id'],
- 'log_ip' => $user->ip,
+ 'user_id' => (empty(phpbb::$user->data)) ? ANONYMOUS : phpbb::$user->data['user_id'],
+ 'log_ip' => phpbb::$user->ip,
'log_time' => time(),
'log_operation' => $action,
'log_data' => $data,
@@ -1850,9 +1828,9 @@ function add_log()
return false;
}
- $db->sql_query('INSERT INTO ' . LOG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
+ phpbb::$db->sql_query('INSERT INTO ' . LOG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary));
- return $db->sql_nextid();
+ return phpbb::$db->sql_nextid();
}
/**
@@ -2217,25 +2195,25 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
define('IN_ERROR_HANDLER', true);
- if (empty($user->data))
+ if (empty(phpbb::$user->data))
{
- $user->session_begin();
+ phpbb::$user->session_begin();
}
// We re-init the auth array to get correct results on login/logout
- $auth->acl($user->data);
+ phpbb::$acl->init(phpbb::$user->data);
- if (empty($user->lang))
+ if (empty(phpbb::$user->lang))
{
- $user->setup();
+ phpbb::$user->setup();
}
- $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
- $msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title);
+ $msg_text = (!empty(phpbb::$user->lang[$msg_text])) ? phpbb::$user->lang[$msg_text] : $msg_text;
+ $msg_title = (!isset($msg_title)) ? phpbb::$user->lang['INFORMATION'] : ((!empty(phpbb::$user->lang[$msg_title])) ? phpbb::$user->lang[$msg_title] : $msg_title);
if (!defined('HEADER_INC'))
{
- if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']))
+ if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin']))
{
adm_page_header($msg_title);
}
@@ -2245,11 +2223,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
}
}
- $template->set_filenames(array(
+ phpbb::$template->set_filenames(array(
'body' => 'message_body.html')
);
- $template->assign_vars(array(
+ phpbb::$template->assign_vars(array(
'MESSAGE_TITLE' => $msg_title,
'MESSAGE_TEXT' => $msg_text,
'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false,
@@ -2259,7 +2237,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
// We do not want the cron script to be called on error messages
define('IN_CRON', true);
- if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']))
+ if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin']))
{
adm_page_footer();
}
@@ -2335,7 +2313,7 @@ function page_header($page_title = '', $display_online_list = true)
// Get number of online guests
if (!phpbb::$config['load_online_guests'])
{
- if (phpbb::$db->count_distinct)
+ if (phpbb::$db->features['count_distinct'])
{
$sql = 'SELECT COUNT(DISTINCT s.session_ip) as num_guests
FROM ' . SESSIONS_TABLE . ' s
@@ -2390,7 +2368,7 @@ function page_header($page_title = '', $display_online_list = true)
if (($row['session_viewonline']) || phpbb::$acl->acl_get('u_viewonline'))
{
- $user_online_link = get_username_string(($row['user_type'] <> USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']);
+ $user_online_link = get_username_string(($row['user_type'] <> phpbb::USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']);
$online_userlist[] = $user_online_link;
}
}
@@ -2502,7 +2480,7 @@ function page_header($page_title = '', $display_online_list = true)
'SITENAME' => phpbb::$config['sitename'],
'SITE_DESCRIPTION' => phpbb::$config['site_desc'],
'PAGE_TITLE' => $page_title,
- 'SCRIPT_NAME' => str_replace('.' . PHP_EXT, '', phpbb::$user->system['page']['page_name']),
+ 'SCRIPT_NAME' => str_replace('.' . PHP_EXT, '', phpbb::$user->page['page_name']),
'LAST_VISIT_DATE' => phpbb::$user->lang('YOU_LAST_VISIT', $s_last_visit),
'LAST_VISIT_YOU' => $s_last_visit,
'CURRENT_TIME' => phpbb::$user->lang('CURRENT_TIME', phpbb::$user->format_date(time(), false, true)),
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 89f2b831fb..856db6ebf6 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2287,11 +2287,9 @@ function cache_moderators()
*/
function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC')
{
- global $db, $user, $auth;
-
$topic_id_list = $reportee_id_list = $is_auth = $is_mod = array();
- $profile_url = (defined('IN_ADMIN')) ? append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'i=users&amp;mode=overview') : append_sid('memberlist', 'mode=viewprofile');
+ $profile_url = (defined('IN_ADMIN')) ? phpbb::$url->append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'i=users&amp;mode=overview') : phpbb::$url->append_sid('memberlist', 'mode=viewprofile');
switch ($mode)
{
@@ -2309,7 +2307,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
}
else if (is_array($forum_id))
{
- $sql_forum = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id));
+ $sql_forum = 'AND ' . phpbb::$db->sql_in_set('l.forum_id', array_map('intval', $forum_id));
}
else
{
@@ -2343,11 +2341,11 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
" . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . "
$sql_forum
ORDER BY $sort_by";
- $result = $db->sql_query_limit($sql, $limit, $offset);
+ $result = phpbb::$db->sql_query_limit($sql, $limit, $offset);
$i = 0;
$log = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if ($row['topic_id'])
{
@@ -2375,15 +2373,15 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
- 'viewforum' => ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? append_sid('viewforum', 'f=' . $row['forum_id']) : false,
- 'action' => (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}',
+ 'viewforum' => ($row['forum_id'] && phpbb::$acl->acl_get('f_read', $row['forum_id'])) ? phpbb::$url->append_sid('viewforum', 'f=' . $row['forum_id']) : false,
+ 'action' => (isset(phpbb::$user->lang[$row['log_operation']])) ? phpbb::$user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}',
);
if (!empty($row['log_data']))
{
$log_data_ary = unserialize($row['log_data']);
- if (isset($user->lang[$row['log_operation']]))
+ if (isset(phpbb::$user->lang[$row['log_operation']]))
{
// Check if there are more occurrences of % than arguments, if there are we fill out the arguments array
// It doesn't matter if we add more arguments than placeholders
@@ -2417,7 +2415,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$i++;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($topic_id_list))
{
@@ -2427,25 +2425,25 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
// although it's also used to determine if the topic still exists in the database
$sql = 'SELECT topic_id, forum_id
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', array_map('intval', $topic_id_list));
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', array_map('intval', $topic_id_list));
+ $result = phpbb::$db->sql_query($sql);
$default_forum_id = 0;
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (!$row['forum_id'])
{
- if ($auth->acl_getf_global('f_read'))
+ if (phpbb::$acl->acl_getf_global('f_read'))
{
if (!$default_forum_id)
{
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST;
- $f_result = $db->sql_query_limit($sql, 1);
- $default_forum_id = (int) $db->sql_fetchfield('forum_id', $f_result);
- $db->sql_freeresult($f_result);
+ $f_result = phpbb::$db->sql_query_limit($sql, 1);
+ $default_forum_id = (int) phpbb::$db->sql_fetchfield('forum_id', $f_result);
+ phpbb::$db->sql_freeresult($f_result);
}
$is_auth[$row['topic_id']] = $default_forum_id;
@@ -2453,23 +2451,23 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
}
else
{
- if ($auth->acl_get('f_read', $row['forum_id']))
+ if (phpbb::$acl->acl_get('f_read', $row['forum_id']))
{
$is_auth[$row['topic_id']] = $row['forum_id'];
}
}
- if ($auth->acl_gets('a_', 'm_', $row['forum_id']))
+ if (phpbb::$acl->acl_gets('a_', 'm_', $row['forum_id']))
{
$is_mod[$row['topic_id']] = $row['forum_id'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
foreach ($log as $key => $row)
{
- $log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? append_sid('viewtopic', 'f=' . $is_auth[$row['topic_id']] . '&amp;t=' . $row['topic_id']) : false;
- $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? append_sid('mcp', 'i=logs&amp;mode=topic_logs&amp;t=' . $row['topic_id'], true, $user->session_id) : false;
+ $log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? phpbb::$url->append_sid('viewtopic', 'f=' . $is_auth[$row['topic_id']] . '&amp;t=' . $row['topic_id']) : false;
+ $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? phpbb::$url->append_sid('mcp', 'i=logs&amp;mode=topic_logs&amp;t=' . $row['topic_id'], true, phpbb::$user->session_id) : false;
}
}
@@ -2480,14 +2478,14 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', $reportee_id_list);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $reportee_id_list);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$reportee_names_list[$row['user_id']] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
foreach ($log as $key => $row)
{
@@ -2506,9 +2504,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
WHERE l.log_type = $log_type
AND l.log_time >= $limit_days
$sql_forum";
- $result = $db->sql_query($sql);
- $log_count = (int) $db->sql_fetchfield('total_entries');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $log_count = (int) phpbb::$db->sql_fetchfield('total_entries');
+ phpbb::$db->sql_freeresult($result);
return;
}
@@ -2629,15 +2627,13 @@ function update_foes($group_id = false, $user_id = false)
*/
function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'user_inactive_time DESC')
{
- global $db, $user;
-
$sql = 'SELECT COUNT(user_id) AS user_count
FROM ' . USERS_TABLE . '
WHERE user_type = ' . phpbb::USER_INACTIVE .
(($limit_days) ? " AND user_inactive_time >= $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);
if ($offset >= $user_count)
{
@@ -2649,27 +2645,27 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li
WHERE user_type = ' . phpbb::USER_INACTIVE .
(($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . "
ORDER BY $sort_by";
- $result = $db->sql_query_limit($sql, $limit, $offset);
+ $result = phpbb::$db->sql_query_limit($sql, $limit, $offset);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
- $row['inactive_reason'] = $user->lang['INACTIVE_REASON_UNKNOWN'];
+ $row['inactive_reason'] = phpbb::$user->lang['INACTIVE_REASON_UNKNOWN'];
switch ($row['user_inactive_reason'])
{
case INACTIVE_REGISTER:
- $row['inactive_reason'] = $user->lang['INACTIVE_REASON_REGISTER'];
+ $row['inactive_reason'] = phpbb::$user->lang['INACTIVE_REASON_REGISTER'];
break;
case INACTIVE_PROFILE:
- $row['inactive_reason'] = $user->lang['INACTIVE_REASON_PROFILE'];
+ $row['inactive_reason'] = phpbb::$user->lang['INACTIVE_REASON_PROFILE'];
break;
case INACTIVE_MANUAL:
- $row['inactive_reason'] = $user->lang['INACTIVE_REASON_MANUAL'];
+ $row['inactive_reason'] = phpbb::$user->lang['INACTIVE_REASON_MANUAL'];
break;
case INACTIVE_REMIND:
- $row['inactive_reason'] = $user->lang['INACTIVE_REASON_REMIND'];
+ $row['inactive_reason'] = phpbb::$user->lang['INACTIVE_REASON_REMIND'];
break;
}
@@ -2711,18 +2707,18 @@ function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limi
*/
function get_database_size()
{
- global $db, $user, $table_prefix;
+ global $table_prefix;
$database_size = false;
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
- switch ($db->dbms_type)
+ switch (phpbb::$db->dbms_type)
{
case 'mysql':
$sql = 'SELECT VERSION() AS mysql_version';
- $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)
{
@@ -2730,14 +2726,14 @@ function get_database_size()
if (preg_match('#(3\.23|[45]\.)#', $version))
{
- $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->dbname}`" : $db->dbname;
+ $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`" . phpbb::$db->dbname . "`" : phpbb::$db->dbname;
$sql = 'SHOW TABLE STATUS
FROM ' . $db_name;
- $result = $db->sql_query($sql, 7200);
+ $result = phpbb::$db->sql_query($sql, 7200);
$database_size = 0;
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB')))
{
@@ -2754,7 +2750,7 @@ function get_database_size()
}
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
}
break;
@@ -2783,22 +2779,22 @@ function get_database_size()
case 'mssql':
$sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize
FROM sysfiles';
- $result = $db->sql_query($sql, 7200);
- $database_size = ($row = $db->sql_fetchrow($result)) ? $row['dbsize'] : false;
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql, 7200);
+ $database_size = ($row = phpbb::$db->sql_fetchrow($result)) ? $row['dbsize'] : false;
+ phpbb::$db->sql_freeresult($result);
break;
case 'postgres':
$sql = "SELECT proname
FROM pg_proc
WHERE proname = 'pg_database_size'";
- $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['proname'] == 'pg_database_size')
{
- $database = $db->dbname;
+ $database = phpbb::$db->dbname;
if (strpos($database, '.') !== false)
{
list($database, ) = explode('.', $database);
@@ -2807,16 +2803,16 @@ function get_database_size()
$sql = "SELECT oid
FROM pg_database
WHERE datname = '$database'";
- $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);
$oid = $row['oid'];
$sql = 'SELECT pg_database_size(' . $oid . ') as size';
- $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);
$database_size = $row['size'];
}
@@ -2825,13 +2821,13 @@ function get_database_size()
case 'oracle':
$sql = 'SELECT SUM(bytes) as dbsize
FROM user_segments';
- $result = $db->sql_query($sql, 7200);
- $database_size = ($row = $db->sql_fetchrow($result)) ? $row['dbsize'] : false;
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql, 7200);
+ $database_size = ($row = phpbb::$db->sql_fetchrow($result)) ? $row['dbsize'] : false;
+ phpbb::$db->sql_freeresult($result);
break;
}
- $database_size = ($database_size !== false) ? get_formatted_filesize($database_size) : $user->lang['NOT_AVAILABLE'];
+ $database_size = ($database_size !== false) ? get_formatted_filesize($database_size) : phpbb::$user->lang['NOT_AVAILABLE'];
return $database_size;
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 8933731648..ceb0d1a99a 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -323,7 +323,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
if ($subforum_row['display'] && $subforum_row['name'])
{
$subforums_list[] = array(
- 'link' => append_sid('viewforum', 'f=' . $subforum_id),
+ 'link' => phpbb::$url->append_sid('viewforum', 'f=' . $subforum_id),
'name' => $subforum_row['name'],
'unread' => $subforum_unread,
);
@@ -465,7 +465,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
phpbb::$template->assign_vars(array(
- 'U_MARK_FORUMS' => (phpbb::$user->is_registered || phpbb::$config['load_anon_lastread']) ? append_sid('viewforum', 'hash=' . phpbb::$security->hash_link('global') . '&amp;f=' . $root_data['forum_id'] . '&amp;mark=forums') : '',
+ 'U_MARK_FORUMS' => (phpbb::$user->is_registered || phpbb::$config['load_anon_lastread']) ? phpbb::$url->append_sid('viewforum', 'hash=' . generate_link_hash('global') . '&amp;f=' . $root_data['forum_id'] . '&amp;mark=forums') : '',
'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
'L_SUBFORUM' => phpbb::$user->lang('SUBFORUMS', $visible_forums),
'LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'))
@@ -538,7 +538,7 @@ function generate_forum_nav(&$forum_data)
'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false,
'FORUM_NAME' => $parent_name,
'FORUM_ID' => $parent_forum_id,
- 'U_VIEW_FORUM' => append_sid('viewforum', 'f=' . $parent_forum_id))
+ 'U_VIEW_FORUM' => phpbb::$url->append_sid('viewforum', 'f=' . $parent_forum_id))
);
}
}
@@ -549,7 +549,7 @@ function generate_forum_nav(&$forum_data)
'S_IS_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
'FORUM_NAME' => $forum_data['forum_name'],
'FORUM_ID' => $forum_data['forum_id'],
- 'U_VIEW_FORUM' => append_sid('viewforum', 'f=' . $forum_data['forum_id']))
+ 'U_VIEW_FORUM' => phpbb::$url->append_sid('viewforum', 'f=' . $forum_data['forum_id']))
);
$template->assign_vars(array(
@@ -999,8 +999,8 @@ function display_user_activity(&$userdata)
'ACTIVE_TOPIC' => censor_text($active_t_name),
'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct),
- 'U_ACTIVE_FORUM' => append_sid('viewforum', 'f=' . $active_f_id),
- 'U_ACTIVE_TOPIC' => append_sid('viewtopic', 't=' . $active_t_id),
+ 'U_ACTIVE_FORUM' => phpbb::$url->append_sid('viewforum', 'f=' . $active_f_id),
+ 'U_ACTIVE_TOPIC' => phpbb::$url->append_sid('viewtopic', 't=' . $active_t_id),
'S_SHOW_ACTIVITY' => true,
));
}
@@ -1043,7 +1043,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
$uid = request_var('uid', 0);
if ($uid != $user_id)
{
- $redirect_url = append_sid("view$mode", "$u_url=$match_id&amp;start=$start");
+ $redirect_url = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&amp;start=$start");
$message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
trigger_error($message);
}
@@ -1057,7 +1057,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
$db->sql_query($sql);
}
- $redirect_url = append_sid("view$mode", "$u_url=$match_id&amp;start=$start");
+ $redirect_url = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&amp;start=$start");
meta_refresh(3, $redirect_url);
@@ -1083,7 +1083,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
if (phpbb_request::is_set('watch', phpbb_request::GET))
{
$token = request_var('hash', '');
- $redirect_url = append_sid("view$mode", "$u_url=$match_id&amp;start=$start");
+ $redirect_url = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&amp;start=$start");
if (phpbb_request::variable('watch', '', false, phpbb_request::GET) == $mode && check_link_hash($token, "{$mode}_$match_id"))
{
@@ -1124,7 +1124,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
if ($can_watch)
{
- $s_watching['link'] = append_sid("view$mode", "$u_url=$match_id&amp;" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&amp;start=$start&amp;hash=" . generate_link_hash("{$mode}_$match_id"));
+ $s_watching['link'] = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&amp;" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&amp;start=$start&amp;hash=" . generate_link_hash("{$mode}_$match_id"));
$s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
$s_watching['is_watching'] = $is_watching;
}
diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php
index 9206febca6..c980840fa5 100644
--- a/phpBB/includes/functions_module.php
+++ b/phpBB/includes/functions_module.php
@@ -40,7 +40,7 @@ class p_master
*/
public function __construct($include_path = false)
{
- $this->include_path = ($include_path !== false) ? $include_path : PHPBB_ROOT_PATH . 'includes/';
+ $this->include_path = ($include_path !== false) ? $include_path : PHPBB_ROOT_PATH . 'modules/';
// Make sure the path ends with /
if (substr($this->include_path, -1) !== '/')
@@ -78,8 +78,6 @@ class p_master
*/
function list_modules($p_class)
{
- global $auth, $db, $user;
-
// Sanitise for future path use, it's escaped as appropriate for queries
$this->p_class = str_replace(array('.', '/', '\\'), '', basename($p_class));
@@ -89,16 +87,16 @@ class p_master
// Get modules
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "
- WHERE module_class = '" . $db->sql_escape($this->p_class) . "'
+ WHERE module_class = '" . phpbb::$db->sql_escape($this->p_class) . "'
ORDER BY left_id ASC";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$rows = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$rows[$row['module_id']] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$this->module_cache = array();
foreach ($rows as $module_id => $row)
@@ -243,7 +241,7 @@ class p_master
'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '',
- 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']),
+ 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : phpbb::$user->lang($row['module_langname']),
'langname' => $row['module_langname'],
'left' => $row['left_id'],
@@ -310,8 +308,6 @@ class p_master
*/
function module_auth($module_auth, $forum_id = false)
{
- global $auth;
-
$module_auth = trim($module_auth);
// Generally allowed to access module if module_auth is empty
@@ -358,7 +354,7 @@ class p_master
$forum_id = ($forum_id === false) ? $this->acl_forum_id : $forum_id;
$is_auth = false;
- eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z0-9_]+)(,\$id)?#', '#\$id#', '#aclf_([a-z0-9_]+)#', '#cfg_([a-z0-9_]+)#', '#request_([a-zA-Z0-9_]+)#'), array('(int) $auth->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) $auth->acl_getf_global(\'\\1\')', '(int) phpbb::$config[\'\\1\']', 'phpbb_request::variable(\'\\1\', false)'), $module_auth) . ');');
+ eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z0-9_]+)(,\$id)?#', '#\$id#', '#aclf_([a-z0-9_]+)#', '#cfg_([a-z0-9_]+)#', '#request_([a-zA-Z0-9_]+)#'), array('(int) phpbb::$acl->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) phpbb::$acl->acl_getf_global(\'\\1\')', '(int) phpbb::$config[\'\\1\']', 'phpbb_request::variable(\'\\1\', false)'), $module_auth) . ');');
return $is_auth;
}
@@ -426,8 +422,6 @@ class p_master
*/
function load_active($mode = false, $module_url = false, $execute_module = true)
{
- global $user;
-
$module_path = $this->include_path . $this->p_class;
$icat = request_var('icat', '');
@@ -471,7 +465,7 @@ class p_master
}
// Not being able to overwrite ;)
- $this->module->u_action = append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
+ $this->module->u_action = phpbb::$url->append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
}
else
{
@@ -482,10 +476,10 @@ class p_master
}
else
{
- $this->module->u_action = PHPBB_ROOT_PATH . (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'];
+ $this->module->u_action = PHPBB_ROOT_PATH . ((phpbb::$user->page['page_dir']) ? phpbb::$user->page['page_dir'] . '/' : '') . phpbb::$user->page['page_name'];
}
- $this->module->u_action = append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
+ $this->module->u_action = phpbb::$url->append_sid($this->module->u_action, "i={$this->p_name}") . (($icat) ? '&amp;icat=' . $icat : '') . "&amp;mode={$this->p_mode}";
}
// Add url_extra parameter to u_action url
@@ -560,8 +554,6 @@ class p_master
*/
function get_parents($parent_id, $left_id, $right_id, &$all_parents)
{
- global $db;
-
$parents = array();
if ($parent_id > 0)
@@ -646,8 +638,6 @@ class p_master
*/
function assign_tpl_vars($module_url)
{
- global $template;
-
$current_id = $right_id = false;
// Make sure the module_url has a question mark set, effectively determining the delimiter to use
@@ -747,7 +737,7 @@ class p_master
'U_TITLE' => $u_title
);
- $template->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
+ phpbb::$template->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
}
$tpl_ary = array(
@@ -756,7 +746,7 @@ class p_master
'U_TITLE' => $u_title
);
- $template->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
+ phpbb::$template->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
$current_depth = $depth;
}
@@ -775,14 +765,12 @@ class p_master
*/
function get_page_title()
{
- global $user;
-
if (!isset($this->module->page_title))
{
return '';
}
- return (isset($user->lang[$this->module->page_title])) ? $user->lang[$this->module->page_title] : $this->module->page_title;
+ return phpbb::$user->lang($this->module->page_title);
}
/**
@@ -804,10 +792,8 @@ class p_master
*/
function display($page_title, $display_online_list = true)
{
- global $template, $user;
-
// Generate the page
- if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
+ if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin'])
{
adm_page_header($page_title);
}
@@ -816,11 +802,11 @@ class p_master
page_header($page_title, $display_online_list);
}
- $template->set_filenames(array(
+ phpbb::$template->set_filenames(array(
'body' => $this->get_tpl_name())
);
- if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
+ if (defined('IN_ADMIN') && isset(phpbb::$user->data['session_admin']) && phpbb::$user->data['session_admin'])
{
adm_page_footer();
}
@@ -849,13 +835,11 @@ class p_master
*/
function add_mod_info($module_class)
{
- global $user;
-
- if (file_exists($user->lang_path . $user->lang_name . '/mods'))
+ if (file_exists(phpbb::$user->lang_path . phpbb::$user->lang_name . '/mods'))
{
$add_files = array();
- $dir = @opendir($user->lang_path . $user->lang_name . '/mods');
+ $dir = @opendir(phpbb::$user->lang_path . phpbb::$user->lang_name . '/mods');
if ($dir)
{
@@ -871,7 +855,7 @@ class p_master
if (sizeof($add_files))
{
- $user->add_lang($add_files);
+ phpbb::$user->add_lang($add_files);
}
}
}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index f4afd31780..fb9c5002d6 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -26,8 +26,6 @@ if (!defined('IN_PHPBB'))
*/
function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false)
{
- global $db;
-
// Are both arrays already filled? Yep, return else
// are neither array filled?
if ($user_id_ary && $username_ary)
@@ -55,18 +53,18 @@ function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false)
$sql_where = ($which_ary == 'user_id_ary') ? 'user_id' : 'username_clean';
$sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set($sql_where, $sql_in);
+ WHERE ' . phpbb::$db->sql_in_set($sql_where, $sql_in);
if ($user_type !== false && !empty($user_type))
{
- $sql .= ' AND ' . $db->sql_in_set('user_type', $user_type);
+ $sql .= ' AND ' . phpbb::$db->sql_in_set('user_type', $user_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)))
{
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return 'NO_USERS';
}
@@ -75,8 +73,8 @@ function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false)
$username_ary[$row['user_id']] = $row['username'];
$user_id_ary[] = $row['user_id'];
}
- while ($row = $db->sql_fetchrow($result));
- $db->sql_freeresult($result);
+ while ($row = phpbb::$db->sql_fetchrow($result));
+ phpbb::$db->sql_freeresult($result);
return false;
}
@@ -86,16 +84,14 @@ function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false)
*/
function update_last_username()
{
- global $db;
-
// Get latest username
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '
WHERE user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
ORDER BY user_id DESC';
- $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 ($row)
{
@@ -113,8 +109,6 @@ function update_last_username()
*/
function user_update_name($old_name, $new_name)
{
- global $db;
-
$update_ary = array(
FORUMS_TABLE => array('forum_last_poster_name'),
MODERATOR_CACHE_TABLE => array('username'),
@@ -127,9 +121,9 @@ function user_update_name($old_name, $new_name)
foreach ($field_ary as $field)
{
$sql = "UPDATE $table
- SET $field = '" . $db->sql_escape($new_name) . "'
- WHERE $field = '" . $db->sql_escape($old_name) . "'";
- $db->sql_query($sql);
+ SET $field = '" . phpbb::$db->sql_escape($new_name) . "'
+ WHERE $field = '" . phpbb::$db->sql_escape($old_name) . "'";
+ phpbb::$db->sql_query($sql);
}
}
@@ -151,8 +145,6 @@ function user_update_name($old_name, $new_name)
*/
function user_add($user_row, $cp_data = false)
{
- global $db, $user, $auth;
-
if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type']))
{
return false;
@@ -223,7 +215,7 @@ function user_add($user_row, $cp_data = false)
'user_sig_bbcode_uid' => '',
'user_sig_bbcode_bitfield' => '',
- 'user_form_salt' => unique_id(),
+ 'user_form_salt' => phpbb::$security->unique_id(),
);
// Now fill the sql array with not required variables
@@ -244,10 +236,10 @@ function user_add($user_row, $cp_data = false)
}
}
- $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
- $db->sql_query($sql);
+ $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
+ phpbb::$db->sql_query($sql);
- $user_id = $db->sql_nextid();
+ $user_id = phpbb::$db->sql_nextid();
// Insert Custom Profile Fields
if ($cp_data !== false && sizeof($cp_data))
@@ -256,21 +248,21 @@ function user_add($user_row, $cp_data = false)
if (!class_exists('custom_profile'))
{
- include_once(PHPBB_ROOT_PATH . 'includes/functions_profile_fields.' . PHP_EXT);
+ include_once PHPBB_ROOT_PATH . 'includes/functions_profile_fields.' . PHP_EXT;
}
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' .
- $db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));
- $db->sql_query($sql);
+ phpbb::$db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));
+ phpbb::$db->sql_query($sql);
}
// Place into appropriate group...
- $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ $sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'user_id' => (int) $user_id,
'group_id' => (int) $user_row['group_id'],
'user_pending' => 0)
);
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// Now make it the users default group...
group_set_user_default($user_row['group_id'], array($user_id), false);
@@ -285,9 +277,9 @@ function user_add($user_row, $cp_data = false)
$sql = 'SELECT group_colour
FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . (int) $user_row['group_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);
set_config('newest_user_colour', $row['group_colour'], true);
}
@@ -300,14 +292,14 @@ function user_add($user_row, $cp_data = false)
*/
function user_delete($mode, $user_id, $post_username = false)
{
- global $db, $user, $auth;
+ global $user, $auth;
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
- $result = $db->sql_query($sql);
- $user_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $user_row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if (!$user_row)
{
@@ -319,15 +311,15 @@ function user_delete($mode, $user_id, $post_username = false)
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
WHERE r.user_id = ' . $user_id . '
AND p.post_id = r.post_id';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$report_posts = $report_topics = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$report_posts[] = $row['post_id'];
$report_topics[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($report_posts))
{
@@ -337,17 +329,17 @@ function user_delete($mode, $user_id, $post_username = false)
// Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $report_topics) . '
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $report_topics) . '
AND post_reported = 1
- AND ' . $db->sql_in_set('post_id', $report_posts, true);
- $result = $db->sql_query($sql);
+ AND ' . phpbb::$db->sql_in_set('post_id', $report_posts, true);
+ $result = phpbb::$db->sql_query($sql);
$keep_report_topics = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$keep_report_topics[] = $row['topic_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($keep_report_topics))
{
@@ -358,20 +350,20 @@ function user_delete($mode, $user_id, $post_username = false)
// Now set the flags back
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0
- WHERE ' . $db->sql_in_set('post_id', $report_posts);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('post_id', $report_posts);
+ phpbb::$db->sql_query($sql);
if (sizeof($report_topics))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
- WHERE ' . $db->sql_in_set('topic_id', $report_topics);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $report_topics);
+ phpbb::$db->sql_query($sql);
}
}
// Remove reports
- $db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE user_id = ' . $user_id);
+ phpbb::$db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE user_id = ' . $user_id);
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == AVATAR_UPLOAD)
{
@@ -382,7 +374,7 @@ function user_delete($mode, $user_id, $post_username = false)
{
case 'retain':
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
if ($post_username === false)
{
@@ -396,29 +388,29 @@ function user_delete($mode, $user_id, $post_username = false)
else
{
$sql = 'UPDATE ' . FORUMS_TABLE . '
- SET forum_last_poster_id = ' . ANONYMOUS . ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "', forum_last_poster_colour = ''
+ SET forum_last_poster_id = ' . ANONYMOUS . ", forum_last_poster_name = '" . phpbb::$db->sql_escape($post_username) . "', forum_last_poster_colour = ''
WHERE forum_last_poster_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
- SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "'
+ SET poster_id = ' . ANONYMOUS . ", post_username = '" . phpbb::$db->sql_escape($post_username) . "'
WHERE poster_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_edit_user = ' . ANONYMOUS . "
WHERE post_edit_user = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
- SET topic_poster = ' . ANONYMOUS . ", topic_first_poster_name = '" . $db->sql_escape($post_username) . "', topic_first_poster_colour = ''
+ SET topic_poster = ' . ANONYMOUS . ", topic_first_poster_name = '" . phpbb::$db->sql_escape($post_username) . "', topic_first_poster_colour = ''
WHERE topic_poster = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
- SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "', topic_last_poster_colour = ''
+ SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . phpbb::$db->sql_escape($post_username) . "', topic_last_poster_colour = ''
WHERE topic_last_poster_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// Since we change every post by this author, we need to count this amount towards the anonymous user
@@ -428,11 +420,11 @@ function user_delete($mode, $user_id, $post_username = false)
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + ' . $user_row['user_posts'] . '
WHERE user_id = ' . ANONYMOUS;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
}
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
break;
@@ -447,37 +439,37 @@ function user_delete($mode, $user_id, $post_username = false)
FROM ' . POSTS_TABLE . "
WHERE poster_id = $user_id
GROUP BY topic_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']] = $row['total_posts'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($topic_id_ary))
{
$sql = 'SELECT topic_id, topic_replies, topic_replies_real
FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', array_keys($topic_id_ary));
+ $result = phpbb::$db->sql_query($sql);
$del_topic_ary = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']])
{
$del_topic_ary[] = $row['topic_id'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($del_topic_ary))
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $del_topic_ary);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('topic_id', $del_topic_ary);
+ phpbb::$db->sql_query($sql);
}
}
@@ -487,7 +479,7 @@ function user_delete($mode, $user_id, $post_username = false)
break;
}
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
$table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE);
@@ -495,7 +487,7 @@ function user_delete($mode, $user_id, $post_username = false)
{
$sql = "DELETE FROM $table
WHERE user_id = $user_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE);
@@ -505,43 +497,43 @@ function user_delete($mode, $user_id, $post_username = false)
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
AND folder_id = ' . PRIVMSGS_NO_BOX;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$undelivered_msg = $undelivered_user = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$undelivered_msg[] = $row['msg_id'];
$undelivered_user[$row['user_id']][] = true;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($undelivered_msg))
{
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('msg_id', $undelivered_msg);
+ phpbb::$db->sql_query($sql);
}
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
AND folder_id = ' . PRIVMSGS_NO_BOX;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// Delete all to-information
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . $user_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// Set the remaining author id to anonymous - this way users are still able to read messages from users being removed
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET author_id = ' . ANONYMOUS . '
WHERE author_id = ' . $user_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET author_id = ' . ANONYMOUS . '
WHERE author_id = ' . $user_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
foreach ($undelivered_user as $_user_id => $ary)
{
@@ -554,10 +546,10 @@ function user_delete($mode, $user_id, $post_username = false)
SET user_new_privmsg = user_new_privmsg - ' . sizeof($ary) . ',
user_unread_privmsg = user_unread_privmsg - ' . sizeof($ary) . '
WHERE user_id = ' . $_user_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
// Reset newest user info if appropriate
if (phpbb::$config['newest_user_id'] == $user_id)
@@ -581,7 +573,7 @@ function user_delete($mode, $user_id, $post_username = false)
*/
function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
{
- global $db, $user, $auth;
+ global $user, $auth;
$deactivated = $activated = 0;
$sql_statements = array();
@@ -598,10 +590,10 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
$sql = 'SELECT user_id, group_id, user_type, user_inactive_reason
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id_ary);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$sql_ary = array();
@@ -632,16 +624,16 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
$sql_statements[$row['user_id']] = $sql_ary;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($sql_statements))
{
foreach ($sql_statements as $user_id => $sql_ary)
{
$sql = 'UPDATE ' . USERS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_id;
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
$auth->acl_clear_prefetch(array_keys($sql_statements));
@@ -674,13 +666,13 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
*/
function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason = '')
{
- global $db, $user, $auth;
+ global $user, $auth;
// Delete stale bans
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
WHERE ban_end < ' . time() . '
AND ban_end <> 0';
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
$ban_list = (!is_array($ban)) ? array_unique(explode("\n", $ban)) : $ban;
$ban_list_log = implode(', ', $ban_list);
@@ -721,14 +713,14 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
$sql = 'SELECT user_id, user_email, username_clean
FROM ' . USERS_TABLE . '
WHERE user_type = ' . 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))
{
$founder[$row['user_id']] = $row['user_email'];
$founder_names[$row['user_id']] = $row['username_clean'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
$banlist_ary = array();
@@ -769,34 +761,34 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('username_clean', $sql_usernames);
+ WHERE ' . phpbb::$db->sql_in_set('username_clean', $sql_usernames);
// Do not allow banning yourself
if (sizeof($founder))
{
- $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), array($user->data['user_id'])), true);
+ $sql .= ' AND ' . phpbb::$db->sql_in_set('user_id', array_merge(array_keys($founder), array($user->data['user_id'])), true);
}
else
{
$sql .= ' AND user_id <> ' . $user->data['user_id'];
}
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
- if ($row = $db->sql_fetchrow($result))
+ if ($row = phpbb::$db->sql_fetchrow($result))
{
do
{
$banlist_ary[] = (int) $row['user_id'];
}
- while ($row = $db->sql_fetchrow($result));
+ while ($row = phpbb::$db->sql_fetchrow($result));
}
else
{
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
trigger_error('NO_USERS');
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
break;
case 'ip':
@@ -939,12 +931,12 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
FROM " . BANLIST_TABLE . "
WHERE $sql_where
AND ban_exclude = " . (int) $ban_exclude;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
// Reset $sql_where, because we use it later...
$sql_where = '';
- if ($row = $db->sql_fetchrow($result))
+ if ($row = phpbb::$db->sql_fetchrow($result))
{
$banlist_ary_tmp = array();
do
@@ -964,12 +956,12 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
break;
}
}
- while ($row = $db->sql_fetchrow($result));
+ while ($row = phpbb::$db->sql_fetchrow($result));
$banlist_ary = array_unique(array_diff($banlist_ary, $banlist_ary_tmp));
unset($banlist_ary_tmp);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// We have some entities to ban
if (sizeof($banlist_ary))
@@ -988,7 +980,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
);
}
- $db->sql_multi_insert(BANLIST_TABLE, $sql_ary);
+ phpbb::$db->sql_multi_insert(BANLIST_TABLE, $sql_ary);
// If we are banning we want to logout anyone matching the ban
if (!$ban_exclude)
@@ -996,11 +988,11 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
switch ($mode)
{
case 'user':
- $sql_where = 'WHERE ' . $db->sql_in_set('session_user_id', $banlist_ary);
+ $sql_where = 'WHERE ' . phpbb::$db->sql_in_set('session_user_id', $banlist_ary);
break;
case 'ip':
- $sql_where = 'WHERE ' . $db->sql_in_set('session_ip', $banlist_ary);
+ $sql_where = 'WHERE ' . phpbb::$db->sql_in_set('session_ip', $banlist_ary);
break;
case 'email':
@@ -1013,22 +1005,22 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_email', $banlist_ary_sql);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_email', $banlist_ary_sql);
+ $result = phpbb::$db->sql_query($sql);
$sql_in = array();
- if ($row = $db->sql_fetchrow($result))
+ if ($row = phpbb::$db->sql_fetchrow($result))
{
do
{
$sql_in[] = $row['user_id'];
}
- while ($row = $db->sql_fetchrow($result));
+ while ($row = phpbb::$db->sql_fetchrow($result));
- $sql_where = 'WHERE ' . $db->sql_in_set('session_user_id', $sql_in);
+ $sql_where = 'WHERE ' . phpbb::$db->sql_in_set('session_user_id', $sql_in);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
break;
}
@@ -1036,12 +1028,12 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
{
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
$sql_where";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
if ($mode == 'user')
{
- $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' ' . ((in_array('*', $banlist_ary)) ? '' : 'WHERE ' . $db->sql_in_set('user_id', $banlist_ary));
- $db->sql_query($sql);
+ $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' ' . ((in_array('*', $banlist_ary)) ? '' : 'WHERE ' . phpbb::$db->sql_in_set('user_id', $banlist_ary));
+ phpbb::$db->sql_query($sql);
}
}
}
@@ -1069,13 +1061,13 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
*/
function user_unban($mode, $ban)
{
- global $db, $user, $auth;
+ global $user, $auth;
// Delete stale bans
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
WHERE ban_end < ' . time() . '
AND ban_end <> 0';
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
if (!is_array($ban))
{
@@ -1092,34 +1084,34 @@ function user_unban($mode, $ban)
case 'user':
$sql = 'SELECT u.username AS unban_info
FROM ' . USERS_TABLE . ' u, ' . BANLIST_TABLE . ' b
- WHERE ' . $db->sql_in_set('b.ban_id', $unban_sql) . '
+ WHERE ' . phpbb::$db->sql_in_set('b.ban_id', $unban_sql) . '
AND u.user_id = b.ban_userid';
break;
case 'email':
$sql = 'SELECT ban_email AS unban_info
FROM ' . BANLIST_TABLE . '
- WHERE ' . $db->sql_in_set('ban_id', $unban_sql);
+ WHERE ' . phpbb::$db->sql_in_set('ban_id', $unban_sql);
break;
case 'ip':
$sql = 'SELECT ban_ip AS unban_info
FROM ' . BANLIST_TABLE . '
- WHERE ' . $db->sql_in_set('ban_id', $unban_sql);
+ WHERE ' . phpbb::$db->sql_in_set('ban_id', $unban_sql);
break;
}
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$l_unban_list = '';
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$l_unban_list .= (($l_unban_list != '') ? ', ' : '') . $row['unban_info'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
- WHERE ' . $db->sql_in_set('ban_id', $unban_sql);
- $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('ban_id', $unban_sql);
+ phpbb::$db->sql_query($sql);
// Add to moderator and admin log
add_log('admin', 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list);
@@ -1344,7 +1336,7 @@ function validate_match($string, $optional = false, $match = '')
*/
function validate_username($username, $allowed_username = false)
{
- global $db, $user;
+ global $user;
$clean_username = utf8_clean_string($username);
$allowed_username = ($allowed_username === false) ? $user->data['username_clean'] : utf8_clean_string($allowed_username);
@@ -1398,10 +1390,10 @@ function validate_username($username, $allowed_username = false)
$sql = 'SELECT username
FROM ' . USERS_TABLE . "
- WHERE username_clean = '" . $db->sql_escape($clean_username) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE username_clean = '" . phpbb::$db->sql_escape($clean_username) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -1410,10 +1402,10 @@ function validate_username($username, $allowed_username = false)
$sql = 'SELECT group_name
FROM ' . GROUPS_TABLE . "
- WHERE group_name = '" . $db->sql_escape($clean_username) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE group_name = '" . phpbb::$db->sql_escape($clean_username) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -1440,7 +1432,7 @@ function validate_username($username, $allowed_username = false)
*/
function validate_password($password)
{
- global $db, $user;
+ global $user;
if (!$password)
{
@@ -1510,7 +1502,7 @@ function validate_password($password)
*/
function validate_email($email, $allowed_email = false)
{
- global $db, $user;
+ global $user;
$email = strtolower($email);
$allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email);
@@ -1547,9 +1539,9 @@ function validate_email($email, $allowed_email = false)
$sql = 'SELECT user_email_hash
FROM ' . USERS_TABLE . "
WHERE user_email_hash = " . hexdec(crc32($email) . strlen($email));
- $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)
{
@@ -1768,7 +1760,7 @@ function validate_jabber($jid)
*/
function avatar_delete($mode, $row, $clean_db = false)
{
- global $db, $user;
+ global $user;
// Check if the users avatar is actually *not* a group avatar
if ($mode == 'user')
@@ -1798,7 +1790,7 @@ function avatar_delete($mode, $row, $clean_db = false)
*/
function avatar_remote($data, &$error)
{
- global $db, $user;
+ global $user;
if (!preg_match('#^(http|https|ftp)://#i', $data['remotelink']))
{
@@ -1876,7 +1868,7 @@ function avatar_remote($data, &$error)
*/
function avatar_upload($data, &$error)
{
- global $db, $user;
+ global $user;
// Init upload class
include_once(PHPBB_ROOT_PATH . 'includes/functions_upload.' . PHP_EXT);
@@ -2101,7 +2093,7 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $
*/
function avatar_process_user(&$error, $custom_userdata = false)
{
- global $auth, $user, $db;
+ global $auth, $user;
$data = array(
'uploadurl' => request_var('uploadurl', ''),
@@ -2242,9 +2234,9 @@ function avatar_process_user(&$error, $custom_userdata = false)
}
$sql = 'UPDATE ' . USERS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (($custom_userdata === false) ? $user->data['user_id'] : $custom_userdata['user_id']);
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
}
@@ -2262,7 +2254,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
*/
function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false)
{
- global $db, $user, $file_upload;
+ global $user, $file_upload;
$error = array();
$attribute_ary = array(
@@ -2341,13 +2333,13 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
WHERE group_id = ' . $group_id;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$user_ary[] = $row['user_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (isset($sql_ary['group_avatar']) && !$sql_ary['group_avatar'])
{
@@ -2359,25 +2351,25 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
}
$sql = 'UPDATE ' . GROUPS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . "
WHERE group_id = $group_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// Since we may update the name too, we need to do this on other tables too...
$sql = 'UPDATE ' . MODERATOR_CACHE_TABLE . "
- SET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "'
+ SET group_name = '" . phpbb::$db->sql_escape($sql_ary['group_name']) . "'
WHERE group_id = $group_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
else
{
- $sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
- $db->sql_query($sql);
+ $sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary);
+ phpbb::$db->sql_query($sql);
}
if (!$group_id)
{
- $group_id = $db->sql_nextid();
+ $group_id = phpbb::$db->sql_nextid();
if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == AVATAR_UPLOAD)
{
group_correct_avatar($group_id, $sql_ary['group_avatar']);
@@ -2423,8 +2415,6 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
*/
function group_correct_avatar($group_id, $old_entry)
{
- global $db;
-
$group_id = (int)$group_id;
$ext = substr(strrchr($old_entry, '.'), 1);
$old_filename = get_avatar_filename($old_entry);
@@ -2435,9 +2425,9 @@ function group_correct_avatar($group_id, $old_entry)
if (@rename($avatar_path . '/'. $old_filename, $avatar_path . '/' . $new_filename))
{
$sql = 'UPDATE ' . GROUPS_TABLE . '
- SET group_avatar = \'' . $db->sql_escape($new_entry) . "'
+ SET group_avatar = \'' . phpbb::$db->sql_escape($new_entry) . "'
WHERE group_id = $group_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
}
@@ -2447,13 +2437,11 @@ function group_correct_avatar($group_id, $old_entry)
*/
function avatar_remove_db($avatar_name)
{
- global $db;
-
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_avatar = '',
user_avatar_type = 0
- WHERE user_avatar = '" . $db->sql_escape($avatar_name) . '\'';
- $db->sql_query($sql);
+ WHERE user_avatar = '" . phpbb::$db->sql_escape($avatar_name) . '\'';
+ phpbb::$db->sql_query($sql);
}
@@ -2462,8 +2450,6 @@ function avatar_remove_db($avatar_name)
*/
function group_delete($group_id, $group_name = false)
{
- global $db;
-
if (!$group_name)
{
$group_name = get_group_name($group_id);
@@ -2480,9 +2466,9 @@ function group_delete($group_id, $group_name = false)
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . " u
WHERE ug.group_id = $group_id
AND u.user_id = ug.user_id";
- $result = $db->sql_query_limit($sql, 200, $start);
+ $result = phpbb::$db->sql_query_limit($sql, 200, $start);
- if ($row = $db->sql_fetchrow($result))
+ if ($row = phpbb::$db->sql_fetchrow($result))
{
do
{
@@ -2491,7 +2477,7 @@ function group_delete($group_id, $group_name = false)
$start++;
}
- while ($row = $db->sql_fetchrow($result));
+ while ($row = phpbb::$db->sql_fetchrow($result));
group_user_del($group_id, $user_id_ary, $username_ary, $group_name);
}
@@ -2499,19 +2485,19 @@ function group_delete($group_id, $group_name = false)
{
$start = 0;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
while ($start);
// Delete group
$sql = 'DELETE FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// Delete auth entries from the groups table
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "
WHERE group_id = $group_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
// Re-cache moderators
if (!function_exists('cache_moderators'))
@@ -2534,7 +2520,7 @@ function group_delete($group_id, $group_name = false)
*/
function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false)
{
- global $db, $auth;
+ global $auth;
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);
@@ -2547,12 +2533,12 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
// Remove users who are already members of this group
$sql = 'SELECT user_id, group_leader
FROM ' . USER_GROUP_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . "
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id_ary) . "
AND group_id = $group_id";
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$add_id_ary = $update_id_ary = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$add_id_ary[] = (int) $row['user_id'];
@@ -2561,7 +2547,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
$update_id_ary[] = (int) $row['user_id'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Do all the users exist in this group?
$add_id_ary = array_diff($user_id_ary, $add_id_ary);
@@ -2572,7 +2558,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
return 'GROUP_USERS_EXIST';
}
- $db->sql_transaction('begin');
+ phpbb::$db->sql_transaction('begin');
// Insert the new users
if (sizeof($add_id_ary))
@@ -2589,16 +2575,16 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
);
}
- $db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary);
+ phpbb::$db->sql_multi_insert(USER_GROUP_TABLE, $sql_ary);
}
if (sizeof($update_id_ary))
{
$sql = 'UPDATE ' . USER_GROUP_TABLE . '
SET group_leader = 1
- WHERE ' . $db->sql_in_set('user_id', $update_id_ary) . "
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $update_id_ary) . "
AND group_id = $group_id";
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
if ($default)
@@ -2606,7 +2592,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
group_set_user_default($group_id, $user_id_ary, $group_attributes);
}
- $db->sql_transaction('commit');
+ phpbb::$db->sql_transaction('commit');
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
@@ -2635,7 +2621,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
*/
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
{
- global $db, $auth;
+ global $auth;
$group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS');
@@ -2651,11 +2637,11 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
$sql = 'SELECT *
FROM ' . GROUPS_TABLE . '
- WHERE ' . $db->sql_in_set('group_name_clean', $clean_group_order);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('group_name_clean', $clean_group_order);
+ $result = phpbb::$db->sql_query($sql);
$group_order_id = $special_group_data = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$group_order_id[$row['group_name']] = $row['group_id'];
@@ -2675,40 +2661,40 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
);
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// Get users default groups - we only need to reset default group membership if the group from which the user gets removed is set as default
$sql = 'SELECT user_id, group_id
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id_ary);
+ $result = phpbb::$db->sql_query($sql);
$default_groups = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$default_groups[$row['user_id']] = $row['group_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
// What special group memberships exist for these users?
$sql = 'SELECT g.group_id, g.group_name_clean, ug.user_id
FROM ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g
- WHERE ' . $db->sql_in_set('ug.user_id', $user_id_ary) . "
+ WHERE ' . phpbb::$db->sql_in_set('ug.user_id', $user_id_ary) . "
AND g.group_id = ug.group_id
AND g.group_id <> $group_id
AND g.group_type = " . GROUP_SPECIAL . '
ORDER BY ug.user_id, g.group_id';
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
$temp_ary = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if ($default_groups[$row['user_id']] == $group_id && (!isset($temp_ary[$row['user_id']]) || array_search($row['group_name_clean'], $clean_group_order) < $temp_ary[$row['user_id']]))
{
$temp_ary[$row['user_id']] = $row['group_id'];
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql_where_ary = array();
foreach ($temp_ary as $uid => $gid)
@@ -2730,8 +2716,8 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
$sql = 'DELETE FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
- AND " . $db->sql_in_set('user_id', $user_id_ary);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('user_id', $user_id_ary);
+ phpbb::$db->sql_query($sql);
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
@@ -2757,8 +2743,6 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
*/
function remove_default_avatar($group_id, $user_ids)
{
- global $db;
-
if (!is_array($user_ids))
{
$user_ids = array($user_ids);
@@ -2773,13 +2757,13 @@ function remove_default_avatar($group_id, $user_ids)
$sql = 'SELECT *
FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . (int)$group_id;
- $result = $db->sql_query($sql);
- if (!$row = $db->sql_fetchrow($result))
+ $result = phpbb::$db->sql_query($sql);
+ if (!$row = phpbb::$db->sql_fetchrow($result))
{
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return false;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_avatar = '',
@@ -2787,10 +2771,10 @@ function remove_default_avatar($group_id, $user_ids)
user_avatar_width = 0,
user_avatar_height = 0
WHERE group_id = " . (int) $group_id . "
- AND user_avatar = '" . $db->sql_escape($row['group_avatar']) . "'
- AND " . $db->sql_in_set('user_id', $user_ids);
+ AND user_avatar = '" . phpbb::$db->sql_escape($row['group_avatar']) . "'
+ AND " . phpbb::$db->sql_in_set('user_id', $user_ids);
- $db->sql_query($sql);
+ phpbb::$db->sql_query($sql);
}
/**
@@ -2798,8 +2782,6 @@ function remove_default_avatar($group_id, $user_ids)
*/
function remove_default_rank($group_id, $user_ids)
{
- global $db;
-
if (!is_array($user_ids))
{
$user_ids = array($user_ids);
@@ -2814,21 +2796,21 @@ function remove_default_rank($group_id, $user_ids)
$sql = 'SELECT *
FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . (int)$group_id;
- $result = $db->sql_query($sql);
- if (!$row = $db->sql_fetchrow($result))
+ $result = phpbb::$db->sql_query($sql);
+ if (!$row = phpbb::$db->sql_fetchrow($result))
{
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return false;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_rank = 0
WHERE group_id = ' . (int)$group_id . '
AND user_rank <> 0
AND user_rank = ' . (int)$row['group_rank'] . '
- AND ' . $db->sql_in_set('user_id', $user_ids);
- $db->sql_query($sql);
+ AND ' . phpbb::$db->sql_in_set('user_id', $user_ids);
+ phpbb::$db->sql_query($sql);
}
/**
@@ -2836,7 +2818,7 @@ function remove_default_rank($group_id, $user_ids)
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
- global $db, $auth;
+ global $auth;
// We need both username and user_id info
$result = user_get_id_name($user_id_ary, $username_ary);
@@ -2859,10 +2841,10 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
$sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
AND user_pending = 1
- AND " . $db->sql_in_set('user_id', $user_id_ary);
- $result = $db->sql_query_limit($sql, 1);
- $not_empty = ($db->sql_fetchrow($result));
- $db->sql_freeresult($result);
+ AND " . phpbb::$db->sql_in_set('user_id', $user_id_ary);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $not_empty = (phpbb::$db->sql_fetchrow($result));
+ phpbb::$db->sql_freeresult($result);
if ($not_empty)
{
return 'NO_VALID_USERS';
@@ -2872,8 +2854,8 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
SET group_leader = ' . (($action == 'promote') ? 1 : 0) . "
WHERE group_id = $group_id
AND user_pending = 0
- AND " . $db->sql_in_set('user_id', $user_id_ary);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('user_id', $user_id_ary);
+ phpbb::$db->sql_query($sql);
$log = ($action == 'promote') ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
break;
@@ -2885,16 +2867,16 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
WHERE ug.group_id = ' . $group_id . '
AND ug.user_pending = 1
AND ug.user_id = u.user_id
- AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
- $result = $db->sql_query($sql);
+ AND ' . phpbb::$db->sql_in_set('ug.user_id', $user_id_ary);
+ $result = phpbb::$db->sql_query($sql);
$user_id_ary = $email_users = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$user_id_ary[] = $row['user_id'];
$email_users[] = $row;
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (!sizeof($user_id_ary))
{
@@ -2904,8 +2886,8 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
$sql = 'UPDATE ' . USER_GROUP_TABLE . "
SET user_pending = 0
WHERE group_id = $group_id
- AND " . $db->sql_in_set('user_id', $user_id_ary);
- $db->sql_query($sql);
+ AND " . phpbb::$db->sql_in_set('user_id', $user_id_ary);
+ phpbb::$db->sql_query($sql);
// Send approved email to users...
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);
@@ -2934,11 +2916,11 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
case 'default':
$sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
- $result = $db->sql_query($sql);
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id_ary, false, true);
+ $result = phpbb::$db->sql_query($sql);
$groups = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
if (!isset($groups[$row['group_id']]))
{
@@ -2946,7 +2928,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
}
$groups[$row['group_id']][] = $row['user_id'];
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
foreach ($groups as $gid => $uids)
{
@@ -2973,8 +2955,6 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
*/
function group_validate_groupname($group_id, $group_name)
{
- global $db;
-
$group_name = utf8_clean_string($group_name);
if (!empty($group_id))
@@ -2982,9 +2962,9 @@ function group_validate_groupname($group_id, $group_name)
$sql = 'SELECT group_name_clean
FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . (int) $group_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)
{
@@ -3001,10 +2981,10 @@ function group_validate_groupname($group_id, $group_name)
$sql = 'SELECT group_name
FROM ' . GROUPS_TABLE . "
- WHERE group_name_clean = '" . $db->sql_escape(utf8_clean_string($group_name)) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE group_name_clean = '" . phpbb::$db->sql_escape(utf8_clean_string($group_name)) . "'";
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
if ($row)
{
@@ -3021,8 +3001,6 @@ function group_validate_groupname($group_id, $group_name)
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
{
- global $db;
-
if (empty($user_id_ary))
{
return;
@@ -3047,9 +3025,9 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
$sql = 'SELECT ' . implode(', ', array_keys($attribute_ary)) . '
FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id";
- $result = $db->sql_query($sql);
- $group_attributes = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $group_attributes = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
}
foreach ($attribute_ary as $attribute => $type)
@@ -3073,15 +3051,15 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
// Ok, get the original avatar data from users having an uploaded one (we need to remove these from the filesystem)
$sql = 'SELECT user_id, group_id, user_avatar
FROM ' . USERS_TABLE . '
- WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . '
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id_ary) . '
AND user_avatar_type = ' . AVATAR_UPLOAD;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
avatar_delete('user', $row);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
else
{
@@ -3090,24 +3068,24 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
unset($sql_ary['user_avatar_width']);
}
- $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
- WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
- $db->sql_query($sql);
+ $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE ' . phpbb::$db->sql_in_set('user_id', $user_id_ary);
+ phpbb::$db->sql_query($sql);
if (isset($sql_ary['user_colour']))
{
// Update any cached colour information for these users
- $sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'
- WHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary);
- $db->sql_query($sql);
+ $sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_last_poster_colour = '" . phpbb::$db->sql_escape($sql_ary['user_colour']) . "'
+ WHERE " . phpbb::$db->sql_in_set('forum_last_poster_id', $user_id_ary);
+ phpbb::$db->sql_query($sql);
- $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'
- WHERE " . $db->sql_in_set('topic_poster', $user_id_ary);
- $db->sql_query($sql);
+ $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_first_poster_colour = '" . phpbb::$db->sql_escape($sql_ary['user_colour']) . "'
+ WHERE " . phpbb::$db->sql_in_set('topic_poster', $user_id_ary);
+ phpbb::$db->sql_query($sql);
- $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'
- WHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary);
- $db->sql_query($sql);
+ $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_poster_colour = '" . phpbb::$db->sql_escape($sql_ary['user_colour']) . "'
+ WHERE " . phpbb::$db->sql_in_set('topic_last_poster_id', $user_id_ary);
+ phpbb::$db->sql_query($sql);
if (in_array(phpbb::$config['newest_user_id'], $user_id_ary))
{
@@ -3126,14 +3104,14 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
*/
function get_group_name($group_id)
{
- global $db, $user;
+ global $user;
$sql = 'SELECT group_name, group_type
FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . (int) $group_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)
{
@@ -3151,8 +3129,6 @@ function get_group_name($group_id)
*/
function group_memberships($group_id_ary = false, $user_id_ary = false, $return_bool = false)
{
- global $db;
-
if (!$group_id_ary && !$user_id_ary)
{
return true;
@@ -3175,22 +3151,22 @@ function group_memberships($group_id_ary = false, $user_id_ary = false, $return_
if ($group_id_ary)
{
- $sql .= ' ' . $db->sql_in_set('ug.group_id', $group_id_ary);
+ $sql .= ' ' . phpbb::$db->sql_in_set('ug.group_id', $group_id_ary);
}
if ($user_id_ary)
{
$sql .= ($group_id_ary) ? ' AND ' : ' ';
- $sql .= $db->sql_in_set('ug.user_id', $user_id_ary);
+ $sql .= phpbb::$db->sql_in_set('ug.user_id', $user_id_ary);
}
- $result = ($return_bool) ? $db->sql_query_limit($sql, 1) : $db->sql_query($sql);
+ $result = ($return_bool) ? phpbb::$db->sql_query_limit($sql, 1) : phpbb::$db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
+ $row = phpbb::$db->sql_fetchrow($result);
if ($return_bool)
{
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return ($row) ? true : false;
}
@@ -3205,9 +3181,9 @@ function group_memberships($group_id_ary = false, $user_id_ary = false, $return_
{
$return[] = $row;
}
- while ($row = $db->sql_fetchrow($result));
+ while ($row = phpbb::$db->sql_fetchrow($result));
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
return $return;
}