From 5b93dc9c2b6616233222b3d41f5509fd1de9b564 Mon Sep 17 00:00:00 2001 From: tmos Date: Sun, 4 May 2014 17:28:32 +0200 Subject: [PATCH] timestamp update --- .gitignore | 1 + config.php | 1 + rss.php | 14 ++++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index cb61bce..44f1c9b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ photos/ thumbs/ db_feed_source db_old_files +db_rss_timestamp rss.locker new_files_list diff --git a/config.php b/config.php index 47f4582..d0df8eb 100755 --- a/config.php +++ b/config.php @@ -41,6 +41,7 @@ $label_loading = "Loading..."; //Thumbnail loading text $gallery_link = substr("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 0, strlen("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])-7); // the -7 is to remove "rss.php" $description = "MiniGal Nano"; $nb_items_rss = 25; //number ef elements to display in the feed. If you add a lot of pictures at the time, consider increasing this number +$rss_refresh_interval = 60;//time, in seconds, between two RSS refresh. for example, 3600 = 1update max per hour, 86400 = 1/day. $SkipExts = array('html', 'txt', 'php', "gitignore"); //Files with one of this extension will not be displayed on the RSS feed $SkipObjects = array('UnDossier', 'UnFichier'); //Those files and folders will not be displayed on the RSS feed //ADVANCED SETTINGS diff --git a/rss.php b/rss.php index 3feb9b0..b4462fa 100644 --- a/rss.php +++ b/rss.php @@ -62,8 +62,8 @@ require("config.php"); #$content = ""; $old_files_list = "db_old_files"; //list of files in ./photos - $new_files_list = "new_files_list"; $db_feed_source = "db_feed_source"; + $db_rss_timestamp = "db_rss_timestamp"; $Folder = 'photos'; $content = ListFiles($gallery_link, $content, $Folder, $SkipExts, $SkipObjects); $to_store = ""; @@ -76,17 +76,23 @@ { file_put_contents($db_feed_source, ""); } + if (!file_exists($db_rss_timestamp)) + { + file_put_contents($db_rss_timestamp, ""); + } /*===================*/ /*Computing*/ /*===================*/ #Todo : ajouter une condition : dois-je regénérer le flux ou utiliser les anciens fichiers ? $temp = file_get_contents($db_feed_source); - - //If the RSS generation is already launched, don't do à second generation at the same time - if (file_exists("rss.locker") == false) + $last_rss_gen = file_get_contents($db_rss_timestamp); + $current_time = time(); + //If the RSS generation is already launched, don't do a second generation at the same time + if (($current_time - $last_rss_gen) > $rss_refresh_interval && file_exists("rss.locker") == false) { file_put_contents("rss.locker", ""); + file_put_contents($db_rss_timestamp, time()); // Load the list from files. $old_files_list_content = explode("\n", file_get_contents($old_files_list)); $new_files_list_content = explode("\n", $content); #debug