1<?php 2// Builds the dynamic links based on the namespaces. 3function dyn_links($ns) { 4 $check = "./data/pages/".$ns; 5 if (is_dir($check)) { 6 $root = $ns; 7 $ns = "/".$ns; 8 } else { 9 $ns = ""; 10 }; 11 $first = "="; 12 $dir = "./data/pages$ns"; 13 $titleref = ""; 14 $titlearr = array(); 15 $ac = 1; 16 if ($handle = opendir($dir)) { 17 while (false !== ($lfile = readdir($handle))) { 18 Switch ($lfile) { 19 case ".": 20 break; 21 case "..": 22 break; 23 case "start.txt": 24 break; 25 case "sidebar.txt": 26 break; 27 default: 28 if (is_dir($dir."/".$lfile)) { 29 break; 30 } else { 31 $ext = strpos($lfile, "."); 32 $fh = fopen($dir."/".$lfile, 'r'); 33 $fr = fread($fh, filesize($dir."/".$lfile)); 34 $begstr = strpos($fr, $first, 0); 35 $begstr = $begstr + 6; 36 $count = strpos($fr, $first, $begstr); 37 $count = $count - $begstr; 38 $title = substr($fr, $begstr, $count); 39 $titleref[$ac] = substr($lfile, 0, $ext); 40 $titlearr[$ac] = $title; 41 $ac++; 42 } 43 } 44 } 45 closedir($handle); 46 if ($ns == "") { 47 echo "<a class='nav' href='doku.php?id=start'>Home</a>"; 48 } else { 49 echo "<a class='nav' href='doku.php?id=start'>Home</a>"; 50 $ssns = stripslashes($root); 51 $uns = strtoupper($ssns); 52 echo "<a class='nav' href='doku.php?id=$ssns'>$uns</a>"; 53 }; 54 for($lc = 1; $lc < $ac; $lc++) { 55 if (isset($root)) { 56 echo "<a class='nav' href='doku.php?id=$root:$titleref[$lc]'>$titlearr[$lc]</a>"; 57 } else { 58 echo "<a class='nav' href='doku.php?id=$titleref[$lc]'>$titlearr[$lc]</a>"; 59 }; 60 } 61 } 62} 63 64?>