<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------+
| Modified by PHP-Fusion SF Group
| Copyright © 2007 by SF
| http://www.rus-phpfusion.com/
+----------------------------------------------------*/
if (!defined("IN_FUSION")) { header("Location:../../index.php"); exit; }

if (file_exists(INFUSIONS."last_seen_users_panel/locale/".$settings['locale'].".php")) {
	include INFUSIONS."last_seen_users_panel/locale/".$settings['locale'].".php";
} else { include INFUSIONS."last_seen_users_panel/locale/English.php"; }

/*******************************************************************
* Set minimum and maximum number of users you want displayed on each level
*******************************************************************/

$min = 10;	// minimum visible shouts in first level.
$max = 10;	// maximum number of shouts in second level (hidden).
$colors = array(
	103 => "#F75013",	// User name color for Super Admins
	102 => "#008000",	// User name color for Admins
	101 => "#3333CC"	// User name color for members
);

/******************************************************************/

echo "<script type='text/javascript'>
<!--
function toggle_lsup() {
	var smu = document.getElementById('show_more_users');
	var smutxt = document.getElementById('show_more_users_text');
	if (smu.style.display == 'none') {
		smu.style.display = 'block';
		smutxt.innerHTML = '".$locale['LSUP_010']."';
	} else {
		smu.style.display = 'none';
		smutxt.innerHTML = '".$locale['LSUP_009']."';
	}
}
//-->
</script>";

openside($locale['LSUP_000']);

echo "<table cellpadding='0' cellspacing='0' width='100%'  class=''>";
$result = dbquery("SELECT * FROM ".$db_prefix."users ORDER BY user_lastvisit DESC LIMIT ".($min + $max));
if (dbrows($result) != 0) {
	$user_count = 0;
	while ($data = dbarray($result)) {

/*******************************************************************
* Begin show more feature.
********************************************************************/

		if ($user_count == $min) {
			echo "</table>
<br>
<div align='center'>
<img alt='' border='0' src='".THEME."images/bullet.gif'>&nbsp;
<a href=\"javascript:void(0)\" onClick=\"toggle_lsup();\"><span id='show_more_users_text'>".$locale['LSUP_009']."</span></a>&nbsp;
<img alt='' border='0' src='".THEME."images/bulletb.gif'>
</div>
<div id='show_more_users' style='display: none;'>
<br>
<table cellpadding='0' cellspacing='0' width='100%'  class=''>";
			}

/*******************************************************************
* End show more feature.
********************************************************************/

		// Check if user has ever logged in
		if ($data['user_lastvisit'] != 0) {
			$lastseen = time() - $data['user_lastvisit'];
			$iW=sprintf("%2d",floor($lastseen/604800));
			$iD=sprintf("%2d",floor($lastseen/(60*60*24)));
			$iH=sprintf("%02d",floor((($lastseen%604800)%86400)/3600));
			$iM=sprintf("%02d",floor(((($lastseen%604800)%86400)%3600)/60));
			$iS=sprintf("%02d",floor((((($lastseen%604800)%86400)%3600)%60)));
			if ($lastseen < 60){
				$lastseen="".$locale['LSUP_001']."";
			} elseif ($lastseen < 360){
				$lastseen="".$locale['LSUP_002']."";
			} elseif ($iW > 0){
				if ($iW == 1) {
					$Text = $locale['LSUP_003'];
				} else {
					$Text = $locale['LSUP_004'];
				}
				$lastseen = "".$iW." ".$Text."";
			} elseif ($iD > 0){
				if ($iD == 1) {
					$Text = $locale['LSUP_005'];
				} else {
					$Text = $locale['LSUP_006'];
				}
				$lastseen = "".$iD." ".$Text."";
			} else {
				$lastseen = $iH.":".$iM.":".$iS;
			}
		} else {
			$lastseen = $locale['LSUP_007'];
		}
		echo "<tr>
<td class='small' align='left'>
<a href='".BASEDIR."profile.php?lookup=".$data['user_id']."'><font color='".$colors[$data['user_level']]."' title='".$data['user_name']." is located in: ".trimlink($data['user_location'] ? $data['user_location'] : $locale['LSUP_008'], 20)."'>".trimlink ($data['user_name'], 12)."</font></a>
</td>
<td class='small2' align='right'>".$lastseen."</td>
</tr>";
		$user_count ++;
	}
}
echo "</table>";
if ($user_count > $min) { echo "</div>\n"; }

closeside();
?>