ProgressUI.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 isset($_GET["destdir"]) ? $_GET["destdir"] : ""; ?>";
  68. var f_time = 1;
  69. var f_totaltime = 1;
  70. var f_cancel = false;
  71. //Initiate floatWindow events
  72. ao_module_setWindowTitle("Inflating from compressed file...");
  73. ao_module_setWindowIcon("loading spinner");
  74. var f_load = setInterval(function(){
  75. $.ajax({
  76. //url: "getMessage.php?id=" + f_rand + "messages",
  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. $.get( '../SystemAOB/functions/file_system/move.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'&to=../../' + f_destdir + f_filenameToFoldername(f_file), function(data) {
  111. if(data !== "DONE"){
  112. if(ao_module_virtualDesktop){
  113. parent.msgbox(data,'<i class="caution sign icon"></i> 7-Zip File Manager',"");
  114. ao_module_close();
  115. }else{
  116. msgbox(data,"","");
  117. setTimeout(function(){ts('#modal').modal('hide')},1500);
  118. }
  119. }else{
  120. f_openFile(true);
  121. }
  122. });
  123. }else{
  124. f_openFile(false);
  125. }
  126. }
  127. });
  128. function f_filenameToFoldername(path){
  129. var filename = path.split("\\").join("/").split("/").pop();
  130. var filename = filename.split(".");
  131. if (filename.length > 1){
  132. filename.pop();
  133. }
  134. filename = filename.join(".");
  135. if (filename.substring(0,5) == "inith"){
  136. filename = filename.replace("inith","");
  137. }
  138. return filename;
  139. }
  140. function f_openFile(bool){
  141. var Folder = "";
  142. // bool = true then it have destdir
  143. // bool = false then it dont have destdir
  144. if(bool == true){
  145. //f_method = e then it is only single file
  146. //f_method = x then it is a folder
  147. if(f_method == "e"){
  148. Folder = f_destdir.replace("../","") + f_filenameToFoldername(f_file) + "/" + f_dir.replace(/^.*[\\\/]/, '');
  149. }else if(f_method == "x"){
  150. Folder = f_destdir.replace("../","") + f_filenameToFoldername(f_file);
  151. }
  152. }else{
  153. //f_method = e then it is only single file
  154. //f_method = x then it is a folder
  155. if(f_method == "e"){
  156. Folder = "7-Zip File Manager/tmp/" + f_rand + "/" + f_dir.replace(/^.*[\\\/]/, '');
  157. }else if(f_method == "x"){
  158. Folder = "7-Zip File Manager/tmp/" + f_rand + "/";
  159. }
  160. }
  161. //console.log(f_rand + Folder);
  162. if(ao_module_virtualDesktop){
  163. if(f_method == "e"){
  164. ao_module_openFile(Folder,"7-Zip Preview");
  165. }else if(f_method == "x"){
  166. ao_module_openPath(Folder);
  167. }
  168. ao_module_close();
  169. }else{
  170. if(f_method == "e"){
  171. window.open("../" + Folder);
  172. }else if(f_method == "x"){
  173. window.open("../SystemAOB/functions/file_system/index.php?controlLv=2#../../../" + Folder);
  174. }
  175. setTimeout(function(){ts('#modal').modal('hide')},1500);
  176. }
  177. }
  178. function f_convert(time){
  179. var hours = Math.floor(time / 3600);
  180. var minutes = Math.floor((time - (hours * 3600)) / 60);
  181. var seconds = time - (hours * 3600) - (minutes * 60);
  182. if(hours < 10){
  183. var dhour = "0" + hours;
  184. }else{
  185. var dhour = hours;
  186. }
  187. if(minutes < 10){
  188. var dminutes = "0" + minutes;
  189. }else{
  190. var dminutes = minutes;
  191. }
  192. if(seconds < 10){
  193. var dseconds = "0" + seconds;
  194. }else{
  195. var dseconds = seconds;
  196. }
  197. if(!isNaN(hours) && !isNaN(minutes) && !isNaN(seconds)){
  198. var formatted = dhour + ":" + dminutes + ":" + dseconds;
  199. }else{
  200. var formatted = "00:00:00";
  201. }
  202. return formatted;
  203. }
  204. function f_filesize(size){
  205. if(size >= 1073741824){
  206. return Math.floor(size/1073741824*100)/100 + "GB";
  207. }else if(size >= 1048576){
  208. return Math.floor(size/1048576*100)/100 + "MB";
  209. }else if(size >= 1024){
  210. return Math.floor(size/1024*100)/100 + "KB";
  211. }else{
  212. return size + "Bytes";
  213. }
  214. }
  215. function msgbox(content,bgcolor,fontcolor){
  216. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  217. ts('.snackbar').snackbar({
  218. content: content,
  219. onAction: () => {
  220. $(".snackbar").removeAttr("style");
  221. }
  222. });
  223. }
  224. function f_close(){
  225. if(ao_module_virtualDesktop){
  226. ao_module_close();
  227. }else{
  228. setTimeout(function(){ts('#modal').modal('hide')},1500);
  229. }
  230. }
  231. </script>
  232. </html>