Fixed various issues and bugs

git-svn-id: file:///svn/phpbb/trunk@1260 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-11-03 13:54:04 +00:00
parent 2297465c60
commit 5251423378
4 changed files with 116 additions and 88 deletions

View file

@ -124,6 +124,7 @@ define(PAGE_TOPIC_OFFSET, 5000);
// Auth settings // Auth settings
define(AUTH_LIST_ALL, 0);
define(AUTH_ALL, 0); define(AUTH_ALL, 0);
define(AUTH_REG, 1); define(AUTH_REG, 1);
@ -145,8 +146,6 @@ define(AUTH_POLLCREATE, 9);
define(AUTH_VOTE, 10); define(AUTH_VOTE, 10);
define(AUTH_ATTACH, 11); define(AUTH_ATTACH, 11);
define(AUTH_LIST_ALL, 20);
// Table names // Table names
define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access'); define('AUTH_ACCESS_TABLE', $table_prefix.'auth_access');

View file

@ -26,12 +26,16 @@
// //
// You should also try to set a locale and a character // You should also try to set a locale and a character
// encoding (plus direction). The encoding and direction // encoding (plus direction). The encoding and direction
// will be sent to the template // will be sent to the template. The locale may or may
// not work, it's dependent on OS support and the syntax
// varies ... give it your best guess!
// //
setlocale(LC_ALL, "en"); setlocale(LC_ALL, "en");
$lang['ENCODING'] = "iso-8859-1"; $lang['ENCODING'] = "iso-8859-1";
$lang['DIRECTION'] = "LTR"; $lang['DIRECTION'] = "LTR";
$lang['LEFT'] = "LEFT";
$lang['RIGHT'] = "RIGHT";
// //
// Common, these terms are used // Common, these terms are used
@ -193,15 +197,15 @@ $lang['View_newest_posts'] = "View posts since your last visit";
$lang['Topics_marked_read'] = "The topics for this forum have now been marked read"; $lang['Topics_marked_read'] = "The topics for this forum have now been marked read";
$lang['Rules_post_can'] = "You <b>can</b> post new topics in this forum"; $lang['Rules_post_can'] = "You <b>can</b> post new topics in this forum";
$lang['Rules_post_cannot'] = "You <b>can</b> post new topics in this forum"; $lang['Rules_post_cannot'] = "You <b>cannot</b> post new topics in this forum";
$lang['Rules_reply_can'] = "You <b>can</b> reply to topics in this forum"; $lang['Rules_reply_can'] = "You <b>can</b> reply to topics in this forum";
$lang['Rules_reply_cannot'] = "You <b>can</b> reply to topics in this forum"; $lang['Rules_reply_cannot'] = "You <b>cannot</b> reply to topics in this forum";
$lang['Rules_edit_can'] = "You <b>can</b> edit your posts in this forum"; $lang['Rules_edit_can'] = "You <b>can</b> edit your posts in this forum";
$lang['Rules_edit_cannot'] = "You <b>can</b> edit your posts in this forum"; $lang['Rules_edit_cannot'] = "You <b>cannot</b> edit your posts in this forum";
$lang['Rules_delete_can'] = "You <b>can</b> delete posts in this forum"; $lang['Rules_delete_can'] = "You <b>can</b> delete posts in this forum";
$lang['Rules_delete_cannot'] = "You <b>can</b> delete posts in this forum"; $lang['Rules_delete_cannot'] = "You <b>cannot</b> delete posts in this forum";
$lang['Rules_vote_can'] = "You <b>can</b> vote in polls in this forum"; $lang['Rules_vote_can'] = "You <b>can</b> vote in polls in this forum";
$lang['Rules_vote_cannot'] = "You <b>can</b> vote in polls in this forum"; $lang['Rules_vote_cannot'] = "You <b>cannot</b> vote in polls in this forum";
$lang['Rules_moderate'] = "You <b>can</b> %smoderate this forum%s"; // %s replaced by a href $lang['Rules_moderate'] = "You <b>can</b> %smoderate this forum%s"; // %s replaced by a href
// //
@ -639,6 +643,9 @@ $lang['this_forum'] = " this forum";
// Viewonline // Viewonline
// //
$lang['Who_is_online'] = "Who is online"; $lang['Who_is_online'] = "Who is online";
$lang['Reg_users_online'] = "There are %d Registered and %d Hidden users online";
$lang['Guest_users_online'] = "There are %d Guest users online";
$lang['Guest_user_online'] = "There is %d Guest user online";
$lang['Online_explain'] = "This data is based on users active over the past five minutes"; $lang['Online_explain'] = "This data is based on users active over the past five minutes";
$lang['No_users_browsing'] = "There are no users currently browsing this forum"; $lang['No_users_browsing'] = "There are no users currently browsing this forum";
$lang['Location'] = "Location"; $lang['Location'] = "Location";

View file

@ -546,7 +546,7 @@ if($total_topics)
$view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"); $view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
$topic_poster = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $topic_rowset[$i]['user_id']) . "\">" : ""; $topic_poster = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $topic_rowset[$i]['user_id']) . "\">" : "";
$topic_poster .= $topic_rowset[$i]['username']; $topic_poster .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : $topic_rowset[$i]['post_username'];
$topic_poster .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? "</a>" : ""; $topic_poster .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? "</a>" : "";
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']); $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);

View file

@ -33,6 +33,24 @@ init_userprefs($userdata);
// End session management // End session management
// //
// ---------------
// Begin functions
//
function inarray($needle, $haystack)
{
for($i = 0; $i < sizeof($haystack); $i++ )
{
if( $haystack[$i] == $needle )
{
return true;
}
}
return false;
}
//
// End functions
// -------------
// //
// Output page header and load // Output page header and load
// viewonline template // viewonline template
@ -72,7 +90,7 @@ if(!$result = $db->sql_query($sql))
} }
$onlinerow_reg = $db->sql_fetchrowset($result); $onlinerow_reg = $db->sql_fetchrowset($result);
$sql = "SELECT session_page, session_logged_in, session_time $sql = "SELECT session_page, session_logged_in, session_time, session_ip
FROM " . SESSIONS_TABLE . " FROM " . SESSIONS_TABLE . "
WHERE session_logged_in = 0 WHERE session_logged_in = 0
AND session_time >= " . ( time() - 300 ) . " AND session_time >= " . ( time() - 300 ) . "
@ -108,9 +126,17 @@ $template->assign_vars(array(
$active_users = 0; $active_users = 0;
$guest_users = 0; $guest_users = 0;
//
// Get auth data
//
$is_auth_ary = array();
$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
// //
// Registered users ... // Registered users ...
// //
$reg_userid_ary = array();
if( count($onlinerow_reg) ) if( count($onlinerow_reg) )
{ {
$registered_users = 0; $registered_users = 0;
@ -120,26 +146,22 @@ if( count($onlinerow_reg) )
for($i = 0; $i < count($onlinerow_reg); $i++) for($i = 0; $i < count($onlinerow_reg); $i++)
{ {
if( !eregi("," . $onlinerow_reg[$i]['user_id'], $displayed_userid_list) ) if( !inarray($onlinerow_reg[$i]['user_id'], $reg_userid_ary) )
{ {
if( $onlinerow_reg[$i]['user_allow_viewonline'] || $userdata['user_level'] == ADMIN ) if( $onlinerow_reg[$i]['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
{ {
$displayed_userid_list .= "," . $onlinerow_reg[$i]['user_id'];
$username = $onlinerow_reg[$i]['username']; $username = $onlinerow_reg[$i]['username'];
$hidden = FALSE; $hidden = FALSE;
$registered_users++; $registered_users++;
} }
else else
{ {
$displayed_userid_list .= "," . $onlinerow_reg[$i]['user_id'];
$username = $onlinerow_reg[$i]['username']; $username = $onlinerow_reg[$i]['username'];
$hidden = TRUE; $hidden = TRUE;
$hidden_users++; $hidden_users++;
} }
if($onlinerow_reg[$i]['session_page'] < 1) if( $onlinerow_reg[$i]['session_page'] < 1 || !$is_auth_ary[$onlinerow_reg[$i]['session_page']]['auth_view'] )
{ {
switch($onlinerow_reg[$i]['session_page']) switch($onlinerow_reg[$i]['session_page'])
{ {
@ -209,19 +231,15 @@ if( count($onlinerow_reg) )
} }
} }
$l_h_user_s = ($hidden_users == 1) ? $lang['User'] : $lang['Users'];
$l_r_user_s = ($registered_users == 1) ? $lang['User'] : $lang['Users'];
$l_is_are = ($registered_users == 1) ? $lang['is'] : $lang['are'];
$template->assign_vars(array( $template->assign_vars(array(
"TOTAL_REGISTERED_USERS_ONLINE" => $lang['There'] . " $l_is_are $logged_visible_online " . $lang['Registered'] . " $l_r_user_s " . $lang['and'] . " $logged_hidden_online " . $lang['Hidden'] . " $l_h_user_s " . $lang['online']) "TOTAL_REGISTERED_USERS_ONLINE" => sprintf($lang['Reg_users_online'], $registered_users, $hidden_users))
); );
} }
else else
{ {
$template->assign_vars(array( $template->assign_vars(array(
"TOTAL_REGISTERED_USERS_ONLINE" => $lang['There'] . " " . $lang['are'] . " 0 " . $lang['Registered'] . " " . $lang['Users'] . " " . $lang['and'] . " 0 " . $lang['Hidden'] . " " . $lang['Users'] . " " . $lang['online'], "TOTAL_REGISTERED_USERS_ONLINE" => sprintf($lang['Reg_users_online'], 0, 0),
"L_NO_REGISTERED_USERS_BROWSING" => $lang['No_users_browsing']) "L_NO_REGISTERED_USERS_BROWSING" => $lang['No_users_browsing'])
); );
} }
@ -229,92 +247,96 @@ else
// //
// Guest users // Guest users
// //
$guest_userip_ary = array();
if( count($onlinerow_guest) ) if( count($onlinerow_guest) )
{ {
$guest_users = 0; $guest_users = 0;
for($i = 0; $i < count($onlinerow_guest); $i++) for($i = 0; $i < count($onlinerow_guest); $i++)
{ {
$guest_users++; if( !inarray($onlinerow_guest[$i]['session_ip'], $guest_userip_ary) )
if($onlinerow_guest[$i]['session_page'] < 1)
{ {
switch($onlinerow_guest[$i]['session_page']) $guest_users++;
if($onlinerow_guest[$i]['session_page'] < 1 || !$is_auth_ary[$onlinerow_reg[$i]['session_page']]['auth_view'] )
{ {
case PAGE_INDEX: switch($onlinerow_guest[$i]['session_page'])
$location = $lang['Forum_index']; {
$location_url = "index.$phpEx"; case PAGE_INDEX:
break; $location = $lang['Forum_index'];
case PAGE_POSTING: $location_url = "index.$phpEx";
$location = $lang['Posting_message']; break;
$location_url = "index.$phpEx"; case PAGE_POSTING:
break; $location = $lang['Posting_message'];
case PAGE_LOGIN: $location_url = "index.$phpEx";
$location = $lang['Logging_on']; break;
$location_url = "index.$phpEx"; case PAGE_LOGIN:
break; $location = $lang['Logging_on'];
case PAGE_SEARCH: $location_url = "index.$phpEx";
$location = $lang['Searching_forums']; break;
$location_url = "search.$phpEx"; case PAGE_SEARCH:
break; $location = $lang['Searching_forums'];
case PAGE_PROFILE: $location_url = "search.$phpEx";
$location = $lang['Viewing_profile']; break;
$location_url = "index.$phpEx"; case PAGE_PROFILE:
break; $location = $lang['Viewing_profile'];
case PAGE_VIEWONLINE: $location_url = "index.$phpEx";
$location = $lang['Viewing_online']; break;
$location_url = "viewonline.$phpEx"; case PAGE_VIEWONLINE:
break; $location = $lang['Viewing_online'];
case PAGE_VIEWMEMBERS: $location_url = "viewonline.$phpEx";
$location = $lang['Viewing_member_list']; break;
$location_url = "memberlist.$phpEx"; case PAGE_VIEWMEMBERS:
break; $location = $lang['Viewing_member_list'];
case PAGE_PRIVMSGS: $location_url = "memberlist.$phpEx";
$location = $lang['Viewing_priv_msgs']; break;
$location_url = "privmsg.$phpEx"; case PAGE_PRIVMSGS:
break; $location = $lang['Viewing_priv_msgs'];
case PAGE_FAQ: $location_url = "privmsg.$phpEx";
$location = $lang['Viewing_FAQ']; break;
$location_url = "faq.$phpEx"; case PAGE_FAQ:
break; $location = $lang['Viewing_FAQ'];
default: $location_url = "faq.$phpEx";
$location = $lang['Forum_index']; break;
$location_url = "index.$phpEx"; default:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx";
}
} }
else
{
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow_guest[$i]['session_page']);
$location = $forum_data[$onlinerow_guest[$i]['session_page']];
}
$row_color = ( $guest_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( $guest_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("guest_user_row", array(
"ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class,
"USERNAME" => $lang['Guest'],
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_time'], $board_config['board_timezone']),
"LOCATION" => $location,
"U_FORUM_LOCATION" => append_sid($location_url))
);
} }
else
{
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow_guest[$i]['session_page']);
$location = $forum_data[$onlinerow_guest[$i]['session_page']];
}
$row_color = ( $guest_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( $guest_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("guest_user_row", array(
"ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class,
"USERNAME" => $lang['Guest'],
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_time'], $board_config['board_timezone']),
"LOCATION" => $location,
"U_FORUM_LOCATION" => append_sid($location_url))
);
} }
$l_g_user_s = ($guest_users == 1) ? $lang['User'] : $lang['Users']; $l_g_user_s = ( $guest_users == 1 ) ? $lang['Guest_user_online'] : $lang['Guest_users_online'];
$l_is_are = ($guest_users == 1) ? $lang['is'] : $lang['are'];
$template->assign_vars(array( $template->assign_vars(array(
"TOTAL_GUEST_USERS_ONLINE" => $lang['There'] . " $l_is_are $guests_online " . $lang['Guest'] . " $l_g_user_s " . $lang['online']) "TOTAL_GUEST_USERS_ONLINE" => sprintf($l_g_user_s, $guest_users))
); );
} }
else else
{ {
$template->assign_vars(array( $template->assign_vars(array(
"TOTAL_GUEST_USERS_ONLINE" => $lang['There'] . " " . $lang['are'] . " 0 " . $lang['Guest'] . " " . $lang['Users'] . " " . $lang['online'], "TOTAL_GUEST_USERS_ONLINE" => sprintf($lang['Guest_users_online'], 0, 0),
"L_NO_GUESTS_BROWSING" => $lang['No_guests_browsing']) "L_NO_GUESTS_BROWSING" => $lang['No_users_browsing'])
); );
} }