This repository has been archived by the owner on Jul 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstd_rss_out.php
executable file
·88 lines (78 loc) · 3.99 KB
/
std_rss_out.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
function std_rss_out($data) {
$rtrn = '';
$rtrn .= '<?xml version="1.0" ?>'."\n";
$rtrn .= '<rss version="2.0" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/">'."\n";
$rtrn .= ' <channel>'."\n";
$rtrn .= ' <title>'.htmlspecialchars($data['title']).'</title>'."\n";
$rtrn .= ' <link>'.htmlspecialchars($data['link']).'</link>'."\n";
$rtrn .= ' <description>'.htmlspecialchars($data['description']).'</description>'."\n";
if($data['image'])
$rtrn .= ' <image>'."\n";
if($data['image']['link'])
$rtrn .= ' <link>'.htmlspecialchars($data['image']['link']).'</link>'."\n";
if($data['image']['url'])
$rtrn .= ' <url>'.htmlspecialchars($data['image']['url']).'</url>'."\n";
if($data['image']['title'])
$rtrn .= ' <title>'.htmlspecialchars($data['image']['title']).'</title>'."\n";
if($data['image'])
$rtrn .= ' </image>'."\n";
if($data['language'])
$rtrn .= ' <language>'.htmlspecialchars($data['language']).'</language>'."\n";
if($data['copyright'])
$rtrn .= ' <copyright>'.htmlspecialchars($data['copyright']).'</copyright>'."\n";
if($data['webMaster'])
$rtrn .= ' <webMaster>'.htmlspecialchars($data['webMaster']).'</webMaster>'."\n";
if($data['dc:creator'])
$rtrn .= ' <dc:creator>'.htmlspecialchars($data['dc:creator']).'</dc:creator>'."\n";
if($data['pubDate'])
$rtrn .= ' <pubDate>'.htmlspecialchars(date('r',$data['pubDate'])).'</pubDate>'."\n";
if($data['category']) {
if(is_array($data['category'])) {
foreach($data['category'] as $cat)
$rtrn .= ' <category>'.htmlspecialchars($cat).'</category>'."\n";
} else
$rtrn .= ' <category>'.htmlspecialchars($data['category']).'</category>'."\n";
}//end if category
foreach($data['items'] as $id => $item) {
$rtrn .= ' <item>'."\n";
$rtrn .= ' <title>'.htmlspecialchars($item['title']).'</title>'."\n";
if($item['link'])
$rtrn .= ' <link>'.htmlspecialchars($item['link']).'</link>'."\n";
if(!$item['guid']) $item['guid'] = md5($item['title'].$item['description']);
if(preg_match('/^[^ ]+\.[a-z]{2,4}(\/[^ ]*)?$/',$item['guid']))
$rtrn .= ' <guid>'.htmlspecialchars($item['guid']).'</guid>'."\n";
else
$rtrn .= ' <guid isPermaLink="false">'.htmlspecialchars($item['guid']).'</guid>'."\n";
if($item['description'])
$rtrn .= ' <description>'.htmlspecialchars($item['description']).'</description>'."\n";
if($item['dc:creator'])
$rtrn .= ' <dc:creator>'.htmlspecialchars($item['dc:creator']).'</dc:creator>'."\n";
if($item['author'])
$rtrn .= ' <author>'.htmlspecialchars($item['author']).'</author>'."\n";
if($item['comments'])
$rtrn .= ' <comments>'.htmlspecialchars($item['comments']).'</comments>'."\n";
if($item['enclosure'])
$rtrn .= ' <enclosure>'.htmlspecialchars($item['enclosure']).'</enclosure>'."\n";
if($item['pubDate'])
$rtrn .= ' <pubDate>'.htmlspecialchars(date('r',$item['pubDate'])).'</pubDate>'."\n";
if($item['source'])
$rtrn .= ' <source>'.htmlspecialchars($item['source']).'</source>'."\n";
if($item['wfw:comment'])
$rtrn .= ' <wfw:comment>'.htmlspecialchars($item['wfw:comment']).'</wfw:comment>'."\n";
if($item['wfw:commentRss'])
$rtrn .= ' <wfw:commentRss>'.htmlspecialchars($item['wfw:commentRss']).'</wfw:commentRss>'."\n";
if($item['category']) {
if(is_array($item['category'])) {
foreach($item['category'] as $cat)
$rtrn .= ' <category>'.htmlspecialchars($cat).'</category>'."\n";
} else
$rtrn .= ' <category>'.htmlspecialchars($item['category']).'</category>'."\n";
}//end if category
$rtrn .= ' </item>'."\n";
}//end foreach items
$rtrn .= ' </channel>'."\n";
$rtrn .= '</rss>';
return $rtrn;
}//end function std_rss_out
?>