Advertisement
Kawiesh

Directory Listing Formatting

Mar 27th, 2022 (edited)
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.17 KB | None | 0 0
  1. <!-- ----------.htaccess---------- -->
  2. #ENABLE DIR.LIST BUT HIDE PARENT DIR. AND PHP
  3. Options +Indexes
  4. IndexIgnore .. *php
  5.  
  6. #SET INDEX OPTIONS
  7. IndexOptions IgnoreCase FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* SuppressHTMLPreamble HTMLTable
  8.  
  9. #SPECIFY HEADER AND FOOTER FILE
  10. HeaderName /path/header.html
  11. ReadmeName /path/footer.html
  12.  
  13. <!-- ----------header.html---------- -->
  14. <html>
  15. <head>
  16. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  17. <style>
  18.  
  19. table{
  20. border:1.5px solid black;      
  21. border-collapse: collapse;
  22. width: 96%;
  23. margin: 10px 2% 0 2%;
  24. font: 12px Arial;
  25. table-layout: fixed;
  26. }
  27.  
  28. a{
  29. text-decoration: none;
  30. }
  31.  
  32. a:visited{
  33. color: blue;
  34. }
  35.  
  36. th{
  37. background: yellow;
  38. text-align: center;
  39. border: 1px solid black;
  40. }
  41.  
  42. th:nth-child(1){
  43. width: 30px;
  44. }
  45.  
  46. th:nth-child(2){
  47. text-align: left;
  48. width: auto;
  49. }
  50.  
  51. th:nth-child(3){
  52. width: 70px;
  53. }
  54.  
  55. th:nth-child(4){
  56. width: 40px;
  57. }
  58.  
  59. td{
  60. padding: 2px;
  61. border:1px solid black;
  62. height: 1em;
  63. text-align: left;
  64. vertical-align: center;
  65. overflow: auto;
  66. }
  67.  
  68. td:nth-child(3){
  69. text-align: center;
  70. font-style: italic;
  71. }
  72.  
  73. td:nth-child(1),
  74. td:nth-child(4){
  75. text-align: center;
  76. }
  77.  
  78. th[colspan="5"],
  79. th:nth-child(5),
  80. td:nth-child(5){
  81. display: none;
  82. }
  83.  
  84. h3{
  85. font: bold 12px Arial;
  86. color: green;
  87. margin: 0 0 0 2%;
  88. }
  89.  
  90. #home{
  91. width: 96%;
  92. margin: 20px 2%;
  93. font: bold 12px "Courier New";
  94. animation: skale 2.5s linear infinite alternate;
  95. }
  96.  
  97. @keyframes skale{
  98. 0%{transform: scale(1,1)}
  99. 100%{transform: scale(0.9,0.9)}
  100. }
  101. </style>
  102. </head>
  103. <body>
  104.  
  105.  
  106.  
  107.  
  108.  
  109. <!-- ----------footer.html---------- -->
  110. <div id="home">
  111. In the table above, you can see the files and subdirectories present in this directory. PHP files are hidden, since they can't be viewed in the browser. Click <a href="/">HERE</a> to go back to the home page! &#9734; Kawiesh &#9734;
  112. </div>
  113. <script>
  114. let create= (x)=> document.createElement(x),
  115. select= (x,y=document)=> y.querySelector(x),
  116. selectAll= (x,y=document)=> y.querySelectorAll(x);
  117.  
  118. addH3();
  119. renameMod();
  120. removeTime();
  121.  
  122. function addH3(){
  123. let a= `List of files in ${location.hostname}`;
  124. let b= `List of files in ${location.hostname}${location.pathname}`;
  125.  
  126.  
  127. let h3= create("h3");
  128. document.body.prepend(h3);
  129.  
  130. h3.innerHTML= (location.pathname=="/") ? a : b;
  131. document.title= location.hostname + " - File list";
  132. }
  133.  
  134. function renameMod(){
  135. let a= select("th:nth-child(3)>a");
  136. a.text= "Modified";
  137. }
  138.  
  139. function removeTime(){
  140. let a= selectAll("td:nth-child(3)");
  141. let b= /\d{4}-\d{2}-\d{2}/;
  142.  
  143. a.forEach(i=>{
  144. let a= i.innerHTML.match(b);
  145. a= a.toString().split("-");
  146. let d= a[2], m= a[1], y= a[0];
  147. i.innerHTML= `${d}-${m}-${y}`;
  148. });
  149. }
  150.  
  151. //Add custom icons
  152.  
  153. function addIcon(a,b,c){
  154. if(a.text.endsWith(b)){
  155. a.closest("td").previousElementSibling.innerHTML= c;
  156. }
  157. }
  158. let name= selectAll("td:nth-child(2)>a");
  159. name.forEach(i=>{
  160. addIcon(i,"",file);
  161. addIcon(i,".svg",pic);
  162. addIcon(i,".jpg",pic);
  163. addIcon(i,".png",pic);
  164. addIcon(i,".gif",pic);
  165. addIcon(i,".mp3",mp3);
  166. addIcon(i,".pdf",pdf);
  167. addIcon(i,".zip",zip);
  168. addIcon(i,"/",folder);
  169. });
  170.  
  171. //Make variables for file,pic,mp3,pdf,zip,folder,etc.
  172. //Inline svg or img
  173.  
  174. </script>
  175. </body>
  176. </html>
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement