Advertisement
umasoodch

tablephp

Dec 19th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.06 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3.  
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>Directory Contents</title>
  7. <script src=".sorttable.js"></script>
  8. </head>
  9.  
  10. <style>
  11.  
  12. {
  13. padding:0;
  14. margin:0;
  15. }
  16.  
  17. body {
  18. color: #333;
  19. font: 14px Sans-Serif;
  20. padding: 50px;
  21. background: #eee;
  22. }
  23.  
  24. h1 {
  25. text-align: center;
  26. padding: 20px 0 12px 0;
  27. margin: 0;
  28. }
  29. h2 {
  30. font-size: 16px;
  31. text-align: center;
  32. padding: 0 0 12px 0;
  33. }
  34.  
  35. #container {
  36. box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
  37. position: relative;
  38. background: white;
  39. }
  40.  
  41. table {
  42. background-color: #F3F3F3;
  43. border-collapse: collapse;
  44. width: 100%;
  45. margin: 15px 0;
  46. }
  47.  
  48. th {
  49. background-color: #FE4902;
  50. color: #FFF;
  51. cursor: pointer;
  52. padding: 5px 10px;
  53. }
  54.  
  55. th small {
  56. font-size: 9px;
  57. }
  58.  
  59. td, th {
  60. text-align: left;
  61. }
  62.  
  63. a {
  64. text-decoration: none;
  65. }
  66.  
  67. td a {
  68. color: #663300;
  69. display: block;
  70. padding: 5px 10px;
  71. }
  72. th a {
  73. padding-left: 0
  74. }
  75.  
  76. td:first-of-type a {
  77. background: url(./.images/file.png) no-repeat 10px 50%;
  78. padding-left: 35px;
  79. }
  80. th:first-of-type {
  81. padding-left: 35px;
  82. }
  83.  
  84. td:not(:first-of-type) a {
  85. background-image: none !important;
  86. }
  87.  
  88. tr:nth-of-type(odd) {
  89. background-color: #E6E6E6;
  90. }
  91.  
  92. tr:hover td {
  93. background-color:#CACACA;
  94. }
  95.  
  96. tr:hover td a {
  97. color: #000;
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104. /* icons for file types (icons by famfamfam) */
  105.  
  106. /* images */
  107. table tr td:first-of-type a[href$=".jpg"],
  108. table tr td:first-of-type a[href$=".png"],
  109. table tr td:first-of-type a[href$=".gif"],
  110. table tr td:first-of-type a[href$=".svg"],
  111. table tr td:first-of-type a[href$=".jpeg"]
  112. {background-image: url(./.images/image.png);}
  113.  
  114. /* zips */
  115. table tr td:first-of-type a[href$=".zip"]
  116. {background-image: url(./.images/zip.png);}
  117.  
  118. /* css */
  119. table tr td:first-of-type a[href$=".css"]
  120. {background-image: url(./.images/css.png);}
  121.  
  122. /* docs */
  123. table tr td:first-of-type a[href$=".doc"],
  124. table tr td:first-of-type a[href$=".docx"],
  125. table tr td:first-of-type a[href$=".ppt"],
  126. table tr td:first-of-type a[href$=".pptx"],
  127. table tr td:first-of-type a[href$=".pps"],
  128. table tr td:first-of-type a[href$=".ppsx"],
  129. table tr td:first-of-type a[href$=".xls"],
  130. table tr td:first-of-type a[href$=".xlsx"]
  131. {background-image: url(./.images/office.png)}
  132.  
  133. /* videos */
  134. table tr td:first-of-type a[href$=".avi"],
  135. table tr td:first-of-type a[href$=".wmv"],
  136. table tr td:first-of-type a[href$=".mp4"],
  137. table tr td:first-of-type a[href$=".mov"],
  138. table tr td:first-of-type a[href$=".m4a"]
  139. {background-image: url(./.images/video.png);}
  140.  
  141. /* audio */
  142. table tr td:first-of-type a[href$=".mp3"],
  143. table tr td:first-of-type a[href$=".ogg"],
  144. table tr td:first-of-type a[href$=".aac"],
  145. table tr td:first-of-type a[href$=".wma"]
  146. {background-image: url(./.images/audio.png);}
  147.  
  148. /* web pages */
  149. table tr td:first-of-type a[href$=".html"],
  150. table tr td:first-of-type a[href$=".htm"],
  151. table tr td:first-of-type a[href$=".xml"]
  152. {background-image: url(./.images/xml.png);}
  153.  
  154. table tr td:first-of-type a[href$=".php"]
  155. {background-image: url(./.images/php.png);}
  156.  
  157. table tr td:first-of-type a[href$=".js"]
  158. {background-image: url(./.images/script.png);}
  159.  
  160. /* directories */
  161. table tr.dir td:first-of-type a
  162. {background-image: url(./.images/folder.png);}
  163.  
  164.  
  165. </style>
  166.  
  167. <body>
  168.  
  169. <div id="container">
  170.  
  171. <h1>Directory Contents</h1>
  172.  
  173. <table class="sortable">
  174. <thead>
  175. <tr>
  176. <th>Filename</th>
  177. <th>Type</th>
  178. <th>Size <small>(bytes)</small></th>
  179. <th>Date Modified</th>
  180. </tr>
  181. </thead>
  182.  
  183. <?php
  184. // Opens directory
  185. session_start();
  186. $myDirectory=opendir('FilesUploading/' . $_SESSION['user_name'] . '/' . $file);
  187.  
  188. // Gets each entry
  189. while($entryName=readdir($myDirectory)) {
  190. $dirArray[]=$entryName;
  191. }
  192.  
  193. // Finds extensions of files
  194. function findexts ($filename) {
  195. $filename=strtolower($filename);
  196. $exts=split("[/\\.]", $filename);
  197. $n=count($exts)-1;
  198. $exts=$exts[$n];
  199. return $exts;
  200. }
  201.  
  202. // Closes directory
  203. closedir($myDirectory);
  204.  
  205. // Counts elements in array
  206. $indexCount=count($dirArray);
  207.  
  208. // Sorts files
  209. sort($dirArray);
  210.  
  211. // Loops through the array of files
  212. for($index=0; $index < $indexCount; $index++) {
  213.  
  214. // Allows ./?hidden to show hidden files
  215. if($_SERVER['QUERY_STRING']=="hidden")
  216. {$hide="";
  217. $ahref="./";
  218. $atext="Hide";}
  219. else
  220. {$hide=".";
  221. $ahref="./?hidden";
  222. $atext="Show";}
  223. if(substr("$dirArray[$index]", 0, 1) != $hide) {
  224.  
  225. // Gets File Names
  226. $name=$dirArray[$index];
  227. $namehref=$dirArray[$index];
  228.  
  229. // Gets Extensions
  230. $extn=findexts($dirArray[$index]);
  231.  
  232. // Gets file size
  233. $size=number_format(filesize('FilesUploading/' . $_SESSION['user_name'] . '/' .$dirArray[$index]));
  234.  
  235. // Gets Date Modified Data
  236. $modtime=date("M j Y g:i A", filemtime('FilesUploading/' . $_SESSION['user_name'] . '/' .$dirArray[$index]));
  237. $timekey=date("YmdHis", filemtime('FilesUploading/' . $_SESSION['user_name'] . '/' .$dirArray[$index]));
  238.  
  239. // Prettifies File Types, add more to suit your needs.
  240. switch ($extn){
  241. case "png": $extn="PNG Image"; break;
  242. case "jpg": $extn="JPEG Image"; break;
  243. case "svg": $extn="SVG Image"; break;
  244. case "gif": $extn="GIF Image"; break;
  245. case "ico": $extn="Windows Icon"; break;
  246.  
  247. case "txt": $extn="Text File"; break;
  248. case "log": $extn="Log File"; break;
  249. case "htm": $extn="HTML File"; break;
  250. case "php": $extn="PHP Script"; break;
  251. case "js": $extn="Javascript"; break;
  252. case "css": $extn="Stylesheet"; break;
  253. case "pdf": $extn="PDF Document"; break;
  254.  
  255. case "zip": $extn="ZIP Archive"; break;
  256. case "bak": $extn="Backup File"; break;
  257.  
  258. default: $extn=strtoupper($extn)." File"; break;
  259. }
  260.  
  261. // Separates directories
  262. if(is_dir($dirArray[$index])) {
  263. $extn="&lt;Directory&gt;";
  264. $size="&lt;Directory&gt;";
  265. $class="dir";
  266. } else {
  267. $class="file";
  268. }
  269.  
  270. // Cleans up . and .. directories
  271. if($name=="."){$name=". (Current Directory)"; $extn="&lt;System Dir&gt;";}
  272. if($name==".."){$name=".. (Parent Directory)"; $extn="&lt;System Dir&gt;";}
  273.  
  274. // Print 'em
  275. print("
  276. <tr class='$class'>
  277. <td><a href='./$namehref'>$name</a></td>
  278. <td><a href='./$namehref'>$extn</a></td>
  279. <td><a href='./$namehref'>$size</a></td>
  280. <td sorttable_customkey='$timekey'><a href='./$namehref'>$modtime</a></td>
  281. </tr>");
  282. }
  283. }
  284. ?>
  285. </tbody>
  286. </table>
  287.  
  288. <form action="Creating_folder.php" method="get">
  289. <input type="text" name=$searchfol id=$searchfol size="20" value="">
  290. <input type="submit" value="Create Folder">
  291. <input type="hidden" name="search" value="1">
  292. </form>
  293.  
  294. <?php
  295. echo "<select name='files'>";
  296. $files = array_map("htmlspecialchars", scandir('FilesUploading/' . $_SESSION['user_name'] . '/'.$dirArray[$index]));
  297. foreach ($files as $fileqw)
  298. echo "<option value='$option'>$fileqw</option>";
  299. echo "</select>";
  300. ?>
  301.  
  302.  
  303. <form action="Delete.php">
  304. <input type="submit" value="Delete File">
  305. </form>
  306. <form action="Delete_folder.php">
  307. <input type="submit" value="Delete Folder">
  308. </form>
  309. <form action="Download.php">
  310. <input type="submit" value="Download File/Folder">
  311. </form>
  312.  
  313. <form action="Rename.php" method="get">
  314. <input type="text" name=$searchfol id=$searchfol size="20" value="">
  315. <input type="submit" value="Rename">
  316. <input type="hidden" name="search" value="1">
  317. </form>
  318.  
  319.  
  320. </div>
  321. </body>
  322. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement