]>
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'); |
1f2b01ed | 7 | |
de696427 AD |
8 | define('DISABLE_SESSIONS', true); |
9 | ||
1f2b01ed AD |
10 | require_once "sanity_check.php"; |
11 | require_once "config.php"; | |
12 | require_once "db.php"; | |
13 | require_once "db-prefs.php"; | |
14 | require_once "functions.php"; | |
31a6d42d AD |
15 | |
16 | $lock_filename = "update_feeds.lock"; | |
17 | ||
18 | $lock_handle = make_lockfile($lock_filename); | |
19 | ||
20 | if (!$lock_handle) { | |
21 | die("error: Can't create lockfile ($lock_filename). ". | |
22 | "Maybe another process is already running.\n"); | |
23 | } | |
1f2b01ed AD |
24 | |
25 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
26 | ||
27 | if (!$link) { | |
28 | if (DB_TYPE == "mysql") { | |
29 | print mysql_error(); | |
30 | } | |
31 | // PG seems to display its own errors just fine by default. | |
32 | return; | |
33 | } | |
34 | ||
35 | if (DB_TYPE == "pgsql") { | |
36 | pg_query("set client_encoding = 'utf-8'"); | |
ef063748 | 37 | pg_set_client_encoding("UNICODE"); |
70dcff6b | 38 | } else { |
bddc9788 AD |
39 | if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
40 | db_query($link, "SET NAMES " . MYSQL_CHARSET); | |
75ca1986 | 41 | // db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET); |
bddc9788 | 42 | } |
1f2b01ed AD |
43 | } |
44 | ||
45 | $result = db_query($link, "SELECT id FROM ttrss_users"); | |
46 | ||
47 | while ($line = db_fetch_assoc($result)) { | |
48 | $user_id = $line["id"]; | |
e7dfc9c9 | 49 | initialize_user_prefs($link, $user_id); |
1f2b01ed AD |
50 | update_all_feeds($link, false, $user_id, true); |
51 | } | |
52 | ||
99018440 | 53 | if (DAEMON_SENDS_DIGESTS) send_headlines_digests($link); |
9cd7c995 | 54 | |
1f2b01ed AD |
55 | db_close($link); |
56 | ||
31a6d42d | 57 | unlink($lock_filename); |
1f2b01ed | 58 | ?> |