Problem ist gelöst
Hier mal für andere User :
PHP-Code:
<?php
// ----------------------------------------------------------- //
// Send rconcommand on BF1942 Server
// 25.01.2006
// Zyrusthc : zyrusthc.homeip.net
// -----------------------------------------------------------
// Thanks to :
// http://www.dontcamp.com/code/?file=bf1942_rcon_class.php
// http://www.bf1942.lightcubed.com/forum/viewtopic.php?p=11941
// ----------------------------------------------------------- //
$bf1942server = "192.168.10.1";
$bf1942serverport3 = "4712";
$bf1942rconuser = "admin";
$bf1942rconpass = "****";
$remotecommand = "game.listmaps";
// ----------------------------------------------------------- //
function _xorcrypt($string, $key) {
for($i=0; $i<strlen($string); $i++) {
$string[$i] = $string[$i]^$key[$i];
}
return $string;
}
function xbyte_to_int($stri_conv) {
$val_finale = 0;
$len_stri = strlen($stri_conv);
for ($x = 0; $x < $len_stri; $x++) {
$val_finale = $val_finale + (ord(substr($stri_conv, $x, 1)) * pow(256, $x));
}
return $val_finale;
}
function int_to_4byte($numero_conv) {
$final_stri = "";
for ($x = 1; $x <= 3; $x++) {
$n_val = intval(floor($numero_conv/256));
$n_rest = intval($numero_conv % 256);
$final_stri .= chr($n_rest);
$numero_conv = $n_val;
}
$final_stri .= chr($n_val);
return $final_stri;
}
$command ="$remotecommand\n";
if(!$fp = fsockopen($bf1942server, $bf1942serverport3, $errno, $errstr, 5))
{
echo "Kann nicht zum Server verbinden! (" . $errstr . ")";
}
else
{
$key = fread($fp, 10);
$username = _xorcrypt($bf1942rconuser, $key) . "\x00";
$password = _xorcrypt($bf1942rconpass, $key) . "\x00";
fwrite($fp, pack("L",strlen($username)));
fwrite($fp, $username);
fwrite($fp, pack("L",strlen($password)));
fwrite($fp, $password);
$result = fread($fp,1);
$response = xbyte_to_int($result);
if ($response == 1)
$acstatus = "OK";
else
$acstatus = "ERR";
if ($acstatus== "OK") {
$comm_tmp = int_to_4byte(2);
fwrite($fp, $comm_tmp);
$comm_tmp = "ConsoleMessage 0";
$len = strlen($comm_tmp) + 1;
fwrite($fp, int_to_4byte($len));
fwrite($fp, $comm_tmp . chr(0));
$len = strlen($command) + 1;
fwrite($fp, int_to_4byte($len));
fwrite($fp, $command . chr(0));
$result = fread($fp,4);
$response = xbyte_to_int($result);
if ($response == 1) {
$result = fread($fp,4);
$len = xbyte_to_int($result);
$response_len = $len;
if ($len > 1) {
$result = fread($fp,$len);
}
else $result = "N/A";
$final_result = $result;
}
}
else {
$response_len = "N/A";
$final_result = "N/A";
}
$return = array('authentication' => $acstatus,
'response_len' => $response_len,
'response' => $final_result);
$login = $return['authentication'];
$antwortlaenge = $return['response_len'];
$antwort = nl2br($return['response']);
fclose ($fp);
}
echo "Login: $login<br>";
echo "Antwortlaenge: $antwortlaenge<br>";
echo "Antwort: $antwort";
?>
gruss Oli
Lesezeichen