Hey all....
Getting frustrated here...I tried a few different techniques to make this work...but still nothing...the code I have is as follows...it only reads one directory, and looks for a specific file called unitinfo.txt, opens it, and looks for the line called Progress:. But I need it to read subfolders also and look for the same file here....
$directory = array('/fah');
$dir = opendir($directory);
while(false !== ($entry = readdir($dir))) {
if(preg_match('|unitinfo.txt|i', $entry)) {
$matching[] = $entry; // Throws the file names into an array
echo $matching[0];
}
}
closedir($directory); // close the directory from reading
// This loop reads the files themselves and //
// looks for the specified line we want. //
if (!isset($matching)) {
die("No Valid Data In Directory <b>{$directory}</b>");}
else {
echo "<table border = 1>\n"
. "<tr><td><b>Backed Up File</b></td>"
. "<td><b>Progress</b></td>"
. "<td><b>Last Modified</b></td></tr>\n";
foreach ($matching as $element) {
$handle = @fopen("$directory" ."/". "$element", "rb");
$line = 0;
while (!feof($handle)) {
$line++;
$buffer = fgets($handle, 1024);
//$mod = date("m/d/y @ h:i:sA", filemtime($element));
if (preg_match('|^Progress\:|i', $buffer)) {
echo "<tr><td>{$element}</td>\n"
. "<td>$buffer<br/></td>\n"
. "<td>No DATA</td></tr>\n";
break;
}
}
fclose($handle);
}
echo "</table>";
}
I tried making a loop to read the directory, list everything, and then try to see which ones are directories and which ones are files...it would throw the files i needed to parse into an array, the directories into another which it would continue to open up and use....HELP!!!! I dont have that code anymore 🙁 and this is starting to frustrate me...I have read the php directory piece, and many other things here...still a no go.