X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=update_feeds.php;h=4b6ad3c4fedba68b3b3fbc4b1e7c13282a23aed3;hb=45004d43408bb006f89dd2c46fb3b934966896b0;hp=aa07321e66fdd9d0d140cb524c260ba9408ae152;hpb=70dcff6b3d681bbeae4b9536139426d6d60a46bd;p=tt-rss.git diff --git a/update_feeds.php b/update_feeds.php index aa07321e..4b6ad3c4 100644 --- a/update_feeds.php +++ b/update_feeds.php @@ -3,16 +3,29 @@ // 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'); - + define('SIMPLEPIE_CACHE_DIR', '/var/tmp/simplepie-ttrss-cache-cli'); + define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); define('DISABLE_SESSIONS', true); + error_reporting(DEFAULT_ERROR_LEVEL); + 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"; + $lock_filename = "update_feeds.lock"; + + $lock_handle = make_lockfile($lock_filename); + + // Try to lock a file in order to avoid concurrent update. + if (!$lock_handle) { + die("error: Can't create lockfile ($lock_filename). ". + "Maybe another process is already running.\n"); + } + + // Create a database connection. $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); if (!$link) { @@ -27,20 +40,19 @@ pg_query("set client_encoding = 'utf-8'"); pg_set_client_encoding("UNICODE"); } else { - db_query($link, "SET NAMES utf8"); - db_query($link, "SET CHARACTER SET utf8"); + if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { + db_query($link, "SET NAMES " . MYSQL_CHARSET); +// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET); + } } - $result = db_query($link, "SELECT id FROM ttrss_users"); - - while ($line = db_fetch_assoc($result)) { - $user_id = $line["id"]; - initialize_user_prefs($link, $user_id); - update_all_feeds($link, false, $user_id, true); - } + // Update all feeds needing a update. + update_daemon_common($link, $limit=0); + // Send feed digests by email if needed. if (DAEMON_SENDS_DIGESTS) send_headlines_digests($link); db_close($link); + unlink(LOCK_DIRECTORY . "/$lock_filename"); ?>