Re: [PHP-DB] How many users From: kenji chan (kenjikenji <email protected>)
Date: 11/13/00

""Enrico Comini"" <algobit <email protected>>
news:NCBBIOBMPJJBPJICNDLLCEKDEBAA.algobit <email protected>
> There is a way in php to check the number of users connected to site ?
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe <email protected>
> For additional commands, e-mail: php-db-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
>
*************
yes, the code here !!!!
**online.php**

<HTML>
<HEAD>
<TITLE>Kenji PHP Online</TITLE>
</HEAD>
<BODY background="" BGCOLOR="#006699" onLoad="updateTime()">
<center>
 <div ID="TimeDiv" style="position: absolute; left: 100; top: 100;"></div>
  <?php

 $refreshmin = 6;
 $ofile = fopen("i.love.sandy","w");
 flock($ofile,1);
 while ($buffer = fgets($ofile, 4096)) {
  list($temp, $thetime) = split(",", $buffer, 2);
  if ((time() - $thetime) < ($refreshmin * 60)) {
     $users[$temp] = $thetime;
   $countnow++;
  }
 }
 flock($ofile,3);
 fclose ($ofile);

 $key = getenv("REMOTE_ADDR");
 if (!(isset($users[$key]))) {$countnow++;}
 $users[$key] = time();

 $nfile = fopen("i.love.sandy","w");
 while (list($key, $val) = each($users)) {
  fwrite($nfile,"$key,$val\n");
 }
 fclose ($nfile);

  ?>

</center>

<SCRIPT language="JavaScript">
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
var now = new Date(<?php echo date("Y"),",",date("n")-1,",",date("d,H,i,s")
?>);
var diff = new Date;
var iTimed = new Date;
var base = new Date;
var old = 0;
function updateTime() {
 var CDate = new Date;
 diff.setTime(CDate.getTime()-now.getTime());
 printTime();
}

function printTime() {
 var CDate = new Date;
 now.setTime(CDate.getTime()-diff.getTime());
 iTimed.setTime(now.getTime() - 25200000)
 txt = now.getHours() +":" + TwoDigits(now.getMinutes()) + ":" +
TwoDigits(now.getSeconds());
 var iTime = Math.floor((iTimed.getHours() * 3600 + iTimed.getMinutes() * 60
+
 iTimed.getSeconds()) * 5 / 432);
 txt += " iTime @" + iTime;
 if ((CDate.getTime()-base.getTime())>300000) {
  location.reload(true);
 }
 txt = '<span style="font-family: ; font-size: 12pt;"><B>'+txt+'<?php
print("<BR>$countnow People")?>'+'</B></span>';
 if (ns4) {
  var lyr = document.TimeDiv.document;
  lyr.write(txt);
  lyr.close();
 }
 else if (ie4) document.all["TimeDiv"].innerHTML = txt;
 setTimeout("printTime()",1000);
}

function TwoDigits(a) {
 if (a<10) {
  a = "0" + a;
 }
 return a;
}

</SCRIPT>

</BODY>

</HTML>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>