Jump to content

Recommended Posts

is this the one you were talking about ?

 

<?php
if ($_SESSION['admin']['intime'] != '') {
if ($_SESSION['admin']['intime'] < time() - 1800) {
session_unset('admin');
$over = "1800";
echo "ERROR: you have been idle for more than 1800 seconds. Please login again";
}}

$_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';

switch ($_action) {
default:
	if (!isset($_SESSION['admin'])) {
	if ($over != "1800") {
	echo 'Authorization Required.  Please log in.'
	}
	// login form html here
	} else {
		include of the page you wish to show
	}

break;

case login:
	if ($_REQUEST['act'] != "login") {
		if (isset($_SESSION['admin']) ) {
			// update session
		}
		if ($_SESSION['admin']['username'] != '') {
			// include of the page you want to view
		} else {
			if ($over != "1800") {
				echo "authorization required";
			}
			// login form include
		}
	} else {
		// the query to the database, (use LIKE BINARY for case sensitivity)
// also the cookie/session creation would go here
		if ($login == "true") {
		// show the actual page you want them to view 

		} else {
		// show the login form				
		}
	}
break;
}

?>

 

Thanks,

 

~ Chocopi

No that is a login script -- this is from a LONG LONG time ago -- let me see if i can find it on here for you.

 

-- edit:

 

after doing some searching I found my code...

 

<?php
$time = time() - 60 * 15;
$mems = "SELECT * FROM members WHERE last_activity <= $time";
$mems = mysql_num_rows(mysql_query($mems), 0);
$guest = "SELECT * FROM online_guests";
$guest = mysql_num_rows(mysql_query($guest), 0);
$tot = "SELECT * FROM members";
$tot = mysql_num_rows(mysql_query($tot), 0);
echo $mems." members online";
echo $guest." guests online";
echo $tot." total members";
?>

 

That code will generate a count of each who are online...  please note that I am no longer using this code, but it did work @ the time of conception -- you will need to modify it a little to fit your application.

 

<?php
$time = time() - 60 * 15;
$mems = "SELECT * FROM members WHERE last_activity <= $time";
$mems = mysql_query($mems);
$cnt = mysql_num_rows($mems);
for ($i = 0; $i < $cnt && $rows = mysql_fetch_assoc($mems); $i++) {
echo $rows['username'].', ';
}
?>

 

This here will give you a list of usernames who are currently online (within 15 minutes)...  This has not been tested, but by the looks of things should work without any problems....

 

<?php
$time = time() - 15 * 60
$mem = "SELECT inout FROM users WHERE username = '$user_name'";
$mem = mysql_query($mem);
$mem = mysql_result($mem, 0);
if ($mem == "in") {
echo '<img src="in.gif">';
} else {
echo '<img src="out.gif">';
}
?>

 

This here is to have a online/offline image next to a users name, in a forum setting this would need to be dramatically changed as this will only do a single user instead of all the users who have posted in a forum or whatever...

 

I hope that these 3 code samples help you in figuring out what you want and need to do, to get something working for your site.  And as I say to everyone, if you need any help I am only a PM away.

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.