<? ##################################################
## ##
## path.php v1.3 ##
## Version for eTemplate for PHP ##
## Copyright 2000 ##
## ##
## Jim Fletcher jim@websitecode.com ##
## ##
## Free to distribute as long as this notice ##
## remains. You cannot charge for this work or ##
## any derivatives thereof. No warranties on ##
## this program are made or implied. ##
## ##
##################################################
## Revisions:
## 1.3 $ignore converted to array. Multiple ignores allowed.
## 1.2 $urlbase autodetects. Ignore page change to "Home"
## for compatibility with eTemplate for PHP script.
## 1.1 Doesn't print link to index page
#
## You may make any modifications to this script##
## to best fit your needs, but if you find some-##
## thing wrong, let me know at ##
## jim@websitecode.com ##
##################################################
#
# To run this script you will need PHP enabled on
# your server, and the PHP call:
# include("/path-to-this-script/path.php");
# inserted within the PHP pages you want it to run on.
#
# NOTE: the "/path-to-this-script/" listed above
# means change it to the location on YOUR
# webserver or delete it if the path.php is in the
# same directory as the calling page.
#
####################################
# USER VARIABLES #
####################################
#What is the path that is going to be parsed? You may pass comment this out and pass the $originalpath as a variable from the calling page, but in testing the $PHP_SELF variable came from the original calling page, not the path.php page.
$originalpath = $PHP_SELF;
#What is the Base URL? (usually the domain name) $urlbase = "http://".$HTTP_HOST; #$urlbase = "http://www.itprofessional.org"; # Uncomment if the above line isn't working for you.
# What Link Text Do You Want To Appear for the link to the base URL? $roottitle = "Home";
# In Your Output, What Symbol and Spacing Do You Want Between the Links? examples are | / :
$seperator = " > ";
# What file do you want to not print a link to? (drop the .php suffix & capitalize the filename)
$ignore = array("Index","Home");
#######################################
# Do not modify beneath this point unless you know what you're doing!
function check_ignore($ignore,$referer){
if (count($ignore)){
global $errors;
$found = true;
#$referer = $path[$number];
for ($x=0; $x < count($ignore); $x++){
if ($ignore[$x] == $referer){
$found = false;
}
}
return $found;
} else {
return true; //Not a good idea, if empty, it will allow it.
}
}
#Splits the path into an array using a forward slash $path = explode ("/", $originalpath); #Counts How many elements are in the array so the loop below knows how long to loop
$totalelements = count ($path); # Print out the Link to the Homepage printf("<a href="%s">%s</a>", $urlbase, $roottitle); # Loops thru the array printing out the link to the respective directory or file
for($number=1; $number<$totalelements ; $number++) {
#Appends the next directory or file down to the URL
$urlbase = $urlbase . "/" . $path[$number];
# Do Some Formatting on the Link Text
#Replace Triple Underscore with Ampersand Surrounded By Underscores to be later converted to spaces
$path[$number] = str_replace("___", "_&_", $path[$number]);
#Replace Underscore with Space
$path[$number] = str_replace("_", " ", $path[$number]);
#Replace Tilde with Question Mark
$path[$number] = str_replace("~", "?", $path[$number]);
#Erase .php file extension
$path[$number] = str_replace(".php", "", $path[$number]);
#Capitalize All Words
$path[$number] = ucwords($path[$number]);
# Print Out The URL With The Formatted Link Text
if(check_ignore($ignore,$path[$number])){
printf("%s<a href="%s">%s</a>", $seperator, $urlbase, $path[$number]);
}
} ?>
|
|