]> git.wh0rd.org - tt-rss.git/blobdiff - functions.php
simplepie: enable https and digest auth
[tt-rss.git] / functions.php
index ac2699c95c7c10cf129c3b517ceb2bb962b8a69e..5ab98829c0a9f2f41866d3e11f4e5de1c1f69351 100644 (file)
@@ -13,6 +13,7 @@
                                        "auto"  => "Detect automatically",
                                        "en_US" => "English",
                                        "fr_FR" => "Français",
+                                       "nb_NO" => "Norsk Bokmål",
                                        "ru_RU" => "Русский",
                                        "pt_BR" => "Portuguese/Brazil",
                                        "zh_CN" => "Simplified Chinese");
@@ -76,6 +77,7 @@
 
        function _debug($msg) {
                $ts = strftime("%H:%M:%S", time());
+               $ts = "$ts/" . posix_getpid();
                print "[$ts] $msg\n";
        }
 
                        _debug("update_rss_feed: start");
                }
 
-               $result = db_query($link, "SELECT id,update_interval,auth_login,auth_pass,cache_images
-                       FROM ttrss_feeds WHERE id = '$feed'");
+               if (!$ignore_daemon) {
+
+                       if (DB_TYPE == "pgsql") {
+                                       $updstart_thresh_qpart = "(ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '120 seconds')";
+                               } else {
+                                       $updstart_thresh_qpart = "(ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 120 SECOND))";
+                               }                       
+       
+                       $result = db_query($link, "SELECT id,update_interval,auth_login,
+                               auth_pass,cache_images
+                               FROM ttrss_feeds WHERE id = '$feed' AND $updstart_thresh_qpart");
+
+               } else {
+
+                       $result = db_query($link, "SELECT id,update_interval,auth_login,
+                               auth_pass,cache_images
+                               FROM ttrss_feeds WHERE id = '$feed'");
+
+               }
 
                if (db_num_rows($result) == 0) {
                        if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
-                               _debug("update_rss_feed: feed $feed [$feed_url] NOT FOUND");
+                               _debug("update_rss_feed: feed $feed [$feed_url] NOT FOUND/SKIPPED");
                        }               
                        return;
                }
 
+               db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW()
+                       WHERE id = '$feed'");
+
                $auth_login = db_fetch_result($result, 0, "auth_login");
                $auth_pass = db_fetch_result($result, 0, "auth_pass");
 
 
                                        $additional_tags = array();
                                        $additional_tags_src = $item->get_categories();
-
+                                       
                                        if (is_array($additional_tags_src)) {
                                                foreach ($additional_tags_src as $tobj) {
                                                        array_push($additional_tags, $tobj->get_term());
                                if (ENABLE_SIMPLEPIE) {
                                        $encs = $item->get_enclosures();
 
-                                       foreach ($encs as $e) {
-                                               $e_item = array(
-                                                       $e->link, $e->type, $e->length);
-
-                                               array_push($enclosures, $e_item);
+                                       if (is_array($encs)) {
+                                               foreach ($encs as $e) {
+                                                       $e_item = array(
+                                                               $e->link, $e->type, $e->length);
+       
+                                                       array_push($enclosures, $e_item);
+                                               }
                                        }
 
                                } else {
        function file_is_locked($filename) {
                if (function_exists('flock')) {
                        error_reporting(0);
-                       $fp = fopen($filename, "r");
+                       $fp = fopen(LOCK_DIRECTORY . "/$filename", "r");
                        error_reporting(DEFAULT_ERROR_LEVEL);
                        if ($fp) {
                                if (flock($fp, LOCK_EX | LOCK_NB)) {
        }
 
        function make_lockfile($filename) {
-               $fp = fopen($filename, "w");
+               $fp = fopen(LOCK_DIRECTORY . "/$filename", "w");
 
                if (flock($fp, LOCK_EX | LOCK_NB)) {            
                        return $fp;
        }
 
        function make_stampfile($filename) {
-               $fp = fopen($filename, "w");
+               $fp = fopen(LOCK_DIRECTORY . "/$filename", "w");
 
                if (flock($fp, LOCK_EX | LOCK_NB)) {
                        fwrite($fp, time() . "\n");
        function read_stampfile($filename) {
 
                error_reporting(0);
-               $fp = fopen($filename, "r");
+               $fp = fopen(LOCK_DIRECTORY . "/$filename", "r");
                error_reporting (DEFAULT_ERROR_LEVEL);
 
                if (flock($fp, LOCK_EX)) {
                print "<param key=\"icons_location\" value=\"" . 
                        ICONS_URL . "\"/>";
 
+               print "<param key=\"hide_read_shows_special\" value=\"" . 
+                       (int) get_pref($link, "HIDE_READ_SHOWS_SPECIAL") . "\"/>";
+
                print "</init-params>";
        }
 
                                }
        
                                printFeedEntry($feed_id, $class, $feed, $unread, 
-                                       ICONS_DIR."/$feed_id.ico", $link, $rtl_content, 
+                                       ICONS_URL."/$feed_id.ico", $link, $rtl_content, 
                                        $last_updated, $line["last_error"]);
        
                                ++$lnum;