Zezombia Posted July 16, 2008 Share Posted July 16, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/114969-how-to-work-php/ Share on other sites More sharing options...
cooldude832 Posted July 16, 2008 Share Posted July 16, 2008 You server needs to have php installed. Otherwise the document is simply displayed to the browser as a document instead of being compiled and executed. Go to php.net for installation information. Quote Link to comment https://forums.phpfreaks.com/topic/114969-how-to-work-php/#findComment-591279 Share on other sites More sharing options...
Zezombia Posted July 16, 2008 Author Share Posted July 16, 2008 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/114969-how-to-work-php/#findComment-591281 Share on other sites More sharing options...
trq Posted July 16, 2008 Share Posted July 16, 2008 Also note that you should be using <?php tags not simply <? Quote Link to comment https://forums.phpfreaks.com/topic/114969-how-to-work-php/#findComment-591289 Share on other sites More sharing options...
azfar siddiqui Posted July 16, 2008 Share Posted July 16, 2008 agree with thorpe, if you are working with PHP5 , you can only use <?php Quote Link to comment https://forums.phpfreaks.com/topic/114969-how-to-work-php/#findComment-591412 Share on other sites More sharing options...
trq Posted July 16, 2008 Share Posted July 16, 2008 if you are working with PHP5 , you can only use <?php That is not the case, its just best practice to do so because allot of servers will not support short tags. Quote Link to comment https://forums.phpfreaks.com/topic/114969-how-to-work-php/#findComment-591432 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.