What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Users Online Script

Users Online Script
Author: Message:
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
O.P. Tongue  Users Online Script
I need a quick script for the amount of usersonline :)

code:
<?php
// Configuration
$dbhost = "localhost";
$dbuser = "[to-add]"; // MySQL Username
$dbpass = "[to-add]"; // MySQL Password
$dbname = "[to-add]"; // Database Name
$timeoutseconds = 1200; // length of session, 20 minutes is the standard

$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
$ip = substr($REMOTE_ADDR, 0, strrpos($REMOTE_ADDR,"."));

// Connect to MySQL Database
@mysql_connect($dbhost,$dbuser,$dbpass);
@mysql_select_db($dbname) or die("No db");

// Add this user to database
$loopcap = 0;
while ($loopcap<3 && @mysql_query("insert into useronline values('$timestamp','$ip','$PHP_SELF')"))
{ // in case of collision
$timestamp = $timestamp+$ip{0}; $loopcap++;
}

// Delete users that have been online for more then "$timeoutseconds" seconds
@mysql_query("delete from useronline where timestamp<$timeout");

// Select users online
$result = @mysql_query("select distinct ip from useronline");
$user = @mysql_num_rows($result);

mysql_free_result($result);
@mysql_close();

// Show all users online
if ($user==1) {echo $user.' user online';} else {echo $user.' users online';}
?>



I was using that but my new hosts server does not use it right.

It can be mysql stored or txt file stored I do not care, if anyone could make thid quick script I would appciate it :)

This post was edited on 10-28-2005 at 04:02 PM by absorbation.
10-28-2005 03:44 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Users Online Script - by absorbation on 10-28-2005 at 03:44 PM
RE: Users Online Scipt - by Fourjays on 10-28-2005 at 03:58 PM
RE: Users Online Scipt - by absorbation on 10-28-2005 at 04:00 PM
RE: Users Online Scipt - by WDZ on 10-28-2005 at 04:06 PM
RE: Users Online Script - by absorbation on 10-28-2005 at 04:10 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On