msing Posted March 15, 2007 Share Posted March 15, 2007 Hi I've got some PHP code in my nav bar (which is included in every site page) that recursively reads file/folder modification times in the entire site to find the most recently modified file time, and displays that. I recently made some pages that are password protected and now that code fails and stops the the rest of the page from processing. So it's trying to read all of the file mod times, but apparently gets stuck on the password protected directories and dies. So short of removing the protection on these directories, is there a way to allow this code (apparently executing as the anonymous user) to read the appropriate file/folder attribute information without giving read access to anonymous users? Link to comment https://forums.phpfreaks.com/topic/42859-can-i-allow-php-to-read-filefolder-attributes-without-giving-full-access/ Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 I am not sure, I would look at the dir class via php.net and see if there is an option for supplying a username/password to gain access to those directories. Link to comment https://forums.phpfreaks.com/topic/42859-can-i-allow-php-to-read-filefolder-attributes-without-giving-full-access/#findComment-208105 Share on other sites More sharing options...
msing Posted March 15, 2007 Author Share Posted March 15, 2007 Nope doesn't look like it. There's an option for ignoring errors. I tried that in the hopes that the page would at least finish loading when the function call failed, but no dice either. I should note that I didn't write this code that finds file mod times and here it is BTW. So if you think of any ways to make this code read protected file/folder modification time info, please let me know. <!-- Taken from 'wookie at no-way dot org' on http://www.php.net/function.filemtime --> <?php function mostRecentModifiedFileTime($dirName,$doRecursive) { $d = dir($dirName); $lastModified = 0; while($entry = $d->read()) { if ($entry != "." && $entry != "..") { if (!is_dir($dirName."/".$entry)) { $currentModified = filemtime($dirName."/".$entry); } else if ($doRecursive && is_dir($dirName."/".$entry)) { $currentModified = mostRecentModifiedFileTime($dirName."/".$entry,true); } if ($currentModified > $lastModified){ $lastModified = $currentModified; } } } $d->close(); return $lastModified; } ?> Link to comment https://forums.phpfreaks.com/topic/42859-can-i-allow-php-to-read-filefolder-attributes-without-giving-full-access/#findComment-208453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.