]>
Commit | Line | Data |
---|---|---|
cd2cd415 | 1 | #!/usr/bin/php |
1d3a17c7 | 2 | <?php |
1f2b01ed AD |
3 | // this script is probably run not from your httpd-user, so cache |
4 | // directory defined in config.php won't be accessible | |
5 | define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache-cli'); | |
ade696f8 | 6 | define('SIMPLEPIE_CACHE_DIR', '/var/tmp/simplepie-ttrss-cache-cli'); |
aa8ab7ae | 7 | define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); |
de696427 AD |
8 | define('DISABLE_SESSIONS', true); |
9 | ||
aa8ab7ae AD |
10 | error_reporting(DEFAULT_ERROR_LEVEL); |
11 | ||
1f2b01ed AD |
12 | require_once "sanity_check.php"; |
13 | require_once "config.php"; | |
14 | require_once "db.php"; | |
15 | require_once "db-prefs.php"; | |
16 | require_once "functions.php"; | |
31a6d42d AD |
17 | |
18 | $lock_filename = "update_feeds.lock"; | |
19 | ||
20 | $lock_handle = make_lockfile($lock_filename); | |
21 | ||
45004d43 | 22 | // Try to lock a file in order to avoid concurrent update. |
31a6d42d AD |
23 | if (!$lock_handle) { |
24 | die("error: Can't create lockfile ($lock_filename). ". | |
25 | "Maybe another process is already running.\n"); | |
26 | } | |
1f2b01ed | 27 | |
45004d43 | 28 | // Create a database connection. |
1f2b01ed AD |
29 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
30 | ||
31 | if (!$link) { | |
32 | if (DB_TYPE == "mysql") { | |
33 | print mysql_error(); | |
34 | } | |
35 | // PG seems to display its own errors just fine by default. | |
36 | return; | |
37 | } | |
38 | ||
39 | if (DB_TYPE == "pgsql") { | |
40 | pg_query("set client_encoding = 'utf-8'"); | |
ef063748 | 41 | pg_set_client_encoding("UNICODE"); |
70dcff6b | 42 | } else { |
bddc9788 AD |
43 | if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
44 | db_query($link, "SET NAMES " . MYSQL_CHARSET); | |
75ca1986 | 45 | // db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET); |
bddc9788 | 46 | } |
1f2b01ed AD |
47 | } |
48 | ||
d16d57ff AD |
49 | // Purge all posts (random 30 feeds) |
50 | global_purge_old_posts($link, true, 30); | |
51 | ||
45004d43 AD |
52 | // Update all feeds needing a update. |
53 | update_daemon_common($link, $limit=0); | |
1f2b01ed | 54 | |
45004d43 | 55 | // Send feed digests by email if needed. |
99018440 | 56 | if (DAEMON_SENDS_DIGESTS) send_headlines_digests($link); |
9cd7c995 | 57 | |
1f2b01ed AD |
58 | db_close($link); |
59 | ||
cfa43e02 | 60 | unlink(LOCK_DIRECTORY . "/$lock_filename"); |
1f2b01ed | 61 | ?> |