]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | <? |
4356293a | 2 | session_start(); |
090e250b | 3 | |
cce28758 AD |
4 | if ($_GET["debug"]) { |
5 | define('DEFAULT_ERROR_LEVEL', E_ALL); | |
6 | } else { | |
7 | define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); | |
8 | } | |
9 | ||
10 | error_reporting(DEFAULT_ERROR_LEVEL); | |
11 | ||
262bd8ea AD |
12 | $op = $_REQUEST["op"]; |
13 | ||
a2770077 | 14 | if ((!$op || $op == "rpc" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { |
262bd8ea AD |
15 | header("Content-Type: application/xml"); |
16 | } | |
17 | ||
a2770077 | 18 | if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") { |
262bd8ea | 19 | |
a2770077 | 20 | if ($op == "rpc") { |
262bd8ea AD |
21 | print "<error error-code=\"6\"/>"; |
22 | } | |
23 | exit; | |
24 | } | |
1c7f75ed | 25 | |
a2770077 AD |
26 | if (!$op) { |
27 | print "<error error-code=\"7\"/>"; | |
28 | exit; | |
29 | } | |
30 | ||
cce28758 | 31 | define('SCHEMA_VERSION', 2); |
1cd17194 | 32 | |
66581886 | 33 | require_once "sanity_check.php"; |
82baad4a | 34 | require_once "config.php"; |
648472a7 | 35 | require_once "db.php"; |
3bac89ad | 36 | require_once "db-prefs.php"; |
82baad4a AD |
37 | require_once "functions.php"; |
38 | require_once "magpierss/rss_fetch.inc"; | |
1cd17194 | 39 | |
406d9489 AD |
40 | $script_started = getmicrotime(); |
41 | ||
648472a7 | 42 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
d76a3b03 | 43 | |
5136011e AD |
44 | if (!$link) { |
45 | if (DB_TYPE == "mysql") { | |
46 | print mysql_error(); | |
47 | } | |
48 | // PG seems to display its own errors just fine by default. | |
49 | return; | |
50 | } | |
51 | ||
648472a7 AD |
52 | if (DB_TYPE == "pgsql") { |
53 | pg_query("set client_encoding = 'utf-8'"); | |
54 | } | |
7ec2a838 | 55 | |
331900c6 | 56 | $fetch = $_GET["fetch"]; |
175847de | 57 | |
1572afe5 AD |
58 | function getAllCounters($link) { |
59 | getLabelCounters($link); | |
60 | getFeedCounters($link); | |
61 | getTagCounters($link); | |
62 | getGlobalCounters($link); | |
63 | } | |
64 | ||
8143ae1f AD |
65 | /* FIXME this needs reworking */ |
66 | ||
fc69e641 | 67 | function getGlobalCounters($link) { |
4c193675 AD |
68 | $result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries |
69 | WHERE unread = true AND | |
70 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
71 | owner_uid = " . $_SESSION["uid"]); | |
fc69e641 AD |
72 | $c_id = db_fetch_result($result, 0, "c_id"); |
73 | print "<counter id='global-unread' counter='$c_id'/>"; | |
74 | } | |
75 | ||
8143ae1f | 76 | function getTagCounters($link) { |
05732aa0 | 77 | |
8143ae1f | 78 | $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count |
4c193675 AD |
79 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE |
80 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
4356293a | 81 | ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND |
05732aa0 | 82 | post_int_id = ttrss_user_entries.int_id AND unread = true GROUP BY tag_name |
8143ae1f | 83 | UNION |
4356293a AD |
84 | select tag_name,0 as count FROM ttrss_tags |
85 | WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]); | |
8143ae1f AD |
86 | |
87 | $tags = array(); | |
88 | ||
89 | while ($line = db_fetch_assoc($result)) { | |
90 | $tags[$line["tag_name"]] += $line["count"]; | |
91 | } | |
92 | ||
93 | foreach (array_keys($tags) as $tag) { | |
94 | $unread = $tags[$tag]; | |
95 | ||
96 | $tag = htmlspecialchars($tag); | |
97 | print "<tag id=\"$tag\" counter=\"$unread\"/>"; | |
98 | } | |
99 | } | |
100 | ||
090e250b AD |
101 | function getLabelCounters($link) { |
102 | ||
4c193675 AD |
103 | $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries |
104 | WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND | |
105 | unread = true AND owner_uid = ".$_SESSION["uid"]); | |
090e250b | 106 | |
d61fd764 | 107 | $count = db_fetch_result($result, 0, "count"); |
090e250b AD |
108 | |
109 | print "<label id=\"-1\" counter=\"$count\"/>"; | |
110 | ||
4356293a AD |
111 | $result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM |
112 | ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description"); | |
090e250b AD |
113 | |
114 | while ($line = db_fetch_assoc($result)) { | |
115 | ||
116 | $id = -$line["id"] - 11; | |
117 | ||
118 | error_reporting (0); | |
d61fd764 | 119 | |
4c193675 | 120 | $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries |
655be073 | 121 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND |
4c193675 | 122 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
655be073 | 123 | owner_uid = ".$_SESSION["uid"]); |
090e250b | 124 | |
d61fd764 | 125 | $count = db_fetch_result($tmp_result, 0, "count"); |
090e250b | 126 | |
ab3f3f72 | 127 | print "<label id=\"$id\" counter=\"$count\"/>"; |
090e250b | 128 | |
cce28758 | 129 | error_reporting (DEFAULT_ERROR_LEVEL); |
090e250b AD |
130 | |
131 | } | |
132 | } | |
133 | ||
8073cce7 AD |
134 | function getFeedCounter($link, $id) { |
135 | ||
136 | $result = db_query($link, "SELECT | |
4c193675 AD |
137 | count(id) as count FROM ttrss_entries,ttrss_user_entries |
138 | WHERE feed_id = '$id' AND unread = true | |
139 | AND ttrss_user_entries.ref_id = ttrss_entries.id"); | |
8073cce7 AD |
140 | |
141 | $count = db_fetch_result($result, 0, "count"); | |
142 | ||
143 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
144 | } | |
090e250b | 145 | |
8073cce7 AD |
146 | function getFeedCounters($link) { |
147 | ||
090e250b | 148 | $result = db_query($link, "SELECT id, |
4c193675 AD |
149 | (SELECT count(id) |
150 | FROM ttrss_entries,ttrss_user_entries | |
151 | WHERE feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id | |
b88917af | 152 | AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count |
4356293a | 153 | FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]); |
090e250b AD |
154 | |
155 | while ($line = db_fetch_assoc($result)) { | |
156 | ||
157 | $id = $line["id"]; | |
158 | $count = $line["count"]; | |
159 | ||
160 | print "<feed id=\"$id\" counter=\"$count\"/>"; | |
161 | } | |
162 | } | |
163 | ||
8143ae1f | 164 | function outputFeedList($link, $tags = false) { |
175847de | 165 | |
1a66d16e AD |
166 | print "<html><head> |
167 | <title>Tiny Tiny RSS : Feedlist</title> | |
430bf183 AD |
168 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
169 | ||
503eb349 AD |
170 | $user_theme = $_SESSION["theme"]; |
171 | if ($user_theme) { | |
172 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
173 | href=\"themes/$user_theme/theme.css\">"; | |
174 | } | |
175 | ||
4769ddaf | 176 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
430bf183 AD |
177 | print "<link rel=\"stylesheet\" type=\"text/css\" |
178 | href=\"tt-rss_compact.css\"/>"; | |
179 | } else { | |
180 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
181 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
182 | } | |
183 | ||
184 | print "<script type=\"text/javascript\" src=\"functions.js\"></script> | |
1a66d16e AD |
185 | <script type=\"text/javascript\" src=\"feedlist.js\"></script> |
186 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
3745788e | 187 | </head><body onload=\"init()\">"; |
254e0e4b AD |
188 | |
189 | print "<ul class=\"feedList\" id=\"feedList\">"; | |
190 | ||
4356293a AD |
191 | $owner_uid = $_SESSION["uid"]; |
192 | ||
8143ae1f | 193 | if (!$tags) { |
254e0e4b | 194 | |
8143ae1f | 195 | /* virtual feeds */ |
254e0e4b | 196 | |
91ff844a AD |
197 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
198 | print "<li class=\"feedCat\">Special</li>"; | |
703b632e | 199 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
91ff844a AD |
200 | } |
201 | ||
8143ae1f | 202 | $result = db_query($link, "SELECT count(id) as num_starred |
4c193675 AD |
203 | FROM ttrss_entries,ttrss_user_entries |
204 | WHERE marked = true AND | |
205 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
206 | unread = true AND owner_uid = '$owner_uid'"); | |
8143ae1f | 207 | $num_starred = db_fetch_result($result, 0, "num_starred"); |
254e0e4b | 208 | |
3745788e | 209 | $class = "virt"; |
8add756a AD |
210 | |
211 | if ($num_starred > 0) $class .= "Unread"; | |
212 | ||
213 | printFeedEntry(-1, $class, "Starred articles", $num_starred, | |
4668523d | 214 | "images/mark_set.png", $link); |
48f0adb0 | 215 | |
91ff844a | 216 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
703b632e | 217 | print "</li></ul>"; |
91ff844a AD |
218 | } |
219 | ||
4769ddaf | 220 | if (get_pref($link, 'ENABLE_LABELS')) { |
8143ae1f AD |
221 | |
222 | $result = db_query($link, "SELECT id,sql_exp,description FROM | |
4356293a | 223 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); |
8143ae1f AD |
224 | |
225 | if (db_num_rows($result) > 0) { | |
91ff844a AD |
226 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
227 | print "<li class=\"feedCat\">Labels</li>"; | |
703b632e | 228 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
91ff844a AD |
229 | } else { |
230 | print "<li><hr></li>"; | |
231 | } | |
8143ae1f AD |
232 | } |
233 | ||
234 | while ($line = db_fetch_assoc($result)) { | |
48f0adb0 | 235 | |
8143ae1f AD |
236 | error_reporting (0); |
237 | ||
4c193675 AD |
238 | $tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries |
239 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND | |
240 | ttrss_user_entries.ref_id = ttrss_entries.id | |
655be073 | 241 | AND owner_uid = '$owner_uid'"); |
8143ae1f AD |
242 | |
243 | $count = db_fetch_result($tmp_result, 0, "count"); | |
244 | ||
3745788e | 245 | $class = "label"; |
8143ae1f AD |
246 | |
247 | if ($count > 0) { | |
248 | $class .= "Unread"; | |
249 | } | |
250 | ||
cce28758 | 251 | error_reporting (DEFAULT_ERROR_LEVEL); |
8143ae1f AD |
252 | |
253 | printFeedEntry(-$line["id"]-11, | |
4668523d | 254 | $class, $line["description"], $count, "images/label.png", $link); |
8143ae1f AD |
255 | |
256 | } | |
91ff844a AD |
257 | |
258 | if (db_num_rows($result) > 0) { | |
259 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
703b632e | 260 | print "</li></ul>"; |
91ff844a AD |
261 | } |
262 | } | |
263 | ||
264 | } | |
265 | ||
266 | // if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
267 | print "<li><hr></li>"; | |
268 | // } | |
269 | ||
270 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
271 | $order_by_qpart = "category,title"; | |
272 | } else { | |
273 | $order_by_qpart = "title"; | |
48f0adb0 | 274 | } |
8143ae1f AD |
275 | |
276 | $result = db_query($link, "SELECT *, | |
4c193675 AD |
277 | (SELECT count(id) FROM ttrss_entries,ttrss_user_entries |
278 | WHERE feed_id = ttrss_feeds.id AND | |
279 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
280 | owner_uid = '$owner_uid') AS total, | |
281 | (SELECT count(id) FROM ttrss_entries,ttrss_user_entries | |
b88917af | 282 | WHERE feed_id = ttrss_feeds.id AND unread = true |
4c193675 | 283 | AND ttrss_user_entries.ref_id = ttrss_entries.id |
91ff844a AD |
284 | AND owner_uid = '$owner_uid') as unread, |
285 | (SELECT title FROM ttrss_feed_categories | |
286 | WHERE id = cat_id) AS category | |
287 | FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY $order_by_qpart"); | |
8143ae1f AD |
288 | |
289 | $actid = $_GET["actid"]; | |
290 | ||
291 | /* real feeds */ | |
292 | ||
293 | $lnum = 0; | |
294 | ||
295 | $total_unread = 0; | |
91ff844a AD |
296 | |
297 | $category = ""; | |
8143ae1f | 298 | |
48f0adb0 | 299 | while ($line = db_fetch_assoc($result)) { |
8143ae1f AD |
300 | |
301 | $feed = $line["title"]; | |
302 | $feed_id = $line["id"]; | |
303 | ||
304 | $subop = $_GET["subop"]; | |
305 | ||
306 | $total = $line["total"]; | |
307 | $unread = $line["unread"]; | |
91ff844a AD |
308 | |
309 | $tmp_category = $line["category"]; | |
310 | ||
311 | if (!$tmp_category) { | |
312 | $tmp_category = "Uncategorized"; | |
313 | } | |
8143ae1f AD |
314 | |
315 | // $class = ($lnum % 2) ? "even" : "odd"; | |
48f0adb0 | 316 | |
3745788e | 317 | $class = "feed"; |
8143ae1f AD |
318 | |
319 | if ($unread > 0) $class .= "Unread"; | |
320 | ||
321 | if ($actid == $feed_id) { | |
322 | $class .= "Selected"; | |
392d4563 | 323 | } |
48f0adb0 | 324 | |
8143ae1f | 325 | $total_unread += $unread; |
91ff844a AD |
326 | |
327 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
328 | ||
329 | if ($category) { | |
330 | print "</li></ul></li>"; | |
331 | } | |
332 | ||
333 | $category = $tmp_category; | |
334 | ||
335 | print "<li class=\"feedCat\">$category</li>"; | |
703b632e | 336 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; |
91ff844a | 337 | } |
8143ae1f | 338 | |
91ff844a AD |
339 | printFeedEntry($feed_id, $class, $feed, $unread, |
340 | "icons/$feed_id.ico", $link); | |
8143ae1f AD |
341 | |
342 | ++$lnum; | |
48f0adb0 | 343 | } |
91ff844a | 344 | |
8143ae1f | 345 | } else { |
a1a8a2be | 346 | |
8143ae1f | 347 | // tags |
a1a8a2be | 348 | |
8143ae1f | 349 | $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count |
05732aa0 AD |
350 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE |
351 | post_int_id = ttrss_user_entries.int_id AND | |
352 | unread = true AND ref_id = ttrss_entries.id | |
3b0948c4 | 353 | AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name |
8143ae1f | 354 | UNION |
3b0948c4 AD |
355 | select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid' |
356 | ORDER BY tag_name"); | |
8143ae1f AD |
357 | |
358 | $tags = array(); | |
359 | ||
360 | while ($line = db_fetch_assoc($result)) { | |
361 | $tags[$line["tag_name"]] += $line["count"]; | |
1a66d16e | 362 | } |
8143ae1f AD |
363 | |
364 | foreach (array_keys($tags) as $tag) { | |
365 | ||
366 | $unread = $tags[$tag]; | |
367 | ||
83957936 | 368 | $class = "tag"; |
8143ae1f AD |
369 | |
370 | if ($unread > 0) { | |
371 | $class .= "Unread"; | |
372 | } | |
373 | ||
4668523d | 374 | printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link); |
8143ae1f AD |
375 | |
376 | } | |
1a66d16e | 377 | |
e828e31e | 378 | } |
82baad4a | 379 | |
dc33ec95 | 380 | if (db_num_rows($result) == 0) { |
8037c618 AD |
381 | if ($tags) { |
382 | $what = "tags"; | |
383 | } else { | |
384 | $what = "feeds"; | |
385 | } | |
386 | print "<li>No $what to display.</li>"; | |
dc33ec95 AD |
387 | } |
388 | ||
8143ae1f | 389 | print "</ul>"; |
1cd17194 | 390 | |
caa4e57f AD |
391 | print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>"; |
392 | ||
c3b81db0 AD |
393 | } |
394 | ||
395 | ||
396 | if ($op == "rpc") { | |
397 | ||
398 | $subop = $_GET["subop"]; | |
399 | ||
090e250b | 400 | if ($subop == "getLabelCounters") { |
8073cce7 | 401 | $aid = $_GET["aid"]; |
090e250b AD |
402 | print "<rpc-reply>"; |
403 | getLabelCounters($link); | |
8073cce7 AD |
404 | if ($aid) { |
405 | getFeedCounter($link, $aid); | |
406 | } | |
090e250b AD |
407 | print "</rpc-reply>"; |
408 | } | |
409 | ||
410 | if ($subop == "getFeedCounters") { | |
411 | print "<rpc-reply>"; | |
412 | getFeedCounters($link); | |
413 | print "</rpc-reply>"; | |
414 | } | |
415 | ||
416 | if ($subop == "getAllCounters") { | |
417 | print "<rpc-reply>"; | |
1572afe5 | 418 | getAllCounters($link); |
090e250b | 419 | print "</rpc-reply>"; |
090e250b AD |
420 | } |
421 | ||
f4c10d44 AD |
422 | if ($subop == "mark") { |
423 | $mark = $_GET["mark"]; | |
648472a7 | 424 | $id = db_escape_string($_GET["id"]); |
f4c10d44 AD |
425 | |
426 | if ($mark == "1") { | |
427 | $mark = "true"; | |
428 | } else { | |
429 | $mark = "false"; | |
430 | } | |
431 | ||
b5137506 AD |
432 | // FIXME this needs collision testing |
433 | ||
434 | $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark | |
435 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
f4c10d44 AD |
436 | } |
437 | ||
caa4e57f | 438 | if ($subop == "updateFeed") { |
648472a7 | 439 | $feed_id = db_escape_string($_GET["feed"]); |
9cfc649a | 440 | |
648472a7 | 441 | $result = db_query($link, |
a5873b2e AD |
442 | "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id' |
443 | AND owner_uid = " . $_SESSION["uid"]); | |
9cfc649a | 444 | |
648472a7 AD |
445 | if (db_num_rows($result) > 0) { |
446 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
a5873b2e | 447 | update_rss_feed($link, $feed_url, $feed_id); |
caa4e57f | 448 | } |
9cfc649a | 449 | |
a5873b2e AD |
450 | print "<rpc-reply>"; |
451 | getFeedCounter($link, $feed_id); | |
452 | print "</rpc-reply>"; | |
453 | ||
caa4e57f | 454 | return; |
9cfc649a AD |
455 | } |
456 | ||
090e250b | 457 | if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") { |
c5142cca | 458 | |
05732aa0 | 459 | update_all_feeds($link, $subop == "forceUpdateAllFeeds"); |
c3b81db0 | 460 | |
ab3f3f72 AD |
461 | $omode = $_GET["omode"]; |
462 | ||
463 | if (!$omode) $omode = "tfl"; | |
464 | ||
090e250b | 465 | print "<rpc-reply>"; |
ab3f3f72 AD |
466 | if (strchr($omode, "l")) getLabelCounters($link); |
467 | if (strchr($omode, "f")) getFeedCounters($link); | |
468 | if (strchr($omode, "t")) getTagCounters($link); | |
fc69e641 | 469 | getGlobalCounters($link); |
090e250b | 470 | print "</rpc-reply>"; |
c3b81db0 | 471 | } |
1572afe5 AD |
472 | |
473 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ | |
b018b49b | 474 | if ($subop == "catchupSelected") { |
c3b81db0 AD |
475 | |
476 | $ids = split(",", $_GET["ids"]); | |
477 | ||
1572afe5 | 478 | $cmode = sprintf("%d", $_GET["cmode"]); |
c3b81db0 | 479 | |
1572afe5 | 480 | foreach ($ids as $id) { |
c3b81db0 | 481 | |
1572afe5 AD |
482 | if ($cmode == 0) { |
483 | db_query($link, "UPDATE ttrss_user_entries SET | |
484 | unread = false,last_read = NOW() | |
485 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
486 | } else if ($cmode == 1) { | |
487 | db_query($link, "UPDATE ttrss_user_entries SET | |
488 | unread = true | |
489 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
490 | } else { | |
491 | db_query($link, "UPDATE ttrss_user_entries SET | |
492 | unread = NOT unread,last_read = NOW() | |
493 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
494 | } | |
c3b81db0 | 495 | } |
1572afe5 AD |
496 | print "<rpc-reply>"; |
497 | getAllCounters($link); | |
498 | print "</rpc-reply>"; | |
499 | } | |
c3b81db0 | 500 | |
1572afe5 AD |
501 | if ($subop == "markSelected") { |
502 | ||
503 | $ids = split(",", $_GET["ids"]); | |
504 | ||
505 | $cmode = sprintf("%d", $_GET["cmode"]); | |
506 | ||
507 | foreach ($ids as $id) { | |
508 | ||
509 | if ($cmode == 0) { | |
510 | db_query($link, "UPDATE ttrss_user_entries SET | |
511 | marked = false | |
512 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
513 | } else if ($cmode == 1) { | |
514 | db_query($link, "UPDATE ttrss_user_entries SET | |
515 | marked = true | |
516 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
517 | } else { | |
518 | db_query($link, "UPDATE ttrss_user_entries SET | |
519 | marked = NOT marked | |
520 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
521 | } | |
522 | } | |
523 | print "<rpc-reply>"; | |
524 | getAllCounters($link); | |
525 | print "</rpc-reply>"; | |
c3b81db0 | 526 | } |
295f9b42 AD |
527 | |
528 | if ($subop == "sanityCheck") { | |
529 | ||
530 | $error_code = 0; | |
531 | ||
532 | $result = db_query($link, "SELECT schema_version FROM ttrss_version"); | |
533 | ||
534 | $schema_version = db_fetch_result($result, 0, "schema_version"); | |
535 | ||
536 | if ($schema_version != SCHEMA_VERSION) { | |
537 | $error_code = 5; | |
538 | } | |
539 | ||
262bd8ea | 540 | print "<error error-code='$error_code'/>"; |
295f9b42 | 541 | } |
fefa6ca3 AD |
542 | |
543 | if ($subop == "globalPurge") { | |
544 | ||
545 | print "<rpc-reply>"; | |
546 | global_purge_old_posts($link, true); | |
547 | print "</rpc-reply>"; | |
548 | ||
549 | } | |
550 | ||
c3b81db0 AD |
551 | } |
552 | ||
553 | if ($op == "feeds") { | |
554 | ||
8143ae1f AD |
555 | $tags = $_GET["tags"]; |
556 | ||
c3b81db0 AD |
557 | $subop = $_GET["subop"]; |
558 | ||
559 | if ($subop == "catchupAll") { | |
b018b49b | 560 | db_query($link, "UPDATE ttrss_user_entries SET |
6d15e1ef | 561 | last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]); |
c3b81db0 AD |
562 | } |
563 | ||
8143ae1f | 564 | outputFeedList($link, $tags); |
c3b81db0 | 565 | |
1cd17194 AD |
566 | } |
567 | ||
568 | if ($op == "view") { | |
569 | ||
d76a3b03 | 570 | $id = $_GET["id"]; |
8073cce7 | 571 | $feed_id = $_GET["feed"]; |
d76a3b03 | 572 | |
4c193675 AD |
573 | $result = db_query($link, "UPDATE ttrss_user_entries |
574 | SET unread = false,last_read = NOW() | |
575 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
a1a8a2be | 576 | |
70830c87 AD |
577 | $addheader = $_GET["addheader"]; |
578 | ||
21703604 | 579 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, |
9167e250 | 580 | SUBSTRING(updated,1,16) as updated, |
21703604 | 581 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url |
4c193675 AD |
582 | FROM ttrss_entries,ttrss_user_entries |
583 | WHERE id = '$id' AND ref_id = id"); | |
1cd17194 | 584 | |
70830c87 | 585 | if ($addheader) { |
f0601b87 | 586 | print "<html><head> |
70830c87 | 587 | <title>Tiny Tiny RSS : Article $id</title> |
503eb349 AD |
588 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
589 | ||
590 | $user_theme = $_SESSION["theme"]; | |
591 | if ($user_theme) { | |
592 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
593 | href=\"themes/$user_theme/theme.css\">"; | |
594 | } | |
595 | ||
596 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { | |
597 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
598 | href=\"tt-rss_compact.css\"/>"; | |
599 | } else { | |
600 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
601 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
602 | } | |
603 | ||
604 | print "<script type=\"text/javascript\" src=\"functions.js\"></script> | |
70830c87 | 605 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
f0601b87 | 606 | </head><body>"; |
70830c87 AD |
607 | } |
608 | ||
d76a3b03 | 609 | if ($result) { |
1cd17194 | 610 | |
648472a7 | 611 | $line = db_fetch_assoc($result); |
1cd17194 | 612 | |
b7f4bda2 AD |
613 | if ($line["icon_url"]) { |
614 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
615 | } else { | |
616 | $feed_icon = " "; | |
617 | } | |
d76a3b03 | 618 | |
f7181e9b AD |
619 | if ($line["comments"] && $line["link"] != $line["comments"]) { |
620 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; | |
621 | } else { | |
622 | $entry_comments = ""; | |
623 | } | |
624 | ||
e828e31e AD |
625 | print "<div class=\"postReply\">"; |
626 | ||
21703604 AD |
627 | print "<div class=\"postHeader\"><table width=\"100%\">"; |
628 | ||
9167e250 AD |
629 | print "<tr><td>" . $line["title"] . "</td>"; |
630 | ||
631 | $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
632 | strtotime($line["updated"])); | |
633 | ||
634 | print "<td class=\"postDate\">$parsed_updated</td>"; | |
635 | ||
636 | print "</tr>"; | |
21703604 AD |
637 | |
638 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM | |
639 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
640 | ORDER BY tag_name"); | |
641 | ||
642 | $tags_str = ""; | |
643 | ||
644 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
645 | $tag = $tmp_line["tag_name"]; | |
b400ca77 | 646 | $tags_str .= "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, "; |
21703604 AD |
647 | } |
648 | ||
b400ca77 | 649 | $tags_str = preg_replace("/, $/", "", $tags_str); |
e828e31e | 650 | |
b400ca77 | 651 | print "<tr><td width='50%'> |
f7181e9b | 652 | <a href=\"" . $line["link"] . "\">".$line["link"]."</a> |
21703604 AD |
653 | $entry_comments</td> |
654 | <td align=\"right\">$tags_str</td></tr>"; | |
655 | ||
656 | /* if ($tags_str) { | |
657 | print "<tr><td><b>Tags:</b></td> | |
658 | <td width='100%'>$tags_str</td></tr>"; | |
659 | } */ | |
660 | ||
e828e31e AD |
661 | print "</table></div>"; |
662 | ||
663 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
664 | print "<div class=\"postContent\">" . $line["content"] . "</div>"; | |
665 | ||
666 | print "</div>"; | |
667 | ||
090e250b | 668 | print "<script type=\"text/javascript\"> |
4f3a84f4 | 669 | update_all_counters('$feed_id'); |
090e250b | 670 | </script>"; |
d76a3b03 | 671 | } |
70830c87 AD |
672 | |
673 | if ($addheader) { | |
674 | print "</body></html>"; | |
675 | } | |
1cd17194 AD |
676 | } |
677 | ||
678 | if ($op == "viewfeed") { | |
679 | ||
680 | $feed = $_GET["feed"]; | |
d76a3b03 | 681 | $skip = $_GET["skip"]; |
476cac42 | 682 | $subop = $_GET["subop"]; |
f175937c | 683 | $view_mode = $_GET["view"]; |
f0601b87 | 684 | $addheader = $_GET["addheader"]; |
cb1083a1 | 685 | $limit = $_GET["limit"]; |
a1a8a2be | 686 | |
8d7008c7 | 687 | if (!$feed) { |
8d7008c7 AD |
688 | return; |
689 | } | |
690 | ||
ac53063a AD |
691 | if (!$skip) $skip = 0; |
692 | ||
476cac42 | 693 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 694 | |
f0601b87 AD |
695 | if ($addheader) { |
696 | print "<html><head> | |
ac43eba1 | 697 | <title>Tiny Tiny RSS : Feed $feed</title> |
430bf183 AD |
698 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; |
699 | ||
503eb349 AD |
700 | $user_theme = $_SESSION["theme"]; |
701 | if ($user_theme) { | |
702 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
703 | href=\"themes/$user_theme/theme.css\">"; | |
704 | } | |
705 | ||
4769ddaf | 706 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { |
430bf183 AD |
707 | print "<link rel=\"stylesheet\" |
708 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
709 | ||
710 | } else { | |
711 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
712 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
713 | } | |
503eb349 | 714 | |
430bf183 | 715 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
f0601b87 AD |
716 | <script type=\"text/javascript\" src=\"functions.js\"></script> |
717 | <script type=\"text/javascript\" src=\"viewfeed.js\"></script> | |
b623b3ed | 718 | </head><body onload='init()'>"; |
f0601b87 AD |
719 | } |
720 | ||
dcee8f61 AD |
721 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { |
722 | ||
723 | $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds | |
724 | WHERE id = '$feed'"); | |
725 | ||
726 | $feed_url = db_fetch_result($tmp_result, 0, "feed_url"); | |
727 | ||
728 | update_rss_feed($link, $feed_url, $feed); | |
729 | ||
730 | } | |
731 | ||
0e32076b | 732 | if ($subop == "MarkAllRead") { |
d76a3b03 | 733 | |
0e32076b AD |
734 | if (sprintf("%d", $feed) != 0) { |
735 | ||
736 | if ($feed > 0) { | |
f23a2177 | 737 | db_query($link, "UPDATE ttrss_user_entries |
0e32076b | 738 | SET unread = false,last_read = NOW() |
f23a2177 | 739 | WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]); |
0e32076b AD |
740 | |
741 | } else if ($feed < 0 && $feed > -10) { // special, like starred | |
742 | ||
743 | if ($feed == -1) { | |
f23a2177 | 744 | db_query($link, "UPDATE ttrss_user_entries |
0e32076b | 745 | SET unread = false,last_read = NOW() |
5859be02 | 746 | WHERE marked = true AND owner_uid = ".$_SESSION["uid"]); |
0e32076b AD |
747 | } |
748 | ||
749 | } else if ($feed < -10) { // label | |
750 | ||
f23a2177 AD |
751 | // TODO make this more efficient |
752 | ||
7db95187 | 753 | $label_id = -$feed - 11; |
0e32076b | 754 | |
7db95187 | 755 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels |
f23a2177 | 756 | WHERE id = '$label_id'"); |
7db95187 AD |
757 | |
758 | if ($tmp_result) { | |
759 | $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp"); | |
760 | ||
f23a2177 AD |
761 | db_query($link, "BEGIN"); |
762 | ||
763 | $tmp2_result = db_query($link, | |
764 | "SELECT | |
765 | int_id | |
766 | FROM | |
767 | ttrss_user_entries,ttrss_entries | |
768 | WHERE | |
769 | ref_id = id AND | |
770 | $sql_exp AND | |
771 | owner_uid = " . $_SESSION["uid"]); | |
772 | ||
773 | while ($tmp_line = db_fetch_assoc($tmp2_result)) { | |
774 | db_query($link, "UPDATE | |
775 | ttrss_user_entries | |
776 | SET | |
777 | unread = false, last_read = NOW() | |
778 | WHERE | |
779 | int_id = " . $tmp_line["int_id"]); | |
780 | } | |
781 | ||
782 | db_query($link, "COMMIT"); | |
783 | ||
784 | /* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries | |
7db95187 | 785 | SET unread = false,last_read = NOW() |
f23a2177 AD |
786 | WHERE $sql_exp |
787 | AND ref_id = id | |
788 | AND owner_uid = ".$_SESSION["uid"]); */ | |
7db95187 | 789 | } |
254e0e4b | 790 | } |
0e32076b | 791 | } else { // tag |
7eec90cf AD |
792 | db_query($link, "BEGIN"); |
793 | ||
794 | $tag_name = db_escape_string($feed); | |
795 | ||
796 | $result = db_query($link, "SELECT post_int_id FROM ttrss_tags | |
797 | WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]); | |
798 | ||
799 | while ($line = db_fetch_assoc($result)) { | |
800 | db_query($link, "UPDATE ttrss_user_entries SET | |
801 | unread = false, last_read = NOW() | |
802 | WHERE int_id = " . $line["post_int_id"]); | |
803 | } | |
804 | db_query($link, "COMMIT"); | |
a1a8a2be | 805 | } |
0e32076b | 806 | |
a1a8a2be | 807 | } |
d76a3b03 | 808 | |
c374a3fe AD |
809 | $search = $_GET["search"]; |
810 | ||
52b51244 AD |
811 | $search_mode = $_GET["smode"]; |
812 | ||
f175937c | 813 | if ($search) { |
ac53063a AD |
814 | $search_query_part = "(upper(title) LIKE upper('%$search%') |
815 | OR content LIKE '%$search%') AND"; | |
f175937c AD |
816 | } else { |
817 | $search_query_part = ""; | |
818 | } | |
819 | ||
820 | $view_query_part = ""; | |
821 | ||
822 | if ($view_mode == "Starred") { | |
823 | $view_query_part = " marked = true AND "; | |
ac53063a AD |
824 | } |
825 | ||
ac43eba1 AD |
826 | if ($view_mode == "Unread") { |
827 | $view_query_part = " unread = true AND "; | |
828 | } | |
829 | ||
b5aa95e7 AD |
830 | if ($view_mode == "Unread or Starred") { |
831 | $view_query_part = " (unread = true OR marked = true) AND "; | |
832 | } | |
833 | ||
bdd01d3f AD |
834 | if ($view_mode == "Unread or Updated") { |
835 | $view_query_part = " (unread = true OR last_read is NULL) AND "; | |
836 | } | |
837 | ||
254e0e4b | 838 | /* $result = db_query($link, "SELECT count(id) AS total_entries |
36bf7496 AD |
839 | FROM ttrss_entries WHERE |
840 | $search_query_part | |
841 | feed_id = '$feed'"); | |
e6d1c0a0 | 842 | |
254e0e4b | 843 | $total_entries = db_fetch_result($result, 0, "total_entries"); */ |
e6d1c0a0 | 844 | |
648472a7 | 845 | /* $result = db_query("SELECT count(id) AS unread_entries |
ac43eba1 AD |
846 | FROM ttrss_entries WHERE |
847 | $search_query_part | |
848 | unread = true AND | |
849 | feed_id = '$feed'"); | |
850 | ||
648472a7 | 851 | $unread_entries = db_fetch_result($result, 0, "unread_entries"); */ |
ac43eba1 | 852 | |
8d7008c7 | 853 | if ($limit && $limit != "All") { |
82c9223c | 854 | $limit_query_part = "LIMIT " . $limit; |
ad3cb710 | 855 | } |
f0601b87 | 856 | |
254e0e4b AD |
857 | $vfeed_query_part = ""; |
858 | ||
52b51244 | 859 | // override query strategy and enable feed display when searching globally |
d3416913 | 860 | if ($search && $search_mode == "All feeds") { |
52b51244 AD |
861 | $query_strategy_part = "id > 0"; |
862 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
863 | id = feed_id) as feed_title,"; | |
864 | } else if (sprintf("%d", $feed) == 0) { | |
8143ae1f AD |
865 | $query_strategy_part = "ttrss_entries.id > 0"; |
866 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
867 | id = feed_id) as feed_title,"; | |
868 | } else if ($feed >= 0) { | |
254e0e4b | 869 | $query_strategy_part = "feed_id = '$feed'"; |
48f0adb0 | 870 | } else if ($feed == -1) { // starred virtual feed |
254e0e4b | 871 | $query_strategy_part = "marked = true"; |
48f0adb0 AD |
872 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
873 | id = feed_id) as feed_title,"; | |
874 | } else if ($feed <= -10) { // labels | |
875 | $label_id = -$feed - 11; | |
876 | ||
877 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
878 | WHERE id = '$label_id'"); | |
879 | ||
880 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
881 | ||
254e0e4b AD |
882 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
883 | id = feed_id) as feed_title,"; | |
884 | } else { | |
48f0adb0 | 885 | $query_strategy_part = "id > 0"; // dumb |
254e0e4b AD |
886 | } |
887 | ||
f99321a3 AD |
888 | $order_by = "updated DESC"; |
889 | ||
890 | // if ($feed < -10) { | |
891 | // $order_by = "feed_id,updated DESC"; | |
892 | // } | |
893 | ||
1572afe5 AD |
894 | $feed_title = ""; |
895 | ||
896 | if ($search && $search_mode == "All feeds") { | |
897 | $feed_title = "Search results"; | |
898 | } else if (sprintf("%d", $feed) == 0) { | |
899 | $feed_title = $feed; | |
900 | } else if ($feed > 0) { | |
901 | $result = db_query($link, "SELECT title,site_url FROM ttrss_feeds | |
902 | WHERE id = '$feed'"); | |
903 | ||
904 | $feed_title = db_fetch_result($result, 0, "title"); | |
905 | $feed_site_url = db_fetch_result($result, 0, "site_url"); | |
906 | ||
907 | } else if ($feed == -1) { | |
908 | $feed_title = "Starred articles"; | |
909 | } else if ($feed < -10) { | |
910 | $label_id = -$feed - 11; | |
911 | $result = db_query($link, "SELECT description FROM ttrss_labels | |
912 | WHERE id = '$label_id'"); | |
913 | $feed_title = db_fetch_result($result, 0, "description"); | |
914 | } else { | |
915 | $feed_title = "?"; | |
916 | } | |
917 | ||
918 | print "<table class=\"headlinesSubToolbar\" | |
919 | width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>"; | |
920 | ||
921 | print "<td class=\"headlineActions\"> | |
922 | Select: | |
923 | <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', | |
924 | 'RROW-', 'RCHK-', true)\">All</a>, | |
925 | <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', | |
926 | 'RROW-', 'RCHK-', true, 'Unread')\">Unread</a>, | |
927 | <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', | |
928 | 'RROW-', 'RCHK-', false)\">None</a> | |
929 | | |
930 | Toggle: <a href=\"javascript:toggleUnread()\">Unread</a>, | |
931 | <a href=\"javascript:toggleStarred()\">Starred</a>"; | |
932 | ||
933 | /* print " | |
934 | View: | |
935 | <a href=\"javascript:limitView('All')\">All</a>, | |
936 | <a href=\"javascript:limitView('Unread')\">Unread</a>, | |
937 | <a href=\"javascript:limitView('Starred')\">Starred</a> | |
938 | | |
939 | Feed: | |
940 | <a href=\"javascript:updateCurrentFeed()\">Update</a>, | |
941 | <a href=\"javascript:catchupCurrentFeed()\">Mark as read</a>"; */ | |
942 | ||
943 | print "</td>"; | |
944 | ||
945 | print "<td class=\"headlineTitle\">"; | |
946 | ||
947 | if ($feed_site_url) { | |
7c888fd9 | 948 | print "<a target=\"_blank\" href=\"$feed_site_url\">$feed_title</a>"; |
1572afe5 AD |
949 | } else { |
950 | print $feed_title; | |
951 | } | |
952 | ||
953 | print "</td>"; | |
954 | print "</tr></table>"; | |
955 | ||
7d0e004f AD |
956 | print "<table class=\"headlinesList\" id=\"headlinesList\" |
957 | cellspacing=\"0\" width=\"100%\">"; | |
1572afe5 AD |
958 | |
959 | ||
48f0adb0 AD |
960 | if ($feed < -10) error_reporting (0); |
961 | ||
8143ae1f AD |
962 | if (sprintf("%d", $feed) != 0) { |
963 | ||
21703604 AD |
964 | if ($feed > 0) { |
965 | $feed_kind = "Feeds"; | |
966 | } else { | |
967 | $feed_kind = "Labels"; | |
968 | } | |
969 | ||
bd34c528 AD |
970 | if (!$vfeed_query_part) { |
971 | $content_query_part = "content as content_preview,"; | |
972 | } else { | |
973 | $content_query_part = ""; | |
974 | } | |
975 | ||
8143ae1f | 976 | $result = db_query($link, "SELECT |
1572afe5 AD |
977 | id,title, |
978 | SUBSTRING(updated,1,16) as updated, | |
979 | unread,feed_id,marked,link,last_read, | |
8143ae1f AD |
980 | SUBSTRING(last_read,1,19) as last_read_noms, |
981 | $vfeed_query_part | |
bd34c528 AD |
982 | $content_query_part |
983 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 984 | FROM |
4c193675 | 985 | ttrss_entries,ttrss_user_entries |
8143ae1f | 986 | WHERE |
4c193675 | 987 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
aee86c2e | 988 | owner_uid = '".$_SESSION["uid"]."' AND |
8143ae1f AD |
989 | $search_query_part |
990 | $view_query_part | |
991 | $query_strategy_part ORDER BY $order_by | |
992 | $limit_query_part"); | |
993 | ||
994 | } else { | |
995 | // browsing by tag | |
996 | ||
21703604 AD |
997 | $feed_kind = "Tags"; |
998 | ||
8143ae1f | 999 | $result = db_query($link, "SELECT |
1572afe5 AD |
1000 | ttrss_entries.id as id,title, |
1001 | SUBSTRING(updated,1,16) as updated, | |
1002 | unread,feed_id, | |
8143ae1f | 1003 | marked,link,last_read, |
c05a19f3 | 1004 | SUBSTRING(last_read,1,19) as last_read_noms, |
254e0e4b | 1005 | $vfeed_query_part |
bd34c528 AD |
1006 | $content_query_part |
1007 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 1008 | FROM |
05732aa0 | 1009 | ttrss_entries,ttrss_user_entries,ttrss_tags |
8143ae1f | 1010 | WHERE |
05732aa0 AD |
1011 | ref_id = ttrss_entries.id AND |
1012 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
1013 | post_int_id = int_id AND tag_name = '$feed' AND | |
8143ae1f AD |
1014 | $view_query_part |
1015 | $search_query_part | |
1016 | $query_strategy_part ORDER BY $order_by | |
1017 | $limit_query_part"); | |
1018 | } | |
d76a3b03 | 1019 | |
48f0adb0 AD |
1020 | if (!$result) { |
1021 | print "<tr><td colspan='4' align='center'> | |
1022 | Could not display feed (query failed). Please check match syntax or local configuration.</td></tr>"; | |
1023 | return; | |
1024 | } | |
1025 | ||
a1a8a2be | 1026 | $lnum = 0; |
48f0adb0 | 1027 | |
cce28758 | 1028 | error_reporting (DEFAULT_ERROR_LEVEL); |
48f0adb0 | 1029 | |
e1123aee | 1030 | $num_unread = 0; |
d76a3b03 | 1031 | |
648472a7 | 1032 | while ($line = db_fetch_assoc($result)) { |
d76a3b03 | 1033 | |
a1a8a2be | 1034 | $class = ($lnum % 2) ? "even" : "odd"; |
d76a3b03 | 1035 | |
ad99045e AD |
1036 | $id = $line["id"]; |
1037 | $feed_id = $line["feed_id"]; | |
1038 | ||
4cc6ea5e AD |
1039 | if ($line["last_read"] == "" && |
1040 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
1041 | ||
ecb14114 AD |
1042 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" |
1043 | alt=\"Updated\">"; | |
1044 | } else { | |
1045 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
1046 | alt=\"Updated\">"; | |
c43f77f5 | 1047 | } |
b197f117 | 1048 | |
8158c57a | 1049 | if ($line["unread"] == "t" || $line["unread"] == "1") { |
a1a8a2be | 1050 | $class .= "Unread"; |
e1123aee AD |
1051 | ++$num_unread; |
1052 | } | |
d76a3b03 | 1053 | |
8158c57a | 1054 | if ($line["marked"] == "t" || $line["marked"] == "1") { |
f4c10d44 AD |
1055 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" |
1056 | alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>"; | |
1057 | } else { | |
1058 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
1059 | alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>"; | |
1060 | } | |
1061 | ||
ac43eba1 | 1062 | $content_link = "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" . |
b197f117 AD |
1063 | $line["title"] . "</a>"; |
1064 | ||
d5224f0d | 1065 | print "<tr class='$class' id='RROW-$id'>"; |
5f89f780 | 1066 | // onclick=\"javascript:view($id,$feed_id)\"> |
b197f117 | 1067 | |
179d6f57 | 1068 | print "<td valign='center' class='hlUpdatePic'>$update_pic</td>"; |
1572afe5 | 1069 | |
179d6f57 | 1070 | print "<td valign='center' class='hlSelectRow'> |
1572afe5 AD |
1071 | <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\" |
1072 | class=\"feedCheckBox\" id=\"RCHK-$id\"> | |
1073 | </td>"; | |
1074 | ||
179d6f57 | 1075 | print "<td valign='center' class='hlMarkedPic'>$marked_pic</td>"; |
254e0e4b AD |
1076 | |
1077 | if ($line["feed_title"]) { | |
179d6f57 AD |
1078 | print "<td class='hlContent'>$content_link</td>"; |
1079 | print "<td class='hlFeed'> | |
2db4190c | 1080 | <a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>"; |
591c396d | 1081 | } else { |
0f172fff AD |
1082 | print "<td class='hlContent'>"; |
1083 | ||
1084 | print "<a id=\"FTITLE-$id\" href=\"javascript:view($id,$feed_id);\">" . | |
1085 | $line["title"]; | |
1086 | ||
591c396d | 1087 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { |
0f172fff | 1088 | |
591c396d | 1089 | $content_preview = truncate_string(strip_tags($line["content_preview"]), |
2e85e07b | 1090 | 101); |
0f172fff | 1091 | |
ad3dee91 AD |
1092 | if ($content_preview) { |
1093 | print "<span class=\"contentPreview\"> - $content_preview</span>"; | |
1094 | } | |
591c396d | 1095 | } |
0f172fff AD |
1096 | |
1097 | print "</a>"; | |
591c396d | 1098 | print "</td>"; |
254e0e4b | 1099 | } |
d76a3b03 | 1100 | |
be773442 AD |
1101 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
1102 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
1103 | } else { | |
1104 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1105 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
1106 | } | |
1107 | ||
12d7c4cd | 1108 | print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>"; |
179d6f57 | 1109 | |
a1a8a2be | 1110 | print "</tr>"; |
d76a3b03 | 1111 | |
a1a8a2be AD |
1112 | ++$lnum; |
1113 | } | |
d76a3b03 | 1114 | |
ac53063a | 1115 | if ($lnum == 0) { |
a82065a1 | 1116 | print "<tr><td align='center'>No articles found.</td></tr>"; |
047bae73 | 1117 | } |
a2015351 | 1118 | |
a1a8a2be | 1119 | print "</table>"; |
6113ef7d AD |
1120 | |
1121 | print "<script type=\"text/javascript\"> | |
bb7cface | 1122 | document.onkeydown = hotkey_handler; |
4f3a84f4 | 1123 | update_all_counters('$feed'); |
6113ef7d | 1124 | </script>"; |
d76a3b03 | 1125 | |
f0601b87 AD |
1126 | if ($addheader) { |
1127 | print "</body></html>"; | |
1128 | } | |
1129 | ||
1cd17194 AD |
1130 | } |
1131 | ||
0e091d38 | 1132 | if ($op == "pref-rpc") { |
331900c6 | 1133 | |
0e091d38 | 1134 | $subop = $_GET["subop"]; |
331900c6 | 1135 | |
83fe4d6d AD |
1136 | if ($subop == "unread") { |
1137 | $ids = split(",", $_GET["ids"]); | |
1138 | foreach ($ids as $id) { | |
a5873b2e AD |
1139 | db_query($link, "UPDATE ttrss_user_entries SET unread = true |
1140 | WHERE feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
83fe4d6d | 1141 | } |
0e091d38 | 1142 | |
a5873b2e | 1143 | print "Marked selected feeds as unread."; |
83fe4d6d AD |
1144 | } |
1145 | ||
1146 | if ($subop == "read") { | |
1147 | $ids = split(",", $_GET["ids"]); | |
1148 | foreach ($ids as $id) { | |
a5873b2e AD |
1149 | db_query($link, "UPDATE ttrss_user_entries |
1150 | SET unread = false,last_read = NOW() WHERE | |
1151 | feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
83fe4d6d | 1152 | } |
0e091d38 | 1153 | |
a5873b2e | 1154 | print "Marked selected feeds as read."; |
0e091d38 AD |
1155 | |
1156 | } | |
1157 | ||
1158 | } | |
1159 | ||
1160 | if ($op == "pref-feeds") { | |
1161 | ||
1162 | $subop = $_GET["subop"]; | |
1163 | ||
508a81e1 | 1164 | if ($subop == "editSave") { |
648472a7 AD |
1165 | $feed_title = db_escape_string($_GET["t"]); |
1166 | $feed_link = db_escape_string($_GET["l"]); | |
d148926e | 1167 | $upd_intl = db_escape_string($_GET["ui"]); |
5d73494a | 1168 | $purge_intl = db_escape_string($_GET["pi"]); |
91ff844a AD |
1169 | $feed_id = db_escape_string($_GET["id"]); |
1170 | $cat_id = db_escape_string($_GET["catid"]); | |
508a81e1 | 1171 | |
d148926e AD |
1172 | if (strtoupper($upd_intl) == "DEFAULT") |
1173 | $upd_intl = 0; | |
1174 | ||
5d73494a AD |
1175 | if (strtoupper($purge_intl) == "DEFAULT") |
1176 | $purge_intl = 0; | |
1177 | ||
140aae81 AD |
1178 | if (strtoupper($purge_intl) == "DISABLED") |
1179 | $purge_intl = -1; | |
1180 | ||
91ff844a AD |
1181 | if ($cat_id != 0) { |
1182 | $category_qpart = "cat_id = '$cat_id'"; | |
1183 | } else { | |
1184 | $category_qpart = 'cat_id = NULL'; | |
1185 | } | |
1186 | ||
648472a7 | 1187 | $result = db_query($link, "UPDATE ttrss_feeds SET |
91ff844a | 1188 | $category_qpart, |
d148926e | 1189 | title = '$feed_title', feed_url = '$feed_link', |
5d73494a | 1190 | update_interval = '$upd_intl', |
91ff844a | 1191 | purge_interval = '$purge_intl' |
f72dbbde | 1192 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
508a81e1 | 1193 | |
83fe4d6d AD |
1194 | } |
1195 | ||
331900c6 | 1196 | if ($subop == "remove") { |
331900c6 | 1197 | |
b0b4abcf | 1198 | if (!WEB_DEMO_MODE) { |
331900c6 | 1199 | |
b0b4abcf AD |
1200 | $ids = split(",", $_GET["ids"]); |
1201 | ||
1202 | foreach ($ids as $id) { | |
f72dbbde AD |
1203 | db_query($link, "DELETE FROM ttrss_feeds |
1204 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
4769ddaf | 1205 | |
273a2f6b | 1206 | $icons_dir = ICONS_DIR; |
d5caaae5 | 1207 | |
4769ddaf AD |
1208 | if (file_exists($icons_dir . "/$id.ico")) { |
1209 | unlink($icons_dir . "/$id.ico"); | |
d5caaae5 | 1210 | } |
b0b4abcf | 1211 | } |
331900c6 AD |
1212 | } |
1213 | } | |
1214 | ||
1215 | if ($subop == "add") { | |
b0b4abcf AD |
1216 | |
1217 | if (!WEB_DEMO_MODE) { | |
331900c6 | 1218 | |
b6b535ca | 1219 | $feed_link = db_escape_string(trim($_GET["link"])); |
331900c6 | 1220 | |
648472a7 | 1221 | $result = db_query($link, |
7e9a3986 AD |
1222 | "SELECT id FROM ttrss_feeds |
1223 | WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]); | |
1224 | ||
1225 | if (db_num_rows($result) == 0) { | |
1226 | ||
1227 | $result = db_query($link, | |
1228 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title) | |
1229 | VALUES ('".$_SESSION["uid"]."', '$feed_link', '')"); | |
331900c6 | 1230 | |
7e9a3986 AD |
1231 | $result = db_query($link, |
1232 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link' | |
1233 | AND owner_uid = " . $_SESSION["uid"]); | |
1234 | ||
1235 | $feed_id = db_fetch_result($result, 0, "id"); | |
1236 | ||
1237 | if ($feed_id) { | |
ddb68b81 | 1238 | update_rss_feed($link, $feed_link, $feed_id, true); |
7e9a3986 AD |
1239 | } |
1240 | } else { | |
331900c6 | 1241 | |
7e9a3986 AD |
1242 | print "<div class=\"warning\"> |
1243 | Feed <b>$feed_link</b> already exists in the database. | |
1244 | </div>"; | |
b0b4abcf AD |
1245 | } |
1246 | } | |
331900c6 | 1247 | } |
a0d53889 | 1248 | |
91ff844a AD |
1249 | if ($subop == "addCat") { |
1250 | ||
1251 | if (!WEB_DEMO_MODE) { | |
1252 | ||
1253 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
1254 | ||
1255 | $result = db_query($link, | |
1256 | "SELECT id FROM ttrss_feed_categories | |
1257 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
1258 | ||
1259 | if (db_num_rows($result) == 0) { | |
1260 | ||
1261 | $result = db_query($link, | |
1262 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
1263 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
1264 | ||
1265 | } else { | |
1266 | ||
1267 | print "<div class=\"warning\"> | |
1268 | Category <b>$feed_cat</b> already exists in the database. | |
1269 | </div>"; | |
1270 | } | |
1271 | ||
1272 | ||
1273 | } | |
1274 | } | |
1275 | ||
1276 | if ($subop == "removeCats") { | |
1277 | ||
1278 | if (!WEB_DEMO_MODE) { | |
1279 | ||
1280 | $ids = split(",", $_GET["ids"]); | |
1281 | ||
1282 | foreach ($ids as $id) { | |
1283 | ||
1284 | db_query($link, "BEGIN"); | |
1285 | ||
1286 | $result = db_query($link, | |
1287 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
1288 | WHERE cat_id = '$id'"); | |
1289 | ||
1290 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
1291 | ||
1292 | if ($num_feeds == 0) { | |
1293 | db_query($link, "DELETE FROM ttrss_feed_categories | |
1294 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1295 | } else { | |
1296 | ||
1297 | print "<div class=\"warning\"> | |
1298 | Unable to delete non empty feed categories.</div>"; | |
1299 | ||
1300 | } | |
1301 | ||
1302 | db_query($link, "COMMIT"); | |
1303 | } | |
1304 | } | |
1305 | } | |
1306 | ||
c64d5b03 | 1307 | // print "<h3>Edit Feeds</h3>"; |
91ff844a | 1308 | |
4904f845 AD |
1309 | $result = db_query($link, "SELECT id,title,feed_url,last_error |
1310 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1311 | ||
1312 | if (db_num_rows($result) > 0) { | |
1313 | ||
1314 | print "<div class=\"warning\">"; | |
1315 | ||
1316 | print "<b>Feeds with update errors:</b>"; | |
1317 | ||
1318 | print "<ul class=\"nomarks\">"; | |
1319 | ||
1320 | while ($line = db_fetch_assoc($result)) { | |
1321 | print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " . | |
1322 | $line["last_error"]; | |
1323 | } | |
1324 | ||
1325 | print "</ul>"; | |
1326 | print "</div>"; | |
1327 | ||
1328 | } | |
1329 | ||
c64d5b03 | 1330 | print "<p><div class=\"prefGenericAddBox\"> |
2c7070b5 AD |
1331 | <input id=\"fadd_link\" size=\"40\"> <input |
1332 | type=\"submit\" class=\"button\" | |
1333 | onclick=\"javascript:addFeed()\" value=\"Add feed\"></div>"; | |
a0d53889 | 1334 | |
b83c7545 AD |
1335 | $feeds_sort = db_escape_string($_GET["sort"]); |
1336 | ||
1337 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
1338 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
1339 | if (!$feeds_sort) $feeds_sort = "title"; | |
1340 | } | |
1341 | ||
1342 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
1343 | ||
648472a7 | 1344 | $result = db_query($link, "SELECT |
d148926e | 1345 | id,title,feed_url,substring(last_updated,1,16) as last_updated, |
91ff844a AD |
1346 | update_interval,purge_interval, |
1347 | (SELECT title FROM ttrss_feed_categories | |
1348 | WHERE id = cat_id) AS category | |
c0e5a40e | 1349 | FROM |
b83c7545 AD |
1350 | ttrss_feeds WHERE owner_uid = '".$_SESSION["uid"]."' |
1351 | ORDER by $feeds_sort,title"); | |
1cd17194 | 1352 | |
3b0feb9b | 1353 | if (db_num_rows($result) != 0) { |
91ff844a | 1354 | |
3b0feb9b | 1355 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
35f3c923 | 1356 | |
f4fe2cde AD |
1357 | print "<p><table width=\"100%\" cellspacing=\"0\" |
1358 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
35f3c923 AD |
1359 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
1360 | Select: | |
1361 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', | |
3055bc41 | 1362 | 'FEEDR-', 'FRCHK-', true)\">All</a>, |
35f3c923 | 1363 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', |
3055bc41 | 1364 | 'FEEDR-', 'FRCHK-', false)\">None</a> |
35f3c923 AD |
1365 | </td</tr>"; |
1366 | ||
3b0feb9b | 1367 | print "<tr class=\"title\"> |
3547842a AD |
1368 | <td width=\"3%\"> </td> |
1369 | <td width=\"3%\">Select</td> | |
3b0feb9b AD |
1370 | <td width=\"20%\"> |
1371 | <a href=\"javascript:updateFeedList('title')\">Title</a></td> | |
1372 | <td width=\"20%\"> | |
1373 | <a href=\"javascript:updateFeedList('feed_url')\">Link</a> | |
1374 | </td>"; | |
54d3ba50 | 1375 | |
3b0feb9b AD |
1376 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1377 | print "<td width=\"10%\"> | |
1378 | <a href=\"javascript:updateFeedList('category')\">Category</a></td>"; | |
603c27f8 | 1379 | } |
603c27f8 | 1380 | |
f92db4f5 | 1381 | print " |
3b0feb9b AD |
1382 | <td width=\"10%\"> |
1383 | <a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a> | |
1384 | </td> | |
1385 | <td width=\"10%\"> | |
1386 | <a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a> | |
1387 | </td> | |
3b0feb9b AD |
1388 | </tr>"; |
1389 | ||
c64d5b03 AD |
1390 | $lnum = 0; |
1391 | ||
1392 | while ($line = db_fetch_assoc($result)) { | |
1393 | ||
1394 | $class = ($lnum % 2) ? "even" : "odd"; | |
1395 | ||
3b0feb9b | 1396 | $feed_id = $line["id"]; |
c64d5b03 | 1397 | |
3b0feb9b | 1398 | $edit_feed_id = $_GET["id"]; |
c64d5b03 | 1399 | |
3b0feb9b | 1400 | if ($subop == "edit" && $feed_id != $edit_feed_id) { |
c64d5b03 | 1401 | $class .= "Grayed"; |
53226edc AD |
1402 | $this_row_id = ""; |
1403 | } else { | |
1404 | $this_row_id = "id=\"FEEDR-$feed_id\""; | |
c64d5b03 AD |
1405 | } |
1406 | ||
53226edc | 1407 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
1408 | |
1409 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1410 | ||
1411 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1412 | $feed_icon = "<img width=\"16\" height=\"16\" | |
1413 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1414 | } else { | |
1415 | $feed_icon = " "; | |
1416 | } | |
1417 | print "<td align='center'>$feed_icon</td>"; | |
c64d5b03 AD |
1418 | |
1419 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
3b0feb9b AD |
1420 | $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); |
1421 | $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); | |
1422 | ||
1423 | if (!$edit_cat) $edit_cat = "Uncategorized"; | |
c64d5b03 | 1424 | |
3b0feb9b | 1425 | if (!$edit_feed_id || $subop != "edit") { |
c64d5b03 AD |
1426 | |
1427 | print "<td><input onclick='toggleSelectRow(this);' | |
3b0feb9b | 1428 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
3547842a AD |
1429 | |
1430 | $edit_title = truncate_string($edit_title, 40); | |
1431 | $edit_link = truncate_string($edit_link, 60); | |
c64d5b03 | 1432 | |
3b0feb9b | 1433 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
c64d5b03 | 1434 | $edit_title . "</a></td>"; |
3b0feb9b AD |
1435 | |
1436 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1437 | $edit_link . "</a></td>"; | |
1438 | ||
1439 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1440 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1441 | $edit_cat . "</a></td>"; | |
1442 | } | |
1443 | ||
1444 | if ($line["update_interval"] == "0") | |
1445 | $line["update_interval"] = "Default"; | |
c64d5b03 | 1446 | |
3b0feb9b AD |
1447 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
1448 | $line["update_interval"] . "</a></td>"; | |
1449 | ||
1450 | if ($line["purge_interval"] == "0") | |
1451 | $line["purge_interval"] = "Default"; | |
1452 | ||
1453 | if ($line["purge_interval"] < 0) | |
1454 | $line["purge_interval"] = "Disabled"; | |
1455 | ||
1456 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1457 | $line["purge_interval"] . "</a></td>"; | |
1458 | ||
1459 | } else if ($feed_id != $edit_feed_id) { | |
c64d5b03 AD |
1460 | |
1461 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1462 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
3547842a AD |
1463 | |
1464 | $edit_title = truncate_string($edit_title, 40); | |
1465 | $edit_link = truncate_string($edit_link, 60); | |
1466 | ||
c64d5b03 | 1467 | print "<td>$edit_title</td>"; |
3b0feb9b AD |
1468 | print "<td>$edit_link</td>"; |
1469 | ||
1470 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1471 | print "<td>$edit_cat</td>"; | |
1472 | } | |
1473 | ||
1474 | if ($line["update_interval"] == "0") | |
1475 | $line["update_interval"] = "Default"; | |
1476 | ||
1477 | print "<td>" . $line["update_interval"] . "</td>"; | |
1478 | ||
1479 | if ($line["purge_interval"] == "0") | |
1480 | $line["purge_interval"] = "Default"; | |
1481 | ||
1482 | if ($line["purge_interval"] < 0) | |
1483 | $line["purge_interval"] = "Disabled"; | |
1484 | ||
1485 | print "<td>" . $line["purge_interval"] . "</td>"; | |
c64d5b03 AD |
1486 | |
1487 | } else { | |
1488 | ||
1489 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
1490 | ||
1491 | print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>"; | |
3b0feb9b AD |
1492 | print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>"; |
1493 | ||
1494 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1495 | ||
1496 | print "<td>"; | |
1497 | print "<select id=\"iedit_fcat\">"; | |
1498 | print "<option id=\"0\">Uncategorized</option>"; | |
1499 | ||
1500 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories | |
1501 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
1502 | ||
1503 | if (db_num_rows($tmp_result) > 0) { | |
1504 | print "<option disabled>--------</option>"; | |
1505 | } | |
1506 | ||
1507 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1508 | if ($tmp_line["id"] == $line["cat_id"]) { | |
1509 | $is_selected = "selected"; | |
1510 | } else { | |
1511 | $is_selected = ""; | |
1512 | } | |
1513 | printf("<option $is_selected id='%d'>%s</option>", | |
1514 | $tmp_line["id"], $tmp_line["title"]); | |
1515 | } | |
1516 | ||
1517 | print "</select></td>"; | |
1518 | print "</td>"; | |
1519 | ||
1520 | } | |
c64d5b03 | 1521 | |
3b0feb9b AD |
1522 | print "<td><input id=\"iedit_updintl\" |
1523 | value=\"".$line["update_interval"]."\"></td>"; | |
1524 | print "<td><input id=\"iedit_purgintl\" | |
1525 | value=\"".$line["purge_interval"]."\"></td>"; | |
1526 | ||
c64d5b03 | 1527 | } |
3b0feb9b | 1528 | |
3547842a | 1529 | /* if (!$line["last_updated"]) $line["last_updated"] = "Never"; |
3b0feb9b | 1530 | |
3547842a | 1531 | print "<td>" . $line["last_updated"] . "</td>"; */ |
c64d5b03 AD |
1532 | |
1533 | print "</tr>"; | |
1534 | ||
1535 | ++$lnum; | |
1536 | } | |
1537 | ||
c64d5b03 | 1538 | print "</table>"; |
3b0feb9b | 1539 | |
c64d5b03 AD |
1540 | print "<p>"; |
1541 | ||
3b0feb9b AD |
1542 | if ($subop == "edit") { |
1543 | print "Edit feed: | |
c64d5b03 | 1544 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 1545 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> |
c64d5b03 | 1546 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
1547 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
1548 | } else { | |
c64d5b03 AD |
1549 | |
1550 | print " | |
1551 | Selection: | |
1552 | <input type=\"submit\" class=\"button\" | |
3b0feb9b | 1553 | onclick=\"javascript:selectedFeedDetails()\" value=\"Details\"> |
c64d5b03 | 1554 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
1555 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> |
1556 | <input type=\"submit\" class=\"button\" | |
1557 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
1558 | ||
1559 | if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) { | |
1560 | print " | |
1561 | <input type=\"submit\" class=\"button\" | |
4f3a84f4 | 1562 | onclick=\"javascript:readSelectedFeeds(true)\" value=\"Mark as read\"> |
3b0feb9b | 1563 | <input type=\"submit\" class=\"button\" |
4f3a84f4 | 1564 | onclick=\"javascript:readSelectedFeeds(false)\" |
3b0feb9b AD |
1565 | value=\"Mark as unread\"> "; |
1566 | } | |
1567 | ||
1568 | print " | |
1569 | All feeds: <input type=\"submit\" | |
1570 | class=\"button\" onclick=\"gotoExportOpml()\" | |
1571 | value=\"Export OPML\">"; | |
1572 | } | |
1573 | } else { | |
1574 | ||
1575 | print "<p>No feeds defined.</p>"; | |
1576 | ||
1577 | } | |
1578 | ||
1579 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1580 | ||
1581 | print "<h3>Edit Categories</h3>"; | |
1582 | ||
1583 | // print "<h3>Categories</h3>"; | |
1584 | ||
1585 | print "<div class=\"prefGenericAddBox\"> | |
1586 | <input id=\"fadd_cat\" size=\"40\"> <input | |
1587 | type=\"submit\" class=\"button\" | |
1588 | onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>"; | |
1589 | ||
1590 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
1591 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1592 | ORDER BY title"); | |
1593 | ||
1594 | if (db_num_rows($result) != 0) { | |
1595 | ||
35f3c923 | 1596 | print "<p><table width=\"100%\" class=\"prefFeedCatList\" |
f4fe2cde | 1597 | cellspacing=\"0\" id=\"prefFeedCatList\">"; |
35f3c923 AD |
1598 | |
1599 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
1600 | Select: | |
1601 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', | |
3055bc41 | 1602 | 'FCATR-', 'FCCHK-', true)\">All</a>, |
35f3c923 | 1603 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', |
3055bc41 | 1604 | 'FCATR-', 'FCCHK-', false)\">None</a> |
35f3c923 AD |
1605 | </td</tr>"; |
1606 | ||
3b0feb9b AD |
1607 | print "<tr class=\"title\"> |
1608 | <td width=\"10%\">Select</td><td width=\"80%\">Title</td> | |
1609 | </tr>"; | |
1610 | ||
1611 | $lnum = 0; | |
1612 | ||
1613 | while ($line = db_fetch_assoc($result)) { | |
1614 | ||
1615 | $class = ($lnum % 2) ? "even" : "odd"; | |
1616 | ||
1617 | $cat_id = $line["id"]; | |
1618 | ||
1619 | $edit_cat_id = $_GET["id"]; | |
1620 | ||
1621 | if ($subop == "editCat" && $cat_id != $edit_cat_id) { | |
1622 | $class .= "Grayed"; | |
53226edc AD |
1623 | $this_row_id = ""; |
1624 | } else { | |
1625 | $this_row_id = "id=\"FCATR-$cat_id\""; | |
3b0feb9b AD |
1626 | } |
1627 | ||
53226edc | 1628 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
1629 | |
1630 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
1631 | ||
1632 | if (!$edit_cat_id || $subop != "editCat") { | |
1633 | ||
1634 | print "<td><input onclick='toggleSelectRow(this);' | |
1635 | type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>"; | |
1636 | ||
1637 | print "<td><a href=\"javascript:editFeedCat($cat_id);\">" . | |
1638 | $edit_title . "</a></td>"; | |
1639 | ||
1640 | } else if ($cat_id != $edit_cat_id) { | |
1641 | ||
1642 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1643 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
1644 | ||
1645 | print "<td>$edit_title</td>"; | |
1646 | ||
1647 | } else { | |
1648 | ||
1649 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
1650 | ||
1651 | print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>"; | |
1652 | ||
1653 | } | |
1654 | ||
1655 | print "</tr>"; | |
1656 | ||
1657 | ++$lnum; | |
1658 | } | |
1659 | ||
1660 | print "</table>"; | |
1661 | ||
1662 | print "<p>"; | |
1663 | ||
1664 | if ($subop == "editCat") { | |
1665 | print "Edit category: | |
1666 | <input type=\"submit\" class=\"button\" | |
1667 | onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\"> | |
1668 | <input type=\"submit\" class=\"button\" | |
1669 | onclick=\"javascript:feedCatEditSave()\" value=\"Save\">"; | |
1670 | } else { | |
1671 | ||
1672 | print " | |
1673 | Selection: | |
1674 | <input type=\"submit\" class=\"button\" | |
1675 | onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\"> | |
1676 | <input type=\"submit\" class=\"button\" | |
1677 | onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">"; | |
1678 | ||
1679 | } | |
1680 | ||
1681 | } else { | |
1682 | print "<p>No feed categories defined.</p>"; | |
1683 | } | |
c64d5b03 AD |
1684 | } |
1685 | ||
1686 | print "<h3>Import OPML</h3> | |
f5a50b25 AD |
1687 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
1688 | File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
1689 | <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\" | |
1690 | type=\"submit\" value=\"Import\"> | |
1691 | </form>"; | |
1692 | ||
007bda35 AD |
1693 | } |
1694 | ||
a0d53889 AD |
1695 | if ($op == "pref-filters") { |
1696 | ||
1697 | $subop = $_GET["subop"]; | |
1698 | ||
1699 | if ($subop == "editSave") { | |
a0d53889 | 1700 | |
648472a7 AD |
1701 | $regexp = db_escape_string($_GET["r"]); |
1702 | $descr = db_escape_string($_GET["d"]); | |
1703 | $match = db_escape_string($_GET["m"]); | |
1704 | $filter_id = db_escape_string($_GET["id"]); | |
ead60402 AD |
1705 | $feed_id = db_escape_string($_GET["fid"]); |
1706 | ||
1707 | if (!$feed_id) { | |
1708 | $feed_id = 'NULL'; | |
1709 | } else { | |
1710 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
1711 | } | |
0afbd851 | 1712 | |
648472a7 | 1713 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 1714 | reg_exp = '$regexp', |
0afbd851 | 1715 | description = '$descr', |
ead60402 | 1716 | feed_id = $feed_id, |
0afbd851 AD |
1717 | filter_type = (SELECT id FROM ttrss_filter_types WHERE |
1718 | description = '$match') | |
1719 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
1720 | } |
1721 | ||
1722 | if ($subop == "remove") { | |
1723 | ||
1724 | if (!WEB_DEMO_MODE) { | |
1725 | ||
1726 | $ids = split(",", $_GET["ids"]); | |
1727 | ||
1728 | foreach ($ids as $id) { | |
648472a7 | 1729 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
1730 | |
1731 | } | |
1732 | } | |
1733 | } | |
1734 | ||
1735 | if ($subop == "add") { | |
1736 | ||
de435974 | 1737 | if (!WEB_DEMO_MODE) { |
a0d53889 | 1738 | |
b6b535ca AD |
1739 | $regexp = db_escape_string(trim($_GET["regexp"])); |
1740 | $match = db_escape_string(trim($_GET["match"])); | |
ead60402 AD |
1741 | $feed_id = db_escape_string($_GET["fid"]); |
1742 | ||
1743 | if (!$feed_id) { | |
1744 | $feed_id = 'NULL'; | |
1745 | } else { | |
1746 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
1747 | } | |
4401bf04 | 1748 | |
648472a7 | 1749 | $result = db_query($link, |
ead60402 | 1750 | "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id) VALUES |
de435974 | 1751 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
ead60402 | 1752 | description = '$match'),'".$_SESSION["uid"]."', $feed_id)"); |
de435974 | 1753 | } |
a0d53889 AD |
1754 | } |
1755 | ||
648472a7 | 1756 | $result = db_query($link, "SELECT description |
a0d53889 AD |
1757 | FROM ttrss_filter_types ORDER BY description"); |
1758 | ||
1759 | $filter_types = array(); | |
1760 | ||
648472a7 | 1761 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
1762 | array_push($filter_types, $line["description"]); |
1763 | } | |
1764 | ||
2c7070b5 AD |
1765 | print "<div class=\"prefGenericAddBox\"> |
1766 | <input id=\"fadd_regexp\" size=\"40\"> "; | |
1767 | ||
ead60402 AD |
1768 | print_select("fadd_match", "Title", $filter_types); |
1769 | ||
1770 | print " <select id=\"fadd_feed\">"; | |
1771 | ||
1772 | print "<option selected id=\"0\">All feeds</option>"; | |
1773 | ||
1774 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
1775 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
1776 | ||
1777 | if (db_num_rows($result) > 0) { | |
1778 | print "<option disabled>--------</option>"; | |
1779 | } | |
1780 | ||
1781 | while ($line = db_fetch_assoc($result)) { | |
1782 | printf("<option id='%d'>%s</option>", $line["id"], $line["title"]); | |
1783 | } | |
1784 | ||
2c7070b5 | 1785 | print "</select> "; |
a0d53889 | 1786 | |
2c7070b5 AD |
1787 | print "<input type=\"submit\" |
1788 | class=\"button\" onclick=\"javascript:addFilter()\" | |
1789 | value=\"Add filter\">"; | |
a0d53889 | 1790 | |
648472a7 | 1791 | $result = db_query($link, "SELECT |
ead60402 AD |
1792 | ttrss_filters.id AS id,reg_exp, |
1793 | ttrss_filters.description AS description, | |
1794 | ttrss_filter_types.name AS filter_type_name, | |
1795 | ttrss_filter_types.description AS filter_type_descr, | |
1796 | feed_id, | |
1797 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title | |
a0d53889 | 1798 | FROM |
ead60402 | 1799 | ttrss_filters,ttrss_filter_types |
4356293a | 1800 | WHERE |
ead60402 AD |
1801 | filter_type = ttrss_filter_types.id AND |
1802 | ttrss_filters.owner_uid = ".$_SESSION["uid"]." | |
4356293a | 1803 | ORDER by reg_exp"); |
a0d53889 | 1804 | |
3b0feb9b | 1805 | if (db_num_rows($result) != 0) { |
a0d53889 | 1806 | |
f4fe2cde AD |
1807 | print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" |
1808 | id=\"prefFilterList\">"; | |
35f3c923 AD |
1809 | |
1810 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
1811 | Select: | |
1812 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', | |
3055bc41 | 1813 | 'FILRR-', 'FICHK-', true)\">All</a>, |
35f3c923 | 1814 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', |
3055bc41 | 1815 | 'FILRR-', 'FICHK-', false)\">None</a> |
35f3c923 AD |
1816 | </td</tr>"; |
1817 | ||
3b0feb9b AD |
1818 | print "<tr class=\"title\"> |
1819 | <td width=\"5%\">Select</td><td width=\"30%\">Filter expression</td> | |
1820 | <td width=\"30%\">Feed</td><td width=\"10%\">Match</td> | |
1821 | <td width=\"30%\">Description</td></tr>"; | |
a0d53889 | 1822 | |
3b0feb9b AD |
1823 | $lnum = 0; |
1824 | ||
1825 | while ($line = db_fetch_assoc($result)) { | |
1826 | ||
1827 | $class = ($lnum % 2) ? "even" : "odd"; | |
1828 | ||
1829 | $filter_id = $line["id"]; | |
1830 | $edit_filter_id = $_GET["id"]; | |
1831 | ||
1832 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
1833 | $class .= "Grayed"; | |
53226edc AD |
1834 | $this_row_id = ""; |
1835 | } else { | |
1836 | $this_row_id = "id=\"FILRR-$filter_id\""; | |
ead60402 | 1837 | } |
3b0feb9b | 1838 | |
53226edc | 1839 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
1840 | |
1841 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); | |
1842 | $line["description"] = htmlspecialchars($line["description"]); | |
1843 | ||
1844 | if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; | |
1845 | ||
1846 | if (!$edit_filter_id || $subop != "edit") { | |
1847 | ||
1848 | if (!$line["description"]) $line["description"] = "[No description]"; | |
1849 | ||
1850 | print "<td><input onclick='toggleSelectRow(this);' | |
1851 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; | |
1852 | ||
1853 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
1854 | $line["reg_exp"] . "</td>"; | |
1855 | ||
1856 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
1857 | $line["feed_title"] . "</td>"; | |
1858 | ||
1859 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
1860 | $line["filter_type_descr"] . "</td>"; | |
1861 | ||
1862 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
1863 | $line["description"] . "</td>"; | |
1864 | ||
1865 | } else if ($filter_id != $edit_filter_id) { | |
1866 | ||
1867 | if (!$line["description"]) $line["description"] = "[No description]"; | |
1868 | ||
1869 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
1870 | id=\"FICHK-".$line["id"]."\"></td>"; | |
1871 | ||
1872 | print "<td>".$line["reg_exp"]."</td>"; | |
1873 | print "<td>".$line["feed_title"]."</td>"; | |
1874 | print "<td>".$line["filter_type_descr"]."</td>"; | |
1875 | print "<td>".$line["description"]."</td>"; | |
1876 | ||
1877 | } else { | |
1878 | ||
1879 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
1880 | ||
1881 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. | |
1882 | "\"></td>"; | |
1883 | ||
1884 | print "<td>"; | |
1885 | ||
1886 | print "<select id=\"iedit_feed\">"; | |
1887 | ||
1888 | print "<option id=\"0\">All feeds</option>"; | |
1889 | ||
1890 | if (db_num_rows($result) > 0) { | |
1891 | print "<option disabled>--------</option>"; | |
1892 | } | |
1893 | ||
1894 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
1895 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
1896 | ||
1897 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1898 | if ($tmp_line["id"] == $line["feed_id"]) { | |
1899 | $is_selected = "selected"; | |
1900 | } else { | |
1901 | $is_selected = ""; | |
1902 | } | |
1903 | printf("<option $is_selected id='%d'>%s</option>", | |
1904 | $tmp_line["id"], $tmp_line["title"]); | |
ead60402 | 1905 | } |
3b0feb9b AD |
1906 | |
1907 | print "</select></td>"; | |
1908 | ||
1909 | print "<td>"; | |
1910 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
1911 | print "</td>"; | |
1912 | ||
1913 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
1914 | "\"></td>"; | |
1915 | ||
1916 | print "</td>"; | |
ead60402 | 1917 | } |
3b0feb9b AD |
1918 | |
1919 | print "</tr>"; | |
1920 | ||
1921 | ++$lnum; | |
a0d53889 | 1922 | } |
3b0feb9b AD |
1923 | |
1924 | if ($lnum == 0) { | |
1925 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
1926 | } | |
1927 | ||
1928 | print "</table>"; | |
1929 | ||
1930 | print "<p>"; | |
1931 | ||
1932 | if ($subop == "edit") { | |
1933 | print "Edit feed: | |
1934 | <input type=\"submit\" class=\"button\" | |
1935 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\"> | |
1936 | <input type=\"submit\" class=\"button\" | |
1937 | onclick=\"javascript:filterEditSave()\" value=\"Save\">"; | |
1938 | ||
1939 | } else { | |
1940 | ||
1941 | print " | |
1942 | Selection: | |
e828e31e | 1943 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 1944 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> |
e828e31e | 1945 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
1946 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; |
1947 | } | |
1948 | ||
a0d53889 AD |
1949 | } else { |
1950 | ||
3b0feb9b AD |
1951 | print "<p>No filters defined.</p>"; |
1952 | ||
a0d53889 AD |
1953 | } |
1954 | } | |
1955 | ||
48f0adb0 AD |
1956 | if ($op == "pref-labels") { |
1957 | ||
1958 | $subop = $_GET["subop"]; | |
1959 | ||
d9dde1d6 AD |
1960 | if ($subop == "test") { |
1961 | ||
1962 | $expr = $_GET["expr"]; | |
1963 | $descr = $_GET["descr"]; | |
1964 | ||
1965 | print "<div class='infoBoxContents'>"; | |
1966 | ||
1967 | print "<h1>Label «$descr»</h1>"; | |
1968 | ||
1969 | // print "<p><b>Expression</b>: $expr</p>"; | |
1970 | ||
1971 | $result = db_query($link, | |
1972 | "SELECT count(id) AS num_matches | |
1973 | FROM ttrss_entries,ttrss_user_entries | |
1974 | WHERE ($expr) AND | |
1975 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
1976 | owner_uid = " . $_SESSION["uid"]); | |
1977 | ||
1978 | $num_matches = db_fetch_result($result, 0, "num_matches");; | |
1979 | ||
1980 | if ($num_matches > 0) { | |
1981 | ||
a31a7b39 | 1982 | print "<p>Query returned <b>$num_matches</b> matches, first 5 follow:</p>"; |
d9dde1d6 AD |
1983 | |
1984 | $result = db_query($link, | |
1985 | "SELECT title, | |
1986 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title | |
1987 | FROM ttrss_entries,ttrss_user_entries | |
1988 | WHERE ($expr) AND | |
1989 | ttrss_user_entries.ref_id = ttrss_entries.id | |
1990 | AND owner_uid = " . $_SESSION["uid"] . " | |
1991 | ORDER BY date_entered DESC LIMIT 5"); | |
1992 | ||
1993 | print "<ul class=\"nomarks\">"; | |
1994 | while ($line = db_fetch_assoc($result)) { | |
1995 | print "<li>".$line["title"]. | |
1996 | " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>"; | |
1997 | } | |
1998 | print "</ul>"; | |
1999 | ||
2000 | } else { | |
2001 | print "<p>Query didn't return any matches.</p>"; | |
2002 | } | |
2003 | ||
2004 | print "</div>"; | |
2005 | ||
2006 | print "<div align='center'> | |
2007 | <input type='submit' class='button' | |
2008 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
2009 | return; | |
2010 | } | |
2011 | ||
48f0adb0 AD |
2012 | if ($subop == "editSave") { |
2013 | ||
2014 | $sql_exp = $_GET["s"]; | |
2015 | $descr = $_GET["d"]; | |
2016 | $label_id = db_escape_string($_GET["id"]); | |
2017 | ||
2018 | // print "$sql_exp : $descr : $label_id"; | |
2019 | ||
2020 | $result = db_query($link, "UPDATE ttrss_labels SET | |
2021 | sql_exp = '$sql_exp', | |
2022 | description = '$descr' | |
2023 | WHERE id = '$label_id'"); | |
2024 | } | |
2025 | ||
2026 | if ($subop == "remove") { | |
2027 | ||
2028 | if (!WEB_DEMO_MODE) { | |
2029 | ||
2030 | $ids = split(",", $_GET["ids"]); | |
2031 | ||
2032 | foreach ($ids as $id) { | |
2033 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
2034 | ||
2035 | } | |
2036 | } | |
2037 | } | |
2038 | ||
2039 | if ($subop == "add") { | |
2040 | ||
2041 | if (!WEB_DEMO_MODE) { | |
2042 | ||
4401bf04 AD |
2043 | // no escaping is done here on purpose |
2044 | $exp = trim($_GET["exp"]); | |
48f0adb0 AD |
2045 | |
2046 | $result = db_query($link, | |
4356293a AD |
2047 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) |
2048 | VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); | |
48f0adb0 AD |
2049 | } |
2050 | } | |
2051 | ||
2c7070b5 AD |
2052 | print "<div class=\"prefGenericAddBox\"> |
2053 | <input size=\"40\" id=\"ladd_expr\"> "; | |
48f0adb0 | 2054 | |
2c7070b5 AD |
2055 | print"<input type=\"submit\" class=\"button\" |
2056 | onclick=\"javascript:addLabel()\" value=\"Add label\"></div>"; | |
48f0adb0 AD |
2057 | |
2058 | $result = db_query($link, "SELECT | |
2059 | id,sql_exp,description | |
2060 | FROM | |
4356293a AD |
2061 | ttrss_labels |
2062 | WHERE | |
2063 | owner_uid = ".$_SESSION["uid"]." | |
2064 | ORDER by description"); | |
48f0adb0 | 2065 | |
d9dde1d6 AD |
2066 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
2067 | ||
3b0feb9b | 2068 | if (db_num_rows($result) != 0) { |
48f0adb0 | 2069 | |
f4fe2cde AD |
2070 | print "<p><table width=\"100%\" cellspacing=\"0\" |
2071 | class=\"prefLabelList\" id=\"prefLabelList\">"; | |
35f3c923 AD |
2072 | |
2073 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2074 | Select: | |
2075 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', | |
3055bc41 | 2076 | 'LILRR-', 'LICHK-', true)\">All</a>, |
35f3c923 | 2077 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', |
3055bc41 | 2078 | 'LILRR-', 'LICHK-', false)\">None</a> |
35f3c923 AD |
2079 | </td</tr>"; |
2080 | ||
3b0feb9b AD |
2081 | print "<tr class=\"title\"> |
2082 | <td width=\"5%\">Select</td><td width=\"40%\">SQL expression | |
01c9c74a | 2083 | <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a> |
3b0feb9b AD |
2084 | </td> |
2085 | <td width=\"40%\">Caption</td></tr>"; | |
2086 | ||
2087 | $lnum = 0; | |
2088 | ||
2089 | while ($line = db_fetch_assoc($result)) { | |
2090 | ||
2091 | $class = ($lnum % 2) ? "even" : "odd"; | |
2092 | ||
2093 | $label_id = $line["id"]; | |
2094 | $edit_label_id = $_GET["id"]; | |
2095 | ||
2096 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
2097 | $class .= "Grayed"; | |
53226edc AD |
2098 | $this_row_id = ""; |
2099 | } else { | |
2100 | $this_row_id = "id=\"LILRR-$label_id\""; | |
3b0feb9b AD |
2101 | } |
2102 | ||
53226edc | 2103 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2104 | |
2105 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
2106 | $line["description"] = htmlspecialchars($line["description"]); | |
2107 | ||
2108 | if (!$edit_label_id || $subop != "edit") { | |
2109 | ||
2110 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
2111 | ||
2112 | print "<td><input onclick='toggleSelectRow(this);' | |
2113 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; | |
2114 | ||
2115 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
2116 | $line["sql_exp"] . "</td>"; | |
48f0adb0 | 2117 | |
3b0feb9b AD |
2118 | print "<td><a href=\"javascript:editLabel($label_id);\">" . |
2119 | $line["description"] . "</td>"; | |
2120 | ||
2121 | } else if ($label_id != $edit_label_id) { | |
2122 | ||
2123 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2124 | ||
2125 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2126 | id=\"LICHK-".$line["id"]."\"></td>"; | |
2127 | ||
2128 | print "<td>".$line["sql_exp"]."</td>"; | |
2129 | print "<td>".$line["description"]."</td>"; | |
2130 | ||
2131 | } else { | |
2132 | ||
2133 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2134 | ||
2135 | print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. | |
2136 | "\"></td>"; | |
2137 | ||
2138 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
2139 | "\"></td>"; | |
2140 | ||
2141 | } | |
2142 | ||
48f0adb0 | 2143 | |
3b0feb9b AD |
2144 | print "</tr>"; |
2145 | ||
2146 | ++$lnum; | |
2147 | } | |
2148 | ||
2149 | if ($lnum == 0) { | |
2150 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
2151 | } | |
2152 | ||
2153 | print "</table>"; | |
2154 | ||
2155 | print "<p>"; | |
2156 | ||
2157 | if ($subop == "edit") { | |
2158 | print "Edit label: | |
d9dde1d6 AD |
2159 | <input type=\"submit\" class=\"button\" |
2160 | onclick=\"javascript:labelTest()\" value=\"Test\"> | |
3b0feb9b AD |
2161 | <input type=\"submit\" class=\"button\" |
2162 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\"> | |
2163 | <input type=\"submit\" class=\"button\" | |
2164 | onclick=\"javascript:labelEditSave()\" value=\"Save\">"; | |
2165 | ||
2166 | } else { | |
2167 | ||
2168 | print " | |
2169 | Selection: | |
48f0adb0 | 2170 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2171 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> |
48f0adb0 | 2172 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2173 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; |
2174 | } | |
48f0adb0 | 2175 | } else { |
3b0feb9b | 2176 | print "<p>No labels defined.</p>"; |
48f0adb0 AD |
2177 | } |
2178 | } | |
2179 | ||
e828e31e AD |
2180 | if ($op == "error") { |
2181 | print "<div width=\"100%\" align='center'>"; | |
2182 | $msg = $_GET["msg"]; | |
2183 | print $msg; | |
2184 | print "</div>"; | |
2185 | } | |
2186 | ||
7dc66a61 | 2187 | if ($op == "help") { |
01c9c74a AD |
2188 | if (!$_GET["noheaders"]) { |
2189 | print "<html><head> | |
2190 | <title>Tiny Tiny RSS : Help</title> | |
2191 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
2192 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
2193 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
2194 | </head><body>"; | |
2195 | } | |
7dc66a61 AD |
2196 | |
2197 | $tid = sprintf("%d", $_GET["tid"]); | |
2198 | ||
01c9c74a | 2199 | print "<div class='infoBoxContents'>"; |
7dc66a61 | 2200 | |
01c9c74a AD |
2201 | if (file_exists("help/$tid.php")) { |
2202 | include("help/$tid.php"); | |
2203 | } else { | |
2204 | print "<p>Help topic not found.</p>"; | |
2205 | } | |
7dc66a61 | 2206 | |
01c9c74a | 2207 | print "</div>"; |
7dc66a61 AD |
2208 | |
2209 | print "<div align='center'> | |
01c9c74a AD |
2210 | <input type='submit' class='button' |
2211 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
7dc66a61 | 2212 | |
01c9c74a AD |
2213 | if (!$_GET["noheaders"]) { |
2214 | print "</body></html>"; | |
2215 | } | |
7dc66a61 AD |
2216 | |
2217 | } | |
2218 | ||
f84a97a3 AD |
2219 | if ($op == "dlg") { |
2220 | $id = $_GET["id"]; | |
6de5d056 | 2221 | $param = $_GET["param"]; |
f84a97a3 AD |
2222 | |
2223 | if ($id == "quickAddFeed") { | |
76332f3c AD |
2224 | print " |
2225 | Feed URL: <input | |
033e47e0 AD |
2226 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" |
2227 | id=\"qafInput\"> | |
f84a97a3 AD |
2228 | <input class=\"button\" |
2229 | type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\"> | |
2230 | <input class=\"button\" | |
2231 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2232 | value=\"Cancel\">"; | |
2233 | } | |
6de5d056 AD |
2234 | |
2235 | if ($id == "quickDelFeed") { | |
2236 | ||
2237 | $param = db_escape_string($param); | |
2238 | ||
2239 | $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'"); | |
2240 | ||
2241 | if ($result) { | |
2242 | ||
2243 | $f_title = db_fetch_result($result, 0, "title"); | |
2244 | ||
76332f3c | 2245 | print "Remove current feed (<b>$f_title</b>)? |
6de5d056 AD |
2246 | <input class=\"button\" |
2247 | type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\"> | |
2248 | <input class=\"button\" | |
2249 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2250 | value=\"Cancel\">"; | |
2251 | } else { | |
2252 | print "Error: Feed $param not found. | |
2253 | <input class=\"button\" | |
2254 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2255 | value=\"Cancel\">"; | |
2256 | } | |
2257 | } | |
2258 | ||
033e47e0 AD |
2259 | if ($id == "search") { |
2260 | ||
2261 | print "<input id=\"searchbox\" class=\"extSearch\" | |
2262 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
2263 | onchange=\"javascript:search()\"> | |
2264 | <select id=\"searchmodebox\"> | |
2265 | <option selected>All feeds</option> | |
2266 | <option>This feed</option> | |
2267 | </select> | |
2268 | <input type=\"submit\" | |
2269 | class=\"button\" onclick=\"javascript:search()\" value=\"Search\"> | |
2270 | <input class=\"button\" | |
2271 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2272 | value=\"Close\">"; | |
2273 | ||
2274 | } | |
2275 | ||
f84a97a3 AD |
2276 | } |
2277 | ||
a2770077 AD |
2278 | // update feeds of all users, may be used anonymously |
2279 | if ($op == "globalUpdateFeeds") { | |
2280 | ||
2281 | $result = db_query($link, "SELECT id FROM ttrss_users"); | |
2282 | ||
2283 | while ($line = db_fetch_assoc($result)) { | |
2284 | $user_id = $line["id"]; | |
2285 | // print "<!-- updating feeds of uid $user_id -->"; | |
2286 | update_all_feeds($link, false, $user_id); | |
2287 | } | |
e65af9c1 | 2288 | |
a2770077 AD |
2289 | print "<rpc-reply> |
2290 | <message msg=\"All feeds updated\"/> | |
2291 | </rpc-reply>"; | |
e65af9c1 AD |
2292 | |
2293 | } | |
2294 | ||
77e96719 AD |
2295 | if ($op == "pref-prefs") { |
2296 | ||
b1895692 | 2297 | $subop = $_REQUEST["subop"]; |
77e96719 AD |
2298 | |
2299 | if ($subop == "Save configuration") { | |
2300 | ||
d2892032 AD |
2301 | if (WEB_DEMO_MODE) { |
2302 | header("Location: prefs.php"); | |
2303 | return; | |
2304 | } | |
01d68cf9 | 2305 | |
93cb4442 AD |
2306 | $_SESSION["prefs_op_result"] = "save-config"; |
2307 | ||
77e96719 AD |
2308 | foreach (array_keys($_POST) as $pref_name) { |
2309 | ||
2310 | $pref_name = db_escape_string($pref_name); | |
2311 | $value = db_escape_string($_POST[$pref_name]); | |
2312 | ||
2313 | $result = db_query($link, "SELECT type_name | |
2314 | FROM ttrss_prefs,ttrss_prefs_types | |
2315 | WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id"); | |
2316 | ||
2317 | if (db_num_rows($result) > 0) { | |
2318 | ||
2319 | $type_name = db_fetch_result($result, 0, "type_name"); | |
2320 | ||
5da169d9 AD |
2321 | // print "$pref_name : $type_name : $value<br>"; |
2322 | ||
77e96719 | 2323 | if ($type_name == "bool") { |
5da169d9 | 2324 | if ($value == "1") { |
77e96719 AD |
2325 | $value = "true"; |
2326 | } else { | |
2327 | $value = "false"; | |
2328 | } | |
2329 | } else if ($type_name == "integer") { | |
2330 | $value = sprintf("%d", $value); | |
2331 | } | |
2332 | ||
2333 | // print "$pref_name : $type_name : $value<br>"; | |
2334 | ||
ff485f1d AD |
2335 | db_query($link, "UPDATE ttrss_user_prefs SET value = '$value' |
2336 | WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]); | |
77e96719 AD |
2337 | |
2338 | } | |
2339 | ||
2340 | header("Location: prefs.php"); | |
2341 | ||
2342 | } | |
2343 | ||
b1895692 AD |
2344 | } else if ($subop == "getHelp") { |
2345 | ||
2346 | $pref_name = db_escape_string($_GET["pn"]); | |
2347 | ||
2348 | $result = db_query($link, "SELECT help_text FROM ttrss_prefs | |
2349 | WHERE pref_name = '$pref_name'"); | |
2350 | ||
2351 | if (db_num_rows($result) > 0) { | |
2352 | $help_text = db_fetch_result($result, 0, "help_text"); | |
2353 | print $help_text; | |
2354 | } else { | |
2355 | print "Unknown option: $pref_name"; | |
2356 | } | |
2357 | ||
1c7f75ed AD |
2358 | } else if ($subop == "Change password") { |
2359 | ||
d2892032 AD |
2360 | if (WEB_DEMO_MODE) { |
2361 | header("Location: prefs.php"); | |
2362 | return; | |
2363 | } | |
1c7f75ed AD |
2364 | |
2365 | $old_pw = $_POST["OLD_PASSWORD"]; | |
2366 | $new_pw = $_POST["OLD_PASSWORD"]; | |
2367 | ||
2368 | $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]); | |
2369 | $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]); | |
2370 | ||
2371 | $active_uid = $_SESSION["uid"]; | |
2372 | ||
2373 | if ($old_pw && $new_pw) { | |
2374 | ||
2375 | $login = db_escape_string($_SERVER['PHP_AUTH_USER']); | |
2376 | ||
2377 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
2378 | id = '$active_uid' AND (pwd_hash = '$old_pw' OR | |
2379 | pwd_hash = '$old_pw_hash')"); | |
2380 | ||
2381 | if (db_num_rows($result) == 1) { | |
2382 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash' | |
2383 | WHERE id = '$active_uid'"); | |
b791095d AD |
2384 | |
2385 | $_SESSION["pwd_change_result"] = "ok"; | |
2386 | } else { | |
2387 | $_SESSION["pwd_change_result"] = "failed"; | |
1c7f75ed AD |
2388 | } |
2389 | } | |
2390 | ||
2391 | header("Location: prefs.php"); | |
b791095d | 2392 | |
77e96719 AD |
2393 | } else if ($subop == "Reset to defaults") { |
2394 | ||
d2892032 AD |
2395 | if (WEB_DEMO_MODE) { |
2396 | header("Location: prefs.php"); | |
2397 | return; | |
2398 | } | |
01d68cf9 | 2399 | |
93cb4442 AD |
2400 | $_SESSION["prefs_op_result"] = "reset-to-defaults"; |
2401 | ||
e1aa0559 AD |
2402 | if (DB_TYPE == "pgsql") { |
2403 | db_query($link,"UPDATE ttrss_user_prefs | |
2404 | SET value = ttrss_prefs.def_value | |
2405 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
2406 | ttrss_prefs.pref_name = ttrss_user_prefs.pref_name"); | |
2407 | } else { | |
2408 | db_query($link, "DELETE FROM ttrss_user_prefs | |
2409 | WHERE owner_uid = ".$_SESSION["uid"]); | |
2410 | initialize_user_prefs($link, $_SESSION["uid"]); | |
2411 | } | |
5da169d9 | 2412 | |
77e96719 AD |
2413 | header("Location: prefs.php"); |
2414 | ||
58f8ad54 AD |
2415 | } else if ($subop == "Change theme") { |
2416 | ||
2417 | $theme = db_escape_string($_POST["theme"]); | |
2418 | ||
2419 | if ($theme == "Default") { | |
2420 | $theme_qpart = 'NULL'; | |
2421 | } else { | |
2422 | $theme_qpart = "'$theme'"; | |
2423 | } | |
2424 | ||
6752e330 AD |
2425 | $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes |
2426 | WHERE theme_name = '$theme'"); | |
2427 | ||
2428 | if (db_num_rows($result) == 1) { | |
2429 | $theme_id = db_fetch_result($result, 0, "id"); | |
2430 | $theme_path = db_fetch_result($result, 0, "theme_path"); | |
2431 | } else { | |
2432 | $theme_id = "NULL"; | |
2433 | $theme_path = ""; | |
2434 | } | |
2435 | ||
58f8ad54 | 2436 | db_query($link, "UPDATE ttrss_users SET |
6752e330 | 2437 | theme_id = $theme_id WHERE id = " . $_SESSION["uid"]); |
58f8ad54 | 2438 | |
6752e330 | 2439 | $_SESSION["theme"] = $theme_path; |
503eb349 | 2440 | |
58f8ad54 AD |
2441 | header("Location: prefs.php"); |
2442 | ||
77e96719 AD |
2443 | } else { |
2444 | ||
7d4c898a | 2445 | if (!SINGLE_USER_MODE) { |
1c7f75ed | 2446 | |
a029d530 AD |
2447 | $result = db_query($link, "SELECT id FROM ttrss_users |
2448 | WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR | |
2449 | pwd_hash = 'SHA1:".sha1("password")."')"); | |
2450 | ||
2451 | if (db_num_rows($result) != 0) { | |
b791095d | 2452 | print "<div class=\"warning\"> |
a029d530 AD |
2453 | Your password is at default value, please change it. |
2454 | </div>"; | |
2455 | } | |
2456 | ||
b791095d AD |
2457 | if ($_SESSION["pwd_change_result"] == "failed") { |
2458 | print "<div class=\"warning\"> | |
2459 | There was an error while changing your password. | |
2460 | </div>"; | |
2461 | } | |
2462 | ||
2463 | if ($_SESSION["pwd_change_result"] == "ok") { | |
2464 | print "<div class=\"notice\"> | |
2465 | Password changed successfully. | |
2466 | </div>"; | |
2467 | } | |
2468 | ||
2469 | $_SESSION["pwd_change_result"] = ""; | |
2470 | ||
93cb4442 AD |
2471 | if ($_SESSION["prefs_op_result"] == "reset-to-defaults") { |
2472 | print "<div class=\"notice\"> | |
2473 | Your configuration was reset to defaults. | |
2474 | </div>"; | |
2475 | } | |
2476 | ||
2477 | if ($_SESSION["prefs_op_result"] == "save-config") { | |
2478 | print "<div class=\"notice\"> | |
2479 | Your configuration was saved successfully. | |
2480 | </div>"; | |
2481 | } | |
2482 | ||
2483 | $_SESSION["prefs_op_result"] = ""; | |
2484 | ||
7d4c898a AD |
2485 | print "<form action=\"backend.php\" method=\"POST\">"; |
2486 | ||
2487 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
2488 | print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>"; | |
2489 | ||
2490 | print "<tr><td width=\"40%\">Old password</td>"; | |
2491 | print "<td><input class=\"editbox\" type=\"password\" | |
2492 | name=\"OLD_PASSWORD\"></td></tr>"; | |
2493 | ||
2494 | print "<tr><td width=\"40%\">New password</td>"; | |
2495 | ||
2496 | print "<td><input class=\"editbox\" type=\"password\" | |
2497 | name=\"NEW_PASSWORD\"></td></tr>"; | |
2498 | ||
2499 | print "</table>"; | |
2500 | ||
2501 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
2502 | ||
2503 | print "<p><input class=\"button\" type=\"submit\" | |
2504 | value=\"Change password\" name=\"subop\">"; | |
2505 | ||
2506 | print "</form>"; | |
1c7f75ed | 2507 | |
7d4c898a | 2508 | } |
1c7f75ed | 2509 | |
58f8ad54 AD |
2510 | $result = db_query($link, "SELECT |
2511 | theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]); | |
2512 | ||
2513 | $user_theme_id = db_fetch_result($result, 0, "theme_id"); | |
2514 | ||
2515 | $result = db_query($link, "SELECT | |
2516 | id,theme_name FROM ttrss_themes ORDER BY theme_name"); | |
2517 | ||
2518 | if (db_num_rows($result) > 0) { | |
6752e330 AD |
2519 | |
2520 | print "<form action=\"backend.php\" method=\"POST\">"; | |
2521 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
2522 | print "<tr><td colspan='3'><h3>Themes</h3></tr></td>"; | |
2523 | print "<tr><td width=\"40%\">Select theme</td>"; | |
2524 | print "<td><select name=\"theme\">"; | |
2525 | print "<option>Default</option>"; | |
58f8ad54 | 2526 | print "<option disabled>--------</option>"; |
6752e330 | 2527 | |
58f8ad54 AD |
2528 | while ($line = db_fetch_assoc($result)) { |
2529 | if ($line["id"] == $user_theme_id) { | |
2530 | $selected = "selected"; | |
2531 | } else { | |
2532 | $selected = ""; | |
2533 | } | |
2534 | print "<option $selected>" . $line["theme_name"] . "</option>"; | |
2535 | } | |
6752e330 AD |
2536 | print "</select></td></tr>"; |
2537 | print "</table>"; | |
2538 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
2539 | print "<p><input class=\"button\" type=\"submit\" | |
2540 | value=\"Change theme\" name=\"subop\">"; | |
2541 | print "</form>"; | |
58f8ad54 AD |
2542 | } |
2543 | ||
77e96719 | 2544 | $result = db_query($link, "SELECT |
ff485f1d | 2545 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, |
77e96719 | 2546 | section_name,def_value |
ff485f1d | 2547 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs |
77e96719 | 2548 | WHERE type_id = ttrss_prefs_types.id AND |
ff485f1d | 2549 | section_id = ttrss_prefs_sections.id AND |
a2411bd9 AD |
2550 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND |
2551 | owner_uid = ".$_SESSION["uid"]." | |
650bc435 | 2552 | ORDER BY section_id,short_desc"); |
77e96719 AD |
2553 | |
2554 | print "<form action=\"backend.php\" method=\"POST\">"; | |
2555 | ||
77e96719 AD |
2556 | $lnum = 0; |
2557 | ||
2558 | $active_section = ""; | |
2559 | ||
2560 | while ($line = db_fetch_assoc($result)) { | |
2561 | ||
2562 | if ($active_section != $line["section_name"]) { | |
59a654ba AD |
2563 | |
2564 | if ($active_section != "") { | |
1c7f75ed | 2565 | print "</table>"; |
59a654ba | 2566 | } |
1c7f75ed AD |
2567 | |
2568 | print "<p><table width=\"100%\" class=\"prefPrefsList\">"; | |
59a654ba AD |
2569 | |
2570 | $active_section = $line["section_name"]; | |
2571 | ||
77e96719 | 2572 | print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>"; |
59a654ba AD |
2573 | // print "<tr class=\"title\"> |
2574 | // <td width=\"25%\">Option</td><td>Value</td></tr>"; | |
7268adf7 AD |
2575 | |
2576 | $lnum = 0; | |
77e96719 AD |
2577 | } |
2578 | ||
650bc435 | 2579 | // $class = ($lnum % 2) ? "even" : "odd"; |
77e96719 | 2580 | |
650bc435 | 2581 | print "<tr>"; |
77e96719 | 2582 | |
77e96719 AD |
2583 | $type_name = $line["type_name"]; |
2584 | $pref_name = $line["pref_name"]; | |
2585 | $value = $line["value"]; | |
2586 | $def_value = $line["def_value"]; | |
b1895692 AD |
2587 | $help_text = $line["help_text"]; |
2588 | ||
2589 | print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"]; | |
2590 | ||
2591 | if ($help_text) print "<div class=\"prefHelp\">$help_text</div>"; | |
2592 | ||
2593 | print "</td>"; | |
77e96719 AD |
2594 | |
2595 | print "<td>"; | |
2596 | ||
2597 | if ($type_name == "bool") { | |
2598 | // print_select($pref_name, $value, array("true", "false")); | |
2599 | ||
2600 | if ($value == "true") { | |
2601 | $value = "Yes"; | |
2602 | } else { | |
2603 | $value = "No"; | |
2604 | } | |
2605 | ||
2606 | print_radio($pref_name, $value, array("Yes", "No")); | |
2607 | ||
2608 | } else { | |
2609 | print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">"; | |
2610 | } | |
2611 | ||
2612 | print "</td>"; | |
2613 | ||
2614 | print "</tr>"; | |
2615 | ||
2616 | $lnum++; | |
2617 | } | |
2618 | ||
2619 | print "</table>"; | |
2620 | ||
2621 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
2622 | ||
2623 | print "<p><input class=\"button\" type=\"submit\" | |
2624 | name=\"subop\" value=\"Save configuration\">"; | |
2625 | ||
2626 | print " <input class=\"button\" type=\"submit\" | |
2627 | name=\"subop\" value=\"Reset to defaults\"></p>"; | |
2628 | ||
2629 | print "</form>"; | |
2630 | ||
2631 | } | |
2632 | ||
2633 | } | |
2634 | ||
e6cb77a0 AD |
2635 | if ($op == "pref-users") { |
2636 | ||
2637 | $subop = $_GET["subop"]; | |
2638 | ||
2639 | if ($subop == "editSave") { | |
2640 | ||
2641 | if (!WEB_DEMO_MODE) { | |
2642 | ||
2643 | $login = db_escape_string($_GET["l"]); | |
2644 | $uid = db_escape_string($_GET["id"]); | |
2645 | $access_level = sprintf("%d", $_GET["al"]); | |
2646 | ||
2647 | db_query($link, "UPDATE ttrss_users SET login = '$login', access_level = '$access_level' WHERE id = '$uid'"); | |
2648 | ||
2649 | } | |
2650 | } else if ($subop == "remove") { | |
2651 | ||
2652 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
2653 | ||
2654 | $ids = split(",", $_GET["ids"]); | |
2655 | ||
2656 | foreach ($ids as $id) { | |
2657 | db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]); | |
2658 | ||
2659 | } | |
2660 | } | |
2661 | } else if ($subop == "add") { | |
2662 | ||
2663 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
2664 | ||
b6b535ca | 2665 | $login = db_escape_string(trim($_GET["login"])); |
e6cb77a0 AD |
2666 | $tmp_user_pwd = make_password(8); |
2667 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
2668 | ||
2669 | db_query($link, "INSERT INTO ttrss_users (login,pwd_hash,access_level) | |
2670 | VALUES ('$login', '$pwd_hash', 0)"); | |
2671 | ||
2672 | ||
2673 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
2674 | login = '$login' AND pwd_hash = '$pwd_hash'"); | |
2675 | ||
2676 | if (db_num_rows($result) == 1) { | |
2677 | ||
2678 | $new_uid = db_fetch_result($result, 0, "id"); | |
2679 | ||
2680 | print "<div class=\"notice\">Added user <b>".$_GET["login"]. | |
2681 | "</b> with password <b>$tmp_user_pwd</b>.</div>"; | |
2682 | ||
2683 | initialize_user($link, $new_uid); | |
2684 | ||
2685 | } else { | |
2686 | ||
2687 | print "<div class=\"warning\">Error while adding user <b>". | |
2688 | $_GET["login"].".</b></div>"; | |
2689 | ||
2690 | } | |
2691 | } | |
2692 | } else if ($subop == "resetPass") { | |
2693 | ||
2694 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
2695 | ||
2696 | $uid = db_escape_string($_GET["id"]); | |
2697 | ||
2698 | $result = db_query($link, "SELECT login FROM ttrss_users WHERE id = '$uid'"); | |
2699 | ||
2700 | $login = db_fetch_result($result, 0, "login"); | |
2701 | $tmp_user_pwd = make_password(8); | |
2702 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
2703 | ||
2704 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash' | |
2705 | WHERE id = '$uid'"); | |
2706 | ||
2707 | print "<div class=\"notice\">Changed password of | |
2708 | user <b>$login</b> to <b>$tmp_user_pwd</b>.</div>"; | |
2709 | ||
2710 | } | |
2711 | } | |
2712 | ||
2c7070b5 AD |
2713 | print "<div class=\"prefGenericAddBox\"> |
2714 | <input id=\"uadd_box\" size=\"40\"> "; | |
e6cb77a0 | 2715 | |
2c7070b5 AD |
2716 | print"<input type=\"submit\" class=\"button\" |
2717 | onclick=\"javascript:addUser()\" value=\"Add user\"></div>"; | |
e6cb77a0 AD |
2718 | |
2719 | $result = db_query($link, "SELECT | |
fe99ab12 AD |
2720 | id,login,access_level, |
2721 | SUBSTRING(last_login,1,16) as last_login | |
e6cb77a0 AD |
2722 | FROM |
2723 | ttrss_users | |
2724 | ORDER by login"); | |
2725 | ||
2317ffaa | 2726 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
1a7572cb | 2727 | |
f4fe2cde AD |
2728 | print "<p><table width=\"100%\" cellspacing=\"0\" |
2729 | class=\"prefUserList\" id=\"prefUserList\">"; | |
e6cb77a0 | 2730 | |
35f3c923 AD |
2731 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
2732 | Select: | |
2733 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', | |
3055bc41 | 2734 | 'UMRR-', 'UMCHK-', true)\">All</a>, |
35f3c923 | 2735 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', |
3055bc41 | 2736 | 'UMRR-', 'UMCHK-', false)\">None</a> |
35f3c923 AD |
2737 | </td</tr>"; |
2738 | ||
e6cb77a0 | 2739 | print "<tr class=\"title\"> |
f6f32198 AD |
2740 | <td width=\"5%\">Select</td> |
2741 | <td width='30%'>Username</td> | |
2742 | <td width='30%'>Access Level</td> | |
2743 | <td width='30%'>Last login</td></tr>"; | |
e6cb77a0 AD |
2744 | |
2745 | $lnum = 0; | |
2746 | ||
2747 | while ($line = db_fetch_assoc($result)) { | |
2748 | ||
2749 | $class = ($lnum % 2) ? "even" : "odd"; | |
2750 | ||
2751 | $uid = $line["id"]; | |
2752 | $edit_uid = $_GET["id"]; | |
2753 | ||
2754 | if ($uid == $_SESSION["uid"] || ($subop == "edit" && $uid != $edit_uid)) { | |
2755 | $class .= "Grayed"; | |
53226edc AD |
2756 | $this_row_id = ""; |
2757 | } else { | |
2758 | $this_row_id = "id=\"UMRR-$uid\""; | |
2759 | } | |
2760 | ||
2761 | print "<tr class=\"$class\" $this_row_id>"; | |
e6cb77a0 AD |
2762 | |
2763 | $line["login"] = htmlspecialchars($line["login"]); | |
2764 | ||
2765 | if ($uid == $_SESSION["uid"]) { | |
2766 | ||
2767 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2768 | id=\"UMCHK-".$line["id"]."\"></td>"; | |
2769 | ||
2770 | print "<td>".$line["login"]."</td>"; | |
2771 | print "<td>".$line["access_level"]."</td>"; | |
e6cb77a0 AD |
2772 | |
2773 | } else if (!$edit_uid || $subop != "edit") { | |
2774 | ||
2775 | print "<td><input onclick='toggleSelectRow(this);' | |
1a7572cb | 2776 | type=\"checkbox\" id=\"UMCHK-$uid\"></td>"; |
e6cb77a0 AD |
2777 | |
2778 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
2779 | $line["login"] . "</td>"; | |
2780 | ||
2781 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
2782 | $line["access_level"] . "</td>"; | |
2783 | ||
2784 | } else if ($uid != $edit_uid) { | |
2785 | ||
2786 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2787 | id=\"UMCHK-".$line["id"]."\"></td>"; | |
2788 | ||
2789 | print "<td>".$line["login"]."</td>"; | |
2790 | print "<td>".$line["access_level"]."</td>"; | |
2791 | ||
2792 | } else { | |
2793 | ||
2794 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2795 | ||
2796 | print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"]. | |
2797 | "\"></td>"; | |
2798 | ||
2799 | print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"]. | |
2800 | "\"></td>"; | |
2801 | ||
2802 | } | |
2803 | ||
f6f32198 AD |
2804 | print "<td>".$line["last_login"]."</td>"; |
2805 | ||
e6cb77a0 AD |
2806 | print "</tr>"; |
2807 | ||
2808 | ++$lnum; | |
2809 | } | |
2810 | ||
2811 | print "</table>"; | |
2812 | ||
2813 | print "<p>"; | |
2814 | ||
2815 | if ($subop == "edit") { | |
2816 | print "Edit label: | |
2817 | <input type=\"submit\" class=\"button\" | |
2818 | onclick=\"javascript:userEditCancel()\" value=\"Cancel\"> | |
2819 | <input type=\"submit\" class=\"button\" | |
2820 | onclick=\"javascript:userEditSave()\" value=\"Save\">"; | |
2821 | ||
2822 | } else { | |
2823 | ||
2824 | print " | |
2825 | Selection: | |
2826 | <input type=\"submit\" class=\"button\" | |
717f5e64 | 2827 | onclick=\"javascript:selectedUserDetails()\" value=\"User details\"> |
e6cb77a0 AD |
2828 | <input type=\"submit\" class=\"button\" |
2829 | onclick=\"javascript:editSelectedUser()\" value=\"Edit\"> | |
2830 | <input type=\"submit\" class=\"button\" | |
717f5e64 AD |
2831 | onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\"> |
2832 | <input type=\"submit\" class=\"button\" | |
2833 | onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">"; | |
2834 | ||
2835 | } | |
2836 | } | |
2837 | ||
2838 | if ($op == "user-details") { | |
2839 | ||
2840 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { | |
2841 | return; | |
2842 | } | |
2843 | ||
1a7572cb | 2844 | /* print "<html><head> |
717f5e64 AD |
2845 | <title>Tiny Tiny RSS : User Details</title> |
2846 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
2847 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
1a7572cb | 2848 | </head><body>"; */ |
717f5e64 AD |
2849 | |
2850 | $uid = sprintf("%d", $_GET["id"]); | |
2851 | ||
c6c3a07f | 2852 | print "<div class='infoBoxContents'>"; |
717f5e64 | 2853 | |
fe99ab12 AD |
2854 | $result = db_query($link, "SELECT login, |
2855 | SUBSTRING(last_login,1,16) AS last_login, | |
2856 | access_level, | |
c6c3a07f AD |
2857 | (SELECT COUNT(int_id) FROM ttrss_user_entries |
2858 | WHERE owner_uid = id) AS stored_articles | |
717f5e64 AD |
2859 | FROM ttrss_users |
2860 | WHERE id = '$uid'"); | |
2861 | ||
2862 | if (db_num_rows($result) == 0) { | |
2863 | print "<h1>User not found</h1>"; | |
2864 | return; | |
2865 | } | |
2866 | ||
2867 | print "<h1>User Details</h1>"; | |
2868 | ||
2869 | print "<table width='100%'>"; | |
2870 | ||
2871 | $login = db_fetch_result($result, 0, "login"); | |
2872 | $last_login = db_fetch_result($result, 0, "last_login"); | |
2873 | $access_level = db_fetch_result($result, 0, "access_level"); | |
c6c3a07f | 2874 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); |
717f5e64 AD |
2875 | |
2876 | print "<tr><td>Username</td><td>$login</td></tr>"; | |
2877 | print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
2878 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
c6c3a07f | 2879 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; |
717f5e64 AD |
2880 | |
2881 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds | |
2882 | WHERE owner_uid = '$uid'"); | |
2883 | ||
2884 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
2885 | ||
2886 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; | |
2887 | ||
5d15d3ea | 2888 | /* $result = db_query($link, "SELECT |
717f5e64 | 2889 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size |
c6c3a07f AD |
2890 | FROM ttrss_user_entries,ttrss_entries |
2891 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
717f5e64 | 2892 | |
d9f115c3 | 2893 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
717f5e64 | 2894 | |
c6c3a07f | 2895 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ |
717f5e64 AD |
2896 | |
2897 | print "</table>"; | |
2898 | ||
2899 | print "<h1>Subscribed feeds</h1>"; | |
2900 | ||
2901 | $result = db_query($link, "SELECT id,title,feed_url FROM ttrss_feeds | |
d9f115c3 | 2902 | WHERE owner_uid = '$uid' ORDER BY title"); |
717f5e64 AD |
2903 | |
2904 | print "<ul class=\"nomarks\">"; | |
2905 | ||
2906 | while ($line = db_fetch_assoc($result)) { | |
2907 | ||
2908 | $icon_file = ICONS_URL."/".$line["id"].".ico"; | |
2909 | ||
2910 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
6c56687e | 2911 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; |
717f5e64 | 2912 | } else { |
5951ded1 | 2913 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
717f5e64 AD |
2914 | } |
2915 | ||
2916 | print "<li>$feed_icon <a href=\"".$line["feed_url"]."\">".$line["title"]."</a></li>"; | |
e6cb77a0 | 2917 | } |
717f5e64 AD |
2918 | |
2919 | print "</ul>"; | |
2920 | ||
717f5e64 AD |
2921 | print "</div>"; |
2922 | ||
1a7572cb AD |
2923 | print "<div align='center'> |
2924 | <input type='submit' class='button' | |
c6c3a07f | 2925 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; |
1a7572cb AD |
2926 | |
2927 | // print "</body></html>"; | |
717f5e64 | 2928 | |
e6cb77a0 AD |
2929 | } |
2930 | ||
c6c3a07f AD |
2931 | if ($op == "feed-details") { |
2932 | ||
2933 | $feed_id = $_GET["id"]; | |
2934 | ||
2935 | $result = db_query($link, | |
2936 | "SELECT | |
f324892e | 2937 | title,feed_url,last_updated,icon_url,site_url, |
c6c3a07f AD |
2938 | (SELECT COUNT(int_id) FROM ttrss_user_entries |
2939 | WHERE feed_id = id) AS total, | |
2940 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
2941 | WHERE feed_id = id AND unread = true) AS unread, | |
2942 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
2943 | WHERE feed_id = id AND marked = true) AS marked | |
2944 | FROM ttrss_feeds | |
2945 | WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]); | |
2946 | ||
2947 | if (db_num_rows($result) == 0) return; | |
2948 | ||
2949 | $title = db_fetch_result($result, 0, "title"); | |
2950 | $last_updated = db_fetch_result($result, 0, "last_updated"); | |
2951 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
4fec9fd7 | 2952 | $icon_url = db_fetch_result($result, 0, "icon_url"); |
c6c3a07f AD |
2953 | $total = db_fetch_result($result, 0, "total"); |
2954 | $unread = db_fetch_result($result, 0, "unread"); | |
2955 | $marked = db_fetch_result($result, 0, "marked"); | |
f324892e | 2956 | $site_url = db_fetch_result($result, 0, "site_url"); |
4fec9fd7 AD |
2957 | |
2958 | $result = db_query($link, "SELECT COUNT(id) AS subscribed | |
2959 | FROM ttrss_feeds WHERE feed_url = '$feed_url'"); | |
2960 | ||
2961 | $subscribed = db_fetch_result($result, 0, "subscribed"); | |
2962 | ||
2963 | print "<div class=\"infoBoxContents\">"; | |
2964 | ||
2965 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
2966 | ||
2967 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
2968 | $feed_icon = "<img width=\"16\" height=\"16\" | |
2969 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
2970 | } else { | |
2971 | $feed_icon = ""; | |
2972 | } | |
2973 | ||
2974 | print "<h1>$feed_icon $title</h1>"; | |
c6c3a07f AD |
2975 | |
2976 | print "<table width='100%'>"; | |
2977 | ||
f324892e AD |
2978 | if ($site_url) { |
2979 | print "<tr><td width='30%'>Link</td> | |
2980 | <td><a href=\"$site_url\">$site_url</a> | |
2981 | <a href=\"$feed_url\">(feed)</a></td> | |
2982 | </td></tr>"; | |
2983 | } else { | |
2984 | print "<tr><td width='30%'>Feed URL</td> | |
2985 | <td><a href=\"$feed_url\">$feed_url</a></td></tr>"; | |
2986 | } | |
c6c3a07f AD |
2987 | print "<tr><td>Last updated</td><td>$last_updated</td></tr>"; |
2988 | print "<tr><td>Total articles</td><td>$total</td></tr>"; | |
2989 | print "<tr><td>Unread articles</td><td>$unread</td></tr>"; | |
2990 | print "<tr><td>Starred articles</td><td>$marked</td></tr>"; | |
4fec9fd7 | 2991 | print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>"; |
c6c3a07f AD |
2992 | |
2993 | print "</table>"; | |
2994 | ||
bffdddd0 AD |
2995 | $result = db_query($link, "SELECT title, |
2996 | SUBSTRING(updated,1,16) AS updated,unread | |
bca02305 AD |
2997 | FROM ttrss_entries,ttrss_user_entries |
2998 | WHERE ref_id = id AND feed_id = '$feed_id' | |
c565e1ef | 2999 | ORDER BY date_entered DESC LIMIT 5"); |
c6c3a07f | 3000 | |
bca02305 AD |
3001 | if (db_num_rows($result) > 0) { |
3002 | ||
3003 | print "<h1>Latest headlines</h1>"; | |
c6c3a07f | 3004 | |
bca02305 AD |
3005 | print "<ul class=\"nomarks\">"; |
3006 | ||
3007 | while ($line = db_fetch_assoc($result)) { | |
c565e1ef AD |
3008 | if ($line["unread"] == "t" || $line["unread"] == "1") { |
3009 | $line["title"] = "<b>" . $line["title"] . "</b>"; | |
3010 | } | |
bca02305 AD |
3011 | print "<li>" . $line["title"]. |
3012 | " <span class=\"insensitive\">(" .$line["updated"].")</span></li>"; | |
3013 | } | |
3014 | ||
3015 | print "</ul>"; | |
3016 | ||
3017 | print "</div>"; | |
3018 | ||
3019 | print "<div align='center'> | |
3020 | <input type='submit' class='button' | |
3021 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
3022 | } | |
c6c3a07f AD |
3023 | } |
3024 | ||
4b3dff6e | 3025 | db_close($link); |
1cd17194 | 3026 | ?> |
406d9489 AD |
3027 | |
3028 | <!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> | |
3029 |