69 lines
2.7 KiB
PHP
69 lines
2.7 KiB
PHP
<?php
|
|
// Full RSS Feed
|
|
// replaces article description with article contents
|
|
|
|
// Copyright ©️ 2019-2024 Scott Alfter
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining
|
|
// a copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
// the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be
|
|
// included in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
|
|
// implement a simple article cache in /tmp
|
|
function fetch_page($url)
|
|
{
|
|
$cachefile="/tmp/fullurl_".hash("sha256", $url).".html";
|
|
|
|
if (!file_exists($cachefile))
|
|
{
|
|
exec("/usr/bin/curl '".$url."' | /usr/local/bin/rdrview -H", $result);
|
|
$article="";
|
|
foreach ($result as $line)
|
|
$article=$article.$line."\n";
|
|
|
|
file_put_contents($cachefile, $article);
|
|
}
|
|
return file_get_contents($cachefile);
|
|
}
|
|
|
|
$url=$_GET["url"];
|
|
$ch=curl_init(); // 8 Apr 25: market-ticker.org wants a user agent set
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0");
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$feed=new SimpleXmlElement(curl_exec($ch)); // read feed into object
|
|
curl_close($ch);
|
|
|
|
// type 1
|
|
foreach ($feed->item as $entry) // fix up each entry
|
|
{
|
|
if (substr($entry->link, 0, 21)=="http://minx.cc/?post=") // fix AoSHQ links
|
|
$entry->link="http://acecomments.mu.nu/?post=".substr($entry->link, 21);
|
|
|
|
$entry->description=fetch_page($entry->link);
|
|
}
|
|
|
|
// type 2
|
|
foreach ($feed->channel->item as $entry) // fix up each entry
|
|
$entry->description=fetch_page($entry->link);
|
|
|
|
header("Content-Type: application/rss+xml");
|
|
echo $feed->asXML(); // write the modified feed back out
|
|
?>
|