U3Games

Games | Desarrollo & Soporte => L2 | Sección Web => Lineage => L2 | Codes Web => Mensaje iniciado por: Swarlog en Jun 13, 2025, 11:48 PM

Título: Estado del servidor y jugadores conectados
Publicado por: Swarlog en Jun 13, 2025, 11:48 PM
<?php/**==========================================================================================*================================= U3G | Lineage II ========================================*=========================== http://l2.united-extreme.com/ =================================*==========================================================================================*/function pingDomain($server, $port){	$start_time 	= microtime(true);     $file      		= @fsockopen ($server, $port, $errno, $errstr, 10);     $stop_time  	= microtime(true);     $status    		= 0;         if(!$file)    {    	 $status = -1;     }     else     {         fclose($file);         $status = ($stop_time - $start_time) * 12000;         $status = floor($status);     }         return $status; }/** Configuracion de la estabilidad del servidor:*/function server_status($ping = 0){	if($ping <= 50) 	{		$MessageStatus = 'Excelente';	}	elseif($ping <= 80)	{		$MessageStatus = 'Buena';	}	elseif($ping <= 100)	{		$MessageStatus = 'Normal';	}	elseif($ping <= 150)	{		$MessageStatus = 'Regular';	}	elseif($ping <= 999)	{		$MessageStatus = 'Mala';	}	else	{		$MessageStatus = 'Desconectado';	}		return $MessageStatus;}/** Configuracion de los datos del servidor:*/$server_1 	= 	'77.241.112.63';$port_1		= 	'7777';$server_2	=	'77.241.112.63';$port_2		=	'7777';$server_3	=	'77.241.112.63';$port_3		=	'7777';/** Datos del Login:*/$status = pingDomain($server_1, $port_1); $MessageStatus = server_status($status);	$upmessage = "<font size='2' color='black'><br>Estabilidad: </font><font color='gray' size='2'>$MessageStatus</font><br>"; $downmessage = "<font size='2' color='black'><br>Estabilidad: </font><font color='gray' size='2'>Nula</font><br>"; $tout = "5"; $serverg1 = @fsockopen ($server_1, $port_1, $errno, $errstr, $tout); if(!$serverg1){ 	echo "<br>		<font color='#C8B560' size='3' style='Arial'><strong>Login</strong></font>		<br>		<font size='2' color='black'>Estado:</font>		<font color='red' size='2' style='Arial'> Off</font>$downmessage"; } else { 	echo"<br>		<font color='#C8B560' size='3' style='Arial'><strong>Login</strong></font>		<br>		<font size='2' color='black'>Estado:</font>		<font color='green' size='2' style='Arial'> On</font>$upmessage"; } /** Datos del Servidor:*/$status = pingDomain($server_2, $port_2); $MessageStatus = server_status($status);	$upmessage = "<font size='2' color='black'><br>Estabilidad: </font><font color='gray' size='2'>$MessageStatus</font><br>"; $downmessage = "<font size='2' color='black'><br>Estabilidad: </font><font color='gray' size='2'>Nula</font><br>"; $tout = "5"; $serverg2 = @fsockopen ($server_2, $port_2, $errno, $errstr, $tout); if(!$serverg2){ 	echo "<br>		<font color='#C8B560' size='3' style='Arial'><strong>Game Server</strong></font>		<br>		<font size='2' color='black'>Estado:</font>		<font color='red' size='2' style='Arial'> Off</font>$downmessage"; } else { 	echo "<br>		<font color='#C8B560' size='3' style='Arial'><strong>Game Server</strong></font>		<br>		<font size='2' color='black'>Estado:</font>		<font color='green' size='2' style='Arial'> On</font>$upmessage";}/** Datos de la Comunidad:*/$status = pingDomain($server_3, $port_3); $MessageStatus = server_status($status);	$upmessage = "<font size='2' color='black'><br>Estabilidad: </font><font color='gray' size='2'>$MessageStatus</font><br>"; $downmessage = "<font size='2' color='black'><br>Estabilidad: </font><font color='gray' size='2'>Nula</font><br>"; $tout = "5"; $serverg1 = @fsockopen ($server_3, $port_3, $errno, $errstr, $tout); if(!$serverg1){ 	echo "<br>		<font color='#C8B560' size='3' style='Arial'><strong>Comunity Board</strong></font>		<br>		<font size='2' color='black'>Estado:</font>		<font color='red' size='2' style='Arial'> Off</font>$downmessage"; } else { 	echo"<br>		<font color='#C8B560' size='3' style='Arial'><strong>Comunity Board</strong></font>		<br>		<font size='2' color='black'>Estado:</font>		<font color='green' size='2' style='Arial'> On</font>$upmessage"; } /** Configuracion de la base de datos del servidor:*/define('hostas1', 'xx.xxx.xxx.xx'); define('db1', 'xxxxxxx'); define('useris1', 'xxxxxxx'); define('pass1', 'xxxxxxx'); $db_link1 = mysql_pconnect( hostas1, useris1, pass1 )or die( 'klaida<br><br>'.mysql_error() );$db_select = mysql_select_db( db1, $db_link1 )or die( 'klaida<br><br>'.mysql_error() );$chars=mysql_query("SELECT * FROM characters");$rows =mysql_numrows($chars);$i=0;$x=0;while ($i < $rows) {$online=mysql_result($chars,$i,"online"); if ($online == 1) { $x++; } $i++; }print 'Conectados: '.$x.''; /** By Swarlog*/?>