View previous topic :: View next topic |
Author |
Message |
buddha -
Joined: 19 Aug 2003 Posts: 4 Location: Sweden
|
Posted: Mon Dec 29, 2003 2:35 pm Post subject: Help need with powerful script ! I share the script. |
|
|
Hallo over there!
I am using a php script allows the easy navigation especially for larger websites. For each directory a customizable menue is created from the TITLE tag and sorted following own rules. Files and directories may be included or excluded following own definitions.
This works just fine on my live server ( Apache ) and now i would like to make it work on my local server ( Abyss )
I get this error :
Notice: Undefined variable: SCRIPT_FILENAME in http://127.0.0.1/sitsonline/en/scripts/menu.inc on line 39
Fatal error: Call to a member function on a non-object in http://127.0.0.1/sitsonline/en/scripts/menu.inc on line 44
This is the script: ( Any one is free to use it, help your self, )
(note: to use this script the first file in a directory needs to be index.php)
<?php
function zeigen ($type) {
function echo_link($art, $link, $text, $type) {
$col = "#303030"; // Color of a standard entry
// $logo = "•";
$logo = "<img SRC=/lab1/images/icons/standardentry.gif border=0>"; // Pictur of standard entry
if ($art=="0") {$col = "#FF0000";$logo = "<img SRC=/lab1/images/home2.gif border=0>";} // Home
if ($art=="1") {$col = "#0000e0";$logo = "<img SRC=/lab1/images/up.gif border=0>";} // Up
if ($art=="2") {$col = "#0000e0";$logo = "<img SRC=/lab1/images/icons/dok2_index.gif border=0>";} // Index-File directory
if ($art=="3") {$col = "#303030";$logo = "<img SRC=/lab1/images/icons/nav_kat.gif border=0>";} // Sub-Folders
if ($art=="4") {$col = "FF9A00";$logo = "<img SRC=/lab1/images/icons/nav_sub_orange.gif border=0>";} // Currently selected File
// Die Druckspalte vertikal - printed entry for a vertical column
If ($type = "2")
echo "<tr><td align=right><a href=\"$link\">$logo</td><td><font size=\"1\"><a href=\"$link\" style=\"text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; color: $col;\" >$text</a></font></td></tr>\r";
// Horizontal
else
echo "<font size=\"-2\"><a href=\"$link\" style=\"text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; color: $col;\" > $logo $text</a></font>\r";
}
// -------------------- Main programm starts here ---------------------------
// *** Define horizontal or vertical layout ***
// Okay, let's open the TABLE and define size, background color etc
If ($type = "2")
echo "<table bgcolor=\"\" width = \"\" border =\" 0\"><tr><td>";
else
echo "<table bgcolor=\"#FEF5E2\" width = \"100%\"><tr><td>";
// Now, the "home" and "up" link
// IMPORTANT to change HOMEDIR here
// echo_link("0", "http://127.0.0.1", "Home",$type); // -your own HOMEPAGE here
// echo_link("1", "../", "Back",$type); // Upwards Link
/* If you're including this script from a function, you'll need
to make $SCRIPT_FILENAME a global variable. */
if (!$SCRIPT_FILENAME)
global $SCRIPT_FILENAME;
// We'll have to loop through all the files in the current directory
$d = dir(dirname($SCRIPT_FILENAME));
while($file=$d->read()){
// ************* FILTER files and directories **************
$wahl = "N"; // not selected a standard
if (is_dir($file)) {$wahl = "J";} // Select if Directory
if (eregi("php", $file)){$wahl = "J"; } // Select if php - take HTM HTML or whatever you need
$rest = substr ($file, 0, 1);
if ($rest == "_") {$wahl = "N";} // deselect if starts with "_" or "."
if ($rest == ".") {$wahl = "N";}
if ($wahl =="J") {
// ------------- Takes Subdirectories here ----------------
if (is_dir($file))
{
$xbuild = "3"."|".$file."|".$file."|3"; // Build print line for DIRECTORY files: Sorting = 3, Type is also 3
$xline[] = $xbuild;
}
else {
// -------------------- normale file -----------------
$fp = fopen("$file", "r"); // Not a directory file -> normal file
$build = "";
$line = "";
$flag = 0;
$i = 0;
while (($i < 20)and (!feof ($fp)) ) {
$i = $i +1;
$line = fgets($fp, 1024);
$lineup = strtoupper($line); // search in uppercase string
/* The <TITLE> tag MUST be opened at the beginning of a new line */
if (ereg("^<TITLE>", $lineup))
{$flag = 1;
$build = substr($line,1,100); // Maximal 100 chars
}
if ($flag == 1)
{$build = $build.$line;
}
if (ereg("</TITLE>", $lineup))
{$flag = 0;
}
$flag = 0;
}
$lineup = strtoupper($build);
if ($build > ""):
$start = strpos($lineup,"TITLE");
$end = strpos($lineup,"</TITLE>");
$laenge = $end - $start - 6;
$build = substr($build,$start + 6,$laenge);
$xsort ="5"; // File sorting is standard
$xtype ="5"; // File type is standard
// Currently Selected File is treated differently
if ($file == basename($SCRIPT_FILENAME)){$xtype = "4";}
// Index-File File is treated differently
$pos = strpos ("1".strtoupper($file), "INDEX.");
if ($pos == 1){$xsort = "2";$xtype = "2";}
$buildline = $xsort."|".$build."|".$file."|".$xtype; // build line
// echo $buildline;
$xline[] = $buildline;
endif;
}
}
}
// and finally, close the directory
$d->close();
// ------------------ now sort the whole thing following code + Title
sort ($xline);
reset ($xline);
while (list ($key, $val) = each ($xline)) {
$pieces = explode ("|", $val); // restore original values for type, filename and title
echo_link($pieces[3], $pieces[2], $pieces[1],$type);
}
// To finish off the bar - you may add links for example
// echo_link("5", "http://127.0.0.1","Links",$type);
// Close Table
echo "</td></TR></table>";
};
?>
Does anyone have a solution, please help me!
Best regards / Buddha. |
|
Back to top |
|
 |
whackaxe -
Joined: 28 Jun 2003 Posts: 90
|
Posted: Mon Dec 29, 2003 9:44 pm Post subject: |
|
|
replace $SCRIPT_FILENAME by $_SERVER['SCRIPT_FILENAME'] |
|
Back to top |
|
 |
buddha -
Joined: 19 Aug 2003 Posts: 4 Location: Sweden
|
Posted: Tue Dec 30, 2003 10:13 am Post subject: Can u give me an example, please |
|
|
Regads / B |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Tue Dec 30, 2003 1:39 pm Post subject: Re: Can u give me an example, please |
|
|
buddha,
Search also for "Undefined Variable" in this forum to know how to make your original script work with new releases of PHP. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|