Jump to content

Recommended Posts

I am completely new to .php. I know nothing about it. I was able to scrounge this up, for tests:

 

index.html:

<html>
<head><title>Rcon Connection Client</title></head>
<body>
<form name="rcon" method="post" action="rcon.php">
IP: <input type="text" name="ip" value="127.0.0.1">
Port: <input type="text" name="port" value="7777">
Password <input type="text" name="pass" size="25"><br>
Cmd: <input type="text" name="cmd" size="100"><br>
<input type="submit" name="submit">
</form>
</body>
</html>

 

rcon.php:

<?
  $ip = $_POST['ip'];  if (!$ip) die();
  $port = $_POST['port']; if (!$port) die();

  $pass = $_POST['pass']; if (!$pass) die();
  $passlen = strlen($pass);
  $cmd = $_POST['cmd']; if (!$cmd) die();
  $cmdlen = strlen($cmd);

  $packet = 'SAMP';
  $packet .= chr(strtok($ip, '.')).chr(strtok('.')).chr(strtok('.')).chr(strtok('.'));
  $packet .= chr($port & 0xFF).chr($port >> 8 & 0xFF);
  $packet .= "x";
  $packet .= chr($passlen & 0xFF).chr($passlen >> 8 & 0xFF).$pass;
  $packet .= chr($cmdlen & 0xFF).chr($cmdlen >> 8 & 0xFF).$cmd;

  $fp =fsockopen('udp://' . $ip, $port, $errno, $errstr);
  fwrite($fp, $packet);
  while(!feof($fp)) {
    $str=fread($fp,128);
    $str=substr($str,13,strlen($str)-13);
    if (!$str) break;
    echo $str."<br>";
   }
  fclose($fp);
?>

 

I was testing it on my localhost and on a free host. With firefox, it just shows me a page with the .php script on it instead of actually running it. With IE, it just pops up as a download.

 

Is there a special way to run .php?

Link to comment
https://forums.phpfreaks.com/topic/114969-how-to-work-php/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.