|
|
|
|
![]() ![]() |
Jul 8 2008, 01:24 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 204 Joined: 6-October 04 From: London, uk Member No.: 1,444 |
Here is the script:
CODE <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 Thanks Andre This post has been edited by krap: Jul 8 2008, 01:26 AM |
|
|
|
Jul 8 2008, 02:54 AM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 257 Joined: 2-June 07 From: U to the S to the A (but i'm haitian) Member No.: 44,040 |
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: CODE <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) |
|
|
|
Jul 10 2008, 12:13 AM
Post
#3
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 1,001 Joined: 25-September 05 From: L.A. Member No.: 12,251 |
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. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 21st August 2008 - 01:36 AM |