Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by Robin ( 19 years ago )
<?
//Script created under a BSD-Style license

//Database variables
$server         	= "localhost";  		// Your MySQL Server address. This is usually localhost
$db_user        	= "username"; 		    // Your MySQL Username
$db_pass        	= "password";	    	// Your MySQL Password
$database       	= "database";	        // Database Name

//Customizations
$timeoutseconds 	= "300";			// How long it it boefore the user is no longer online

//Only one person is online
$oneperson1       = "There is curently";  //Change the text that will be displayed
$oneperson2       = "person online.";     //Change the text that will be displayed

//Two or more people online
$twopeople1       ="There are currently"; //Change the text that will be displayed
$twopeople2       ="people online.";      //Change the text that will be displayed





//The following should only be modified if you know what you are doing
if($_SERVER['HTTP_X_FORWARDED_FOR']){
  $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else{
  $ip=$_SERVER['REMOTE_ADDR'];
}

$scripturl = $_SERVER[’PHP_SELF’];

$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
mysql_connect($server, $db_user, $db_pass) or die ("Error: Unable to connect to MySQL");
mysql_db_query($database, "INSERT INTO online VALUES ('$timestamp','$ip','$scripturl')") or die("Error: Can't insert data into database'");
mysql_db_query($database, "DELETE FROM online WHERE timestamp<$timeout") or die("Error: Unable to delete old entries from the database");
$result = mysql_db_query($database, "SELECT DISTINCT ip FROM online WHERE file='$scripturl'") or die("Error: Unable to select entries in the database");
$users  = mysql_num_rows($result);
mysql_close();

if ($user==1){
  echo"<font size=1>$oneperson1 $users $oneperson2</font>";
}
else{
  echo"<font size=1>$twopeople1 $users $twopeople2";
}
?>

 

Revise this Paste

Your Name: Code Language: