litefm.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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('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. $fileName = !empty($_POST['name']) ? $_POST['name'] : (isset($_GET['name']) ? $_GET['name'] : '');
  53. if(isset($_GET['type'])){
  54. $type = $_GET['type'];
  55. }else{
  56. $type = "file";
  57. }
  58. if(!isset($_SESSION['fm_files_'.$home_id][$_GET['item']]))
  59. return FALSE;
  60. $path = $_SESSION['fm_files_'.$home_id][$_GET['item']];
  61. if($path == $fileName){
  62. // Validate the path for dangerous characters and traversal attempts
  63. if(!validate_path($path))
  64. {
  65. print_failure(get_lang("unallowed_char") . " : " . htmlspecialchars($path));
  66. $_SESSION['fm_cwd_'.$home_id] = NULL;
  67. return FALSE;
  68. }
  69. else
  70. {
  71. if($type != "file"){
  72. $_SESSION['fm_cwd_'.$home_id] = @$_SESSION['fm_cwd_'.$home_id] . "/" . $path;
  73. $_SESSION['fm_cwd_'.$home_id] = clean_path($_SESSION['fm_cwd_'.$home_id]);
  74. }else{
  75. if((isset($_SESSION['fm_cwd_'.$home_id]) and !endsWith($_SESSION['fm_cwd_'.$home_id], $path)) or !isset($_SESSION['fm_cwd_'.$home_id])){
  76. $_SESSION['fm_cwd_'.$home_id] = @$_SESSION['fm_cwd_'.$home_id] . "/" . $path;
  77. $_SESSION['fm_cwd_'.$home_id] = clean_path($_SESSION['fm_cwd_'.$home_id]);
  78. }
  79. }
  80. }
  81. }
  82. }
  83. // To go back a dir, we just use dirname to strip the last directory or file off the path
  84. 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'] ))
  85. {
  86. $_SESSION['fm_cwd_'.$home_id] = dirname( $_SESSION['fm_cwd_'.$home_id] );
  87. }
  88. return TRUE;
  89. }
  90. ?>