SA-MP Forums Archive
Need help ! PHP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need help ! PHP (/showthread.php?tid=62776)



Need help ! PHP - gernes - 24.01.2009

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


Re: Need help ! PHP - Yaheli_Faro - 24.01.2009

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...


Re: Need help ! PHP - gernes - 24.01.2009

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


Re: Need help ! PHP - SuperS0nic - 24.01.2009

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


Re: Need help ! PHP - darkrider366 - 22.03.2009

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.


Re: Need help ! PHP - Pyrokid - 22.03.2009

You realize how old this topic is, right?