hello I am trying to make this recursive directory code snippet to work, but it is giving me these errors
Warning: Undefined variable: dispThis in c:\inetpub\wwwroot\test2.php on line 31
Warning: Use of undefined constant strategies - assumed 'strategies' in on line 49
Warning: Undefined variable: dispThis in con line 31
the only variables I was suppose to put in were scanthis and rootdir? what is the syntax of these variables, has anyone used this snippet before? thank you for you help
<?
$scanthis = "c:\inetpub\wwwroot\";
$rootDir = "c:\inetpub\wwwroot\";
function parse_dir($scanthis) {
$dir = @opendir($scanthis);
while (false!=($file = @readdir($dir))) {
if ($file != "." && $file != "..") {
if (is_dir($scanthis."/".$file)) {
echo "<span class=\"fileText\"><img src=\"path/to/images/dir.gif\" border=\"0\">" . " <b>" . $scanthis . "/" . $file . " is a directory containing the following files:</b><br></span>";
parse_dir($scanthis."/".$file,$level_d+1);
}
else {
$fu = round(filesize("$scanthis/$file")/1000,2);
$scanthispp = preg_replace("/\s/","%20",$scanthis);
$filep = preg_replace("/\s/","%20",$file);
if ($filep != '.htaccess') {
//Get last modified date of file
$theFile = $scanthispp . "/" . $filep;
$modDate = filemtime($theFile);
$modDate = date("d-m-Y H:i:s", $modDate);
//Get title of page
$fp = fopen("$theFile",'r');
$buffer = fgetss($fp,100,"<html lang=\"en\"><head><title>");
$buffer = ereg_replace("</title>", "", $buffer);
$string = substr($buffer,20);
$dispThis .= "<tr><td align=\"left\"><span class=\"fileTextLink\"><a title=\"Go here to view: $file\" class=\"fileTextLink\" href=\"$scanthispp/$filep\">$file</a></span></td><td align=\"left\"><span class=\"fileText\">Size: $fu K</span></td><td align=\"left\"><span class=\"fileText\">$modDate</span></td><td align=\"left\"><span class=\"fileText\">$string</span></td></tr>";
}//end-if
}//end-else
}//end-if
}//end-while
echo $dispThis;
}//end-function declaration
$rootDir = "216.148.121.4";
$level_d = 1;
parse_dir($rootDir, $level_d);
//closedir($rootDir);
?>
/
Place the following in the HTML of the page you wish the results of the function to be displayed within:
/
<!-- Display contents of directory -->
<?php
//Start off display table
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\"><tr><th align=\"left\"><p>Filename</p></th><th align=\"left\"><p>Filesize</p></th><th align=\"left\"><p>Modified on</p></th><th align=\"left\"><p>Title/Description</p></th></tr>";
//Get contents of directory using parse_dir() (Change value of parse_dir according to dir to be searched)
parse_dir(strategies);
//Finish off display table
echo "</table>";
?>