-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetrss.php
153 lines (123 loc) · 4.39 KB
/
getrss.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
header('Content-Type: text/html');
set_time_limit(20);
error_reporting(0);
$xml=$_GET["x"];
if ($xml=="") exit;
$width=$_GET["w"];
$height=$_GET["h"];
$border_color=$_GET["bc"];
$border_width=$_GET["bw"];
$background_color=$_GET["bgc"];
$maxitems=$_GET["m"];
$include_title=$_GET["it"];
$title=$_GET["t"];
$title_color=$_GET["tc"];
$title_size=$_GET["ts"];
$title_background=$_GET["tb"];
$include_link=$_GET["il"];
$link_color=$_GET["lc"];
$link_size=$_GET["ls"];
$link_bold=$_GET["lb"];
$include_description=$_GET["id"];
$description_color=$_GET["dc"];
$description_size=$_GET["ds"];
$include_date=$_GET["idt"];
$date_color=$_GET["dtc"];
$date_size=$_GET["dts"];
$title_style="color:#".$title_color."; font-size:".$title_size."px;";
$title_th_style="";
if ($title_background!="" && $title_background!="transparent")
$title_th_style="background-color:#".$title_background;
$item_style="color:#".$link_color."; font-size:".$link_size."px;";
if ($link_bold=="true")
$item_style=$item_style." font-weight:bold;";
$date_style="color:#".$date_color."; font-size:".$date_size."px;";
$description_style="color:#".$description_color."; font-size:".$description_size."px;";
$xmlDoc = new DOMDocument();
if (!$xmlDoc->load($xml, LIBXML_NOERROR))
{
echo 'Failed to open the RSS feed.';
exit;
}
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;
if ($title!="" && $title!="(default)")
$channel_title=$title;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$xmlDoc->actualEncoding ?>" />
<style type = "text/css">
html {border: 0; padding:0; margin:0;}
</style>
</head>
<body style = "border:0; padding:0; margin:0; overflow-y:auto; overflow-x:hidden; <?=($background_color!="transparent" ? "background:#".$background_color : "")?>">
<table border="0" cellpadding="2" cellspacing="2" width="100%" style="table-layout:fixed;margin:0;padding:0;">
<?php
if ($include_title!="false")
{
?>
<tr><th style="<?=$title_th_style ?>"><span style="<?=$title_style ?>"><?=$channel_title ?></span></th></tr>
<?php
}
?>
<?php
$x=$xmlDoc->getElementsByTagName('item');
$n=$x->length;
if ($maxitems<$n)
$n=$maxitems;
for ($i=0; $i<$n; $i++)
{
$item_title=$x->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$item_link=$x->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
$item_desc=$item_title;
if ($x->item($i)->getElementsByTagName('description') != NULL)
if ($x->item($i)->getElementsByTagName('description')->item(0)->childNodes != NULL)
$item_desc=$x->item($i)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;
$item_date=$x->item($i)->getElementsByTagName('pubDate')->item(0)->childNodes->item(0)->nodeValue;
if ($item_title=="")
break;
$item_desc=str_replace('<br clear="all"/>','',$item_desc);
$item_desc=str_replace('<br clear="both"/>','',$item_desc);
$item_desc=str_replace('<br clear="all"/>','',$item_desc);
$item_desc=str_replace('<br clear="both"/>','',$item_desc);
$item_desc=str_replace('<br clear="all" />','',$item_desc);
$item_desc=str_replace('<br clear="both" />','',$item_desc);
$item_desc=str_replace('<br style="clear: both;"/>','',$item_desc);
$item_desc=str_replace('<br style="clear: all;"/>','',$item_desc);
$item_desc=str_replace('<br style="clear: both;" />','',$item_desc);
$item_desc=str_replace('<br style="clear: all;" />','',$item_desc);
$item_desc=str_replace('<br clear="both" style="clear: both;"/>','',$item_desc);
$item_desc=str_replace('<br clear="all" style="clear: all;"/>','',$item_desc);
$item_desc=str_replace('<a ','<a target="_blank" ',$item_desc);
if ($include_link=="true")
{
?>
<tr><td><a href="<?=$item_link ?>" target="_blank" style="<?=$item_style ?>"><?=$item_title ?></a></td></tr>
<?php
}
if ($include_date=="true")
{
$item_date_str = $item_date;
?>
<tr><td><span style="<?=$date_style ?>"><?=$item_date_str ?></span></td></tr>
<?php
}
if ($include_description=="true")
{
?>
<tr><td><span style="<?=$description_style ?>"><?=$item_desc ?></span></td></tr>
<?php
}
}
?>
<tr><td><br></td></tr>
</table>
</body>
</html>