]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
Merge branch 'master' of github.com:gothfox/Tiny-Tiny-RSS
[tt-rss.git] / include / rssfuncs.php
index 0ecab6a257c8419b354c73be1c2c1538ee8fcb9a..08bf1fe6dbb217751f7da0bfb388bcc614d06ad7 100644 (file)
                        return false;
                }
 
+               // set last update to now so if anything *simplepie* crashes later we won't be
+               // continuously failing on the same feed
+               db_query("UPDATE ttrss_feeds SET last_updated = NOW() WHERE id = '$feed'");
+
                $last_updated = db_fetch_result($result, 0, "last_updated");
                $last_article_timestamp = @strtotime(db_fetch_result($result, 0, "last_article_timestamp"));
                $owner_uid = db_fetch_result($result, 0, "owner_uid");
                                _debug("date $entry_timestamp [$entry_timestamp_fmt]", $debug_enabled);
 
                                $entry_title = html_entity_decode($item->get_title(), ENT_COMPAT, 'UTF-8');
+                               $entry_title = decode_numeric_entities($entry_title);
 
                                $entry_link = rewrite_relative_url($site_url, $item->get_link());
 
 
                _debug("Cleaned $rc cached tags.");
        }
+
+       function utf8_entity_decode($entity){
+               $convmap = array(0x0, 0x10000, 0, 0xfffff);
+               return mb_decode_numericentity($entity, $convmap, 'UTF-8');
+       }
+
+       function decode_numeric_entities($body) {
+               $body = preg_replace('/&#\d{2,5};/ue', "utf8_entity_decode('$0')", $body );
+               $body = preg_replace('/&#x([a-fA-F0-7]{2,8});/ue', "utf8_entity_decode('&#'.hexdec('$1').';')", $body );
+               return $body;
+       }
 ?>