PageRenderTime 25ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/pdw_file_browser/view_details.php

https://github.com/dingwen/ZenHouse-Media-Template
PHP | 136 lines | 100 code | 11 blank | 25 comment | 18 complexity | 47e0e7126f8eda53cda2142885b632f4 MD5 | raw file
  1. <?php
  2. /*
  3. PDW File Browser v1.0 beta
  4. Date: May 9, 2010
  5. Url: http://www.neele.name
  6. Copyright (c) 2010 Guido Neele
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. */
  23. require_once('functions.php');
  24. if(isset($_REQUEST["ajax"])){
  25. $selectedpath = urldecode($_REQUEST["path"]);
  26. if($selectedpath = checkpath($selectedpath, $uploadpath)){
  27. $dirs = getDirTree(DOCUMENTROOT.$selectedpath, true, false);
  28. } else {
  29. die('0||'.$lang["loadfolder_error_1"]);
  30. }
  31. } else {
  32. $selectedpath = $uploadpath;
  33. }
  34. print '<table id="details" class="files">
  35. <thead>
  36. <tr>
  37. <th colspan="3" class="filename">'.$lang["Filename"].'</th>
  38. <th>'.$lang["Modified on"].'</th>
  39. <th>'.$lang["Filetype"].'</th>
  40. <th>'.$lang["Size"].'</th>
  41. <th>'.$lang["Dimensions"].'</th>
  42. <th class="end">&nbsp;</th>
  43. </tr>
  44. </thead>
  45. <tbody>';
  46. foreach($dirs as $key => $value){
  47. if($value != "folder"){
  48. if(strtolower($value) == "png" || strtolower($value) == "jpg" || strtolower($value) == "jpeg" || strtolower($value) == "gif" || strtolower($value) == "bmp"){
  49. $filename = DOCUMENTROOT.$selectedpath.$key;
  50. $image_info = getimagesize($filename);
  51. $file_modified = date($datetimeFormat, filemtime($filename));
  52. $file_size = filesize($filename);
  53. $file_size = $file_size < 1024 ? $file_size. ' bytes' : $file_size < 1048576 ? number_format($file_size / 1024, 2, $dec_seperator, $thousands_separator) . ' kB' : number_format($file_size / 1048576, 2, $dec_seperator, $thousands_separator) . ' MB';
  54. $htmlFiles .= sprintf('<tr href="%1$s" class="image">
  55. <td class="begin"></td>
  56. <td class="icon"><span class="%8$s"></span></td>
  57. <td class="filename">%2$s</td>
  58. <td class="filemodified">%7$s</td>
  59. <td class="filetype">%3$s</td>
  60. <td class="filesize">%4$s</td>
  61. <td class="filedim">%5$s x %6$s</td>
  62. <td class="end">&nbsp;</td>
  63. </tr>',
  64. $selectedpath.$key,
  65. $key,
  66. $image_info['mime'],
  67. $file_size,
  68. $image_info[0],
  69. $image_info[1],
  70. $file_modified,
  71. strtolower($value)
  72. );
  73. } else {
  74. $filename = DOCUMENTROOT.$selectedpath.$key;
  75. $file_modified = date($datetimeFormat, filemtime($filename));
  76. $file_size = filesize($filename);
  77. $file_type = mime_content_type($filename);
  78. $file_size = $file_size < 1024 ? $file_size. ' bytes' : $file_size < 1048576 ? number_format($file_size / 1024, 2, $dec_seperator, $thousands_separator) . ' kB' : number_format($file_size / 1048576, 2, $dec_seperator, $thousands_separator) . ' MB';
  79. $htmlFiles .= sprintf('<tr href="%1$s" class="file">
  80. <td class="begin"></td>
  81. <td class="icon"><span class="%6$s"></span></td>
  82. <td class="filename">%2$s</td>
  83. <td class="filemodified">%5$s</td>
  84. <td class="filetype">%3$s</td>
  85. <td class="filesize">%4$s</td>
  86. <td class="filedim">&nbsp;</td>
  87. <td class="end">&nbsp;</td>
  88. </tr>',
  89. $selectedpath.$key,
  90. $key,
  91. $file_type,
  92. $file_size,
  93. $file_modified,
  94. $value
  95. );
  96. }
  97. } else {
  98. $foldername = DOCUMENTROOT.$selectedpath.$key;
  99. $folder_modified = date($datetimeFormat, filemtime($foldername));
  100. $htmlFolders .= sprintf('<tr href="%1$s" class="folder">
  101. <td class="begin"></td>
  102. <td class="icon"><span class="folder"></span></td>
  103. <td class="filename">%2$s</td>
  104. <td class="filemodified">%4$s</td>
  105. <td class="filetype">%3$s</td>
  106. <td class="filesize">&nbsp;</td>
  107. <td class="filedim">&nbsp;</td>
  108. <td class="end">&nbsp;</td>
  109. </tr>',
  110. $selectedpath.$key."/",
  111. $key,
  112. $lang["Directory"],
  113. $folder_modified
  114. );
  115. }
  116. }
  117. print $htmlFolders;
  118. print $htmlFiles;
  119. print '</tbody>
  120. </table>';
  121. ?>