PHP Lindsay Help


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $dir = opendir($current_dir);
  3. $files = array();
  4. $folders = array();
  5. $sortF = array();
  6.  
  7.  
  8.  
  9. while (false !== ($filename = readdir($dir))) {
  10.  
  11. if (!is_dir($current_dir . "/" . $filename)) {
  12. $files[] = $filename;
  13. }
  14. else if (is_dir($current_dir . "/" . $filename)) {
  15. $folders[] = $filename;
  16. }
  17. }
  18.  
  19. sort ($files);
  20. sort($folders);
  21.  
  22. foreach ($files as $file) {
  23.  
  24. $filetype = strtolower(substr($file, -3, 3));
  25.  
  26. if ($file != '.' && $file != '..' && $file != '' && $file !='Thumbs.db' && $file != '.DS_Store' && $filetype != 'pdf' && $filetype != 'zip') {
  27. $sortF['file'][] = $file;
  28. }
  29. else if ( $filetype == 'pdf') {
  30. $sortF['pdf'][] = $file;
  31. }
  32. else if ( $filetype == 'zip') {
  33. $sortF['zip'][] = $file;
  34. }
  35.  
  36.  
  37. }
  38.  
  39. foreach($sortF['file'] as $file) {
  40. ?>
  41. <li><a href="<?php echo './refreshmockupview.php?directory=' . $section . '&' . 'cat=' . $page_title . '&mockup=' . urlencode($file); ?>"><?php echo str_replace($strip_out, ' ', substr($file, 0, strrpos($file, '.'))); ?></a></li>
  42. <?php
  43. }
  44.  
  45. foreach($sortF['pdf'] as $file) {
  46. ?>
  47. <li style="background:url(img/ui/new_pdf_icon.gif) top left no-repeat;"><a href="<?php echo $current_dir . "/" . $file; ?>"><?php echo str_replace($strip_out, ' ', substr($file, 0, strrpos($file, '.'))); ?></a></li>
  48. <?php
  49. }
  50.  
  51. foreach($sortF['zip'] as $file) {
  52. ?>
  53. <li style="background:url(img/ui/new_zip_icon.gif) top left no-repeat;"><a href="<?php echo $current_dir . "/" . $file; ?>"><?php echo str_replace($strip_out, ' ', substr($file, 0, strrpos($file, '.'))); ?></a></li>
  54. <?php
  55. }
  56.  
  57.  
  58. foreach ($folders as $folder) {
  59. if ($folder != '.' && $folder != '..' && $folder != '') {
  60. ?><li style="background:url(img/ui/new_folder_icon.gif) top left no-repeat;"><a href="<?php echo './refreshsection.php?cat=' . strtoupper($folder) . '&directory=' . urlencode($section . '/' . $folder); ?>"><?php echo str_replace($strip_out, ' ', $folder); ?></a></li>
  61. <?php
  62. }
  63. }
  64.  
  65.  
  66. closedir($dir);
  67. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.