My boss needs this code doing for tonight....so i dont have long.
Basically, this little script should go to the root of the server, and find all the directries, the only problem is, it isnt giving my the directries!
in the root folder i have:
dir:hello1
dir:hello2
dir:hello3
file: helloworld.txt
What i need the code to do is read that, and choose the directries, which it should do.
But when i echo back the $temp variable, it gives me no luck, only: .. and .
so how do i make the code read only the directries, then go through each one?
Below is the snippet of code
Code: Select all
//Open the logfile and input the server IP
$ip_hold = $_SERVER['SERVER_ADDR'];
$ip_write = "The IP of the server that send this log is".$ip_hold."";
$fh = fopen($PUBSTER_EMAIL.".txt", "w");
fwrite($fh,$ip_write);
//Open www directory
$dir = opendir("../../");
$count = 0;
$count2 = 0;
//Put all files into an array
while (($file = readdir($dir)) !== false)
{
$files[$count]=$file;
$count++;
}
closedir($dir);
while ($count2 != $count)
{
$temp = $files[$count2];
$direc = "../$temp";
if(is_dir($direc))
{
$filename = "../../$temp/inc/hello.php";
if (file_exists($filename))
{
require $filename;
fwrite($fh, "Domain: $DOMAIN_NAME
");
}
$count2++;
}
else
{
$count2++;
}
fclose($fh);
}~Monotoko