/** Balances teams. * This function balances the teams according to the arrival order of the players. * It is executed on new connections and when a player changes team (if AutoTeams is enabled in plugin config). * It only changes the team of new players. * * \param $server The server that has requested the balance. * * \return Nothing. */ public function WSMethodBalanceTeams($server) { $actual = Server::getName(); Server::setServer($this->_main->servers[$server]); Rcon::setServer($this->_main->servers[$server]); $this->_balance(); Server::setServer($this->_main->servers[$actual]); Rcon::setServer($this->_main->servers[$actual]); }
echo "{$subtractedtot}"; //Encryption and Decryption should be used to protect COOKIES //cookie* $host = "localhost"; // Server host name or IP //Encryption and Decryption should be used to protect COOKIES //cookie* $port = $_SESSION["portcon"]; // Port rcon is listening on //Encryption and Decryption should be used to protect COOKIES //cookie* $password = "******"; // rcon.password setting set in server.properties $timeout = 3; // How long to timeout. $rcon = new Rcon($host, $port, $password, $timeout); if ($rcon->connect()) { $rcon->send_command("cp give {$sender} {$amount} hi"); } $APPtotal = $_SESSION['subapp']; $UUser = $_COOKIE['UID']; //Update the APPPurse in DB $connn = mysqli_connect("localhost", "phpmate", "freeagent7", "_datatrap"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } else { mysqli_query($connn, "UPDATE members SET points='{$APPtotal}'\nWHERE uid='{$UUser}'"); echo "Connected"; } unset($_POST['sendto']);
} } loadFile(); displayContents(); psconsole.scrollTop(psconsole[0].scrollHeight - psconsole.height()); }, 20); </script> <textarea id='console' rows='13' cols='100' spellcheck="off"></textarea> <form action="" method="POST"> <input type="text" style="width: 740px;" autocomplete="off" autofocus class="consolecmd" id="consolecmd" name="consolecmd"></textarea> <input type="submit" id="submit" name="submit" value="Send"></input> </form action="" method="POST"> </body> </html> <?php if (isset($_POST['submit'])) { $command = $_POST['consolecmd']; require_once 'rcon.php'; $host = 'localhost'; $port = 25575; $password = '******'; $timeout = 3; $rcon = new Rcon($host, $port, $password, $timeout); if ($rcon->connect()) { $rcon->send_command($command); } }
private function _showStatsMsg($user, $admin = NULL) { $buffer = array(); $_stats = Server::get('stats'); $_awards = Server::get('awards'); //Gestion du ratio pour éviter la division par zéro if ($_stats[$user]['deaths'] != 0) { $ratio = $_stats[$user]['kills'] / $_stats[$user]['deaths']; } else { $ratio = $_stats[$user]['kills']; } $aratio = round($_awards['ratio'][1], 2); //Gestion du ratio (changement de couleur selon le ratio) $ratio = round($ratio, 2); if ($ratio >= 1) { $ratioColor = '^2'; } else { $ratioColor = '^1'; } $gametype = Server::getServer()->serverInfo['g_gametype']; //Gestion des awards (plus précisément de la couleur en cas d'award ou non) foreach ($this->config['ShowStats'] as $stat) { if (in_array($stat, $this->config['ShowStats'])) { if ($_awards[$stat][0] == $user && in_array($stat, $this->config['ShowAwards'])) { $statColor = '^6'; } else { $statColor = '^3'; } if (in_array($stat, $this->config['ShowAwards'])) { if ($stat == 'ratio') { // cpu/memory saving $statAward = '^4/' . round($_awards[$stat][1], 2); } else { $statAward = '^4/' . $_awards[$stat][1]; } } else { $statAward = ''; } if ($stat == 'ratio') { $buffer[] = $statColor . ucfirst($stat) . ' : ' . $ratioColor . $ratio . $statAward; } elseif ($stat == 'caps' && $gametype == Server::GAME_CTF or $stat == 'round' && $gametype == Server::GAME_LMS or !in_array($stat, array('ratio', 'caps', 'round'))) { $buffer[] = $statColor . ucfirst($stat) . ' : ^2' . $_stats[$user][$stat] . $statAward; } } } if ($admin !== NULL) { $user = $admin; } // If a admin use !stats <player> //On affiche enfin les stats Rcon::tell($user, '$stats', array('stats' => join('^3 - ', $buffer))); }
for ($i = 1; $i <= $params[1]; $i++) { // Setup the Minecraft command. $monsternum = rand(0, 2); $result = "spawnnamedmob Test" . $i . " " . $monsters[$monsternum] . " " . $x . " " . $y . " " . $z; $rcon = new Rcon($host, $port, $password, $timeout); if ($rcon->connect()) { $rcon->send_command($result); } sleep(2); } // End for loop } else { // Ok we have a valid mob to spawn!! Let's DO this thing. // Setup the Minecraft command. $result = "spawnnamedmob " . $params[0] . " " . $params[1] . " " . $x . " " . $y . " " . $z; $rcon = new Rcon($host, $port, $password, $timeout); if ($rcon->connect()) { $rcon->send_command($result); // $rcon->send_command("spawnnamedmob Simon spider -97 78 228"); } if (strtolower($params[0]) == "jeff") { header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?> <Response> <Message>JEFF!! just sent <?php echo $params[0]; ?> the <?php echo $params[1]; ?>
public function CommandIrcco($player, $args) { LeelaBotIrc::send('NAMES ' . $this->config['MainChannel']); $continue = TRUE; while ($continue) { $ret = rtrim(LeelaBotIrc::get()); if ($ret) { $data = explode(':', $ret); $cmd = explode(' ', $data[1]); if ($cmd[1] == '353') { $nicks .= ' ' . $data[2]; } elseif ($cmd[1] == '366') { $continue = FALSE; } } } $nicks = str_replace(array('@', '+', '~'), array('', '', ''), $nicks); Rcon::tell($player, 'People connected to IRC : $nicks', array('nicks' => $nicks)); }
$servers_array[] = $servers_info; } if ($_GET['sid'] != "" && is_numeric($_GET['sid'])) { $sid = $_GET['sid']; } else { $sid = "0"; } $server_id = $servers_list[$sid]; //fetch server_information $resource2 = mysql_query("SELECT * FROM {$config->servers} WHERE id = '" . $server_id . "'") or die(mysql_error()); $result2 = mysql_fetch_object($resource2); if (mysql_num_rows($resource2)) { $split_address = explode(":", $result2->address); $eye_pee = $split_address['0']; $poort = $split_address['1']; $server = new Rcon(); $server->Connect($eye_pee, $poort, $result2->rcon); $infos = $server->Info(); $info = $server->ServerInfo(); //Action $response = $server->RconCommand("amx_timeleft"); $response1 = $server->RconCommand("mp_timelimit"); $response2 = $server->RconCommand("sv_visiblemaxplayers"); //get addons version $response_amxmodx = $server->RconCommand("amxmodx_version"); $response_amxbans = $server->RconCommand("amxbans_version"); $response_ptb = $server->RconCommand("amx_ptb_version"); $response_atac = $server->RconCommand("atac_version"); $response_hlr = $server->RconCommand("hltv_report"); $response_sank = $server->RconCommand("sanksounds_version"); $response_steambans = $server->RconCommand("sbsrv_version");
$server = new Rcon(); if ($server->Connect($server_address[0], $server_address[1], $servers_array[$sid]["rcon"])) { $response = $server->RconCommand("kick #" . $pl_uid . " " . $pl_reason); if (substr($response, 1) != "") { $user_msg = "_PLAYERKICKED"; log_to_db("Kick online", "nick: " . $pl_name . " <" . $pl_steamid . "><" . $pl_ip . "> kicked"); } $server_msg = $servers_array[$sid]["address"] . "<br>" . substr($response, 1); //for debug, shows the response from server $server->Disconnect(); } } if ($servers_array[$sid]["mod"]) { //get player list sent by plugin $server_address = explode(":", trim($servers_array[$sid]["address"])); $server = new Rcon(); if ($server->Connect($server_address[0], $server_address[1], $servers_array[$sid]["rcon"])) { $response = $server->ServerPlayers(); //explode packet and get infos $re = explode("\n", $response); //there is a response from amxmodx plugin if (strlen($response)) { if ($re[0] != "Bad rcon_password." && $re[1] != "Bad rcon_password." && $re[2] != "Bad rcon_password.") { foreach ($re as $k => $v) { $pl = explode("ü", $v); if (!is_array($pl)) { break; } $gi = geoip_open("include/GeoIP.dat", GEOIP_STANDARD); $cc = geoip_country_code_by_addr($gi, $pl[3]); $cn = geoip_country_name_by_addr($gi, $pl[3]);
/** Gives information about a player * This function is bound to the !whois command. It gives the name, ip, level, host of the player specified in argument. * * \param $id The game ID of the player who executed the command. * \param $command The command parameters. * * \return Nothing. */ public function CommandWhois($id, $command) { if (!empty($command[0])) { $target = Server::searchPlayer($command[0]); if ($target === FALSE) { RCon::tell($id, "No player found."); } elseif (is_array($target)) { $players = array(); foreach ($target as $p) { $players[] = Server::getPlayer($p)->name; } RCon::tell($id, 'Multiple players found : $0', array(join(', ', $players))); } else { $target = Server::getPlayer($target); Rcon::tell($id, 'Whois ^2$name ^3> IP : $addr, Level : $level, Host : $host', array('name' => $target->name, 'addr' => $target->addr, 'level' => $target->level, 'host' => gethostbyaddr($target->addr))); } } else { Rcon::tell($id, 'Missing parameters.'); } }
} else { if ($gspy->serv_rcon_response != '') { //echo 'Server has responded : ' . $gspy->serv_rcon_response; $response = $gspy->serv_rcon_response; } else { //echo 'Command has been sent but no response has been receveid (does not indicate an error)'; $empty_result = "Command has been sent but no response has been received (does not indicate an error)"; } } } } else { if ($config->rcon_class == "two") { $split_address = explode(":", $result2->address); $eye_pee = $split_address['0']; $poort = $split_address['1']; $server = new Rcon(); $server->Connect($eye_pee, $poort, $result2->rcon); //Action $response = $server->RconCommand("amx_list"); //close connection $server->Disconnect(); } } $lists = explode("#WM#", $response); if (ereg("ogeoip", $lists['0'])) { $geoip = "off"; } else { $geoip = "on"; } $lists = array_slice($lists, 1); $player_array = array();
public function SrvEventSay($id, $contents) { if ($contents[0] != '!') { $addwarn = FALSE; foreach ($this->_badwords as $word) { if (strpos(strtolower($contents), $word) !== FALSE) { $addwarn = TRUE; } } if ($addwarn) { $warns = $this->_addWarn($id); Rcon::tell($id, 'Please be careful with your language. You have $warns warnings', array('warns' => $warns)); } } }
// Require basic site files require_once "include/config.inc.php"; require_once "include/access.inc.php"; require_once "include/menu.inc.php"; require_once "include/functions.inc.php"; //require_once("include/logfunc.inc.php"); //require_once("include/sql.inc.php"); require_once "include/rcon_hl_net.inc"; //fetch server_information $resource2 = mysql_query("SELECT * FROM " . $config->db_prefix . "_serverinfo ORDER BY hostname ASC") or die(mysql_error()); while ($result2 = mysql_fetch_object($resource2)) { $split_address = explode(":", $result2->address); $ip = $split_address['0']; $port = $split_address['1']; if ($ip && $port) { $server = new Rcon(); $ip = gethostbyname($ip); $server->Connect($ip, $port, $result2->rcon); $infos = $server->Info(); if ($infos) { //yes, infos ok $players = $server->Players(); $rules = $server->ServerRules(); //copy rules to rules array for template if (is_array($rules)) { foreach ($rules as $k => $v) { $rules_array[] = array("name" => $k, "value" => $v); } } //check if mappic exists if (file_exists("images/maps/" . $infos[mod] . "/" . $infos[map] . ".jpg")) {
function rcon_send($command, $sid, $max_response_pages = 0) { //get server info global $config; $resource = mysql_query("SELECT address,rcon FROM " . $config->db_prefix . "_serverinfo WHERE id=" . $sid) or die(mysql_error()); $result = mysql_fetch_object($resource); if ($result) { $server_address = explode(":", trim($result->address)); $server_rcon = $result->rcon; $server = new Rcon(); if ($server->Connect($server_address[0], $server_address[1], $server_rcon)) { $response = $server->RconCommand($command, $max_response_pages); $server->Disconnect(); if ($response != "") { return trim($response); } else { return false; } } } }