MainUI.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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" 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" onclick="functionbar_extract();">
  48. <i class="copy icon"></i> Copy
  49. </a>
  50. <a class="item" 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> Delete
  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;" id="breadcrumb">
  61. <button class="ts icon mini basic button" path="" attr="Dir" id="returnBtn" onclick="load(this)">
  62. <i class="level up icon"></i>
  63. </button>
  64. <p href="#!" class="section"><?php echo $_GET["file"] ?></p>
  65. </div>
  66. <table class="ts borderless table">
  67. <thead>
  68. <tr id="thead">
  69. </tr>
  70. </thead>
  71. <tbody id="tbody">
  72. </tbody>
  73. </table>
  74. <!-- use for displaying dialog , for VDI user , use VDI module instead -->
  75. <div class="ts modals dimmer">
  76. <dialog id="modal" class="ts basic modal" style="background-color: white;color: black!important" open>
  77. <div class="content" id="modaldata">
  78. </div>
  79. </dialog>
  80. </div>
  81. <div class="ts bottom right snackbar">
  82. <div class="content"></div>
  83. </div>
  84. <div class="ts contextmenu">
  85. <div class="item" onclick="contextmenu_extract()">
  86. Open
  87. <span class="description">Enter</span>
  88. </div>
  89. <div class="item" onclick="functionbar_extract()">
  90. Extract
  91. </div>
  92. <div class="item" onclick="functionbar_info()">
  93. Properties
  94. </div>
  95. </div>
  96. </body>
  97. <script>
  98. //Global variable
  99. var random = Math.floor((Math.random() * 10000) + 1000);
  100. var file = "<?php echo $_GET["file"] ?>";
  101. load($(returnBtn));
  102. $.get("deltmp.php", function(data) {
  103. });
  104. ts('*').contextmenu({
  105. menu: '.ts.contextmenu'
  106. });
  107. $('body').on('click', function(e) {
  108. if (e.target !== this)
  109. return;
  110. $("tr").removeAttr("style");
  111. });
  112. document.onkeydown = function(e) {
  113. if($("[style='background-color: #e9e9e9;']").length > 0){
  114. var htmlelement = $("[style='background-color: #e9e9e9;']");
  115. }else{
  116. var htmlelement = $("#tbody tr:first");
  117. }
  118. switch (e.keyCode) {
  119. case 9:
  120. if(htmlelement.prev().length > 0){
  121. var next = htmlelement.prev();
  122. $("tr").removeAttr("style");
  123. $(next).attr("style","background-color: #e9e9e9;");
  124. }
  125. case 13:
  126. var htmlelement = $("[style='background-color: #e9e9e9;']");
  127. load(htmlelement);
  128. break;
  129. case 38:
  130. if(htmlelement.prev().length > 0){
  131. var next = htmlelement.prev();
  132. $("tr").removeAttr("style");
  133. $(next).attr("style","background-color: #e9e9e9;");
  134. }else{
  135. $("tr").removeAttr("style");
  136. $(htmlelement).attr("style","background-color: #e9e9e9;");
  137. }
  138. break;
  139. case 40:
  140. if(htmlelement.next().length > 0){
  141. var next = htmlelement.next();
  142. $("tr").removeAttr("style");
  143. $(next).attr("style","background-color: #e9e9e9;");
  144. }else{
  145. $("tr").removeAttr("style");
  146. $(htmlelement).attr("style","background-color: #e9e9e9;");
  147. }
  148. break;
  149. }
  150. };
  151. //for load data into table
  152. load($(returnBtn));
  153. function onsingleclick(htmlelement){
  154. $("tr").removeAttr("style");
  155. $(htmlelement).attr("style","background-color: #e9e9e9;");
  156. }
  157. function load(htmlelement){
  158. if($(htmlelement).attr("attr") == "Dir"){
  159. $("#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>');
  160. //for load data into table
  161. $.get("opr.php?method=l&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"), function( raw ) {
  162. //clear table for pepare load data into table
  163. $("#thead").html("");
  164. $("#tbody").html("");
  165. var data = JSON.parse(raw); //parse it
  166. var header = data["Header"];
  167. //create thead
  168. $(data["Header"]).each(function( key, value ) {
  169. $("#thead").append("<th>" + value + "</th>");//create header (thead) first
  170. });
  171. //create tbody
  172. $(data["Information"]).each(function( a, value ) {
  173. //to check if attr not exists. if not exists, assume it is an file.
  174. if(typeof value["Attributes"] === 'undefined'){
  175. var attr = "File";
  176. }else{
  177. if(value["Attributes"].includes("D")){
  178. var attr = "Dir";
  179. }else{
  180. var attr = "File";
  181. }
  182. }
  183. //create HTML structure
  184. var tmp = "";
  185. tmp = tmp + '<tr path="' + value["Path"] + '" attr="' + attr + '" ondblclick="load(this)" onclick="onsingleclick(this)" oncontextmenu="onsingleclick(this)">'
  186. $.each(data["Header"], function( a, key ) {
  187. if(typeof value[key] !== 'undefined'){
  188. if(key == "Path"){
  189. //create fanastic icon to user
  190. if(attr == "Dir"){
  191. var tdicon = '<i class="folder outline icon"></i>';
  192. }else{
  193. var tdicon = '<i class="file outline icon"></i>';
  194. }
  195. var tdpath = value[key].replace(new RegExp($(htmlelement).attr("path") + "/"),"");
  196. if(tdpath.includes("?")){
  197. var tdicon = '<i class="exclamation triangle icon"></i>';
  198. }
  199. tmp = tmp + "<td>" + tdicon + tdpath + "</td>";
  200. }else{
  201. tmp = tmp + "<td>" + value[key] + "</td>";
  202. }
  203. }else{
  204. tmp = tmp + "<td></td>";
  205. }
  206. });
  207. $("#tbody").append(tmp + "</tr>");
  208. });
  209. //Little patch for HEX file name (PATCH)
  210. $( "tr td:first-child" ).each( function( index, element ){
  211. var tpath = $(this);
  212. if(/^inith[0-9a-fA-F]*\..*$|^[0-9a-fA-F]*$/.test($(tpath).text())){
  213. $.get( '../SystemAOB/functions/file_system/um_filename_decoder.php?filename=' + $(tpath).text(), function( decodedfilename ) {
  214. $(tpath).text(decodedfilename);
  215. });
  216. }
  217. });
  218. //process for Prev button
  219. var path = $(htmlelement).attr("path").split("/");
  220. var previousPath = $(htmlelement).attr("path").replace(/([^\/]+)$/, '').slice(0, -1);
  221. if(previousPath == $(htmlelement).attr("path")){
  222. previousPath = "";
  223. }
  224. console.log(previousPath);
  225. $("#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>');
  226. if($(htmlelement).attr("path").length > 1){
  227. $.each(path, function( a, key ) {
  228. $("#breadcrumb").append('<p href="#!" class="section"><i class="folder icon"></i>' + key + '</p><div class="divider">/</div>');
  229. });
  230. }
  231. });
  232. }else{
  233. //if it was file, show it.
  234. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"),720,250);
  235. random = Math.floor((Math.random() * 10000) + 1000);
  236. }
  237. }
  238. function contextmenu_extract(){
  239. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,250);
  240. random = Math.floor((Math.random() * 10000) + 1000);
  241. }
  242. function functionbar_extract(){
  243. //extract files or dir , if file then pass method=e , if dir then pass method=x
  244. if($("[style='background-color: #e9e9e9;']").attr("attr") == "Dir"){
  245. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $($("[style='background-color: #e9e9e9;']")).attr("path"),720,250);
  246. }else if($("[style='background-color: #e9e9e9;']").attr("attr") == "File"){
  247. showDialog("CopyNMoveUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,250);
  248. }else{
  249. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $("#returnBtn").attr("currPath"),720,250);
  250. }
  251. //generate new number for next extraction
  252. random = Math.floor((Math.random() * 10000) + 1000);
  253. }
  254. function functionbar_info(){
  255. showDialog("infoUI.php?file=" + file,340,250);
  256. }
  257. function showDialog(href,x,y){
  258. if(ao_module_virtualDesktop){
  259. ao_module_newfw('7-Zip File Manager/' + href,'7-Zip','file outline','7-ZipProgressUI' + Math.floor(Math.random()*100),x,y);
  260. }else{
  261. $.get( href, function( data ) {
  262. $( "#modaldata" ).html( data );
  263. ts('#modal').modal("show");
  264. });
  265. }
  266. }
  267. function msgbox(content,bgcolor,fontcolor){
  268. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  269. ts('.snackbar').snackbar({
  270. content: content,
  271. onAction: () => {
  272. $(".snackbar").removeAttr("style");
  273. }
  274. });
  275. }
  276. </script>
  277. </html>