]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | <? |
a2015351 | 2 | // header("Content-Type: application/xml"); |
1cd17194 | 3 | |
82baad4a | 4 | require_once "config.php"; |
648472a7 | 5 | require_once "db.php"; |
82baad4a AD |
6 | require_once "functions.php"; |
7 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 8 | |
648472a7 | 9 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
d76a3b03 | 10 | |
648472a7 AD |
11 | if (DB_TYPE == "pgsql") { |
12 | pg_query("set client_encoding = 'utf-8'"); | |
13 | } | |
d76a3b03 | 14 | |
6f428bc5 | 15 | $op = $_GET["op"]; |
331900c6 | 16 | $fetch = $_GET["fetch"]; |
175847de | 17 | |
c3b81db0 | 18 | function outputFeedList($link) { |
175847de | 19 | |
1a66d16e AD |
20 | print "<html><head> |
21 | <title>Tiny Tiny RSS : Feedlist</title> | |
22 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
23 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
24 | <script type=\"text/javascript\" src=\"feedlist.js\"></script> | |
25 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
26 | </head><body>"; | |
27 | ||
648472a7 | 28 | $result = db_query($link, "SELECT *, |
d76a3b03 AD |
29 | (SELECT count(id) FROM ttrss_entries |
30 | WHERE feed_id = ttrss_feeds.id) AS total, | |
31 | (SELECT count(id) FROM ttrss_entries | |
32 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
33 | FROM ttrss_feeds ORDER BY title"); | |
1cd17194 | 34 | |
1a66d16e AD |
35 | $actid = $_GET["actid"]; |
36 | ||
e828e31e AD |
37 | // print "<table width=\"100%\" class=\"feedsList\" id=\"feedsList\">"; |
38 | ||
39 | print "<ul class=\"feedList\" id=\"feedList\">"; | |
1cd17194 AD |
40 | |
41 | $lnum = 0; | |
42 | ||
76798ff3 AD |
43 | $total_unread = 0; |
44 | ||
648472a7 | 45 | while ($line = db_fetch_assoc($result)) { |
a1a8a2be | 46 | |
6f428bc5 | 47 | $feed = $line["title"]; |
2c1dd701 | 48 | $feed_id = $line["id"]; |
13ad9102 AD |
49 | |
50 | $subop = $_GET["subop"]; | |
2c1dd701 | 51 | |
d76a3b03 AD |
52 | $total = $line["total"]; |
53 | $unread = $line["unread"]; | |
54 | ||
e828e31e AD |
55 | // $class = ($lnum % 2) ? "even" : "odd"; |
56 | ||
57 | $class = "odd"; | |
a1a8a2be AD |
58 | |
59 | if ($unread > 0) $class .= "Unread"; | |
60 | ||
1a66d16e AD |
61 | if ($actid == $feed_id) { |
62 | $class .= "Selected"; | |
63 | } | |
64 | ||
76798ff3 AD |
65 | $total_unread += $unread; |
66 | ||
e828e31e | 67 | // print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; |
a1a8a2be | 68 | |
78800912 | 69 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
13ad9102 AD |
70 | |
71 | if ($subop != "piggie") { | |
72 | ||
73 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
e828e31e | 74 | $feed_icon = "<img src=\"" . ICONS_URL . "/$feed_id.ico\">"; |
13ad9102 | 75 | } else { |
e828e31e | 76 | $feed_icon = "<img src=\"images/blank_icon.png\">"; |
13ad9102 | 77 | } |
78800912 | 78 | } else { |
13ad9102 AD |
79 | $feed_icon = "<img width=\"16\" height=\"16\" |
80 | src=\"http://madoka.spb.ru/stuff/fox/tiny_piggie.png\">"; | |
78800912 | 81 | } |
13ad9102 | 82 | |
a1a8a2be | 83 | $feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed</a>"; |
e828e31e AD |
84 | |
85 | /* if (ENABLE_FEED_ICONS) { | |
78800912 AD |
86 | print "<td>$feed_icon</td>"; |
87 | } | |
e828e31e | 88 | |
a1a8a2be | 89 | print "<td id=\"FEEDN-$feed_id\">$feed</td>"; |
c442fb6e AD |
90 | print "<td>"; |
91 | print "<span id=\"FEEDU-$feed_id\">$unread</span> / "; | |
92 | print "<span id=\"FEEDT-$feed_id\">$total</span>"; | |
93 | print "</td>"; | |
a1a8a2be | 94 | |
e828e31e AD |
95 | print "</tr>"; */ |
96 | ||
97 | print "<li id=\"FEEDR-$feed_id\" class=\"$class\">"; | |
98 | if (ENABLE_FEED_ICONS) { | |
99 | print "$feed_icon"; | |
100 | } | |
101 | print "<span id=\"FEEDN-$feed_id\">$feed</span>"; | |
1cd17194 | 102 | |
0c674406 AD |
103 | if ($unread != 0) { |
104 | $fctr_class = ""; | |
105 | } else { | |
106 | $fctr_class = "class=\"invisible\""; | |
e828e31e | 107 | } |
0c674406 AD |
108 | |
109 | print "<span $fctr_class id=\"FEEDCTR-$feed_id\"> | |
110 | (<span id=\"FEEDU-$feed_id\">$unread</span>)</span>"; | |
e828e31e AD |
111 | |
112 | print "</li>"; | |
476cac42 | 113 | |
e828e31e AD |
114 | ++$lnum; |
115 | } | |
82baad4a | 116 | |
a1a8a2be | 117 | print "</table>"; |
1cd17194 | 118 | |
caa4e57f | 119 | print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>"; |
1a66d16e | 120 | print "<div class=\"invisible\" id=\"ACTFEEDID\">$actid</div>"; |
caa4e57f | 121 | |
c3b81db0 AD |
122 | } |
123 | ||
124 | ||
125 | if ($op == "rpc") { | |
126 | ||
127 | $subop = $_GET["subop"]; | |
128 | ||
f4c10d44 AD |
129 | if ($subop == "mark") { |
130 | $mark = $_GET["mark"]; | |
648472a7 | 131 | $id = db_escape_string($_GET["id"]); |
f4c10d44 AD |
132 | |
133 | if ($mark == "1") { | |
134 | $mark = "true"; | |
135 | } else { | |
136 | $mark = "false"; | |
137 | } | |
138 | ||
648472a7 | 139 | $result = db_query($link, "UPDATE ttrss_entries SET marked = $mark |
f4c10d44 AD |
140 | WHERE id = '$id'"); |
141 | } | |
142 | ||
caa4e57f | 143 | if ($subop == "updateFeed") { |
648472a7 | 144 | $feed_id = db_escape_string($_GET["feed"]); |
9cfc649a | 145 | |
648472a7 | 146 | $result = db_query($link, |
caa4e57f | 147 | "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'"); |
9cfc649a | 148 | |
648472a7 AD |
149 | if (db_num_rows($result) > 0) { |
150 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
caa4e57f AD |
151 | // update_rss_feed($link, $feed_url, $feed_id); |
152 | } | |
9cfc649a | 153 | |
caa4e57f | 154 | print "DONE-$feed_id"; |
9cfc649a | 155 | |
caa4e57f | 156 | return; |
9cfc649a AD |
157 | } |
158 | ||
c3b81db0 AD |
159 | if ($subop == "forceUpdateAllFeeds") { |
160 | update_all_feeds($link, true); | |
c3b81db0 AD |
161 | } |
162 | ||
163 | if ($subop == "updateAllFeeds") { | |
164 | update_all_feeds($link, false); | |
c3b81db0 AD |
165 | } |
166 | ||
167 | if ($subop == "catchupPage") { | |
168 | ||
169 | $ids = split(",", $_GET["ids"]); | |
170 | ||
171 | foreach ($ids as $id) { | |
172 | ||
648472a7 | 173 | db_query($link, "UPDATE ttrss_entries SET unread=false,last_read = NOW() |
c3b81db0 AD |
174 | WHERE id = '$id'"); |
175 | ||
176 | } | |
177 | ||
178 | print "Marked active page as read."; | |
179 | } | |
180 | ||
181 | } | |
182 | ||
183 | if ($op == "feeds") { | |
184 | ||
185 | $subop = $_GET["subop"]; | |
186 | ||
187 | if ($subop == "catchupAll") { | |
648472a7 | 188 | db_query($link, "UPDATE ttrss_entries SET last_read = NOW(),unread = false"); |
c3b81db0 AD |
189 | } |
190 | ||
191 | outputFeedList($link); | |
192 | ||
1cd17194 AD |
193 | } |
194 | ||
195 | if ($op == "view") { | |
196 | ||
d76a3b03 AD |
197 | $id = $_GET["id"]; |
198 | ||
648472a7 | 199 | $result = db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE id = '$id'"); |
a1a8a2be | 200 | |
70830c87 AD |
201 | $addheader = $_GET["addheader"]; |
202 | ||
648472a7 | 203 | $result = db_query($link, "SELECT title,link,content,feed_id,comments, |
b7f4bda2 AD |
204 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url |
205 | FROM ttrss_entries | |
d76a3b03 | 206 | WHERE id = '$id'"); |
1cd17194 | 207 | |
70830c87 | 208 | if ($addheader) { |
f0601b87 | 209 | print "<html><head> |
70830c87 AD |
210 | <title>Tiny Tiny RSS : Article $id</title> |
211 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
c05608c2 | 212 | <script type=\"text/javascript\" src=\"functions.js\"></script> |
70830c87 | 213 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
f0601b87 | 214 | </head><body>"; |
70830c87 AD |
215 | } |
216 | ||
d76a3b03 | 217 | if ($result) { |
1cd17194 | 218 | |
648472a7 | 219 | $line = db_fetch_assoc($result); |
1cd17194 | 220 | |
b7f4bda2 AD |
221 | if ($line["icon_url"]) { |
222 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
223 | } else { | |
224 | $feed_icon = " "; | |
225 | } | |
d76a3b03 | 226 | |
f7181e9b AD |
227 | if ($line["comments"] && $line["link"] != $line["comments"]) { |
228 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; | |
229 | } else { | |
230 | $entry_comments = ""; | |
231 | } | |
232 | ||
e828e31e AD |
233 | print "<div class=\"postReply\">"; |
234 | ||
235 | print "<div class=\"postHeader\"><table>"; | |
236 | ||
237 | print "<tr><td><b>Title:</b></td> | |
238 | <td width='100%'>" . $line["title"] . "</td></tr>"; | |
f7181e9b | 239 | |
e828e31e | 240 | print "<tr><td><b>Link:</b></td> |
f7181e9b AD |
241 | <td width='100%'> |
242 | <a href=\"" . $line["link"] . "\">".$line["link"]."</a> | |
243 | $entry_comments</td></tr>"; | |
e828e31e AD |
244 | |
245 | print "</table></div>"; | |
246 | ||
247 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
248 | print "<div class=\"postContent\">" . $line["content"] . "</div>"; | |
249 | ||
250 | print "</div>"; | |
251 | ||
d76a3b03 | 252 | } |
70830c87 AD |
253 | |
254 | if ($addheader) { | |
255 | print "</body></html>"; | |
256 | } | |
1cd17194 AD |
257 | } |
258 | ||
259 | if ($op == "viewfeed") { | |
260 | ||
261 | $feed = $_GET["feed"]; | |
d76a3b03 | 262 | $skip = $_GET["skip"]; |
476cac42 | 263 | $subop = $_GET["subop"]; |
f175937c | 264 | $view_mode = $_GET["view"]; |
f0601b87 | 265 | $addheader = $_GET["addheader"]; |
cb1083a1 | 266 | $limit = $_GET["limit"]; |
a1a8a2be | 267 | |
8d7008c7 AD |
268 | if (!$feed) { |
269 | print "Error: no feed to display."; | |
270 | return; | |
271 | } | |
272 | ||
ac53063a AD |
273 | if (!$skip) $skip = 0; |
274 | ||
476cac42 | 275 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 276 | |
f0601b87 AD |
277 | if ($addheader) { |
278 | print "<html><head> | |
ac43eba1 | 279 | <title>Tiny Tiny RSS : Feed $feed</title> |
f0601b87 AD |
280 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> |
281 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
282 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
283 | <script type=\"text/javascript\" src=\"viewfeed.js\"></script> | |
284 | </head><body>"; | |
285 | } | |
286 | ||
8d7008c7 AD |
287 | $result = db_query($link, |
288 | "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s | |
289 | FROM ttrss_feeds WHERE id = '$feed'"); | |
290 | ||
d76a3b03 | 291 | if ($result) { |
1cd17194 | 292 | |
648472a7 | 293 | $line = db_fetch_assoc($result); |
1cd17194 | 294 | |
deaaa02c | 295 | update_rss_feed($link, $line["feed_url"], $feed); |
f0601b87 | 296 | |
deaaa02c | 297 | if ($subop == "MarkAllRead") { |
d76a3b03 | 298 | |
deaaa02c AD |
299 | db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() |
300 | WHERE feed_id = '$feed'"); | |
a1a8a2be AD |
301 | } |
302 | } | |
d76a3b03 | 303 | |
175847de | 304 | print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">"; |
ac53063a | 305 | |
a2015351 AD |
306 | $feed_last_updated = "Updated: " . $line["last_updated"]; |
307 | ||
c374a3fe AD |
308 | $search = $_GET["search"]; |
309 | ||
f175937c | 310 | if ($search) { |
ac53063a AD |
311 | $search_query_part = "(upper(title) LIKE upper('%$search%') |
312 | OR content LIKE '%$search%') AND"; | |
f175937c AD |
313 | } else { |
314 | $search_query_part = ""; | |
315 | } | |
316 | ||
317 | $view_query_part = ""; | |
318 | ||
319 | if ($view_mode == "Starred") { | |
320 | $view_query_part = " marked = true AND "; | |
ac53063a AD |
321 | } |
322 | ||
ac43eba1 AD |
323 | if ($view_mode == "Unread") { |
324 | $view_query_part = " unread = true AND "; | |
325 | } | |
326 | ||
648472a7 | 327 | $result = db_query($link, "SELECT count(id) AS total_entries |
36bf7496 AD |
328 | FROM ttrss_entries WHERE |
329 | $search_query_part | |
330 | feed_id = '$feed'"); | |
e6d1c0a0 | 331 | |
648472a7 | 332 | $total_entries = db_fetch_result($result, 0, "total_entries"); |
e6d1c0a0 | 333 | |
648472a7 | 334 | /* $result = db_query("SELECT count(id) AS unread_entries |
ac43eba1 AD |
335 | FROM ttrss_entries WHERE |
336 | $search_query_part | |
337 | unread = true AND | |
338 | feed_id = '$feed'"); | |
339 | ||
648472a7 | 340 | $unread_entries = db_fetch_result($result, 0, "unread_entries"); */ |
ac43eba1 | 341 | |
8d7008c7 | 342 | if ($limit && $limit != "All") { |
82c9223c | 343 | $limit_query_part = "LIMIT " . $limit; |
ad3cb710 | 344 | } |
f0601b87 | 345 | |
648472a7 | 346 | $result = db_query($link, "SELECT |
deaaa02c | 347 | id,title,updated,unread,feed_id,marked,link,last_read |
b197f117 AD |
348 | FROM |
349 | ttrss_entries | |
350 | WHERE | |
ac53063a | 351 | $search_query_part |
f175937c | 352 | $view_query_part |
f0601b87 AD |
353 | feed_id = '$feed' ORDER BY updated DESC |
354 | $limit_query_part"); | |
d76a3b03 | 355 | |
a1a8a2be | 356 | $lnum = 0; |
e1123aee AD |
357 | |
358 | $num_unread = 0; | |
d76a3b03 | 359 | |
648472a7 | 360 | while ($line = db_fetch_assoc($result)) { |
d76a3b03 | 361 | |
a1a8a2be | 362 | $class = ($lnum % 2) ? "even" : "odd"; |
d76a3b03 | 363 | |
ad99045e AD |
364 | $id = $line["id"]; |
365 | $feed_id = $line["feed_id"]; | |
366 | ||
c4b0722c | 367 | /* if ($line["last_read"] && $line["updated"] && |
20fcff19 | 368 | strtotime($line["last_read"]) < strtotime($line["updated"]) && |
deaaa02c AD |
369 | ($line["unread"] == "f" || $line["unread"] == "0")) { |
370 | ||
ad99045e AD |
371 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" |
372 | alt=\"Updated\">"; | |
e1123aee | 373 | ++$num_unread; |
b197f117 | 374 | } else { |
ad99045e AD |
375 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.png\" |
376 | alt=\"Updated\">"; | |
c4b0722c AD |
377 | } */ |
378 | ||
c43f77f5 AD |
379 | // printf("L %d (%s) > U %d (%s) = %d<br>", |
380 | // strtotime($line["last_read"]), $line["last_read"], | |
381 | // strtotime($line["updated"]), $line["updated"], | |
382 | // strtotime($line["last_read"]) >= strtotime($line["updated"])); | |
383 | ||
384 | if ($line["last_read"] != "" && $line["updated"] != "" && | |
385 | strtotime($line["last_read"]) < strtotime($line["updated"])) { | |
386 | ||
387 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
388 | alt=\"Updated\">"; | |
389 | ||
390 | } else { | |
391 | ||
392 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.png\" | |
393 | alt=\"Updated\">"; | |
394 | ||
395 | } | |
b197f117 | 396 | |
8158c57a | 397 | if ($line["unread"] == "t" || $line["unread"] == "1") { |
a1a8a2be | 398 | $class .= "Unread"; |
e1123aee AD |
399 | ++$num_unread; |
400 | } | |
d76a3b03 | 401 | |
8158c57a | 402 | if ($line["marked"] == "t" || $line["marked"] == "1") { |
f4c10d44 AD |
403 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" |
404 | alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>"; | |
405 | } else { | |
406 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
407 | alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>"; | |
408 | } | |
409 | ||
ac43eba1 | 410 | $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" . |
b197f117 AD |
411 | $line["title"] . "</a>"; |
412 | ||
5f89f780 AD |
413 | print "<tr class='$class' id='RROW-$id'"; |
414 | // onclick=\"javascript:view($id,$feed_id)\"> | |
b197f117 | 415 | |
8d7008c7 AD |
416 | print "<td valign='center' align='center'>$update_pic</td>"; |
417 | print "<td valign='center' align='center'>$marked_pic</td>"; | |
b197f117 | 418 | |
8d7008c7 | 419 | print "<td width='25%'> |
a3ee2a38 | 420 | <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>"; |
8d7008c7 | 421 | print "<td width='70%'>$content_link</td>"; |
d76a3b03 | 422 | |
a1a8a2be | 423 | print "</tr>"; |
d76a3b03 | 424 | |
a1a8a2be AD |
425 | ++$lnum; |
426 | } | |
d76a3b03 | 427 | |
ac53063a AD |
428 | if ($lnum == 0) { |
429 | print "<tr><td align='center'>No entries found.</td></tr>"; | |
047bae73 | 430 | } |
ac53063a | 431 | |
047bae73 AD |
432 | while ($lnum < HEADLINES_PER_PAGE) { |
433 | ++$lnum; | |
434 | print "<tr><td> </td></tr>"; | |
ac53063a | 435 | } |
a2015351 | 436 | |
a1a8a2be | 437 | print "</table>"; |
d76a3b03 | 438 | |
648472a7 | 439 | $result = db_query($link, "SELECT id, (SELECT count(id) FROM ttrss_entries |
a1a8a2be AD |
440 | WHERE feed_id = ttrss_feeds.id) AS total, |
441 | (SELECT count(id) FROM ttrss_entries | |
442 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
443 | FROM ttrss_feeds WHERE id = '$feed'"); | |
d76a3b03 | 444 | |
648472a7 AD |
445 | $total = db_fetch_result($result, 0, "total"); |
446 | $unread = db_fetch_result($result, 0, "unread"); | |
d76a3b03 | 447 | |
6113ef7d AD |
448 | // update unread/total counters and status for active feed in the feedlist |
449 | // kludge, because iframe doesn't seem to support onload() | |
450 | ||
451 | print "<script type=\"text/javascript\"> | |
bb7cface AD |
452 | document.onkeydown = hotkey_handler; |
453 | ||
1a66d16e AD |
454 | var p_document = parent.frames['feeds-frame'].document; |
455 | ||
456 | var feedr = p_document.getElementById(\"FEEDR-\" + $feed); | |
1a66d16e | 457 | var feedu = p_document.getElementById(\"FEEDU-\" + $feed); |
6113ef7d | 458 | |
0c674406 AD |
459 | if (feedu) { |
460 | feedu.innerHTML = \"$unread\"; | |
461 | } | |
462 | ||
463 | var feedctr = p_document.getElementById(\"FEEDCTR-\" + $feed); | |
6113ef7d AD |
464 | |
465 | if ($unread > 0 && !feedr.className.match(\"Unread\")) { | |
466 | feedr.className = feedr.className + \"Unread\"; | |
0c674406 | 467 | feedctr.className = ''; |
6113ef7d AD |
468 | } else if ($unread <= 0) { |
469 | feedr.className = feedr.className.replace(\"Unread\", \"\"); | |
0c674406 | 470 | feedctr.className = 'invisible'; |
6113ef7d | 471 | } |
c05608c2 | 472 | |
90e395dc | 473 | // p_notify(\"\"); |
0c674406 | 474 | |
6113ef7d | 475 | </script>"; |
d76a3b03 | 476 | |
f0601b87 AD |
477 | if ($addheader) { |
478 | print "</body></html>"; | |
479 | } | |
480 | ||
1cd17194 AD |
481 | } |
482 | ||
0e091d38 | 483 | if ($op == "pref-rpc") { |
331900c6 | 484 | |
0e091d38 | 485 | $subop = $_GET["subop"]; |
331900c6 | 486 | |
83fe4d6d AD |
487 | if ($subop == "unread") { |
488 | $ids = split(",", $_GET["ids"]); | |
489 | foreach ($ids as $id) { | |
648472a7 | 490 | db_query($link, "UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'"); |
83fe4d6d | 491 | } |
0e091d38 AD |
492 | |
493 | print "Marked selected feeds as read."; | |
83fe4d6d AD |
494 | } |
495 | ||
496 | if ($subop == "read") { | |
497 | $ids = split(",", $_GET["ids"]); | |
498 | foreach ($ids as $id) { | |
648472a7 | 499 | db_query($link, "UPDATE ttrss_entries |
b197f117 | 500 | SET unread = false,last_read = NOW() WHERE feed_id = '$id'"); |
83fe4d6d | 501 | } |
0e091d38 AD |
502 | |
503 | print "Marked selected feeds as unread."; | |
504 | ||
505 | } | |
506 | ||
507 | } | |
508 | ||
509 | if ($op == "pref-feeds") { | |
510 | ||
511 | $subop = $_GET["subop"]; | |
512 | ||
508a81e1 | 513 | if ($subop == "editSave") { |
648472a7 AD |
514 | $feed_title = db_escape_string($_GET["t"]); |
515 | $feed_link = db_escape_string($_GET["l"]); | |
508a81e1 AD |
516 | $feed_id = $_GET["id"]; |
517 | ||
648472a7 | 518 | $result = db_query($link, "UPDATE ttrss_feeds SET |
508a81e1 AD |
519 | title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'"); |
520 | ||
83fe4d6d AD |
521 | } |
522 | ||
331900c6 | 523 | if ($subop == "remove") { |
331900c6 | 524 | |
b0b4abcf | 525 | if (!WEB_DEMO_MODE) { |
331900c6 | 526 | |
b0b4abcf AD |
527 | $ids = split(",", $_GET["ids"]); |
528 | ||
529 | foreach ($ids as $id) { | |
648472a7 AD |
530 | db_query($link, "BEGIN"); |
531 | db_query($link, "DELETE FROM ttrss_entries WHERE feed_id = '$id'"); | |
532 | db_query($link, "DELETE FROM ttrss_feeds WHERE id = '$id'"); | |
533 | db_query($link, "COMMIT"); | |
d5caaae5 AD |
534 | |
535 | if (file_exists(ICONS_DIR . "/$id.ico")) { | |
536 | unlink(ICONS_DIR . "/$id.ico"); | |
537 | } | |
b0b4abcf | 538 | } |
331900c6 AD |
539 | } |
540 | } | |
541 | ||
542 | if ($subop == "add") { | |
b0b4abcf AD |
543 | |
544 | if (!WEB_DEMO_MODE) { | |
331900c6 | 545 | |
648472a7 | 546 | $feed_link = db_escape_string($_GET["link"]); |
b0b4abcf | 547 | |
648472a7 | 548 | $result = db_query($link, |
b0b4abcf | 549 | "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')"); |
331900c6 | 550 | |
648472a7 | 551 | $result = db_query($link, |
e9c54861 | 552 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'"); |
331900c6 | 553 | |
648472a7 | 554 | $feed_id = db_fetch_result($result, 0, "id"); |
331900c6 | 555 | |
b0b4abcf AD |
556 | if ($feed_id) { |
557 | update_rss_feed($link, $feed_link, $feed_id); | |
558 | } | |
559 | } | |
331900c6 | 560 | } |
a0d53889 AD |
561 | |
562 | print "<table class=\"prefAddFeed\"><tr> | |
563 | <td><input id=\"fadd_link\"></td> | |
564 | <td colspan=\"4\" align=\"right\"> | |
565 | <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr> | |
566 | </table>"; | |
567 | ||
648472a7 | 568 | $result = db_query($link, "SELECT |
c0e5a40e AD |
569 | id,title,feed_url,substring(last_updated,1,16) as last_updated |
570 | FROM | |
571 | ttrss_feeds ORDER by title"); | |
1cd17194 | 572 | |
331900c6 | 573 | print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">"; |
007bda35 | 574 | print "<tr class=\"title\"> |
603c27f8 | 575 | <td> </td><td>Select</td><td width=\"40%\">Title</td> |
0afbd851 | 576 | <td width=\"40%\">Link</td><td>Last updated</td></tr>"; |
007bda35 AD |
577 | |
578 | $lnum = 0; | |
579 | ||
648472a7 | 580 | while ($line = db_fetch_assoc($result)) { |
007bda35 AD |
581 | |
582 | $class = ($lnum % 2) ? "even" : "odd"; | |
9b307248 | 583 | |
331900c6 | 584 | $feed_id = $line["id"]; |
603c27f8 AD |
585 | |
586 | $edit_feed_id = $_GET["id"]; | |
587 | ||
9b307248 AD |
588 | if ($subop == "edit" && $feed_id != $edit_feed_id) { |
589 | $class .= "Grayed"; | |
590 | } | |
591 | ||
331900c6 | 592 | print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; |
007bda35 | 593 | |
c0e5a40e AD |
594 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
595 | ||
596 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
597 | $feed_icon = "<img width=\"16\" height=\"16\" | |
598 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
599 | } else { | |
600 | $feed_icon = " "; | |
601 | } | |
602 | print "<td align='center'>$feed_icon</td>"; | |
603 | ||
9b307248 | 604 | if (!$edit_feed_id || $subop != "edit") { |
603c27f8 AD |
605 | |
606 | print "<td><input onclick='toggleSelectRow(this);' | |
331900c6 | 607 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
603c27f8 AD |
608 | |
609 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
610 | $line["title"] . "</td>"; | |
611 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
612 | $line["feed_url"] . "</td>"; | |
9b307248 AD |
613 | |
614 | ||
615 | } else if ($feed_id != $edit_feed_id) { | |
616 | ||
e9c54861 AD |
617 | print "<td><input disabled=\"true\" type=\"checkbox\" |
618 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
9b307248 AD |
619 | |
620 | print "<td>".$line["title"]."</td>"; | |
621 | print "<td>".$line["feed_url"]."</td>"; | |
622 | ||
603c27f8 AD |
623 | } else { |
624 | ||
e9c54861 | 625 | print "<td><input disabled=\"true\" type=\"checkbox\"></td>"; |
603c27f8 AD |
626 | |
627 | print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>"; | |
628 | print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>"; | |
629 | ||
630 | } | |
0afbd851 AD |
631 | |
632 | if (!$line["last_updated"]) $line["last_updated"] = "Never"; | |
633 | ||
007bda35 | 634 | print "<td>" . $line["last_updated"] . "</td>"; |
603c27f8 | 635 | |
007bda35 AD |
636 | print "</tr>"; |
637 | ||
638 | ++$lnum; | |
639 | } | |
640 | ||
0afbd851 AD |
641 | if ($lnum == 0) { |
642 | print "<tr><td colspan=\"5\" align=\"center\">No feeds defined.</td></tr>"; | |
643 | } | |
644 | ||
007bda35 AD |
645 | print "</table>"; |
646 | ||
603c27f8 AD |
647 | print "<p>"; |
648 | ||
649 | if ($subop == "edit") { | |
650 | print "Edit feed: | |
e828e31e AD |
651 | <input type=\"submit\" class=\"button\" |
652 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> | |
653 | <input type=\"submit\" class=\"button\" | |
8158c57a | 654 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
603c27f8 AD |
655 | } else { |
656 | ||
603c27f8 AD |
657 | print " |
658 | Selection: | |
e828e31e AD |
659 | <input type=\"submit\" class=\"button\" |
660 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> | |
661 | <input type=\"submit\" class=\"button\" | |
662 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
663 | ||
f92db4f5 AD |
664 | if (ENABLE_PREFS_CATCHUP_UNCATCHUP) { |
665 | print " | |
e828e31e AD |
666 | <input type=\"submit\" class=\"button\" |
667 | onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\"> | |
668 | <input type=\"submit\" class=\"button\" | |
669 | onclick=\"javascript:unreadSelectedFeeds()\" value=\"Mark as unread\"> "; | |
f92db4f5 AD |
670 | } |
671 | print " | |
e828e31e AD |
672 | All feeds: |
673 | <input type=\"submit\" | |
8158c57a | 674 | class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">"; |
10c5820d | 675 | |
603c27f8 AD |
676 | } |
677 | ||
007bda35 AD |
678 | } |
679 | ||
a0d53889 AD |
680 | if ($op == "pref-filters") { |
681 | ||
682 | $subop = $_GET["subop"]; | |
683 | ||
684 | if ($subop == "editSave") { | |
a0d53889 | 685 | |
648472a7 AD |
686 | $regexp = db_escape_string($_GET["r"]); |
687 | $descr = db_escape_string($_GET["d"]); | |
688 | $match = db_escape_string($_GET["m"]); | |
689 | $filter_id = db_escape_string($_GET["id"]); | |
0afbd851 | 690 | |
648472a7 | 691 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 692 | reg_exp = '$regexp', |
0afbd851 AD |
693 | description = '$descr', |
694 | filter_type = (SELECT id FROM ttrss_filter_types WHERE | |
695 | description = '$match') | |
696 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
697 | } |
698 | ||
699 | if ($subop == "remove") { | |
700 | ||
701 | if (!WEB_DEMO_MODE) { | |
702 | ||
703 | $ids = split(",", $_GET["ids"]); | |
704 | ||
705 | foreach ($ids as $id) { | |
648472a7 | 706 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
707 | |
708 | } | |
709 | } | |
710 | } | |
711 | ||
712 | if ($subop == "add") { | |
713 | ||
de435974 | 714 | if (!WEB_DEMO_MODE) { |
a0d53889 | 715 | |
8158c57a | 716 | $regexp = db_escape_string($_GET["regexp"]); |
648472a7 | 717 | $match = db_escape_string($_GET["match"]); |
a0d53889 | 718 | |
648472a7 | 719 | $result = db_query($link, |
4b3dff6e | 720 | "INSERT INTO ttrss_filters (reg_exp,filter_type) VALUES |
de435974 AD |
721 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
722 | description = '$match'))"); | |
723 | } | |
a0d53889 AD |
724 | } |
725 | ||
648472a7 | 726 | $result = db_query($link, "SELECT description |
a0d53889 AD |
727 | FROM ttrss_filter_types ORDER BY description"); |
728 | ||
729 | $filter_types = array(); | |
730 | ||
648472a7 | 731 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
732 | array_push($filter_types, $line["description"]); |
733 | } | |
734 | ||
735 | print "<table class=\"prefAddFeed\"><tr> | |
ea6774cf | 736 | <td><input id=\"fadd_regexp\"></td> |
a0d53889 | 737 | <td>"; |
bdc00fe0 | 738 | print_select("fadd_match", "Title", $filter_types); |
a0d53889 AD |
739 | |
740 | print"</td><td colspan=\"4\" align=\"right\"> | |
741 | <a class=\"button\" href=\"javascript:addFilter()\">Add filter</a></td></tr> | |
742 | </table>"; | |
743 | ||
648472a7 | 744 | $result = db_query($link, "SELECT |
4b3dff6e | 745 | id,reg_exp,description, |
a0d53889 AD |
746 | (SELECT name FROM ttrss_filter_types WHERE |
747 | id = filter_type) as filter_type_name, | |
748 | (SELECT description FROM ttrss_filter_types | |
749 | WHERE id = filter_type) as filter_type_descr | |
750 | FROM | |
4b3dff6e | 751 | ttrss_filters ORDER by reg_exp"); |
a0d53889 AD |
752 | |
753 | print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">"; | |
754 | ||
755 | print "<tr class=\"title\"> | |
0afbd851 AD |
756 | <td width=\"5%\">Select</td><td width=\"40%\">Filter expression</td> |
757 | <td width=\"40%\">Description</td><td width=\"10%\">Match</td></tr>"; | |
a0d53889 AD |
758 | |
759 | $lnum = 0; | |
760 | ||
648472a7 | 761 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
762 | |
763 | $class = ($lnum % 2) ? "even" : "odd"; | |
764 | ||
765 | $filter_id = $line["id"]; | |
766 | $edit_filter_id = $_GET["id"]; | |
767 | ||
768 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
769 | $class .= "Grayed"; | |
770 | } | |
771 | ||
772 | print "<tr class=\"$class\" id=\"FILRR-$filter_id\">"; | |
773 | ||
4b3dff6e | 774 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); |
ea6774cf AD |
775 | $line["description"] = htmlspecialchars($line["description"]); |
776 | ||
a0d53889 AD |
777 | if (!$edit_filter_id || $subop != "edit") { |
778 | ||
0afbd851 AD |
779 | if (!$line["description"]) $line["description"] = "[No description]"; |
780 | ||
a0d53889 AD |
781 | print "<td><input onclick='toggleSelectRow(this);' |
782 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; | |
783 | ||
784 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
4b3dff6e | 785 | $line["reg_exp"] . "</td>"; |
a0d53889 AD |
786 | |
787 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
788 | $line["description"] . "</td>"; | |
789 | ||
790 | print "<td>".$line["filter_type_descr"]."</td>"; | |
791 | ||
792 | } else if ($filter_id != $edit_filter_id) { | |
793 | ||
0afbd851 AD |
794 | if (!$line["description"]) $line["description"] = "[No description]"; |
795 | ||
a0d53889 AD |
796 | print "<td><input disabled=\"true\" type=\"checkbox\" |
797 | id=\"FICHK-".$line["id"]."\"></td>"; | |
798 | ||
4b3dff6e | 799 | print "<td>".$line["reg_exp"]."</td>"; |
a0d53889 AD |
800 | print "<td>".$line["description"]."</td>"; |
801 | print "<td>".$line["filter_type_descr"]."</td>"; | |
802 | ||
803 | } else { | |
804 | ||
805 | print "<td><input disabled=\"true\" type=\"checkbox\"></td>"; | |
806 | ||
4b3dff6e | 807 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. |
a0d53889 AD |
808 | "\"></td>"; |
809 | ||
810 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
811 | "\"></td>"; | |
812 | ||
813 | print "<td>"; | |
814 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
815 | print "</td>"; | |
816 | ||
817 | } | |
818 | ||
819 | ||
820 | print "</tr>"; | |
821 | ||
822 | ++$lnum; | |
823 | } | |
824 | ||
0afbd851 AD |
825 | if ($lnum == 0) { |
826 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
827 | } | |
828 | ||
a0d53889 AD |
829 | print "</table>"; |
830 | ||
831 | print "<p>"; | |
832 | ||
833 | if ($subop == "edit") { | |
e828e31e AD |
834 | print "Edit feed: |
835 | <input type=\"submit\" class=\"button\" | |
836 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\"> | |
837 | <input type=\"submit\" class=\"button\" | |
838 | onclick=\"javascript:filterEditSave()\" value=\"Save\">"; | |
a0d53889 AD |
839 | |
840 | } else { | |
841 | ||
842 | print " | |
e828e31e AD |
843 | Selection: |
844 | <input type=\"submit\" class=\"button\" | |
845 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> | |
846 | <input type=\"submit\" class=\"button\" | |
847 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; | |
a0d53889 AD |
848 | } |
849 | } | |
850 | ||
e828e31e AD |
851 | if ($op == "error") { |
852 | print "<div width=\"100%\" align='center'>"; | |
853 | $msg = $_GET["msg"]; | |
854 | print $msg; | |
855 | print "</div>"; | |
856 | } | |
857 | ||
4b3dff6e | 858 | db_close($link); |
1cd17194 | 859 | ?> |