From 4e508f419b77e3ab8f3d3c8db9a09e32ca303a0a Mon Sep 17 00:00:00 2001 From: SansGuidon Date: Thu, 9 Jan 2025 12:27:48 +0000 Subject: [PATCH] del(indieblog) remove old feed generator --- cron/generate_indieblog_rss.php | 89 --------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 cron/generate_indieblog_rss.php diff --git a/cron/generate_indieblog_rss.php b/cron/generate_indieblog_rss.php deleted file mode 100644 index b7e04f6..0000000 --- a/cron/generate_indieblog_rss.php +++ /dev/null @@ -1,89 +0,0 @@ -= $recentCutoff && - !in_array($item['itemid'], $includedIds); -}); - -// Sort items by publication date (newest first) -usort($recentItems, fn($a, $b) => $b['published'] <=> $a['published']); - -// Generate RSS feed -$rss = new SimpleXMLElement(''); -$channel = $rss->addChild('channel'); -$channel->addChild('title', 'IndieBlog Feed (Recent)'); -$channel->addChild('link', 'https://indieblog.page/'); -$channel->addChild('description', 'RSS feed of articles published in the last 24 hours'); -$channel->addChild('language', 'en'); - -// Add recent items to RSS feed -$newEntries = []; -foreach ($recentItems as $item) { - $rssItem = $channel->addChild('item'); - $rssItem->addChild('title', htmlspecialchars($item['itemtitle'] ?? 'No title')); - $rssItem->addChild('link', htmlspecialchars($item['itemurl'] ?? '')); - $rssItem->addChild('pubDate', date(DATE_RSS, $item['published'])); - - // Fetch original RSS feed content for the entry - $originalContent = fetchOriginalContent($item['itemurl']); - $rssItem->addChild('description', htmlspecialchars($originalContent ?? $item['feedtitle'] ?? 'No content')); - - $newEntries[] = $item['itemid']; -} - -// Update cache with newly processed IDs -if (!empty($newEntries)) { - file_put_contents($cacheFile, implode("\n", array_merge($includedIds, $newEntries))); -} - -// Save RSS feed -$rss->asXML($rssFile); - -/** - * Fetches the original content from a given URL. - * - * @param string $url The URL of the article to fetch. - * @return string|null The extracted content, or null if unavailable. - */ -function fetchOriginalContent(string $url): ?string -{ - $html = @file_get_contents($url); - if (!$html) { - return null; - } - - // Extract content between tags (basic extraction, adapt as needed) - if (preg_match('/(.*?)<\/body>/si', $html, $matches)) { - // Clean HTML content (strip tags, keep minimal formatting) - return strip_tags($matches[1], '


'); - } - - return null; -}