<?php

$topLevelName 
"Simpli Hosting";        // name of home/root directory
$separator " &raquo; ";        // characters(s) to separate links in hierarchy (default is a > with a space on either side)

// is this entry in the array the page we are on?
function MPBCDirIndex($dir) {
    if (
$_SERVER['SCRIPT_FILENAME'] == $dir "index.php") {
        
$index '';
    }
    else {
        
$index "index.php";
    }
    return 
$index;
}

// make clean array (trim entries and remove blanks)...
function MPBCTrimArray($array) {
    
$clean = array();
    for (
$n=0$n<count($array); $n++) {
        
$entry trim($array[$n]);
        if (
$entry != ''$clean[] = $entry;
        }
    return 
$clean;
    }

// function to prep string folder names if needed...
function MPBCFixNames($string) {
    
$string str_replace('_'' '$string);
    
$string ucwords($string);
    return 
$string;
}

$server = (isset($_SERVER)) ? $_SERVER $HTTP_SERVER_VARS;

$htmlRoot = (isset($server['DOCUMENT_ROOT'])) ? $server['DOCUMENT_ROOT'] : '';
if (
$htmlRoot == ''$htmlRoot = (isset($server['SITE_HTMLROOT'])) ? $server['SITE_HTMLROOT'] : '';

$pagePath = (isset($server['SCRIPT_FILENAME'])) ? $server['SCRIPT_FILENAME'] : '';
if (
$pagePath == ''$pagePath = (isset($server['SCRIPT_FILENAME'])) ? $server['SCRIPT_FILENAME'] : '';

$httpPath = ($htmlRoot != '/') ? str_replace($htmlRoot''$pagePath) : $pathPath;

$dirArray explode('/'$httpPath);
if (!
is_dir($htmlRoot.$httpPath)) $dirArray array_slice($dirArray0count($dirArray) - 1);

$linkArray = array();
$thisDir '';
$baseDir = ($htmlRoot == '') ? '' $htmlRoot;
for (
$n=0$n<count($dirArray); $n++) {
    
$thisDir .= $dirArray[$n].'/';
    
$thisIndex MPBCDirIndex($htmlRoot.$thisDir);
    
$thisText = ($n == 0) ? $topLevelName MPBCFixNames($dirArray[$n]);
    
$thisLink = ($thisIndex != '') ? '<a href="'.$thisDir.$thisIndex.'">'.$thisText.'</a>' $thisText;
    if (
$thisLink != ''$linkArray[] = $thisLink;
}

if (
strpos($server['SCRIPT_NAME'], "index") === FALSE)  {
    
$linkArray[] = MPBCFixNames(basename($server['SCRIPT_NAME'], ".php"));
}

$results = (count($linkArray) > 0) ? implode($separator$linkArray) : '';
if (
$results != '') print($results);

?>