This repository has been archived by the owner on Jul 25, 2018. It is now read-only.
/
yubnub-mkrss.php
executable file
·52 lines (43 loc) · 1.89 KB
/
yubnub-mkrss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
if($_REQUEST['get'])
$_REQUEST['data'] = file_get_contents($_REQUEST['get']);
if(!$_REQUEST['data']) {
header('Content-Type: text/plain');
header('Location: http://yubnub.org/kernel/man?args=mkrss',TRUE,303);
exit;
}//end if ! data
header('Content-Type: application/xml;charset=utf-8');
$_REQUEST['title'] = $_REQUEST['title'] ? $_REQUEST['title'] : ($_REQUEST['url'] ? $_REQUEST['url'] : 'A mkrss feed');
$_REQUEST['url'] = $_REQUEST['url'] ? $_REQUEST['url'] : 'http://yubnub.org/kernel/man?args=mkrss';
require('yubnub2phparray.php');
$items = yubnub2phparray($_REQUEST['data']);
echo '<?xml version="1.0" ?>'."\n";
?>
<rss version="2.0">
<channel>
<title><?php echo htmlspecialchars(iconv('', 'UTF-8', $_REQUEST['title'])); ?></title>
<link><?php echo htmlspecialchars(iconv('', 'UTF-8', $_REQUEST['url'])); ?></link>
<description>Powered by mkrss - a YubNub command</description>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>PHP script</generator>
<?php
foreach($items as $item) {
$link = array();
preg_match('/<a .*?href="(.*?)"/',$item,$link['url']);
$link['url'] = $link['url'][1];
preg_match('/<a.*?>(.*?)<\/a>/',$item,$link['text']);
$link['text'] = $link['text'][1];
if(!strip_tags($link['text'])) $link['text'] = $item;
echo ' <item>'."\n";
echo ' <title>'.htmlspecialchars(strip_tags($link['text'])).'</title>'."\n";
if($link['url']) {
echo ' <link>'.htmlspecialchars(iconv('', 'UTF-8', $link['url'])).'</link>'."\n";
echo ' <guid>'.htmlspecialchars(iconv('', 'UTF-8', $link['url'])).'</guid>'."\n";
} else
echo ' <guid>'.md5($link['text'].$item).'</guid>'."\n";
echo ' <description>'.htmlspecialchars(iconv('', 'UTF-8', $item)).'</description>'."\n";
echo ' </item>'."\n";
}//end foreach struct
?>
</channel>
</rss>