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:
@@ -22,11 +22,25 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
|
|||||||
{
|
{
|
||||||
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
|
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
|
||||||
$today = (mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']));
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
$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';
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|||||||
@@ -25,26 +25,55 @@ $s_display_friends = false;
|
|||||||
// Output listing of friends online
|
// Output listing of friends online
|
||||||
$update_time = $config['load_online_time'] * 60;
|
$update_time = $config['load_online_time'] * 60;
|
||||||
|
|
||||||
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
switch ($db->sql_layer)
|
||||||
'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(
|
case 'mssql':
|
||||||
USERS_TABLE => 'u',
|
case 'mssql_odbc':
|
||||||
ZEBRA_TABLE => 'z'
|
$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(
|
'LEFT_JOIN' => array(
|
||||||
array(
|
array(
|
||||||
'FROM' => array(SESSIONS_TABLE => 's'),
|
'FROM' => array(SESSIONS_TABLE => 's'),
|
||||||
'ON' => 's.session_user_id = z.zebra_id'
|
'ON' => 's.session_user_id = z.zebra_id'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
|
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
|
||||||
AND z.friend = 1
|
AND z.friend = 1
|
||||||
AND u.user_id = z.zebra_id',
|
AND u.user_id = z.zebra_id',
|
||||||
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.user_allow_viewonline, u.user_colour',
|
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.user_allow_viewonline, u.user_colour',
|
||||||
'ORDER_BY' => 'u.username_clean ASC',
|
'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',
|
||||||
|
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_clean ASC',
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$result = $db->sql_query_limit($sql, $portal_config['portal_max_online_friends']);
|
$result = $db->sql_query_limit($sql, $portal_config['portal_max_online_friends']);
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,35 @@ if (!defined('IN_PORTAL'))
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT *
|
switch ($db->sql_layer)
|
||||||
FROM ' . USERS_TABLE . '
|
{
|
||||||
WHERE user_type <> ' . USER_IGNORE . '
|
case 'postgres':
|
||||||
AND user_type <> ' . USER_INACTIVE . '
|
$sql = 'SELECT *
|
||||||
ORDER BY RAND()
|
FROM ' . USERS_TABLE . '
|
||||||
LIMIT 1';
|
WHERE user_type <> ' . USER_IGNORE . '
|
||||||
$result = $db->sql_query($sql);
|
AND user_type <> ' . USER_INACTIVE . '
|
||||||
|
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);
|
$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']);
|
$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