1. <?php
  2. // table of contents over all dirs in the dir (with hyperlink)
  3. // (c) maximilianus7
  4. // please adapt...
  5. $ignore_list = 'docs~dokumente~ablage~sources~old~backup~install~adds~phpmyadmin'; //use ~ as delimiter!
  6. $title_prefix = '--> ';
  7. $title_pattern = '.title=';
  8. $lang = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
  9. $host = $_SERVER[HTTP_HOST];
  10. echo "<html> <body> <h3>Shared Tables on $host</h3>";
  11. echo '<table>';
  12. show_list ('', "../projects/", 'R'); // title, dir, R=recursive
  13. show_list ('some text files', "./misc/", 'F'); // F=file
  14. // show_list ('old SToW clients', "../home/", 'D'); // D=directory (non-recursive)
  15. echo @file_get_contents('additional_links.html');
  16. echo '</table>';
  17. ////////////////////////////////////////////////////////////////////////////////////////
  18. function show_list ($title, $dir, $type, $level=1)
  19. {
  20. global $ignore_list;
  21. if ( $title > '' ): echo "<tr><td style='font-size:larger;font-weight:bold'><br>$title</td></tr>"; endif;
  22. $list = scandir ($dir);
  23. natcasesort ($list);
  24. //DD// echo "$level---$file <br>";
  25. foreach ( $list as $file ):
  26. if ( $file [0] == "." ) continue; // ignore ., .. and all starting with .
  27. switch ( $type ):
  28. case 'R': // recursive
  29. case 'D': // directory
  30. if ( is_file ("$dir$file") ): continue 2; endif;
  31. //$_i = stripos ("~$ignore_list~", "~$file~" ); var_dump($_i,$ignore_list,$file);
  32. if ( stripos ("~~$ignore_list~", "~$file~" ) > 0): continue 2; endif;
  33. if ( stripos ($file, '.' ) > 0): continue 2; endif;
  34. $descr = find_title ("$dir$file");
  35. break;
  36. case 'F': // file
  37. if ( is_dir ("$dir$file") ) continue 2;
  38. if ( substr (strrev ($file), 0, 4) == 'php.') continue 2; //continue 1 works as break inside the switch
  39. break;
  40. endswitch;
  41. $indent = str_repeat ('&nbsp;', ($level - 1) * 3);
  42. echo "<tr><td>$indent<a href=\"$dir$file\">$file</a></td><td>$descr</td></tr>";
  43. $descr = '';
  44. if ( $type == 'R' ): show_list ('', "$dir$file/", 'R', $level + 1); endif;
  45. endforeach;
  46. }
  47. ////////////////////////////////////////////////////////////////////////////////////////
  48. function find_title ($dir)
  49. {
  50. global $title_prefix, $title_pattern;
  51. $files = scandir ($dir);
  52. foreach ($files as $f):
  53. if ( substr ($f, 0, strlen ($title_pattern)) == $title_pattern ):
  54. return title_prefix . substr ($f, strlen ($title_pattern));
  55. endif;
  56. endforeach;
  57. return "";
  58. }
  59. ?>
  60. </body>
  61. </html>