PDA

View Full Version : Users online



roly
March 18th, 2002, 04:27
Does anyone know a script that shos the users online? It can be in Perl or PHP (yes it can use mySQL)

Mika
March 18th, 2002, 12:25
http://www.hotscripts.com/PHP/Scripts_and_Programs/Counters/Real-Time/
-----------------------------------------------------------------------------------
http://www.hotscripts.com/Perl/Scripts_and_Programs/Counters/Real-Time/

invalid
March 18th, 2002, 19:11
curtosy of spoono.com


<?php
//fill in some basic info
$server = "localhost";
$db_user = "username";
$db_pass = "password";
$database = "users";
$timeoutseconds = 300;

//get the time
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;

//connect to database
mysql_connect($server, $db_user, $db_pass);

//insert the values
$insert = mysql_db_query($database, "INSERT INTO useronline VALUES
('$timestamp','$REMOTE_ADDR','$PHP_SELF')");
if(!($insert)) {
print "Useronline Insert Failed > ";
}

//delete values when they leave
$delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout");
if(!($delete)) {
print "Useronline Delete Failed > ";
}

//grab the results
$result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'");
if(!($result)) {
print "Useronline Select Error > ";
}

//number of rows = the number of people online
$user = mysql_num_rows($result);


//spit out the results
mysql_close();
if($user == 1) {
print("$user user online\n");
} else {
print("$user users online\n");
}
?>

shizzle
March 18th, 2002, 19:14
Try using cgi-resources.com. They have bunches more scripts than hotscripts.

Lokannon
March 19th, 2002, 18:48
Its called cgi-resources. Does that mean that its ALL cgi?? Cause PHP is better (in MY opinion... dont argue with me, I dont feel like it right now...), and faster. If it has PHP scripts too, id much rather go there. :D.

alien
March 19th, 2002, 19:49
Originally posted by Lokannon
Its called cgi-resources. Does that mean that its ALL cgi?? Cause PHP is better (in MY opinion... dont argue with me, I dont feel like it right now...), and faster. If it has PHP scripts too, id much rather go there. :D.

http://php.resourceindex.com/