improve update-time detection

This commit is contained in:
mappu 2015-11-08 11:49:18 +13:00
parent fc28e8c5c8
commit 138a3c3342

View File

@ -192,11 +192,20 @@ class CProject {
// Identify resources in folder
$ls = scandir($this->dir);
$found_real_lastupdate = false;
foreach($ls as $file) {
if ($file[0] == '.') continue;
if ($file == 'README.txt') {
$this->lastupdate = max($this->lastupdate, filectime($this->dir.$file)); // don't count README updates
// Guess 'last update' time
$matches = [];
if (preg_match('~\n(\d\d\d\d-\d\d-\d\d)~', $this->longdesc, $matches)) {
// Use first date entry (assumed to be a CHANGELOG)
$this->lastupdate = strtotime($matches[1]);
$found_real_lastupdate = true;
}
$this->longdesc = file_get_contents($this->dir.'README.txt');
@ -235,11 +244,13 @@ class CProject {
continue;
}
if (! $found_real_lastupdate) {
$this->lastupdate = max(
$this->lastupdate,
// filectime($this->dir.$file),
filemtime($this->dir.$file)
($file == 'README.txt' ? filectime($this->dir.$file) : filemtime($this->dir.$file)) // Don't count README updates
);
}
if (is_image($file)) {
$this->images[] = $file;
@ -582,6 +593,7 @@ function main($args) {
//
ini_set('display_errors', 'On');
date_default_timezone_set('Etc/UTC');
error_reporting(E_ALL);
main(array_slice($_SERVER['argv'], 1));