PageRenderTime 126ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/banned/ajax/saveAdminListToServer.php

http://globalban-spanish.googlecode.com/
PHP | 62 lines | 33 code | 7 blank | 22 comment | 1 complexity | 8e6c7480aa5b353952ab21ad5f452a30 MD5 | raw file
  1. <?php
  2. /*
  3. This file is part of GlobalBan.
  4. Written by Stefan Jonasson <soynuts@unbuinc.net>
  5. Copyright 2008 Stefan Jonasson
  6. GlobalBan is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. GlobalBan is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GlobalBan. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. require_once(ROOTDIR."/include/database/class.ServerQueries.php");
  18. require_once(ROOTDIR."/include/database/class.UserQueries.php");
  19. require_once(ROOTDIR."/include/class.rcon.php");
  20. $serverId = $_GET['serverId'];
  21. $serverQueries = new ServerQueries();
  22. $userQueries = new UserQueries();
  23. $server = $serverQueries->getServer($serverId);
  24. $users = $userQueries->getUsers();
  25. // Create an rcon object to connect to a single server on each iteration
  26. $r = new rcon($server->getIp(),$server->getPort(),$server->getRcon());
  27. $active = 0;
  28. // Make sure it connected to the server
  29. if($r->isValid()) {
  30. $r->Auth(); // Establish the connection
  31. $active = 1;
  32. $r->sendRconCommand("es gb_refreshAdmins");
  33. }
  34. // Send back the new active state
  35. header('Content-Type: text/xml');
  36. header("Cache-Control: no-cache, must-revalidate");
  37. function convertXmlSpecial($string) {
  38. $string = str_replace("&", "&amp;", $string);
  39. $string = str_replace("'", "&apos;", $string);
  40. $string = str_replace("\"", "&quot;", $string);
  41. $string = str_replace("<", "&lt;", $string);
  42. $string = str_replace(">", "&gt;", $string);
  43. return $string;
  44. }
  45. ?>
  46. <?php echo "<?xml version=\"1.0\" ?>";?>
  47. <root>
  48. <id><?php echo $server->getId()?></id>
  49. <name><?php echo convertXmlSpecial($server->getName())?></name>
  50. <active><?php echo $active?></active>
  51. </root>