/*
# UBB.threads, Version 6
# Official Release Date for UBB.threads Version6: 06/05/2002
# First version of UBB.threads created July 30, 1996 (by Rick Baker).
# This entire program is copyright Infopop Corporation, 2002.
# For more info on the UBB.threads and other Infopop
# Products/Services, visit: http://www.infopop.com
# Program Author: Rick Baker.
# File Version 6.5.1.1
# You may not distribute this program in any manner, modified or otherwise,
# without the express, written written consent from Infopop Corporation.
# Note: if you modify ANY code within UBB.threads, we at Infopop Corporation
# cannot offer you support-- thus modify at your own peril :)
# ---------------------------------------------------------------------------
*/
// Require the library
require ("./includes/main.inc.php");
require ("languages/{$myprefs['language']}/online.php");
// Define any necessary variables
$icqindicator = "";
// -------------
// Get the input
$Cat = get_input("Cat","get");
// -----------------
// Get the user info
$userob = new user;
$user = $userob -> authenticate("U_TimeOffset,U_Groups,U_TimeFormat");
$toffset = "";
isset($user['U_TimeOffset']) && $toffset = $user['U_TimeOffset'];
!isset($user['U_TimeFormat']) && $user['U_TimeFormat'] = $theme['timeformat'];
// ---------------------------------
// Split their groups into an array
if (!$user['U_Groups']) {
$user['U_Groups'] = "-4-";
}
$Grouparray = split("-",$user['U_Groups']);
$gsize = sizeof($Grouparray);
// -------------------------
// Delete the inactive users
if (!isset($config['onlinetime'])) {
$config['onlinetime'] = 10;
}
$html = new html;
$Outdated = $html -> get_date() - ($config['onlinetime'] * 60 );
$query = "
DELETE FROM {$config['tbprefix']}Online
WHERE O_Last < $Outdated
";
$dbh -> do_query($query,__LINE__,__FILE__);
// Generate any content island feeds for recent visitors
define('visitors','1');
define('CI_BUILDER','1');
include("ci_builder.php");
// ------------------
// Send a html header
$html -> send_header($ubbt_lang['ONLINE_HEAD'],$Cat,"",$user);
$query = "
SELECT t1.O_Username, t1.O_Last, t1.O_What,t1.O_Board,t1.O_Extra,t1.O_Read,t2.U_Status,t2.U_Visible,t2.U_Extra1,t2.U_Title,t2.U_Color,t2.U_OnlineFormat,t2.U_Number
FROM {$config['tbprefix']}Online AS t1
LEFT JOIN {$config['tbprefix']}Users AS t2
ON t1.O_Username = t2.U_Username
WHERE t1.O_Type='r'
ORDER BY t1.O_Last DESC
";
$reged = $dbh -> do_query($query,__LINE__,__FILE__);
$regrows = $dbh -> total_rows($reged);
$color = "lighttable";
// Array key tracker
$x = 0;
while (list($Username,$Last,$RealWhat,$Board,$Extra,$Read,$Status,$Visible,$ICQ,$Title,$Color,$OnlineFormat,$Uid) = $dbh -> fetch_array($reged) ) {
// -----------------------------------------------
// Let's see if we need to block some information
$Private = 0;
if ($user['U_Status'] != "Administrator") {
$Private = 1;
if ($Read) {
for ($i=0; $i<=$gsize; $i++) {
if (!preg_match("/[0-9]/",$Grouparray[$i])) { continue; };
if (!strstr($Read,"-$Grouparray[$i]-")) {
$Private = 1;
}
else {
$Private = 0;
break;
}
}
}
}
// ------------------------------------------------------
// Replace their location with something that makes sense
$What = $ubbt_lang[$RealWhat];
if (!$What) { $What = $ubbt_lang['all_admin']; }
if ( ($user['U_Status'] != "Administrator") && ($Visible == "no") ) {
continue;
}
$extra = "";
if ($Visible == "no") {
$extra = "(I)";
}
$regrow[$x]['extra'] = $extra;
$Last = $html -> convert_time($Last,$toffset,$user['U_TimeFormat']);
$EUsername = $Uid;
$PUsername = $Username;
if ($Color) {
$PUsername = "$Username";
}
if ($Status == "Administrator") {
if (!$Color) {
$PUsername = "$Username";
}
$Status = $ubbt_lang['USER_ADMIN'];
}
if ($Status == "Moderator") {
if (!$Color) {
$PUsername = "$Username";
}
$Status = $ubbt_lang['USER_MOD'];
}
if ($Status == "User") { $Status = $ubbt_lang['USER_USER']; }
$regrow[$x]['color'] = $color;
$regrow[$x]['EUsername'] = $EUsername;
$regrow[$x]['PUsername'] = $PUsername;
// -----------------------------------------------------
// Here we give more information on what they are doing
if ( ($OnlineFormat == "no") && ($user['U_Status'] != "Administrator") ) { $Private = 1; }
if (!$Private){
if (( $RealWhat == "postlist") || ($RealWhat == "newpost") ){
if (!isset($Boards[$Board])) {
$query = "SELECT Bo_Title FROM {$config['tbprefix']}Boards WHERE Bo_Keyword='$Board'";
$sti = $dbh -> do_query($query,__LINE__,__FILE__);
list($Boards[$Board]) = $dbh -> fetch_array($sti);
}
$Extra = "
$Boards[$Board]";
}
elseif ($RealWhat == "showflat") {
list($number,$subject) = split("_SEP_",$Extra);
$Extra = "
$subject";
}
elseif ($RealWhat == "showthreaded") {
list($number,$subject) = split("_SEP_",$Extra);
$Extra = "
$subject";
}
elseif ($RealWhat == "newreply") {
list($number,$subject) = split("_SEP_",$Extra);
$Extra = "
$subject";
}
elseif ($RealWhat == "addpost") {
list($number,$subject) = split("_SEP_",$Extra);
if ($subject) {
$Extra = "
$subject";
}
else {
if (!isset($Boards[$Board])) {
$query = "SELECT Bo_Title FROM {$config['tbprefix']}Boards WHERE Bo_Keyword='$Board'";
$sti = $dbh -> do_query($query,__LINE__,__FILE__);
list($Boards[$Board]) = $dbh -> fetch_array($sti);
}
$Extra = "
$Boards[$board]";
}
}
}
if ( ($Board) && ($Private) ){
$Extra = "
({$ubbt_lang['Private']})";
}
if ( (preg_match('/^\d+$/',$ICQ)) && ($config['ICQ_Status']) ) {
$icqindicator = "";
}
else {
$icqindicator = "";
}
if ($Extra == "0") { $Extra = ""; }
$regrow[$x]['icqindicator'] = $icqindicator;
$regrow[$x]['Status'] = $Status;
$regrow[$x]['Title'] = $Title;
$regrow[$x]['Last'] = $Last;
$regrow[$x]['What'] = $What;
$regrow[$x]['Extra'] = $Extra;
$color = $html -> switch_colors($color);
$x++;
}
$regsize = 0;
if (isset($regrow)) {
$regsize = sizeof($regrow);
}
$dbh -> finish_sth($reged);
// ----------------------------------------
// Now show the one's that aren't logged in
$query = "
SELECT O_Username,O_Last,O_What,O_Board,O_Extra
FROM {$config['tbprefix']}Online
WHERE O_Type = 'a'
ORDER BY O_Last DESC
";
$unreged = $dbh -> do_query($query,__LINE__,__FILE__);
$anonrows = $dbh -> total_rows($unreged);
if ($user['U_Status'] == "Administrator") {
$column = $ubbt_lang['FROM_IP'];
}
else {
$column = $ubbt_lang['USERNAME_TEXT'];
}
$color = "lighttable";
$What = "";
$Extra = "";
// Anonrow array key number
$x = 0;
while (list($Username,$Last,$RealWhat,$Board,$Extra) = $dbh -> fetch_array($unreged) ) {
$anonrow[$x]['color'] = $color;
// ------------------------------------------------------
// Replace their location with something that makes sense
$What = $ubbt_lang[$RealWhat];
if ($user['U_Status'] == "Administrator") {
$piece['0'] = "";
preg_match("/-ANON-(.*)/",$Username,$piece);
$Username = $piece['1'];
}
else {
$Username = $ubbt_lang['ANON_TEXT'];
}
$Last = $html -> convert_time($Last,$toffset,$user['U_TimeFormat']);
// -----------------------------------------------------
// Here we give more information on what they are doing
if ($Board){
if (( $RealWhat == "postlist") || ($RealWhat == "newpost") ){
if (!isset($Boards[$Board])) {
$query = "SELECT Bo_Title FROM {$config['tbprefix']}Boards WHERE Bo_Keyword='$Board'";
$sti = $dbh -> do_query($query,__LINE__,__FILE__);
list($Boards[$Board]) = $dbh -> fetch_array($sti);
}
$Extra = "
$Boards[$Board]";
}
elseif ($RealWhat == "showflat") {
list($number,$subject) = split("_SEP_",$Extra);
$Extra = "
$subject";
}
elseif ($RealWhat == "showthreaded") {
list($number,$subject) = split("_SEP_",$Extra);
$Extra = "
$subject";
}
elseif ($RealWhat == "newreply") {
list($number,$subject) = split("_SEP_",$Extra);
$Extra = "
$subject";
}
elseif ($RealWhat == "addpost") {
@list($number,$subject) = @split("_SEP_",$Extra);
if ($subject) {
$Extra = "
$subject";
}
else {
if (!isset($Boards[$Board])) {
$query = "SELECT Bo_Title FROM {$config['tbprefix']}Boards WHERE Bo_Keyword='$Board'";
$sti = $dbh -> do_query($query,__LINE__,__FILE__);
list($Boards[$Board]) = $dbh -> fetch_array($sti);
}
$Extra = "
$Boards[$Board]";
}
}
}
if (!$Extra) { $Extra = ""; }
$anonrow[$x]['Username'] = $Username;
$anonrow[$x]['Last'] = $Last;
$anonrow[$x]['What'] = $What;
$anonrow[$x]['Extra'] = $Extra;
$x++;
$color = $html -> switch_colors($color);
}
if (isset($anonrow)) {
$anonsize = sizeof($anonrow);
}
else {
$anonsize = "0";
}
$dbh -> finish_sth($unreged);
// ---------------------
// Grab the tablewrapper
list($tbopen,$tbclose) = $html -> table_wrapper();
if (!$debug) {
include("$thispath/templates/$tempstyle/online.tmpl");
}
// Send the footer
$html -> send_footer();
?>