MainUI.php 11 KB

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