ProgressUI.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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_DontCreateNewFolder = <?php echo isset($_GET["DontCreateNewFolder"]) ? $_GET["DontCreateNewFolder"] : "false"; ?>;
  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. var f_iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
  73. //Initiate floatWindow events
  74. ao_module_setWindowTitle("Inflating from compressed file...");
  75. ao_module_setWindowIcon("loading spinner");
  76. var f_load = setInterval(function(){
  77. $.ajax({
  78. //url: "getMessage.php?id=" + f_rand + "messages",
  79. url: "./tmp/" + f_rand + "messages",
  80. contentType: "text/plain"
  81. }).done(function(data) {
  82. var progress = data.match(/ ([0-9]{0,2}%)/gim);
  83. console.log(progress[progress.length - 1]);
  84. f_totaltime = Math.floor(f_time / (parseInt(progress[progress.length - 1])/100));
  85. $("#bar").attr("style","width: " + progress[progress.length - 1]);
  86. $("#time").text(f_convert(f_time));
  87. $("#remaining").text(f_convert(f_totaltime - f_time));
  88. $("#speed").text(f_filesize(Math.floor(f_size / f_totaltime)) + "/s");
  89. $("#totalsize").text(f_filesize(f_size));
  90. f_time += 1;
  91. });
  92. /*
  93. $.get("./tmp/" + f_rand + "messages", function( data ) {
  94. var progress = data.match(/ ([0-9]{0,2}%)/gim);
  95. console.log(progress[progress.length - 1]);
  96. f_totaltime = Math.floor(f_time / (parseInt(progress[progress.length - 1])/100));
  97. $("#bar").attr("style","width: " + progress[progress.length - 1]);
  98. $("#time").text(f_convert(f_time));
  99. $("#remaining").text(f_convert(f_totaltime - f_time));
  100. $("#speed").text(f_filesize(Math.floor(f_size / f_totaltime)) + "/s");
  101. $("#totalsize").text(f_filesize(f_size));
  102. f_time += 1;
  103. });
  104. */
  105. }, 1000);
  106. f_load;
  107. $.get("opr.php?method=" + f_method + "&rand=" + f_rand + "&file=" + f_file + "&dir=" + f_dir , function( raw ) {
  108. clearInterval(f_load);
  109. if(!f_cancel){
  110. if(f_destdir.length >0){
  111. //console.log('../SystemAOB/functions/file_system/move.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'&to=../../' + f_destdir + 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. $.get( 'move.php?from=../7-Zip%20File%20Manager/tmp/' + f_rand +'&to=' + f_destdir + f_filenameToFoldername(f_file) + '&DontCreateNewFolder=' + f_DontCreateNewFolder , function(data) {
  114. if(data !== "DONE"){
  115. if(ao_module_virtualDesktop){
  116. parent.msgbox(data,'<i class="caution sign icon"></i> 7-Zip File Manager',"");
  117. ao_module_close();
  118. }else{
  119. msgbox(data,"","");
  120. setTimeout(function(){ts('#modal').modal('hide')},1500);
  121. }
  122. }else{
  123. f_openFile(true);
  124. }
  125. });
  126. }else{
  127. f_openFile(false);
  128. }
  129. }
  130. });
  131. function f_filenameToFoldername(path){
  132. if(!f_DontCreateNewFolder){
  133. var filename = path.split("\\").join("/").split("/").pop();
  134. var filename = filename.split(".");
  135. if (filename.length > 1){
  136. filename.pop();
  137. }
  138. filename = filename.join(".");
  139. if (filename.substring(0,5) == "inith"){
  140. filename = filename.replace("inith","");
  141. }
  142. return filename;
  143. }else{
  144. return "";
  145. }
  146. }
  147. function f_openFile(bool){
  148. var Folder = "";
  149. // bool = true then it have destdir
  150. // bool = false then it dont have destdir
  151. if(bool == true){
  152. //f_method = e then it is only single file
  153. //f_method = x then it is a folder
  154. if(f_method == "e"){
  155. Folder = f_destdir.replace("../","") + f_filenameToFoldername(f_file) + "/" + f_dir.replace(/^.*[\\\/]/, '');
  156. }else if(f_method == "x"){
  157. Folder = f_destdir.replace("../","") + f_filenameToFoldername(f_file);
  158. }
  159. }else{
  160. //f_method = e then it is only single file
  161. //f_method = x then it is a folder
  162. if(f_method == "e"){
  163. Folder = "7-Zip File Manager/tmp/" + f_rand + "/" + f_dir.replace(/^.*[\\\/]/, '');
  164. }else if(f_method == "x"){
  165. Folder = "7-Zip File Manager/tmp/" + f_rand + "/";
  166. }
  167. }
  168. //console.log(f_rand + Folder);
  169. if(ao_module_virtualDesktop){
  170. if(f_method == "e"){
  171. ao_module_openFile(Folder,"7-Zip Preview");
  172. }else if(f_method == "x"){
  173. ao_module_openPath(Folder);
  174. }
  175. ao_module_close();
  176. }else{
  177. if(f_method == "e"){
  178. if(f_iOS){
  179. window.location.replace("../" + Folder)
  180. }else{
  181. window.open("../" + Folder);
  182. }
  183. }else if(f_method == "x"){
  184. if(f_iOS){
  185. window.location.replace("../SystemAOB/functions/file_system/index.php?controlLv=2#../../../" + Folder)
  186. }else{
  187. window.open("../SystemAOB/functions/file_system/index.php?controlLv=2#../../../" + Folder);
  188. }
  189. }
  190. setTimeout(function(){ts('#modal').modal('hide')},1500);
  191. }
  192. }
  193. function f_convert(time){
  194. var hours = Math.floor(time / 3600);
  195. var minutes = Math.floor((time - (hours * 3600)) / 60);
  196. var seconds = time - (hours * 3600) - (minutes * 60);
  197. if(hours < 10){
  198. var dhour = "0" + hours;
  199. }else{
  200. var dhour = hours;
  201. }
  202. if(minutes < 10){
  203. var dminutes = "0" + minutes;
  204. }else{
  205. var dminutes = minutes;
  206. }
  207. if(seconds < 10){
  208. var dseconds = "0" + seconds;
  209. }else{
  210. var dseconds = seconds;
  211. }
  212. if(!isNaN(hours) && !isNaN(minutes) && !isNaN(seconds)){
  213. var formatted = dhour + ":" + dminutes + ":" + dseconds;
  214. }else{
  215. var formatted = "00:00:00";
  216. }
  217. return formatted;
  218. }
  219. function f_filesize(size){
  220. if(size >= 1073741824){
  221. return Math.floor(size/1073741824*100)/100 + "GB";
  222. }else if(size >= 1048576){
  223. return Math.floor(size/1048576*100)/100 + "MB";
  224. }else if(size >= 1024){
  225. return Math.floor(size/1024*100)/100 + "KB";
  226. }else{
  227. return size + "Bytes";
  228. }
  229. }
  230. function msgbox(content,bgcolor,fontcolor){
  231. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  232. ts('.snackbar').snackbar({
  233. content: content,
  234. onAction: () => {
  235. $(".snackbar").removeAttr("style");
  236. }
  237. });
  238. }
  239. function f_close(){
  240. if(ao_module_virtualDesktop){
  241. ao_module_close();
  242. }else{
  243. setTimeout(function(){ts('#modal').modal('hide')},1500);
  244. }
  245. }
  246. </script>
  247. </html>