Page 1 of 1

Notice: Undefined variable: sdirs in ...

Posted: Wed Oct 24, 2007 8:30 am
by Tomino23
hi there. i have some troubles with this script. I downloaded it like a free script for creating site-map on website... but it still noticed me with this:
Notice: Undefined variable: sdirs in ezmap.php on line 187

this is the script:

Code: Select all

<?php

// W3C Markup Validation Service - http://validator.w3.org/
// Choose which format you want EzMap to validate in.
// Valid HTML 4.01 Transitional or Valid XHTML 1.0 Transitional
// validation format, 0 for XHTML, 1 for HTML - Choose one or the other!
$ezmapvalidate = 1;

// Set this to NO ( 0 ) to NOT display the W3C Valid Button
// Show valid format button at bottom of page, 1 for YES, 0 for NO

$ezmap_valid_image = 0;

// User configuration
// Show size of each file, 1 for YES, 0 for NO

$showsize = 0;

// Array with file types to display and the images to use.
// Use the below to set which files you want searched and displayed.
// Uncomment for each you wish to show.
// Syntax: $display['filetype'] = "image";

$display['html'] = "img/html.gif";
$display['htm'] = "img/html.gif";
$display['shtml'] = "img/html.gif";
$display['php'] = "img/php.gif";
$display['pdf'] = "img/pdf.gif";
$display['gif'] = "img/gif.gif";
$display['jpg'] = "img/jpg.gif";
$display['png'] = "img/png.gif";
//$display['bmp'] = "img/bmp.gif";
//$display['tif'] = "img/tif.gif";
//$display['ico'] = "img/ico.gif";
$display['txt'] = "img/txt.gif";
$display['doc'] = "img/doc.gif";
$display['fla'] = "img/fla.gif";
$display['swf'] = "img/swf.gif";
//$display['zip'] = "img/zip.gif";
//$display['rar'] = "img/rar.gif";
//$display['avi'] = "img/avi.gif";
//$display['mpg'] = "img/mpg.gif";
//$display['mpeg'] = "img/mpg.gif";
//$display['mov'] = "img/mov.gif";
//$display['wmv'] = "img/wmv.gif";
//$display['midi'] = "img/midi.gif";
//$display['mp3'] = "img/mp3.gif";
//$display['wav'] = "img/wav.gif";
//$display['wps'] = "img/default.gif";

// Array with directories to exclude.
// This used to exclude or NOT listed a directory.
// ADD the directories you do not want to be included or show.
// * If you exclude a directory, nothing inside it will be shown!
// Syntax: $excludedir[] = "directory";

$excludedir[] = "cgi-bin";
$excludedir[] = "phpMyAdmin";
$excludedir[] = "style";
$excludedir[] = "images";
$excludedir[] = "tinymce";
$excludedir[] = "admin";
$excludedir[] = "dynamic_content";
$excludedir[] = "feeds";
$excludedir[] = "includes";
$excludedir[] = "menu";
$excludedir[] = "resources";
$excludedir[] = "slideshow";
$excludedir[] = ".svn";
$excludedir[] = "ezmap";

// Array with files to exclude.
// This used to exclude or NOT list pages, files and so on.
// ADD the file names you do not want to be included or show.
// * If you exclude a file, nothing with the same name will be shown!
// Syntax: $excludefile[] = "filename";

$excludefile[] = "phpinfo.php";
$excludefile[] = "test.html";
$excludefile[] = "test2.html";
$excludefile[] = "competitions.admin.php";
$excludefile[] = "documents.admin.php";
$excludefile[] = "informations.admin.php";

$stime = gettimeofday();

$root = getcwd();

$pre = explode("/", $_SERVER['REQUEST_URI']);
array_pop($pre);
$prefix = join("/", $pre);

$root = str_replace($prefix, "", $root);
$prefix = "";

$root .= "/";
//$root = "./";
// Display server name and directory

if ($ezmapvalidate == 1) {
echo "<table width=\"90%\" class=\"ezmap\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
echo "<tr><td><img align=\"top\" src=\"img/server.gif\" width=\"20\" height=\"20\" border=\"0\" alt=\"\"> <b>http://".$_SERVER['SERVER_NAME'];
echo "$prefix/";
echo "</b></td></tr><tr><td><img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\"></td></tr>\n";	
} else {
echo "<table width=\"90%\" class=\"ezmap\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
echo "<tr><td><img align=\"top\" src=\"img/server.gif\" width=\"20\" height=\"20\" border=\"0\" alt=\"\" />\n";
echo " <b>http://".$_SERVER['SERVER_NAME'];
echo "$prefix/";
echo "</b></td></tr><tr><td><img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\" /></td></tr>\n";
}

function get_extension($name) {

$ezmapvalidate = 1;

$array = explode(".", $name);
$retval = strtolower(array_pop($array));
return $retval;
}

function list_dir($chdir) {

$ezmapvalidate = 1;

global $root, $prefix, $showsize, $display, $excludedir, $excludefile;
unset($sdirs);
unset($sfiles);
chdir($chdir);
$self = basename($_SERVER['PHP_SELF']);

// Open the current directory

$handle = opendir('.');

// Read the directory. If the item is a directory, place it in $sdirs.
// If it's a filetype we want, put it in $sfiles.
// If it is excluded, ignore it!

while ($file = readdir($handle))
{
if(is_dir($file) && $file != "." && $file != ".." && !in_array($file, $excludedir))
{ $sdirs[] = $file; }
elseif(is_file($file) && $file != "$self" && array_key_exists(get_extension($file), $display)
&& !in_array($file, $excludefile))
{ $sfiles[] = $file; }
}

$dir = getcwd();
$dir1 = str_replace($root, "", $dir."/");
$count = substr_count($dir1, "/") + substr_count($dir1, "\\");
		  	  
if(is_array($sdirs)) {
sort($sdirs);
reset($sdirs);
			 
for($y=0; $y<sizeof($sdirs); $y++) {
if ($ezmapvalidate == 1) {
echo "<tr><td>";
} else {
echo "<tr><td>";	
}
for($z=1; $z<=$count; $z++)
{
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\">&nbsp;&nbsp;&nbsp;";	
} else {
echo "<img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\" />&nbsp;&nbsp;&nbsp;";
}
}
if(is_array($sfiles))
{
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"img/tshaped.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\">";
} else { 
echo "<img align=\"top\" src=\"img/tshaped.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\" />";
}
}
else
{
if ($ezmapvalidate == 1) {	
echo "<img align=\"top\" src=\"img/upangle.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\">";
} else {
echo "<img align=\"top\" src=\"img/upangle.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\" />";
}
}
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"img/folder.gif\" width=\"20\" height=\"20\" border=\"0\" alt=\"\"> <a href=\"http://".$_SERVER['SERVER_NAME']."$prefix/$dir1$sdirs[$y]\" target=\"_top\">$sdirs[$y]</a>";
} else {
echo "<img align=\"top\" src=\"img/folder.gif\" width=\"20\" height=\"20\" border=\"0\" alt=\"\" /> <a href=\"http://".$_SERVER['SERVER_NAME']."$prefix/$dir1$sdirs[$y]\" target=\"_top\">$sdirs[$y]</a></td></tr>";
}
list_dir($dir."/".$sdirs[$y]);
}
}
		 		  
chdir($chdir);
		  
if(is_array($sfiles)) {
sort($sfiles);
reset($sfiles);
				 
$sizeof = sizeof($sfiles);
			 
for($y=0; $y<$sizeof; $y++) {
if ($ezmapvalidate == 1) {
echo "<tr><td class=\"ezmap_details\">";
} else {
echo "<tr><td class=\"ezmap_details\">";
}
for($z=1; $z<=$count; $z++)
{
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\">&nbsp;&nbsp;&nbsp;";
} else {
echo "<img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\" />&nbsp;&nbsp;&nbsp;";
}
}
if($y == ($sizeof -1))
{
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"img/upangle.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\">";
} else {
echo "<img align=\"top\" src=\"img/upangle.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\" />";
}
} else {
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"img/tshaped.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\">";
} else {
echo "<img align=\"top\" src=\"img/tshaped.gif\" width=\"10\" height=\"24\" border=\"0\" alt=\"\" />";
}
}
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"";
echo $display[get_extension($sfiles[$y])];
echo "\" border=\"0\" alt=\"\"> ";
echo "<a href=\"http://".$_SERVER['SERVER_NAME']."$prefix/$dir1$sfiles[$y]\" target=\"_top\">$sfiles[$y]</a>";	
} else {
echo "<img align=\"top\" src=\"";
echo $display[get_extension($sfiles[$y])];
echo "\" border=\"0\" alt=\"\" /> ";
echo "<a href=\"http://".$_SERVER['SERVER_NAME']."$prefix/$dir1$sfiles[$y]\" target=\"_top\">$sfiles[$y]</a>";
}

if($showsize) {
$fsize = @filesize($sfiles[$y])/1024;
printf(" ( %.2f kB )", $fsize);
}

if ($ezmapvalidate == 1) {
echo "</td></tr>";	
} else {
echo "</td></tr>";
}			
}
if ($ezmapvalidate == 1) {
echo "<tr><td>";
} else {
echo "<tr><td>";
}

for($z=1; $z<=$count; $z++)
{
if ($ezmapvalidate == 1) {
echo "<img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\">&nbsp;&nbsp;&nbsp;";
} else {
echo "<img align=\"top\" src=\"img/line.gif\" width=\"7\" height=\"24\" border=\"0\" alt=\"\" />&nbsp;&nbsp;&nbsp;";
}
}
if ($ezmapvalidate == 1) {
echo "</td></tr>\n";
} else {
echo "</td></tr>\n";
}
}
}

list_dir($root);

if ($ezmapvalidate == 1) {
echo "</table><br>\n";
} else {
echo "</table><br />\n";
}

?>
thx a lot for any help, or ideas...

Posted: Wed Oct 24, 2007 9:50 am
by pickle
Line 187 - you're referencing $sdirs without declaring it first.