upload_interface.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <?php
  2. include '../auth.php';
  3. ?>
  4. <!DOCTYPE HTML>
  5. <html>
  6. <head>
  7. <script src="../script/jquery.min.js"></script>
  8. <script src="../script/dropzone/dropzone.js"></script>
  9. <link rel="stylesheet" href="../script/dropzone/min/dropzone.min.css">
  10. <link rel="stylesheet" href="../script/tocas/tocas.css">
  11. <script src="../script/tocas/tocas.js"></script>
  12. <title>ArOZ Onlineβ</title>
  13. <style type="text/css">
  14. body {
  15. //padding-top: 4em;
  16. background-color: rgb(250, 250, 250);
  17. }
  18. .ts.segmented.list {
  19. //height: 100vh;
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <?php
  25. $embeddMode = false;
  26. if (isset($_GET['embedded']) && $_GET['embedded'] == "true"){
  27. $embeddMode = true;
  28. }else{
  29. echo '<nav id="topMenu" class="ts attached inverted borderless large menu">
  30. <div class="ts narrow container">
  31. <a href="../index.php" class="item">ArOZ Online β</a>
  32. </div>
  33. </nav>';
  34. }
  35. ?>
  36. <br>
  37. <style>
  38. .dropzone-previews {
  39. height: 200px;
  40. width: 500px;
  41. border: dashed 1px red;
  42. background-color: lightblue;
  43. }
  44. </style>
  45. <?php
  46. $upload2module = "";
  47. //Check if the target module directory has been provided
  48. if (isset($_GET['target']) && $_GET['target'] != ""){
  49. $upload2module = $_GET['target'];
  50. }else{
  51. $errmsg = "The upload target directory is undefined.";
  52. $thisfile = basename($_SERVER['PHP_SELF']);
  53. header("Location: index.php?errmsg=" . $errmsg ."&source=" . $thisfile );
  54. die();
  55. }
  56. //Check if the target module support upload or notice
  57. if (!file_exists("../" . $upload2module . "/uploads/")){
  58. $errmsg = "The 'uploads' directory in the target directory were not found. Are you sure you have created an 'uploads' folder under your module's root directory?";
  59. $thisfile = basename($_SERVER['PHP_SELF']);
  60. header("Location: index.php?errmsg=" . $errmsg ."&source=" . $thisfile );
  61. die();
  62. }
  63. $reminder = '<dialog id="reminder" class="ts basic fullscreen modal" style="position:fixed;
  64. margin:0 auto;
  65. clear:left;
  66. height:auto;
  67. z-index: 1000;
  68. display:none;
  69. background:rgba(0,0,0,0.5);
  70. text-align:center;" open>
  71. <div class="ts icon header">
  72. <i class="notice circle icon"></i> Reminder from %MODULE_NAME% Module
  73. </div>
  74. <div class="content">
  75. <p>%REMINDER_TEXT%<br>
  76. %SYSTEMINFO%</p>
  77. </div>
  78. <div class="actions">
  79. <button class="ts inverted basic button" onClick="NSA()">
  80. Never shown again
  81. </button>
  82. <button class="ts inverted basic button" onClick="HideReminder()">
  83. OK
  84. </button>
  85. </div>
  86. </dialog>';
  87. if (isset($_GET['reminder']) && $_GET['reminder'] != ""){
  88. $rbox = str_replace("%MODULE_NAME%",$upload2module,$reminder);
  89. $rbox = str_replace("%REMINDER_TEXT%",$_GET['reminder'],$rbox);
  90. $systeminfo = "ArOZ Online BETA [Developmental Build] Upload Manager UI";
  91. $rbox = str_replace("%SYSTEMINFO%",$systeminfo,$rbox);
  92. echo $rbox;
  93. }
  94. $finishing = "";
  95. if (isset($_GET['finishing']) && $_GET['finishing'] != ""){
  96. $finishing = "../" . $upload2module . "/" . $_GET['finishing'];
  97. }else{
  98. $finishing = "../". $upload2module . "/";
  99. }
  100. ?>
  101. <script>
  102. //Transfering variables from PHP to Javascript
  103. var modulename = "<?php echo $upload2module;?>";
  104. var finishingStep = "<?php echo $finishing;?>";
  105. </script>
  106. <div class="ts narrow container">
  107. <div class="ts breadcrumb">
  108. <div href="#!" class="section">Upload Manager UI</div>
  109. <div class="divider">/</div>
  110. <a href="<?php if (!$embeddMode){echo "../" . $upload2module . "/";}?>" class="section"><i class="folder icon"></i> <?php echo $upload2module;?></a>
  111. <div class="divider">/</div>
  112. <div class="active section">
  113. <?php
  114. if (isset($_GET['ext']) && $_GET['ext'] != ""){
  115. if (strpos($_GET['ext'],"/media/") === 0){
  116. echo '<i class="usb icon"></i>'.$_GET['ext'];
  117. }else{
  118. die("ERROR. Invalid external upload path.");
  119. }
  120. }else{
  121. echo '<i class="folder icon"></i>Uploads';
  122. }
  123. ?>
  124. </div>
  125. </div>
  126. <div class="active section" style="display:inline;position:absolute;right: 0;">
  127. <?php
  128. //Echo the internal storage path
  129. echo '<a class="ts label" onClick="changeUploadTarget(this);">
  130. <i class="folder icon"></i> ' . "Uploads" .'
  131. </a>';
  132. include("../SystemAOB/functions/system_statistic/listMountedStorage.php");
  133. foreach ($mountInfo as $usabledrive){
  134. echo '<a class="ts label" onClick="changeUploadTarget(this);">
  135. <i class="usb icon"></i> ' . $usabledrive[1] .'
  136. </a>';
  137. }
  138. ?>
  139. </div>
  140. <!-- END OF TOP BAR-->
  141. <br><br>
  142. <form action="upload_handler.php"
  143. class="dropzone"
  144. id="fileDropzone">
  145. <input type="text" style="display:none;" name="targetModule" value="<?php echo $upload2module;?>">
  146. <input type="text" style="display:none;" name="filetype" value="<?php
  147. if (isset($_GET['filetype']) && $_GET['filetype'] != ""){
  148. echo $_GET['filetype'];
  149. }else{
  150. echo '';
  151. }
  152. ?>">
  153. <input type="text" style="display:none;" name="extmode" value="<?php
  154. if (isset($_GET['ext']) && $_GET['ext'] != ""){
  155. echo $_GET['ext'];
  156. }else{
  157. echo '';
  158. }
  159. ?>">
  160. </form>
  161. <p><i class="notice circle icon"></i>Supported Format:
  162. <?php
  163. if (isset($_GET['filetype']) && $_GET['filetype'] != ""){
  164. echo $_GET['filetype'];
  165. }else{
  166. echo 'ALL';
  167. }
  168. ?></p>
  169. <div class="ts grid">
  170. <div class="eleven wide column">
  171. <div class="ts selection segmented list">
  172. <?php
  173. $item_template = ' <a class="item">
  174. <i class="%ICON_TYPE% icon"></i>
  175. %FILE_NAME%
  176. </a>';
  177. if (isset($_GET['ext']) && $_GET['ext'] != "" && file_exists($_GET['ext'])){
  178. $path = $_GET['ext'] . "/" . $upload2module . '/';
  179. }else{
  180. $path = '../' . $upload2module . '/uploads/';
  181. }
  182. $files = scandir($path);
  183. $files = array_diff(scandir($path), array('.', '..','Thumbs.db'));//If you are on windows,then ignore the Thumbs.db
  184. foreach ($files as $file){
  185. //Decode File Name
  186. $filename = hex2bin(str_replace("." . pathinfo($file, PATHINFO_EXTENSION),"",str_replace("inith","",$file))) . "." . pathinfo($file, PATHINFO_EXTENSION);
  187. //echo $filename . "<br>";
  188. $mime = mime_content_type($path . $file);
  189. if(strstr($mime, "video/")){
  190. $icontype = "file video outline";
  191. }else if(strstr($mime, "image/")){
  192. $icontype = "file image outline";
  193. }else if(strstr($mime, "audio/")){
  194. $icontype = "file audio outline";
  195. }else{
  196. $icontype = "file outline";
  197. }
  198. //Echo each unit of file
  199. $itembox = str_replace("%ICON_TYPE%",$icontype,$item_template);
  200. $itembox = str_replace("%FILE_NAME%",$filename,$itembox);
  201. echo $itembox;
  202. }
  203. ?>
  204. </div>
  205. </div>
  206. <div class="five wide column">
  207. <div class="ts card">
  208. <div class="secondary very padded extra content">
  209. <div class="ts icon header">
  210. <?php
  211. if (file_exists("../$upload2module/img/function_icon.png")){
  212. echo '<img class="ts fluid image" src="../'.$upload2module.'/img/function_icon.png"></img>';
  213. }else{
  214. echo '<img class="ts fluid image" src="../img/no_icon.png"></img>';
  215. }
  216. ?>
  217. </div>
  218. </div>
  219. <!-- Module description -->
  220. <div class="extra content">
  221. <div class="header"><?php
  222. $description_path = "../" . $upload2module . "/description.txt";
  223. if (file_exists($description_path)){
  224. echo file_get_contents($description_path);
  225. }else{
  226. echo 'This module has no description.';
  227. }
  228. ?></div>
  229. </div>
  230. <div class="extra content">
  231. <div class="ts fluid vertical buttons">
  232. <button onclick = "DoneUpload()" class="ts basic positive button">Done</button>
  233. <button onClick = "location.reload();" class="ts basic button">Update List</button>
  234. <?php
  235. if (!$embeddMode){
  236. echo <<<EOF
  237. <button onClick="cancelOperation();" class="ts basic negative button">Cancel</button>
  238. EOF;
  239. }
  240. ?>
  241. </div>
  242. </div>
  243. <div class="ts horizontal right floated middoted link list">
  244. <?php if (!$embeddMode){ echo '<a class="item" onClick="traditional();">Alternative Upload</a>';}else{echo '<div class="item">Embbedded Mode</div>';}?>
  245. <div class="item">Upload Manager v1.0</div>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. <script>
  251. var ao_module_virtualDesktop = !(!parent.isFunctionBar);
  252. if (ao_module_virtualDesktop){
  253. $("#topMenu").hide();
  254. $("body").css("padding-bottom","50px");
  255. }
  256. function cancelOperation(){
  257. if (ao_module_virtualDesktop){
  258. if (ao_module_virtualDesktop)ao_module_windowID = $(window.frameElement).parent().attr("id");
  259. parent.closeWindow(ao_module_windowID);
  260. }else{
  261. window.location = '../';
  262. }
  263. }
  264. $( document ).ready(function() {
  265. //Check if reminder should be shown
  266. var show_reminder = localStorage.getItem(modulename.toLowerCase() + "-reminder");
  267. console.log(show_reminder);
  268. if (show_reminder == '0'){
  269. $('#reminder').hide();
  270. }else{
  271. $('#reminder').show();
  272. }
  273. });
  274. function traditional(){
  275. var uri = 'upload_interface_traditional.php';
  276. uri = uri + document.location.search;
  277. window.location.href=uri;
  278. }
  279. function DoneUpload(){
  280. window.location = finishingStep;
  281. }
  282. function HideReminder(){
  283. $('#reminder').fadeOut('slow');
  284. }
  285. function NSA(){
  286. //Never shown again for this module
  287. localStorage.setItem(modulename.toLowerCase() + "-reminder", 0);
  288. $('#reminder').fadeOut('slow');
  289. }
  290. function changeUploadTarget(object){
  291. var target = ($(object).text().trim());
  292. var newurl = window.location.href;
  293. if (target == "Uploads"){
  294. newurl = removeParam("ext",newurl);
  295. }else{
  296. newurl = removeParam("ext",newurl);
  297. newurl = newurl + "&ext=" + target;
  298. }
  299. window.location.href = newurl;
  300. }
  301. function removeParam(key, sourceURL) {
  302. var rtn = sourceURL.split("?")[0],
  303. param,
  304. params_arr = [],
  305. queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : "";
  306. if (queryString !== "") {
  307. params_arr = queryString.split("&");
  308. for (var i = params_arr.length - 1; i >= 0; i -= 1) {
  309. param = params_arr[i].split("=")[0];
  310. if (param === key) {
  311. params_arr.splice(i, 1);
  312. }
  313. }
  314. rtn = rtn + "?" + params_arr.join("&");
  315. }
  316. return rtn;
  317. }
  318. </script>
  319. </body>
  320. </html>