view_log.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2017 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. require_once('includes/lib_remote.php');
  25. function exec_ogp_module() {
  26. global $view;
  27. global $db;
  28. echo "<h2>". view_log ."</h2>";
  29. $rhost_id = @$_REQUEST['rhost_id'];
  30. $remote_server = $db->getRemoteServer($rhost_id);
  31. $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout'] );
  32. if(isset($_POST['save_file']))
  33. {
  34. $file_info = $remote->remote_writefile('./ogp_agent.log', strip_real_escape_string($_REQUEST['file_content']));
  35. if ( $file_info === 1 )
  36. {
  37. print_success( get_lang("wrote_changes") );
  38. }
  39. else if ( $file_info === 0 )
  40. print_failure( get_lang("failed_write") );
  41. else
  42. {
  43. print_failure( get_lang("agent_offline") );
  44. }
  45. }
  46. $data = "";
  47. $file_info = $remote->remote_readfile('./ogp_agent.log',$data);
  48. if ( $file_info === 0 )
  49. {
  50. print_failure( get_lang("not_found") );
  51. return;
  52. }
  53. else if ( $file_info === -1 )
  54. {
  55. print_failure( get_lang("agent_offline") );
  56. return;
  57. }
  58. else if ( $file_info === -2 )
  59. {
  60. print_failure( get_lang("failed_read") );
  61. return;
  62. }
  63. echo "<form action='?m=server&amp;p=log&amp;rhost_id=".$rhost_id."' method='post'>";
  64. echo "<textarea name='file_content' style='width:98%;' rows='40'>$data</textarea>";
  65. echo "<p><input type='submit' name='save_file' value='Save' /></p>";
  66. echo "</form>";
  67. echo create_back_button($_GET['m']);
  68. }
  69. ?>