]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
remove image.php; put cached image endpoint to public.php
[tt-rss.git] / include / rssfuncs.php
index cec44cd8eb54115b5266bd3f132da6e32430a85d..b285f74c0cf6694ec081a54a159ee4939b56333b 100644 (file)
 
                        if (!$registered_title || $registered_title == "[Unknown]") {
 
-                               $feed_title = db_escape_string($rss->get_title());
+                               $feed_title = db_escape_string(mb_substr($rss->get_title(), 0, 199));
 
                                if ($feed_title) {
                                        _debug("registering title: $feed_title", $debug_enabled);
                                        "link" => $entry_link,
                                        "tags" => $entry_tags,
                                        "author" => $entry_author,
+                                       "force_catchup" => false, // ugly hack for the time being
                                        "language" => $entry_language, // read only
                                        "feed" => array("id" => $feed,
                                                "fetch_url" => $fetch_url,
 
                                _debug("article hash: $entry_current_hash [stored=$entry_stored_hash]", $debug_enabled);
 
-                               if ($entry_current_hash == $entry_stored_hash) {
+                               if ($entry_current_hash == $entry_stored_hash && !isset($_REQUEST["force_rehash"])) {
                                        _debug("stored article seems up to date [IID: $base_entry_id], updating timestamp only", $debug_enabled);
 
                                        // we keep encountering the entry in feeds, so we need to
                                        db_query("UPDATE ttrss_entries SET date_updated = NOW()
                                                WHERE id = '$base_entry_id'");
 
-                                       continue;
+                    // if we allow duplicate posts, we have to continue to
+                    // create the user entries for this feed
+                    if (!get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
+                        continue;
+                    }
                                }
 
                                _debug("hash differs, applying plugin filters:", $debug_enabled);
                                $entry_author = db_escape_string($article["author"]);
                                $entry_link = db_escape_string($article["link"]);
                                $entry_content = $article["content"]; // escaped below
+                               $entry_force_catchup = $article["force_catchup"];
+
+                               _debug("force catchup: $entry_force_catchup");
 
                                if ($cache_images && is_writable(CACHE_DIR . '/images'))
                                        cache_images($entry_content, $site_url, $debug_enabled);
 
                                                _debug("user record not found, creating...", $debug_enabled);
 
-                                               if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
+                                               if ($score >= -500 && !find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) {
                                                        $unread = 'true';
                                                        $last_read_qpart = 'NULL';
                                                } else {
 
                                                // N-grams
 
-                                               if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
+                                               /* if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
 
                                                        $result = db_query("SELECT COUNT(*) AS similar FROM
                                                                        ttrss_entries,ttrss_user_entries
                                                        if ($ngram_similar > 0) {
                                                                $unread = 'false';
                                                        }
-                                               }
+                                               } */
 
                                                $last_marked = ($marked == 'true') ? 'NOW()' : 'NULL';
                                                $last_published = ($published == 'true') ? 'NOW()' : 'NULL';
                                        db_query("COMMIT");
                                }
 
-                               if (get_pref("AUTO_ASSIGN_LABELS", $owner_uid, false)) {
-                                       _debug("auto-assigning labels...", $debug_enabled);
-
-                                       foreach ($labels as $label) {
-                                               $caption = preg_quote($label["caption"]);
-
-                                               if ($caption && preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($entry_content) . " $entry_title")) {
-                                                       if (!labels_contains_caption($article_labels, $caption)) {
-                                                               label_add_article($entry_ref_id, $caption, $owner_uid);
-                                                       }
-                                               }
-                                       }
-                               }
-
                                _debug("article processed", $debug_enabled);
                        }
 
                                                file_put_contents($local_filename, $file_content);
                                        }
                                }
-
-                               /* if (file_exists($local_filename)) {
-                                       $entry->setAttribute('src', SELF_URL_PATH . '/image.php?url=' .
-                                               base64_encode($src));
-                               } */
                        }
                }
-
-               //$node = $doc->getElementsByTagName('body')->item(0);
-               //return $doc->saveXML($node);
        }
 
        function expire_error_log($debug) {