iGuest 3 Report post Posted November 13, 2004 Simple 'User Online' script If you use this, Please link back to my site athttp://forums.xisto.com/no_longer_exists/ /* 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), ); <?///////////////////////* next write the script to retrieve online userscan 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 connectmysql_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...<?/*somewhere on the page you need to update the last login on page refreshmy 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'");}?> Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 13, 2004 Nice, I will see if I can edit this to view users on my IRC Server! -Fatality Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 13, 2004 Sweet man. Thanks for the script. Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 23, 2004 Thanks welbis,Very useful script.. Share this post Link to post Share on other sites
iGuest 3 Report post Posted January 6, 2005 nice and very easy.good job Share this post Link to post Share on other sites
iGuest 3 Report post Posted January 6, 2005 nice and very easy.good job Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 13, 2005 How to use it? Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 13, 2005 simple and effective i like it Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 20, 2005 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 oneLINK: http://www.saiyan-rebirth.com/?id=pscripts Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 20, 2005 This thread is old. I don't think there's any more discussion required.~Locked. Share this post Link to post Share on other sites