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