File Modification Time Action
This action allows you to display the modification time of any file on the filesystem. Save this as actions/filemtime.php:
<?php
/*
filemtime action
Displays the modification time of a file
Syntax: {{filemtime path="/path/to/file"}}
*/
$path = trim($vars['path']);
if (file_exists($path)) {
echo "<font size=-2>" . date("M d, Y h:i:s a", filemtime($path)) . "</font>";
} else {
echo "<!-- ERROR (filemtime): '" . htmlspecialchars($path) ."' not found -->";
}
?>
/*
filemtime action
Displays the modification time of a file
Syntax: {{filemtime path="/path/to/file"}}
*/
$path = trim($vars['path']);
if (file_exists($path)) {
echo "<font size=-2>" . date("M d, Y h:i:s a", filemtime($path)) . "</font>";
} else {
echo "<!-- ERROR (filemtime): '" . htmlspecialchars($path) ."' not found -->";
}
?>
If you find this action useful, post a comment and let me know! Also, feel free to comment with requests for feature enhancements. --JasonHuebel
CategoryUserContributions
Two suggestions:
1. Apart from allowing any file on the system, (which could be easily solved by matching the path with the current path), it's not entirely secure in this form; off the top of my head, you'll probably want to apply trip_tags() to the path parameter, as well as htmlspecialchars() instead of htmlspecialchars_ent() so that any entities are escaped as well.
2. Rather than using the old-fashioned and decprecated font tag, it would be better to use a span tag with a class (e.g., "filetime"), to be styled with the strylesheet.
Of course, hiding the error message in a comment has the same security effect: 'view source' won't execute scripts. :)
I'm considering changing the action to include the option of jailing it to the web root path and should have those modifications done in the next couple of weeks (when I have time to look at it).