1

I personally know limited PHP, however I have a script provided by another, that I have tweaked a bit

<?php

function getFiles($dir)
{
    $arr=scandir($dir);
    $res=array();
    foreach ($arr as $item)
    {
        if ($item=='..' || $item=='.'){continue;}
        $path=$dir.'/'.$item;
        if (is_dir($path))
        {
            $res=array_merge($res,getFiles($path));
        }
        else
        {
            $res[$path]=fileatime($path);
        }
    }
    return $res;
}

 $files=getFiles(dirname('Manuals'));
 arsort($files);
 $files=array_slice(array_keys($files),0,11);
 foreach ($files as $file)
 {
 $URL=$file;
 $file = trim(substr($file, strrpos($file, '/') + 1));
 $file = str_replace(".pdf", "", $file);
     echo '<!--<li style="margin-left: -25px; white-space: pre;">--><a href="'.$URL.'" title="'.$file.'">'.$file.'</a><br />';
 }

?>

changing the previous filemtime to fileatime in "$res[$path]=fileatime($path);"

from what I gather, this should show the last time the file is accessed, however it appears to function no different than filemtime or filectime. Perhaps the server is not updating the time accessed? (all files are html, php, and pdf)

any idea if this is a permissions thing? server thing? code thing?

NRGdallas
  • 395
  • 1
  • 8
  • 20
  • You should check whether the file system where the files reside wasn't mounted with atime support disabled (/etc/fstab, noatime option), often used to improve server performance. – fvu Jun 13 '12 at 17:05

1 Answers1

2

You might see one of two effects:

  • On many webservers, the filesystems carrying the web data are mounted noatime to save the expensive IO of updating atime for every request.

  • PHP's fstat cache tends to have a life on its own: use clearstatcache() to overcome this.

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • any idea how to check if the data is mounted that way? I use parallels Plesk Linux distribution, current version. – NRGdallas Jun 13 '12 at 17:09
  • 1
    run the command `mount`, look for the filesystem you are on, then look for "noatime" in the mount options (bracketed expression at line end) – Eugen Rieck Jun 13 '12 at 17:11