]> git.wh0rd.org Git - tt-rss.git/blob - update_feeds.php
tweak infscroll
[tt-rss.git] / update_feeds.php
1 #!/usr/bin/php
2 <?php
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');
6         define('SIMPLEPIE_CACHE_DIR',   '/var/tmp/simplepie-ttrss-cache-cli');
7
8         define('DISABLE_SESSIONS', true);
9
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";
15         require_once "magpierss/rss_fetch.inc";
16
17         $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
18
19         if (!$link) {
20                 if (DB_TYPE == "mysql") {
21                         print mysql_error();
22                 }
23                 // PG seems to display its own errors just fine by default.             
24                 return;
25         }
26
27         if (DB_TYPE == "pgsql") {
28                 pg_query("set client_encoding = 'utf-8'");
29                 pg_set_client_encoding("UNICODE");
30         } else {
31                 if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
32                         db_query($link, "SET NAMES " . MYSQL_CHARSET);
33 //                      db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
34                 }
35         }
36
37         $result = db_query($link, "SELECT id FROM ttrss_users");
38
39         while ($line = db_fetch_assoc($result)) {
40                         $user_id = $line["id"];
41                         initialize_user_prefs($link, $user_id);
42                         update_all_feeds($link, false, $user_id, true);
43         }
44
45         if (DAEMON_SENDS_DIGESTS) send_headlines_digests($link);
46
47         db_close($link);
48
49 ?>