TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   User online state indicator (http://www.talkphp.com/general/4654-user-online-state-indicator.html)

Peuplarchie 06-30-2009 07:22 PM

User online state indicator
 
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 :
PHP Code:


<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 Code:


<?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 !


All times are GMT. The time now is 06:57 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0