Jump to content

user online


RogerB

Recommended Posts

I am trying to use a "user online script I found.......Being that I just just spent the last 3 hours searching for an answer, I am posting here.  All you have to do is use the "include" function to make it appear, but, it totally jacks up the phhpvms code when you add it(you can't view pages, no other php code will show) things like that..  Here is the code, see if any of you spot a problem.

<?php
//Script created by janssens.org.uk under the GNU GPL
//For help with this please go to: http://janssens.org.uk/repository/php/php-user-online-script/

//Database variables
$server         	= "localhost";  		// Your MySQL Server address. This is usually localhost
$db_user        	= "****"; 		    // Your MySQL Username
$db_pass        	= "******";	    	// Your MySQL Password
$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 ($users==1){
  echo"<font size=1>$oneperson1 $users $oneperson2</font>";
}
else{
  echo"<font size=1>$twopeople1 $users $twopeople2";
}
?>

Link to comment
Share on other sites

i dont know if this would help and not sure if you added it in there but maybe take out the font sizeing. I added a users online code on my site that just uses a txt file simple yet effective, and it had divs and all this other crap where the code was to show up i took that out and it works just like its suppose to now.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...