Jump to content

L2jOrion.com - Interlude Server Files

Take a moment to join us, we are waiting for you.

Sign in to follow this  
maziqpl

LS&GS, online status (PHP?)

Recommended Posts

Hi,

Is any chance to get PHP Script for Login and Gameserver status and online number (similar like here on forum)?

Share this post


Link to post
Share on other sites
On 7/7/2019 at 8:24 PM, maziqpl said:

Hi,

Is any chance to get PHP Script for Login and Gameserver status and online number (similar like here on forum)?


Β 

$serverip = "185.80.128.233";
$lsport = "2106";
$gsport = "7777";

$servername = "database_ip";
$username = "database_username";
$password = "database_password";
$dbase = "database_name";

// fake online
$foc = 0;

try 
{
$conn = new PDO("mysql:host=$servername;dbname=$dbase", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} 
catch (PDOException $e)
{
	echo "Error: <font color=red>TS Database offline</font>";
}

$players = $conn->query("SELECT COUNT(*) `online` FROM `characters` WHERE `online` = '1'");
	$row = $players->fetch(PDO::FETCH_ASSOC);
	$players_online = (!$row['online']) ? 0 + $foc : $row['online'] + $foc;

function getStatus($serverip, $lsport)
		{
			if (fsockopen($serverip, $lsport, $errno, $errstr, 0.5))
			{
				return "<font color='#008C00'>ON</font>";
			}
			else
			{
				return "<font color='#ff0000'>OFF</font>";
			}
		}

		function getStatus2($serverip, $gsport)
		{
			if (fsockopen($serverip, $gsport, $errno, $errstr, 0.5))
			{
				return "<font color='#008C00'>ON</font>";
			}
			else
			{
				return "<font color='#ff0000'>OFF</font>";
			}
		}

if ($players_online >= 1) { $players_online = "<font color='008C00'>$players_online</font>"; }

<div id='frmonline' style='padding-left: 15px; padding-top: 5px; padding-bottom: 5px;'><center>
  Auth: <b>" . getStatus(''.$serverip.'',''.$lsport.'') . "</b> 
  World: <b>" . getStatus2(''.$serverip.'',''.$gsport.'') . "</b> 
  Online: <b><font color='ff0000'>$players_online</font></b> <br><br>
  </center></div>



Β 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

Γ—