]> git.wh0rd.org - tt-rss.git/blobdiff - classes/rssutils.php
Merge branch 'i18n' of HenryQW/tt-rss into master
[tt-rss.git] / classes / rssutils.php
index af5fd057ce33278a0d1988a88a5dd0f9a116f93e..094b294084f2b8509c70cbbc7199b692a84852cd 100755 (executable)
@@ -187,7 +187,12 @@ class RSSUtils {
                                        array_push($batch_owners, $tline["owner_uid"]);
 
                                $fstarted = microtime(true);
-                               RSSUtils::update_rss_feed($tline["id"], true, false);
+
+                               try {
+                                       RSSUtils::update_rss_feed($tline["id"], true, false);
+                               } catch (PDOException $e) {
+                                       Logger::get()->log_error(E_USER_NOTICE, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
+                               }
                                _debug_suppress(false);
 
                                _debug(sprintf("    %.4f (sec)", microtime(true) - $fstarted));
@@ -218,24 +223,15 @@ class RSSUtils {
 
                $pdo = Db::pdo();
 
-               $sth = $pdo->prepare("SELECT owner_uid,feed_url,auth_pass,auth_login,auth_pass_encrypted
+               $sth = $pdo->prepare("SELECT owner_uid,feed_url,auth_pass,auth_login
                                FROM ttrss_feeds WHERE id = ?");
                $sth->execute([$feed]);
 
                if ($row = $sth->fetch()) {
 
                        $owner_uid = $row["owner_uid"];
-
-                       $auth_pass_encrypted = $row["auth_pass_encrypted"];
-
                        $auth_login = $row["auth_login"];
                        $auth_pass = $row["auth_pass"];
-
-                       if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) {
-                               require_once "crypt.php";
-                               $auth_pass = decrypt_string($auth_pass);
-                       }
-
                        $fetch_url = $row["feed_url"];
 
                        $pluginhost = new PluginHost();
@@ -347,7 +343,6 @@ class RSSUtils {
 
                        $owner_uid = $row["owner_uid"];
                        $mark_unread_on_update = $row["mark_unread_on_update"];
-                       $auth_pass_encrypted = $row["auth_pass_encrypted"];
 
                        $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_update_started = NOW()
                                WHERE id = ?");
@@ -355,16 +350,11 @@ class RSSUtils {
 
                        $auth_login = $row["auth_login"];
                        $auth_pass = $row["auth_pass"];
-
-                       if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) {
-                               require_once "crypt.php";
-                               $auth_pass = decrypt_string($auth_pass);
-                       }
-
                        $stored_last_modified = $row["last_modified"];
                        $last_unconditional = $row["last_unconditional"];
                        $cache_images = $row["cache_images"];
                        $fetch_url = $row["feed_url"];
+
                        $feed_language = mb_strtolower($row["feed_language"]);
                        if (!$feed_language) $feed_language = 'english';
 
@@ -1075,7 +1065,7 @@ class RSSUtils {
                                }
 
                                $esth = $pdo->prepare("SELECT id FROM ttrss_enclosures
-                                               WHERE content_url = ? AND post_id = ?");
+                                               WHERE content_url = ? AND content_type = ? AND post_id = ?");
 
                                $usth = $pdo->prepare("INSERT INTO ttrss_enclosures
                                                        (content_url, content_type, title, duration, post_id, width, height) VALUES
@@ -1089,7 +1079,7 @@ class RSSUtils {
                                        $enc_width = intval($enc[4]);
                                        $enc_height = intval($enc[5]);
 
-                                       $esth->execute([$enc_url, $entry_ref_id]);
+                                       $esth->execute([$enc_url, $enc_type, $entry_ref_id]);
 
                                        if (!$esth->fetch()) {
                                                $usth->execute([$enc_url, $enc_type, (string)$enc_title, $enc_dur, $entry_ref_id, $enc_width, $enc_height]);
@@ -1228,7 +1218,7 @@ class RSSUtils {
                                        if ($file_content && strlen($file_content) > MIN_CACHE_FILE_SIZE) {
                                                file_put_contents($local_filename, $file_content);
                                        }
-                               } else {
+                               } else if (is_writable($local_filename)) {
                                        touch($local_filename);
                                }
                        }
@@ -1254,15 +1244,17 @@ class RSSUtils {
 
                                $local_filename = CACHE_DIR . "/images/" . sha1($src);
 
-                               if ($debug) _debug("cache_media: downloading: $src to $local_filename");
+                               if ($debug) _debug("cache_media: checking $src");
 
                                if (!file_exists($local_filename)) {
+                                       if ($debug) _debug("cache_media: downloading: $src to $local_filename");
+
                                        $file_content = fetch_file_contents($src);
 
                                        if ($file_content && strlen($file_content) > MIN_CACHE_FILE_SIZE) {
                                                file_put_contents($local_filename, $file_content);
                                        }
-                               } else {
+                               } else if (is_writable($local_filename)) {
                                        touch($local_filename);
                                }
                        }