TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-30-2009, 07:22 PM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application 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 !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy to Modify Login Script with Hierarchical User Permissions and XML Account File Wildhoney Script Giveaway 4 05-04-2011 06:11 AM
Automatic User Removal Seraskier Advanced PHP Programming 8 03-24-2009 08:39 AM
Zend Acl on individual user? kokjj87 Advanced PHP Programming 0 02-13-2009 03:19 PM
Need help with a User class maZtah General 10 01-13-2009 07:02 PM
User profile page h0ly lag General 2 05-08-2008 08:53 PM


All times are GMT. The time now is 05:19 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design