2076 Posts in 483 Topics- by 820 Members - Latest Member: akunp2

Pages: [1]   Go Down
  Print  
Author Topic: statistika  (Read 721 times)
cinta
phpBB Guru
*
Offline Offline

Posts: 5


View Profile Email
« on: November 30, 2008, 06:33:18 PM »

mr... tolong kasih contoh script pembuatan statistika untuk mengetahui lama nya login  masing -2 user. mathur thankyu... (jangan lama-2 yach) penting!!!  :D
Logged
webmaster
Administrator
phpBB Guru
*****
Offline Offline

Posts: 924


hairulazami
View Profile WWW
« Reply #1 on: December 13, 2008, 09:37:14 AM »

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:

Code:
<? 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>&nbsp;</p>
<p>Refresh in every 10 second.</p>
<?
}
?>
</body>
</html>
Logged


Pages: [1]   Go Up
  Print  
 
Jump to: