]>
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 | |
ac53063a AD |
268 | if (!$skip) $skip = 0; |
269 | ||
476cac42 | 270 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 271 | |
f0601b87 AD |
272 | if ($addheader) { |
273 | print "<html><head> | |
ac43eba1 | 274 | <title>Tiny Tiny RSS : Feed $feed</title> |
f0601b87 AD |
275 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> |
276 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
277 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
278 | <script type=\"text/javascript\" src=\"viewfeed.js\"></script> | |
279 | </head><body>"; | |
280 | } | |
281 | ||
8158c57a AD |
282 | if (DB_TYPE == "pgsql") { |
283 | $result = db_query($link, | |
284 | "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s, | |
285 | EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout | |
286 | FROM ttrss_feeds WHERE id = '$feed'"); | |
287 | } else { | |
288 | $result = db_query($link, | |
289 | "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s | |
290 | FROM ttrss_feeds WHERE id = '$feed'"); | |
291 | } | |
1cd17194 | 292 | |
d76a3b03 | 293 | if ($result) { |
1cd17194 | 294 | |
648472a7 | 295 | $line = db_fetch_assoc($result); |
1cd17194 | 296 | |
deaaa02c | 297 | update_rss_feed($link, $line["feed_url"], $feed); |
f0601b87 | 298 | |
deaaa02c | 299 | if ($subop == "MarkAllRead") { |
d76a3b03 | 300 | |
deaaa02c AD |
301 | db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() |
302 | WHERE feed_id = '$feed'"); | |
a1a8a2be AD |
303 | } |
304 | } | |
d76a3b03 | 305 | |
175847de | 306 | print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">"; |
ac53063a | 307 | |
a2015351 AD |
308 | $feed_last_updated = "Updated: " . $line["last_updated"]; |
309 | ||
c374a3fe AD |
310 | $search = $_GET["search"]; |
311 | ||
f175937c | 312 | if ($search) { |
ac53063a AD |
313 | $search_query_part = "(upper(title) LIKE upper('%$search%') |
314 | OR content LIKE '%$search%') AND"; | |
f175937c AD |
315 | } else { |
316 | $search_query_part = ""; | |
317 | } | |
318 | ||
319 | $view_query_part = ""; | |
320 | ||
321 | if ($view_mode == "Starred") { | |
322 | $view_query_part = " marked = true AND "; | |
ac53063a AD |
323 | } |
324 | ||
ac43eba1 AD |
325 | if ($view_mode == "Unread") { |
326 | $view_query_part = " unread = true AND "; | |
327 | } | |
328 | ||
648472a7 | 329 | $result = db_query($link, "SELECT count(id) AS total_entries |
36bf7496 AD |
330 | FROM ttrss_entries WHERE |
331 | $search_query_part | |
332 | feed_id = '$feed'"); | |
e6d1c0a0 | 333 | |
648472a7 | 334 | $total_entries = db_fetch_result($result, 0, "total_entries"); |
e6d1c0a0 | 335 | |
648472a7 | 336 | /* $result = db_query("SELECT count(id) AS unread_entries |
ac43eba1 AD |
337 | FROM ttrss_entries WHERE |
338 | $search_query_part | |
339 | unread = true AND | |
340 | feed_id = '$feed'"); | |
341 | ||
648472a7 | 342 | $unread_entries = db_fetch_result($result, 0, "unread_entries"); */ |
ac43eba1 | 343 | |
82c9223c AD |
344 | if ($limit != "All") { |
345 | $limit_query_part = "LIMIT " . $limit; | |
ad3cb710 | 346 | } |
f0601b87 | 347 | |
648472a7 | 348 | $result = db_query($link, "SELECT |
deaaa02c | 349 | id,title,updated,unread,feed_id,marked,link,last_read |
b197f117 AD |
350 | FROM |
351 | ttrss_entries | |
352 | WHERE | |
ac53063a | 353 | $search_query_part |
f175937c | 354 | $view_query_part |
f0601b87 AD |
355 | feed_id = '$feed' ORDER BY updated DESC |
356 | $limit_query_part"); | |
d76a3b03 | 357 | |
a1a8a2be | 358 | $lnum = 0; |
e1123aee AD |
359 | |
360 | $num_unread = 0; | |
d76a3b03 | 361 | |
648472a7 | 362 | while ($line = db_fetch_assoc($result)) { |
d76a3b03 | 363 | |
a1a8a2be | 364 | $class = ($lnum % 2) ? "even" : "odd"; |
d76a3b03 | 365 | |
ad99045e AD |
366 | $id = $line["id"]; |
367 | $feed_id = $line["feed_id"]; | |
368 | ||
deaaa02c AD |
369 | // printf("%d %s - %d %s<br>", strtotime($line["last_read"]), $line["last_read"], |
370 | // strtotime($line["updated"]), $line["updated"]); | |
371 | ||
372 | if (strtotime($line["last_read"]) < strtotime($line["updated"]) && | |
373 | ($line["unread"] == "f" || $line["unread"] == "0")) { | |
374 | ||
ad99045e AD |
375 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" |
376 | alt=\"Updated\">"; | |
e1123aee | 377 | ++$num_unread; |
b197f117 | 378 | } else { |
ad99045e AD |
379 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.png\" |
380 | alt=\"Updated\">"; | |
b197f117 AD |
381 | } |
382 | ||
8158c57a | 383 | if ($line["unread"] == "t" || $line["unread"] == "1") { |
a1a8a2be | 384 | $class .= "Unread"; |
e1123aee AD |
385 | ++$num_unread; |
386 | } | |
d76a3b03 | 387 | |
8158c57a | 388 | if ($line["marked"] == "t" || $line["marked"] == "1") { |
f4c10d44 AD |
389 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" |
390 | alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>"; | |
391 | } else { | |
392 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
393 | alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>"; | |
394 | } | |
395 | ||
ac43eba1 | 396 | $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" . |
b197f117 AD |
397 | $line["title"] . "</a>"; |
398 | ||
5f89f780 AD |
399 | print "<tr class='$class' id='RROW-$id'"; |
400 | // onclick=\"javascript:view($id,$feed_id)\"> | |
b197f117 | 401 | |
ad99045e | 402 | print "<td valign='center' align='center' |
f4c10d44 AD |
403 | class='headlineUpdateMark'>$update_pic</td>"; |
404 | ||
c80e2175 | 405 | print "<td valign='center' align='center' |
f4c10d44 | 406 | class='headlineUpdateMark'>$marked_pic</td>"; |
b197f117 | 407 | |
c80e2175 | 408 | print "<td class='headlineUpdated' width='25%'> |
a3ee2a38 | 409 | <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>"; |
c80e2175 | 410 | print "<td width='70%' class='headlineTitle'>$content_link</td>"; |
d76a3b03 | 411 | |
a1a8a2be | 412 | print "</tr>"; |
d76a3b03 | 413 | |
a1a8a2be AD |
414 | ++$lnum; |
415 | } | |
d76a3b03 | 416 | |
ac53063a AD |
417 | if ($lnum == 0) { |
418 | print "<tr><td align='center'>No entries found.</td></tr>"; | |
047bae73 | 419 | } |
ac53063a | 420 | |
047bae73 AD |
421 | while ($lnum < HEADLINES_PER_PAGE) { |
422 | ++$lnum; | |
423 | print "<tr><td> </td></tr>"; | |
ac53063a | 424 | } |
a2015351 | 425 | |
a1a8a2be | 426 | print "</table>"; |
d76a3b03 | 427 | |
648472a7 | 428 | $result = db_query($link, "SELECT id, (SELECT count(id) FROM ttrss_entries |
a1a8a2be AD |
429 | WHERE feed_id = ttrss_feeds.id) AS total, |
430 | (SELECT count(id) FROM ttrss_entries | |
431 | WHERE feed_id = ttrss_feeds.id AND unread = true) as unread | |
432 | FROM ttrss_feeds WHERE id = '$feed'"); | |
d76a3b03 | 433 | |
648472a7 AD |
434 | $total = db_fetch_result($result, 0, "total"); |
435 | $unread = db_fetch_result($result, 0, "unread"); | |
d76a3b03 | 436 | |
6113ef7d AD |
437 | // update unread/total counters and status for active feed in the feedlist |
438 | // kludge, because iframe doesn't seem to support onload() | |
439 | ||
440 | print "<script type=\"text/javascript\"> | |
bb7cface AD |
441 | document.onkeydown = hotkey_handler; |
442 | ||
1a66d16e AD |
443 | var p_document = parent.frames['feeds-frame'].document; |
444 | ||
445 | var feedr = p_document.getElementById(\"FEEDR-\" + $feed); | |
1a66d16e | 446 | var feedu = p_document.getElementById(\"FEEDU-\" + $feed); |
6113ef7d | 447 | |
0c674406 AD |
448 | if (feedu) { |
449 | feedu.innerHTML = \"$unread\"; | |
450 | } | |
451 | ||
452 | var feedctr = p_document.getElementById(\"FEEDCTR-\" + $feed); | |
6113ef7d AD |
453 | |
454 | if ($unread > 0 && !feedr.className.match(\"Unread\")) { | |
455 | feedr.className = feedr.className + \"Unread\"; | |
0c674406 | 456 | feedctr.className = ''; |
6113ef7d AD |
457 | } else if ($unread <= 0) { |
458 | feedr.className = feedr.className.replace(\"Unread\", \"\"); | |
0c674406 | 459 | feedctr.className = 'invisible'; |
6113ef7d | 460 | } |
c05608c2 | 461 | |
90e395dc | 462 | // p_notify(\"\"); |
0c674406 | 463 | |
6113ef7d | 464 | </script>"; |
d76a3b03 | 465 | |
f0601b87 AD |
466 | if ($addheader) { |
467 | print "</body></html>"; | |
468 | } | |
469 | ||
1cd17194 AD |
470 | } |
471 | ||
0e091d38 | 472 | if ($op == "pref-rpc") { |
331900c6 | 473 | |
0e091d38 | 474 | $subop = $_GET["subop"]; |
331900c6 | 475 | |
83fe4d6d AD |
476 | if ($subop == "unread") { |
477 | $ids = split(",", $_GET["ids"]); | |
478 | foreach ($ids as $id) { | |
648472a7 | 479 | db_query($link, "UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'"); |
83fe4d6d | 480 | } |
0e091d38 AD |
481 | |
482 | print "Marked selected feeds as read."; | |
83fe4d6d AD |
483 | } |
484 | ||
485 | if ($subop == "read") { | |
486 | $ids = split(",", $_GET["ids"]); | |
487 | foreach ($ids as $id) { | |
648472a7 | 488 | db_query($link, "UPDATE ttrss_entries |
b197f117 | 489 | SET unread = false,last_read = NOW() WHERE feed_id = '$id'"); |
83fe4d6d | 490 | } |
0e091d38 AD |
491 | |
492 | print "Marked selected feeds as unread."; | |
493 | ||
494 | } | |
495 | ||
496 | } | |
497 | ||
498 | if ($op == "pref-feeds") { | |
499 | ||
500 | $subop = $_GET["subop"]; | |
501 | ||
508a81e1 | 502 | if ($subop == "editSave") { |
648472a7 AD |
503 | $feed_title = db_escape_string($_GET["t"]); |
504 | $feed_link = db_escape_string($_GET["l"]); | |
508a81e1 AD |
505 | $feed_id = $_GET["id"]; |
506 | ||
648472a7 | 507 | $result = db_query($link, "UPDATE ttrss_feeds SET |
508a81e1 AD |
508 | title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'"); |
509 | ||
83fe4d6d AD |
510 | } |
511 | ||
331900c6 | 512 | if ($subop == "remove") { |
331900c6 | 513 | |
b0b4abcf | 514 | if (!WEB_DEMO_MODE) { |
331900c6 | 515 | |
b0b4abcf AD |
516 | $ids = split(",", $_GET["ids"]); |
517 | ||
518 | foreach ($ids as $id) { | |
648472a7 AD |
519 | db_query($link, "BEGIN"); |
520 | db_query($link, "DELETE FROM ttrss_entries WHERE feed_id = '$id'"); | |
521 | db_query($link, "DELETE FROM ttrss_feeds WHERE id = '$id'"); | |
522 | db_query($link, "COMMIT"); | |
d5caaae5 AD |
523 | |
524 | if (file_exists(ICONS_DIR . "/$id.ico")) { | |
525 | unlink(ICONS_DIR . "/$id.ico"); | |
526 | } | |
b0b4abcf | 527 | } |
331900c6 AD |
528 | } |
529 | } | |
530 | ||
531 | if ($subop == "add") { | |
b0b4abcf AD |
532 | |
533 | if (!WEB_DEMO_MODE) { | |
331900c6 | 534 | |
648472a7 | 535 | $feed_link = db_escape_string($_GET["link"]); |
b0b4abcf | 536 | |
648472a7 | 537 | $result = db_query($link, |
b0b4abcf | 538 | "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')"); |
331900c6 | 539 | |
648472a7 | 540 | $result = db_query($link, |
e9c54861 | 541 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'"); |
331900c6 | 542 | |
648472a7 | 543 | $feed_id = db_fetch_result($result, 0, "id"); |
331900c6 | 544 | |
b0b4abcf AD |
545 | if ($feed_id) { |
546 | update_rss_feed($link, $feed_link, $feed_id); | |
547 | } | |
548 | } | |
331900c6 | 549 | } |
a0d53889 AD |
550 | |
551 | print "<table class=\"prefAddFeed\"><tr> | |
552 | <td><input id=\"fadd_link\"></td> | |
553 | <td colspan=\"4\" align=\"right\"> | |
554 | <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr> | |
555 | </table>"; | |
556 | ||
648472a7 | 557 | $result = db_query($link, "SELECT |
c0e5a40e AD |
558 | id,title,feed_url,substring(last_updated,1,16) as last_updated |
559 | FROM | |
560 | ttrss_feeds ORDER by title"); | |
1cd17194 | 561 | |
331900c6 | 562 | print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">"; |
007bda35 | 563 | print "<tr class=\"title\"> |
603c27f8 | 564 | <td> </td><td>Select</td><td width=\"40%\">Title</td> |
0afbd851 | 565 | <td width=\"40%\">Link</td><td>Last updated</td></tr>"; |
007bda35 AD |
566 | |
567 | $lnum = 0; | |
568 | ||
648472a7 | 569 | while ($line = db_fetch_assoc($result)) { |
007bda35 AD |
570 | |
571 | $class = ($lnum % 2) ? "even" : "odd"; | |
9b307248 | 572 | |
331900c6 | 573 | $feed_id = $line["id"]; |
603c27f8 AD |
574 | |
575 | $edit_feed_id = $_GET["id"]; | |
576 | ||
9b307248 AD |
577 | if ($subop == "edit" && $feed_id != $edit_feed_id) { |
578 | $class .= "Grayed"; | |
579 | } | |
580 | ||
331900c6 | 581 | print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">"; |
007bda35 | 582 | |
c0e5a40e AD |
583 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
584 | ||
585 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
586 | $feed_icon = "<img width=\"16\" height=\"16\" | |
587 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
588 | } else { | |
589 | $feed_icon = " "; | |
590 | } | |
591 | print "<td align='center'>$feed_icon</td>"; | |
592 | ||
9b307248 | 593 | if (!$edit_feed_id || $subop != "edit") { |
603c27f8 AD |
594 | |
595 | print "<td><input onclick='toggleSelectRow(this);' | |
331900c6 | 596 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
603c27f8 AD |
597 | |
598 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
599 | $line["title"] . "</td>"; | |
600 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
601 | $line["feed_url"] . "</td>"; | |
9b307248 AD |
602 | |
603 | ||
604 | } else if ($feed_id != $edit_feed_id) { | |
605 | ||
e9c54861 AD |
606 | print "<td><input disabled=\"true\" type=\"checkbox\" |
607 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
9b307248 AD |
608 | |
609 | print "<td>".$line["title"]."</td>"; | |
610 | print "<td>".$line["feed_url"]."</td>"; | |
611 | ||
603c27f8 AD |
612 | } else { |
613 | ||
e9c54861 | 614 | print "<td><input disabled=\"true\" type=\"checkbox\"></td>"; |
603c27f8 AD |
615 | |
616 | print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>"; | |
617 | print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>"; | |
618 | ||
619 | } | |
0afbd851 AD |
620 | |
621 | if (!$line["last_updated"]) $line["last_updated"] = "Never"; | |
622 | ||
007bda35 | 623 | print "<td>" . $line["last_updated"] . "</td>"; |
603c27f8 | 624 | |
007bda35 AD |
625 | print "</tr>"; |
626 | ||
627 | ++$lnum; | |
628 | } | |
629 | ||
0afbd851 AD |
630 | if ($lnum == 0) { |
631 | print "<tr><td colspan=\"5\" align=\"center\">No feeds defined.</td></tr>"; | |
632 | } | |
633 | ||
007bda35 AD |
634 | print "</table>"; |
635 | ||
603c27f8 AD |
636 | print "<p>"; |
637 | ||
638 | if ($subop == "edit") { | |
639 | print "Edit feed: | |
e828e31e AD |
640 | <input type=\"submit\" class=\"button\" |
641 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> | |
642 | <input type=\"submit\" class=\"button\" | |
8158c57a | 643 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
603c27f8 AD |
644 | } else { |
645 | ||
603c27f8 AD |
646 | print " |
647 | Selection: | |
e828e31e AD |
648 | <input type=\"submit\" class=\"button\" |
649 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> | |
650 | <input type=\"submit\" class=\"button\" | |
651 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
652 | ||
f92db4f5 AD |
653 | if (ENABLE_PREFS_CATCHUP_UNCATCHUP) { |
654 | print " | |
e828e31e AD |
655 | <input type=\"submit\" class=\"button\" |
656 | onclick=\"javascript:readSelectedFeeds()\" value=\"Mark as read\"> | |
657 | <input type=\"submit\" class=\"button\" | |
658 | onclick=\"javascript:unreadSelectedFeeds()\" value=\"Mark as unread\"> "; | |
f92db4f5 AD |
659 | } |
660 | print " | |
e828e31e AD |
661 | All feeds: |
662 | <input type=\"submit\" | |
8158c57a | 663 | class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">"; |
10c5820d | 664 | |
603c27f8 AD |
665 | } |
666 | ||
007bda35 AD |
667 | } |
668 | ||
a0d53889 AD |
669 | if ($op == "pref-filters") { |
670 | ||
671 | $subop = $_GET["subop"]; | |
672 | ||
673 | if ($subop == "editSave") { | |
a0d53889 | 674 | |
648472a7 AD |
675 | $regexp = db_escape_string($_GET["r"]); |
676 | $descr = db_escape_string($_GET["d"]); | |
677 | $match = db_escape_string($_GET["m"]); | |
678 | $filter_id = db_escape_string($_GET["id"]); | |
0afbd851 | 679 | |
648472a7 | 680 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 681 | reg_exp = '$regexp', |
0afbd851 AD |
682 | description = '$descr', |
683 | filter_type = (SELECT id FROM ttrss_filter_types WHERE | |
684 | description = '$match') | |
685 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
686 | } |
687 | ||
688 | if ($subop == "remove") { | |
689 | ||
690 | if (!WEB_DEMO_MODE) { | |
691 | ||
692 | $ids = split(",", $_GET["ids"]); | |
693 | ||
694 | foreach ($ids as $id) { | |
648472a7 | 695 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
696 | |
697 | } | |
698 | } | |
699 | } | |
700 | ||
701 | if ($subop == "add") { | |
702 | ||
de435974 | 703 | if (!WEB_DEMO_MODE) { |
a0d53889 | 704 | |
8158c57a | 705 | $regexp = db_escape_string($_GET["regexp"]); |
648472a7 | 706 | $match = db_escape_string($_GET["match"]); |
a0d53889 | 707 | |
648472a7 | 708 | $result = db_query($link, |
4b3dff6e | 709 | "INSERT INTO ttrss_filters (reg_exp,filter_type) VALUES |
de435974 AD |
710 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
711 | description = '$match'))"); | |
712 | } | |
a0d53889 AD |
713 | } |
714 | ||
648472a7 | 715 | $result = db_query($link, "SELECT description |
a0d53889 AD |
716 | FROM ttrss_filter_types ORDER BY description"); |
717 | ||
718 | $filter_types = array(); | |
719 | ||
648472a7 | 720 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
721 | array_push($filter_types, $line["description"]); |
722 | } | |
723 | ||
724 | print "<table class=\"prefAddFeed\"><tr> | |
ea6774cf | 725 | <td><input id=\"fadd_regexp\"></td> |
a0d53889 | 726 | <td>"; |
bdc00fe0 | 727 | print_select("fadd_match", "Title", $filter_types); |
a0d53889 AD |
728 | |
729 | print"</td><td colspan=\"4\" align=\"right\"> | |
730 | <a class=\"button\" href=\"javascript:addFilter()\">Add filter</a></td></tr> | |
731 | </table>"; | |
732 | ||
648472a7 | 733 | $result = db_query($link, "SELECT |
4b3dff6e | 734 | id,reg_exp,description, |
a0d53889 AD |
735 | (SELECT name FROM ttrss_filter_types WHERE |
736 | id = filter_type) as filter_type_name, | |
737 | (SELECT description FROM ttrss_filter_types | |
738 | WHERE id = filter_type) as filter_type_descr | |
739 | FROM | |
4b3dff6e | 740 | ttrss_filters ORDER by reg_exp"); |
a0d53889 AD |
741 | |
742 | print "<p><table width=\"100%\" class=\"prefFilterList\" id=\"prefFilterList\">"; | |
743 | ||
744 | print "<tr class=\"title\"> | |
0afbd851 AD |
745 | <td width=\"5%\">Select</td><td width=\"40%\">Filter expression</td> |
746 | <td width=\"40%\">Description</td><td width=\"10%\">Match</td></tr>"; | |
a0d53889 AD |
747 | |
748 | $lnum = 0; | |
749 | ||
648472a7 | 750 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
751 | |
752 | $class = ($lnum % 2) ? "even" : "odd"; | |
753 | ||
754 | $filter_id = $line["id"]; | |
755 | $edit_filter_id = $_GET["id"]; | |
756 | ||
757 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
758 | $class .= "Grayed"; | |
759 | } | |
760 | ||
761 | print "<tr class=\"$class\" id=\"FILRR-$filter_id\">"; | |
762 | ||
4b3dff6e | 763 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); |
ea6774cf AD |
764 | $line["description"] = htmlspecialchars($line["description"]); |
765 | ||
a0d53889 AD |
766 | if (!$edit_filter_id || $subop != "edit") { |
767 | ||
0afbd851 AD |
768 | if (!$line["description"]) $line["description"] = "[No description]"; |
769 | ||
a0d53889 AD |
770 | print "<td><input onclick='toggleSelectRow(this);' |
771 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; | |
772 | ||
773 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
4b3dff6e | 774 | $line["reg_exp"] . "</td>"; |
a0d53889 AD |
775 | |
776 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
777 | $line["description"] . "</td>"; | |
778 | ||
779 | print "<td>".$line["filter_type_descr"]."</td>"; | |
780 | ||
781 | } else if ($filter_id != $edit_filter_id) { | |
782 | ||
0afbd851 AD |
783 | if (!$line["description"]) $line["description"] = "[No description]"; |
784 | ||
a0d53889 AD |
785 | print "<td><input disabled=\"true\" type=\"checkbox\" |
786 | id=\"FICHK-".$line["id"]."\"></td>"; | |
787 | ||
4b3dff6e | 788 | print "<td>".$line["reg_exp"]."</td>"; |
a0d53889 AD |
789 | print "<td>".$line["description"]."</td>"; |
790 | print "<td>".$line["filter_type_descr"]."</td>"; | |
791 | ||
792 | } else { | |
793 | ||
794 | print "<td><input disabled=\"true\" type=\"checkbox\"></td>"; | |
795 | ||
4b3dff6e | 796 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. |
a0d53889 AD |
797 | "\"></td>"; |
798 | ||
799 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
800 | "\"></td>"; | |
801 | ||
802 | print "<td>"; | |
803 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
804 | print "</td>"; | |
805 | ||
806 | } | |
807 | ||
808 | ||
809 | print "</tr>"; | |
810 | ||
811 | ++$lnum; | |
812 | } | |
813 | ||
0afbd851 AD |
814 | if ($lnum == 0) { |
815 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
816 | } | |
817 | ||
a0d53889 AD |
818 | print "</table>"; |
819 | ||
820 | print "<p>"; | |
821 | ||
822 | if ($subop == "edit") { | |
e828e31e AD |
823 | print "Edit feed: |
824 | <input type=\"submit\" class=\"button\" | |
825 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\"> | |
826 | <input type=\"submit\" class=\"button\" | |
827 | onclick=\"javascript:filterEditSave()\" value=\"Save\">"; | |
a0d53889 AD |
828 | |
829 | } else { | |
830 | ||
831 | print " | |
e828e31e AD |
832 | Selection: |
833 | <input type=\"submit\" class=\"button\" | |
834 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> | |
835 | <input type=\"submit\" class=\"button\" | |
836 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; | |
a0d53889 AD |
837 | } |
838 | } | |
839 | ||
e828e31e AD |
840 | if ($op == "error") { |
841 | print "<div width=\"100%\" align='center'>"; | |
842 | $msg = $_GET["msg"]; | |
843 | print $msg; | |
844 | print "</div>"; | |
845 | } | |
846 | ||
4b3dff6e | 847 | db_close($link); |
1cd17194 | 848 | ?> |