Hallo, ich habe auf einer Homepage diese Funktion. Sie sorgt dafür, dass der Autor und das Datum eines Artikels angezeigt werden. Nebenbei wird dann auch eine Breadcrump Navigation erstellt, die auf der Ordnerstruktur der Website basiert. Mein Problem ist, das das Script so nur stumpf davon ausgeht, dass sich in jedem Ordner eine index.php befindet und einen Link dazu ausgibt. Da aber nicht immer eine index.php vorhanden ist, kommt häufig nur ein 404 Error. Wie könnte ich das Script ändern, damit auch auf die vorhandene index.php geprüft wird?
PHP-Code:
function headline($autor,$datum) {
$pos = strpos($datum, "-");
if ($pos !== false) {
list ($jahr, $monat, $tag) = split('[/.-]', $datum);
$datum = $tag.".".$monat.".".$jahr;
}
$host= $_SERVER['HTTP_HOST'];
$path = $_SERVER['PHP_SELF'];
$path = ereg_replace("^/([a-zA-Z0-9 _.]+)","\\1",$path);
$path = explode("/",$path);
$pathcounter = 0;
while (isset($path[$pathcounter])) {
$pathname = $path[$pathcounter];
$pathname = ucfirst($pathname);
$pathname = ereg_replace(".php$","",$pathname);
$pathname = ereg_replace("Index","",$pathname);
$pathname = ereg_replace("_"," ",$pathname);
$pathname = umlaute_umsetzten($pathname);
$pathfilecounter = 0;
$pathfile = "";
while($pathfilecounter <= $pathcounter) {
if (ereg("^([a-z0-9_]+)$",$path[$pathfilecounter])) {
$pathfile .= $path[$pathfilecounter] . "/";
} else { $pathfile = "NOLINK"; }
$pathfilecounter ++;
}
if ($pathfile != "" AND $pathfile != "NOLINK") { $pathfile .= "index.php"; } else {}
if ($pathname) {
if ($pathfile == "NOLINK") { $pathecho .= "<li>$pathname</li>";
else {
$pathecho .= "<li><a href=\"http://$host/" . $pathfile . "\">$pathname</a></li>";
}
}
$pathcounter++;
}
if (preg_match("/^[0-9]{1,}$/",$autor)) {
$autor = name($autor);
}
echo "<div id=\"crumbs\"><ul><li><a href=\"http://" . $_SERVER['HTTP_HOST'] . "/index.php\">website.com</a></li>$pathecho";
echo "</ul>";
if ($autor && $datum)
{
echo "<span class=\"right\">$autor | $datum</span>";
} else if (!$autor && $datum)
{
echo "<span class=\"right\">$datum</span>";
}
echo "</div>";
}