]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
image cache: do not try to cache data: schema urls; add caching of html5 video conten...
[tt-rss.git] / include / rssfuncs.php
index 3f4a0aef23ed3b912044563515abf4a79637df80..1f38091b6126dc64c84d1aa7dfd37e4f75bb0ea0 100644 (file)
                $auth_login = db_fetch_result($result, 0, "auth_login");
                $auth_pass = db_fetch_result($result, 0, "auth_pass");
 
-               if ($auth_pass_encrypted) {
+               if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) {
                        require_once "crypt.php";
                        $auth_pass = decrypt_string($auth_pass);
                }
 
                $feed_data = fetch_file_contents($fetch_url, false,
                        $auth_login, $auth_pass, false,
-                       FEED_FETCH_TIMEOUT_TIMEOUT,
+                       FEED_FETCH_TIMEOUT,
                        0);
 
                global $fetch_curl_used;
                $auth_login = db_fetch_result($result, 0, "auth_login");
                $auth_pass = db_fetch_result($result, 0, "auth_pass");
 
-               if ($auth_pass_encrypted) {
+               if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) {
                        require_once "crypt.php";
                        $auth_pass = decrypt_string($auth_pass);
                }
                                if ($feed_hub_url && $feed_self_url && function_exists('curl_init') &&
                                        !ini_get("open_basedir")) {
 
-                                       require_once 'lib/pubsubhubbub/subscriber.php';
+                                       require_once 'lib/pubsubhubbub/Subscriber.php';
 
                                        $callback_url = get_self_url_prefix() .
                                                "/public.php?op=pubsub&id=$feed";
 
-                                       $s = new Subscriber($feed_hub_url, $callback_url);
+                                       $s = new Pubsubhubbub\Subscriber\Subscriber($feed_hub_url, $callback_url);
 
                                        $rc = $s->subscribe($feed_self_url);
 
                                                                "/public.php?op=rss&id=-2&key=" .
                                                                get_feed_access_key(-2, false, $owner_uid);
 
-                                                       $p = new Publisher(PUBSUBHUBBUB_HUB);
+                                                       $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
 
                                                        /* $pubsub_result = */ $p->publish_update($rss_link);
                                                }
                $doc->loadHTML($charset_hack . $html);
                $xpath = new DOMXPath($doc);
 
-               $entries = $xpath->query('(//img[@src])');
+               $entries = $xpath->query('(//img[@src])|(//video/source[@src])');
 
                foreach ($entries as $entry) {
-                       if ($entry->hasAttribute('src')) {
+                       if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) {
                                $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
 
-                               $local_filename = CACHE_DIR . "/images/" . sha1($src) . ".png";
+                               $extension = $entry->tagName == 'source' ? '.mp4' : '.png';
+                               $local_filename = CACHE_DIR . "/images/" . sha1($src) . $extension;
 
                                if ($debug) _debug("cache_images: downloading: $src to $local_filename");