Hello I think this is an easy one
I have written a script which gets the current path, does some evil things to it and comes up with a nice YOU ARE HERE! bar.
The only problem is if I make a function and include it in say drawnav.php, it prints out the path to the file with the actual function in it, as opposed to the function call file.
My question is simple... (i hope!) how do i make it throw the file name of drawnav.php instead of nav.php
Here is the source of nav.php
PHP Code:
<?php
/* Noisyscanner's "You are here" script */
function drawnav()
{
$path = dirname(__FILE__); //Get the path of the current script
$file = basename(__FILE__); //Get the current file name
$dir = basename(dirname(__FILE__)); //Get the directory of the current script
echo '<link href="http://universalgames.biz/nav/navstyles.css" rel="stylesheet" type="text/css">';
$path = explode("/home/brad291/public_html/", $path); // Get rid of the stuff at the beginning, we only want the path after that
$DirArray = explode("/", $path[1]);
$path[1] = "http://universalgames.biz/$path[1]"; // Change the value of the $path[1] variable in the array $path to "Mysite.com/the/path"
$expfile = explode(".", $file); // Get rid of the file extension
$expfile[0] = ucwords($expfile[0]);
if($expfile[0] == "Index"){ //If the exploded file name (without php html shtml and so forth) is index, set the $dispfile variable to false
$dispfile = false;
}else{$dispfile = true;}
echo '<div class="nav">'; // Start the div with the navigation style
echo "You are here: <a href=\"http://universalgames.biz\">Home</a> > "; // Print "You are here" and a link to the homepage.
foreach($DirArray as $key => $value)// For each $DirArray element, $key is the key and $value is the value
{
$ucvalue = ucwords($value); // Upper-case the first letter of the word to make it look nice..
$predir .= "/$value"; // Add the current directory being echoed on to the one before...
echo "<a href=\"http://universalgames.biz$predir\">$ucvalue</a> > "; // Echo the links!
}
if($file == "play.php")
{
$id=$_GET[id];
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$select_game = mysql_query("SELECT * FROM games WHERE id='$id'");
while($row = mysql_fetch_array( $select_game )) {
if($dispfile == true)
{
echo "<a href=\"$path[1]/$file?id=$_GET[id]\">Playing game: $row[game]</a> "; // Echo the file name without the extension. But not if the file is index.
}
}
}else{
if($dispfile == true)
{
echo "<a href=\"$path[1]/$file\">$expfile[0]</a> "; // Echo the file name without the extension. But not if the file is index.
}
}
echo "</div>";
}
?>
and here is the source of drawnav.php
PHP Code:
<?php
include 'nav/nav2/nav3/nav.php';
drawnav();
?>