Siteβ―Builder
Editing:
rss-prox1y.php
writable 0666
<?php /************************************************************************* * RSSβPROXY β /social/rss-proxy.php?slug=rfsafe * * βΊ Returns: {items:[{title,link,date}], url:"β¦"} (JSON) * βΊ Max 5 items, 15β―s absolute timeout * βΊ Open proxy is NOT allowed β it only serves feeds that belong * to slugs already present in /social/<slug>/social.json or * new-social.json. *************************************************************************/ declare(strict_types=1); header('Content-Type: application/json; charset=utf-8'); set_time_limit(15); $slug = preg_replace('/[^a-z0-9_]/i','', $_GET['slug'] ?? ''); if (!$slug) { http_response_code(400); echo '{"error":"bad slug"}'; exit; } /* ---------- find profile JSON ---------- */ $dir = $_SERVER['DOCUMENT_ROOT']."/social/$slug"; $profileFile = is_file("$dir/social.json") ? "$dir/social.json" : (is_file("$dir/new-social.json") ? "$dir/new-social.json" : ''); if (!$profileFile) { http_response_code(404); echo '{"error":"profile not found"}'; exit; } $profile = json_decode(file_get_contents($profileFile), true); $channels = $profile['channels'] ?? []; /* ---------- choose RSS URL ---------- */ $rssUrl = $profile['rss'] ?? null; // explicit override $website= $profile['website'] ?? ''; if (!$rssUrl && $website) { // WordPress fallback $base = rtrim($website,'/'); foreach (["$base/feed/","$base/?feed=rss2"] as $c) { $xml = @simplexml_load_file($c, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml && stripos((string)($xml->channel->generator ?? ''), 'wordpress') !== false) { $rssUrl = $c; break; } } } /* hardβcoded dev test for rfsafe */ if (!$rssUrl && $slug === 'rfsafe') { $rssUrl = 'https://www.rfsafe.com/feed/'; } if (!$rssUrl) { echo '{"items":[],"url":null}'; exit; } /* ---------- fetch & parse ---------- */ $items = []; $xml = @simplexml_load_file($rssUrl, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml && isset($xml->channel->item)) { foreach ($xml->channel->item as $it) { $items[] = [ 'title'=> (string)$it->title, 'link' => (string)$it->link, 'date' => (string)$it->pubDate ]; if (count($items)===5) break; } } echo json_encode(['items'=>$items,'url'=>$rssUrl], JSON_UNESCAPED_SLASHES);
Save changes
Create folder
writable 0777
Create
Cancel