if rss script is in read-only directory, skip file generation and diff calculations.
This commit is contained in:
parent
78122f16b6
commit
ba387e0c47
1 changed files with 51 additions and 45 deletions
60
rss.php
60
rss.php
|
@ -92,33 +92,37 @@ function print_array($array_to_display)
|
||||||
/*===================*/
|
/*===================*/
|
||||||
require("config-default.php");
|
require("config-default.php");
|
||||||
include("config.php");
|
include("config.php");
|
||||||
#$content = "";
|
|
||||||
$old_files_list = "db_old_files"; //list of files in ./photos
|
|
||||||
$db_feed_source = "db_feed_source";
|
|
||||||
$db_rss_timestamp = "db_rss_timestamp";
|
|
||||||
$Folder = 'photos';
|
|
||||||
$content = ListFiles($gallery_link, $content, $Folder, $SkipExts, $SkipObjects);
|
|
||||||
$to_store = "";
|
|
||||||
// Init files
|
|
||||||
if (!file_exists($old_files_list)) {
|
|
||||||
file_put_contents($old_files_list, "");
|
|
||||||
}
|
|
||||||
if (!file_exists($db_feed_source)) {
|
|
||||||
file_put_contents($db_feed_source, "");
|
|
||||||
}
|
|
||||||
if (!file_exists($db_rss_timestamp)) {
|
|
||||||
file_put_contents($db_rss_timestamp, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===================*/
|
$content = "";
|
||||||
/* Computing */
|
$folder = "photos";
|
||||||
/*===================*/
|
$content = listFiles($gallery_link, $content, $folder, $SkipExts, $SkipObjects);
|
||||||
#Todo : ajouter une condition : dois-je regénérer le flux ou utiliser les anciens fichiers ?
|
|
||||||
$temp = file_get_contents($db_feed_source);
|
if (is_writeable(".")) {
|
||||||
$last_rss_gen = file_get_contents($db_rss_timestamp);
|
$to_store = "";
|
||||||
$current_time = time();
|
$old_files_list = "db_old_files"; //list of files in ./photos
|
||||||
// If the RSS generation is already launched, don't do a second generation at the same time
|
$db_feed_source = "db_feed_source";
|
||||||
if (($current_time - $last_rss_gen) > $rss_refresh_interval && file_exists("rss.locker") == false) {
|
$db_rss_timestamp = "db_rss_timestamp";
|
||||||
|
|
||||||
|
// Init files
|
||||||
|
if (!file_exists($old_files_list)) {
|
||||||
|
file_put_contents($old_files_list, "");
|
||||||
|
}
|
||||||
|
if (!file_exists($db_feed_source)) {
|
||||||
|
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);
|
||||||
|
$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("rss.locker", "");
|
||||||
file_put_contents($db_rss_timestamp, time());
|
file_put_contents($db_rss_timestamp, time());
|
||||||
// Load the list from files.
|
// Load the list from files.
|
||||||
|
@ -141,12 +145,14 @@ if (($current_time - $last_rss_gen) > $rss_refresh_interval && file_exists("rss.
|
||||||
// Store the current file list for the next generation
|
// Store the current file list for the next generation
|
||||||
file_put_contents($old_files_list, $content);
|
file_put_contents($old_files_list, $content);
|
||||||
unlink("rss.locker");
|
unlink("rss.locker");
|
||||||
|
}
|
||||||
|
$content = $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===================*/
|
/*===================*/
|
||||||
/* XML Gen */
|
/* XML Gen */
|
||||||
/*===================*/
|
/*===================*/
|
||||||
$temp = explode("\n", $temp);
|
$temp = explode("\n", $content);
|
||||||
echo "<rss version='2.0'>\n<channel>";
|
echo "<rss version='2.0'>\n<channel>";
|
||||||
echo "<title>$title</title>";
|
echo "<title>$title</title>";
|
||||||
echo "<link>$gallery_link</link>";
|
echo "<link>$gallery_link</link>";
|
||||||
|
|
Loading…
Reference in a new issue