Welcome Guest ( Log In | Register)



 
Closed TopicStart new topic
> Who's online?
welbis
post 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 smile.gif

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'");



}

?>

Go to the top of the page
 
+Quote Post
Fatal-Fatality
post 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! biggrin.gif

-Fatality
Go to the top of the page
 
+Quote Post
Meeko
post Nov 13 2004, 01:52 AM
Post #3





Guests






Sweet man. Thanks for the script. biggrin.gif
Go to the top of the page
 
+Quote Post
chakhei
post Dec 23 2004, 02:25 PM
Post #4





Guests






Thanks welbis,

Very useful script..
Go to the top of the page
 
+Quote Post
Bandit
post Jan 6 2005, 05:29 PM
Post #5





Guests






nice and very easy.
good job
Go to the top of the page
 
+Quote Post
Bandit
post Jan 6 2005, 05:30 PM
Post #6





Guests






nice and very easy.
good job
Go to the top of the page
 
+Quote Post
nedra
post Feb 13 2005, 07:55 PM
Post #7





Guests






How to use it?
Go to the top of the page
 
+Quote Post
diox
post Feb 13 2005, 11:36 PM
Post #8





Guests






simple and effective i like it
Go to the top of the page
 
+Quote Post
blitzfx
post 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
Go to the top of the page
 
+Quote Post
God
post Feb 20 2005, 09:49 PM
Post #10





Guests






This thread is old. I don't think there's any more discussion required.

~Locked.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. The Naruto Online Game(42)
  2. Online Quiz Generator(4)
  3. Which Online Payment Method Do You Use Most?(15)
  4. Private Server Ro .(165)
  5. Grand Theft Auto San Andreas Online Multiplayer Mode(15)
  6. Make Money Online!(25)
  7. Have You Ever Lied Online?(52)
  8. Boltblue: Beware!(20)
  9. Free Online Pictures(5)
  10. Boy Strangles Old Lady To Play Online(6)
  11. Im Addicted To Online Forums Hahaha(12)
  12. Learn Html, Css, C And C++ Online For Free(13)
  13. Selling Myself Online For Money!(16)
  14. Credit System V3.0 Online(158)
  15. San Andreas Multiplayer(4)
  1. Online Divorcee Jailed After Killing Virtual Hubby(8)
  2. Make Income Online(2)
  3. Make Money Online(1)
  4. Can You Make Lots Of Money Online With Very Little Effort?(17)
  5. Yes You Can Make Money Online(3)
  6. Pandanda - Online Virtual World For Kids(4)
  7. Warhammer Online Review(2)
  8. Shot Online(0)
  9. 'king-war', A Free Online Strategy Game, Play Both In Web And Client(1)
  10. A Really Cool Online Color Picker: Kuler.adobe.com(0)
  11. Designing An Online Community Center Site(4)
  12. Javascript Game(6)
  13. Advice For Online Game Please!(1)


 



- Lo-Fi Version Time is now: 21st November 2008 - 04:47 AM