Need help ! PHP
#1

Hello, this is functional code, but when the offline server is not so, please help me THX

Код:
<?php
header("Content-type: image/png");
if(isset($_GET["ip"]))
{
	$ip = $_GET["ip"]; 
	$port = $_GET["port"];

	$img = ImageCreateFrompng("./1.png");
	
	$color = ImageColorAllocate($img, 255, 255, 255);

	$fp = fsockopen('udp://' . $ip, $port, $errno, $errstr,0.0);
	@socket_set_timeout($fp, 1);
		$packet = 'SAMP';
		$packet .= chr(strtok($ip, '.'));
		$packet .= chr(strtok('.'));
		$packet .= chr(strtok('.'));
		$packet .= chr(strtok('.'));
		$packet .= chr($port & 0xFF);
		$packet .= chr($port >> 8 & 0xFF);

		fwrite($fp, $packet.'i');
		if(fread($fp, 11))
		
  $is_passworded = ord(fread($fp, 1)); 
  $plr_count  = ord(fread($fp, 2)); 
  $max_plrs   = ord(fread($fp, 2)); 
  $strlen    = ord(fread($fp, 4)); 
  $hostname   = htmlentities(fread($fp, $strlen)); 
  $strlen    = ord(fread($fp, 4)); 
  $gamemode   = htmlentities(fread($fp, $strlen)); 
  $strlen    = ord(fread($fp, 4)); 
  $mapname   = htmlentities(fread($fp, $strlen)); 


  ImageString ($img, 4, 5, 5, "$hostname", $color); 
  ImageString($img, 3, 5, 32, "IP: $ip:$port", $color); 
  ImageString($img, 3, 5, 46, "Players: $plr_count/$max_plrs", $color); 
  ImageString($img, 3, 5, 61, "GameMode: $gamemode", $color); 

	
			if ($is_passworded)
			{
				ImageString($img, 3, 5, 76, "Password: Yes", $color);
			}else{
				ImageString($img, 3, 5, 76, "Password: No", $color);
			}

			fwrite($fp, $packet.'c');
			fread($fp, 11);
			fclose($fp);

}
imagepng($img);
imagedestroy($img);
?>
Trial -> http://gen.crazy.gzk.cz/status/
Please help me add the code to the server offline...THANKS ALL
Reply
#2

Quote:

Discussion and help related to creating scripts for SA-MP.

I don't think this is related to creating a script for SA:MP...
Reply
#3

Sorry . Scripting Discution ..I was wrong..and please help me..thx
Reply
#4

Learn PHP, cause i can't help you with this , go to a diffrent subforum .
Reply
#5

Quote:
Originally Posted by ~•F•r•E•n•K•~
Hello, this is functional code, but when the offline server is not so, please help me THX

Код:
<?php
header("Content-type: image/png");
if(isset($_GET["ip"]))
{
	$ip = $_GET["ip"]; 
	$port = $_GET["port"];

	$img = ImageCreateFrompng("./1.png");
	
	$color = ImageColorAllocate($img, 255, 255, 255);

	$fp = fsockopen('udp://' . $ip, $port, $errno, $errstr,0.0);
	@socket_set_timeout($fp, 1);
		$packet = 'SAMP';
		$packet .= chr(strtok($ip, '.'));
		$packet .= chr(strtok('.'));
		$packet .= chr(strtok('.'));
		$packet .= chr(strtok('.'));
		$packet .= chr($port & 0xFF);
		$packet .= chr($port >> 8 & 0xFF);

		fwrite($fp, $packet.'i');
		if(fread($fp, 11))
		
  $is_passworded = ord(fread($fp, 1)); 
  $plr_count  = ord(fread($fp, 2)); 
  $max_plrs   = ord(fread($fp, 2)); 
  $strlen    = ord(fread($fp, 4)); 
  $hostname   = htmlentities(fread($fp, $strlen)); 
  $strlen    = ord(fread($fp, 4)); 
  $gamemode   = htmlentities(fread($fp, $strlen)); 
  $strlen    = ord(fread($fp, 4)); 
  $mapname   = htmlentities(fread($fp, $strlen)); 


  ImageString ($img, 4, 5, 5, "$hostname", $color); 
  ImageString($img, 3, 5, 32, "IP: $ip:$port", $color); 
  ImageString($img, 3, 5, 46, "Players: $plr_count/$max_plrs", $color); 
  ImageString($img, 3, 5, 61, "GameMode: $gamemode", $color); 

	
			if ($is_passworded)
			{
				ImageString($img, 3, 5, 76, "Password: Yes", $color);
			}else{
				ImageString($img, 3, 5, 76, "Password: No", $color);
			}

			fwrite($fp, $packet.'c');
			fread($fp, 11);
			fclose($fp);

}
imagepng($img);
imagedestroy($img);
?>
Trial -> http://gen.crazy.gzk.cz/status/
Please help me add the code to the server offline...THANKS ALL
Quote:
Originally Posted by SuperS0nic
Learn PHP, cause i can't help you with this , go to a diffrent subforum .
screw learning php, learn some english first.
Reply
#6

You realize how old this topic is, right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)