yeah, simple example, hope ppl can use this as frame:
(there was a bug in php that did prevent reading from udp stream, tho it was fixed in 4.3.1 (or smthng), so you'll need recent version of php for this.
<?php
//set servers rcon password
$rcon_password = "SecreT"
//command to send to server
$yourcommand = "say message from outer world: it's SUMMER!";
//open connection
$conn = fsockopen( "udp://10.0.0.1", 27910, $error, $errdescription, 10 );
//check if connection was made
if ($conn) {
//send data to server
fputs( $conn, "\xff\xff\xff\xff".$yourcommand);
//parse output
$output = str_replace("ÿ", "", (fread( $conn, 1024 )));
//aaand make array out of it
$reply = split ("\x0a", $output);
//then let's see what we wanna do with those rows that server sent back
foreach ($reply as $r) {
//as i am simple man, i don't wanna do anything but print the output
print $r."\n";
}
}
//something ain't working
else {
//i've seen it all
die("ERROR with connection: ".$errdescription);
}
?>
yeah, just add fputs-lines for every rcon command you want to issue, and so on. you don't NEED to check the reply btw. if you just wanna execute rcon commands, skip the postprocessing.
<html>
<body>
<?php
//set server's rcon password
$rcon_password = $_POST['rcon'];
//command to send to server
$yourcommand = $_POST['command'];
//server address
$serveraddr = $_POST['server'];
//open connection
$conn = fsockopen($serveraddr, 27910, $error, $errdescription, 10);
//check if connection was made
if ($conn) {
//send data to server
fputs( $conn, "\xff\xff\xff\xff".$yourcommand);
//parse output
$output = str_replace("ÿ", "", (fread( $conn, 1024 )));
//aaand make array out of it
$reply = split ("\x0a", $output);
//then let's see what we wanna do with those rows that server sent back
foreach ($reply as $r) {
//as i am simple man, i don't wanna do anything but print the output
print $r."<br>\n";
}
}
print "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
?>
<input type="text" name="server" size="20"> : server address<br>
<input type="text" name="rcon" size="20"> : rcon password<br>
<input type="text" name="command" size="20"> : command<br>
<input type="submit">
</form>
</body>
</html>
spectre, this looks intresting... I have used a bit these php -> q2 things, but I haven't put enough effort to resolve those things what you need to send to q2 server...
where did you hack that '\xff\xff\xff\xff'? from q2 source?