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