browser.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <script type="text/javascript" src="js/modules/user_games.js"></script>
  2. <?php
  3. /*
  4. *
  5. * OGP - Open Game Panel
  6. * Copyright (C) 2008 - 2018 The OGP Development Team
  7. *
  8. * http://www.opengamepanel.org/
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. *
  24. */
  25. require_once('includes/lib_remote.php');
  26. function litefm_check($home_id)
  27. {
  28. if (isset($_GET['folder']))
  29. $_SESSION['browser_cwd_'.$home_id] = stripslashes($_GET['folder']);
  30. if (isset($_GET['item']))
  31. {
  32. if($_SESSION['browser_folders_'.$home_id][$_GET['item']])
  33. {
  34. $_SESSION['browser_cwd_'.$home_id] = clean_path(@$_SESSION['browser_cwd_'.$home_id] . "/" .
  35. $_SESSION['browser_folders_'.$home_id][$_GET['item']]);
  36. }
  37. }
  38. // To go back a dir, we just use dirname to strip the last directory or file off the path
  39. if (isset($_GET['back']))
  40. {
  41. $_SESSION['browser_cwd_'.$home_id] = dirname( $_SESSION['browser_cwd_'.$home_id] );
  42. }
  43. return TRUE;
  44. }
  45. function exec_ogp_module()
  46. {
  47. $home_id = $_REQUEST['home_id'];
  48. if (empty($home_id))
  49. {
  50. print_failure(get_lang('home_id_missing'));
  51. return;
  52. }
  53. global $db;
  54. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  55. if($isAdmin)
  56. $home_cfg = $db->getGameHome($home_id);
  57. else
  58. $home_cfg = $db->getUserGameHome($_SESSION['user_id'],$home_id);
  59. if ($home_cfg === FALSE)
  60. {
  61. print_failure(get_lang('no_access_to_home'));
  62. return;
  63. }
  64. $home_id = $home_cfg['home_id'];
  65. litefm_check($home_id);
  66. $remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key'], $home_cfg['timeout']);
  67. if($isAdmin and isset($_GET['all_fs']))
  68. $path = clean_path("/".@$_SESSION['browser_cwd_'.$home_id]);
  69. else
  70. $path = clean_path($home_cfg['home_path'].@$_SESSION['browser_cwd_'.$home_id]);
  71. while(!$remote->rfile_exists($path))
  72. {
  73. $_SESSION['browser_cwd_'.$home_id] = dirname( $_SESSION['browser_cwd_'.$home_id] );
  74. if($isAdmin && $_GET['all_fs'])
  75. $path = clean_path("/".@$_SESSION['browser_cwd_'.$home_id]);
  76. else
  77. $path = clean_path($home_cfg['home_path'].@$_SESSION['browser_cwd_'.$home_id]);
  78. }
  79. if( isset( $_GET['create_folder'] ) )
  80. {
  81. $folder_name = stripslashes($_GET['folder_name']);
  82. $folder_path = clean_path( $path . "/" . $folder_name );
  83. $remote->shell_action('create_dir', $folder_path);
  84. $db->logger( get_lang("create_folder") . ": " . $folder_path );
  85. }
  86. $dirlist = $remote->remote_dirlistfm($path);
  87. $_SESSION['browser_folders_'.$home_id] = array();
  88. if ( is_array($dirlist) )
  89. {
  90. $selected_path = clean_path("/".@$_SESSION['browser_cwd_'.$home_id]);
  91. echo "<p id=selected_path >$selected_path</p>".
  92. "<table class='center' width='440px' >\n<b class='levelup' title='".
  93. get_lang("level_up_info")."' data-home-id='".$home_id."' data-path='".$path."' >";
  94. if( $path != "/" )
  95. echo '..&nbsp;&nbsp;'.get_lang("level_up");
  96. echo "</b><tr><td align=left >\n".
  97. get_lang('folder')."</td>".
  98. "<td align=center >".get_lang('owner').
  99. "</td><td align=center >".get_lang('group')."</td></tr>\n";
  100. if(isset($dirlist['directorys']) and is_array($dirlist['directorys']))
  101. {
  102. $dirlist['directorys'] = array_orderby($dirlist['directorys'], 'filename', SORT_ASC);
  103. $i = 0;
  104. foreach($dirlist['directorys'] as $directory)
  105. {
  106. echo "<tr>\n".
  107. "<td class='folder' align=left data-item='$i' >".
  108. "<img src=\"" . check_theme_image("images/folder.png") . "\" alt=\"Directory\" /> ".
  109. "<b>" . $directory['filename'] . "</b></td>";
  110. echo "<td align=center >" . $directory['user'] . "</td>".
  111. "<td align=center >" . $directory['group']. "</td>\n".
  112. "</tr>\n";
  113. $_SESSION['browser_folders_'.$home_id][$i] = $directory['filename'];
  114. $i++;
  115. }
  116. }
  117. echo "<tr>\n".
  118. "<td align=left>".
  119. "<input style='width:100%;' type=text name=dirname placeholder='".
  120. get_lang("add_folder")."' title='".get_lang("add_folder_info").
  121. "' ></td><td align=left >&nbsp;<img id='addfolder' src=\"" . check_theme_image("images/addfolder.png") . "\" title=\"".
  122. get_lang("add_folder")."\" /> ".
  123. "</td>\n".
  124. "</tr>\n".
  125. "</table>\n";
  126. }
  127. }
  128. ?>