]> git.wh0rd.org - tt-rss.git/blobdiff - functions.php
getAllCounters: return category counters even if ENABLE_FEED_CATS is disabled (for...
[tt-rss.git] / functions.php
index f966a9a0a34f092dd31d86456ffd56932cf980ce..32c642a19c4e17c17be4f9e604617a2b6b4347ee 100644 (file)
 
        $config = HTMLPurifier_Config::createDefault();
 
-       $allowed = "p,a[href],i,em,b,strong,code,pre,blockquote,br,img[src|alt|title],ul,ol,li,h1,h2,h3,h4,s,object[classid|type|id|name|width|height|codebase],param[name|value]";
+       $allowed = "p,a[href],i,em,b,strong,code,pre,blockquote,br,img[src|alt|title],ul,ol,li,h1,h2,h3,h4,s,object[classid|type|id|name|width|height|codebase],param[name|value],table,tr,td";
 
        $config->set('HTML.SafeObject', true);
        @$config->set('HTML', 'Allowed', $allowed);
                                return; // no articles
                        }
 
-                       if ($pubsub_state != 2) {
+                       if ($pubsub_state != 2 && PUBSUBHUBBUB_ENABLED) {
+
+                               if ($debug_enabled) _debug("update_rss_feed: checking for PUSH hub...");
 
                                $feed_hub_url = false;
                                if ($use_simplepie) {
                                        }
                                }
 
+                               if ($debug_enabled) _debug("update_rss_feed: feed hub url: $feed_hub_url");
+
                                if ($feed_hub_url && function_exists('curl_init')) {
+
                                        $callback_url = get_self_url_prefix() .
                                                "/backend.php?op=pubsub&id=$feed";
 
                                        $s = new Subscriber($feed_hub_url, $callback_url);
 
-                                       $s->subscribe($fetch_url);
+                                       $rc = $s->subscribe($fetch_url);
+
+                                       if ($debug_enabled)
+                                               _debug("update_rss_feed: feed hub url found, subscribe request sent.");
 
                                        db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 1
                                                WHERE id = '$feed'");
                                        }
 
                                        $post_needs_update = false;
+                                       $update_insignificant = false;
 
-                                       if ($content_hash != $orig_content_hash) {
-//                                             print "<!-- [$entry_title] $content_hash vs $orig_content_hash -->";
+                                       if ($orig_num_comments != $num_comments) {
                                                $post_needs_update = true;
+                                               $update_insignificant = true;
                                        }
 
-                                       if (db_escape_string($orig_title) != $entry_title) {
+                                       if ($content_hash != $orig_content_hash) {
                                                $post_needs_update = true;
+                                               $update_insignificant = false;
                                        }
 
-                                       if ($orig_num_comments != $num_comments) {
+                                       if (db_escape_string($orig_title) != $entry_title) {
                                                $post_needs_update = true;
+                                               $update_insignificant = false;
                                        }
 
-//                                     this doesn't seem to be very reliable
-//
-//                                     if ($orig_timestamp != $entry_timestamp && !$orig_no_orig_date) {
-//                                             $post_needs_update = true;
-//                                     }
-
                                        // if post needs update, update it and mark all user entries
                                        // linking to this post as updated
                                        if ($post_needs_update) {
                                                                num_comments = '$num_comments'
                                                        WHERE id = '$ref_id'");
 
-                                               if ($mark_unread_on_update) {
-                                                       db_query($link, "UPDATE ttrss_user_entries
-                                                               SET last_read = null, unread = true WHERE ref_id = '$ref_id'");
-                                               } else if ($update_on_checksum_change) {
-                                                       db_query($link, "UPDATE ttrss_user_entries
-                                                               SET last_read = null WHERE ref_id = '$ref_id' AND unread = false");
+                                               if (!$update_insignificant) {
+                                                       if ($mark_unread_on_update) {
+                                                               db_query($link, "UPDATE ttrss_user_entries
+                                                                       SET last_read = null, unread = true WHERE ref_id = '$ref_id'");
+                                                       } else if ($update_on_checksum_change) {
+                                                               db_query($link, "UPDATE ttrss_user_entries
+                                                                       SET last_read = null WHERE ref_id = '$ref_id'
+                                                                               AND unread = false");
+                                                       }
                                                }
-
                                        }
                                }
 
                if (strchr($omode, "l")) $data = array_merge($data, getLabelCounters($link));
                if (strchr($omode, "f")) $data = array_merge($data, getFeedCounters($link, $active_feed));
                if (strchr($omode, "t")) $data = array_merge($data, getTagCounters($link));
-               if (strchr($omode, "c")) {
-                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
-                               $data = array_merge($data, getCategoryCounters($link));
-                       }
-               }
+               if (strchr($omode, "c")) $data = array_merge($data, getCategoryCounters($link));
 
                return $data;
        }
                $result = db_query($link, "SELECT feed_url, site_url, title, COUNT(id) AS subscribers
                        FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
                                WHERE tf.feed_url = ttrss_feeds.feed_url
-                               AND (private IS true OR feed_url LIKE '%:%@%/%'))
+                               AND (private IS true OR auth_login != '' OR auth_pass != '' OR feed_url LIKE '%:%@%/%'))
                                GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT 1000");
 
                db_query($link, "BEGIN");
 
                if ($query) {
                        if (DB_TYPE == "pgsql") {
-                               $query .= " AND ttrss_entries.date_entered > NOW() - INTERVAL '30 days'";
+                               $query = " ($query) AND ttrss_entries.date_entered > NOW() - INTERVAL '14 days'";
                        } else {
-                               $query .= " AND ttrss_entries.date_entered > DATE_SUB(NOW(), INTERVAL 30 DAY";
+                               $query = " ($query) AND ttrss_entries.date_entered > DATE_SUB(NOW(), INTERVAL 14 DAY";
                        }
                        $query .= " AND ";
                }
 
+
                return $query;
        }