update_feeds.php for CLI

This commit is contained in:
Andrew Dolgov 2005-12-03 15:25:40 +01:00
parent 8fe19cd81e
commit 1f2b01ed8e
3 changed files with 43 additions and 3 deletions

View File

@ -39,6 +39,9 @@
// */30 * * * * /usr/bin/wget -O /dev/null -T 600 "http://www.your-site.xxx/tt-rss/backend.php?op=globalUpdateFeeds&daemon=1"
//
// The alternative approach is to run update_feeds.php from your crontab
// with command line PHP interpreter.
define('SMART_RPC_COUNTERS', true);
// If enabled, stores feed counter information on the server side and sends
// only diffs to the client. In the nutshell, it saves your bandwidth and

View File

@ -1,5 +1,4 @@
<?
session_start();
if ($_GET["debug"]) {
define('DEFAULT_ERROR_LEVEL', E_ALL);
@ -90,7 +89,7 @@
(SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
}
function update_all_feeds($link, $fetch, $user_id = false) {
function update_all_feeds($link, $fetch, $user_id = false, $force_daemon = false) {
if (WEB_DEMO_MODE) return;
@ -115,7 +114,7 @@
if ($fetch || (!$line["last_updated"] ||
time() - strtotime($line["last_updated"]) > ($upd_intl * 60))) {
update_rss_feed($link, $line["feed_url"], $line["id"]);
update_rss_feed($link, $line["feed_url"], $line["id"], $force_daemon);
}
}

38
update_feeds.php Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/php4
<?
// this script is probably run not from your httpd-user, so cache
// directory defined in config.php won't be accessible
define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache-cli');
require_once "sanity_check.php";
require_once "config.php";
require_once "db.php";
require_once "db-prefs.php";
require_once "functions.php";
require_once "magpierss/rss_fetch.inc";
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (!$link) {
if (DB_TYPE == "mysql") {
print mysql_error();
}
// PG seems to display its own errors just fine by default.
return;
}
if (DB_TYPE == "pgsql") {
pg_query("set client_encoding = 'utf-8'");
}
$result = db_query($link, "SELECT id FROM ttrss_users");
while ($line = db_fetch_assoc($result)) {
$user_id = $line["id"];
update_all_feeds($link, false, $user_id, true);
}
db_close($link);
?>