index.php
1 <?php
2
3 /*
4 popeliger Feedreader benutzt Sajax <http://www.modernmethod.com/sajax/>
5
6 20.07.2005 14:37, M. Kniebes <mk@kniebes.net>
7
8 */
9
10 require("incl_sajax.php");
11 require('magpierss-0.71.1/rss_fetch.inc');
12
13 /* opeml datei parsen und liste der feeds erstellen
14 */
15 $opmlfile = "feeds.opml";
16 $parser = xml_parser_create();
17 $data = implode("", file($opmlfile));
18
19 xml_parse_into_struct($parser, $data, $d_ar, $i_ar);
20 $feeds = array();
21
22 foreach ($d_ar as $element) {
23 if ($element["tag"] == "OUTLINE") {
24 $blog = $element["attributes"]["TITLE"];
25 $url = $element["attributes"]["XMLURL"];
26 $feeds["$blog"] = $url;
27 }
28 }
29
30 $fl = array();
31 $fl[] = '<ul>';
32
33 foreach ($feeds as $key => $val) {
34 $blog = base64_encode( $key );
35 $fl[] = '<li><a href="javascript:start_fetchfeed(\'' .
36 $blog .
37 '\',do_fetchfeed_cb)">' .
38 $key .
39 '</a></li>';
40 }
41 $fl[] = '</ul>';
42
43
44 rs_init();
45 rs_export("fetchfeed");
46 rs_handle_client_request();
47
48
49 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
50 <html xmlns="http://www.w3.org/1999/xhtml">
51 <head>
52 <title>RSSReader</title>
53 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
54 <script type="text/javascript">
55
56 <?php rs_show_javascript(); ?>
57
58 function do_fetchfeed_cb(feed) {
59 var sh = document.getElementById("feed");
60 sh.style.display = "block";
61 sh.innerHTML = feed;
62 }
63
64 function start_fetchfeed( key ) {
65 var sh = document.getElementById("feed");
66 sh.innerHTML = '<div id="progress"> </div>';
67 x_fetchfeed( key, do_fetchfeed_cb );
68 }
69
70
71 </script>
72
73 <style type="text/css">
74 body {
75 padding: 0px;
76 margin: 0px;
77 background-color: #F4F4F3;
78 background-image: url(/_img/bg-body-1.gif);
79 background-repeat: repeat-x;
80 background-attachment: fixed;
81 font: 0.75em/1.7em "trebuchet ms", Arial, Helvetica, Sans-Seif;
82 color: #000;
83 }
84 #feed {
85 position: absolute;
86 top: 75px;
87 left: 350px;
88 width: 550px;
89 height: 500px;
90 background-color: #F4F4F3;
91 border-top: 9px solid #949D8C;
92 overflow: auto;
93 background-color: #F4F4F3;
94
95 }
96 #liste {
97 position: absolute;
98 top: 75px;
99 left: 50px;
100 width: 250px;
101 height: 500px;
102 border-top: 9px solid #949D8C;
103 padding: 5px;
104 overflow: auto;
105 background-color: #F4F4F3;
106 }
107 html>body #liste {
108 position: fixed;
109 }
110 #waiting {
111 padding: 50px 0 0 250px;
112 }
113 h1 {
114 position:absolute;
115 top: 30px;
116 left: 50px;
117 color: #000;
118 margin: 0;
119 padding: 0;
120 font-size: 1em;
121 letter-spacing: 7px;
122 }
123 h2 {
124 color: #000;
125 font-size: 1em;
126 font-weight: bold;
127 padding: 1px 10px;
128 margin: 0;
129 letter-spacing: 3px;
130 }
131 #version {
132 font-size: 0.9em;
133 letter-spacing: 0px;
134 padding-left: 10px;
135 color: #666;
136 }
137 #version:before {
138 content: "( ";
139 }
140 #version:after {
141 content: " )";
142 }
143 #progress {
144 width: 100%;
145 height: 100px;
146 background-image: url(progress.gif);
147 background-repeat: no-repeat;
148 background-position: center center;
149 }
150 p {
151 padding: 1px 10px;
152 margin: 0;
153 }
154 a {
155 text-decoration: none;
156 color: #000;
157 }
158 .content a {
159 text-decoration: underline;
160 color: #000;
161 }
162 h2 a {
163 color: #000;
164 }
165 a:hover {
166 color: #060;
167 }
168 .content {
169 padding-left: 30px;
170 }
171 .entry {
172 padding: 0 0 60px 0;
173 }
174 #liste ul {
175 list-style-type: none;
176 margin-left: 7px;
177 padding-left: 7px;
178 }
179 </style>
180
181 </head>
182 <body>
183 <h1>RSSReader <span id="version">Version 0</span></h1>
184 <div id="liste"><h2>Feedliste</h2>
185 <ul>
186 <li>OPML Datei: <a href="<?=$opmlfile?>"><?=$opmlfile?></a></li>
187 <li><a href="source.php">Quellcode</a></li>
188 </ul>
189 <?=implode("\n", $fl)?>
190 </div>
191 <div id="feed" name="feed"><p style="text-align: center;">Feed auswählen</p></div>
192 </body>
193 </html>
194 <?php
195
196 // --------------------------------------------------------------------
197
198 function fetchfeed($blog)
199 {
200 global $feeds;
201
202 $blog = base64_decode( $blog );
203 $o = array();
204
205 if (isset($feeds["$blog"])) {
206 $url = $feeds["$blog"];
207 $rss = @fetch_rss($url);
208 $o[] = '<h1>'.$rss->title.'</h1>';
209
210 if ($rss) {
211 foreach ($rss->items as $this_item) {
212 $content = isset($this_item["content"]["encoded"])
213 ? utf8_encode($this_item["content"]["encoded"])
214 : utf8_encode($this_item["description"]);
215
216 $title = utf8_encode($this_item["title"]);
217 $o[] = '<div class="entry">';
218 $o[] = '<h2><a href="' . $this_item["link"] .'">' . $title . '</a></h2>';
219 $o[] = '<p style="text-align:right;"><a href="' . $this["link"] . '">' . $this["dc"]["date"] . '</a></p>';
220 $o[] = '<div class="content">' . $content . '</div>';
221 $o[] = '</div>';
222 }
223 } else {
224 $o[] = '<p>Der Feed funzt nicht.</p>';
225 }
226 }
227 return implode("\n", $o);
228 }
229
230 // --------------------------------------------------------------------
231
232 ?>