2007-03-02 14:41:57 +00:00
|
|
|
#!/usr/bin/php
|
2006-08-19 07:04:45 +00:00
|
|
|
<?php
|
2005-12-03 14:25:40 +00:00
|
|
|
// 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');
|
2007-08-29 01:01:06 +00:00
|
|
|
define('SIMPLEPIE_CACHE_DIR', '/var/tmp/simplepie-ttrss-cache-cli');
|
2007-11-21 07:20:54 +00:00
|
|
|
define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
|
2006-02-11 13:52:17 +00:00
|
|
|
define('DISABLE_SESSIONS', true);
|
|
|
|
|
2007-11-21 07:20:54 +00:00
|
|
|
error_reporting(DEFAULT_ERROR_LEVEL);
|
|
|
|
|
2005-12-03 14:25:40 +00:00
|
|
|
require_once "sanity_check.php";
|
|
|
|
require_once "config.php";
|
|
|
|
require_once "db.php";
|
|
|
|
require_once "db-prefs.php";
|
|
|
|
require_once "functions.php";
|
2007-09-25 03:23:29 +00:00
|
|
|
|
|
|
|
$lock_filename = "update_feeds.lock";
|
|
|
|
|
|
|
|
$lock_handle = make_lockfile($lock_filename);
|
|
|
|
|
2008-01-26 05:33:59 +00:00
|
|
|
// Try to lock a file in order to avoid concurrent update.
|
2007-09-25 03:23:29 +00:00
|
|
|
if (!$lock_handle) {
|
|
|
|
die("error: Can't create lockfile ($lock_filename). ".
|
|
|
|
"Maybe another process is already running.\n");
|
|
|
|
}
|
2005-12-03 14:25:40 +00:00
|
|
|
|
2008-01-26 05:33:59 +00:00
|
|
|
// Create a database connection.
|
2005-12-03 14:25:40 +00:00
|
|
|
$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'");
|
2007-02-20 08:33:17 +00:00
|
|
|
pg_set_client_encoding("UNICODE");
|
2007-08-17 16:02:15 +00:00
|
|
|
} else {
|
2007-08-21 10:47:25 +00:00
|
|
|
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
|
|
|
|
db_query($link, "SET NAMES " . MYSQL_CHARSET);
|
2007-08-25 04:28:10 +00:00
|
|
|
// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
|
2007-08-21 10:47:25 +00:00
|
|
|
}
|
2005-12-03 14:25:40 +00:00
|
|
|
}
|
|
|
|
|
2008-06-24 03:25:16 +00:00
|
|
|
// Purge all posts (random 30 feeds)
|
|
|
|
global_purge_old_posts($link, true, 30);
|
|
|
|
|
2008-01-26 05:33:59 +00:00
|
|
|
// Update all feeds needing a update.
|
2008-11-05 05:58:49 +00:00
|
|
|
update_daemon_common($link);
|
2005-12-03 14:25:40 +00:00
|
|
|
|
2008-01-26 05:33:59 +00:00
|
|
|
// Send feed digests by email if needed.
|
2006-08-21 07:34:49 +00:00
|
|
|
if (DAEMON_SENDS_DIGESTS) send_headlines_digests($link);
|
2006-08-21 06:43:38 +00:00
|
|
|
|
2005-12-03 14:25:40 +00:00
|
|
|
db_close($link);
|
|
|
|
|
2008-01-17 05:33:52 +00:00
|
|
|
unlink(LOCK_DIRECTORY . "/$lock_filename");
|
2005-12-03 14:25:40 +00:00
|
|
|
?>
|