filemtype not working ?!?
| From: | Mario de Mello Bittencourt Neto | Date: | Wed, 14 Jun 2000 02:41:24 +0000 |
| Subject: | filemtype not working ?!? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-1802@lists.php.net to get a copy of this message | ||
Hi all,
I am am writing a small script to manage my httpd log files. I am
organizing then in a year/month way so I've decided to check the files
last modified time in order to find out where does it belong.
Unfortunatelly even tough I've managed to make it work under a
regular directory whenever I try to run it in /var/log/httpd it show's
me that every file it 1969/12/31...
I wrote the small example bellow.
if(!isSet($diretorio))
{ $diretorio = "/var/log/httpd/" ; }
// mktime(int hour, int minute, int second, int month, int day, int
year)
$tsMonth = mktime(0,0,0,date("m"),1,date("Y")) ;
$handle=opendir($diretorio);
while ($file = readdir($handle))
{
if("dir" != filetype($file))
{
if(filemtime($file) < $tsMonth)
{
// I'll copy
$year = date("Y",filemtime($file)) ;
$month = date("m",filemtime($file)) ;
$cmd = escapeShellCmd("cp ".$file."
".$pathBackup."/".$year."/".$month."/") ;
echo $cmd."<br>" ;
}
}
}
closedir($handle);
The output of the above program in a test machine is
cp error_log /1969/12/
cp access_log /1969/12/
cp ssl-error_log /1969/12/
cp ssl_engine_log /1969/12/
cp ssl-access_log /1969/12/
cp ssl_request_log /1969/12/
cp ssl_mutex.10113 /1969/12/
cp ssl_scache.pag /1969/12/
cp ssl_scache.dir /1969/12/
cp index.html /2000/03/
The index.html is a file which I've copied., the others are generated by
the httpd server.
a ls -l shows
-rw-r--r-- 1 root root 139737 Jun 13 22:25 access_log
-rw-r--r-- 1 root root 100121 Jun 13 22:25 error_log
-rw-r--r-- 1 root root 2511 Jun 11 14:48 index.html
-rw-r--r-- 1 root root 1188 Jun 5 21:34 ssl-access_log
-rw-r--r-- 1 root root 908 Jun 11 14:14 ssl-error_log
-rw-r--r-- 1 root root 104404 Jun 13 22:12 ssl_engine_log
-rw------- 1 nobody root 0 Apr 21 18:03 ssl_mutex.10113
-rw-r--r-- 1 root root 1250 Jun 5 21:34 ssl_request_log
-rw------- 1 nobody root 0 Jun 13 22:12 ssl_scache.dir
-rw------- 1 nobody root 0 Jun 13 22:12 ssl_scache.pag
I've run it as nobody (through the browser) and both as regular/root
user - cgi. same thing.
Any ideas ?