/************************************************************************/
/* PHP-Nuke Platinum: Expect to be impressed COPYRIGHT */
/* */
/* Copyright (c) 2004 - 2006 by http://www.techgfx.com */
/* Techgfx - Graeme Allan (goose@techgfx.com) */
/* */
/* Copyright (c) 2004 - 2006 by http://www.conrads-berlin.de */
/* MrFluffy - Axel Conrads (axel@conrads-berlin.de) */
/* */
/* Copyright (c) 2004 - 2006 by http://www.nukeplanet.com */
/* Loki / Teknerd - Scott Partee (loki@nukeplanet.com) */
/* */
/* Refer to Nukeplanet.com for detailed information on PHP-Nuke Platinum*/
/* */
/* TechGFX: Your dreams, our imagination */
/************************************************************************/
if ( !defined('BLOCK_FILE') ) {
die("Illegal Block File Access");
}
global $cookie, $prefix, $currentlang, $dbi, $username, $numusers;
$prefix = "nuke";
$numusers = 11;
if(file_exists("language/lastseen/lastseen-$currentlang.php")) {
include("language/lastseen/lastseen-$currentlang.php");
}
else {
include("language/lastseen/lastseen-english.php");
}
$username = $cookie[1];
sql_query("CREATE TABLE IF NOT EXISTS $prefix"._lastseen." (id INT (15) not null AUTO_INCREMENT, username TEXT not null, date INT(15) not null, ip CHAR(50), PRIMARY KEY (id), UNIQUE (id))", $dbi);
if (isset($username)) {
$ip = getenv("REMOTE_HOST");
if (empty($ip)) {
$ip = getenv("REMOTE_ADDR");
}
$result = sql_query("SELECT * FROM $prefix"._lastseen." WHERE username = \"$username\"", $dbi);
if (sql_num_rows($result, $dbi) > 0) {
sql_query("UPDATE $prefix"._lastseen." SET date = " . time() . " WHERE username = \"$username\"", $dbi);
} else {
sql_query("INSERT INTO $prefix"._lastseen." VALUES (\"\", \"$username\", ".time().", \"".$ip."\")", $dbi);
}
}
$content = "";
$result = sql_query("SELECT username, date FROM $prefix"._lastseen." ORDER BY date DESC limit $numusers", $dbi);
while (list($uname, $date) = sql_fetch_row($result, $dbi)) {
if ($uname != $username) {
$realtime = time() - $date;
$dont = false;
// how many days ago?
if ($realtime >= (60*60*24*2)) { // if it's been more than 2 days
$days = floor($realtime / (60*60*24));
$dont = true;
} else if ($realtime >= (60*60*24)) { // if it's been less than 2 days
$days = 1;
$realtime -= (60*60*24);
}
if (!$dont) {
// how many hours ago?
if ($realtime >= (60*60)) {
//$content .= " ($realtime) ";
$hours = floor($realtime / (60*60));
$realtime -= (60*60*$hours);
}
// how many minutes ago?
if ($realtime >= 60) {
$mins = floor($realtime / 60);
$realtime -= (60*$mins);
}
// just a little precation, although I don't *think* mins will ever be 60...
if ($mins == 60) {
$mins = 0;
$hours += 1;
}
}
$myresult = sql_query("select user_id from nuke_users where (username='$uname')", $dbi);
list($uid) = sql_fetch_row($myresult, $dbi);
$content .= "".$uname.":";
if ($dont) {
$content .= " ".$days." "._LASTSEENDAYS."";
} else {
if ($days > 0) {
$content .= " ".$days." "._LASTSEENDAY."".(($hours == 0 && $mins == 0)?(""):(","));
}
if ($hours > 0) {
$content .= " ".$hours." ".(($hours > 1)?(""._LASTSEENHOURS.""):(""._LASTSEENHOUR."")).(($mins == 0)?(""):(","));
}
if ($mins > 0) {
$content .= " ".$mins." ".(($mins > 1)?(""._LASTSEENMINUTES.""):(""._LASTSEENMINUTE.""))."";
} else { // less than a minute :)
$content .= " ".$realtime." "._LASTSEENSECONDS."";
}
}
$content .= " "._LASTSEENAGO."
";
$days = 0;
$hours = 0;
$mins = 0;
$dont = false;
}
}
$content .= "";
?>