<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");
if((!userEditor())AND(!userAdmin())) loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsOnline'])) loginError($sxLang['LoginRequired']);
if(!$timestamp)
$timestamp = 900;
$visit_time = $NOW - $timestamp;
if($sxShowGuests == 'off')
$query = "SELECT * FROM $DB_Visitors WHERE userid!='0' AND lastvisit>'$visit_time'";
else
$query = "SELECT * FROM $DB_Visitors WHERE lastvisit>'$visit_time'";
$result = mysql_query($query, $Link) or queryError("56", mysql_error());
$totalOnline = mysql_num_rows($result);
$elements_per_page = $sxThemeConfig['AdminElementsPerPage'];
if(!$page)
$page = 1;
$start = ($page - 1)*$elements_per_page;
$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<div class="bodyWrapper">
<h1 class="sxAdminHeading"><?PHP echo $sxLang['UserHeadingOnline']; ?></h1>
<div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <a href="user_manager.php"><?PHP echo $sxLang['UserHeadingManager']; ?></a> > <?PHP echo $sxLang['UserHeadingOnline']; ?></div>
<?PHP echoMessage($message); ?>
<div style="padding-bottom:10px;font-weight:bold;">
<?PHP echo $sxLang['UserActiveInPast']; ?> <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=300"<?PHP if($timestamp == 300) echo ' selected'; ?>>5 <?PHP echo $sxLang['DateMinutes']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=900"<?PHP if($timestamp == 900) echo ' selected'; ?>>15 <?PHP echo $sxLang['DateMinutes']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=1800"<?PHP if($timestamp == 1800) echo ' selected'; ?>>30 <?PHP echo $sxLang['DateMinutes']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=3600"<?PHP if($timestamp == 3600) echo ' selected'; ?>>1 <?PHP echo $sxLang['DateHour']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=7200"<?PHP if($timestamp == 7200) echo ' selected'; ?>>2 <?PHP echo $sxLang['DateHours']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=43200"<?PHP if($timestamp == 43200) echo ' selected'; ?>>12 <?PHP echo $sxLang['DateHours']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=86400"<?PHP if($timestamp == 86400) echo ' selected'; ?>>24 <?PHP echo $sxLang['DateHours']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=172800"<?PHP if($timestamp == 172800) echo ' selected'; ?>>2 <?PHP echo $sxLang['DateDays']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=604800"<?PHP if($timestamp == 604800) echo ' selected'; ?>>7 <?PHP echo $sxLang['DateDays']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=1209600"<?PHP if($timestamp == 1209600) echo ' selected'; ?>>2 <?PHP echo $sxLang['DateWeeks']; ?></option>
<option value="<?PHP echo $PHP_SELF; ?>?sxShowGuests=<?PHP echo $sxShowGuests; ?>×tamp=2419200"<?PHP if($timestamp == 2419200) echo ' selected'; ?>>1 <?PHP echo $sxLang['DateMonth']; ?></option>
</select>
<input type="checkbox" name="sxShowGuests" value="1"<?PHP if($sxShowGuests != 'off') echo 'checked="checked"'; ?> onclick="window.location='<?PHP echo $PHP_SELF; if($sxShowGuests != 'off') echo '?sxShowGuests=off×tamp='.$timestamp; else echo '?sxShowGuests=on×tamp='.$timestamp; ?>'" /><?PHP echo $sxLang['UserOnlineShowGuests']; ?>
</div>
<div style="padding-bottom:10px;"><strong><?PHP echo $sxLang['UserTotal']; ?>:</strong> <?PHP echo number_format($totalOnline); ?></div>
<div style="padding-top:0px;padding-bottom:8px;font-size:10px;"><?PHP pageTurns("$PHP_SELF?sxShowGuests=$sxShowGuests×tamp=$timestamp&", $totalOnline, $page, $elements_per_page); ?></div>
<table border="0" cellspacing="2" cellpadding="5">
<tr>
<td class="tableColumn"><?PHP echo $sxLang['UserItemUsername']; ?></td>
<td class="tableColumn"><?PHP echo $sxLang['UserOnlineItemLastIP']; ?></td>
<td class="tableColumn"><?PHP echo $sxLang['UserOnlineItemVisitTime']; ?></td>
<td class="tableColumn"><?PHP echo $sxLang['UserOnlineItemTotalVisits']; ?></td>
<td class="tableColumn"><?PHP echo $sxLang['UserOnlineItemTotalHits']; ?></td>
</tr>
<?PHP
// Hide guest users if desired
if($sxShowGuests == 'off')
$query = "SELECT * FROM $DB_Visitors WHERE userid!='0' AND lastip!='previous_count' AND lastvisit>'$visit_time' ORDER BY lastvisit DESC LIMIT $start, $elements_per_page";
else
$query = "SELECT * FROM $DB_Visitors WHERE lastip!='previous_count' AND lastvisit>'$visit_time' ORDER BY lastvisit DESC LIMIT $start, $elements_per_page";
$result = mysql_query($query, $Link) or queryError("27", mysql_error());
while($ROW = mysql_fetch_object($result))
{
echo ' <tr bgcolor="' . $sxTheme['ColorTableRow'] . '">';
if($ROW->userid != 0)
{
$query2 = "SELECT * FROM $DB_Users WHERE id='$ROW->userid'";
$result2 = mysql_query($query2, $Link) or queryError("28", mysql_error());
$ROW2 = mysql_fetch_object($result2);
echo ' <td><a href="profile_view.php?user=' . htmlspecialchars($ROW2->username) . '">' . htmlspecialchars($ROW2->username) . '</a></td>';
}
else
echo ' <td><em>' . $sxLang['UserGuest'] . '</em></td>';
echo ' <td>' . $ROW->lastip . '</td>';
echo ' <td>' . fetchDate($ROW->lastvisit, 1, 1) . '</td>';
echo ' <td>' . number_format($ROW->visits) . '</td>';
echo ' <td>' . number_format($ROW->pagehits) . '</td>';
echo ' </tr>';
}
if(!mysql_num_rows($result))
echo'<tr><td><em>' . $sxLang['NoVisitors'] . '</em></td></tr>';
?></table>
<div style="padding-top:8px;padding-bottom:8px;font-size:10px;">
<?PHP pageTurns("$PHP_SELF?", $totalElements, $page, $elements_per_page); ?></div>
</div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>