Fix $db and config vars

This commit is contained in:
Visman 2017-01-07 12:31:24 +07:00
parent 7ba2287c71
commit 3bd5693039
20 changed files with 133 additions and 70 deletions

View file

@ -361,7 +361,7 @@ else if (isset($_GET['find_ban']))
$conditions[] = 'b.expire<'.$expire_before;
}
$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
$like_command = ($container->getParameter('DB_TYPE') == 'pgsql') ? 'ILIKE' : 'LIKE';
foreach ($form as $key => $input)
{
if ($input != '' && in_array($key, array('username', 'ip', 'email', 'message')))

View file

@ -45,7 +45,7 @@ if ($action == 'rebuild')
$db->truncate_table('search_words') or error('Unable to empty search index words table', __FILE__, __LINE__, $db->error());
// Reset the sequence for the search words (not needed for SQLite)
switch ($db_type)
switch ($container->getParameter('DB_TYPE'))
{
case 'mysql':
case 'mysqli':

View file

@ -66,7 +66,7 @@ $num_online = $db->result($result);
// Collect some additional info about MySQL
if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
if (in_array($container->getParameter('DB_TYPE'), ['mysql', 'mysqli', 'mysql_innodb', 'mysqli_innodb']))
{
// Calculate total db size/row count
$result = $db->query('SHOW TABLE STATUS LIKE \''.$db->prefix.'%\'') or error('Unable to fetch table status', __FILE__, __LINE__, $db->error());

View file

@ -789,7 +789,7 @@ else if (isset($_GET['find_user']))
$conditions[] = 'u.registered<'.$registered_before;
}
$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
$like_command = ($container->getParameter('DB_TYPE') == 'pgsql') ? 'ILIKE' : 'LIKE';
foreach ($form as $key => $input)
{
if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'gender', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note'))) // мод пола - Visman

View file

@ -16,6 +16,7 @@ return [
'COOKIE_SALT' => '_COOKIE_SALT_',
'ALGO_FOR_HMAC' => 'sha1',
'SALT1' => '',
'JQUERY_LINK' => '//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js',
'shared' => [
'Request' => \ForkBB\Core\Request::class,
'DBLoader' => [

View file

@ -664,6 +664,7 @@ switch ($stage)
if (! isset($pun_config['i_fork_revision']) || $pun_config['i_fork_revision'] < 1) {
if (! isset($pun_config['i_fork_revision'])) {
$db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'i_fork_revision\', \'0\')') or error('Unable to insert config value \'i_fork_revision\'', __FILE__, __LINE__, $db->error());
$pun_config['i_fork_revision'] = 1;
}
if (! isset($pun_config['s_fork_version'])) {
$db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'s_fork_version\', \'0\')') or error('Unable to insert config value \'s_fork_version\'', __FILE__, __LINE__, $db->error());

View file

@ -146,7 +146,7 @@ else if ($footer_style == 'viewtopic')
<?php
// End the transaction
$db->end_transaction();
$container->get('DB')->end_transaction();
// Display debug info (if enabled/defined)
if (defined('PUN_DEBUG'))
@ -155,7 +155,7 @@ if (defined('PUN_DEBUG'))
// Calculate script generation time
$time_diff = sprintf('%.3f', microtime(true) - (empty($_SERVER['REQUEST_TIME_FLOAT']) ? $pun_start : $_SERVER['REQUEST_TIME_FLOAT']));
echo sprintf($lang_common['Querytime'], $time_diff, $db->get_num_queries());
echo sprintf($lang_common['Querytime'], $time_diff, $container->get('DB')->get_num_queries());
if (function_exists('memory_get_usage'))
{
@ -178,7 +178,7 @@ ob_end_clean();
// END SUBST - <pun_footer>
// Close the db connection (and free up any result data)
$db->close();
$container->get('DB')->close();
if (isset($page_js))
$tpl_main = str_replace('<!-- forum_javascript -->', generation_js($page_js), $tpl_main);

View file

@ -16,7 +16,9 @@ if (!defined('PUN'))
//
function generate_config_cache()
{
global $db;
global $container;
$db = $container->get('DB');
// Get the forum config from the DB
$result = $db->query('SELECT * FROM '.$db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error());
@ -36,7 +38,9 @@ function generate_config_cache()
//
function generate_bans_cache()
{
global $db;
global $container;
$db = $container->get('DB');
// Get the ban list from the DB
$result = $db->query('SELECT * FROM '.$db->prefix.'bans', true) or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error());
@ -56,7 +60,9 @@ function generate_bans_cache()
//
function generate_quickjump_cache($group_id = false)
{
global $db, $lang_common;
global $container, $lang_common;
$db = $container->get('DB');
$groups = array();
@ -142,7 +148,9 @@ function generate_quickjump_cache($group_id = false)
//
function generate_censoring_cache()
{
global $db;
global $container;
$db = $container->get('DB');
$result = $db->query('SELECT search_for, replace_with FROM '.$db->prefix.'censoring') or error('Unable to fetch censoring list', __FILE__, __LINE__, $db->error());
$num_words = $db->num_rows($result);
@ -193,7 +201,9 @@ function generate_stopwords_cache()
//
function generate_users_info_cache()
{
global $db;
global $container;
$db = $container->get('DB');
$stats = array();
@ -214,7 +224,9 @@ function generate_users_info_cache()
//
function generate_admins_cache()
{
global $db;
global $container;
$db = $container->get('DB');
// Get admins from the DB
$result = $db->query('SELECT id FROM '.$db->prefix.'users WHERE group_id='.PUN_ADMIN) or error('Unable to fetch users info', __FILE__, __LINE__, $db->error());
@ -273,7 +285,9 @@ function clear_feed_cache()
//
function generate_smiley_cache()
{
global $db;
global $container;
$db = $container->get('DB');
$str = '<?php'."\n".'$smilies = array('."\n";
@ -324,7 +338,9 @@ function generate_subforums_asc(&$list, $tree, $node = array(0))
function generate_subforums_cache($group_id = false)
{
global $db;
global $container;
$db = $container->get('DB');
$groups = array();

View file

@ -64,10 +64,6 @@ require PUN_ROOT . 'app/bootstrap.php';
// The addon manager is responsible for storing the hook listeners and communicating with the addons
$flux_addons = new flux_addon_manager();
// If a cookie name is not specified in config.php, we use the default (pun_cookie)
if (empty($cookie_name))
$cookie_name = 'pun_cookie';
// If the cache directory is not specified, we use the default setting
if (!defined('FORUM_CACHE_DIR'))
define('FORUM_CACHE_DIR', PUN_ROOT.'cache/');
@ -79,8 +75,7 @@ define('PUN_MOD', 2);
define('PUN_GUEST', 3);
define('PUN_MEMBER', 4);
// Load DB abstraction layer and connect
require PUN_ROOT.'include/dblayer/common_db.php';
$db = $container->get('DB');
// Start a transaction
$db->start_transaction();

View file

@ -134,7 +134,9 @@ function generate_admin_menu($page = '')
//
function prune($forum_id, $prune_sticky, $prune_date)
{
global $db;
global $container;
$db = $container->get('DB');
$extra_sql = ($prune_date != -1) ? ' AND last_post<'.$prune_date : '';

View file

@ -12,7 +12,11 @@
//
function check_cookie(&$pun_user)
{
global $db, $db_type, $pun_config, $cookie_name, $cookie_seed;
global $container, $pun_config;
$db = $container->get('DB');
$cookie_name = $container->getParameter('COOKIE_PREFIX');
$cookie_seed = $container->getParameter('COOKIE_SALT');
$now = time();
@ -93,7 +97,7 @@ function check_cookie(&$pun_user)
$pun_user['logged'] = $now;
// With MySQL/MySQLi/SQLite, REPLACE INTO avoids a user having two rows in the online table
switch ($db_type)
switch ($container->getParameter('DB_TYPE'))
{
case 'mysql':
case 'mysqli':
@ -160,7 +164,9 @@ function escape_cdata($str)
//
function authenticate_user($user, $password, $password_is_hash = false)
{
global $db, $pun_user;
global $container, $pun_user;
$db = $container->get('DB');
// Check if there's a user matching $user and $password
$result = $db->query('SELECT u.*, g.*, o.logged, o.idle FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON o.user_id=u.id WHERE '.(is_int($user) ? 'u.id='.intval($user) : 'u.username=\''.$db->escape($user).'\'')) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
@ -270,7 +276,11 @@ function get_admin_ids()
//
function set_default_user()
{
global $db, $db_type, $pun_user, $pun_config, $cookie_name, $languages;
global $container, $pun_user, $pun_config, $languages;
$db = $container->get('DB');
$cookie_name = $container->getParameter('COOKIE_PREFIX');
$remote_addr = get_remote_address();
@ -293,7 +303,7 @@ function set_default_user()
$pun_user['logged'] = time();
// With MySQL/MySQLi/SQLite, REPLACE INTO avoids a user having two rows in the online table
switch ($db_type)
switch ($container->getParameter('DB_TYPE'))
{
case 'mysql':
case 'mysqli':
@ -374,7 +384,10 @@ function forum_hmac($data, $key, $raw_output = false)
//
function pun_setcookie($user_id, $password_hash, $expire)
{
global $cookie_name, $cookie_seed;
global $container;
$cookie_name = $container->getParameter('COOKIE_PREFIX');
$cookie_seed = $container->getParameter('COOKIE_SALT');
forum_setcookie($cookie_name, $user_id.'|'.forum_hmac($password_hash, $cookie_seed.'_password_hash').'|'.$expire.'|'.forum_hmac($user_id.'|'.$expire, $cookie_seed.'_cookie_hash'), $expire);
}
@ -385,7 +398,11 @@ function pun_setcookie($user_id, $password_hash, $expire)
//
function forum_setcookie($name, $value, $expire)
{
global $cookie_path, $cookie_domain, $cookie_secure, $pun_config;
global $container, $pun_config;
$cookie_path = $container->getParameter('COOKIE_PATH');
$cookie_domain = $container->getParameter('COOKIE_DOMAIN');
$cookie_secure = $container->getParameter('COOKIE_SECURE');
if ($expire - time() - $pun_config['o_timeout_visit'] < 1)
$expire = 0;
@ -405,7 +422,9 @@ function forum_setcookie($name, $value, $expire)
//
function check_bans()
{
global $db, $pun_config, $lang_common, $pun_user, $pun_bans;
global $container, $pun_config, $lang_common, $pun_user, $pun_bans;
$db = $container->get('DB');
// Admins and moderators aren't affected
if ($pun_user['is_admmod'] || !$pun_bans)
@ -476,7 +495,9 @@ function check_bans()
//
function check_username($username, $exclude_id = null)
{
global $db, $pun_config, $errors, $lang_prof_reg, $lang_register, $lang_common, $pun_bans;
global $container, $pun_config, $errors, $lang_prof_reg, $lang_register, $lang_common, $pun_bans;
$db = $container->get('DB');
// Include UTF-8 function
require_once PUN_ROOT.'include/utf8/strcasecmp.php';
@ -532,7 +553,9 @@ function check_username($username, $exclude_id = null)
// ф-ия переписана - Visman
function update_users_online($tid = 0, &$witt_us = array())
{
global $db, $pun_config, $onl_u, $onl_g, $onl_s;
global $container, $pun_config, $onl_u, $onl_g, $onl_s;
$db = $container->get('DB');
$now = time();
$nn1 = $now-$pun_config['o_timeout_online'];
@ -685,7 +708,9 @@ function generate_page_title($page_title, $p = null)
//
function set_tracked_topics($tracked_topics)
{
global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $pun_config;
global $container, $pun_config;
$cookie_name = $container->getParameter('COOKIE_PREFIX');
$cookie_data = '';
if (!empty($tracked_topics))
@ -718,7 +743,9 @@ function set_tracked_topics($tracked_topics)
//
function get_tracked_topics()
{
global $cookie_name;
global $container;
$cookie_name = $container->getParameter('COOKIE_PREFIX');
$cookie_data = isset($_COOKIE[$cookie_name.'_track']) ? $_COOKIE[$cookie_name.'_track'] : false;
if (!$cookie_data)
@ -759,7 +786,9 @@ function flux_hook($name)
//
function update_forum($forum_id)
{
global $db;
global $container;
$db = $container->get('DB');
$result = $db->query('SELECT COUNT(id), SUM(num_replies) FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id) or error('Unable to fetch forum topic count', __FILE__, __LINE__, $db->error());
list($num_topics, $num_posts) = $db->fetch_row($result);
@ -801,7 +830,9 @@ function delete_avatar($user_id)
//
function delete_topic($topic_id, $flag_f = 1) // not sum - Visman
{
global $db;
global $container;
$db = $container->get('DB');
// Delete the topic and any redirect topics
$db->query('DELETE FROM '.$db->prefix.'topics WHERE id='.$topic_id.' OR moved_to='.$topic_id) or error('Unable to delete topic', __FILE__, __LINE__, $db->error());
@ -848,7 +879,9 @@ function delete_topic($topic_id, $flag_f = 1) // not sum - Visman
//
function delete_post($post_id, $topic_id)
{
global $db;
global $container;
$db = $container->get('DB');
$result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id.' ORDER BY id DESC LIMIT 2') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
list($last_id, ,) = $db->fetch_row($result);
@ -901,7 +934,6 @@ function forum_clear_cache()
//
function censor_words($text)
{
global $db;
static $search_for, $replace_with;
// If not already built in a previous call, build an array of censor words and their replacement text
@ -1031,7 +1063,7 @@ function paginate($num_pages, $cur_page, $link)
//
function message($message, $no_back_link = false, $http_status = null)
{
global $db, $lang_common, $pun_config, $pun_start, $tpl_main, $pun_user, $page_js;
global $container, $lang_common, $pun_config, $pun_start, $tpl_main, $pun_user, $page_js;
witt_query(); // MOD Кто в этой теме - Visman
@ -1420,7 +1452,7 @@ function array_insert(&$input, $offset, $element, $key = null)
//
function maintenance_message()
{
global $db, $pun_config, $lang_common, $pun_user;
global $container, $pun_config, $lang_common, $pun_user;
// Send no-cache headers
header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
@ -1518,11 +1550,11 @@ function maintenance_message()
// End the transaction
$db->end_transaction();
$container->get('DB')->end_transaction();
// Close the db connection (and free up any result data)
$db->close();
$container->get('DB')->close();
exit($tpl_maint);
}
@ -1533,7 +1565,7 @@ function maintenance_message()
//
function redirect($destination_url, $message)
{
global $db, $pun_config, $lang_common, $pun_user;
global $container, $pun_config, $lang_common, $pun_user;
// Prefix with base_url (unless there's already a valid URI)
if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_url, '/') !== 0)
@ -1545,8 +1577,8 @@ function redirect($destination_url, $message)
// If the delay is 0 seconds, we might as well skip the redirect all together
if ($pun_config['o_redirect_delay'] == '0')
{
$db->end_transaction();
$db->close();
$container->get('DB')->end_transaction();
$container->get('DB')->close();
header('Location: '.str_replace('&amp;', '&', $destination_url));
exit;
@ -1647,7 +1679,7 @@ function redirect($destination_url, $message)
ob_start();
// End the transaction
$db->end_transaction();
$container->get('DB')->end_transaction();
// Display executed queries (if enabled)
if (defined('PUN_SHOW_QUERIES'))
@ -1660,7 +1692,7 @@ function redirect($destination_url, $message)
// Close the db connection (and free up any result data)
$db->close();
$container->get('DB')->close();
exit($tpl_redir);
}
@ -2251,10 +2283,10 @@ function forum_is_writable($path)
//
function display_saved_queries()
{
global $db, $lang_common;
global $container, $lang_common;
// Get the queries so that we can print them out
$saved_queries = $db->get_saved_queries();
$saved_queries = $container->get('DB')->get_saved_queries();
?>
@ -2326,9 +2358,11 @@ function dump()
//
function generation_js($arr)
{
global $container;
$res = '';
if (!empty($arr['j']))
$res.= '<script type="text/javascript" src="'.FORUM_AJAX_JQUERY.'"></script>'."\n";
$res.= '<script type="text/javascript" src="'.$container->getParameter('JQUERY_LINK').'"></script>'."\n";
if (!empty($arr['f']))
$res.= '<script type="text/javascript" src="'.implode('"></script>'."\n".'<script type="text/javascript" src="', $arr['f']).'"></script>'."\n";
if (!empty($arr['c']))
@ -2344,9 +2378,11 @@ function generation_js($arr)
//
function witt_query($var = NULL)
{
global $db;
global $container;
static $query;
$db = $container->get('DB');
if (!defined('WITT_ENABLE'))
{
if (is_string($var))

View file

@ -84,7 +84,9 @@ function generate_pmsn_menu($page = '')
function pmsn_user_update($user, $flag = false)
{
global $db, $db_type;
global $container;
$db = $container->get('DB');
$mkol = $mnew = 0;
$result = $db->query('SELECT id, starter_id, topic_st, topic_to FROM '.$db->prefix.'pms_new_topics WHERE (starter_id='.$user.' AND topic_st<2) OR (to_id='.$user.' AND topic_to<2)') or error('Unable to fetch pms topics IDs', __FILE__, __LINE__, $db->error());
@ -104,7 +106,9 @@ function pmsn_user_update($user, $flag = false)
function pmsn_user_delete($user, $mflag, $topics = array())
{
global $db, $db_type;
global $container;
$db = $container->get('DB');
$user_up = array($user);
$tf_st = $tf_to = $tm_st = $tm_to = array();

View file

@ -56,7 +56,9 @@ function poll_bad()
// может ли голосовать юзер ****************************************************
function poll_can_vote($tid, $uid)
{
global $db, $cur_topic;
global $container, $cur_topic;
$db = $container->get('DB');
if (is_null($uid) || $uid < 2) return false;
if (isset($cur_topic['closed']) && $cur_topic['closed'] != '0') return false;
@ -68,7 +70,9 @@ function poll_can_vote($tid, $uid)
// получение информации по опросу **********************************************
function poll_info($tid, $uid = null)
{
global $db;
global $container;
$db = $container->get('DB');
if ($tid == 0) return null;
@ -410,7 +414,9 @@ function poll_cache_delete($tid)
// удаление опроса *************************************************************
function poll_delete($tid, $flag = false)
{
global $db;
global $container;
$db = $container->get('DB');
$db->query('DELETE FROM '.$db->prefix.'poll WHERE tid='.$tid) or error('Unable to remove poll', __FILE__, __LINE__, $db->error());
$db->query('DELETE FROM '.$db->prefix.'poll_voted WHERE tid='.$tid) or error('Unable to remove poll_voted', __FILE__, __LINE__, $db->error());
@ -423,7 +429,9 @@ function poll_delete($tid, $flag = false)
// сохраняем опрос *************************************************************
function poll_save($tid)
{
global $db, $pun_config;
global $container, $pun_config;
$db = $container->get('DB');
if (poll_bad() || poll_noedit($tid)) return;
@ -595,7 +603,7 @@ function poll_display_post($tid, $uid)
function poll_display($tid, $uid, $info, $top, $prev = false)
{
global $db, $lang_poll, $pun_config, $lang_common;
global $lang_poll, $pun_config, $lang_common;
if (is_null($info)) return;
@ -727,7 +735,9 @@ function poll_display($tid, $uid, $info, $top, $prev = false)
// голосуем ********************************************************************
function poll_vote($tid, $uid)
{
global $db;
global $container;
$db = $container->get('DB');
if (poll_bad() || !poll_can_vote($tid, $uid)) poll_mess('Err1');

View file

@ -247,7 +247,6 @@ function update_search_index($mode, $post_id, $message, $subject = null)
global $container;
$db = $container->get('DB');
$db_type = $container->getParameter('DB_TYPE');
$message = utf8_strtolower($message);
$subject = utf8_strtolower($subject);
@ -309,7 +308,7 @@ function update_search_index($mode, $post_id, $message, $subject = null)
if (!empty($new_words))
{
switch ($db_type)
switch ($container->getParameter('DB_TYPE'))
{
case 'mysql':
case 'mysqli':
@ -364,9 +363,8 @@ function strip_search_index($post_ids)
global $container;
$db = $container->get('DB');
$db_type = $container->getParameter('DB_TYPE');
switch ($db_type)
switch ($container->getParameter('DB_TYPE'))
{
case 'mysql':
case 'mysqli':

View file

@ -153,7 +153,7 @@ else
$page_js['f']['collapse'] = 'js/collapse.js';
$page_js['c'][] = 'if (typeof FluxBB === \'undefined\' || !FluxBB) {var FluxBB = {};}
FluxBB.vars = {
collapse_cookieid: "'.$cookie_name.'_",
collapse_cookieid: "'.$container->getParameter('COOKIE_PREFIX').'",
collapse_folder: "'.(file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/exp_down.png') ? 'style/'.$pun_user['style'].'/' : 'img/').'"
};
FluxBB.collapse.init();';

View file

@ -27,7 +27,7 @@ if (isset($_POST['form_sent']) && $action == 'in')
$form_password = pun_trim($_POST['req_password']);
$save_pass = isset($_POST['save_pass']);
$username_sql = ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') ? 'username=\''.$db->escape($form_username).'\'' : 'LOWER(username)=LOWER(\''.$db->escape($form_username).'\')';
$username_sql = in_array($container->getParameter('DB_TYPE'), ['mysql', 'mysqli', 'mysql_innodb', 'mysqli_innodb']) ? 'username=\''.$db->escape($form_username).'\'' : 'LOWER(username)=LOWER(\''.$db->escape($form_username).'\')';
// проверка IP админов и модераторов - Visman
if ($pun_config['o_check_ip'] == '1')

View file

@ -56,7 +56,7 @@ else if ($action == 'lang')
if ($pun_user['is_guest'])
{
forum_setcookie($cookie_name.'_glang', $language, time()+ 31536000);
forum_setcookie($container->getParameter('COOKIE_PREFIX') . '_glang', $language, time()+ 31536000);
}
else
$db->query('UPDATE '.$db->prefix.'users SET language="'.$db->escape($language).'" WHERE id='.$pun_user['id']) or error('Unable to update profile', __FILE__, __LINE__, $db->error());

View file

@ -279,7 +279,7 @@ if (isset($_GET['action']) || isset($_GET['search_id']))
// If it's a search for author name (and that author name isn't Guest)
if ($author && $author != 'guest' && $author != utf8_strtolower($lang_common['Guest']))
{
switch ($db_type)
switch ($container->getParameter('DB_TYPE'))
{
case 'pgsql':
$result = $db->query('SELECT id FROM '.$db->prefix.'users WHERE username ILIKE \''.$db->escape($author).'\'') or error('Unable to fetch users', __FILE__, __LINE__, $db->error());
@ -366,7 +366,7 @@ if (isset($_GET['action']) || isset($_GET['search_id']))
// If it's a search for topics in which the user has posted
else if ($action == 'show_replies')
{
$result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$pun_user['id'].' GROUP BY t.id'.($db_type == 'pgsql' ? ', t.last_post' : '').' ORDER BY t.last_post DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$pun_user['id'].' GROUP BY t.id'.($container->getParameter('DB_TYPE') == 'pgsql' ? ', t.last_post' : '').' ORDER BY t.last_post DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
$num_hits = $db->num_rows($result);
if (!$num_hits)

View file

@ -32,7 +32,7 @@ $sort_dir = isset($_GET['sort_dir']) && $_GET['sort_dir'] == 'DESC' ? 'DESC' : '
// Create any SQL for the WHERE clause
$where_sql = array();
$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
$like_command = ($container->getParameter('DB_TYPE') == 'pgsql') ? 'ILIKE' : 'LIKE';
if ($username != '')
$where_sql[] = 'u.username '.$like_command.' \''.$db->escape(str_replace('*', '%', $username)).'\'';

View file

@ -190,7 +190,7 @@ if ($db->num_rows($result))
else
{
// With "the dot"
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.poll_type FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN('.implode(',', $topic_ids).') GROUP BY t.id'.($db_type == 'pgsql' ? ', t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id' : '').' ORDER BY t.sticky DESC, t.'.$sort_by.', t.id DESC';
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.poll_type FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN('.implode(',', $topic_ids).') GROUP BY t.id'.($container->getParameter('DB_TYPE') == 'pgsql' ? ', t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id' : '').' ORDER BY t.sticky DESC, t.'.$sort_by.', t.id DESC';
}
$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());