krap 0 Report post Posted July 8, 2008 (edited) Here is the script: <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><? $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);?> It seems to work for some other people on different hosts and I've tried on both my websites (one is on alpha, the other on iota) and it doesn't seem to be working. It is a remote control script for the game server I run and it just times out after 60 secs without executing the command on the server I am of course replacing the default 127.0.0.1, I know that wouldn't work and I've tested it on another host and it worked fine.ThanksAndre Edited July 8, 2008 by krap (see edit history) Share this post Link to post Share on other sites
etycto 0 Report post Posted July 8, 2008 excuse me if i'm wrong: i'm not great with PHP, but i think i see two thing wrong with that. should the script <? ?> be insite the HTML or body tag like this: <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><? $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);?></body></html> also should there be a decleration that says it's a PHP script. (maybe it works only for a certain version of PHP did you check that by any chance) Share this post Link to post Share on other sites
galexcd 0 Report post Posted July 10, 2008 I'm assuming the page doesn't time out when you comment out the while loop? Since you mentioned this script works on other hosts and not this one I'm assuming it may be an issue with the servers attempting to block data over the ud protocol. I may be mistaken, however that seems to be the only issue I can find. The code should run fine, as long as the server has PHP 4 or higher installed.@etycto: None of those solutions would cause the page to timeout, however the point about echoing information outside of the body tag might be a good idea if he wants to keep his page at least partly up to par with today's web standards. Share this post Link to post Share on other sites