fredmintah
Programmer
Hi all,
Below is my code which is not working as I want it to work.. I need to recursively check for all files and directory under a directory and look for files or directory that has been created or edited with the day.. This code cannot read files or directories with embedded space/s. If it finds one it does not read it..
How can I make this code or php per-sey read files with embedded spaces.. Below is my code.
All suggestion and comments are welcomed..
Cheers
<?php
$checkDate = date("DdMYgiA", time());
$checkDate = $checkDate . ".xls";
$fp = fopen("D:\Frederick_Mintah\php\mmorawa\\$checkDate", "a");
$header = "File Names" . "\t" . "Date Created" . "\t" . "Date Modified" ."\n";
fwrite($fp, strtoupper($header));
echo "File Name" . "\t\t" . "Created Date" . "\t\t" . "Modified Date\n\n";
parse_dir("D:\Frederick_Mintah\php\mmorawa");
function parse_dir($scanthis)
{
$dir = @opendir($scanthis);
while (false!=($file = @readdir($dir)))
{
if ($file != "." && $file != "..")
{
$scanthispp = preg_replace("/\s/","%20",$scanthis);
$filep = preg_replace("/\s/","%20",$file);
$theFile = $scanthispp . "\\" . $filep;
$scanthispp = substr($scanthis,25); //trim absolute file path
if (is_dir($theFile))
{
parse_dir($theFile);
}
$modDate = filemtime($theFile); //get last modified date of file
$modDate = date("D d M Y g:i A", $modDate);
$creDate = filectime($theFile); //get the created date of file
$creDate = date("D d M Y g:i A", $creDate);
$checkDetails = $scanthis. "\\" . $filep . "\t " . $creDate . " \t" . $modDate ."\n";
$modDate2 = filemtime($theFile); //get last modified date of file
$modDate2 = date("D d M Y", $modDate2);
$creDate2= filectime($theFile); //get the created date of file
$creDate2 = date("D d M Y", $creDate2);
$today = date("D d M Y", time());
global $fp;
if($modDate2 == $today || $creDate2 == $today)
{
fwrite($fp, $checkDetails);
echo "\n" .$scanthis. "\\" . $filep . "\t\t " . $creDate . " \t\t" . $modDate ."\n\n";
}
}
}
}
?>
Below is my code which is not working as I want it to work.. I need to recursively check for all files and directory under a directory and look for files or directory that has been created or edited with the day.. This code cannot read files or directories with embedded space/s. If it finds one it does not read it..
How can I make this code or php per-sey read files with embedded spaces.. Below is my code.
All suggestion and comments are welcomed..
Cheers
<?php
$checkDate = date("DdMYgiA", time());
$checkDate = $checkDate . ".xls";
$fp = fopen("D:\Frederick_Mintah\php\mmorawa\\$checkDate", "a");
$header = "File Names" . "\t" . "Date Created" . "\t" . "Date Modified" ."\n";
fwrite($fp, strtoupper($header));
echo "File Name" . "\t\t" . "Created Date" . "\t\t" . "Modified Date\n\n";
parse_dir("D:\Frederick_Mintah\php\mmorawa");
function parse_dir($scanthis)
{
$dir = @opendir($scanthis);
while (false!=($file = @readdir($dir)))
{
if ($file != "." && $file != "..")
{
$scanthispp = preg_replace("/\s/","%20",$scanthis);
$filep = preg_replace("/\s/","%20",$file);
$theFile = $scanthispp . "\\" . $filep;
$scanthispp = substr($scanthis,25); //trim absolute file path
if (is_dir($theFile))
{
parse_dir($theFile);
}
$modDate = filemtime($theFile); //get last modified date of file
$modDate = date("D d M Y g:i A", $modDate);
$creDate = filectime($theFile); //get the created date of file
$creDate = date("D d M Y g:i A", $creDate);
$checkDetails = $scanthis. "\\" . $filep . "\t " . $creDate . " \t" . $modDate ."\n";
$modDate2 = filemtime($theFile); //get last modified date of file
$modDate2 = date("D d M Y", $modDate2);
$creDate2= filectime($theFile); //get the created date of file
$creDate2 = date("D d M Y", $creDate2);
$today = date("D d M Y", time());
global $fp;
if($modDate2 == $today || $creDate2 == $today)
{
fwrite($fp, $checkDetails);
echo "\n" .$scanthis. "\\" . $filep . "\t\t " . $creDate . " \t\t" . $modDate ."\n\n";
}
}
}
}
?>