Author Topic: CoD 2 Rcon in PHP  (Read 2806 times)

promo

  • CoD.gr Admin
  • DEMO UPLOADER!
  • blah blah blah
    • hit me
CoD 2 Rcon in PHP
« on: December 05, 2006, 05:14:48 PM »
Kapoious apo esas pou asxoleiste me web dev mporei na sas endiaferei.


cod2query.php 
 
Code: [Select]
<?

class cod2query {

var $rconpassword;
var $fp;
var $cmd;
var $lastcmd;

function cod2query($address, $port) {
$this->cmd = str_repeat(chr(255), 4);
$this->fp = fsockopen("udp://$address", $port, $errno, $errstr, 30);
if (!$this->fp)
die("$errstr ($errno)<br />\n");
}

 function set_rconpassword($p) {
$this->rconpassword = $p;
}

 function rcon($s) {
sleep(1);
$this->send('rcon '.$this->rconpassword.' '.$s);
}

 function get_response($timeout=5) {
$s = '';
$bang = time() + $timeout;
while (!strlen($s) and time() < $bang) {
$s = $this->recv();
}
if (substr($s, 0, 4) != $this->cmd) {
}
return substr($s, 4);
}

 function send($string) {
fwrite($this->fp, $this->cmd . $string . "\n");
}

 function recv() {
return fread($this->fp, 9999);
}

}

?>


index.php --> edw yparxei mia forma gia kapoies aples entoles (maps, kick all, status).To $data einai xrhsimo mono otan steileis "/rcon status" kai 8a xreiastei na kaneis parse to string gia na provaleis swsta ta dedomena (map, id, name, guid,klp)

Code: [Select]
<?
$command = $_POST["map_select"];
require('cod2query.php');
$q = new cod2query('127.0.0.1', 28960); //Ip kai port tou CoD2 server
$q->set_rconpassword('rconpassword'); //
$q->rcon($command);
$data=$q->get_response();             //Apanthsh apo server px (echo $data;)
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>---Rcon Easy---</title>
</head>

<body bgcolor="#C0C0C0">
<form method="post" action="<?php echo $PHP_SELF;?>">
<div align="center">
<table border="0" width="57%" id="table1" height="154">
<tr>
<td>
<p align="center">
 <b>
<font face="Verdana" size="5" color="#5A00E7">CoD2 Server RCon Tool</font></b></td>
</tr>
<tr>
<td align="center" height="57">
<select size="1" name="map_select">
<option selected>Select Action</option>
<option value="map_restart">Map Restart</option>
<option value="fast_restart">Fast Map Restart</option>
<option>-----------Maps------------</option>
<option value="map mp_matmata">Matmata</option>
<option value="map mp_toujane">Toujane</option>
<option value="map mp_carentan">Carentan</option>
<option value="map mp_dawnville">Dawnville</option>
<option value="map mp_burgundy">Burgundy</option>
<option value="map mp_breakout">Bocage</option>
<option value="map mp_downtown">Moscow</option>
<option value="map mp_farmhouse">Beltot</option>
<option value="map mp_leningrad">Leningrad</option>
<option value="map mp_railyard">Stalingrad</option>
<option value="map mp_rhine">Wallendar</option>
<option value="map mp_trainstation">Caen</option>
<option value="map mp_decoy">El Alamein</option>
<option value="map mp_harbor">Harbor</option>
<option>-----------------------</option>
<option value="status">Status</option>
<option value="kick all">KICK ALL</option>
</select> <input type="submit" value="Execute" name="submitmap"></form></td>
</tr>
<tr>
<td height="29" align="center">
<?
if ($command!='') {
echo $msg.' <b>command=( <font color="red">'.$command.'</font></b>)';
}else{
echo '<b>Please choose a command!!!</b>'  ;
}
?>
</td>
</tr>
</table>

</div>

</body>
</html>
[16:02] <bazookas> pws gnt na milisoume ston athropo pou evale to anti cheat programa gia na to vgalei?
[16:04] <|ProMo|> re file plaka kaneis?
[16:05] <bazookas> no
http://www.ediodos.gr/4lkis/4lkis.html
http://www.alexander-moda.gr

1

promo

  • CoD.gr Admin
  • DEMO UPLOADER!
  • blah blah blah
    • hit me
Re: CoD 2 Rcon in PHP
« Reply #1 on: December 13, 2006, 06:22:02 PM »
Merikes Veltiwseis...

http://prosvasis.org/rcon/rcon.rar

All Tested, except status (need server with more than 4 players logged on :S).
[16:02] <bazookas> pws gnt na milisoume ston athropo pou evale to anti cheat programa gia na to vgalei?
[16:04] <|ProMo|> re file plaka kaneis?
[16:05] <bazookas> no
http://www.ediodos.gr/4lkis/4lkis.html
http://www.alexander-moda.gr

1

Tak1s

  • CBWARRIOR.
Re: CoD 2 Rcon in PHP
« Reply #2 on: December 13, 2006, 06:45:48 PM »
mm nomizo to PB ihe kati paromio, den ksero ama to ehi k sto cod2