close #69: in the config page, you are notified of the release of a new version

This commit is contained in:
Nicolas Lœuillet
2013-08-05 12:34:16 +02:00
parent 21e0af98eb
commit 3252078501
3 changed files with 31 additions and 1 deletions

View File

@ -130,6 +130,16 @@ class Poche
switch ($view)
{
case 'config':
$dev = $this->getPocheVersion('dev');
$prod = $this->getPocheVersion('prod');
$compare_dev = version_compare(POCHE_VERSION, $dev);
$compare_prod = version_compare(POCHE_VERSION, $prod);
$tpl_vars = array(
'dev' => $dev,
'prod' => $prod,
'compare_dev' => $compare_dev,
'compare_prod' => $compare_prod,
);
Tools::logm('config view');
break;
case 'view':
@ -315,4 +325,16 @@ class Poche
));
Tools::logm('export view');
}
private function getPocheVersion($which = 'prod')
{
$cache_file = CACHE . '/' . $which;
if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) {
$version = file_get_contents($cache_file);
} else {
$version = file_get_contents('http://www.inthepoche.com/' . $which);
file_put_contents($cache_file, $version, LOCK_EX);
}
return $version;
}
}

View File

@ -36,7 +36,7 @@ require_once './vendor/autoload.php';
require_once './inc/3rdparty/simple_html_dom.php';
if (DOWNLOAD_PICTURES) {
require_once './inc/poche/pochePicture.php';
require_once './inc/poche/pochePictures.php';
}
$poche = new Poche($storage_type);