agents.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. include 'includes/lib_remote.php';
  25. function exec_ogp_module()
  26. {
  27. global $db;
  28. $remoteServers = $db->getRemoteServers();
  29. $servers = array();
  30. if(is_array($remoteServers)){
  31. foreach($remoteServers as $server){
  32. $remote = new OGPRemoteLibrary($server['agent_ip'], $server['agent_port'], $server['encryption_key'], 1);
  33. $status = (int)$remote->status_chk();
  34. $servers[] = array(
  35. 'id' => $server['remote_server_id'],
  36. 'name' => $server['remote_server_name'] .' '. (($status) === 0 ? '('.get_lang('offline').')' : '('.get_lang('online').')'),
  37. 'status' => $status,
  38. );
  39. }
  40. }
  41. echo json_encode($servers);
  42. }
  43. ?>