Jump to content

User online state indicator


Peuplarchie

Recommended Posts

Good day to you all,

              I working on a login / logout code, now I need to find out who is online and not.

 

              I was thinking of a javascript which would count time spend on page.

 

here it is :


<SCRIPT LANGUAGE="JavaScript">



<!-- Begin
startday = new Date();
clockStart = startday.getTime();
function initStopwatch() {
var myTime = new Date();
return((myTime.getTime() - clockStart)/1000);
}
function getSecs() {
    var tSecs = Math.round(initStopwatch());
    var iSecs = tSecs % 60;
    var iMins = Math.round((tSecs-30)/60);
    var sSecs ="" + ((iSecs > 9) ? iSecs : "0" + iSecs);
    var sMins ="" + ((iMins > 9) ? iMins : "0" + iMins);
    document.getElementById("timespent").value = sMins+":"+sSecs;
    window.setTimeout('getSecs()',1000);
}
// End -->
</script>


<BODY onLoad="window.setTimeout('getSecs()',1)">

<CENTER>
<FORM>
<input size=5 id="timespent" name="timespent">
</FORM>
</CENTER>


 

 

 

Now I need that for each increment of one minute, a txt file would be update (+1)


<?php
$File = "YourFile.txt";
$Handle = fopen($File, 'w');
$Data = "Jane Doe\n";
fwrite($Handle, $Data);
$Data = "Bilbo Jones\n";
fwrite($Handle, $Data);
print "Data Written";
fclose($Handle);
?>

 

 

Also

 

If the txt file reach a count of 15, user get logout automatically.

 

 

Can somebody help me include the last 2 point to my javascript code ?

 

Thanks !

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/164290-user-online-state-indicator/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.