ProgressUI_mod.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <?php
  2. include '../auth.php';
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <script src="../script/jquery.min.js"></script>
  9. <link rel="stylesheet" href="../script/tocas/tocas.css">
  10. <script type='text/javascript' src="../script/tocas/tocas.js"></script>
  11. <script type='text/javascript' src="../script/ao_module.js"></script>
  12. <title>7z File Manager</title>
  13. <style>
  14. body{
  15. background-color:white
  16. }
  17. .ts.form .inline.field label {
  18. min-width: 50%;
  19. }
  20. .ts.basic.dropdown, .ts.form select {
  21. max-width: 50%;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <br>
  27. <div class="ts container">
  28. <div class="ts grid">
  29. <div class="eight wide column">
  30. <span style="text-align:left">Elasped time:</span>
  31. <span style="text-align:right" id="time">00:00:00</span>
  32. </div>
  33. <div class="eight wide column">
  34. <span style="text-align:left">Total size:</span>
  35. <span style="text-align:right" id="totalsize">0 b</span>
  36. </div>
  37. <div class="eight wide column">
  38. <span style="text-align:left">Remaining time:</span>
  39. <span style="text-align:right" id="remaining">00:00:00</span>
  40. </div>
  41. <div class="eight wide column">
  42. <span style="text-align:left">Speed:</span>
  43. <span style="text-align:right" id="speed">0 b/s</span>
  44. </div>
  45. <div class="sixteen wide column">
  46. <span style="text-align:left">Loading...</span>
  47. <div class="ts progress">
  48. <div class="bar" id="bar" style="width: 0%"></div>
  49. </div>
  50. </div>
  51. <div class="eight wide column"></div>
  52. <div class="eight wide column">
  53. <button class="ts basic button" style="width:100%" onclick="f_close();f_cancel = true;">Cancel</button>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="ts bottom right snackbar">
  58. <div class="content"></div>
  59. </div>
  60. </body>
  61. <script>
  62. var f_method = "<?php echo $_GET["method"] ?>";
  63. var f_rand = "<?php echo $_GET["rand"] ?>";
  64. var f_file = "<?php echo $_GET["file"] ?>";
  65. var f_dir = "<?php echo $_GET["dir"] ?>";
  66. var f_DontCreateNewFoler = "<?php echo $_GET["DontCreateNewFolder"] ?>";
  67. var f_size = "<?php echo filesize($_GET["file"]); ?>";
  68. var f_destdir = "<?php echo isset($_GET["destdir"]) ? $_GET["destdir"] : ""; ?>";
  69. var f_time = 1;
  70. var f_totaltime = 1;
  71. var f_cancel = false;
  72. //Initiate floatWindow events
  73. ao_module_setWindowTitle("Inflating from compressed file...");
  74. ao_module_setWindowIcon("loading spinner");
  75. var f_load = setInterval(function(){
  76. $.ajax({
  77. url: "./tmp/" + f_rand + "messages",
  78. contentType: "text/plain"
  79. }).done(function(data) {
  80. var progress = data.match(/ ([0-9]{0,2}%)/gim);
  81. console.log(progress[progress.length - 1]);
  82. f_totaltime = Math.floor(f_time / (parseInt(progress[progress.length - 1])/100));
  83. $("#bar").attr("style","width: " + progress[progress.length - 1]);
  84. $("#time").text(f_convert(f_time));
  85. $("#remaining").text(f_convert(f_totaltime - f_time));
  86. $("#speed").text(f_filesize(Math.floor(f_size / f_totaltime)) + "/s");
  87. $("#totalsize").text(f_filesize(f_size));
  88. f_time += 1;
  89. });
  90. /*
  91. $.get("./tmp/" + f_rand + "messages", function( data ) {
  92. var progress = data.match(/ ([0-9]{0,2}%)/gim);
  93. console.log(progress[progress.length - 1]);
  94. f_totaltime = Math.floor(f_time / (parseInt(progress[progress.length - 1])/100));
  95. $("#bar").attr("style","width: " + progress[progress.length - 1]);
  96. $("#time").text(f_convert(f_time));
  97. $("#remaining").text(f_convert(f_totaltime - f_time));
  98. $("#speed").text(f_filesize(Math.floor(f_size / f_totaltime)) + "/s");
  99. $("#totalsize").text(f_filesize(f_size));
  100. f_time += 1;
  101. });
  102. */
  103. }, 1000);
  104. f_load;
  105. $.get("opr.php?method=" + f_method + "&rand=" + f_rand + "&file=" + f_file + "&dir=" + f_dir , function( raw ) {
  106. clearInterval(f_load);
  107. if(!f_cancel){
  108. if(f_destdir.length >0){
  109. //console.log('../SystemAOB/functions/file_system/move.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'&to=../../' + f_destdir + f_filenameToFoldername(f_file));
  110. console.log(f_destdir);
  111. console.log(f_filenameToFoldername(f_file));
  112. $.get( '../SystemAOB/functions/file_system/move.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'&to=../../' + f_destdir + f_filenameToFoldername(f_file), function(data) {
  113. console.log('DST' + f_destdir);
  114. console.log('Move to:../../' + f_destdir + f_filenameToFoldername(f_file));
  115. if(data !== "DONE"){
  116. if(ao_module_virtualDesktop){
  117. parent.msgbox(data,'<i class="caution sign icon"></i> 7-Zip File Manager',"");
  118. ao_module_close();
  119. }else{
  120. msgbox(data,"","");
  121. setTimeout(function(){ts('#modal').modal('hide')},1500);
  122. }
  123. }else{
  124. f_openFile(true);
  125. }
  126. });
  127. /*
  128. console.log('../SystemAOB/functions/file_system/copy_folder.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'/&target=../../' + f_destdir + f_rand + "/");
  129. console.log('../SystemAOB/functions/file_system/rename.php?file=../../' + f_destdir + f_rand + '&newFileName=../../' + f_destdir + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + '/&hex=false');
  130. $.get( '../SystemAOB/functions/file_system/copy_folder.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'/&target=../../' + f_destdir + f_rand + "/", function(data) {
  131. if(data !== "DONE"){
  132. msgbox(data,"","");
  133. if(ao_module_virtualDesktop){
  134. parent.msgbox(data,"","");
  135. ao_module_close();
  136. }else{
  137. msgbox(data,"","");
  138. setTimeout(function(){ts('#modal').modal('hide')},1500);
  139. }
  140. }
  141. $.get( '../SystemAOB/functions/file_system/rename.php?file=../../' + f_destdir + f_rand + '&newFileName=../../' + f_destdir + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + '/&hex=false', function(data) {
  142. if(data !== "DONE"){
  143. $.get( '../SystemAOB/functions/file_system/delete.php?filename=../../' + f_destdir + f_rand, function(data) {
  144. });
  145. if(ao_module_virtualDesktop){
  146. parent.msgbox(data,"","");
  147. ao_module_close();
  148. }else{
  149. msgbox(data,"","");
  150. setTimeout(function(){ts('#modal').modal('hide')},1500);
  151. }
  152. }else{
  153. f_openFile(true);
  154. }
  155. });
  156. });
  157. */
  158. }else{
  159. f_openFile(false);
  160. }
  161. }
  162. });
  163. function f_filenameToFoldername(path){
  164. if(!f_DontCreateNewFoler){
  165. var filename = path.split("\\").join("/").split("/").pop();
  166. var filename = filename.split(".");
  167. if (filename.length > 1){
  168. filename.pop();
  169. }
  170. filename = filename.join(".");
  171. if (filename.substring(0,5) == "inith"){
  172. filename = filename.replace("inith","");
  173. }
  174. return filename;
  175. }else{
  176. return "";
  177. }
  178. }
  179. function f_openFile(bool){
  180. var Folder = "";
  181. // bool = true then it have destdir
  182. // bool = false then it dont have destdir
  183. if(bool == true){
  184. //f_method = e then it is only single file
  185. //f_method = x then it is a folder
  186. if(f_method == "e"){
  187. Folder = f_destdir.replace("../","") + f_filenameToFoldername(f_file) + "/" + f_dir.replace(/^.*[\\\/]/, '');
  188. }else if(f_method == "x"){
  189. Folder = f_destdir.replace("../","") + f_filenameToFoldername(f_file);
  190. }
  191. }else{
  192. //f_method = e then it is only single file
  193. //f_method = x then it is a folder
  194. if(f_method == "e"){
  195. Folder = "7-Zip File Manager/tmp/" + f_rand + "/" + f_dir.replace(/^.*[\\\/]/, '');
  196. }else if(f_method == "x"){
  197. Folder = "7-Zip File Manager/tmp/" + f_rand + "/";
  198. }
  199. }
  200. //console.log(f_rand + Folder);
  201. if(ao_module_virtualDesktop){
  202. if(f_method == "e"){
  203. ao_module_openFile(Folder,"7-Zip Preview");
  204. }else if(f_method == "x"){
  205. ao_module_openPath(Folder);
  206. }
  207. ao_module_close();
  208. }else{
  209. if(f_method == "e"){
  210. window.open("../" + Folder);
  211. }else if(f_method == "x"){
  212. window.open("../SystemAOB/functions/file_system/index.php?controlLv=2#../../../" + Folder);
  213. }
  214. setTimeout(function(){ts('#modal').modal('hide')},1500);
  215. }
  216. }
  217. function f_convert(time){
  218. var hours = Math.floor(time / 3600);
  219. var minutes = Math.floor((time - (hours * 3600)) / 60);
  220. var seconds = time - (hours * 3600) - (minutes * 60);
  221. if(hours < 10){
  222. var dhour = "0" + hours;
  223. }else{
  224. var dhour = hours;
  225. }
  226. if(minutes < 10){
  227. var dminutes = "0" + minutes;
  228. }else{
  229. var dminutes = minutes;
  230. }
  231. if(seconds < 10){
  232. var dseconds = "0" + seconds;
  233. }else{
  234. var dseconds = seconds;
  235. }
  236. if(!isNaN(hours) && !isNaN(minutes) && !isNaN(seconds)){
  237. var formatted = dhour + ":" + dminutes + ":" + dseconds;
  238. }else{
  239. var formatted = "00:00:00";
  240. }
  241. return formatted;
  242. }
  243. function f_filesize(size){
  244. if(size >= 1073741824){
  245. return Math.floor(size/1073741824*100)/100 + "GB";
  246. }else if(size >= 1048576){
  247. return Math.floor(size/1048576*100)/100 + "MB";
  248. }else if(size >= 1024){
  249. return Math.floor(size/1024*100)/100 + "KB";
  250. }else if(size > 0){
  251. return size + "Bytes";
  252. }
  253. }
  254. function msgbox(content,bgcolor,fontcolor){
  255. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  256. ts('.snackbar').snackbar({
  257. content: content,
  258. onAction: () => {
  259. $(".snackbar").removeAttr("style");
  260. }
  261. });
  262. }
  263. function f_close(){
  264. if(ao_module_virtualDesktop){
  265. ao_module_close();
  266. }else{
  267. setTimeout(function(){ts('#modal').modal('hide')},1500);
  268. }
  269. }
  270. </script>
  271. </html>