phpfilesystemslastaccesstime

PHP fileatime not updating


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?


Solution

  • You might see one of two effects: