Report#72: Full MSSQL support - added DB switches to these blocks, with the MSSQL fixes provided by Mesmeric in this thread: http://www.board3.de/viewtopic.php?f=10&t=275
Also added a Postgres switch to the random_member.php to avoid bugs with this DB type ( ORDER BY RANDOM() ). Have to be tested by a MSSQL user.
This commit is contained in:
@@ -23,10 +23,24 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
|
||||
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
|
||||
$today = (mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']));
|
||||
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
$sql = 'SELECT user_id, username, user_colour, user_birthday
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE user_birthday <> ''
|
||||
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') ORDER BY user_birthday ASC';
|
||||
break;
|
||||
|
||||
default:
|
||||
$sql = 'SELECT user_id, username, user_colour, user_birthday
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE user_birthday <> ''
|
||||
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') ORDER BY SUBSTRING(user_birthday FROM 4 FOR 2) ASC, SUBSTRING(user_birthday FROM 1 FOR 2) ASC, username_clean ASC';
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
||||
@@ -25,7 +25,34 @@ $s_display_friends = false;
|
||||
// Output listing of friends online
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
|
||||
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
||||
'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
ZEBRA_TABLE => 'z'
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(SESSIONS_TABLE => 's'),
|
||||
'ON' => 's.session_user_id = z.zebra_id'
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
|
||||
AND z.friend = 1
|
||||
AND u.user_id = z.zebra_id',
|
||||
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.user_allow_viewonline, u.user_colour',
|
||||
'ORDER_BY' => 'u.username ASC',
|
||||
));
|
||||
break;
|
||||
|
||||
default:
|
||||
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
||||
'SELECT' => 'u.user_id, u.username, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
@@ -44,7 +71,9 @@ $sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
||||
AND u.user_id = z.zebra_id',
|
||||
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.user_allow_viewonline, u.user_colour',
|
||||
'ORDER_BY' => 'u.username_clean ASC',
|
||||
));
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $db->sql_query_limit($sql, $portal_config['portal_max_online_friends']);
|
||||
|
||||
|
||||
@@ -20,13 +20,35 @@ if (!defined('IN_PORTAL'))
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = 'SELECT *
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'postgres':
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_type <> ' . USER_IGNORE . '
|
||||
AND user_type <> ' . USER_INACTIVE . '
|
||||
ORDER BY RAND()
|
||||
LIMIT 1';
|
||||
$result = $db->sql_query($sql);
|
||||
ORDER BY RANDOM()';
|
||||
break;
|
||||
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_type <> ' . USER_IGNORE . '
|
||||
AND user_type <> ' . USER_INACTIVE . '
|
||||
ORDER BY NEWID()';
|
||||
break;
|
||||
|
||||
default:
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_type <> ' . USER_IGNORE . '
|
||||
AND user_type <> ' . USER_INACTIVE . '
|
||||
ORDER BY RAND()';
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
||||
$avatar_img = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']);
|
||||
|
||||
Reference in New Issue
Block a user