MainUI.php 11 KB

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