/banned/ajax/saveAdminListToServer.php
PHP | 62 lines | 33 code | 7 blank | 22 comment | 1 complexity | 8e6c7480aa5b353952ab21ad5f452a30 MD5 | raw file
- <?php
- /*
- This file is part of GlobalBan.
-
- Written by Stefan Jonasson <soynuts@unbuinc.net>
- Copyright 2008 Stefan Jonasson
-
- GlobalBan is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- GlobalBan is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GlobalBan. If not, see <http://www.gnu.org/licenses/>.
- */
-
- require_once(ROOTDIR."/include/database/class.ServerQueries.php");
- require_once(ROOTDIR."/include/database/class.UserQueries.php");
- require_once(ROOTDIR."/include/class.rcon.php");
-
- $serverId = $_GET['serverId'];
-
- $serverQueries = new ServerQueries();
- $userQueries = new UserQueries();
-
- $server = $serverQueries->getServer($serverId);
- $users = $userQueries->getUsers();
-
- // Create an rcon object to connect to a single server on each iteration
- $r = new rcon($server->getIp(),$server->getPort(),$server->getRcon());
- $active = 0;
-
- // Make sure it connected to the server
- if($r->isValid()) {
- $r->Auth(); // Establish the connection
- $active = 1;
- $r->sendRconCommand("es gb_refreshAdmins");
- }
- // Send back the new active state
- header('Content-Type: text/xml');
- header("Cache-Control: no-cache, must-revalidate");
-
- function convertXmlSpecial($string) {
- $string = str_replace("&", "&", $string);
- $string = str_replace("'", "'", $string);
- $string = str_replace("\"", """, $string);
- $string = str_replace("<", "<", $string);
- $string = str_replace(">", ">", $string);
- return $string;
- }
- ?>
- <?php echo "<?xml version=\"1.0\" ?>";?>
- <root>
- <id><?php echo $server->getId()?></id>
- <name><?php echo convertXmlSpecial($server->getName())?></name>
- <active><?php echo $active?></active>
- </root>