diff --git a/backend.php b/backend.php index b5de559c9..b947a1471 100644 --- a/backend.php +++ b/backend.php @@ -693,10 +693,15 @@ if ($subop == "editSave") { $feed_title = db_escape_string($_GET["t"]); $feed_link = db_escape_string($_GET["l"]); + $upd_intl = db_escape_string($_GET["ui"]); $feed_id = $_GET["id"]; + if (strtoupper($upd_intl) == "DEFAULT") + $upd_intl = 0; + $result = db_query($link, "UPDATE ttrss_feeds SET - title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'"); + title = '$feed_title', feed_url = '$feed_link', + update_interval = '$upd_intl' WHERE id = '$feed_id'"); } @@ -743,14 +748,16 @@ "; $result = db_query($link, "SELECT - id,title,feed_url,substring(last_updated,1,16) as last_updated + id,title,feed_url,substring(last_updated,1,16) as last_updated, + update_interval FROM ttrss_feeds ORDER by title"); print "
Select | Title | -Link | Last updated | Link | Update Interval | +Last updated | "; $lnum = 0; @@ -787,7 +794,12 @@ $line["title"] . ""; print "" . $line["feed_url"] . " | "; - + + if ($line["update_interval"] == "0") + $line["update_interval"] = "Default"; + + print "" . $line["update_interval"] . " | "; + } else if ($feed_id != $edit_feed_id) { @@ -797,13 +809,19 @@ print "".$line["title"]." | "; print "".$line["feed_url"]." | "; + if ($line["update_interval"] == "0") + $line["update_interval"] = "Default"; + + print "" . $line["update_interval"] . " | "; + } else { print ""; print " | "; print " | "; - + print " | "; + } if (!$line["last_updated"]) $line["last_updated"] = "Never"; diff --git a/config.php-dist b/config.php-dist index a0940820e..f56fb6dc9 100644 --- a/config.php-dist +++ b/config.php-dist @@ -30,5 +30,7 @@ // crafted SQL queries. This feature is highly experimental and // at this point not user friendly. Use with caution. + define(MIN_UPDATE_INTERVAL, 30); + // min. interval between feed updates, minutes ?> diff --git a/functions.php b/functions.php index 0c0fc047f..a2e29655b 100644 --- a/functions.php +++ b/functions.php @@ -24,12 +24,20 @@ db_query($link, "BEGIN"); - $result = db_query($link, "SELECT feed_url,id,last_updated FROM ttrss_feeds"); + $result = db_query($link, "SELECT feed_url,id, + substring(last_updated,1,19) as last_updated, + update_interval FROM ttrss_feeds"); while ($line = db_fetch_assoc($result)) { -// if (!$line["last_updated"] || time() - strtotime($line["last_updated"]) > 1800) { + $upd_intl = $line["update_interval"]; + + if (!$upd_intl) $upd_intl = MIN_UPDATE_INTERVAL; + + if (!$line["last_updated"] || + time() - strtotime($line["last_updated"]) > ($upd_intl * 60)) { + update_rss_feed($link, $line["feed_url"], $line["id"]); -// } + } } purge_old_posts($link); diff --git a/prefs.js b/prefs.js index 2d04efedc..1b5277674 100644 --- a/prefs.js +++ b/prefs.js @@ -454,9 +454,16 @@ function feedEditSave() { var link = document.getElementById("iedit_link").value; var title = document.getElementById("iedit_title").value; + var upd_intl = document.getElementById("iedit_updintl").value; // notify("Saving feed."); + if (upd_intl < 0) { + notify("Update interval must be >= 0 (0 = default)"); + return; + } + + if (link.length == 0) { notify("Feed link cannot be blank."); return; @@ -470,7 +477,8 @@ function feedEditSave() { active_feed = false; xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" + - feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) ,true); + feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) + + "&ui=" + param_escape(upd_intl), true); xmlhttp.onreadystatechange=feedlist_callback; xmlhttp.send(null); diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index de01f20d6..408402c70 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -6,6 +6,7 @@ create table ttrss_feeds (id integer not null auto_increment primary key, title varchar(200) not null unique, feed_url varchar(250) unique not null, icon_url varchar(250) not null default '', + update_interval integer not null default 0, last_updated datetime default '') TYPE=InnoDB; insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed'); diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 77e88a158..085bcc675 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -6,6 +6,7 @@ create table ttrss_feeds (id serial not null primary key, title varchar(200) not null unique, feed_url varchar(250) unique not null, icon_url varchar(250) not null default '', + update_interval integer not null default 0, last_updated timestamp default null); insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed'); diff --git a/tt-rss.css b/tt-rss.css index 079ce827c..c0380934e 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -204,7 +204,7 @@ a:hover { opacity : 0.8; } -#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr { +#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl { width : 100%; padding-left : 2px; } |