ProgressUI.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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_size = "<?php echo filesize($_GET["file"]); ?>";
  67. var f_destdir = "<?php echo $_GET["destdir"] ?? ""; ?>";
  68. var f_time = 1;
  69. var f_totaltime = 1;
  70. var f_cancel = false;
  71. var f_load = setInterval(function(){
  72. $.get( "./tmp/" + f_rand + "messages", function( data ) {
  73. var progress = data.match(/ ([0-9]{0,2}%)/gim);
  74. console.log(progress[progress.length - 1]);
  75. f_totaltime = Math.floor(f_time / (parseInt(progress[progress.length - 1])/100));
  76. $("#bar").attr("style","width: " + progress[progress.length - 1]);
  77. $("#time").text(f_convert(f_time));
  78. $("#remaining").text(f_convert(f_totaltime - f_time));
  79. $("#speed").text(f_filesize(Math.floor(f_size / f_totaltime)) + "/s");
  80. $("#totalsize").text(f_filesize(f_size));
  81. f_time += 1;
  82. });
  83. }, 1000);
  84. f_load;
  85. $.get("opr.php?method=" + f_method + "&rand=" + f_rand + "&file=" + f_file + "&dir=" + f_dir , function( raw ) {
  86. clearInterval(f_load);
  87. if(!f_cancel){
  88. if(f_destdir.length >0){
  89. $.get( '../SystemAOB/functions/file_system/copy_folder.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'/&target=../../' + f_destdir + f_rand + "/", function(data) {
  90. if(data !== "DONE"){
  91. msgbox(data,"","");
  92. if(ao_module_virtualDesktop){
  93. parent.msgbox(data,"","");
  94. ao_module_close();
  95. }else{
  96. msgbox(data,"","");
  97. setTimeout(function(){ts('#modal').modal('hide')},1500);
  98. }
  99. }
  100. $.get( '../SystemAOB/functions/file_system/rename.php?file=../../' + f_destdir + f_rand + '&newFileName=../../' + f_destdir + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + '/&hex=false', function(data) {
  101. if(data !== "DONE"){
  102. $.get( '../SystemAOB/functions/file_system/delete.php?filename=../../' + f_destdir + f_rand, function(data) {
  103. });
  104. if(ao_module_virtualDesktop){
  105. parent.msgbox(data,"","");
  106. ao_module_close();
  107. }else{
  108. msgbox(data,"","");
  109. setTimeout(function(){ts('#modal').modal('hide')},1500);
  110. }
  111. }else{
  112. f_openFile(true);
  113. }
  114. });
  115. });
  116. }else{
  117. f_openFile(false);
  118. }
  119. }
  120. });
  121. function f_openFile(bool){
  122. var Folder = "";
  123. // bool = true then it have destdir
  124. // bool = false then it dont have destdir
  125. if(bool == true){
  126. //f_method = e then it is only single file
  127. //f_method = x then it is a folder
  128. if(f_method == "e"){
  129. Folder = f_destdir.substring(3) + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + "/" + f_dir.replace(/^.*[\\\/]/, '');
  130. }else if(f_method == "x"){
  131. Folder = f_destdir.substring(3) + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"");
  132. }
  133. }else{
  134. //f_method = e then it is only single file
  135. //f_method = x then it is a folder
  136. if(f_method == "e"){
  137. Folder = "7-Zip File Manager/tmp/" + f_rand + "/" + f_dir.replace(/^.*[\\\/]/, '');
  138. }else if(f_method == "x"){
  139. Folder = "7-Zip File Manager/tmp/" + f_rand + "/";
  140. }
  141. }
  142. console.log(f_rand + Folder);
  143. if(ao_module_virtualDesktop){
  144. if(f_method == "e"){
  145. ao_module_openFile(Folder,"7-Zip Preview");
  146. }else if(f_method == "x"){
  147. ao_module_openPath(Folder);
  148. }
  149. ao_module_close();
  150. }else{
  151. if(f_method == "e"){
  152. window.open("../" + Folder);
  153. }else if(f_method == "x"){
  154. window.open("../SystemAOB/functions/file_system/index.php?controlLv=2#../../../" + Folder);
  155. }
  156. setTimeout(function(){ts('#modal').modal('hide')},1500);
  157. }
  158. }
  159. function f_convert(time){
  160. var hours = Math.floor(time / 3600);
  161. var minutes = Math.floor((time - (hours * 3600)) / 60);
  162. var seconds = time - (hours * 3600) - (minutes * 60);
  163. if(hours < 10){
  164. var dhour = "0" + hours;
  165. }else{
  166. var dhour = hours;
  167. }
  168. if(minutes < 10){
  169. var dminutes = "0" + minutes;
  170. }else{
  171. var dminutes = minutes;
  172. }
  173. if(seconds < 10){
  174. var dseconds = "0" + seconds;
  175. }else{
  176. var dseconds = seconds;
  177. }
  178. if(!isNaN(hours) && !isNaN(minutes) && !isNaN(seconds)){
  179. var formatted = dhour + ":" + dminutes + ":" + dseconds;
  180. }else{
  181. var formatted = "00:00:00";
  182. }
  183. return formatted;
  184. }
  185. function f_filesize(size){
  186. if(size >= 1073741824){
  187. return Math.floor(size/1073741824*100)/100 + "GB";
  188. }else if(size >= 1048576){
  189. return Math.floor(size/1048576*100)/100 + "MB";
  190. }else if(size >= 1024){
  191. return Math.floor(size/1024*100)/100 + "KB";
  192. }else{
  193. return size + "Bytes";
  194. }
  195. }
  196. function msgbox(content,bgcolor,fontcolor){
  197. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  198. ts('.snackbar').snackbar({
  199. content: content,
  200. onAction: () => {
  201. $(".snackbar").removeAttr("style");
  202. }
  203. });
  204. }
  205. function f_close(){
  206. if(ao_module_virtualDesktop){
  207. ao_module_close();
  208. }else{
  209. setTimeout(function(){ts('#modal').modal('hide')},1500);
  210. }
  211. }
  212. </script>
  213. </html>