MainUI.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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:hover {
  22. background-color: #fafafa;
  23. }
  24. @media (max-width: 767px){
  25. .ts.bottom.right.snackbar.active{
  26. width: 100% !important;
  27. bottom: 0px !important;
  28. right: 0px !important;
  29. }
  30. .ts.snackbar:not(.inline) .content {
  31. margin-bottom: 7px;
  32. }
  33. }
  34. </style>
  35. </head>
  36. <body>
  37. <div class="ts labeled icon menu" style="box-shadow: 0px 0px 0px 0 #000000 !important;">
  38. <a class="item disabled" onclick="msgbox('Error: Operation is not supported','red','white')">
  39. <i class="plus icon"></i> Add
  40. </a>
  41. <a class="item" onclick="functionbar_extract();">
  42. <i class="minus icon"></i> Extract
  43. </a>
  44. <a class="item" onclick="msgbox('Warning: Not implemented','yellow','Black')">
  45. <i class="chevron down icon"></i> Test
  46. </a>
  47. <a class="item disabled" onclick="functionbar_extract();">
  48. <i class="copy icon"></i> Copy
  49. </a>
  50. <a class="item disabled" onclick="functionbar_extract();">
  51. <i class="move icon"></i> Move
  52. </a>
  53. <a class="item" onclick="msgbox('Error: Operation is not supported','red','white')">
  54. <i class="remove icon"></i> Clear Cache
  55. </a>
  56. <a class="item" onclick="functionbar_info();">
  57. <i class="notice icon"></i> Info
  58. </a>
  59. </div>
  60. <div class="ts breadcrumb" style="left: 20px;padding-bottom:10px;" id="breadcrumb">
  61. <button class="ts icon mini basic button" path="" attr="Dir" id="returnBtn" onclick="load(this)">
  62. <i class="reply icon"></i>
  63. </button>
  64. <p href="#!" class="section"><?php echo $_GET["file"] ?></p>
  65. </div>
  66. <div class="ts fitted divider"></div>
  67. <table class="ts borderless table">
  68. <thead>
  69. <tr id="thead">
  70. </tr>
  71. </thead>
  72. <tbody id="tbody">
  73. </tbody>
  74. </table>
  75. <!-- use for displaying dialog , for VDI user , use VDI module instead -->
  76. <div class="ts modals dimmer">
  77. <dialog id="modal" class="ts basic modal" style="background-color: white;color: black!important" open>
  78. <div class="content" id="modaldata">
  79. </div>
  80. </dialog>
  81. </div>
  82. <div class="ts bottom right snackbar">
  83. <div class="content"></div>
  84. </div>
  85. <div class="ts contextmenu">
  86. <div class="item" onclick="contextmenu_extract()">
  87. Open
  88. <span class="description">Enter</span>
  89. </div>
  90. <div class="item" onclick="functionbar_extract()">
  91. Extract
  92. </div>
  93. <div class="item" onclick="functionbar_info()">
  94. Properties
  95. </div>
  96. </div>
  97. </body>
  98. <script>
  99. //Global variable
  100. var random = Math.floor((Math.random() * 10000) + 1000);
  101. var file = "<?php echo $_GET["file"] ?>";
  102. //Init floatWindow events
  103. ao_module_setWindowIcon("file archive outline");
  104. ao_module_setGlassEffectMode();
  105. ao_module_setWindowTitle(ao_module_codec.decodeUmFilename(basename(file)) + " 7-Zip File Manager");
  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. function basename(path){
  111. path = path.split("\\").join("/");
  112. return path.split("/").pop();
  113. }
  114. load($("#returnBtn"));
  115. $.get("deltmp.php", 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 + 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. });
  229. //Little patch for HEX file name (PATCH)
  230. $( "tr td:first-child" ).each( function( index, element ){
  231. var tpath = $(this);
  232. if(/^inith[0-9a-fA-F]*\..*$|^[0-9a-fA-F]*$/.test($(tpath).text())){
  233. $.get( '../SystemAOB/functions/file_system/um_filename_decoder.php?filename=' + $(tpath).text(), function( decodedfilename ) {
  234. $(tpath).text(decodedfilename);
  235. });
  236. }
  237. });
  238. //process for Prev button
  239. var path = $(htmlelement).attr("path").split("/");
  240. var previousPath = $(htmlelement).attr("path").replace(/([^\/]+)$/, '').slice(0, -1);
  241. if(previousPath == $(htmlelement).attr("path")){
  242. previousPath = "";
  243. }
  244. //console.log(previousPath);
  245. $("#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">' + file.replace(/^.*[\\\/]/, '') +'</p><div class="divider">/</div>');
  246. if($(htmlelement).attr("path").length > 1){
  247. $.each(path, function( a, key ) {
  248. $("#breadcrumb").append('<p href="#!" class="section"><i class="folder icon"></i>' + key + '</p><div class="divider">/</div>');
  249. });
  250. }
  251. });
  252. }else{
  253. //if it was file, show it.
  254. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"),720,250);
  255. random = Math.floor((Math.random() * 10000) + 1000);
  256. }
  257. }
  258. function contextmenu_extract(){
  259. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,250);
  260. random = Math.floor((Math.random() * 10000) + 1000);
  261. }
  262. function functionbar_extract(){
  263. //extract files or dir , if file then pass method=e , if dir then pass method=x
  264. if($("[style='background-color: #e9e9e9;']").attr("attr") == "Dir"){
  265. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $($("[style='background-color: #e9e9e9;']")).attr("path"),720,250);
  266. }else if($("[style='background-color: #e9e9e9;']").attr("attr") == "File"){
  267. showDialog("CopyNMoveUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,250);
  268. }else{
  269. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $("#returnBtn").attr("currPath"),720,250);
  270. }
  271. //generate new number for next extraction
  272. random = Math.floor((Math.random() * 10000) + 1000);
  273. }
  274. function functionbar_info(){
  275. //showDialog("infoUI.php?file=" + file,365,475);
  276. var displayname = ao_module_codec.decodeUmFilename(basename(file));
  277. ao_module_newfw('7-Zip File Manager/' + "infoUI.php?file=" + file,displayname + ' - Properties','file outline','7-ZipProgressUI' + Math.floor(Math.random()*100),365,475,undefined,undefined,true,true);
  278. }
  279. function showDialog(href,x,y){
  280. if(ao_module_virtualDesktop){
  281. ao_module_newfw('7-Zip File Manager/' + href,'7-Zip','file outline','7-ZipProgressUI' + Math.floor(Math.random()*100),x,y,undefined,undefined,true,true);
  282. }else{
  283. $.get( href, function( data ) {
  284. $( "#modaldata" ).html( data );
  285. ts('#modal').modal("show");
  286. });
  287. }
  288. }
  289. function msgbox(content,bgcolor,fontcolor){
  290. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  291. ts('.snackbar').snackbar({
  292. content: content,
  293. onAction: () => {
  294. $(".snackbar").removeAttr("style");
  295. }
  296. });
  297. }
  298. </script>
  299. </html>