fm_write.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. require_once(MODULES."/litefm/litefm.php");
  25. function exec_ogp_module()
  26. {
  27. $home_id = $_REQUEST['home_id'];
  28. if (empty($home_id))
  29. {
  30. print_failure(get_lang('home_id_missing'));
  31. return;
  32. }
  33. global $db;
  34. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  35. if($isAdmin)
  36. $home_cfg = $db->getGameHome($home_id);
  37. else
  38. $home_cfg = $db->getUserGameHome($_SESSION['user_id'],$home_id);
  39. if ($home_cfg === FALSE)
  40. {
  41. print_failure(get_lang('no_access_to_home'));
  42. return;
  43. }
  44. if ( preg_match("/f/",$home_cfg['access_rights']) != 1 )
  45. {
  46. print_failure( get_lang("no_rights") );
  47. echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_cfg['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
  48. return;
  49. }
  50. if ( isset($_REQUEST['save_file']) )
  51. {
  52. $remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key'], $home_cfg['timeout']);
  53. $file_info = $remote->remote_writefile($home_cfg['home_path']."/".$_SESSION['fm_cwd_'.$home_id], $_REQUEST['file_content']);
  54. if ( $file_info === 1 )
  55. {
  56. print_success(get_lang('wrote_changes'));
  57. $db->logger(get_lang('wrote_changes')." ( ".$home_cfg['home_name']." - ".$home_cfg['home_path'].$_SESSION['fm_cwd_'.$home_id]." )");
  58. }
  59. else if ( $file_info === 0 )
  60. print_failure(get_lang('failed_write'));
  61. else
  62. print_failure(get_lang("agent_offline"));
  63. }
  64. echo "<table class='center' style='width:100%;'>".show_back($home_id)."</table>";
  65. }
  66. ?>