- <?php
- // table of contents over all dirs in the dir (with hyperlink)
- // (c) maximilianus7
- // please adapt...
- $ignore_list = 'docs~dokumente~ablage~sources~old~backup~install~adds~phpmyadmin'; //use ~ as delimiter!
- $title_prefix = '--> ';
- $title_pattern = '.title=';
- $lang = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
- $host = $_SERVER[HTTP_HOST];
- echo "<html> <body> <h3>Shared Tables on $host</h3>";
- echo '<table>';
- show_list ('', "../projects/", 'R'); // title, dir, R=recursive
- show_list ('some text files', "./misc/", 'F'); // F=file
- // show_list ('old SToW clients', "../home/", 'D'); // D=directory (non-recursive)
- echo @file_get_contents('additional_links.html');
- echo '</table>';
- ////////////////////////////////////////////////////////////////////////////////////////
- function show_list ($title, $dir, $type, $level=1)
- {
- global $ignore_list;
- if ( $title > '' ): echo "<tr><td style='font-size:larger;font-weight:bold'><br>$title</td></tr>"; endif;
- $list = scandir ($dir);
- natcasesort ($list);
- //DD// echo "$level---$file <br>";
- foreach ( $list as $file ):
- if ( $file [0] == "." ) continue; // ignore ., .. and all starting with .
- switch ( $type ):
- case 'R': // recursive
- case 'D': // directory
- if ( is_file ("$dir$file") ): continue 2; endif;
- //$_i = stripos ("~$ignore_list~", "~$file~" ); var_dump($_i,$ignore_list,$file);
- if ( stripos ("~~$ignore_list~", "~$file~" ) > 0): continue 2; endif;
- if ( stripos ($file, '.' ) > 0): continue 2; endif;
- $descr = find_title ("$dir$file");
- break;
- case 'F': // file
- if ( is_dir ("$dir$file") ) continue 2;
- if ( substr (strrev ($file), 0, 4) == 'php.') continue 2; //continue 1 works as break inside the switch
- break;
- endswitch;
- $indent = str_repeat (' ', ($level - 1) * 3);
- echo "<tr><td>$indent<a href=\"$dir$file\">$file</a></td><td>$descr</td></tr>";
- $descr = '';
- if ( $type == 'R' ): show_list ('', "$dir$file/", 'R', $level + 1); endif;
- endforeach;
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- function find_title ($dir)
- {
- global $title_prefix, $title_pattern;
- $files = scandir ($dir);
- foreach ($files as $f):
- if ( substr ($f, 0, strlen ($title_pattern)) == $title_pattern ):
- return title_prefix . substr ($f, strlen ($title_pattern));
- endif;
- endforeach;
- return "";
- }
- ?>
- </body>
- </html>