Mi serviva una soluzione veloce per il "breadcrumb" di un sito che sto pubblicando ed ho trovato questa soluzione che ho già collaudato in un altro sito e funziona benissimo e lo recupero nella pagina così:
<?php include($_SERVER['DOCUMENT_ROOT']."/backlinks.php"); ?>....su Aruba non funziona.
Aruba non ti da accesso alla directory principale ma ad una con dentro la cartella con www.miosito.it
E lo script non funziona....c'è un modo in cui potrei adattare la funzione per renderla utilizzabile?
<?php
$convert_toSpace = true; // true if script should convert _ in folder names to spaces
$upperCaseWords = false; // true if script should convert lowercase to initial caps
$topLevelName = "home"; // name of home/root directory
$separator = " > "; // characters(s) to separate links in hierarchy (default is a > with 2 spaces on either side)
// find index page in directory...
function MPBCDirIndex($dir) {
$index = '';
@$dir_handle = opendir($dir);
if ($dir_handle) {
while ($file = readdir($dir_handle)) {
$test = substr(strtolower($file), 0, 6);
if ($test == 'index.') {
$index = $file;
break;
}
}
}
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) {
global $convert_toSpace;
global $upperCaseWords;
if ($convert_toSpace) $string = str_replace('_', ' ', $string);
if ($upperCaseWords) $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($dirArray, 0, count($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 != '') ? ''.$thisText.'' : $thisText;
if ($thisLink != '') $linkArray[] = $thisLink;
}
$results = (count($linkArray) > 0) ? implode($separator, $linkArray) : '';
if ($results != '') print('<div class="backlinks">'.$results.'</div>');
?>