Page 2 of 3
Posted: Sat Jul 12, 2003 11:59 am
by Heavy
Firstly:
Define what beeing online is.
If beeing online is when you have a page (without frames) open and doing nothing with the server, you have a problem.
One solution could be to write a flash or java applet and let it access something on a regular basis, and let that keep track of who does what.
If beeing online is about fetching new pages now and then, you could always register the access time of a user when he loads a page. If that timestamp is too old, he's offline.
Posted: Sat Jul 12, 2003 12:20 pm
by alexus
Online is when the browser window is open and link with server exist...
Posted: Sat Jul 12, 2003 12:53 pm
by ik
But why don't just to write into $_SESSION[] time of last user login - and then check it? It seems to be much more secure than using of client-side applets.
Posted: Sat Jul 12, 2003 1:13 pm
by m3rajk
because let's say i login at 10 but keep on the site till 1700
at some point it'll say i'm offline when i'm here answering people. what they would have to do for your suggestion is "last page load" in session and look at that. but that wouldn't work. they want tohers to know when you're online
that requires a db feild to check.
personally i don't think it would be a big strain on a db, so i'm thinking of using that.
Posted: Sat Jul 12, 2003 3:39 pm
by mudkicker
that job belongs to DATABASE

Posted: Sat Jul 12, 2003 10:03 pm
by alexus
Enough theory please

(we are not at school here), I still not quit sure how to do a finale script…
I like the example that count the number of session files, but it can’t show me the “names” of the users… I tried to play with msession_list() but I didn’t get it to work…
And actually I (and probably every one else) don’t cares will it use DB or no, because we can record page load time at any time we want…

Let assume that we will use that session example than how can I gat the username from the session files… (Certainly the session contains not only username but also things like access levels + some temp info and ip)
PS: Does anyone know how ICQ online status works (like that web based ISQ and regular Win APP)
Posted: Sat Jul 12, 2003 11:58 pm
by m3mn0n
habitat675 wrote:I have mine run an inline frame that refreshes every 50 seconds or so and updates the user's status. then another script deletes all files older than 1 minute and displays all of the file names for the rest (which are named as user's names). It probably wouldn't be very efficient for a large site but for mine it runs quickly and works well.
I think that is the best method. Inline frames aren't like regular frames. they don't take up any horizontal or vertical web space. They are hidden from the user within the code (by making them 1px by 1px in width+height and blending in the BG of the inline with the bg of the page). This provides for a very powerful solution and a very slick solution since it's practically invisible to a user who doesn't view source. And in theory, it is the best solution.
And I would imagine it would work best with big sites, habitat.
my 2 cents.
Posted: Sun Jul 13, 2003 12:02 am
by m3mn0n
alexus wrote:Enough theory please

(we are not at school here)
Good PHP programming requires a lot of theory. As goes with most other things.
Maybe that's why this simple solution is so hard to find for you? hmmm, just a thought.
Theory = good.
Posted: Sun Jul 13, 2003 4:45 am
by mudkicker
log.php
Code: Select all
<?
if (!isset($user) or !isset($pass) or empty($user) or empty($pass))
{
header( "Location: index.php" );
}
else
{
$connect= mysql_connect("localhost","root","boot") or die("Cannot connect to the server! Please try again later.");
mysql_select_db("db_cv",$connect) or die("Cannot connect to the database! Please try again later.");
$query = mysql_query("SELECT * FROM tbl_users WHERE user='$user' AND pass='$pass'",$connect);
$row = mysql_fetch_array($query);
$num = mysql_num_rows($query);
if ($num > 0)
{
session_start();
session_register("user","uname","dbname","dbpass");
$uname = $rowї"name"];
$dbname = $rowї"dbname"];
$dbpass = $rowї"dbpass"];
header("Location: admin.php");
}
else
{
echo "Incorrect login name or password. Please try again.";
}
mysql_close($connect);
}
?>
---------------------------------------------------------------------------
ADMIN.PHP (ONLY THE PARTS WHERE YOU USE NAMES FROM SESSION)
Code: Select all
<td width=150><div align="center"><a class="arif" href="logout.php">Logout <? echo $uname; ?></a></div></td>
------------------------------------------------------------------------
SECURE.PHP
Code: Select all
<?
ob_start();
session_start();
if(!session_is_registered("user"))
{
header("Location: index.php");
session_unset();
exit();
}
?>
By the way, Secure.php is included in admin.php at the beginning of document.
(require("secure.php");)
Posted: Sun Jul 13, 2003 5:14 am
by Gen-ik
I use the IFRAME method myself as it seems to be the best way.
The only difference is I put the IFRAME within a DIV and just set the position:absolute and the visibility:hidden in it's style... that way it is completely invisible and doesn't take up any page space at all.
Another use for this is to have the IFRAME pull information from say a 'shout box' database and then use a bit of javascript... object.innerHTML .... to update some page content on-the-fly without the user having to refresh the main page at all.
You could use the same method to update who is on-line more or less in real-time without the user having to refresh the page to find out.
And..... ( I've nearly finished )...... how about alerting the user using the same method whenever they get a new reply added to their forum topics.. or get a new note from another user!?
As the old saying goes "It's not what you've got, it's how you use it".
Posted: Sun Jul 13, 2003 5:20 am
by m3mn0n
I never thought about that DIV tag invisibility thing to be used for this, hmm i like it.
About refreshing; using a meta-refresh in the <head> tag to refresh every 5 seconds should do the trick also.
Posted: Sun Jul 13, 2003 7:58 am
by m3rajk
ummm... not everyone has iframe support.
if you really want it to be universal then you want to have it so that everyone can use ithave table "last access"
it takes two fieds, username and access time
select * from last_access where access_time <5 min ago sort by username
easy and universal
Posted: Sun Jul 13, 2003 8:19 am
by Gen-ik
m3rajk wrote:ummm... not everyone has iframe support.
Well... my view on that is that all modern browsers can use IFRAMEs... if people are still using browsers old enough not to support IFRAMEs then they don't deserve to access the site. simple.
I can't stand people who can't be bothered to update their browser.. it holds back website development and the evolution of the web as a whole.
These days I develop sites for IE5+ and NS6+ only.. if you don't have either of those then you don't get access to the site.
Having to constantly downgrade sites and limit the possibilites of website development just to keep the people using old browsers happy won't last much longer because people will just get fed up of being held back.
..a bit off-topic but those couple of words really annoyed me.. sorry!
Posted: Sun Jul 13, 2003 8:32 am
by m3rajk
well.. the site i'm making, we decided that we wanted a certain set up and that it would require them.
ie is only at 6. i think 5 doesn't have full iframe support but 5.5 does. enough people still use 5...
i knoq a lot of people switched to mozilla iinstead of netscape 6.
mozilla is actually better with all that. i know because i'm one of them. and those i know that didn't switch to netscape 6 ( a small number) use 4.81, the last 4.xx that will be made according to netscape.
personally, i know that i consider what i'm making the site for with what i use. i don't een use frames if i am making a site for someone that wants it to be universally accessable. (haven't done that in ages)
at this point anyone that doesn't have the support of iframes is problaby using a web clipper or text-only (ie: lynx... yes it's still around)
Posted: Sun Jul 13, 2003 8:46 am
by m3mn0n
I agree. I have the "If you don't bother having to the latest software, why should i adjust my code/design to suit your needs?" mentality also.
No update = No site. Plain and simple.
