The Little Guy Posted October 31, 2010 Share Posted October 31, 2010 I want to calculate user activity. I want be able know how many hours a user has been using my site, but if a user stays logged in and doesn't do anything for an hour, I don't want to add that hour of nothingness to their count of active hours. Any suggestions on how I should go about doing something like this? Quote Link to comment https://forums.phpfreaks.com/topic/217340-log-user-activity/ Share on other sites More sharing options...
MPeter Posted October 31, 2010 Share Posted October 31, 2010 Hello,The Little Guy. Perhaps the following JavaScript methods would be of interest for you: setTimeout() clearTimeout() I think the rest is obsolete because of your rank? Regards, MPeter Quote Link to comment https://forums.phpfreaks.com/topic/217340-log-user-activity/#findComment-1128602 Share on other sites More sharing options...
MPeter Posted October 31, 2010 Share Posted October 31, 2010 Hello again! Huh? Sorry for double-posting. But after having breakfast and a shower here I think I will integrate that idea to my site as well! Though! I have a few Javascripts through now, and I am into these files now: http://www.w3.org/TR/XMLHttpRequest/ http://www.w3schools.com/xml/xml_http.asp I think am going to post my first working result later on. Well my wife is awake, and it is nearly the local time for lunch here! And onions get not cut by themselves. *cough* Regards, MPeter Quote Link to comment https://forums.phpfreaks.com/topic/217340-log-user-activity/#findComment-1128610 Share on other sites More sharing options...
MPeter Posted October 31, 2010 Share Posted October 31, 2010 Hello, again. First, sorry for triple-posting. But no-one else did post something with code so far. And as I said here this is my first workaround about. Hey! I need a few more counts on my posts when I see 5,000+ on some users. j/k File #1: <html><head> <title>This File has a Title!</title> <script type="text/javascript"> var i = 0; function UserXMLHttpRequest () { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","note.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; MyTimestamp= new Date().getTime(); document.getElementById("userstatcontent").innerHTML= 'Hello ' +xmlDoc.getElementsByTagName("userstatcontent")[0].childNodes[0].nodeValue +'&mtime='+MyTimestamp+' World!'; i = i + 1; // :-) if (i < 9) window.setTimeout("UserXMLHttpRequest()", 10000); } </script> </head> <body onload="javascript:UserXMLHttpRequest();"> <h1>Test-File</h1> <p><b>userstatcontent:</b> <span id="userstatcontent"></span></p> </body> </html> File #2: <note> <userstatcontent>?some=text</userstatcontent> </note> It is based upon the Tutorial from here (with minor changes so far): http://www.w3schools.com/xml/xml_http.asp Well, I think things like window.innerWidth and window.innerHeight - which may change by some reason - can be added easily to this coding. Respectfully all the data which will appear, the use of a Javascript-Cookie I do see as recommended. These are the things I will try to add for myself next. When someone has any additional ideas and resources to link - please - do not hesitate, I got really greedy about this here, and I feel there must be something more than only this! I want to calculate user activity. I want be able know how many hours a user has been using my site, but if a user stays logged in and doesn't do anything for an hour, I don't want to add that hour of nothingness to their count of active hours. Any suggestions on how I should go about doing something like this? ps: Thank you for inspiring me so much. It was a very long time ago I have read such a beautiful description, really. And my native language is not english. A Big Thank You! It was great fun to read up these technical things once again, and to write something useful (for me). And I do hope I could have given an answer. Regards, MPeter Quote Link to comment https://forums.phpfreaks.com/topic/217340-log-user-activity/#findComment-1128627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.