Jump to content

Recommended Posts

For cronjob read my blog:

http://anl4u.freeweb7.com/blog/index.php?cat=13

 

And i think no other way to do it.you can use a logout button for users.but that is not time specific and also not reliable

because some time user close browser,so the online field in table will always 1.

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.

 

 

ok, i judst had an idea to do it, need some help with logic though

 

i am going to get the timestamp from the db, then do

 

if($timestamp <= date("") - 2)

{

 

}

 

would that work, and what would i do in the date ? do i need to convert the time stamp fisrt?

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

okay, take a look at

 

mktime() function

strotime() function

date() function

 

you want to make a time stamp that is x mins in the past and check for lastactive times greater than that, you'll need to format the timestamp so it displays like the mysql timestamp.

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>";
			}

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>";
			}

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.