time cache

This commit is contained in:
Alexander Yakovlev 2017-05-16 13:52:32 +07:00
parent 28fdff3ffe
commit 990218238e
2 changed files with 10 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
vendor
config.yml
.lastrun

View File

@ -3,6 +3,11 @@ require_once ("vendor/autoload.php");
use Symfony\Component\Yaml\Yaml;
$config = Yaml::parse(file_get_contents('config.yml'));
$lastrun = 0;
if (file_exists('.lastrun')) {
$lastrun = file_get_contents('.lastrun');
}
echo $lastrun;
function get_text($url) {
$curl = curl_init();
@ -29,6 +34,9 @@ $articles = $service->parse($string)[0]['value'];
unset($string);
$pandoc = new \Pandoc\Pandoc();
foreach ($articles as $article) {
if (strtotime($article['pubDate']) <= $lastrun) {
continue;
}
$title = $article['title'];
$link = $article['link'];
$description = $article['description'];
@ -52,3 +60,4 @@ foreach ($articles as $article) {
echo $description;
}
}
file_put_contents('.lastrun', time());