|
|
|
|
![]() ![]() |
| welbis |
Nov 13 2004, 01:09 AM
Post
#1
|
|
Guests |
Simple 'User Online' script
If you use this, Please link back to my site at www.jesus-freaks.co.uk CODE /* First create/edit the user the table with at least these fields: */ CREATE TABLE user ( `id` int(11) NOT NULL auto_increment, 'username' varchar(40) NOT NULL, 'last_login' varchar(100) NOT NULL, PRIMARY KEY (last_login), ); CODE <? ////////////////////// /* next write the script to retrieve online users can be adjusted to appear anywhere on any page by copying the bit between //copy// and //end copy// to anywhere you wish. Without copying ti will show up when the url is file.php?page=usersonline assuming a name of file.php for this file */ $page = $_GET['page']; if($page == usersonline) { /////COPY////// $useronlinetable = user; $server = "localhost"; $db_user = "username"; $db_pass = "password"; $database = "database"; /// INSERT basic info for db connect mysql_connect($server, $db_user, $db_pass); $timeout = 120; /* ADJUST how long after a user has refreshed a page that user is said to be offline. Currently 2 minutes. Value in seconds. */ $date=time(); $date = $date+18000; $date = $date - $timeout; $sql_useron = mysql_query("SELECT * FROM users WHERE last_login > FROM_UNIXTIME($date)"); $users_row = mysql_num_rows($sql_useron); if ($users_row == 1) { $userp = "user"; $areis = "is"; } else { $userp = "users"; $areis = "are"; } print "There $areis $users_row $userp currently online<br><br>"; /* the following will display on page*/ while($row=mysql_fetch_array($sql_useron)) { print $row["username"].'<br>'; } /* end display on page*/ /////// END COPY///// } ?> Final Bit... CODE <? /*somewhere on the page you need to update the last login on page refresh my website has this all linked to an IM system that ive posted on here - and you can adapt it however you want*/ if (isset($_SESSION['username'])) { $date=time(); $date = $date+18000; $sql = mysql_query("UPDATE users SET last_login=FROM_UNIXTIME($date) WHERE id='$userid'"); } ?> |
|
|
|
| Fatal-Fatality |
Nov 13 2004, 01:14 AM
Post
#2
|
|
Guests |
Nice, I will see if I can edit this to view users on my IRC Server!
-Fatality |
|
|
|
| Meeko |
Nov 13 2004, 01:52 AM
Post
#3
|
|
Guests |
Sweet man. Thanks for the script.
|
|
|
|
| chakhei |
Dec 23 2004, 02:25 PM
Post
#4
|
|
Guests |
Thanks welbis,
Very useful script.. |
|
|
|
| Bandit |
Jan 6 2005, 05:29 PM
Post
#5
|
|
Guests |
nice and very easy.
good job |
|
|
|
| Bandit |
Jan 6 2005, 05:30 PM
Post
#6
|
|
Guests |
nice and very easy.
good job |
|
|
|
| nedra |
Feb 13 2005, 07:55 PM
Post
#7
|
|
Guests |
How to use it?
|
|
|
|
| diox |
Feb 13 2005, 11:36 PM
Post
#8
|
|
Guests |
simple and effective i like it
|
|
|
|
| blitzfx |
Feb 20 2005, 08:45 PM
Post
#9
|
|
Guests |
well, It is okay, but, I dont see the point in using the mySQL database, `cause, it is more easy for begginers to use a script like this one
LINK: http://www.saiyan-rebirth.com/index.php?id=pscripts |
|
|
|
| God |
Feb 20 2005, 09:49 PM
Post
#10
|
|
Guests |
This thread is old. I don't think there's any more discussion required.
~Locked. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 21st November 2008 - 04:47 AM |