MainUI.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. -webkit-user-select: none; /* Safari */
  17. -moz-user-select: none; /* Firefox */
  18. -ms-user-select: none; /* IE10+/Edge */
  19. user-select: none; /* Standard */
  20. }
  21. tr{
  22. cursor:pointer;
  23. }
  24. tr:hover {
  25. background-color: #fafafa;
  26. }
  27. @media (max-width: 767px){
  28. .ts.bottom.right.snackbar.active{
  29. width: 100% !important;
  30. bottom: 0px !important;
  31. right: 0px !important;
  32. }
  33. .ts.snackbar:not(.inline) .content {
  34. margin-bottom: 7px;
  35. }
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div class="ts labeled icon menu" style="box-shadow: 0px 0px 0px 0 #000000 !important;">
  41. <a class="item" onclick="functionbar_extract();">
  42. <i class="minus icon"></i> Extract
  43. </a>
  44. <a class="item disabled" onclick="functionbar_extract();">
  45. <i class="copy icon"></i> Copy
  46. </a>
  47. <a class="item" onclick="msgbox('Error: Operation is not supported','red','white')">
  48. <i class="remove icon"></i> Clear Cache
  49. </a>
  50. <a class="item" onclick="functionbar_info();">
  51. <i class="notice icon"></i> Info
  52. </a>
  53. </div>
  54. <div class="ts breadcrumb" style="left: 20px;padding-bottom:10px;" id="breadcrumb">
  55. <button class="ts icon mini basic button" path="" attr="Dir" id="returnBtn" onclick="load(this)">
  56. <i class="reply icon"></i>
  57. </button>
  58. <p href="#!" class="section"><?php echo $_GET["file"] ?></p>
  59. </div>
  60. <div class="ts fitted divider"></div>
  61. <table class="ts borderless table">
  62. <thead>
  63. <tr id="thead">
  64. </tr>
  65. </thead>
  66. <tbody id="tbody">
  67. </tbody>
  68. </table>
  69. <!-- use for displaying dialog , for VDI user , use VDI module instead -->
  70. <div class="ts modals dimmer">
  71. <dialog id="modal" class="ts basic modal" style="background-color: white;color: black!important" open>
  72. <div class="content" id="modaldata">
  73. </div>
  74. </dialog>
  75. </div>
  76. <div class="ts bottom right snackbar">
  77. <div class="content"></div>
  78. </div>
  79. <div class="ts contextmenu">
  80. <div class="item" onclick="contextmenu_extract()">
  81. Open
  82. <span class="description">Enter</span>
  83. </div>
  84. <div class="item" onclick="functionbar_extract()">
  85. Extract
  86. </div>
  87. <div class="item" onclick="functionbar_info()">
  88. Properties
  89. </div>
  90. </div>
  91. </body>
  92. <script>
  93. /*
  94. Reminder: the x and y for new windows no longer has any function;
  95. please change it on another page directly.
  96. */
  97. //Global variable
  98. var random = Math.floor((Math.random() * 10000) + 1000);
  99. var file = "<?php echo $_GET["file"] ?>";
  100. //Init floatWindow events
  101. ao_module_setWindowIcon("file archive outline");
  102. ao_module_setGlassEffectMode();
  103. ao_module_setWindowTitle(ao_module_codec.decodeUmFilename(basename(file)) + " 7-Zip File Manager");
  104. if(!["7Z","LZMA","CAB","ZIP","GZIP","BZIP2","Z","TAR"].includes(basename(file).split(".")[1].toUpperCase())){
  105. msgbox('Warning: Unsupport file type','yellow','black');
  106. }
  107. if (ao_module_virtualDesktop){
  108. //Push up the body section a bit to compensate for the floatWindow offsets
  109. $("body").css("padding-bottom","20px");
  110. }
  111. ao_module_setWindowSize(950,530);
  112. function basename(path){
  113. path = path.split("\\").join("/");
  114. return path.split("/").pop();
  115. }
  116. load($("#returnBtn"));
  117. $.get("deltmp.php", function(data) {
  118. });
  119. ts('.borderless.table').contextmenu({
  120. menu: '.ts.contextmenu'
  121. });
  122. $('body').on('click', function(e) {
  123. if (e.target !== this)
  124. return;
  125. $("tr").removeAttr("style");
  126. });
  127. document.onkeydown = function(e) {
  128. if($("[style='background-color: #e9e9e9;']").length > 0){
  129. var htmlelement = $("[style='background-color: #e9e9e9;']");
  130. }else{
  131. var htmlelement = $("#tbody tr:first");
  132. }
  133. switch (e.keyCode) {
  134. case 9:
  135. if(htmlelement.prev().length > 0){
  136. var next = htmlelement.prev();
  137. $("tr").removeAttr("style");
  138. $(next).attr("style","background-color: #e9e9e9;");
  139. }
  140. case 13:
  141. var htmlelement = $("[style='background-color: #e9e9e9;']");
  142. load(htmlelement);
  143. break;
  144. case 38:
  145. if(htmlelement.prev().length > 0){
  146. var next = htmlelement.prev();
  147. $("tr").removeAttr("style");
  148. $(next).attr("style","background-color: #e9e9e9;");
  149. }else{
  150. $("tr").removeAttr("style");
  151. $(htmlelement).attr("style","background-color: #e9e9e9;");
  152. }
  153. break;
  154. case 40:
  155. if(htmlelement.next().length > 0){
  156. var next = htmlelement.next();
  157. $("tr").removeAttr("style");
  158. $(next).attr("style","background-color: #e9e9e9;");
  159. }else{
  160. $("tr").removeAttr("style");
  161. $(htmlelement).attr("style","background-color: #e9e9e9;");
  162. }
  163. break;
  164. }
  165. };
  166. //for load data into table
  167. //load($(returnBtn));
  168. function onsingleclick(htmlelement){
  169. $("tr").removeAttr("style");
  170. $(htmlelement).attr("style","background-color: #e9e9e9;");
  171. }
  172. function load(htmlelement){
  173. if($(htmlelement).attr("attr") == "Dir"){
  174. $("#breadcrumb").html('<button class="ts icon mini basic button" disabled><i class="level up icon"></i></button> <p class="section"><i class="loading circle notched icon"></i>Fetching..</p>');
  175. //for load data into table
  176. $.get("opr.php?method=l&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"), function( raw ) {
  177. //clear table for pepare load data into table
  178. $("#thead").html("");
  179. $("#tbody").html("");
  180. var data = JSON.parse(raw); //parse it
  181. var header = data["Header"];
  182. //create thead
  183. $(data["Header"]).each(function( key, value ) {
  184. $("#thead").append("<th>" + value + "</th>");//create header (thead) first
  185. });
  186. //create tbody
  187. $(data["Information"]).each(function( a, value ) {
  188. //to check if attr not exists. if not exists, assume it is an file.
  189. if(typeof value["Attributes"] === 'undefined'){
  190. var attr = "File";
  191. }else{
  192. if(value["Attributes"].includes("D")){
  193. var attr = "Dir";
  194. }else{
  195. var attr = "File";
  196. }
  197. }
  198. //create HTML structure
  199. var tmp = "";
  200. tmp = tmp + '<tr path="' + value["Path"] + '" attr="' + attr + '" ondblclick="load(this)" onclick="onsingleclick(this)" oncontextmenu="onsingleclick(this)">'
  201. $.each(data["Header"], function( a, key ) {
  202. if(typeof value[key] !== 'undefined'){
  203. if(key == "Path"){
  204. //create fanastic icon to user
  205. if(attr == "Dir"){
  206. var tdicon = '<i class="folder outline icon"></i>';
  207. }else{
  208. var filepath = value["Path"].trim();
  209. if (filepath != ""){
  210. var ext = filepath.split(".").pop();
  211. var icon = ao_module_utils.getIconFromExt(ext);
  212. var tdicon = '<i class="' + icon + ' icon"></i>';
  213. }else{
  214. var tdicon = '<i class="file outline icon"></i>';
  215. }
  216. }
  217. var tdpath = value[key].replace(new RegExp($(htmlelement).attr("path") + "/"),"");
  218. if(tdpath.includes("?")){
  219. var tdicon = '<i class="exclamation triangle icon"></i>';
  220. }
  221. tmp = tmp + "<td>" + tdicon + ao_module_codec.decodeUmFilename(tdpath) + "</td>";
  222. }else{
  223. tmp = tmp + "<td>" + value[key] + "</td>";
  224. }
  225. }else{
  226. tmp = tmp + "<td></td>";
  227. }
  228. });
  229. $("#tbody").append(tmp + "</tr>");
  230. });
  231. /*
  232. //Little patch for HEX file name (PATCH)
  233. $( "tr td:first-child" ).each( function( index, element ){
  234. var tpath = $(this);
  235. if(/^inith[0-9a-fA-F]*\..*$|^[0-9a-fA-F]*$/.test($(tpath).text())){
  236. $.get( '../SystemAOB/functions/file_system/um_filename_decoder.php?filename=' + $(tpath).text(), function( decodedfilename ) {
  237. $(tpath).text(decodedfilename);
  238. });
  239. }
  240. });
  241. */
  242. //process for Prev button
  243. var path = $(htmlelement).attr("path").split("/");
  244. var previousPath = $(htmlelement).attr("path").replace(/([^\/]+)$/, '').slice(0, -1);
  245. if(previousPath == $(htmlelement).attr("path")){
  246. previousPath = "";
  247. }
  248. //console.log(previousPath);
  249. $("#breadcrumb").html('<button class="ts icon mini basic button" currPath="' + $(htmlelement).attr("path") + '" path="' + previousPath + '" attr="Dir" id="returnBtn" onclick="load(this)"><i class="level up icon"></i></button> <p href="#!" class="section">' + ao_module_codec.decodeUmFilename(file.replace(/^.*[\\\/]/, '')) +'</p><div class="divider">/</div>');
  250. if($(htmlelement).attr("path").length > 1){
  251. $.each(path, function( a, key ) {
  252. $("#breadcrumb").append('<p href="#!" class="section"><i class="folder icon"></i>' + key + '</p><div class="divider">/</div>');
  253. });
  254. }
  255. });
  256. }else{
  257. //if it was file, show it.
  258. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"),720,250);
  259. random = Math.floor((Math.random() * 10000) + 1000);
  260. }
  261. }
  262. function contextmenu_extract(){
  263. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,250);
  264. random = Math.floor((Math.random() * 10000) + 1000);
  265. }
  266. function functionbar_extract(){
  267. //extract files or dir , if file then pass method=e , if dir then pass method=x
  268. if($("[style='background-color: #e9e9e9;']").attr("attr") == "Dir"){
  269. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $($("[style='background-color: #e9e9e9;']")).attr("path"),720,280);
  270. }else if($("[style='background-color: #e9e9e9;']").attr("attr") == "File"){
  271. showDialog("CopyNMoveUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,280);
  272. }else{
  273. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $("#returnBtn").attr("currPath"),720,250);
  274. }
  275. //generate new number for next extraction
  276. random = Math.floor((Math.random() * 10000) + 1000);
  277. }
  278. function functionbar_info(){
  279. //showDialog("infoUI.php?file=" + file,365,475);
  280. var displayname = ao_module_codec.decodeUmFilename(basename(file));
  281. var icon = ao_module_utils.getIconFromExt(displayname.split(".").pop().trim());
  282. ao_module_newfw('7-Zip File Manager/' + "infoUI.php?file=" + file,displayname + ' - Properties',icon,'7-ZipProgressUI' + Math.floor(Math.random()*100),365,475,undefined,undefined,true,true);
  283. }
  284. function showDialog(href,x,y){
  285. if(ao_module_virtualDesktop){
  286. ao_module_newfw('7-Zip File Manager/' + href,'Extract Files - 7zip File Manager','external','7-ZipProgressUI' + Math.floor(Math.random()*100),x,y,undefined,undefined,true,true);
  287. }else{
  288. $.get( href, function( data ) {
  289. $( "#modaldata" ).html( data );
  290. ts('#modal').modal("show");
  291. });
  292. }
  293. }
  294. function msgbox(content,bgcolor,fontcolor){
  295. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  296. ts('.snackbar').snackbar({
  297. content: content,
  298. onAction: () => {
  299. $(".snackbar").removeAttr("style");
  300. }
  301. });
  302. }
  303. </script>
  304. </html>