PHP to JavaScript covert?
#1

Hi guys, I made this little thing that gets some basic server stats. I was just wondering, Is it possible to make this code:
Код:
<html>
<?php

getstats();

function getstats()
{
  $ip = "24.111.46.103";
  $port = "7777";
  $fp = fsockopen('udp://' . $ip, $port, $errno, $errstr,0.0);
  if (!$fp)
  {
     echo "offline";
  }
  else
  {
    $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');
    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));
	
	if($is_passworded == 1)
	{
		$is_passworded = "yes";
	}
	else if($is_passworded == 0)
	{
		$is_passworded = "no";
	}	
	
    echo "Hostname  : $hostname " . "<br>";
    echo "Gamemode : $gamemode ". "<br>";
    echo "Map : $mapname ". "<br>";
    echo "Players: $plr_count/$max_plrs". "<br>";
    echo "Passoword: $is_passworded". "<br>";
	
    fwrite($fp, $packet.'c');
    fread($fp, 11);
    fclose($fp);
 }	
}
?>
</html>
Into a JavaScript version of it? Like.. the same exact function, but coded in JavaScript. If it is possible, can you please tell me how? It would mean a lot. Anyway, thanks! Later.
Reply


Messages In This Thread
PHP to JavaScript covert? - by sciman001 - 05.11.2011, 03:40
Re: PHP to JavaScript covert? - by Calgon - 05.11.2011, 07:57
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 16:01
Re: PHP to JavaScript covert? - by Norn - 05.11.2011, 16:16
Re: PHP to JavaScript covert? - by Ronaldo_raul™ - 05.11.2011, 16:23
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 18:54
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 18:56
Re: PHP to JavaScript covert? - by Pinguinn - 05.11.2011, 18:57
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 18:59
Re: PHP to JavaScript covert? - by Norn - 05.11.2011, 19:01
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 19:02
Re: PHP to JavaScript covert? - by Norn - 05.11.2011, 19:09
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 19:32
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 19:35
Re: PHP to JavaScript covert? - by Flyfishes - 05.11.2011, 19:37
Re: PHP to JavaScript covert? - by sciman001 - 05.11.2011, 19:37
Re: PHP to JavaScript covert? - by Calgon - 05.11.2011, 19:38

Forum Jump:


Users browsing this thread: 3 Guest(s)