kayaknya waktu itu ga ke upload balasan gw, karena mungkin waktu itu ada beberapa pertanyaan, dan ini gw kirain udah smua \.. mahap... tapi sbnernya udah gw bikinin tgl 1 des 2008
ni dia script na:
<? session_start(); ?>
<!--01 12 2008 08:25-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>User Stat Logged</title>
</head>
<body>
<?
error_reporting(0);
if($_GET['logout'] == 1)
{
unset($username);
unset($firstlog);
session_destroy();
}
if(!session_is_registered('username'))
{
if($_GET['login'] == 1)
{
$username = "dremigantengdancoolbanged"; //sample ajah
$firstlog = date("d-m-Y H:i:s"); //sample ajah
session_register('username');
session_register('firstlog');
echo "<meta http-equiv=\"refresh\" content=\"0;$_SERVER[PHP_SELF]\" />";
}
else
{
?>
<a href="?login=1">Login Here !</a>
<?
}
}
else
{
function loggedStat()
{
$time = strtotime(date('d-m-Y H:i:s')) - strtotime($_SESSION['firstlog']);
$hours = (int)floor($time/3600);
$minutes = (int)floor($time/60)%60;
$seconds = (int)$time%60;
if ($hours <= 0) {
$txt = "";
} else {
$txt = ($hours == 1) ? "".$hours." hour" : "".$hours." hours";
}
//$txt .= ($hours > 0 && $minutes > 0 && $seconds > 0) ? ", " : " and " ;
$txt .= ($hours > 0 && $minutes > 0 && $seconds > 0) ? ", " : " ";
$s = ($minutes > 1) ? "s" : NULL;
$txt .= ($minutes > 0) ? "".$minutes." minute".$s."" : "";
$s = ($seconds > 1) ? "s" : NULL;
$txt .= ($txt && $seconds>0) ? " and " : "";
if ($seconds > 0) {
$txt .= "".$seconds." second".$s."";
} elseif(!$txt and $seconds==0) {
$txt = "0 seconds";
}
return $txt;
}
?>
<meta http-equiv="refresh" content="10;<? echo $_SERVER['PHP_SELF']; ?>" />
<h2><? echo $_SESSION['username']; ?></h2>
<p>You are logged first time on: <? echo $_SESSION['firstlog']; ?></p>
<p>This time is: <? echo date("d-m-Y H:i:s"); ?></p>
<p>Logged Stats: <? echo loggedStat(); ?></p>
<p><a href="?logout=1">Clear Session !</a></p>
<p> </p>
<p>Refresh in every 10 second.</p>
<?
}
?>
</body>
</html>