+ function hook_house_keeping() {
+ $files = glob($this->cache_dir . "/*.png");
+
+ $last_article_id = 0;
+ $article_exists = 1;
+
+ foreach ($files as $file) {
+ list ($article_id, $hash) = explode("-", basename($file));
+
+ if ($article_id != $last_article_id) {
+ $last_article_id = $article_id;
+ $article_id = db_escape_string($article_id);
+
+ $result = db_query("SELECT id FROM ttrss_entries WHERE id = " . $article_id);
+
+ $article_exists = db_num_rows($result) > 0;
+ }
+
+ if (!$article_exists) {
+ unlink($file);
+ }
+ }
+ }
+