Jump to content

[SOLVED] Currently online list?


DeanWhitehouse

Recommended Posts

i think cron is best way to do it, because you want something asyncronous that will reset your flags.

 

Crons are simple PHP script, which run periodically as per settings done..so i think that is safest way.

 

you can get to know more about crons here

 

http://www.unixgeeks.org/security/newbie/unix/cron-1.html

 

also google around for more info.

 

Example would be entry in crontab like

 

30  *     *     *     *    php /path/to/file/resetting/flag.php

 

Your file will run every 30 mins.

 

 

Link to comment
Share on other sites

What is the user does not refresh his page for 2 hours...the code which checks the cookie will be executed after 2 hours.. and your user wont log out till then

 

also if the browser is closed directly  the flag is not set to logout...

Link to comment
Share on other sites

this is the main part of the code

<?php
$sql = "SELECT * FROM users WHERE lastactive = '???' LIMIT $offset, $rowsperpage";
			$result = mysql_query($sql);
			// while there are rows to be fetched...
			while ($list = mysql_fetch_assoc($result)) {
			if($list['lastactive'] date
			   // echo data
			echo "<tr><td class='NormalContent' style='border:thin solid #AA4B00;'><a href='users.php?id=".$list['ID']."'>".$list['Username']."</a></td></tr>";
}
// end while
?>

 

timestamp is a mysql one. displayed as 2008-07-15 04:32:21

Link to comment
Share on other sites

ok, still not sure how to do it,

 

:(

 

would i do something like this

$date = date("hours,min,seconds");//odviously correct terms then, but something like this?
			$sql = "SELECT * FROM users WHERE lastactive <= '$date' LIMIT $offset, $rowsperpage";
			$result = mysql_query($sql);
			// while there are rows to be fetched...
			while ($list = mysql_fetch_assoc($result)) {

			   // echo data
			echo "<tr><td class='NormalContent' style='border:thin solid #AA4B00;'><a href='users.php?id=".$list['ID']."'>".$list['Username']."</a></td></tr>";
			}

Link to comment
Share on other sites

is this the correct thing

$time = mktime(date("s"), date("i")-2, date("h"), date("m"), date("d"),   date("Y"));
			$sql = "SELECT * FROM users WHERE lastactive >= '$time' LIMIT $offset, $rowsperpage";
			$result = mysql_query($sql);
			// while there are rows to be fetched...
			while ($list = mysql_fetch_assoc($result)) {

			   // echo data
			echo "<tr><td class='NormalContent' style='border:thin solid #AA4B00;'><a href='users.php?id=".$list['ID']."'>".$list['Username']."</a></td></tr>";
			}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.