Skocz do zawartości

Rekomendowane odpowiedzi

Opublikowano

Witam jak zrobić aby wykonywany był od PHP w modyfikacji DawPiego pt. Pages? Mam taki kod:

<?php
	/*
	****************************************************************************
	**
	**	Skrypt:		  Własny monitoring serwera
	**	Wymagania:		Serwer www z obsługą php i biblioteki GD2 oraz klasą HLSOCKET
	**	Wersja:	 1.0
	**	Autor: 		 Leihto
	**	Wykonane dla Graj24.eu
	**
	****************************************************************************
	*/
	/*					Ustawienia do personalizacji skryptu				*/
	/*	Wszystkie grafiki	*/
	$grafiki = array(
		1 => "status/img/podstawa.png",		# Obrazek podstawa
		2 => status/img/cs.gif",		# Ikonka CS
	);
	/*		Czcionka		*/
	$font = 'status/verdana.ttf';
	/*		Szerokość i wysokosc obrazka	*/
	$szerokosc = 350; 
	$wysokosc = 20;
	
	/*		Czy ma być usuwany hosting serwera?	0 - Nie, 1 - Tak		*/
	$usun_hosting = 1;
	
	/*		Pobieranie ip serwera		*/
	if(strpos($_GET['ip'], ":"))
		$ip = $_GET['ip'];
	else
		$ip = "192.168.1.1:27025";
		
	/*		IP tylko jednego serwera	*/
	# $ip = "192.168.1.1:27025";
	
	
	/*		Tych rzeczy nie tykać jeśli się nie zna php!		*/
	
error_reporting(0);

/* Info string */
define('A2S_INFO', "\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00");

/* Replies for HL Version 1 and Version 2 (aka Source) */
define('REPLY_INFO_HL1', 'm');
define('REPLY_INFO_HL2', 'I');

/* Definitions of the bytes */
define('BYTE',     1);
define('BYTE_NUM', BYTE + 1);
define('SHORT',    BYTE_NUM + 1);
define('LONG',     SHORT + 1);
define('FLOAT',    LONG + 1);
define('STRING',   FLOAT + 1);

/**
 * The socket class
 * @author Herwin Weststrate aka Hdez
 * @contact [email protected]
 * @version 2005.10.21
 */
class HLSocket
{
	/* The socket file descriptor */
	var $_socket;

	/* The way to split the incoming data */
	var $_split_info_hl2 = array('type' => BYTE, 'bersion' => BYTE_NUM, 'hostname' => STRING, 'map' => STRING, 'gamedir' => STRING, 'gamedesc' => STRING, 'appid' => SHORT, 'unknown' => BYTE_NUM, 'players' => BYTE_NUM, 'max' => BYTE_NUM, 'bots' => BYTE_NUM, 'dedicated' => BYTE, 'os' => BYTE, 'passworded' => BYTE_NUM, 'secure' => BYTE_NUM, 'gameversion' => STRING);
	var $_split_info_hl1 = array('type' => BYTE, 'ip' => STRING, 'hostname' => STRING, 'map' => STRING, 'gamedir' => STRING, 'gamedesc' => STRING, 'players' => BYTE_NUM, 'max' => BYTE_NUM, 'version' => BYTE_NUM, 'dedicated' => BYTE, 'os' => BYTE, 'passworded' => BYTE_NUM, 'secure' => BYTE_NUM, 'gameversion' => STRING);

	/**
	 * Create a new socket
	 * @param $host The ip or hostname
	 * @param $port The port
	 */
	function HLSocket($host, $port)
	{
		$this->connect($host, $port);
	}

	/**
	 * Actually make the connection to the host
	 * @param $host The ip or hostname
	 * @param $port The port
	 */
	function connect($host, $port)
	{
		$this->_socket = @fsockopen('udp://'.$host, $port);
		if (!$this->_socket)
			echo 'Error met connecten';
		stream_set_timeout($this->_socket, 1); // Set timeout to 1 sec
	}

	/**
	 * Close the connection (and the socket fd)
	 */
	function close()
	{
		fclose($this->_socket);
	}

	/**
	 * Query the server for the details
	 * @return associative array with the game info
	 */
	function details()
	{
		$this->write(A2S_INFO);
		$data = $this->read();
		$res = array();
		switch(substr($data, 0, 1))
		{
			case REPLY_INFO_HL1:
				$res = $this->split($this->_split_info_hl1, $data);
				break;
			case REPLY_INFO_HL2:
				$res = $this->split($this->_split_info_hl2, $data);
				break;
		}
		return $res;
	}

	/**
	 * Write the given message over the socket
	 * @param $msg The message to be written
	 * @deprecated This should be issued as a private function
	 */
	function write($msg)
	{
		fwrite($this->_socket, $msg);
	}

	/**
	 * Read from the socket
	 * @return The data from the socket (excluding the first four [useless] bytes)
	 * @deprecated This should be issued as a private function
	 */
	function read()
	{
		$data = fread($this->_socket, 1);
		$status = socket_get_status($this->_socket);
		if (isset($status['unread_bytes']) && $status['unread_bytes'] > 0)
			$data .= fread($this->_socket, $status['unread_bytes']);
		return substr($data, 4);
	}

	/**
	 * Split the given datatype from $data String and return the value
	 * @param $type The data type [BYTE .. STRING]
	 * @param $data The current data String
	 * @return The value of the given data type from $data
	 * @deprecated This should be issued as a private function
	 */
	function splititem($type, &$data) {
		$add = '';
		switch ($type)
		{
			case BYTE:
				$add = substr($data, 0, 1);
				$data = substr($data, 1);
				break;
			case BYTE_NUM:
				$add = ord(substr($data, 0, 1));
				$data = substr($data, 1);
				break;
			case SHORT:
				$add = ord(substr($data, 0, 1));
				$data = substr($data, 1);
				break;
			case LONG:
				$add = ord(substr($data, 0, 1));
				$data = substr($data, 1);
				break;
			case STRING:
				do
				{
					$char = substr($data, 0, 1);
					if ($char != "\x00")
						$add .= $char;
					$data = substr($data, 1);
				}
				while ($char != "\x00");
				break;
		}
		return $add;
	}

	/**
	 * Split the given datatypes from $data String and return the value
	 * @param $array The data type [BYTE .. STRING] as values of an
	 *               associative array. The keys are also the keys of
	 *               the return array
	 * @param $data The current data String
	 * @return Associative array with keys of $array and values read from $data
	 * @deprecated This should be issued as a private function
	 */
	function split($array, $data)
	{
		$res = array();
		foreach ($array as $k=>$v)
			$res[$k] = $this->splititem($v, $data);
		return $res;
	}
}
	
	header ('Content-type: image/png');
	$input = imagecreatefrompng($grafiki[1]);
	
	$cs = imagecreatefromgif($grafiki[2]);
	imagecopymerge($input, $cs, 2, 2, 0, 0, 16, 16, 75);
	imagedestroy($cs);
		
	/* kolory */
	$white = imagecolorallocate($input, 255, 255, 255);
	
	$ip2 = explode(':', $ip);
	$hlsocket = new HLSocket($ip2[0], $ip2[1]);
	$row = $hlsocket->details();
	if($row['map'] == NULL) $on = 0;  else $on = 1;
			
	if($on >0)
	{
		if($usun_hosting > 0)
			$nazwa_serwera = explode('@', $row['hostname']);
		else
			$nazwa_serwera[0] = $row['hostname'];
		
		imagettftext($input, 7, 0, 30, 9, $white, $font, $nazwa_serwera[0]);							# Nazwa Serwera
		imagettftext($input, 6, 0, 25, 18, $white, $font, $ip);															# IP Serwera
		imagettftext($input, 6, 0, 140, 18, $white, $font, $row['players'].'/'.$row['max']);		# Gracze
		imagettftext($input, 6, 0, 190, 18, $white, $font, $row['map']);										# Mapa serwera
	}
	else
	{
		imagettftext($input, 7, 0, 30, 9, $white, $font, "Serwer jest offline");
		imagettftext($input, 6, 0, 25, 18, $white, $font, $ip);
		imagettftext($input, 6, 0, 140, 18, $white, $font, "0/0");
		imagettftext($input, 6, 0, 190, 18, $white, $font, "N/A");
	}
	$hlsocket->close();
	imagepng($input, NULL);
?>

pod.png

Opublikowano

Każdy plik w naszej bazie posiada swój własny temat z supportem. Proszę pisać w nim, by nie utrudniać niepotrzebnie życia innym użytkownikom i by gromadzić w jednym miejscu sprawy związane z daną modyfikacją.

Dziękujemy!

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.