View Single Post
  #26  
Old 08-21-2005, 01:55 AM
Magoth78
Discordant
 
Join Date: Jun 2003
Posts: 345
Default

Number of users online, their names and the number, using php.

It's my first Php code so don't be rude if it's extremly ugly, basic.
It will show the name and the amount of the connected characters char.

Code:
<?php


$Server = 'Host.com';
$Port    = 9000;
$user  = "your_user\r"; 
$pass  = "your_pass\r";            

$fp = fsockopen($Server, $Port);
	
       		fputs ($fp, $user);
		usleep(125000);   
      		fputs ($fp, $pass);
		usleep(125000);
       		fputs ($fp, "who\r"); 
		usleep(125000);

		          do
			 {
			  $output = fgets($fp);
			  $output = str_replace("Username: Password: Login accepted.", "", $output);
			  $output = str_replace($user">", "", $output);
			  $output = str_replace("who", "", $output);
 			  $output = str_replace("Players", "", $output);
			  $output = str_replace("on", "", $output);
                          $output = str_replace("server:", "", $output);
			  $output = str_replace("line", "", $output);
                          $who = preg_replace('#^.*]\s+(.*?)\(.*$#','\1',$output);
			  
                                echo $who;
				if (preg_match("/Players/i", $who)) {
				Break;
				}
			  }
		while(!feof($fp));
		fclose($fp);
?>
Mag
__________________
User's projects:
-- Original EMPIRE I/II and Factions! servers
-- Web GM Portal
-- EQoffline/bots

Last edited by Magoth78; 08-23-2005 at 08:03 AM..
Reply With Quote