]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | <? |
a2015351 | 2 | // header("Content-Type: application/xml"); |
1cd17194 | 3 | |
82baad4a AD |
4 | require_once "config.php"; |
5 | require_once "functions.php"; | |
6 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 7 | |
f07c0eb4 AD |
8 | error_reporting(0); |
9 | ||
d76a3b03 AD |
10 | $link = pg_connect(DB_CONN); |
11 | ||
f07c0eb4 AD |
12 | error_reporting (E_ERROR | E_WARNING | E_PARSE); |
13 | ||
14 | if (!$link) { | |
15 | print "Could not connect to database. Please check local configuration."; | |
16 | return; | |
17 | } | |
18 | ||
d76a3b03 AD |
19 | pg_query("set client_encoding = 'utf-8'"); |
20 | ||
6f428bc5 | 21 | $op = $_GET["op"]; |
331900c6 | 22 | $fetch = $_GET["fetch"]; |
175847de | 23 | |
c3b81db0 | 24 | function outputFeedList($link) { |
175847de | 25 | |
c3b81db0 | 26 | $result = pg_query($link, "SELECT *, |
d76a3b03 AD |
27 | (SELECT count(id) FROM ttrss_entries |
28 | WHERE feed_id = ttrss_feeds.id) AS total, | |
29 | (SELECT count(id) FROM ttrss_entries | |
30 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
31 | FROM ttrss_feeds ORDER BY title"); | |
1cd17194 | 32 | |
a3ee2a38 | 33 | print "<table width=\"100%\" class=\"feeds\" id=\"feedsList\">"; |
1cd17194 AD |
34 | |
35 | $lnum = 0; | |
36 | ||
76798ff3 AD |
37 | $total_unread = 0; |
38 | ||
6f428bc5 | 39 | while ($line = pg_fetch_assoc($result)) { |
a1a8a2be | 40 | |
6f428bc5 | 41 | $feed = $line["title"]; |
2c1dd701 | 42 | $feed_id = $line["id"]; |
13ad9102 AD |
43 | |
44 | $subop = $_GET["subop"]; | |
2c1dd701 | 45 | |
d76a3b03 AD |
46 | $total = $line["total"]; |
47 | $unread = $line["unread"]; | |
48 | ||
1cd17194 | 49 | $class = ($lnum % 2) ? "even" : "odd"; |
a1a8a2be AD |
50 | |
51 | if ($unread > 0) $class .= "Unread"; | |
52 | ||
76798ff3 AD |
53 | $total_unread += $unread; |
54 | ||
a1a8a2be AD |
55 | print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; |
56 | ||
78800912 | 57 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
13ad9102 AD |
58 | |
59 | if ($subop != "piggie") { | |
60 | ||
61 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
62 | $feed_icon = "<img width=\"16\" height=\"16\" | |
63 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
64 | } else { | |
65 | $feed_icon = " "; | |
66 | } | |
78800912 | 67 | } else { |
13ad9102 AD |
68 | $feed_icon = "<img width=\"16\" height=\"16\" |
69 | src=\"http://madoka.spb.ru/stuff/fox/tiny_piggie.png\">"; | |
78800912 | 70 | } |
13ad9102 | 71 | |
a1a8a2be | 72 | $feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed</a>"; |
78800912 AD |
73 | if (ENABLE_FEED_ICONS) { |
74 | print "<td>$feed_icon</td>"; | |
75 | } | |
a1a8a2be | 76 | print "<td id=\"FEEDN-$feed_id\">$feed</td>"; |
c442fb6e AD |
77 | print "<td>"; |
78 | print "<span id=\"FEEDU-$feed_id\">$unread</span> / "; | |
79 | print "<span id=\"FEEDT-$feed_id\">$total</span>"; | |
80 | print "</td>"; | |
a1a8a2be AD |
81 | |
82 | print "</tr>"; | |
1cd17194 AD |
83 | ++$lnum; |
84 | } | |
85 | ||
476cac42 AD |
86 | // print "<tr><td class=\"footer\" colspan=\"3\"> |
87 | // <a href=\"javascript:update_feed_list(false,true)\">Update all feeds</a></td></tr>"; | |
88 | ||
89 | // print "<tr><td class=\"footer\" colspan=\"2\"> "; | |
90 | // print "</td></tr>"; | |
82baad4a | 91 | |
a1a8a2be | 92 | print "</table>"; |
1cd17194 | 93 | |
476cac42 AD |
94 | print "<p align=\"center\">All feeds: |
95 | <a class=\"button\" | |
cb246176 | 96 | href=\"javascript:scheduleFeedUpdate(true)\">Update</a>"; |
476cac42 AD |
97 | |
98 | print " <a class=\"button\" | |
99 | href=\"javascript:catchupAllFeeds()\">Mark as read</a></p>"; | |
100 | ||
76798ff3 AD |
101 | print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>"; |
102 | ||
c3b81db0 AD |
103 | |
104 | ||
105 | } | |
106 | ||
107 | ||
108 | if ($op == "rpc") { | |
109 | ||
110 | $subop = $_GET["subop"]; | |
111 | ||
9cfc649a AD |
112 | if ($subop == "getRelativeId") { |
113 | $mode = $_GET["mode"]; | |
114 | $id = $_GET["id"]; | |
115 | $feed_id = $_GET["feed"]; | |
116 | ||
117 | if ($id != 'false' && $feed_id != 'false') { | |
118 | ||
119 | if ($mode == 'next') { | |
120 | $check_qpart = "updated >= "; | |
121 | } else { | |
122 | $idcheck_qpart = "id < '$id'"; | |
123 | } | |
124 | ||
125 | $result = pg_query("SELECT id FROM ttrss_entries WHERE | |
126 | $check_qpart AND | |
127 | feed_id = '$feed_id' | |
128 | ORDER BY updated DESC LIMIT 1"); | |
129 | ||
130 | $result_id = pg_fetch_result($result, 0, "id"); | |
131 | ||
132 | print "M $mode : P $id -> P $result_id : F $feed_id"; | |
133 | ||
134 | } | |
135 | } | |
136 | ||
c3b81db0 AD |
137 | if ($subop == "forceUpdateAllFeeds") { |
138 | update_all_feeds($link, true); | |
139 | outputFeedList($link); | |
140 | } | |
141 | ||
142 | if ($subop == "updateAllFeeds") { | |
143 | update_all_feeds($link, false); | |
144 | outputFeedList($link); | |
145 | } | |
146 | ||
147 | if ($subop == "catchupPage") { | |
148 | ||
149 | $ids = split(",", $_GET["ids"]); | |
150 | ||
151 | foreach ($ids as $id) { | |
152 | ||
153 | pg_query("UPDATE ttrss_entries SET unread=false,last_read = NOW() | |
154 | WHERE id = '$id'"); | |
155 | ||
156 | } | |
157 | ||
158 | print "Marked active page as read."; | |
159 | } | |
160 | ||
161 | } | |
162 | ||
163 | if ($op == "feeds") { | |
164 | ||
165 | $subop = $_GET["subop"]; | |
166 | ||
167 | if ($subop == "catchupAll") { | |
168 | pg_query("UPDATE ttrss_entries SET last_read = NOW(),unread = false"); | |
169 | } | |
170 | ||
171 | outputFeedList($link); | |
172 | ||
1cd17194 AD |
173 | } |
174 | ||
175 | if ($op == "view") { | |
176 | ||
d76a3b03 AD |
177 | $id = $_GET["id"]; |
178 | ||
b197f117 | 179 | $result = pg_query("UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE id = '$id'"); |
a1a8a2be | 180 | |
a1ea1e12 | 181 | $result = pg_query("SELECT title,link,content,feed_id,comments, |
b7f4bda2 AD |
182 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url |
183 | FROM ttrss_entries | |
d76a3b03 | 184 | WHERE id = '$id'"); |
1cd17194 | 185 | |
d76a3b03 | 186 | if ($result) { |
1cd17194 | 187 | |
d76a3b03 | 188 | $line = pg_fetch_assoc($result); |
1cd17194 | 189 | |
b7f4bda2 AD |
190 | if ($line["icon_url"]) { |
191 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
192 | } else { | |
193 | $feed_icon = " "; | |
194 | } | |
d76a3b03 | 195 | |
b7f4bda2 AD |
196 | print "<table class=\"postTable\" width=\"100%\" cellspacing=\"0\" |
197 | cellpadding=\"0\">"; | |
198 | ||
f07c0eb4 | 199 | print "<tr class=\"titleTop\"><td align=\"right\"><b>Title:</b></td> |
b7f4bda2 AD |
200 | <td width=\"100%\">".$line["title"]."</td> |
201 | <td> </td></tr>"; | |
a1ea1e12 AD |
202 | |
203 | if ($line["comments"] && $line["comments"] != $line["link"]) { | |
204 | // print "<tr class=\"titleInner\"><td align=\"right\"><b>Comments:</b></td> | |
205 | // <td><a href=\"".$line["comments"]."\">".$line["comments"]."</a></td> | |
206 | // <td> </td> </tr>"; | |
207 | ||
208 | $comments_prompt = "(<a href=\"".$line["comments"]."\">Comments</a>)"; | |
209 | } | |
210 | ||
f07c0eb4 | 211 | print "<tr class=\"titleBottom\"><td align=\"right\"><b>Link:</b></td> |
a1ea1e12 AD |
212 | <td><a href=\"".$line["link"]."\">".$line["link"]."</a> $comments_prompt</td> |
213 | <td> </td></tr>"; | |
126682c1 AD |
214 | print "<tr><td valign=\"top\" class=\"post\" |
215 | colspan=\"2\">" . $line["content"] . "</td> | |
b7f4bda2 AD |
216 | <td valign=\"top\">$feed_icon</td> |
217 | </tr>"; | |
218 | print "</table>"; | |
219 | ||
d76a3b03 | 220 | } |
1cd17194 AD |
221 | } |
222 | ||
223 | if ($op == "viewfeed") { | |
224 | ||
225 | $feed = $_GET["feed"]; | |
d76a3b03 | 226 | $skip = $_GET["skip"]; |
476cac42 | 227 | $subop = $_GET["subop"]; |
a1a8a2be | 228 | |
ac53063a AD |
229 | if (!$skip) $skip = 0; |
230 | ||
476cac42 | 231 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 232 | |
ac53063a AD |
233 | // FIXME: check for null value here |
234 | ||
a2015351 | 235 | $result = pg_query("SELECT *,SUBSTRING(last_updated,1,16) as last_updated, |
82baad4a AD |
236 | EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout |
237 | FROM ttrss_feeds WHERE id = '$feed'"); | |
1cd17194 | 238 | |
d76a3b03 | 239 | if ($result) { |
1cd17194 | 240 | |
d76a3b03 | 241 | $line = pg_fetch_assoc($result); |
1cd17194 | 242 | |
476cac42 AD |
243 | if ($subop == "ForceUpdate" || |
244 | (!$subop && $line["update_timeout"] > MIN_UPDATE_TIME)) { | |
82baad4a AD |
245 | |
246 | update_rss_feed($link, $line["feed_url"], $feed); | |
d76a3b03 | 247 | |
a1a8a2be | 248 | } else { |
d76a3b03 | 249 | |
476cac42 | 250 | if ($subop == "MarkAllRead") { |
d76a3b03 | 251 | |
b197f117 | 252 | pg_query("UPDATE ttrss_entries SET unread = false,last_read = NOW() |
a1a8a2be AD |
253 | WHERE feed_id = '$feed'"); |
254 | } | |
a1a8a2be AD |
255 | } |
256 | } | |
d76a3b03 | 257 | |
175847de | 258 | print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">"; |
ac53063a | 259 | |
a2015351 AD |
260 | $feed_last_updated = "Updated: " . $line["last_updated"]; |
261 | ||
1c37c607 | 262 | print "<tr><td class=\"search\" colspan=\"3\"> |
760966c1 AD |
263 | Search: <input id=\"searchbox\" |
264 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
265 | onchange=\"javascript:search($feed);\"> | |
c374a3fe | 266 | <a class=\"button\" href=\"javascript:resetSearch()\">Reset</a> |
79a33f89 | 267 | </td></tr>"; |
a2015351 AD |
268 | print "<tr> |
269 | <td colspan=\"3\" class=\"title\">" . $line["title"] . "</td></tr>"; | |
d76a3b03 | 270 | |
c374a3fe AD |
271 | $search = $_GET["search"]; |
272 | ||
273 | if (search) { | |
ac53063a AD |
274 | $search_query_part = "(upper(title) LIKE upper('%$search%') |
275 | OR content LIKE '%$search%') AND"; | |
276 | } | |
277 | ||
e6d1c0a0 | 278 | $result = pg_query("SELECT count(id) AS total_entries |
36bf7496 AD |
279 | FROM ttrss_entries WHERE |
280 | $search_query_part | |
281 | feed_id = '$feed'"); | |
e6d1c0a0 AD |
282 | |
283 | $total_entries = pg_fetch_result($result, 0, "total_entries"); | |
284 | ||
b197f117 AD |
285 | $result = pg_query("SELECT |
286 | id,title,updated,unread,feed_id, | |
287 | EXTRACT(EPOCH FROM last_read) AS last_read_ts, | |
288 | EXTRACT(EPOCH FROM updated) AS updated_ts | |
289 | FROM | |
290 | ttrss_entries | |
291 | WHERE | |
ac53063a AD |
292 | $search_query_part |
293 | feed_id = '$feed' ORDER BY updated DESC LIMIT ".HEADLINES_PER_PAGE." OFFSET $skip"); | |
d76a3b03 | 294 | |
a1a8a2be | 295 | $lnum = 0; |
e1123aee AD |
296 | |
297 | $num_unread = 0; | |
d76a3b03 | 298 | |
a1a8a2be | 299 | while ($line = pg_fetch_assoc($result)) { |
d76a3b03 | 300 | |
a1a8a2be | 301 | $class = ($lnum % 2) ? "even" : "odd"; |
d76a3b03 | 302 | |
b197f117 | 303 | if ($line["last_read_ts"] < $line["updated_ts"] && $line["unread"] == "f") { |
e695fdc8 | 304 | $update_pic = "<img src=\"images/updated.png\" alt=\"Updated\">"; |
e1123aee | 305 | ++$num_unread; |
b197f117 AD |
306 | } else { |
307 | $update_pic = " "; | |
308 | } | |
309 | ||
e1123aee | 310 | if ($line["unread"] == "t") { |
a1a8a2be | 311 | $class .= "Unread"; |
e1123aee AD |
312 | ++$num_unread; |
313 | } | |
d76a3b03 | 314 | |
b197f117 AD |
315 | $id = $line["id"]; |
316 | $feed_id = $line["feed_id"]; | |
317 | ||
318 | $content_link = "<a href=\"javascript:view($id,$feed_id);\">" . | |
319 | $line["title"] . "</a>"; | |
320 | ||
321 | print "<tr class='$class' id='RROW-$id'>"; | |
322 | ||
323 | print "<td id='FUPDPIC-$id' valign='center' class='headlineUpdateMark'>$update_pic</td>"; | |
324 | ||
a3ee2a38 AD |
325 | print "<td class='headlineUpdated'> |
326 | <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>"; | |
a1a8a2be | 327 | print "<td class='headlineTitle'>$content_link</td>"; |
d76a3b03 | 328 | |
a1a8a2be | 329 | print "</tr>"; |
d76a3b03 | 330 | |
a1a8a2be AD |
331 | ++$lnum; |
332 | } | |
d76a3b03 | 333 | |
ac53063a AD |
334 | if ($lnum == 0) { |
335 | print "<tr><td align='center'>No entries found.</td></tr>"; | |
047bae73 | 336 | } |
ac53063a | 337 | |
047bae73 AD |
338 | while ($lnum < HEADLINES_PER_PAGE) { |
339 | ++$lnum; | |
340 | print "<tr><td> </td></tr>"; | |
ac53063a AD |
341 | } |
342 | ||
047bae73 AD |
343 | // start unholy navbar block |
344 | ||
b197f117 | 345 | print "<tr><td colspan=\"3\" class=\"headlineToolbar\">"; |
c3a8d71a | 346 | |
a1a8a2be AD |
347 | $next_skip = $skip + HEADLINES_PER_PAGE; |
348 | $prev_skip = $skip - HEADLINES_PER_PAGE; | |
c3a8d71a | 349 | |
83fe4d6d | 350 | print "Navigate: "; |
e6d1c0a0 AD |
351 | |
352 | if ($prev_skip >= 0) { | |
353 | print "<a class=\"button\" | |
354 | href=\"javascript:viewfeed($feed, $prev_skip);\">Previous Page</a>"; | |
355 | } else { | |
356 | print "<a class=\"disabledButton\">Previous Page</a>"; | |
357 | } | |
a1a8a2be | 358 | print " "; |
e6d1c0a0 AD |
359 | |
360 | if ($next_skip < $total_entries) { | |
361 | print "<a class=\"button\" | |
362 | href=\"javascript:viewfeed($feed, $next_skip);\">Next Page</a>"; | |
363 | } else { | |
364 | print "<a class=\"disabledButton\">Next Page</a>"; | |
365 | } | |
2127761f | 366 | print " Feed: "; |
2127761f | 367 | |
ac53063a | 368 | print "<a class=\"button\" |
2127761f | 369 | href=\"javascript:viewfeed($feed, 0, 'ForceUpdate');\">Update</a>"; |
175847de | 370 | |
83fe4d6d | 371 | print " Mark as read: "; |
175847de | 372 | |
e1123aee AD |
373 | if ($num_unread > 0) { |
374 | print "<a class=\"button\" id=\"btnCatchupPage\" | |
375 | href=\"javascript:catchupPage($feed);\">This Page</a>"; | |
376 | print " "; | |
377 | } else { | |
378 | print "<a class=\"disabledButton\">This Page</a>"; | |
379 | print " "; | |
380 | } | |
381 | ||
a1a8a2be | 382 | print "<a class=\"button\" |
83fe4d6d | 383 | href=\"javascript:viewfeed($feed, $skip, 'MarkAllRead');\">All Posts</a>"; |
d76a3b03 | 384 | |
a1a8a2be | 385 | print "</td></tr>"; |
a2015351 AD |
386 | |
387 | // end unholy navbar block | |
388 | ||
a1a8a2be | 389 | print "</table>"; |
d76a3b03 | 390 | |
a1a8a2be AD |
391 | $result = pg_query("SELECT id, (SELECT count(id) FROM ttrss_entries |
392 | WHERE feed_id = ttrss_feeds.id) AS total, | |
393 | (SELECT count(id) FROM ttrss_entries | |
394 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
395 | FROM ttrss_feeds WHERE id = '$feed'"); | |
d76a3b03 | 396 | |
a1a8a2be AD |
397 | $total = pg_fetch_result($result, 0, "total"); |
398 | $unread = pg_fetch_result($result, 0, "unread"); | |
d76a3b03 | 399 | |
a1a8a2be AD |
400 | print "<div class=\"invisible\" id=\"FACTIVE\">$feed</div>"; |
401 | print "<div class=\"invisible\" id=\"FTOTAL\">$total</div>"; | |
402 | print "<div class=\"invisible\" id=\"FUNREAD\">$unread</div>"; | |
d76a3b03 | 403 | |
1cd17194 AD |
404 | } |
405 | ||
0e091d38 | 406 | if ($op == "pref-rpc") { |
331900c6 | 407 | |
0e091d38 | 408 | $subop = $_GET["subop"]; |
331900c6 | 409 | |
83fe4d6d AD |
410 | if ($subop == "unread") { |
411 | $ids = split(",", $_GET["ids"]); | |
412 | foreach ($ids as $id) { | |
413 | pg_query("UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'"); | |
414 | } | |
0e091d38 AD |
415 | |
416 | print "Marked selected feeds as read."; | |
83fe4d6d AD |
417 | } |
418 | ||
419 | if ($subop == "read") { | |
420 | $ids = split(",", $_GET["ids"]); | |
421 | foreach ($ids as $id) { | |
b197f117 AD |
422 | pg_query("UPDATE ttrss_entries |
423 | SET unread = false,last_read = NOW() WHERE feed_id = '$id'"); | |
83fe4d6d | 424 | } |
0e091d38 AD |
425 | |
426 | print "Marked selected feeds as unread."; | |
427 | ||
428 | } | |
429 | ||
430 | } | |
431 | ||
432 | if ($op == "pref-feeds") { | |
433 | ||
434 | $subop = $_GET["subop"]; | |
435 | ||
603c27f8 | 436 | /* if ($subop == "old_edit") { |
508a81e1 AD |
437 | |
438 | $feed_id = $_GET["id"]; | |
439 | ||
440 | $result = pg_query("SELECT title,feed_url | |
441 | FROM ttrss_feeds WHERE id = '$feed_id'"); | |
442 | ||
443 | $fedit_link = pg_fetch_result($result, 0, "feed_url"); | |
444 | $fedit_title = pg_fetch_result($result, 0, "title"); | |
445 | ||
446 | print "<table class=\"prefAddFeed\"> | |
447 | <td>Title:</td><td><input id=\"fedit_title\" value=\"$fedit_title\"></td></tr> | |
448 | <td>Link:</td><td><input id=\"fedit_link\" value=\"$fedit_link\"></td></tr> | |
449 | <tr><td colspan=\"2\" align=\"right\"> | |
450 | <a class=\"button\" href=\"javascript:feedEditCancel()\">Cancel</a> | |
451 | <a class=\"button\" href=\"javascript:feedEditSave($feed_id)\">Save</a> | |
452 | </td></tr> | |
453 | </table>"; | |
454 | ||
455 | } else { | |
456 | ||
457 | print "<table class=\"prefAddFeed\"> | |
458 | <td><input id=\"fadd_link\"></td> | |
459 | <td colspan=\"4\" align=\"right\"> | |
460 | <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr> | |
461 | </table>"; | |
462 | ||
603c27f8 | 463 | } */ |
508a81e1 AD |
464 | |
465 | if ($subop == "editSave") { | |
466 | $feed_title = pg_escape_string($_GET["t"]); | |
467 | $feed_link = pg_escape_string($_GET["l"]); | |
468 | $feed_id = $_GET["id"]; | |
469 | ||
470 | $result = pg_query("UPDATE ttrss_feeds SET | |
471 | title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'"); | |
472 | ||
83fe4d6d AD |
473 | } |
474 | ||
331900c6 | 475 | if ($subop == "remove") { |
331900c6 | 476 | |
b0b4abcf | 477 | if (!WEB_DEMO_MODE) { |
331900c6 | 478 | |
b0b4abcf AD |
479 | $ids = split(",", $_GET["ids"]); |
480 | ||
481 | foreach ($ids as $id) { | |
482 | pg_query("BEGIN"); | |
483 | pg_query("DELETE FROM ttrss_entries WHERE feed_id = '$id'"); | |
484 | pg_query("DELETE FROM ttrss_feeds WHERE id = '$id'"); | |
485 | pg_query("COMMIT"); | |
d5caaae5 AD |
486 | |
487 | if (file_exists(ICONS_DIR . "/$id.ico")) { | |
488 | unlink(ICONS_DIR . "/$id.ico"); | |
489 | } | |
b0b4abcf | 490 | } |
331900c6 AD |
491 | } |
492 | } | |
493 | ||
494 | if ($subop == "add") { | |
b0b4abcf AD |
495 | |
496 | if (!WEB_DEMO_MODE) { | |
331900c6 | 497 | |
b0b4abcf AD |
498 | $feed_link = pg_escape_string($_GET["link"]); |
499 | ||
500 | $result = pg_query( | |
501 | "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')"); | |
331900c6 | 502 | |
b0b4abcf | 503 | $result = pg_query("SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'"); |
331900c6 | 504 | |
b0b4abcf | 505 | $feed_id = pg_fetch_result($result, 0, "id"); |
331900c6 | 506 | |
b0b4abcf AD |
507 | if ($feed_id) { |
508 | update_rss_feed($link, $feed_link, $feed_id); | |
509 | } | |
510 | } | |
331900c6 AD |
511 | } |
512 | ||
c0e5a40e AD |
513 | $result = pg_query("SELECT |
514 | id,title,feed_url,substring(last_updated,1,16) as last_updated | |
515 | FROM | |
516 | ttrss_feeds ORDER by title"); | |
1cd17194 | 517 | |
331900c6 | 518 | print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">"; |
007bda35 | 519 | print "<tr class=\"title\"> |
603c27f8 AD |
520 | <td> </td><td>Select</td><td width=\"40%\">Title</td> |
521 | <td width=\"40%\">Link</td><td>Last Updated</td></tr>"; | |
007bda35 AD |
522 | |
523 | $lnum = 0; | |
524 | ||
525 | while ($line = pg_fetch_assoc($result)) { | |
526 | ||
527 | $class = ($lnum % 2) ? "even" : "odd"; | |
9b307248 | 528 | |
331900c6 | 529 | $feed_id = $line["id"]; |
603c27f8 AD |
530 | |
531 | $edit_feed_id = $_GET["id"]; | |
532 | ||
9b307248 AD |
533 | if ($subop == "edit" && $feed_id != $edit_feed_id) { |
534 | $class .= "Grayed"; | |
535 | } | |
536 | ||
331900c6 | 537 | print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; |
007bda35 | 538 | |
c0e5a40e AD |
539 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
540 | ||
541 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
542 | $feed_icon = "<img width=\"16\" height=\"16\" | |
543 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
544 | } else { | |
545 | $feed_icon = " "; | |
546 | } | |
547 | print "<td align='center'>$feed_icon</td>"; | |
548 | ||
9b307248 | 549 | if (!$edit_feed_id || $subop != "edit") { |
603c27f8 AD |
550 | |
551 | print "<td><input onclick='toggleSelectRow(this);' | |
331900c6 | 552 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
603c27f8 AD |
553 | |
554 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
555 | $line["title"] . "</td>"; | |
556 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
557 | $line["feed_url"] . "</td>"; | |
9b307248 AD |
558 | |
559 | ||
560 | } else if ($feed_id != $edit_feed_id) { | |
561 | ||
5b0a4ec4 | 562 | print "<td><input disabled=\"true\" type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
9b307248 AD |
563 | |
564 | print "<td>".$line["title"]."</td>"; | |
565 | print "<td>".$line["feed_url"]."</td>"; | |
566 | ||
603c27f8 AD |
567 | } else { |
568 | ||
569 | print "<td><input disabled=\"true\" type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; | |
570 | ||
571 | print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>"; | |
572 | print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>"; | |
573 | ||
574 | } | |
331900c6 | 575 | |
007bda35 | 576 | print "<td>" . $line["last_updated"] . "</td>"; |
603c27f8 | 577 | |
007bda35 AD |
578 | print "</tr>"; |
579 | ||
580 | ++$lnum; | |
581 | } | |
582 | ||
583 | print "</table>"; | |
584 | ||
603c27f8 AD |
585 | print "<p>"; |
586 | ||
587 | if ($subop == "edit") { | |
588 | print "Edit feed: | |
589 | <a class=\"button\" href=\"javascript:feedEditCancel()\">Cancel</a> | |
590 | <a class=\"button\" href=\"javascript:feedEditSave()\">Save</a>"; | |
591 | } else { | |
592 | ||
593 | // <a class=\"button\" | |
594 | // href=\"javascript:editSelectedFeed()\">Edit</a> | |
595 | ||
596 | // <a class=\"button\" | |
597 | // href=\"javascript:updateFeedList()\">Refresh</a>"; | |
598 | ||
599 | print " | |
600 | Selection: | |
601 | <a class=\"buttonWarn\" | |
602 | href=\"javascript:removeSelectedFeeds()\">Remove</a> | |
603 | <a class=\"button\" | |
604 | href=\"javascript:readSelectedFeeds()\">Mark as read</a> | |
605 | <a class=\"button\" | |
606 | href=\"javascript:unreadSelectedFeeds()\">Mark as unread</a>"; | |
607 | ||
608 | } | |
609 | ||
007bda35 AD |
610 | } |
611 | ||
612 | pg_close($link); | |
1cd17194 | 613 | ?> |