PageRenderTime 26ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/assets/filemanager/uploader/index.php

https://gitlab.com/agustus/wisata-web
PHP | 166 lines | 87 code | 17 blank | 62 comment | 19 complexity | 721e47124f7f4f1f953d48aaf88dc393 MD5 | raw file
  1. <?php
  2. $config = include '../config/config.php';
  3. //TODO switch to array
  4. extract($config, EXTR_OVERWRITE);
  5. if ( ! $java_upload)
  6. {
  7. die('forbidden');
  8. }
  9. if ($_SESSION['RF']["verify"] != "RESPONSIVEfilemanager")
  10. {
  11. die('forbidden');
  12. }
  13. //Let's load the 'interesting' stuff ... ;-)
  14. include 'jupload.php';
  15. include '../include/utils.php';
  16. $path = $current_path . $_GET['path'];
  17. $cycle = true;
  18. $max_cycles = 50;
  19. $i = 0;
  20. while ($cycle && $i < $max_cycles)
  21. {
  22. $i++;
  23. if ($path == $current_path)
  24. {
  25. $cycle = false;
  26. }
  27. if (file_exists($path . "config.php"))
  28. {
  29. require_once $path . "config.php";
  30. $cycle = false;
  31. }
  32. $path = fix_dirname($path) . "/";
  33. }
  34. $path = "../" . $current_path . $_GET['path'];
  35. if (strpos($_GET['path'], '../') !== false || strpos($_GET['path'], './') !== false || strpos($_GET['path'], '/') === 0)
  36. {
  37. die ('path error');
  38. }
  39. $path = str_replace(' ', '~', $path);
  40. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  41. /////////////// The user callback function, that can be called after upload ////////////////////////
  42. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  43. /**
  44. * This function will be called, once all files are uploaded, with the list of uploaded files as an argument.
  45. *
  46. * Condition to have this function called:
  47. * - Have the applet parameter afterUploadURL unset in this file. This makes the applet use its default behavior, that
  48. * is: afterUploadURL is the current web page, with the ?afterupload=1 parameter added.
  49. * - Have the class parameter callbackAfterUploadManagement set to 'handle_uploaded_files', name of this callback. You
  50. * can use any name you want, but the function must accept one unique parameter: the array that contains the file
  51. * descriptions.
  52. *
  53. * @param $juploadPhpSupportClass The instance of the JUpload PHP class.
  54. * @param $file The array wich contains info about all uploaded files.
  55. */
  56. function handle_uploaded_files($juploadPhpSupportClass, $files)
  57. {
  58. return
  59. "<P>We are in the 'handle_uploaded_files' callback function, in the index.php script. To avoid double coding, we "
  60. . "just call the default behavior of the JUpload PHP class. Just replace this by your code...</P>"
  61. . $juploadPhpSupportClass->defaultAfterUploadManagement();;
  62. }
  63. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  64. //First: the applet parameters
  65. //
  66. // Default value should work nice on most configuration. In this sample, we use some specific parameters, to show
  67. // how to use this array.
  68. // See comment for the parameters used on this demo page.
  69. //
  70. // You can use all applet parameters in this array.
  71. // see all details http://jupload.sourceforge.net/howto-customization.html
  72. //
  73. $appletParameters = array(
  74. //Default value is ... maximum size for a file on the current FS. 2G is problably too much already.
  75. 'maxFileSize' => $JAVAMaxSizeUpload . 'G',
  76. //
  77. //In the sourceforge project structure, the applet jar file is one folder below. Default
  78. //configuration is ok, if wjhk.jupload.jar is in the same folder as the script containing this call.
  79. 'archive' => 'wjhk.jupload.jar',
  80. 'showLogWindow' => 'false',
  81. 'width' => '100%',
  82. 'height' => '358px',
  83. 'name' => 'No limit Uploader',
  84. 'allowedFileExtensions' => implode('/', $ext),
  85. //To manage, other jar files, like the ftp jar files if postURL is an FTP URL:
  86. //'archive' => 'wjhk.jupload.jar,jakarta-commons-oro.jar,jakarta-commons-net.jar',
  87. //
  88. //Default afterUploadURL displays the list of uploaded files above the applet (in the <!--JUPLOAD_FILES--> markers, see below)
  89. //You can use any page you want, to manage the uploaded files. Here is a sample, that also only shows the list of files.
  90. 'afterUploadURL' => 'success.php?path=' . $_GET['path'],
  91. //
  92. //This demo expects the md5sum to be sent by the applet. But the parameter is not mandatory
  93. //This value should be set to false (or the line commented), for big files, as md5 calculation
  94. //may be long (Note this must be string and *not* boolean true/false)
  95. 'sendMD5Sum' => 'false',
  96. //
  97. 'debugLevel' => 0 // 100 disables redirect after upload, so we keep it below. This still gives a lot of information, in case of problem.
  98. );
  99. // for htaccess protected folders
  100. if ((isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER'] != '') && $_SERVER['PHP_AUTH_USER'] != '' && $_SERVER['PHP_AUTH_USER'] != '')
  101. {
  102. $appletParameters['specificHeaders'] = 'Authorization: Basic ' . base64_encode($_SERVER['PHP_AUTH_USER'] . ":" . $_SERVER['PHP_AUTH_PW']);
  103. }
  104. //
  105. //Then: the jupload PHP class parameters
  106. $classParameters = array(
  107. //Files won't be stored on the server. Useful for first tests of the applet behavior ... and sourceforge demo site !
  108. 'demo_mode' => false,
  109. //
  110. //Allow creation of subdirectories, when uploading several folders/files (drag and drop a folder on the applet to use it).
  111. 'allow_subdirs' => true,
  112. //
  113. // The callbackAfterUploadManagement function will be called, once all files are uploaded, with the list
  114. //of uploaded files as an argument. See the above sample, and change it according to your needs.
  115. //'callbackAfterUploadManagement' => 'handle_uploaded_files',
  116. //
  117. //I work on windows. The default configuration is /var/tmp/jupload_test
  118. 'destdir' => $path //Where to store the files on the web
  119. //'errormail' => 'me@my.domain.org',
  120. );
  121. if ( ! empty($convert_spaces))
  122. {
  123. $classParameters['convert_spaces'] = true;
  124. }
  125. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  126. // Instantiate and initialize JUpload : integration of the applet in your web site.
  127. $juploadPhpSupportClass = new JUpload($appletParameters, $classParameters);
  128. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  129. //Then, a simple HTML page, for the demo
  130. //
  131. // "<!--JUPLOAD_FILES-->" is the tag where the list of uploaded files will be written.
  132. // "<!--JUPLOAD_APPLET-->" is the place where the applet will be integrated, in the web page.
  133. ?>
  134. <html>
  135. <head>
  136. <!--JUPLOAD_JSCRIPT-->
  137. <title>JUpload RESPONSIVE filemanager</title>
  138. <style>
  139. body {
  140. padding: 0px;
  141. margin: 0px;
  142. }
  143. </style>
  144. </head>
  145. <body>
  146. <div align="center"><!--JUPLOAD_FILES--></div>
  147. <div align="center"><!--JUPLOAD_APPLET--></div>
  148. </body>
  149. </html>