litefm.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 do_progress($kbytes,$totalsize)
  26. {
  27. if( $totalsize != 0 )
  28. {
  29. $mbytes = round($kbytes / 1024, 2);
  30. if($kbytes > 0)
  31. {
  32. $pct = round(( $kbytes / $totalsize ) * 100, 2);
  33. }
  34. else
  35. {
  36. $pct = get_lang("unavailable");
  37. }
  38. #echo "Percent is $pct";
  39. return "$totalsize;$mbytes;$pct";
  40. }
  41. return "0;0;0";
  42. }
  43. function show_back($home_id)
  44. {
  45. if( isset($_SESSION['fm_cwd_'.$home_id]) && preg_match("/^\/*$/",$_SESSION['fm_cwd_'.$home_id]) == 0 )
  46. return "<tr><td colspan='5' ><a href=\"?m=litefm&amp;home_id=$home_id&amp;back\" style='padding-left:5px;' > ..&nbsp;&nbsp;".get_lang("level_up")."</a></td></tr>";
  47. }
  48. function litefm_check($home_id)
  49. {
  50. if (isset($_GET['item']) and !isset($_GET['upload']) and !isset( $_POST['delete'] ) and !isset( $_POST['create_folder'] ) and !isset( $_POST['secureButton'] ) and !isset( $_POST['delete_check'] ) and !isset( $_POST['secure_check'] ))
  51. {
  52. if(!isset($_SESSION['fm_files_'.$home_id][$_GET['item']]))
  53. return FALSE;
  54. $path = $_SESSION['fm_files_'.$home_id][$_GET['item']];
  55. // Make sure nobody tries to get outside thier game server by referencing the .. directory
  56. if(preg_match("/\/\.\.\/|\||;/", $path))
  57. {
  58. print_failure(get_lang("unallowed_char"));
  59. $_SESSION['fm_cwd_'.$home_id] = NULL;
  60. return FALSE;
  61. }
  62. else
  63. {
  64. $_SESSION['fm_cwd_'.$home_id] = @$_SESSION['fm_cwd_'.$home_id] . "/" . $path;
  65. $_SESSION['fm_cwd_'.$home_id] = clean_path($_SESSION['fm_cwd_'.$home_id]);
  66. }
  67. }
  68. // To go back a dir, we just use dirname to strip the last directory or file off the path
  69. if (isset($_GET['back']) and !isset($_GET['upload']) and !isset( $_POST['delete'] ) and !isset( $_POST['create_folder'] ) and !isset( $_POST['secureButton'] ) and !isset( $_POST['delete_check'] ) and !isset( $_POST['secure_check'] ))
  70. {
  71. $_SESSION['fm_cwd_'.$home_id] = dirname( $_SESSION['fm_cwd_'.$home_id] );
  72. }
  73. return TRUE;
  74. }
  75. ?>