]> git.wh0rd.org - tt-rss.git/blame - backend.php
mobile: interface tweaks
[tt-rss.git] / backend.php
CommitLineData
1cd17194 1<?
36bfab86
AD
2 require_once "sessions.php";
3
59b8192f 4 header("Cache-Control: no-cache, must-revalidate");
ce0619bb
AD
5 header("Pragma: no-cache");
6 header("Expires: -1");
de696427 7
894ebcf5 8/* if ($_GET["debug"]) {
cce28758
AD
9 define('DEFAULT_ERROR_LEVEL', E_ALL);
10 } else {
11 define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
12 }
894ebcf5
AD
13
14 error_reporting(DEFAULT_ERROR_LEVEL); */
cce28758 15
262bd8ea
AD
16 $op = $_REQUEST["op"];
17
a2770077 18 if ((!$op || $op == "rpc" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
262bd8ea
AD
19 header("Content-Type: application/xml");
20 }
21
a2770077 22 if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") {
262bd8ea 23
a2770077 24 if ($op == "rpc") {
262bd8ea 25 print "<error error-code=\"6\"/>";
04269460
AD
26 } else {
27 print "
28 <html><body>
29 <p>Error: Not logged in.</p>
30 <script type=\"text/javascript\">
31 if (parent.window != 'undefined') {
32 parent.window.location = \"login.php\";
33 } else {
34 window.location = \"login.php\";
35 }
36 </script>
37 </body></html>
38 ";
262bd8ea
AD
39 }
40 exit;
41 }
1c7f75ed 42
a2770077
AD
43 if (!$op) {
44 print "<error error-code=\"7\"/>";
45 exit;
46 }
47
70f6dbb1 48 define('SCHEMA_VERSION', 7);
1cd17194 49
66581886 50 require_once "sanity_check.php";
82baad4a 51 require_once "config.php";
648472a7 52 require_once "db.php";
3bac89ad 53 require_once "db-prefs.php";
82baad4a
AD
54 require_once "functions.php";
55 require_once "magpierss/rss_fetch.inc";
1cd17194 56
ad815c71
AD
57 $purge_intervals = array(
58 0 => "Default",
59 -1 => "Never purge",
60 5 => "1 week",
61 14 => "2 weeks",
62 31 => "1 month",
63 60 => "2 months",
64 90 => "3 months");
65
66 $update_intervals = array(
67 0 => "Default",
68 -1 => "Disable updates",
69 30 => "30 minutes",
70 60 => "1 hour",
71 240 => "4 hours",
72 720 => "12 hours",
73 1440 => "Daily",
74 10080 => "Weekly");
75
406d9489
AD
76 $script_started = getmicrotime();
77
648472a7 78 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
d76a3b03 79
5136011e
AD
80 if (!$link) {
81 if (DB_TYPE == "mysql") {
82 print mysql_error();
83 }
84 // PG seems to display its own errors just fine by default.
85 return;
86 }
87
648472a7
AD
88 if (DB_TYPE == "pgsql") {
89 pg_query("set client_encoding = 'utf-8'");
90 }
7ec2a838 91
4053b540
AD
92 if ($_SESSION["uid"]) {
93 if (get_pref($link, "HIDE_READ_FEEDS") == "true") {
94 setcookie("ttrss_vf_hreadf", 1);
95 } else {
96 setcookie("ttrss_vf_hreadf", 0);
97 }
f5de0d8d
AD
98
99 setcookie('ttrss_vf_refresh', FEEDS_FRAME_REFRESH);
c6784aea 100 setcookie('ttrss_vf_daemon', ENABLE_UPDATE_DAEMON);
4053b540 101 }
7f123cda 102
331900c6 103 $fetch = $_GET["fetch"];
175847de 104
76b4eae1 105// setcookie("ttrss_icons_url", ICONS_URL);
b2804af7
AD
106
107 if (!sanity_check($link)) { return; }
023fe037 108
8143ae1f 109 function outputFeedList($link, $tags = false) {
175847de 110
1a66d16e
AD
111 print "<html><head>
112 <title>Tiny Tiny RSS : Feedlist</title>
430bf183
AD
113 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
114
503eb349
AD
115 $user_theme = $_SESSION["theme"];
116 if ($user_theme) {
117 print "<link rel=\"stylesheet\" type=\"text/css\"
118 href=\"themes/$user_theme/theme.css\">";
119 }
120
4769ddaf 121 if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
430bf183
AD
122 print "<link rel=\"stylesheet\" type=\"text/css\"
123 href=\"tt-rss_compact.css\"/>";
124 } else {
125 print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
126 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
127 }
128
129 print "<script type=\"text/javascript\" src=\"functions.js\"></script>
1a66d16e
AD
130 <script type=\"text/javascript\" src=\"feedlist.js\"></script>
131 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
beac550b
AD
132 <!--[if gte IE 5.5000]>
133 <script type=\"text/javascript\" src=\"pngfix.js\"></script>
2f52ca1b 134 <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\">
beac550b 135 <![endif]-->
97dcd654
AD
136 </head><body>
137 <script type=\"text/javascript\">
138 if (document.addEventListener) {
139 document.addEventListener(\"DOMContentLoaded\", init, null);
140 }
141 window.onload = init;
142 </script>";
254e0e4b 143
140ff9db 144 print "<ul class=\"feedList\" id=\"feedList\">\n";
254e0e4b 145
4356293a
AD
146 $owner_uid = $_SESSION["uid"];
147
8143ae1f 148 if (!$tags) {
254e0e4b 149
8143ae1f 150 /* virtual feeds */
254e0e4b 151
91ff844a 152 if (get_pref($link, 'ENABLE_FEED_CATS')) {
937881b5
AD
153 print "<li class=\"feedCat\">Special</li>";
154 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
91ff844a
AD
155 }
156
8143ae1f 157 $result = db_query($link, "SELECT count(id) as num_starred
4c193675
AD
158 FROM ttrss_entries,ttrss_user_entries
159 WHERE marked = true AND
160 ttrss_user_entries.ref_id = ttrss_entries.id AND
161 unread = true AND owner_uid = '$owner_uid'");
8143ae1f 162 $num_starred = db_fetch_result($result, 0, "num_starred");
254e0e4b 163
3745788e 164 $class = "virt";
8add756a
AD
165
166 if ($num_starred > 0) $class .= "Unread";
167
168 printFeedEntry(-1, $class, "Starred articles", $num_starred,
4668523d 169 "images/mark_set.png", $link);
48f0adb0 170
91ff844a 171 if (get_pref($link, 'ENABLE_FEED_CATS')) {
140ff9db 172 print "</ul>\n";
91ff844a
AD
173 }
174
cfaba6df 175 if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) {
8143ae1f
AD
176
177 $result = db_query($link, "SELECT id,sql_exp,description FROM
4356293a 178 ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
8143ae1f
AD
179
180 if (db_num_rows($result) > 0) {
91ff844a 181 if (get_pref($link, 'ENABLE_FEED_CATS')) {
937881b5
AD
182 print "<li class=\"feedCat\">Labels</li>";
183 print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
91ff844a 184 } else {
937881b5 185 print "<li><hr></li>";
91ff844a 186 }
8143ae1f
AD
187 }
188
189 while ($line = db_fetch_assoc($result)) {
48f0adb0 190
8143ae1f
AD
191 error_reporting (0);
192
280ee9a3
AD
193 $tmp_result = db_query($link, "SELECT count(id) as count
194 FROM ttrss_entries,ttrss_user_entries
4c193675
AD
195 WHERE (" . $line["sql_exp"] . ") AND unread = true AND
196 ttrss_user_entries.ref_id = ttrss_entries.id
655be073 197 AND owner_uid = '$owner_uid'");
8143ae1f
AD
198
199 $count = db_fetch_result($tmp_result, 0, "count");
200
3745788e 201 $class = "label";
8143ae1f
AD
202
203 if ($count > 0) {
204 $class .= "Unread";
205 }
206
cce28758 207 error_reporting (DEFAULT_ERROR_LEVEL);
8143ae1f
AD
208
209 printFeedEntry(-$line["id"]-11,
4668523d 210 $class, $line["description"], $count, "images/label.png", $link);
8143ae1f
AD
211
212 }
91ff844a
AD
213
214 if (db_num_rows($result) > 0) {
215 if (get_pref($link, 'ENABLE_FEED_CATS')) {
140ff9db 216 print "</ul>";
91ff844a
AD
217 }
218 }
219
220 }
221
222// if (!get_pref($link, 'ENABLE_FEED_CATS')) {
223 print "<li><hr></li>";
224// }
225
226 if (get_pref($link, 'ENABLE_FEED_CATS')) {
227 $order_by_qpart = "category,title";
228 } else {
229 $order_by_qpart = "title";
48f0adb0 230 }
8143ae1f 231
db42b934
AD
232 $result = db_query($link, "SELECT ttrss_feeds.*,
233 (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
4c193675
AD
234 WHERE feed_id = ttrss_feeds.id AND
235 ttrss_user_entries.ref_id = ttrss_entries.id AND
236 owner_uid = '$owner_uid') AS total,
db42b934 237 (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
b88917af 238 WHERE feed_id = ttrss_feeds.id AND unread = true
4c193675 239 AND ttrss_user_entries.ref_id = ttrss_entries.id
91ff844a 240 AND owner_uid = '$owner_uid') as unread,
023fe037 241 cat_id,last_error,
db42b934
AD
242 ttrss_feed_categories.title AS category,
243 ttrss_feed_categories.collapsed
244 FROM ttrss_feeds LEFT JOIN ttrss_feed_categories
245 ON (ttrss_feed_categories.id = cat_id)
246 WHERE
247 ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL
248 ORDER BY $order_by_qpart");
249
8143ae1f
AD
250 $actid = $_GET["actid"];
251
252 /* real feeds */
253
254 $lnum = 0;
255
256 $total_unread = 0;
91ff844a
AD
257
258 $category = "";
8143ae1f 259
48f0adb0 260 while ($line = db_fetch_assoc($result)) {
8143ae1f 261
69668465 262 $feed = db_unescape_string($line["title"]);
8143ae1f
AD
263 $feed_id = $line["id"];
264
265 $subop = $_GET["subop"];
266
267 $total = $line["total"];
268 $unread = $line["unread"];
91ff844a 269
9323147e
AD
270 $rtl_content = sql_bool_to_bool($line["rtl_content"]);
271
272 if ($rtl_content) {
273 $rtl_tag = "dir=\"RTL\"";
274 } else {
275 $rtl_tag = "";
276 }
277
db42b934
AD
278 $tmp_result = db_query($link,
279 "SELECT id,COUNT(unread) AS unread
280 FROM ttrss_feeds LEFT JOIN ttrss_user_entries
281 ON (ttrss_feeds.id = ttrss_user_entries.feed_id)
282 WHERE parent_feed = '$feed_id' AND unread = true
283 GROUP BY ttrss_feeds.id");
284
285 if (db_num_rows($tmp_result) > 0) {
286 while ($l = db_fetch_assoc($tmp_result)) {
287 $unread += $l["unread"];
288 }
289 }
290
fe14aeb8
AD
291 $cat_id = $line["cat_id"];
292
91ff844a
AD
293 $tmp_category = $line["category"];
294
295 if (!$tmp_category) {
296 $tmp_category = "Uncategorized";
297 }
8143ae1f
AD
298
299 // $class = ($lnum % 2) ? "even" : "odd";
023fe037
AD
300
301 if ($line["last_error"]) {
302 $class = "error";
303 } else {
304 $class = "feed";
305 }
8143ae1f
AD
306
307 if ($unread > 0) $class .= "Unread";
308
309 if ($actid == $feed_id) {
310 $class .= "Selected";
392d4563 311 }
48f0adb0 312
8143ae1f 313 $total_unread += $unread;
91ff844a
AD
314
315 if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
316
317 if ($category) {
140ff9db 318 print "</ul></li>";
91ff844a
AD
319 }
320
321 $category = $tmp_category;
fe14aeb8
AD
322
323 $collapsed = $line["collapsed"];
324
65f85814
AD
325 // workaround for NULL category
326 if ($category == "Uncategorized") {
327 if ($_COOKIE["ttrss_vf_uclps"] == 1) {
328 $collapsed = "t";
329 }
330 }
331
fe14aeb8
AD
332 if ($collapsed == "t" || $collapsed == "1") {
333 $holder_class = "invisible";
65f85814 334 $ellipsis = "...";
fe14aeb8
AD
335 } else {
336 $holder_class = "";
65f85814 337 $ellipsis = "";
280ee9a3
AD
338 }
339
340 if ($cat_id) {
341 $cat_id_qpart = "cat_id = '$cat_id'";
342 } else {
343 $cat_id_qpart = "cat_id IS NULL";
344 }
345
346 $tmp_result = db_query($link, "SELECT count(int_id) AS unread
347 FROM ttrss_user_entries,ttrss_feeds WHERE
348 unread = true AND
349 feed_id = ttrss_feeds.id AND $cat_id_qpart AND
350 ttrss_user_entries.owner_uid = " . $_SESSION["uid"]);
351
352 $cat_unread = db_fetch_result($tmp_result, 0, "unread");
353
354 $cat_id = sprintf("%d", $cat_id);
91ff844a 355
fe14aeb8 356 print "<li class=\"feedCat\" id=\"FCAT-$cat_id\">
ff2c6e6a 357 <a href=\"javascript:toggleCollapseCat($cat_id)\">$tmp_category</a>
99ff73f4 358 <a href=\"javascript:viewCategory($cat_id)\" id=\"FCAP-$cat_id\">
280ee9a3 359 <span id=\"FCATCTR-$cat_id\"
befc807f 360 class=\"$catctr_class\">($cat_unread unread)$ellipsis</span></a></li>";
c3f348c2
AD
361
362 // !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function
363 // -> keyboard navigation, etc.
96737ce9 364 print "<li id=\"feedCatHolder\" class=\"$holder_class\"><ul class=\"feedCatList\" id=\"FCATLIST-$cat_id\">";
91ff844a 365 }
8143ae1f 366
91ff844a 367 printFeedEntry($feed_id, $class, $feed, $unread,
9323147e 368 "icons/$feed_id.ico", $link, $rtl_content);
8143ae1f
AD
369
370 ++$lnum;
48f0adb0 371 }
91ff844a 372
8143ae1f 373 } else {
a1a8a2be 374
8143ae1f 375 // tags
a1a8a2be 376
987170e6 377/* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
05732aa0
AD
378 FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
379 post_int_id = ttrss_user_entries.int_id AND
380 unread = true AND ref_id = ttrss_entries.id
3b0948c4 381 AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name
8143ae1f 382 UNION
3b0948c4 383 select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid'
987170e6
AD
384 ORDER BY tag_name"); */
385
386 $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id)
387 FROM ttrss_user_entries WHERE int_id = post_int_id
388 AND unread = true)) AS count FROM ttrss_tags
389 WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name");
390
8143ae1f
AD
391 $tags = array();
392
393 while ($line = db_fetch_assoc($result)) {
394 $tags[$line["tag_name"]] += $line["count"];
1a66d16e 395 }
8143ae1f
AD
396
397 foreach (array_keys($tags) as $tag) {
398
399 $unread = $tags[$tag];
400
83957936 401 $class = "tag";
8143ae1f
AD
402
403 if ($unread > 0) {
404 $class .= "Unread";
405 }
406
4668523d 407 printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link);
8143ae1f
AD
408
409 }
1a66d16e 410
e828e31e 411 }
82baad4a 412
dc33ec95 413 if (db_num_rows($result) == 0) {
8037c618
AD
414 if ($tags) {
415 $what = "tags";
416 } else {
417 $what = "feeds";
418 }
419 print "<li>No $what to display.</li>";
dc33ec95
AD
420 }
421
8143ae1f 422 print "</ul>";
1cd17194 423
97dcd654
AD
424 print '
425 <script type="text/javascript">
426 /* for IE */
427 function statechange() {
428 if (document.readyState == "interactive") init();
429 }
430
431 if (document.readyState) {
432 if (document.readyState == "interactive" || document.readyState == "complete") {
433 init();
434 } else {
435 document.onreadystatechange = statechange;
436 }
437 }
438 </script></body></html>';
c3b81db0
AD
439 }
440
441
442 if ($op == "rpc") {
443
444 $subop = $_GET["subop"];
445
7f123cda
AD
446 if ($subop == "setpref") {
447 if (WEB_DEMO_MODE) {
448 return;
449 }
450
451 print "<rpc-reply>";
452
453 $key = db_escape_string($_GET["key"]);
454 $value = db_escape_string($_GET["value"]);
455
456 set_pref($link, $key, $value);
457
458 print "<param-set key=\"$key\" value=\"$value\"/>";
459
460 print "</rpc-reply>";
461
462 }
463
090e250b 464 if ($subop == "getLabelCounters") {
8073cce7 465 $aid = $_GET["aid"];
090e250b
AD
466 print "<rpc-reply>";
467 getLabelCounters($link);
8073cce7
AD
468 if ($aid) {
469 getFeedCounter($link, $aid);
470 }
090e250b
AD
471 print "</rpc-reply>";
472 }
473
474 if ($subop == "getFeedCounters") {
475 print "<rpc-reply>";
476 getFeedCounters($link);
477 print "</rpc-reply>";
478 }
479
480 if ($subop == "getAllCounters") {
481 print "<rpc-reply>";
1572afe5 482 getAllCounters($link);
090e250b 483 print "</rpc-reply>";
090e250b
AD
484 }
485
f4c10d44
AD
486 if ($subop == "mark") {
487 $mark = $_GET["mark"];
648472a7 488 $id = db_escape_string($_GET["id"]);
f4c10d44
AD
489
490 if ($mark == "1") {
491 $mark = "true";
492 } else {
493 $mark = "false";
494 }
495
b5137506
AD
496 // FIXME this needs collision testing
497
498 $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
499 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
f4c10d44
AD
500 }
501
caa4e57f 502 if ($subop == "updateFeed") {
648472a7 503 $feed_id = db_escape_string($_GET["feed"]);
9cfc649a 504
648472a7 505 $result = db_query($link,
a5873b2e
AD
506 "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'
507 AND owner_uid = " . $_SESSION["uid"]);
9cfc649a 508
648472a7
AD
509 if (db_num_rows($result) > 0) {
510 $feed_url = db_fetch_result($result, 0, "feed_url");
a5873b2e 511 update_rss_feed($link, $feed_url, $feed_id);
caa4e57f 512 }
9cfc649a 513
a5873b2e
AD
514 print "<rpc-reply>";
515 getFeedCounter($link, $feed_id);
516 print "</rpc-reply>";
517
caa4e57f 518 return;
9cfc649a
AD
519 }
520
090e250b 521 if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") {
9d1ef64e 522
085a5a74 523 if (ENABLE_UPDATE_DAEMON) {
c3b81db0 524
b8a6ff30 525 if ($subop == "forceUpdateAllFeeds") {
8b911251 526
b8a6ff30
AD
527 $result = db_query($link, "SELECT count(id) AS cid FROM
528 ttrss_scheduled_updates WHERE feed_id IS NULL AND
529 owner_uid = " . $_SESSION["uid"]);
530
531 $cid = db_fetch_result($result, 0, "cid");
532
533# print "<rpc-reply>";
534
535 if ($cid == 0) {
536
537 db_query($link, "INSERT INTO ttrss_scheduled_updates
538 (owner_uid, feed_id, entered) VALUES
539 (".$_SESSION["uid"].", NULL, NOW())");
540
36cf32bc 541// print "<!-- ScheduledOK -->";
8b911251 542
b8a6ff30 543 } else {
36cf32bc 544// print "<!-- RequestAlreadyInQueue -->";
b8a6ff30
AD
545 }
546
547# print "</rpc-reply>";
8b911251 548 }
1f4ad53c 549
cd907b7c 550 } else {
1f4ad53c
AD
551 update_all_feeds($link, $subop == "forceUpdateAllFeeds");
552 }
553
78ea1de0
AD
554 $global_unread_caller = sprintf("%d", $_GET["uctr"]);
555 $global_unread = getGlobalUnread($link);
cd907b7c 556
085a5a74 557 print "<rpc-reply>";
78ea1de0
AD
558
559 if ($global_unread_caller != $global_unread) {
560
561 $omode = $_GET["omode"];
562
2bf6e0a8 563 if (!$omode) $omode = "tflc";
78ea1de0
AD
564
565 if (strchr($omode, "l")) getLabelCounters($link);
566 if (strchr($omode, "f")) getFeedCounters($link);
567 if (strchr($omode, "t")) getTagCounters($link);
2bf6e0a8
AD
568 if (strchr($omode, "c")) {
569 if (get_pref($link, 'ENABLE_FEED_CATS')) {
570 getCategoryCounters($link);
571 }
572 }
601a5e04 573 }
e50d3212
AD
574
575 getGlobalCounters($link, $global_unread);
576
085a5a74
AD
577 print "</rpc-reply>";
578
c3b81db0 579 }
1572afe5
AD
580
581 /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
b018b49b 582 if ($subop == "catchupSelected") {
c3b81db0 583
f932bc9f 584 $ids = split(",", db_escape_string($_GET["ids"]));
c3b81db0 585
1572afe5 586 $cmode = sprintf("%d", $_GET["cmode"]);
c3b81db0 587
1572afe5 588 foreach ($ids as $id) {
c3b81db0 589
1572afe5
AD
590 if ($cmode == 0) {
591 db_query($link, "UPDATE ttrss_user_entries SET
592 unread = false,last_read = NOW()
593 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
594 } else if ($cmode == 1) {
595 db_query($link, "UPDATE ttrss_user_entries SET
596 unread = true
597 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
598 } else {
599 db_query($link, "UPDATE ttrss_user_entries SET
600 unread = NOT unread,last_read = NOW()
601 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
602 }
c3b81db0 603 }
1572afe5
AD
604 print "<rpc-reply>";
605 getAllCounters($link);
606 print "</rpc-reply>";
607 }
c3b81db0 608
1572afe5
AD
609 if ($subop == "markSelected") {
610
f932bc9f 611 $ids = split(",", db_escape_string($_GET["ids"]));
1572afe5
AD
612
613 $cmode = sprintf("%d", $_GET["cmode"]);
614
615 foreach ($ids as $id) {
616
617 if ($cmode == 0) {
618 db_query($link, "UPDATE ttrss_user_entries SET
619 marked = false
620 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
621 } else if ($cmode == 1) {
622 db_query($link, "UPDATE ttrss_user_entries SET
623 marked = true
624 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
625 } else {
626 db_query($link, "UPDATE ttrss_user_entries SET
627 marked = NOT marked
628 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
629 }
630 }
631 print "<rpc-reply>";
632 getAllCounters($link);
633 print "</rpc-reply>";
c3b81db0 634 }
295f9b42
AD
635
636 if ($subop == "sanityCheck") {
bc236938
AD
637 if (sanity_check($link)) {
638 print "<error error-code=\"0\"/>";
639 }
295f9b42 640 }
fefa6ca3
AD
641
642 if ($subop == "globalPurge") {
643
644 print "<rpc-reply>";
645 global_purge_old_posts($link, true);
646 print "</rpc-reply>";
647
648 }
649
c3b81db0
AD
650 }
651
652 if ($op == "feeds") {
653
8143ae1f
AD
654 $tags = $_GET["tags"];
655
c3b81db0
AD
656 $subop = $_GET["subop"];
657
658 if ($subop == "catchupAll") {
b018b49b 659 db_query($link, "UPDATE ttrss_user_entries SET
6d15e1ef 660 last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
c3b81db0
AD
661 }
662
fe14aeb8
AD
663 if ($subop == "collapse") {
664 $cat_id = db_escape_string($_GET["cid"]);
280ee9a3 665
fe14aeb8
AD
666 db_query($link, "UPDATE ttrss_feed_categories SET
667 collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " .
668 $_SESSION["uid"]);
669 return;
670 }
671
8143ae1f 672 outputFeedList($link, $tags);
c3b81db0 673
1cd17194
AD
674 }
675
676 if ($op == "view") {
677
70f6dbb1
AD
678 $id = db_escape_string($_GET["id"]);
679 $feed_id = db_escape_string($_GET["feed"]);
680
681 $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
682 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
683
684 if (db_num_rows($result) == 1) {
685 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
686 } else {
687 $rtl_content = false;
688 }
689
690 if ($rtl_content) {
691 $rtl_tag = "dir=\"RTL\"";
ed51e128 692 $rtl_class = "RTL";
70f6dbb1
AD
693 } else {
694 $rtl_tag = "";
ed51e128 695 $rtl_class = "";
70f6dbb1 696 }
d76a3b03 697
4c193675
AD
698 $result = db_query($link, "UPDATE ttrss_user_entries
699 SET unread = false,last_read = NOW()
700 WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
a1a8a2be 701
21703604 702 $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
9167e250 703 SUBSTRING(updated,1,16) as updated,
11b0dce2 704 (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
a545b564
AD
705 num_comments,
706 author
4c193675
AD
707 FROM ttrss_entries,ttrss_user_entries
708 WHERE id = '$id' AND ref_id = id");
1cd17194 709
59b8192f
AD
710 print "<html><head>
711 <title>Tiny Tiny RSS : Article $id</title>
712 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
503eb349 713
59b8192f
AD
714 $user_theme = $_SESSION["theme"];
715 if ($user_theme) {
716 print "<link rel=\"stylesheet\" type=\"text/css\"
717 href=\"themes/$user_theme/theme.css\">";
718 }
503eb349 719
59b8192f
AD
720 if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
721 print "<link rel=\"stylesheet\" type=\"text/css\"
722 href=\"tt-rss_compact.css\"/>";
723 } else {
724 print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
725 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
70830c87
AD
726 }
727
59b8192f
AD
728 print "<script type=\"text/javascript\" src=\"functions.js\"></script>
729 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
70f6dbb1 730 </head><body $rtl_tag>";
59b8192f 731
d76a3b03 732 if ($result) {
1cd17194 733
648472a7 734 $line = db_fetch_assoc($result);
1cd17194 735
b7f4bda2
AD
736 if ($line["icon_url"]) {
737 $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">";
738 } else {
739 $feed_icon = "&nbsp;";
740 }
d76a3b03 741
11b0dce2 742/* if ($line["comments"] && $line["link"] != $line["comments"]) {
f7181e9b
AD
743 $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
744 } else {
745 $entry_comments = "";
11b0dce2
AD
746 } */
747
748 $num_comments = $line["num_comments"];
749 $entry_comments = "";
750
751 if ($num_comments > 0) {
752 if ($line["comments"]) {
753 $comments_url = $line["comments"];
754 } else {
755 $comments_url = $line["link"];
756 }
6a1ad084 757 $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>";
11b0dce2
AD
758 } else {
759 if ($line["comments"] && $line["link"] != $line["comments"]) {
672366bd 760 $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>";
11b0dce2 761 }
f7181e9b
AD
762 }
763
e828e31e
AD
764 print "<div class=\"postReply\">";
765
21703604
AD
766 print "<div class=\"postHeader\"><table width=\"100%\">";
767
a545b564
AD
768 $entry_author = $line["author"];
769
770 if ($entry_author) {
771 $entry_author = " - by $entry_author";
772 }
773
774 print "<tr><td><a href=\"" . $line["link"] . "\">" . $line["title"] .
775 "</a>$entry_author</td>";
9167e250
AD
776
777 $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'),
778 strtotime($line["updated"]));
779
ed51e128 780 print "<td class=\"postDate$rtl_class\">$parsed_updated</td>";
9167e250
AD
781
782 print "</tr>";
21703604
AD
783
784 $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM
785 ttrss_tags WHERE post_int_id = " . $line["int_id"] . "
786 ORDER BY tag_name");
787
788 $tags_str = "";
42918a07
AD
789 $f_tags_str = "";
790
791 $num_tags = 0;
21703604
AD
792
793 while ($tmp_line = db_fetch_assoc($tmp_result)) {
42918a07
AD
794 $num_tags++;
795 $tag = $tmp_line["tag_name"];
796 $tag_str = "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, ";
797
798 if ($num_tags == 5) {
799 $tags_str .= "<a href=\"javascript:showBlockElement('allEntryTags')\">...</a>";
800 } else if ($num_tags < 5) {
801 $tags_str .= $tag_str;
802 }
803 $f_tags_str .= $tag_str;
804 }
21703604 805
42918a07
AD
806 $tags_str = preg_replace("/, $/", "", $tags_str);
807 $f_tags_str = preg_replace("/, $/", "", $f_tags_str);
e828e31e 808
6a1ad084 809// $truncated_link = truncate_string($line["link"], 60);
21703604 810
6a1ad084
AD
811 if ($tags_str || $entry_comments) {
812 print "<tr><td width='50%'>
813 $entry_comments</td>
814 <td align=\"right\">$tags_str</td></tr>";
815 }
21703604 816
e828e31e
AD
817 print "</table></div>";
818
819 print "<div class=\"postIcon\">" . $feed_icon . "</div>";
42918a07
AD
820 print "<div class=\"postContent\">";
821
822 if (db_num_rows($tmp_result) > 5) {
823 print "<div id=\"allEntryTags\">Tags: $f_tags_str</div>";
824 }
825
68511f86
AD
826 if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
827 $line["content"] = preg_replace("/href=/i", "target=\"_new\" href=", $line["content"]);
828 }
829
42918a07 830 print $line["content"] . "</div>";
e828e31e
AD
831
832 print "</div>";
833
090e250b 834 print "<script type=\"text/javascript\">
4f3a84f4 835 update_all_counters('$feed_id');
090e250b 836 </script>";
d76a3b03 837 }
70830c87 838
59b8192f 839 print "</body></html>";
1cd17194
AD
840 }
841
842 if ($op == "viewfeed") {
843
3c81ae1a
AD
844 $feed = db_escape_string($_GET["feed"]);
845 $skip = db_escape_string($_GET["skip"]);
846 $subop = db_escape_string($_GET["subop"]);
847 $view_mode = db_escape_string($_GET["view"]);
848 $limit = db_escape_string($_GET["limit"]);
849 $cat_view = db_escape_string($_GET["cat"]);
a1a8a2be 850
ac53063a
AD
851 if (!$skip) $skip = 0;
852
476cac42 853 if ($subop == "undefined") $subop = "";
1cd17194 854
59b8192f
AD
855 print "<html><head>
856 <title>Tiny Tiny RSS : Feed $feed</title>
857 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">";
503eb349 858
59b8192f
AD
859 $user_theme = $_SESSION["theme"];
860 if ($user_theme) {
861 print "<link rel=\"stylesheet\" type=\"text/css\"
862 href=\"themes/$user_theme/theme.css\">";
863 }
430bf183 864
59b8192f
AD
865 if (get_pref($link, 'USE_COMPACT_STYLESHEET')) {
866 print "<link rel=\"stylesheet\"
867 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
503eb349 868
59b8192f
AD
869 } else {
870 print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\"
871 type=\"text/css\" href=\"tt-rss_compact.css\"/>";
f0601b87
AD
872 }
873
2e915ba9
AD
874 if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
875
876 $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
877 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
70f6dbb1 878
2e915ba9
AD
879 if (db_num_rows($result) == 1) {
880 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
881 } else {
882 $rtl_content = false;
883 }
884
885 if ($rtl_content) {
886 $rtl_tag = "dir=\"RTL\"";
887 } else {
888 $rtl_tag = "";
889 }
70f6dbb1
AD
890 } else {
891 $rtl_tag = "";
2e915ba9 892 $rtl_content = false;
70f6dbb1
AD
893 }
894
59b8192f
AD
895 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
896 <script type=\"text/javascript\" src=\"functions.js\"></script>
897 <script type=\"text/javascript\" src=\"viewfeed.js\"></script>
898 <!--[if gte IE 5.5000]>
899 <script type=\"text/javascript\" src=\"pngfix.js\"></script>
900 <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\">
901 <![endif]-->
10031c3b 902 </head><body $rtl_tag>
59b8192f
AD
903 <script type=\"text/javascript\">
904 if (document.addEventListener) {
905 document.addEventListener(\"DOMContentLoaded\", init, null);
906 }
907 window.onload = init;
908 </script>";
909
7a232fc6 910 if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
23aa0d16 911 update_generic_feed($link, $feed, $cat_view);
dcee8f61
AD
912 }
913
0e32076b 914 if ($subop == "MarkAllRead") {
23aa0d16 915 catchup_feed($link, $feed, $cat_view);
a1a8a2be 916 }
d76a3b03 917
f932bc9f
AD
918 $search = db_escape_string($_GET["search"]);
919 $search_mode = db_escape_string($_GET["smode"]);
52b51244 920
f175937c 921 if ($search) {
8e84993b
AD
922 $search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%')
923 OR ttrss_entries.content LIKE '%$search%') AND";
f175937c
AD
924 } else {
925 $search_query_part = "";
926 }
927
928 $view_query_part = "";
929
0ee2d12f 930 if ($view_mode == "Adaptive") {
f18d0d94
AD
931 if ($search) {
932 $view_query_part = " ";
933 } else if ($feed != -1) {
0ee2d12f
AD
934 $unread = getFeedUnread($link, $feed);
935 if ($unread > 0) {
936 $view_query_part = " unread = true AND ";
937 }
938 }
939 }
940
f175937c
AD
941 if ($view_mode == "Starred") {
942 $view_query_part = " marked = true AND ";
ac53063a
AD
943 }
944
ac43eba1
AD
945 if ($view_mode == "Unread") {
946 $view_query_part = " unread = true AND ";
947 }
948
8d7008c7 949 if ($limit && $limit != "All") {
82c9223c 950 $limit_query_part = "LIMIT " . $limit;
ad3cb710 951 }
f0601b87 952
254e0e4b
AD
953 $vfeed_query_part = "";
954
52b51244 955 // override query strategy and enable feed display when searching globally
d3416913 956 if ($search && $search_mode == "All feeds") {
8e84993b 957 $query_strategy_part = "ttrss_entries.id > 0";
b0005823 958 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
d0bb308e 959 } else if (preg_match("/^-?[0-9][0-9]*$/", $feed) == false) {
8143ae1f
AD
960 $query_strategy_part = "ttrss_entries.id > 0";
961 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
962 id = feed_id) as feed_title,";
b0005823
AD
963 } else if ($feed >= 0 && $search && $search_mode == "This category") {
964
965 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
966
967 $tmp_result = db_query($link, "SELECT id
968 FROM ttrss_feeds WHERE cat_id =
969 (SELECT cat_id FROM ttrss_feeds WHERE id = '$feed') AND id != '$feed'");
970
971 $cat_siblings = array();
972
973 if (db_num_rows($tmp_result) > 0) {
974 while ($p = db_fetch_assoc($tmp_result)) {
975 array_push($cat_siblings, "feed_id = " . $p["id"]);
976 }
977
978 $query_strategy_part = sprintf("(feed_id = %d OR %s)",
979 $feed, implode(" OR ", $cat_siblings));
980
981 } else {
982 $query_strategy_part = "ttrss_entries.id > 0";
983 }
ff2c6e6a 984
8143ae1f 985 } else if ($feed >= 0) {
60103089 986
ff2c6e6a 987 if ($cat_view) {
b0005823 988
99ff73f4
AD
989 if ($feed > 0) {
990 $query_strategy_part = "cat_id = '$feed'";
991 } else {
992 $query_strategy_part = "cat_id IS NULL";
993 }
994
60103089 995 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
ff2c6e6a
AD
996
997 } else {
998 $tmp_result = db_query($link, "SELECT id
999 FROM ttrss_feeds WHERE parent_feed = '$feed'
1000 ORDER BY cat_id,title");
1001
1002 $parent_ids = array();
1003
1004 if (db_num_rows($tmp_result) > 0) {
1005 while ($p = db_fetch_assoc($tmp_result)) {
1006 array_push($parent_ids, "feed_id = " . $p["id"]);
1007 }
1008
1009 $query_strategy_part = sprintf("(feed_id = %d OR %s)",
1010 $feed, implode(" OR ", $parent_ids));
1011
1012 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1013 } else {
1014 $query_strategy_part = "feed_id = '$feed'";
1015 }
60103089 1016 }
48f0adb0 1017 } else if ($feed == -1) { // starred virtual feed
254e0e4b 1018 $query_strategy_part = "marked = true";
60103089 1019 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
48f0adb0
AD
1020 } else if ($feed <= -10) { // labels
1021 $label_id = -$feed - 11;
1022
1023 $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
1024 WHERE id = '$label_id'");
1025
1026 $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp");
1027
60103089 1028 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
254e0e4b 1029 } else {
48f0adb0 1030 $query_strategy_part = "id > 0"; // dumb
254e0e4b
AD
1031 }
1032
f99321a3
AD
1033 $order_by = "updated DESC";
1034
1035// if ($feed < -10) {
1036// $order_by = "feed_id,updated DESC";
1037// }
1038
1572afe5
AD
1039 $feed_title = "";
1040
1041 if ($search && $search_mode == "All feeds") {
49b7cbd3 1042 $feed_title = "Global search results ($search)";
d0bb308e 1043 } else if ($search && preg_match('/^-?[0-9][0-9]*$/', $feed) == false) {
49b7cbd3 1044 $feed_title = "Feed search results ($search, $feed)";
d0bb308e
AD
1045 } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) == false) {
1046 $feed_title = $feed;
1047 } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) != false && $feed >= 0) {
1572afe5 1048
ff2c6e6a 1049 if ($cat_view) {
ff2c6e6a 1050
019ce9f3
AD
1051 if ($feed != 0) {
1052 $result = db_query($link, "SELECT title FROM ttrss_feed_categories
1053 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
1054 $feed_title = db_fetch_result($result, 0, "title");
1055 } else {
1056 $feed_title = "Uncategorized";
1057 }
ff2c6e6a
AD
1058 } else {
1059
1060 $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds
1061 WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
1062
1063 $feed_title = db_fetch_result($result, 0, "title");
1064 $feed_site_url = db_fetch_result($result, 0, "site_url");
1065 $last_error = db_fetch_result($result, 0, "last_error");
1066
1067 }
1572afe5
AD
1068
1069 } else if ($feed == -1) {
1070 $feed_title = "Starred articles";
1071 } else if ($feed < -10) {
1072 $label_id = -$feed - 11;
1073 $result = db_query($link, "SELECT description FROM ttrss_labels
1074 WHERE id = '$label_id'");
1075 $feed_title = db_fetch_result($result, 0, "description");
1076 } else {
1077 $feed_title = "?";
1078 }
1079
48f0adb0
AD
1080 if ($feed < -10) error_reporting (0);
1081
386cbf27
AD
1082 print "<div id=\"headlinesContainer\">";
1083
d0bb308e 1084 if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
8143ae1f 1085
99ff73f4 1086 if ($feed >= 0) {
21703604
AD
1087 $feed_kind = "Feeds";
1088 } else {
1089 $feed_kind = "Labels";
1090 }
1091
386cbf27
AD
1092// if (!$vfeed_query_part) {
1093 $content_query_part = "content as content_preview,";
1094// } else {
1095// $content_query_part = "";
1096// }
bd34c528 1097
894ebcf5 1098 $query = "SELECT
60103089 1099 ttrss_entries.id,ttrss_entries.title,
1572afe5
AD
1100 SUBSTRING(updated,1,16) as updated,
1101 unread,feed_id,marked,link,last_read,
8143ae1f
AD
1102 SUBSTRING(last_read,1,19) as last_read_noms,
1103 $vfeed_query_part
bd34c528
AD
1104 $content_query_part
1105 SUBSTRING(updated,1,19) as updated_noms
8143ae1f 1106 FROM
60103089 1107 ttrss_entries,ttrss_user_entries,ttrss_feeds
8143ae1f 1108 WHERE
60103089 1109 ttrss_user_entries.feed_id = ttrss_feeds.id AND
4c193675 1110 ttrss_user_entries.ref_id = ttrss_entries.id AND
60103089 1111 ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND
8143ae1f
AD
1112 $search_query_part
1113 $view_query_part
1114 $query_strategy_part ORDER BY $order_by
894ebcf5
AD
1115 $limit_query_part";
1116
1117 $result = db_query($link, $query);
1118
1119 if ($_GET["debug"]) print $query;
8143ae1f
AD
1120
1121 } else {
1122 // browsing by tag
1123
21703604
AD
1124 $feed_kind = "Tags";
1125
8143ae1f 1126 $result = db_query($link, "SELECT
1572afe5
AD
1127 ttrss_entries.id as id,title,
1128 SUBSTRING(updated,1,16) as updated,
1129 unread,feed_id,
1e471f3b 1130 marked,link,last_read,
c05a19f3 1131 SUBSTRING(last_read,1,19) as last_read_noms,
254e0e4b 1132 $vfeed_query_part
bd34c528
AD
1133 $content_query_part
1134 SUBSTRING(updated,1,19) as updated_noms
8143ae1f 1135 FROM
05732aa0 1136 ttrss_entries,ttrss_user_entries,ttrss_tags
8143ae1f 1137 WHERE
05732aa0
AD
1138 ref_id = ttrss_entries.id AND
1139 ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND
1140 post_int_id = int_id AND tag_name = '$feed' AND
8143ae1f
AD
1141 $view_query_part
1142 $search_query_part
1143 $query_strategy_part ORDER BY $order_by
1144 $limit_query_part");
1145 }
d76a3b03 1146
48f0adb0 1147 if (!$result) {
386cbf27
AD
1148 print "<div align='center'>
1149 Could not display feed (query failed). Please check label match syntax or local configuration.</div>";
1150 return;
adccd201 1151 }
98bea1b1 1152
e0a7121b 1153 function print_headline_subtoolbar($link, $feed_site_url, $feed_title,
c1c9df00 1154 $bottom = false, $rtl_content = false) {
f56ec297 1155
e0a7121b
AD
1156 if (!$bottom) {
1157 $class = "headlinesSubToolbar";
1158 $tid = "headlineActionsTop";
1159 } else {
1160 $class = "invisible";
1161 $tid = "headlineActionsBottom";
1162 }
1163
1164 print "<table class=\"$class\" id=\"$tid\"
386cbf27
AD
1165 width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
1166
c1c9df00
AD
1167 if ($rtl_content) {
1168 $rtl_cpart = "RTL";
1169 } else {
1170 $rtl_cpart = "";
1171 }
1172
386cbf27 1173 if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
adccd201 1174
c1c9df00 1175 print "<td class=\"headlineActions$rtl_cpart\">
adccd201 1176 Select:
e7811ea5
AD
1177 <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, '', true)\">All</a>,
1178 <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true)\">Unread</a>,
1179 <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false)\">None</a>
386cbf27 1180 &nbsp;&nbsp;
e7811ea5
AD
1181 Toggle: <a href='#' onclick=\"javascript:selectionToggleUnread()\">Unread</a>,
1182 <a href='#' onclick=\"javascript:selectionToggleMarked()\">Starred</a>";
adccd201 1183 print "</td>";
386cbf27
AD
1184
1185 } else {
1186
c1c9df00 1187 print "<td class=\"headlineActions$rtl_cpart\">
386cbf27 1188 Select:
e7811ea5
AD
1189 <a href=\"#\" onclick=\"javascript:cdmSelectArticles('all')\">All</a>,
1190 <a href=\"#\" onclick=\"javascript:cdmSelectArticles('unread')\">Unread</a>,
1191 <a href=\"#\" onclick=\"javascript:cdmSelectArticles('none')\">None</a>
386cbf27 1192 &nbsp;&nbsp;
e7811ea5
AD
1193 Toggle: <a href=\"#\" onclick=\"javascript:selectionToggleUnread(true)\">Unread</a>,
1194 <a href=\"#\" onclick=\"javascript:selectionToggleMarked(true)\">Starred</a>";
386cbf27 1195
adccd201 1196 print "</td>";
386cbf27 1197
386cbf27
AD
1198 }
1199
c1c9df00 1200 print "<td class=\"headlineTitle$rtl_cpart\">";
adccd201 1201
386cbf27 1202 if ($feed_site_url) {
c7a8abe6
AD
1203 if (!$bottom) {
1204 $target = "target=\"_blank\"";
1205 }
1206 print "<a $target href=\"$feed_site_url\">$feed_title</a>";
386cbf27
AD
1207 } else {
1208 print $feed_title;
1209 }
1210
1211 print "</td>";
1212 print "</tr></table>";
1213
98bea1b1
AD
1214 }
1215
1216 if (db_num_rows($result) > 0) {
1217
c1c9df00
AD
1218 print_headline_subtoolbar($link, $feed_site_url, $feed_title, false,
1219 $rtl_content);
98bea1b1 1220
386cbf27 1221 if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
adccd201 1222 print "<table class=\"headlinesList\" id=\"headlinesList\"
10031c3b 1223 cellspacing=\"0\" width=\"100%\">";
f4c10d44 1224 }
386cbf27 1225
e5a99b88
AD
1226 $lnum = 0;
1227
1228 error_reporting (DEFAULT_ERROR_LEVEL);
1229
1230 $num_unread = 0;
1231
1232 while ($line = db_fetch_assoc($result)) {
adccd201 1233
e5a99b88
AD
1234 $class = ($lnum % 2) ? "even" : "odd";
1235
1236 $id = $line["id"];
1237 $feed_id = $line["feed_id"];
1238
1239 if ($line["last_read"] == "" &&
1240 ($line["unread"] != "t" && $line["unread"] != "1")) {
1241
1242 $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\"
1243 alt=\"Updated\">";
1244 } else {
1245 $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\"
1246 alt=\"Updated\">";
1247 }
1248
1249 if ($line["unread"] == "t" || $line["unread"] == "1") {
1250 $class .= "Unread";
1251 ++$num_unread;
386cbf27 1252 $is_unread = true;
adccd201 1253 } else {
386cbf27 1254 $is_unread = false;
e5a99b88
AD
1255 }
1256
1257 if ($line["marked"] == "t" || $line["marked"] == "1") {
1258 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
9932fb06 1259 alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>";
e5a99b88
AD
1260 } else {
1261 $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\"
9932fb06 1262 alt=\"Set mark\" onclick='javascript:toggleMark($id)'>";
e5a99b88
AD
1263 }
1264
e454a889 1265 $content_link = "<a href=\"javascript:view($id,$feed_id);\">" .
e5a99b88 1266 $line["title"] . "</a>";
adccd201 1267
e5a99b88
AD
1268 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1269 $updated_fmt = smart_date_time(strtotime($line["updated"]));
1270 } else {
1271 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1272 $updated_fmt = date($short_date, strtotime($line["updated"]));
1273 }
adccd201
AD
1274
1275 if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
8fd0c717 1276 $content_preview = truncate_string(strip_tags($line["content_preview"]),
070d0d2a 1277 100);
adccd201
AD
1278 }
1279
386cbf27 1280 if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
adccd201
AD
1281
1282 print "<tr class='$class' id='RROW-$id'>";
adccd201
AD
1283
1284 print "<td class='hlUpdatePic'>$update_pic</td>";
1285
1286 print "<td class='hlSelectRow'>
1287 <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\"
1288 class=\"feedCheckBox\" id=\"RCHK-$id\">
1289 </td>";
1290
1291 print "<td class='hlMarkedPic'>$marked_pic</td>";
1292
1293 if ($line["feed_title"]) {
1294 print "<td class='hlContent'>$content_link</td>";
1295 print "<td class='hlFeed'>
9b1424fe
AD
1296 <a href='javascript:viewfeed($feed_id)'>".
1297 $line["feed_title"]."</a>&nbsp;</td>";
adccd201 1298 } else {
de244d27 1299 print "<td class='hlContent' valign='middle'>";
adccd201 1300
e454a889 1301 print "<a href=\"javascript:view($id,$feed_id);\">" .
adccd201
AD
1302 $line["title"];
1303
70f6dbb1 1304 if (get_pref($link, 'SHOW_CONTENT_PREVIEW') && !$rtl_tag) {
adccd201
AD
1305 if ($content_preview) {
1306 print "<span class=\"contentPreview\"> - $content_preview</span>";
1307 }
1308 }
1309
1310 print "</a>";
1311 print "</td>";
1312 }
1313
1314 print "<td class=\"hlUpdated\"><nobr>$updated_fmt&nbsp;</nobr></td>";
1315
1316 print "</tr>";
1317
1318 } else {
386cbf27
AD
1319
1320 if ($is_unread) {
1321 $add_class = "Unread";
1322 } else {
1323 $add_class = "";
1324 }
1325
1326 print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">";
1327
1328 print "<div class=\"cdmHeader\">";
adccd201 1329
386cbf27
AD
1330 print "<div style=\"float : right\">$updated_fmt</div>";
1331
86383df6 1332 print "<a target=\"new\" href=\"".$line["link"]."\">".$line["title"]."</a>";
adccd201 1333
386cbf27
AD
1334 if ($line["feed_title"]) {
1335 print "&nbsp;(<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)";
adccd201 1336 }
adccd201 1337
386cbf27
AD
1338 print "</div>";
1339
1340 print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div>";
1341
1342 print "<div style=\"float : right\">$marked_pic</div>
1343 <div class=\"cdmFooter\">
1344 <input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
1345 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"></div>";
1346
1347 print "</div>";
1348
1349 }
e5a99b88
AD
1350
1351 ++$lnum;
254e0e4b 1352 }
adccd201 1353
386cbf27 1354 if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) {
adccd201 1355 print "</table>";
adccd201 1356 }
d76a3b03 1357
e0a7121b 1358 print_headline_subtoolbar($link,
f90372c4 1359 "javascript:catchupPage()", "Mark page as read", true, $rtl_content);
98bea1b1
AD
1360
1361
e5a99b88
AD
1362 } else {
1363 print "<div width='100%' align='center'>No articles found.</div>";
a1a8a2be 1364 }
d76a3b03 1365
386cbf27 1366 print "</div>";
d76a3b03 1367
386cbf27
AD
1368 print "<script type=\"text/javascript\">
1369 document.onkeydown = hotkey_handler;
5a494a0b 1370 // if (parent.daemon_enabled) parent.updateTitle('$feed_title');
386cbf27
AD
1371 update_all_counters('$feed');
1372 </script>";
adccd201 1373
97dcd654
AD
1374 print '
1375 <script type="text/javascript">
1376 /* for IE */
1377 function statechange() {
1378 if (document.readyState == "interactive") init();
1379 }
1380
1381 if (document.readyState) {
1382 if (document.readyState == "interactive" || document.readyState == "complete") {
1383 init();
1384 } else {
1385 document.onreadystatechange = statechange;
1386 }
1387 }
1388 </script>';
1389
59b8192f 1390 print "</body></html>";
1cd17194
AD
1391 }
1392
0e091d38 1393 if ($op == "pref-rpc") {
331900c6 1394
0e091d38 1395 $subop = $_GET["subop"];
331900c6 1396
83fe4d6d 1397 if ($subop == "unread") {
f932bc9f 1398 $ids = split(",", db_escape_string($_GET["ids"]));
83fe4d6d 1399 foreach ($ids as $id) {
a5873b2e
AD
1400 db_query($link, "UPDATE ttrss_user_entries SET unread = true
1401 WHERE feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]);
83fe4d6d 1402 }
0e091d38 1403
a5873b2e 1404 print "Marked selected feeds as unread.";
83fe4d6d
AD
1405 }
1406
1407 if ($subop == "read") {
f932bc9f 1408 $ids = split(",", db_escape_string($_GET["ids"]));
83fe4d6d 1409 foreach ($ids as $id) {
a5873b2e
AD
1410 db_query($link, "UPDATE ttrss_user_entries
1411 SET unread = false,last_read = NOW() WHERE
1412 feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]);
83fe4d6d 1413 }
0e091d38 1414
a5873b2e 1415 print "Marked selected feeds as read.";
0e091d38
AD
1416
1417 }
1418
1419 }
1420
1421 if ($op == "pref-feeds") {
1422
47c6c988
AD
1423 $subop = $_REQUEST["subop"];
1424 $quiet = $_REQUEST["quiet"];
0e091d38 1425
a0476535
AD
1426 if ($subop == "massSubscribe") {
1427 $ids = split(",", db_escape_string($_GET["ids"]));
1428
a7f22b70
AD
1429 $subscribed = array();
1430
a0476535
AD
1431 foreach ($ids as $id) {
1432 $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds
1433 WHERE id = '$id'");
1434
1435 $feed_url = db_fetch_result($result, 0, "feed_url");
1436 $title = db_fetch_result($result, 0, "title");
1437
1438 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
1439 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
1440
1441 if (db_num_rows($result) == 0) {
1442 $result = db_query($link,
1443 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
1444 VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
a7f22b70
AD
1445
1446 array_push($subscribed, $title);
1447 }
1448 }
1449
1450 if (count($subscribed) > 0) {
1451 print "<div class=\"notice\">";
1452 print "<b>Subscribed to feeds:</b>";
1453 print "<ul class=\"nomarks\">";
1454 foreach ($subscribed as $title) {
1455 print "<li>$title</li>";
a0476535 1456 }
a7f22b70
AD
1457 print "</ul>";
1458 print "</div>";
a0476535
AD
1459 }
1460 }
1461
f9cb39ac 1462 if ($subop == "browse") {
e2f728be
AD
1463
1464 if (!ENABLE_FEED_BROWSER) {
1465 print "Feed browser is administratively disabled.";
1466 return;
1467 }
f9cb39ac
AD
1468
1469 print "<div class=\"infoBoxContents\">";
1470
1471 print "<h1>Feed browser</h1>";
1472
1473 print "<p>Showing top 50 registered feeds, sorted by popularity:</p>";
1474
1475 $result = db_query($link, "SELECT feed_url,count(id) AS subscribers
e3c99f3b
AD
1476 FROM ttrss_feeds
1477 WHERE auth_login = '' AND auth_pass = '' AND private = false
24b18114 1478 GROUP BY feed_url ORDER BY subscribers DESC LIMIT 50");
f9cb39ac
AD
1479
1480 print "<ul class='browseFeedList' id='browseFeedList'>";
dc932d0a
AD
1481
1482 $feedctr = 0;
f9cb39ac
AD
1483
1484 while ($line = db_fetch_assoc($result)) {
1485 $feed_url = $line["feed_url"];
1486 $subscribers = $line["subscribers"];
dc932d0a
AD
1487
1488 $sub_result = db_query($link, "SELECT id
1489 FROM ttrss_feeds WHERE feed_url = '$feed_url' AND owner_uid =" .
1490 $_SESSION["uid"]);
1491
1492 if (db_num_rows($sub_result) > 0) {
1493 continue; // already subscribed
1494 }
f9cb39ac
AD
1495
1496 $det_result = db_query($link, "SELECT site_url,title,id
1497 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
1498
1499 $details = db_fetch_assoc($det_result);
1500
1501 $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
1502
1503 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1504 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
1505 "/".$details["id"].".ico\">";
1506 } else {
1507 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1508 }
1509
b92e6209
AD
1510 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1511 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
f9cb39ac 1512
b92e6209
AD
1513 $class = ($feedctr % 2) ? "even" : "odd";
1514
1515 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
1516 "$feed_icon " . db_unescape_string($details["title"]) .
f9cb39ac 1517 "&nbsp;<span class='subscribers'>($subscribers)</span></li>";
dc932d0a
AD
1518
1519 ++$feedctr;
1520 }
1521
1522 if ($feedctr == 0) {
1523 print "<li>No feeds found to subscribe.</li>";
1524 }
f9cb39ac
AD
1525
1526 print "</ul>";
1527
1528 print "<div align='center'>
f9cb39ac 1529 <input type=\"submit\" class=\"button\"
d10fabe4
AD
1530 onclick=\"feedBrowserSubscribe()\" value=\"Subscribe\">
1531 <input type='submit' class='button'
1532 onclick=\"closeInfoBox()\" value=\"Cancel\"></div>";
f9cb39ac
AD
1533
1534 print "</div>";
1535 return;
1536 }
1537
0ea4fb50
AD
1538 if ($subop == "editfeed") {
1539 $feed_id = db_escape_string($_GET["id"]);
1540
1541 $result = db_query($link,
1542 "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
1543 owner_uid = " . $_SESSION["uid"]);
1544
1545 $title = htmlspecialchars(db_unescape_string(db_fetch_result($result,
1546 0, "title")));
1547
1548 print "<div class=\"infoBoxContents\">";
1549
1550 $icon_file = ICONS_DIR . "/$feed_id.ico";
1551
1552 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1553 $feed_icon = "<img width=\"16\" height=\"16\"
1554 src=\"" . ICONS_URL . "/$feed_id.ico\">";
1555 } else {
1556 $feed_icon = "";
1557 }
1558
1559 print "<h1>$feed_icon $title</h1>";
1560
1561 print "<table width='100%'>";
1562
1563 $row_class = "odd";
1564
1565 print "<tr class='$row_class'><td>Title:</td>";
1566 print "<td><input id=\"iedit_title\" value=\"$title\"></td></tr>";
1567
1568 $feed_url = db_fetch_result($result, 0, "feed_url");
1569 $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result,
1570 0, "feed_url")));
1571 $row_class = toggleEvenOdd($row_class);
1572
1573 print "<tr class='$row_class'><td>Feed URL:</td>";
1574 print "<td><input id=\"iedit_link\" value=\"$feed_url\"></td></tr>";
ad815c71 1575
0ea4fb50
AD
1576 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1577
1578 $cat_id = db_fetch_result($result, 0, "cat_id");
1579
1580 $row_class = toggleEvenOdd($row_class);
1581
1582 print "<tr class='$row_class'><td>Category:</td>";
1583 print "<td>";
1584 print "<select id=\"iedit_fcat\">";
1585 print "<option id=\"0\">Uncategorized</option>";
1586
1587 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories
1588 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1589
1590 if (db_num_rows($tmp_result) > 0) {
1591 print "<option disabled>--------</option>";
1592 }
1593
1594 while ($tmp_line = db_fetch_assoc($tmp_result)) {
1595 if ($tmp_line["id"] == $cat_id) {
1596 $is_selected = "selected";
1597 } else {
1598 $is_selected = "";
1599 }
1600 printf("<option $is_selected id='%d'>%s</option>",
1601 $tmp_line["id"], $tmp_line["title"]);
1602 }
1603
1604 print "</select></td>";
1605 print "</td></tr>";
1606
1607 }
1608
1609 $update_interval = db_fetch_result($result, 0, "update_interval");
1610 $row_class = toggleEvenOdd($row_class);
1611
1612 print "<tr class='$row_class'><td>Update Interval:</td>";
ad815c71
AD
1613// print "<td><input id=\"iedit_updintl\"
1614// value=\"$update_interval\"></td></tr>";
1615
1616 print "<td>";
1617
1618 print "<select id=\"iedit_updintl\">";
1619
1620 foreach (array_keys($update_intervals) as $i) {
1621
1622 if ($i == $update_interval) {
1623 $selected = "selected";
1624 } else {
1625 $selected = "";
1626 }
1627 print "<option $selected id=\"$i\">" . $update_intervals[$i] . "</option>";
1628 }
1629
1630 print "</select>";
1631
1632 print "</td>";
0ea4fb50 1633
1da7e457
AD
1634 $row_class = toggleEvenOdd($row_class);
1635 print "<tr class='$row_class'><td>Link to:</td>";
1636
3b0027a4
AD
1637 $tmp_result = db_query($link, "SELECT COUNT(id) AS count
1638 FROM ttrss_feeds WHERE parent_feed = '$feed_id'");
1639
1640 $linked_count = db_fetch_result($tmp_result, 0, "count");
1641
1da7e457 1642 $parent_feed = db_fetch_result($result, 0, "parent_feed");
3b0027a4
AD
1643
1644 if ($linked_count > 0) {
1645 $disabled = "disabled";
1646 }
1647
1648 print "<select $disabled id=\"iedit_parent_feed\">";
1649
eac46afb 1650 print "<option id=\"0\">Not linked</option>";
1da7e457 1651
8a53e029
AD
1652 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1653 if ($cat_id) {
1654 $cat_qpart = "AND cat_id = '$cat_id'";
1655 } else {
1656 $cat_qpart = "AND cat_id IS NULL";
1657 }
1658 }
1659
1da7e457 1660 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
262c2426
AD
1661 WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]."
1662 $cat_qpart ORDER BY title");
1da7e457
AD
1663
1664 if (db_num_rows($tmp_result) > 0) {
1665 print "<option disabled>--------</option>";
1666 }
1667
1668 while ($tmp_line = db_fetch_assoc($tmp_result)) {
1669 if ($tmp_line["id"] == $parent_feed) {
1670 $is_selected = "selected";
1671 } else {
1672 $is_selected = "";
1673 }
1674 printf("<option $is_selected id='%d'>%s</option>",
1675 $tmp_line["id"], $tmp_line["title"]);
1676 }
1677
1678 print "</select></td>";
1679 print "</td></tr>";
1680
0ea4fb50
AD
1681 $purge_interval = db_fetch_result($result, 0, "purge_interval");
1682 $row_class = toggleEvenOdd($row_class);
1683
1684 print "<tr class='$row_class'><td>Purge Days:</td>";
ad815c71
AD
1685// print "<td><input id=\"iedit_purgintl\"
1686// value=\"$purge_interval\"></td></tr>";
1687
1688 print "<td>";
1689
1690 print "<select id=\"iedit_purgintl\">";
1691
1692 foreach (array_keys($purge_intervals) as $i) {
1693
1694 if ($i == $purge_interval) {
1695 $selected = "selected";
1696 } else {
1697 $selected = "";
1698 }
1699 print "<option $selected id=\"$i\">" . $purge_intervals[$i] . "</option>";
1700 }
1701
1702 print "</select>";
1703
1704 print "</td>";
0ea4fb50 1705
47c6c988
AD
1706// print "<tr><td colspan=\"2\"><b>Authentication</b></td></tr>";
1707
1708 $row_class = toggleEvenOdd($row_class);
1709 $auth_login = db_fetch_result($result, 0, "auth_login");
1710
1711 print "<tr class='$row_class'><td>Login:</td>";
1712 print "<td><input id=\"iedit_login\"
1713 value=\"$auth_login\"></td></tr>";
1714
1715 $row_class = toggleEvenOdd($row_class);
1716 $auth_pass = db_fetch_result($result, 0, "auth_pass");
1717
1718 print "<tr class='$row_class'><td>Password:</td>";
1719 print "<td><input type=\"password\" id=\"iedit_pass\"
1720 value=\"$auth_pass\"></td></tr>";
1721
e3c99f3b
AD
1722 $row_class = toggleEvenOdd($row_class);
1723 $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
1724
1725 if ($private) {
1726 $checked = "checked";
1727 } else {
1728 $checked = "";
1729 }
1730
991ee9e2 1731 print "<tr class='$row_class'><td valign='top'>Options:</td>";
e3c99f3b 1732 print "<td><input type=\"checkbox\" id=\"iedit_private\"
70f6dbb1
AD
1733 $checked><label for=\"iedit_private\">Hide from feed browser</label>";
1734
1735 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
1736
1737 if ($rtl_content) {
1738 $checked = "checked";
1739 } else {
1740 $checked = "";
1741 }
1742
1743 print "<br><input type=\"checkbox\" id=\"iedit_rtl\"
1744 $checked><label for=\"iedit_rtl\">Right-to-left content</label>";
1745
1746 print "</td></tr>";
e3c99f3b 1747
0ea4fb50
AD
1748 print "</table>";
1749 print "</div>";
1750
1751 print "<div align='center'>
0ea4fb50 1752 <input type=\"submit\" class=\"button\"
d10fabe4
AD
1753 onclick=\"feedEditSave()\" value=\"Save\">
1754 <input type='submit' class='button'
1755 onclick=\"feedEditCancel()\" value=\"Cancel\"></div>";
0ea4fb50
AD
1756 return;
1757 }
1758
508a81e1 1759 if ($subop == "editSave") {
47c6c988
AD
1760 $feed_title = db_escape_string($_POST["t"]);
1761 $feed_link = db_escape_string($_POST["l"]);
1762 $upd_intl = db_escape_string($_POST["ui"]);
1763 $purge_intl = db_escape_string($_POST["pi"]);
1764 $feed_id = db_escape_string($_POST["id"]);
1765 $cat_id = db_escape_string($_POST["catid"]);
1766 $auth_login = db_escape_string($_POST["login"]);
1767 $auth_pass = db_escape_string($_POST["pass"]);
1da7e457 1768 $parent_feed = db_escape_string($_POST["pfeed"]);
19ded366 1769 $private = db_escape_string($_POST["is_pvt"]);
70f6dbb1 1770 $rtl_content = db_escape_string($_POST["is_rtl"]);
508a81e1 1771
d148926e
AD
1772 if (strtoupper($upd_intl) == "DEFAULT")
1773 $upd_intl = 0;
1774
a88c1f36
AD
1775 if (strtoupper($upd_intl) == "DISABLED")
1776 $upd_intl = -1;
1777
5d73494a
AD
1778 if (strtoupper($purge_intl) == "DEFAULT")
1779 $purge_intl = 0;
1780
140aae81
AD
1781 if (strtoupper($purge_intl) == "DISABLED")
1782 $purge_intl = -1;
1783
91ff844a
AD
1784 if ($cat_id != 0) {
1785 $category_qpart = "cat_id = '$cat_id'";
1786 } else {
1787 $category_qpart = 'cat_id = NULL';
1788 }
1789
1da7e457
AD
1790 if ($parent_feed != 0) {
1791 $parent_qpart = "parent_feed = '$parent_feed'";
1792 } else {
1793 $parent_qpart = 'parent_feed = NULL';
1794 }
1795
648472a7 1796 $result = db_query($link, "UPDATE ttrss_feeds SET
91ff844a 1797 $category_qpart,
1da7e457 1798 $parent_qpart,
d148926e 1799 title = '$feed_title', feed_url = '$feed_link',
5d73494a 1800 update_interval = '$upd_intl',
47c6c988
AD
1801 purge_interval = '$purge_intl',
1802 auth_login = '$auth_login',
e3c99f3b 1803 auth_pass = '$auth_pass',
ac92cb46
AD
1804 private = $private,
1805 rtl_content = $rtl_content
1806 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
5ddadb4c
AD
1807 }
1808
1809 if ($subop == "saveCat") {
1810 $cat_title = db_escape_string($_GET["title"]);
1811 $cat_id = db_escape_string($_GET["id"]);
1812
1813 $result = db_query($link, "UPDATE ttrss_feed_categories SET
1814 title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
508a81e1 1815
83fe4d6d
AD
1816 }
1817
331900c6 1818 if ($subop == "remove") {
331900c6 1819
b0b4abcf 1820 if (!WEB_DEMO_MODE) {
331900c6 1821
f932bc9f 1822 $ids = split(",", db_escape_string($_GET["ids"]));
b0b4abcf
AD
1823
1824 foreach ($ids as $id) {
f72dbbde
AD
1825 db_query($link, "DELETE FROM ttrss_feeds
1826 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
4769ddaf 1827
273a2f6b 1828 $icons_dir = ICONS_DIR;
d5caaae5 1829
4769ddaf
AD
1830 if (file_exists($icons_dir . "/$id.ico")) {
1831 unlink($icons_dir . "/$id.ico");
d5caaae5 1832 }
b0b4abcf 1833 }
331900c6
AD
1834 }
1835 }
1836
1837 if ($subop == "add") {
b0b4abcf
AD
1838
1839 if (!WEB_DEMO_MODE) {
331900c6 1840
b6b535ca 1841 $feed_link = db_escape_string(trim($_GET["link"]));
15da5cc1
AD
1842 $cat_id = db_escape_string($_GET["cid"]);
1843
5edfe303 1844 if ($cat_id == "0" || !$cat_id) {
15da5cc1
AD
1845 $cat_qpart = "NULL";
1846 } else {
1847 $cat_qpart = "'$cat_id'";
1848 }
331900c6 1849
648472a7 1850 $result = db_query($link,
7e9a3986
AD
1851 "SELECT id FROM ttrss_feeds
1852 WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]);
1853
1854 if (db_num_rows($result) == 0) {
1855
1856 $result = db_query($link,
15da5cc1 1857 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
746b249f
AD
1858 VALUES ('".$_SESSION["uid"]."', '$feed_link',
1859 '[Unknown]', $cat_qpart)");
331900c6 1860
7e9a3986 1861 $result = db_query($link,
746b249f 1862 "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'
7e9a3986
AD
1863 AND owner_uid = " . $_SESSION["uid"]);
1864
1865 $feed_id = db_fetch_result($result, 0, "id");
1866
1867 if ($feed_id) {
ddb68b81 1868 update_rss_feed($link, $feed_link, $feed_id, true);
7e9a3986
AD
1869 }
1870 } else {
331900c6 1871
7e9a3986
AD
1872 print "<div class=\"warning\">
1873 Feed <b>$feed_link</b> already exists in the database.
1874 </div>";
b0b4abcf
AD
1875 }
1876 }
331900c6 1877 }
a0d53889 1878
91ff844a
AD
1879 if ($subop == "addCat") {
1880
1881 if (!WEB_DEMO_MODE) {
1882
1883 $feed_cat = db_escape_string(trim($_GET["cat"]));
1884
1885 $result = db_query($link,
1886 "SELECT id FROM ttrss_feed_categories
1887 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
1888
1889 if (db_num_rows($result) == 0) {
1890
1891 $result = db_query($link,
1892 "INSERT INTO ttrss_feed_categories (owner_uid,title)
1893 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
1894
1895 } else {
1896
1897 print "<div class=\"warning\">
1898 Category <b>$feed_cat</b> already exists in the database.
1899 </div>";
1900 }
1901
1902
1903 }
1904 }
1905
1906 if ($subop == "removeCats") {
1907
1908 if (!WEB_DEMO_MODE) {
1909
f932bc9f 1910 $ids = split(",", db_escape_string($_GET["ids"]));
91ff844a
AD
1911
1912 foreach ($ids as $id) {
1913
1914 db_query($link, "BEGIN");
1915
1916 $result = db_query($link,
1917 "SELECT count(id) as num_feeds FROM ttrss_feeds
1918 WHERE cat_id = '$id'");
1919
1920 $num_feeds = db_fetch_result($result, 0, "num_feeds");
1921
1922 if ($num_feeds == 0) {
1923 db_query($link, "DELETE FROM ttrss_feed_categories
1924 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
1925 } else {
1926
1927 print "<div class=\"warning\">
1928 Unable to delete non empty feed categories.</div>";
1929
1930 }
1931
1932 db_query($link, "COMMIT");
1933 }
1934 }
1935 }
1936
f932bc9f
AD
1937 if ($subop == "categorize") {
1938
1939 if (!WEB_DEMO_MODE) {
1940
1941 $ids = split(",", db_escape_string($_GET["ids"]));
1942
1943 $cat_id = db_escape_string($_GET["cat_id"]);
1944
1945 if ($cat_id == 0) {
1946 $cat_id_qpart = 'NULL';
1947 } else {
1948 $cat_id_qpart = "'$cat_id'";
1949 }
1950
1951 db_query($link, "BEGIN");
1952
1953 foreach ($ids as $id) {
1954
1955 db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
1956 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
1957 }
1958
1959 db_query($link, "COMMIT");
1960 }
1961
1962 }
1963
a24f525c
AD
1964 if ($quiet) return;
1965
c64d5b03 1966// print "<h3>Edit Feeds</h3>";
91ff844a 1967
4904f845
AD
1968 $result = db_query($link, "SELECT id,title,feed_url,last_error
1969 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1970
1971 if (db_num_rows($result) > 0) {
1972
1973 print "<div class=\"warning\">";
a9b0bfd5
AD
1974
1975// print"<img class=\"closeButton\"
1976// onclick=\"javascript:hideParentElement(this);\" src=\"images/close.png\">";
1977
36aab70f
AD
1978 print "<a href=\"javascript:showBlockElement('feedUpdateErrors')\">
1979 <b>Feeds with update errors</b> (click to expand)</a>";
4904f845 1980
36aab70f 1981 print "<ul id=\"feedUpdateErrors\" class=\"nomarks\">";
4904f845
AD
1982
1983 while ($line = db_fetch_assoc($result)) {
1984 print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " .
1985 $line["last_error"];
1986 }
1987
1988 print "</ul>";
1989 print "</div>";
1990
1991 }
1992
f932bc9f
AD
1993 $feed_search = db_escape_string($_GET["search"]);
1994
1995 if (array_key_exists("search", $_GET)) {
1996 $_SESSION["prefs_feed_search"] = $feed_search;
1997 } else {
1998 $feed_search = $_SESSION["prefs_feed_search"];
1999 }
2000
2001 print "<table width='100%' class=\"prefGenericAddBox\"
2002 cellspacing='0' cellpadding='0'><tr>
2003 <td>
2004 <input id=\"fadd_link\"
2005 onchange=\"javascript:addFeed()\"
2006 size=\"40\">
2007 <input type=\"submit\" class=\"button\"
e2f728be
AD
2008 onclick=\"javascript:addFeed()\" value=\"Add feed\">";
2009
2010 if (ENABLE_FEED_BROWSER) {
2011 print "&nbsp;(<a href='javascript:browseFeeds()'>Top 50</a>)";
2012 }
2013
2014 print "</td><td align='right'>
f932bc9f
AD
2015 <input id=\"feed_search\" size=\"20\"
2016 onchange=\"javascript:updateFeedList()\"
2017 value=\"$feed_search\">
2018 <input type=\"submit\" class=\"button\"
2019 onclick=\"javascript:updateFeedList()\" value=\"Search\">
2020 </td>
2021 </tr></table>";
a0d53889 2022
b83c7545
AD
2023 $feeds_sort = db_escape_string($_GET["sort"]);
2024
2025 if (!$feeds_sort || $feeds_sort == "undefined") {
2026 $feeds_sort = $_SESSION["pref_sort_feeds"];
2027 if (!$feeds_sort) $feeds_sort = "title";
2028 }
2029
2030 $_SESSION["pref_sort_feeds"] = $feeds_sort;
2031
f932bc9f 2032 if ($feed_search) {
11de82c3
AD
2033 $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR
2034 UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND";
f932bc9f
AD
2035 } else {
2036 $search_qpart = "";
2037 }
2038
648472a7 2039 $result = db_query($link, "SELECT
db42b934
AD
2040 F1.id,
2041 F1.title,
2042 F1.feed_url,
2043 substring(F1.last_updated,1,16) AS last_updated,
2044 F1.parent_feed,
2045 F1.update_interval,
2046 F1.purge_interval,
2047 F1.cat_id,
2048 F2.title AS parent_title,
2049 C1.title AS category
c0e5a40e 2050 FROM
db42b934
AD
2051 ttrss_feeds AS F1
2052 LEFT JOIN ttrss_feeds AS F2
2053 ON (F1.parent_feed = F2.id)
2054 LEFT JOIN ttrss_feed_categories AS C1
2055 ON (F1.cat_id = C1.id)
f932bc9f 2056 WHERE
db42b934 2057 $search_qpart F1.owner_uid = '".$_SESSION["uid"]."'
0ea4fb50 2058 ORDER by category,$feeds_sort,title");
1cd17194 2059
3b0feb9b 2060 if (db_num_rows($result) != 0) {
91ff844a 2061
3b0feb9b 2062 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
35f3c923 2063
f4fe2cde
AD
2064 print "<p><table width=\"100%\" cellspacing=\"0\"
2065 class=\"prefFeedList\" id=\"prefFeedList\">";
35f3c923
AD
2066 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
2067 Select:
2068 <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList',
3055bc41 2069 'FEEDR-', 'FRCHK-', true)\">All</a>,
35f3c923 2070 <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList',
3055bc41 2071 'FEEDR-', 'FRCHK-', false)\">None</a>
35f3c923
AD
2072 </td</tr>";
2073
0ea4fb50
AD
2074 if (!get_pref($link, 'ENABLE_FEED_CATS')) {
2075 print "<tr class=\"title\">
e325c6e7 2076 <td width='5%' align='center'>&nbsp;</td>
62ac0cc8 2077 <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td>
f42e9435 2078 <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td>
62ac0cc8 2079 <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td>
ad815c71 2080 <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Interval</a></td></tr>";
603c27f8 2081 }
603c27f8 2082
c64d5b03 2083 $lnum = 0;
0ea4fb50
AD
2084
2085 $cur_cat_id = -1;
c64d5b03
AD
2086
2087 while ($line = db_fetch_assoc($result)) {
2088
3b0feb9b 2089 $feed_id = $line["id"];
0ea4fb50
AD
2090 $cat_id = $line["cat_id"];
2091
2092 $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
2093 $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"]));
2094 $edit_cat = htmlspecialchars(db_unescape_string($line["category"]));
c64d5b03 2095
ad815c71
AD
2096// if ($line["update_interval"] == "0") $line["update_interval"] = "Default";
2097// if ($line["update_interval"] == "-1") $line["update_interval"] = "Disabled";
2098// if ($line["purge_interval"] == "0") $line["purge_interval"] = "Default";
2099// if ($line["purge_interval"] < 0) $line["purge_interval"] = "Disabled";
0ea4fb50
AD
2100
2101 if (!$edit_cat) $edit_cat = "Uncategorized";
2102
0ea4fb50 2103 if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
cb58d0df
AD
2104 $lnum = 0;
2105
0ea4fb50
AD
2106 print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>";
2107
2108 print "<tr class=\"title\">
e325c6e7 2109 <td width='5%' align='center'>&nbsp;</td>
62ac0cc8 2110 <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td>
f42e9435 2111 <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td>
62ac0cc8 2112 <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td>
ad815c71 2113 <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Interval</a></td></tr>";
0ea4fb50
AD
2114
2115 $cur_cat_id = $cat_id;
c64d5b03 2116 }
0ea4fb50 2117
cb58d0df 2118 $class = ($lnum % 2) ? "even" : "odd";
0ea4fb50
AD
2119 $this_row_id = "id=\"FEEDR-$feed_id\"";
2120
53226edc 2121 print "<tr class=\"$class\" $this_row_id>";
3b0feb9b
AD
2122
2123 $icon_file = ICONS_DIR . "/$feed_id.ico";
2124
2125 if (file_exists($icon_file) && filesize($icon_file) > 0) {
327a3bbe 2126 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">";
3b0feb9b 2127 } else {
327a3bbe 2128 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
3b0feb9b 2129 }
327a3bbe 2130// print "<td class='feedIcon'>$feed_icon</td>";
c64d5b03 2131
62ac0cc8 2132 print "<td class='feedSelect'><input onclick='toggleSelectRow(this);'
0ea4fb50 2133 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
3547842a 2134
0ea4fb50
AD
2135 $edit_title = truncate_string($edit_title, 40);
2136 $edit_link = truncate_string($edit_link, 60);
a88c1f36 2137
1da7e457
AD
2138 $parent_title = $line["parent_title"];
2139 if ($parent_title) {
2140 $parent_title = "<span class='groupPrompt'>(linked to
2141 $parent_title)</span>";
2142 }
2143
0ea4fb50 2144 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
1da7e457 2145 "$feed_icon $edit_title $parent_title" . "</a></td>";
0ea4fb50
AD
2146
2147 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
2148 $edit_link . "</a></td>";
3547842a 2149
0ea4fb50
AD
2150/* if (get_pref($link, 'ENABLE_FEED_CATS')) {
2151 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
2152 $edit_cat . "</a></td>";
2153 } */
3547842a 2154
0ea4fb50 2155 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
ad815c71 2156 $update_intervals[$line["update_interval"]] . "</a></td>";
3b0feb9b 2157
0ea4fb50 2158 print "<td><a href=\"javascript:editFeed($feed_id);\">" .
ad815c71 2159 $purge_intervals[$line["purge_interval"]] . "</a></td>";
3b0feb9b 2160
c64d5b03
AD
2161 print "</tr>";
2162
2163 ++$lnum;
2164 }
2165
c64d5b03 2166 print "</table>";
3b0feb9b 2167
c64d5b03
AD
2168 print "<p>";
2169
3b0feb9b
AD
2170 if ($subop == "edit") {
2171 print "Edit feed:&nbsp;
c64d5b03 2172 <input type=\"submit\" class=\"button\"
3b0feb9b 2173 onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
c64d5b03 2174 <input type=\"submit\" class=\"button\"
3b0feb9b
AD
2175 onclick=\"javascript:feedEditSave()\" value=\"Save\">";
2176 } else {
c64d5b03
AD
2177
2178 print "
2179 Selection:&nbsp;
2180 <input type=\"submit\" class=\"button\"
3b0feb9b 2181 onclick=\"javascript:selectedFeedDetails()\" value=\"Details\">
c64d5b03 2182 <input type=\"submit\" class=\"button\"
3b0feb9b
AD
2183 onclick=\"javascript:editSelectedFeed()\" value=\"Edit\">
2184 <input type=\"submit\" class=\"button\"
2185 onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">";
f932bc9f
AD
2186
2187 if (get_pref($link, 'ENABLE_FEED_CATS')) {
2188
2189 print "&nbsp;&nbsp;";
2190
2191 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
2192 WHERE owner_uid = ".$_SESSION["uid"]."
2193 ORDER BY title");
2194
2195 print "<select id=\"sfeed_set_fcat\">";
2196 print "<option id=\"0\">Uncategorized</option>";
2197
2198 if (db_num_rows($result) != 0) {
2199
2200 print "<option disabled>--------</option>";
2201
2202 while ($line = db_fetch_assoc($result)) {
2203 printf("<option id='%d'>%s</option>",
2204 $line["id"], $line["title"]);
2205 }
2206 }
2207
2208 print "</select>";
2209
2210 print " <input type=\"submit\" class=\"button\"
2211 onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Set category\">";
2212
2213 }
2214
3b0feb9b
AD
2215 if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) {
2216 print "
2217 <input type=\"submit\" class=\"button\"
4f3a84f4 2218 onclick=\"javascript:readSelectedFeeds(true)\" value=\"Mark as read\">
3b0feb9b 2219 <input type=\"submit\" class=\"button\"
4f3a84f4 2220 onclick=\"javascript:readSelectedFeeds(false)\"
3b0feb9b
AD
2221 value=\"Mark as unread\">&nbsp;";
2222 }
2223
2224 print "
f932bc9f 2225 &nbsp;All feeds: <input type=\"submit\"
3b0feb9b
AD
2226 class=\"button\" onclick=\"gotoExportOpml()\"
2227 value=\"Export OPML\">";
2228 }
2229 } else {
2230
2231 print "<p>No feeds defined.</p>";
2232
2233 }
2234
2235 if (get_pref($link, 'ENABLE_FEED_CATS')) {
2236
2237 print "<h3>Edit Categories</h3>";
2238
2239 // print "<h3>Categories</h3>";
2240
2241 print "<div class=\"prefGenericAddBox\">
f932bc9f
AD
2242 <input id=\"fadd_cat\"
2243 onchange=\"javascript:addFeedCat()\"
2244 size=\"40\">&nbsp;
2245 <input
3b0feb9b
AD
2246 type=\"submit\" class=\"button\"
2247 onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>";
2248
2249 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
2250 WHERE owner_uid = ".$_SESSION["uid"]."
2251 ORDER BY title");
2252
2253 if (db_num_rows($result) != 0) {
2254
35f3c923 2255 print "<p><table width=\"100%\" class=\"prefFeedCatList\"
f4fe2cde 2256 cellspacing=\"0\" id=\"prefFeedCatList\">";
35f3c923
AD
2257
2258 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
2259 Select:
2260 <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList',
3055bc41 2261 'FCATR-', 'FCCHK-', true)\">All</a>,
35f3c923 2262 <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList',
3055bc41 2263 'FCATR-', 'FCCHK-', false)\">None</a>
35f3c923
AD
2264 </td</tr>";
2265
3b0feb9b 2266 print "<tr class=\"title\">
a426e532 2267 <td width=\"5%\"></td><td width=\"80%\">Title</td>
3b0feb9b
AD
2268 </tr>";
2269
2270 $lnum = 0;
2271
2272 while ($line = db_fetch_assoc($result)) {
2273
2274 $class = ($lnum % 2) ? "even" : "odd";
2275
2276 $cat_id = $line["id"];
2277
2278 $edit_cat_id = $_GET["id"];
2279
2280 if ($subop == "editCat" && $cat_id != $edit_cat_id) {
2281 $class .= "Grayed";
53226edc
AD
2282 $this_row_id = "";
2283 } else {
2284 $this_row_id = "id=\"FCATR-$cat_id\"";
3b0feb9b
AD
2285 }
2286
53226edc 2287 print "<tr class=\"$class\" $this_row_id>";
3b0feb9b
AD
2288
2289 $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
2290
2291 if (!$edit_cat_id || $subop != "editCat") {
2292
a426e532 2293 print "<td align='center'><input onclick='toggleSelectRow(this);'
3b0feb9b
AD
2294 type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>";
2295
2296 print "<td><a href=\"javascript:editFeedCat($cat_id);\">" .
2297 $edit_title . "</a></td>";
2298
2299 } else if ($cat_id != $edit_cat_id) {
2300
2301 print "<td><input disabled=\"true\" type=\"checkbox\"
2302 id=\"FRCHK-".$line["id"]."\"></td>";
2303
2304 print "<td>$edit_title</td>";
2305
2306 } else {
2307
2308 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
2309
2310 print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
2311
2312 }
2313
2314 print "</tr>";
2315
2316 ++$lnum;
2317 }
2318
2319 print "</table>";
2320
2321 print "<p>";
2322
2323 if ($subop == "editCat") {
2324 print "Edit category:&nbsp;
2325 <input type=\"submit\" class=\"button\"
2326 onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\">
2327 <input type=\"submit\" class=\"button\"
2328 onclick=\"javascript:feedCatEditSave()\" value=\"Save\">";
2329 } else {
2330
2331 print "
2332 Selection:&nbsp;
2333 <input type=\"submit\" class=\"button\"
2334 onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\">
2335 <input type=\"submit\" class=\"button\"
2336 onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">";
2337
2338 }
2339
2340 } else {
2341 print "<p>No feed categories defined.</p>";
2342 }
c64d5b03
AD
2343 }
2344
2345 print "<h3>Import OPML</h3>
f5a50b25
AD
2346 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
2347 File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
2348 <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\"
2349 type=\"submit\" value=\"Import\">
2350 </form>";
2351
007bda35
AD
2352 }
2353
a0d53889
AD
2354 if ($op == "pref-filters") {
2355
2356 $subop = $_GET["subop"];
a24f525c 2357 $quiet = $_GET["quiet"];
a0d53889
AD
2358
2359 if ($subop == "editSave") {
a0d53889 2360
648472a7
AD
2361 $regexp = db_escape_string($_GET["r"]);
2362 $descr = db_escape_string($_GET["d"]);
2363 $match = db_escape_string($_GET["m"]);
2364 $filter_id = db_escape_string($_GET["id"]);
ead60402 2365 $feed_id = db_escape_string($_GET["fid"]);
19c9cb11 2366 $action_id = db_escape_string($_GET["aid"]);
ead60402
AD
2367
2368 if (!$feed_id) {
2369 $feed_id = 'NULL';
2370 } else {
2371 $feed_id = sprintf("'%s'", db_escape_string($feed_id));
2372 }
0afbd851 2373
648472a7 2374 $result = db_query($link, "UPDATE ttrss_filters SET
4b3dff6e 2375 reg_exp = '$regexp',
0afbd851 2376 description = '$descr',
ead60402 2377 feed_id = $feed_id,
19c9cb11 2378 action_id = '$action_id',
0afbd851
AD
2379 filter_type = (SELECT id FROM ttrss_filter_types WHERE
2380 description = '$match')
2381 WHERE id = '$filter_id'");
a0d53889
AD
2382 }
2383
2384 if ($subop == "remove") {
2385
2386 if (!WEB_DEMO_MODE) {
2387
f932bc9f 2388 $ids = split(",", db_escape_string($_GET["ids"]));
a0d53889
AD
2389
2390 foreach ($ids as $id) {
648472a7 2391 db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'");
a0d53889
AD
2392
2393 }
2394 }
2395 }
2396
2397 if ($subop == "add") {
2398
de435974 2399 if (!WEB_DEMO_MODE) {
a0d53889 2400
b6b535ca
AD
2401 $regexp = db_escape_string(trim($_GET["regexp"]));
2402 $match = db_escape_string(trim($_GET["match"]));
ead60402 2403 $feed_id = db_escape_string($_GET["fid"]);
19c9cb11 2404 $action_id = db_escape_string($_GET["aid"]);
ead60402
AD
2405
2406 if (!$feed_id) {
2407 $feed_id = 'NULL';
2408 } else {
2409 $feed_id = sprintf("'%s'", db_escape_string($feed_id));
2410 }
4401bf04 2411
648472a7 2412 $result = db_query($link,
19c9cb11
AD
2413 "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,
2414 action_id)
2415 VALUES
de435974 2416 ('$regexp', (SELECT id FROM ttrss_filter_types WHERE
19c9cb11
AD
2417 description = '$match'),'".$_SESSION["uid"]."',
2418 $feed_id, '$action_id')");
de435974 2419 }
a0d53889
AD
2420 }
2421
a24f525c
AD
2422 if ($quiet) return;
2423
648472a7 2424 $result = db_query($link, "SELECT description
a0d53889
AD
2425 FROM ttrss_filter_types ORDER BY description");
2426
2427 $filter_types = array();
2428
648472a7 2429 while ($line = db_fetch_assoc($result)) {
a0d53889
AD
2430 array_push($filter_types, $line["description"]);
2431 }
2432
2c7070b5 2433 print "<div class=\"prefGenericAddBox\">
7cc1e5d6 2434 <input id=\"fadd_regexp\" size=\"40\">&nbsp;";
2c7070b5 2435
ead60402
AD
2436 print_select("fadd_match", "Title", $filter_types);
2437
2438 print "&nbsp;<select id=\"fadd_feed\">";
2439
2440 print "<option selected id=\"0\">All feeds</option>";
2441
2442 $result = db_query($link, "SELECT id,title FROM ttrss_feeds
2443 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
2444
2445 if (db_num_rows($result) > 0) {
2446 print "<option disabled>--------</option>";
2447 }
2448
2449 while ($line = db_fetch_assoc($result)) {
2450 printf("<option id='%d'>%s</option>", $line["id"], $line["title"]);
2451 }
2452
2c7070b5 2453 print "</select>&nbsp;";
19c9cb11
AD
2454
2455 print "&nbsp;Action: ";
2456
2457 print "<select id=\"fadd_action\">";
2458
2459 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
2460 ORDER BY name");
2461
2462 while ($line = db_fetch_assoc($result)) {
2463 printf("<option id='%d'>%s</option>", $line["id"], $line["description"]);
2464 }
2465
2466 print "</select>&nbsp;";
2467
9323147e
AD
2468/* print "<input type=\"submit\"
2469 class=\"button\" onclick=\"javascript:testFilter()\"
2470 value=\"Test filter\"> "; */
2471
2c7070b5
AD
2472 print "<input type=\"submit\"
2473 class=\"button\" onclick=\"javascript:addFilter()\"
2474 value=\"Add filter\">";
a0d53889 2475
19c9cb11
AD
2476 print "</div>";
2477
648472a7 2478 $result = db_query($link, "SELECT
ead60402
AD
2479 ttrss_filters.id AS id,reg_exp,
2480 ttrss_filters.description AS description,
2481 ttrss_filter_types.name AS filter_type_name,
2482 ttrss_filter_types.description AS filter_type_descr,
2483 feed_id,
19c9cb11 2484 ttrss_filter_actions.description AS action_description,
11de82c3 2485 ttrss_feeds.title AS feed_title
a0d53889 2486 FROM
5890c3f4
AD
2487 ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN
2488 ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id)
4356293a 2489 WHERE
ead60402 2490 filter_type = ttrss_filter_types.id AND
19c9cb11 2491 ttrss_filter_actions.id = action_id AND
ead60402 2492 ttrss_filters.owner_uid = ".$_SESSION["uid"]."
4356293a 2493 ORDER by reg_exp");
a0d53889 2494
3b0feb9b 2495 if (db_num_rows($result) != 0) {
a0d53889 2496
f4fe2cde
AD
2497 print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\"
2498 id=\"prefFilterList\">";
35f3c923
AD
2499
2500 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
2501 Select:
2502 <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList',
3055bc41 2503 'FILRR-', 'FICHK-', true)\">All</a>,
35f3c923 2504 <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList',
3055bc41 2505 'FILRR-', 'FICHK-', false)\">None</a>
35f3c923
AD
2506 </td</tr>";
2507
3b0feb9b 2508 print "<tr class=\"title\">
e325c6e7 2509 <td align='center' width=\"5%\">&nbsp;</td>
19c9cb11
AD
2510 <td width=\"20%\">Filter expression</td>
2511 <td width=\"20%\">Feed</td>
2512 <td width=\"15%\">Match</td>
2513 <td width=\"15%\">Action</td>
3b0feb9b 2514 <td width=\"30%\">Description</td></tr>";
a0d53889 2515
3b0feb9b
AD
2516 $lnum = 0;
2517
2518 while ($line = db_fetch_assoc($result)) {
2519
2520 $class = ($lnum % 2) ? "even" : "odd";
2521
2522 $filter_id = $line["id"];
2523 $edit_filter_id = $_GET["id"];
2524
2525 if ($subop == "edit" && $filter_id != $edit_filter_id) {
2526 $class .= "Grayed";
53226edc
AD
2527 $this_row_id = "";
2528 } else {
2529 $this_row_id = "id=\"FILRR-$filter_id\"";
ead60402 2530 }
3b0feb9b 2531
53226edc 2532 print "<tr class=\"$class\" $this_row_id>";
3b0feb9b
AD
2533
2534 $line["regexp"] = htmlspecialchars($line["reg_exp"]);
2535 $line["description"] = htmlspecialchars($line["description"]);
2536
2537 if (!$line["feed_title"]) $line["feed_title"] = "All feeds";
2538
2539 if (!$edit_filter_id || $subop != "edit") {
2540
2541 if (!$line["description"]) $line["description"] = "[No description]";
2542
a426e532 2543 print "<td align='center'><input onclick='toggleSelectRow(this);'
3b0feb9b
AD
2544 type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
2545
2546 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
2547 $line["reg_exp"] . "</td>";
2548
2549 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
2550 $line["feed_title"] . "</td>";
2551
2552 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
2553 $line["filter_type_descr"] . "</td>";
19c9cb11
AD
2554
2555 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
2556 $line["action_description"] . "</td>";
2557
3b0feb9b
AD
2558 print "<td><a href=\"javascript:editFilter($filter_id);\">" .
2559 $line["description"] . "</td>";
2560
2561 } else if ($filter_id != $edit_filter_id) {
2562
2563 if (!$line["description"]) $line["description"] = "[No description]";
2564
2565 print "<td><input disabled=\"true\" type=\"checkbox\"
2566 id=\"FICHK-".$line["id"]."\"></td>";
2567
2568 print "<td>".$line["reg_exp"]."</td>";
2569 print "<td>".$line["feed_title"]."</td>";
2570 print "<td>".$line["filter_type_descr"]."</td>";
19c9cb11 2571 print "<td>".$line["action_description"]."</td>";
3b0feb9b 2572 print "<td>".$line["description"]."</td>";
19c9cb11 2573
3b0feb9b
AD
2574 } else {
2575
2576 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
2577
2578 print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"].
2579 "\"></td>";
2580
2581 print "<td>";
3b0feb9b 2582 print "<select id=\"iedit_feed\">";
3b0feb9b
AD
2583 print "<option id=\"0\">All feeds</option>";
2584
3b0feb9b
AD
2585 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
2586 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
19c9cb11
AD
2587
2588 if (db_num_rows($tmp_result) > 0) {
2589 print "<option disabled>--------</option>";
2590 }
2591
3b0feb9b
AD
2592 while ($tmp_line = db_fetch_assoc($tmp_result)) {
2593 if ($tmp_line["id"] == $line["feed_id"]) {
2594 $is_selected = "selected";
2595 } else {
2596 $is_selected = "";
2597 }
2598 printf("<option $is_selected id='%d'>%s</option>",
2599 $tmp_line["id"], $tmp_line["title"]);
ead60402 2600 }
3b0feb9b
AD
2601
2602 print "</select></td>";
2603
2604 print "<td>";
2605 print_select("iedit_match", $line["filter_type_descr"], $filter_types);
2606 print "</td>";
19c9cb11
AD
2607
2608 print "<td>";
2609 print "<select id=\"iedit_filter_action\">";
2610
2611 $tmp_result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
2612 ORDER BY description");
2613
2614 while ($tmp_line = db_fetch_assoc($tmp_result)) {
2615 if ($tmp_line["description"] == $line["action_description"]) {
2616 $is_selected = "selected";
2617 } else {
2618 $is_selected = "";
2619 }
2620 printf("<option $is_selected id='%d'>%s</option>",
2621 $tmp_line["id"], $tmp_line["description"]);
2622 }
3b0feb9b 2623
19c9cb11
AD
2624 print "</select></td>";
2625
2626
3b0feb9b
AD
2627 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
2628 "\"></td>";
2629
2630 print "</td>";
ead60402 2631 }
3b0feb9b
AD
2632
2633 print "</tr>";
2634
2635 ++$lnum;
a0d53889 2636 }
3b0feb9b
AD
2637
2638 if ($lnum == 0) {
2639 print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>";
2640 }
2641
2642 print "</table>";
2643
2644 print "<p>";
2645
2646 if ($subop == "edit") {
d10fabe4 2647 print "Edit filter:
3b0feb9b 2648 <input type=\"submit\" class=\"button\"
d10fabe4 2649 onclick=\"javascript:filterEditSave()\" value=\"Save\">
3b0feb9b 2650 <input type=\"submit\" class=\"button\"
d10fabe4 2651 onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">";
3b0feb9b
AD
2652
2653 } else {
2654
2655 print "
2656 Selection:
e828e31e 2657 <input type=\"submit\" class=\"button\"
3b0feb9b 2658 onclick=\"javascript:editSelectedFilter()\" value=\"Edit\">
e828e31e 2659 <input type=\"submit\" class=\"button\"
3b0feb9b
AD
2660 onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">";
2661 }
2662
a0d53889
AD
2663 } else {
2664
3b0feb9b
AD
2665 print "<p>No filters defined.</p>";
2666
a0d53889
AD
2667 }
2668 }
2669
80dce858
AD
2670 // We need to accept raw SQL data in label queries, so not everything is escaped
2671 // here, this is by design. If you don't like the whole idea, disable labels
2672 // altogether with GLOBAL_ENABLE_LABELS = false
2673
48f0adb0
AD
2674 if ($op == "pref-labels") {
2675
cfaba6df
AD
2676 if (!GLOBAL_ENABLE_LABELS) {
2677 return;
2678 }
2679
48f0adb0
AD
2680 $subop = $_GET["subop"];
2681
d9dde1d6
AD
2682 if ($subop == "test") {
2683
2684 $expr = $_GET["expr"];
2685 $descr = $_GET["descr"];
2686
2687 print "<div class='infoBoxContents'>";
2688
2689 print "<h1>Label &laquo;$descr&raquo;</h1>";
2690
2691// print "<p><b>Expression</b>: $expr</p>";
2692
2693 $result = db_query($link,
2694 "SELECT count(id) AS num_matches
2695 FROM ttrss_entries,ttrss_user_entries
2696 WHERE ($expr) AND
2697 ttrss_user_entries.ref_id = ttrss_entries.id AND
2698 owner_uid = " . $_SESSION["uid"]);
2699
2700 $num_matches = db_fetch_result($result, 0, "num_matches");;
2701
2702 if ($num_matches > 0) {
2703
a31a7b39 2704 print "<p>Query returned <b>$num_matches</b> matches, first 5 follow:</p>";
d9dde1d6
AD
2705
2706 $result = db_query($link,
2707 "SELECT title,
2708 (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
2709 FROM ttrss_entries,ttrss_user_entries
2710 WHERE ($expr) AND
2711 ttrss_user_entries.ref_id = ttrss_entries.id
2712 AND owner_uid = " . $_SESSION["uid"] . "
2713 ORDER BY date_entered DESC LIMIT 5");
2714
2715 print "<ul class=\"nomarks\">";
2716 while ($line = db_fetch_assoc($result)) {
2717 print "<li>".$line["title"].
2718 " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>";
2719 }
2720 print "</ul>";
2721
2722 } else {
2723 print "<p>Query didn't return any matches.</p>";
2724 }
2725
2726 print "</div>";
2727
2728 print "<div align='center'>
2729 <input type='submit' class='button'
2730 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
2731 return;
2732 }
2733
48f0adb0
AD
2734 if ($subop == "editSave") {
2735
2736 $sql_exp = $_GET["s"];
2737 $descr = $_GET["d"];
2738 $label_id = db_escape_string($_GET["id"]);
2739
2740// print "$sql_exp : $descr : $label_id";
2741
2742 $result = db_query($link, "UPDATE ttrss_labels SET
2743 sql_exp = '$sql_exp',
2744 description = '$descr'
2745 WHERE id = '$label_id'");
2746 }
2747
2748 if ($subop == "remove") {
2749
2750 if (!WEB_DEMO_MODE) {
2751
f932bc9f 2752 $ids = split(",", db_escape_string($_GET["ids"]));
48f0adb0
AD
2753
2754 foreach ($ids as $id) {
2755 db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'");
2756
2757 }
2758 }
2759 }
2760
2761 if ($subop == "add") {
2762
2763 if (!WEB_DEMO_MODE) {
2764
4401bf04
AD
2765 // no escaping is done here on purpose
2766 $exp = trim($_GET["exp"]);
48f0adb0
AD
2767
2768 $result = db_query($link,
4356293a
AD
2769 "INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
2770 VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')");
48f0adb0
AD
2771 }
2772 }
2773
2c7070b5
AD
2774 print "<div class=\"prefGenericAddBox\">
2775 <input size=\"40\" id=\"ladd_expr\">&nbsp;";
48f0adb0 2776
2c7070b5
AD
2777 print"<input type=\"submit\" class=\"button\"
2778 onclick=\"javascript:addLabel()\" value=\"Add label\"></div>";
48f0adb0
AD
2779
2780 $result = db_query($link, "SELECT
2781 id,sql_exp,description
2782 FROM
4356293a
AD
2783 ttrss_labels
2784 WHERE
2785 owner_uid = ".$_SESSION["uid"]."
2786 ORDER by description");
48f0adb0 2787
d9dde1d6
AD
2788 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
2789
3b0feb9b 2790 if (db_num_rows($result) != 0) {
48f0adb0 2791
f4fe2cde
AD
2792 print "<p><table width=\"100%\" cellspacing=\"0\"
2793 class=\"prefLabelList\" id=\"prefLabelList\">";
35f3c923
AD
2794
2795 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
2796 Select:
2797 <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList',
3055bc41 2798 'LILRR-', 'LICHK-', true)\">All</a>,
35f3c923 2799 <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList',
3055bc41 2800 'LILRR-', 'LICHK-', false)\">None</a>
35f3c923
AD
2801 </td</tr>";
2802
3b0feb9b 2803 print "<tr class=\"title\">
e325c6e7
AD
2804 <td align='center' width=\"5%\">&nbsp;</td>
2805 <td width=\"40%\">SQL expression
01c9c74a 2806 <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a>
3b0feb9b
AD
2807 </td>
2808 <td width=\"40%\">Caption</td></tr>";
2809
2810 $lnum = 0;
2811
2812 while ($line = db_fetch_assoc($result)) {
2813
2814 $class = ($lnum % 2) ? "even" : "odd";
2815
2816 $label_id = $line["id"];
2817 $edit_label_id = $_GET["id"];
2818
2819 if ($subop == "edit" && $label_id != $edit_label_id) {
2820 $class .= "Grayed";
53226edc
AD
2821 $this_row_id = "";
2822 } else {
2823 $this_row_id = "id=\"LILRR-$label_id\"";
3b0feb9b
AD
2824 }
2825
53226edc 2826 print "<tr class=\"$class\" $this_row_id>";
3b0feb9b
AD
2827
2828 $line["sql_exp"] = htmlspecialchars($line["sql_exp"]);
2829 $line["description"] = htmlspecialchars($line["description"]);
2830
2831 if (!$edit_label_id || $subop != "edit") {
2832
2833 if (!$line["description"]) $line["description"] = "[No caption]";
2834
a426e532 2835 print "<td align='center'><input onclick='toggleSelectRow(this);'
3b0feb9b
AD
2836 type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
2837
2838 print "<td><a href=\"javascript:editLabel($label_id);\">" .
2839 $line["sql_exp"] . "</td>";
48f0adb0 2840
3b0feb9b
AD
2841 print "<td><a href=\"javascript:editLabel($label_id);\">" .
2842 $line["description"] . "</td>";
2843
2844 } else if ($label_id != $edit_label_id) {
2845
2846 if (!$line["description"]) $line["description"] = "[No description]";
2847
2848 print "<td><input disabled=\"true\" type=\"checkbox\"
2849 id=\"LICHK-".$line["id"]."\"></td>";
2850
2851 print "<td>".$line["sql_exp"]."</td>";
2852 print "<td>".$line["description"]."</td>";
2853
2854 } else {
2855
2856 print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
2857
2858 print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"].
2859 "\"></td>";
2860
2861 print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
2862 "\"></td>";
2863
2864 }
2865
48f0adb0 2866
3b0feb9b
AD
2867 print "</tr>";
2868
2869 ++$lnum;
2870 }
2871
2872 if ($lnum == 0) {
2873 print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>";
2874 }
2875
2876 print "</table>";
2877
2878 print "<p>";
2879
2880 if ($subop == "edit") {
2881 print "Edit label:
d9dde1d6
AD
2882 <input type=\"submit\" class=\"button\"
2883 onclick=\"javascript:labelTest()\" value=\"Test\">
3b0feb9b 2884 <input type=\"submit\" class=\"button\"
d10fabe4 2885 onclick=\"javascript:labelEditSave()\" value=\"Save\">
3b0feb9b 2886 <input type=\"submit\" class=\"button\"
d10fabe4 2887 onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">";
3b0feb9b
AD
2888
2889 } else {
2890
2891 print "
2892 Selection:
48f0adb0 2893 <input type=\"submit\" class=\"button\"
3b0feb9b 2894 onclick=\"javascript:editSelectedLabel()\" value=\"Edit\">
48f0adb0 2895 <input type=\"submit\" class=\"button\"
3b0feb9b
AD
2896 onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">";
2897 }
48f0adb0 2898 } else {
3b0feb9b 2899 print "<p>No labels defined.</p>";
48f0adb0
AD
2900 }
2901 }
2902
e828e31e
AD
2903 if ($op == "error") {
2904 print "<div width=\"100%\" align='center'>";
2905 $msg = $_GET["msg"];
2906 print $msg;
2907 print "</div>";
2908 }
2909
7dc66a61 2910 if ($op == "help") {
01c9c74a
AD
2911 if (!$_GET["noheaders"]) {
2912 print "<html><head>
2913 <title>Tiny Tiny RSS : Help</title>
2914 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
2915 <script type=\"text/javascript\" src=\"functions.js\"></script>
2916 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
2917 </head><body>";
2918 }
7dc66a61
AD
2919
2920 $tid = sprintf("%d", $_GET["tid"]);
2921
01c9c74a 2922 print "<div class='infoBoxContents'>";
7dc66a61 2923
01c9c74a
AD
2924 if (file_exists("help/$tid.php")) {
2925 include("help/$tid.php");
2926 } else {
2927 print "<p>Help topic not found.</p>";
2928 }
7dc66a61 2929
01c9c74a 2930 print "</div>";
7dc66a61
AD
2931
2932 print "<div align='center'>
01c9c74a
AD
2933 <input type='submit' class='button'
2934 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
7dc66a61 2935
01c9c74a
AD
2936 if (!$_GET["noheaders"]) {
2937 print "</body></html>";
2938 }
7dc66a61
AD
2939
2940 }
2941
f84a97a3
AD
2942 if ($op == "dlg") {
2943 $id = $_GET["id"];
6de5d056 2944 $param = $_GET["param"];
f84a97a3
AD
2945
2946 if ($id == "quickAddFeed") {
76332f3c
AD
2947 print "
2948 Feed URL: <input
033e47e0 2949 onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
15da5cc1
AD
2950 id=\"qafInput\">";
2951
2952 if (get_pref($link, 'ENABLE_FEED_CATS')) {
2953 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
2954 WHERE owner_uid = ".$_SESSION["uid"]."
2955 ORDER BY title");
2956
2957 print " <select id=\"qafCat\">";
2958 print "<option id=\"0\">Uncategorized</option>";
2959
2960 if (db_num_rows($result) != 0) {
2961
2962 print "<option disabled>--------</option>";
2963
2964 while ($line = db_fetch_assoc($result)) {
2965 printf("<option id='%d'>%s</option>",
2966 $line["id"], $line["title"]);
2967 }
2968 }
2969
2970 print "</select>";
2971 }
2972
2973 print "&nbsp;<input class=\"button\"
f84a97a3
AD
2974 type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\">
2975 <input class=\"button\"
2976 type=\"submit\" onclick=\"javascript:closeDlg()\"
2977 value=\"Cancel\">";
2978 }
6de5d056
AD
2979
2980 if ($id == "quickDelFeed") {
2981
2982 $param = db_escape_string($param);
2983
2984 $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'");
2985
2986 if ($result) {
2987
2988 $f_title = db_fetch_result($result, 0, "title");
2989
76332f3c 2990 print "Remove current feed (<b>$f_title</b>)?&nbsp;
6de5d056
AD
2991 <input class=\"button\"
2992 type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\">
2993 <input class=\"button\"
2994 type=\"submit\" onclick=\"javascript:closeDlg()\"
2995 value=\"Cancel\">";
2996 } else {
2997 print "Error: Feed $param not found.&nbsp;
2998 <input class=\"button\"
2999 type=\"submit\" onclick=\"javascript:closeDlg()\"
3000 value=\"Cancel\">";
3001 }
3002 }
3003
033e47e0
AD
3004 if ($id == "search") {
3005
49b7cbd3
AD
3006 $active_feed_id = db_escape_string($_GET["param"]);
3007
033e47e0
AD
3008 print "<input id=\"searchbox\" class=\"extSearch\"
3009 onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
3010 onchange=\"javascript:search()\">
3011 <select id=\"searchmodebox\">
49b7cbd3
AD
3012 <option selected>All feeds</option>";
3013
3014 if ($active_feed_id) {
3015 print "<option>This feed</option>";
3016 } else {
3017 print "<option disabled>This feed</option>";
3018 }
b0005823
AD
3019
3020 if (get_pref($link, 'ENABLE_FEED_CATS')) {
3021 print "<option>This category</option>";
3022 }
3023
49b7cbd3 3024 print "</select>
033e47e0
AD
3025 <input type=\"submit\"
3026 class=\"button\" onclick=\"javascript:search()\" value=\"Search\">
3027 <input class=\"button\"
3028 type=\"submit\" onclick=\"javascript:closeDlg()\"
3029 value=\"Close\">";
3030
3031 }
3032
a24f525c
AD
3033 if ($id == "quickAddFilter") {
3034
3035 $result = db_query($link, "SELECT description
3036 FROM ttrss_filter_types ORDER BY description");
3037
3038 $filter_types = array();
3039
3040 while ($line = db_fetch_assoc($result)) {
3041 array_push($filter_types, $line["description"]);
3042 }
3043
3044 print "<table>";
3045
3046 print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"40\">&nbsp;";
3047
3048 print_select("fadd_match", "Title", $filter_types);
3049
3050 print "</td></tr>";
3051 print "<tr><td>Feed:</td><td><select id=\"fadd_feed\">";
3052
3053 print "<option selected id=\"0\">All feeds</option>";
3054
3055 $result = db_query($link, "SELECT id,title FROM ttrss_feeds
3056 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
3057
3058 if (db_num_rows($result) > 0) {
3059 print "<option disabled>--------</option>";
3060 }
3061
3062 while ($line = db_fetch_assoc($result)) {
3063 if ($param == $line["id"]) {
3064 $selected = "selected";
3065 } else {
3066 $selected = "";
3067 }
3068 printf("<option id='%d' %s>%s</option>", $line["id"], $selected, $line["title"]);
3069 }
3070
3071 print "</select></td></tr>";
3072
3073 print "<tr><td>Action:</td>";
3074
3075 print "<td><select id=\"fadd_action\">";
3076
3077 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
3078 ORDER BY name");
3079
3080 while ($line = db_fetch_assoc($result)) {
3081 printf("<option id='%d'>%s</option>", $line["id"], $line["description"]);
3082 }
3083
3084 print "</select>";
3085
3086 print "</td></tr><tr><td colspan=\"2\" align=\"right\">";
3087
3088 print "<input type=\"submit\"
3089 class=\"button\" onclick=\"javascript:qaddFilter()\"
3090 value=\"Add filter\"> ";
3091
3092 print "<input class=\"button\"
3093 type=\"submit\" onclick=\"javascript:closeDlg()\"
3094 value=\"Close\">";
3095
3096 print "</td></tr></table>";
3097 }
f84a97a3
AD
3098 }
3099
a2770077
AD
3100 // update feeds of all users, may be used anonymously
3101 if ($op == "globalUpdateFeeds") {
3102
3103 $result = db_query($link, "SELECT id FROM ttrss_users");
3104
3105 while ($line = db_fetch_assoc($result)) {
3106 $user_id = $line["id"];
3107// print "<!-- updating feeds of uid $user_id -->";
3108 update_all_feeds($link, false, $user_id);
3109 }
e65af9c1 3110
a2770077
AD
3111 print "<rpc-reply>
3112 <message msg=\"All feeds updated\"/>
3113 </rpc-reply>";
e65af9c1
AD
3114
3115 }
3116
77e96719
AD
3117 if ($op == "pref-prefs") {
3118
b1895692 3119 $subop = $_REQUEST["subop"];
77e96719
AD
3120
3121 if ($subop == "Save configuration") {
3122
d2892032
AD
3123 if (WEB_DEMO_MODE) {
3124 header("Location: prefs.php");
3125 return;
3126 }
01d68cf9 3127
93cb4442
AD
3128 $_SESSION["prefs_op_result"] = "save-config";
3129
11de82c3
AD
3130 $_SESSION["prefs_cache"] = false;
3131
77e96719
AD
3132 foreach (array_keys($_POST) as $pref_name) {
3133
3134 $pref_name = db_escape_string($pref_name);
3135 $value = db_escape_string($_POST[$pref_name]);
3136
3137 $result = db_query($link, "SELECT type_name
3138 FROM ttrss_prefs,ttrss_prefs_types
3139 WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
3140
3141 if (db_num_rows($result) > 0) {
3142
3143 $type_name = db_fetch_result($result, 0, "type_name");
3144
5da169d9
AD
3145// print "$pref_name : $type_name : $value<br>";
3146
77e96719 3147 if ($type_name == "bool") {
5da169d9 3148 if ($value == "1") {
77e96719
AD
3149 $value = "true";
3150 } else {
3151 $value = "false";
3152 }
3153 } else if ($type_name == "integer") {
3154 $value = sprintf("%d", $value);
3155 }
3156
3157// print "$pref_name : $type_name : $value<br>";
3158
ff485f1d
AD
3159 db_query($link, "UPDATE ttrss_user_prefs SET value = '$value'
3160 WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]);
77e96719
AD
3161
3162 }
3163
3164 header("Location: prefs.php");
3165
3166 }
3167
b1895692
AD
3168 } else if ($subop == "getHelp") {
3169
3170 $pref_name = db_escape_string($_GET["pn"]);
3171
3172 $result = db_query($link, "SELECT help_text FROM ttrss_prefs
3173 WHERE pref_name = '$pref_name'");
3174
3175 if (db_num_rows($result) > 0) {
3176 $help_text = db_fetch_result($result, 0, "help_text");
3177 print $help_text;
3178 } else {
3179 print "Unknown option: $pref_name";
3180 }
3181
cbb01696
AD
3182 } else if ($subop == "Change e-mail") {
3183
3184 if (WEB_DEMO_MODE) {
3185 header("Location: prefs.php");
3186 return;
3187 }
3188
3189 $email = db_escape_string($_GET["email"]);
3190 $active_uid = $_SESSION["uid"];
3191
3192 if ($email) {
3193 db_query($link, "UPDATE ttrss_users SET email = '$email'
3194 WHERE id = '$active_uid'");
3195 }
3196
3197 header("Location: prefs.php");
3198
1c7f75ed
AD
3199 } else if ($subop == "Change password") {
3200
d2892032
AD
3201 if (WEB_DEMO_MODE) {
3202 header("Location: prefs.php");
3203 return;
3204 }
1c7f75ed
AD
3205
3206 $old_pw = $_POST["OLD_PASSWORD"];
3207 $new_pw = $_POST["OLD_PASSWORD"];
3208
3209 $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]);
3210 $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]);
3211
3212 $active_uid = $_SESSION["uid"];
3213
3214 if ($old_pw && $new_pw) {
3215
3216 $login = db_escape_string($_SERVER['PHP_AUTH_USER']);
3217
3218 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
3219 id = '$active_uid' AND (pwd_hash = '$old_pw' OR
3220 pwd_hash = '$old_pw_hash')");
3221
3222 if (db_num_rows($result) == 1) {
3223 db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash'
3224 WHERE id = '$active_uid'");
b791095d
AD
3225
3226 $_SESSION["pwd_change_result"] = "ok";
3227 } else {
3228 $_SESSION["pwd_change_result"] = "failed";
1c7f75ed
AD
3229 }
3230 }
3231
3232 header("Location: prefs.php");
b791095d 3233
77e96719
AD
3234 } else if ($subop == "Reset to defaults") {
3235
d2892032
AD
3236 if (WEB_DEMO_MODE) {
3237 header("Location: prefs.php");
3238 return;
3239 }
01d68cf9 3240
93cb4442
AD
3241 $_SESSION["prefs_op_result"] = "reset-to-defaults";
3242
e1aa0559
AD
3243 if (DB_TYPE == "pgsql") {
3244 db_query($link,"UPDATE ttrss_user_prefs
3245 SET value = ttrss_prefs.def_value
3246 WHERE owner_uid = '".$_SESSION["uid"]."' AND
3247 ttrss_prefs.pref_name = ttrss_user_prefs.pref_name");
3248 } else {
3249 db_query($link, "DELETE FROM ttrss_user_prefs
3250 WHERE owner_uid = ".$_SESSION["uid"]);
3251 initialize_user_prefs($link, $_SESSION["uid"]);
3252 }
5da169d9 3253
77e96719
AD
3254 header("Location: prefs.php");
3255
58f8ad54
AD
3256 } else if ($subop == "Change theme") {
3257
3258 $theme = db_escape_string($_POST["theme"]);
3259
3260 if ($theme == "Default") {
3261 $theme_qpart = 'NULL';
3262 } else {
3263 $theme_qpart = "'$theme'";
3264 }
3265
6752e330
AD
3266 $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes
3267 WHERE theme_name = '$theme'");
3268
3269 if (db_num_rows($result) == 1) {
3270 $theme_id = db_fetch_result($result, 0, "id");
3271 $theme_path = db_fetch_result($result, 0, "theme_path");
3272 } else {
3273 $theme_id = "NULL";
3274 $theme_path = "";
3275 }
3276
58f8ad54 3277 db_query($link, "UPDATE ttrss_users SET
6752e330 3278 theme_id = $theme_id WHERE id = " . $_SESSION["uid"]);
58f8ad54 3279
6752e330 3280 $_SESSION["theme"] = $theme_path;
503eb349 3281
58f8ad54
AD
3282 header("Location: prefs.php");
3283
77e96719
AD
3284 } else {
3285
7d4c898a 3286 if (!SINGLE_USER_MODE) {
1c7f75ed 3287
cbb01696 3288 $result = db_query($link, "SELECT id,email FROM ttrss_users
a029d530
AD
3289 WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR
3290 pwd_hash = 'SHA1:".sha1("password")."')");
3291
3292 if (db_num_rows($result) != 0) {
b791095d 3293 print "<div class=\"warning\">
a029d530
AD
3294 Your password is at default value, please change it.
3295 </div>";
3296 }
3297
b791095d
AD
3298 if ($_SESSION["pwd_change_result"] == "failed") {
3299 print "<div class=\"warning\">
3300 There was an error while changing your password.
3301 </div>";
3302 }
3303
3304 if ($_SESSION["pwd_change_result"] == "ok") {
3305 print "<div class=\"notice\">
3306 Password changed successfully.
3307 </div>";
3308 }
3309
3310 $_SESSION["pwd_change_result"] = "";
3311
93cb4442
AD
3312 if ($_SESSION["prefs_op_result"] == "reset-to-defaults") {
3313 print "<div class=\"notice\">
3314 Your configuration was reset to defaults.
3315 </div>";
3316 }
3317
3318 if ($_SESSION["prefs_op_result"] == "save-config") {
3319 print "<div class=\"notice\">
3320 Your configuration was saved successfully.
3321 </div>";
3322 }
3323
3324 $_SESSION["prefs_op_result"] = "";
3325
cbb01696
AD
3326 print "<form action=\"backend.php\" method=\"GET\">";
3327
3328 print "<table width=\"100%\" class=\"prefPrefsList\">";
3329 print "<tr><td colspan='3'><h3>Personal data</h3></tr></td>";
3330
3331 $result = db_query($link, "SELECT email FROM ttrss_users
3332 WHERE id = ".$_SESSION["uid"]);
3333
3334 $email = db_fetch_result($result, 0, "email");
3335
3336 print "<tr><td width=\"40%\">E-mail</td>";
3337 print "<td><input class=\"editbox\" name=\"email\"
3338 value=\"$email\"></td></tr>";
3339
3340 print "</table>";
3341
3342 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
3343
3344 print "<p><input class=\"button\" type=\"submit\"
3345 value=\"Change e-mail\" name=\"subop\">";
3346
a132b8b1
AD
3347 print "</form>";
3348
7d4c898a
AD
3349 print "<form action=\"backend.php\" method=\"POST\">";
3350
3351 print "<table width=\"100%\" class=\"prefPrefsList\">";
3352 print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>";
3353
3354 print "<tr><td width=\"40%\">Old password</td>";
3355 print "<td><input class=\"editbox\" type=\"password\"
3356 name=\"OLD_PASSWORD\"></td></tr>";
3357
3358 print "<tr><td width=\"40%\">New password</td>";
3359
3360 print "<td><input class=\"editbox\" type=\"password\"
3361 name=\"NEW_PASSWORD\"></td></tr>";
3362
3363 print "</table>";
3364
3365 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
3366
3367 print "<p><input class=\"button\" type=\"submit\"
3368 value=\"Change password\" name=\"subop\">";
3369
3370 print "</form>";
1c7f75ed 3371
7d4c898a 3372 }
1c7f75ed 3373
58f8ad54
AD
3374 $result = db_query($link, "SELECT
3375 theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]);
3376
3377 $user_theme_id = db_fetch_result($result, 0, "theme_id");
3378
3379 $result = db_query($link, "SELECT
3380 id,theme_name FROM ttrss_themes ORDER BY theme_name");
3381
3382 if (db_num_rows($result) > 0) {
6752e330
AD
3383
3384 print "<form action=\"backend.php\" method=\"POST\">";
3385 print "<table width=\"100%\" class=\"prefPrefsList\">";
3386 print "<tr><td colspan='3'><h3>Themes</h3></tr></td>";
3387 print "<tr><td width=\"40%\">Select theme</td>";
3388 print "<td><select name=\"theme\">";
3389 print "<option>Default</option>";
58f8ad54 3390 print "<option disabled>--------</option>";
6752e330 3391
58f8ad54
AD
3392 while ($line = db_fetch_assoc($result)) {
3393 if ($line["id"] == $user_theme_id) {
3394 $selected = "selected";
3395 } else {
3396 $selected = "";
3397 }
3398 print "<option $selected>" . $line["theme_name"] . "</option>";
3399 }
6752e330
AD
3400 print "</select></td></tr>";
3401 print "</table>";
3402 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
3403 print "<p><input class=\"button\" type=\"submit\"
3404 value=\"Change theme\" name=\"subop\">";
3405 print "</form>";
58f8ad54
AD
3406 }
3407
77e96719 3408 $result = db_query($link, "SELECT
ff485f1d 3409 ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
77e96719 3410 section_name,def_value
ff485f1d 3411 FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
77e96719 3412 WHERE type_id = ttrss_prefs_types.id AND
ff485f1d 3413 section_id = ttrss_prefs_sections.id AND
a2411bd9
AD
3414 ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
3415 owner_uid = ".$_SESSION["uid"]."
650bc435 3416 ORDER BY section_id,short_desc");
77e96719
AD
3417
3418 print "<form action=\"backend.php\" method=\"POST\">";
3419
77e96719
AD
3420 $lnum = 0;
3421
3422 $active_section = "";
3423
3424 while ($line = db_fetch_assoc($result)) {
3425
3426 if ($active_section != $line["section_name"]) {
59a654ba
AD
3427
3428 if ($active_section != "") {
1c7f75ed 3429 print "</table>";
59a654ba 3430 }
1c7f75ed
AD
3431
3432 print "<p><table width=\"100%\" class=\"prefPrefsList\">";
59a654ba
AD
3433
3434 $active_section = $line["section_name"];
3435
77e96719 3436 print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>";
59a654ba
AD
3437// print "<tr class=\"title\">
3438// <td width=\"25%\">Option</td><td>Value</td></tr>";
7268adf7
AD
3439
3440 $lnum = 0;
77e96719
AD
3441 }
3442
650bc435 3443// $class = ($lnum % 2) ? "even" : "odd";
77e96719 3444
650bc435 3445 print "<tr>";
77e96719 3446
77e96719
AD
3447 $type_name = $line["type_name"];
3448 $pref_name = $line["pref_name"];
3449 $value = $line["value"];
3450 $def_value = $line["def_value"];
b1895692
AD
3451 $help_text = $line["help_text"];
3452
3453 print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"];
3454
3455 if ($help_text) print "<div class=\"prefHelp\">$help_text</div>";
3456
3457 print "</td>";
77e96719
AD
3458
3459 print "<td>";
3460
3461 if ($type_name == "bool") {
3462// print_select($pref_name, $value, array("true", "false"));
3463
3464 if ($value == "true") {
3465 $value = "Yes";
3466 } else {
3467 $value = "No";
3468 }
3469
3470 print_radio($pref_name, $value, array("Yes", "No"));
3471
3472 } else {
3473 print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">";
3474 }
3475
3476 print "</td>";
3477
3478 print "</tr>";
3479
3480 $lnum++;
3481 }
3482
3483 print "</table>";
3484
3485 print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
3486
3487 print "<p><input class=\"button\" type=\"submit\"
3488 name=\"subop\" value=\"Save configuration\">";
3489
3490 print "&nbsp;<input class=\"button\" type=\"submit\"
69668465
AD
3491 name=\"subop\" onclick=\"return validatePrefsReset()\"
3492 value=\"Reset to defaults\"></p>";
77e96719
AD
3493
3494 print "</form>";
3495
3496 }
3497
3498 }
3499
e6cb77a0
AD
3500 if ($op == "pref-users") {
3501
3502 $subop = $_GET["subop"];
3503
3504 if ($subop == "editSave") {
3505
3506 if (!WEB_DEMO_MODE) {
3507
3508 $login = db_escape_string($_GET["l"]);
3509 $uid = db_escape_string($_GET["id"]);
3510 $access_level = sprintf("%d", $_GET["al"]);
72932a75 3511 $email = db_escape_string($_GET["e"]);
e6cb77a0 3512
72932a75
AD
3513 db_query($link, "UPDATE ttrss_users SET login = '$login',
3514 access_level = '$access_level', email = '$email' WHERE id = '$uid'");
e6cb77a0
AD
3515
3516 }
3517 } else if ($subop == "remove") {
3518
3519 if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) {
3520
f932bc9f 3521 $ids = split(",", db_escape_string($_GET["ids"]));
e6cb77a0
AD
3522
3523 foreach ($ids as $id) {
3524 db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]);
3525
3526 }
3527 }
3528 } else if ($subop == "add") {
3529
3530 if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) {
3531
b6b535ca 3532 $login = db_escape_string(trim($_GET["login"]));
e6cb77a0
AD
3533 $tmp_user_pwd = make_password(8);
3534 $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd);
3535
69c0d759
AD
3536 db_query($link, "INSERT INTO ttrss_users
3537 (login,pwd_hash,access_level,last_login)
3538 VALUES ('$login', '$pwd_hash', 0, NOW())");
e6cb77a0
AD
3539
3540
3541 $result = db_query($link, "SELECT id FROM ttrss_users WHERE
3542 login = '$login' AND pwd_hash = '$pwd_hash'");
3543
3544 if (db_num_rows($result) == 1) {
3545
3546 $new_uid = db_fetch_result($result, 0, "id");
3547
3548 print "<div class=\"notice\">Added user <b>".$_GET["login"].
3549 "</b> with password <b>$tmp_user_pwd</b>.</div>";
3550
3551 initialize_user($link, $new_uid);
3552
3553 } else {
3554
3555 print "<div class=\"warning\">Error while adding user <b>".
3556 $_GET["login"].".</b></div>";
3557
3558 }
3559 }
3560 } else if ($subop == "resetPass") {
3561
3562 if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) {
3563
3564 $uid = db_escape_string($_GET["id"]);
3565
72932a75
AD
3566 $result = db_query($link, "SELECT login,email
3567 FROM ttrss_users WHERE id = '$uid'");
e6cb77a0
AD
3568
3569 $login = db_fetch_result($result, 0, "login");
72932a75 3570 $email = db_fetch_result($result, 0, "email");
e6cb77a0
AD
3571 $tmp_user_pwd = make_password(8);
3572 $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd);
3573
3574 db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash'
3575 WHERE id = '$uid'");
3576
3577 print "<div class=\"notice\">Changed password of
72932a75
AD
3578 user <b>$login</b> to <b>$tmp_user_pwd</b>.";
3579
3580 if (MAIL_RESET_PASS && $email) {
3581 print " Notifying <b>$email</b>.";
3582
3583 mail("$login <$email>", "Password reset notification",
3584 "Hi, $login.\n".
3585 "\n".
3586 "Your password for this TT-RSS installation was reset by".
3587 " an administrator.\n".
3588 "\n".
3589 "Your new password is $tmp_user_pwd, please remember".
3590 " it for later reference.\n".
3591 "\n".
3592 "Sincerely, TT-RSS Mail Daemon.", "From: " . MAIL_FROM);
3593 }
3594
3595 print "</div>";
e6cb77a0
AD
3596
3597 }
3598 }
3599
2c7070b5 3600 print "<div class=\"prefGenericAddBox\">
f932bc9f 3601 <input id=\"uadd_box\" onchange=\"javascript:addUser()\" size=\"40\">&nbsp;";
e6cb77a0 3602
2c7070b5
AD
3603 print"<input type=\"submit\" class=\"button\"
3604 onclick=\"javascript:addUser()\" value=\"Add user\"></div>";
e6cb77a0
AD
3605
3606 $result = db_query($link, "SELECT
72932a75 3607 id,login,access_level,email,
fe99ab12 3608 SUBSTRING(last_login,1,16) as last_login
e6cb77a0
AD
3609 FROM
3610 ttrss_users
3611 ORDER by login");
3612
2317ffaa 3613 print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1a7572cb 3614
f4fe2cde
AD
3615 print "<p><table width=\"100%\" cellspacing=\"0\"
3616 class=\"prefUserList\" id=\"prefUserList\">";
e6cb77a0 3617
35f3c923
AD
3618 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
3619 Select:
3620 <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList',
3055bc41 3621 'UMRR-', 'UMCHK-', true)\">All</a>,
35f3c923 3622 <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList',
3055bc41 3623 'UMRR-', 'UMCHK-', false)\">None</a>
35f3c923
AD
3624 </td</tr>";
3625
e6cb77a0 3626 print "<tr class=\"title\">
e325c6e7 3627 <td align='center' width=\"5%\">&nbsp;</td>
72932a75
AD
3628 <td width='20%'>Username</td>
3629 <td width='20%'>E-mail</td>
3630 <td width='20%'>Access Level</td>
3631 <td width='20%'>Last login</td></tr>";
e6cb77a0
AD
3632
3633 $lnum = 0;
3634
3635 while ($line = db_fetch_assoc($result)) {
3636
3637 $class = ($lnum % 2) ? "even" : "odd";
3638
3639 $uid = $line["id"];
3640 $edit_uid = $_GET["id"];
3641
4154a415 3642 if ($subop == "edit" && $uid != $edit_uid) {
e6cb77a0 3643 $class .= "Grayed";
53226edc
AD
3644 $this_row_id = "";
3645 } else {
3646 $this_row_id = "id=\"UMRR-$uid\"";
3647 }
3648
3649 print "<tr class=\"$class\" $this_row_id>";
e6cb77a0
AD
3650
3651 $line["login"] = htmlspecialchars($line["login"]);
3652
6be6bc03
AD
3653 $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'),
3654 strtotime($line["last_login"]));
3655
5917a8e4
AD
3656 $access_level_names = array(0 => "User", 10 => "Administrator");
3657
72932a75 3658/* if ($uid == $_SESSION["uid"]) {
e6cb77a0 3659
a426e532 3660 print "<td align='center'><input disabled=\"true\" type=\"checkbox\"
e6cb77a0
AD
3661 id=\"UMCHK-".$line["id"]."\"></td>";
3662
72932a75
AD
3663 print "<td>".$line["login"]."</td>";
3664 print "<td>".$line["email"]."</td>";
3665 print "<td>".$line["access_level"]."</td>";
e6cb77a0 3666
72932a75 3667 } else */ if (!$edit_uid || $subop != "edit") {
e6cb77a0 3668
a426e532 3669 print "<td align='center'><input onclick='toggleSelectRow(this);'
1a7572cb 3670 type=\"checkbox\" id=\"UMCHK-$uid\"></td>";
e6cb77a0
AD
3671
3672 print "<td><a href=\"javascript:editUser($uid);\">" .
3673 $line["login"] . "</td>";
72932a75
AD
3674
3675 print "<td><a href=\"javascript:editUser($uid);\">" .
3676 $line["email"] . "</td>";
3677
e6cb77a0 3678 print "<td><a href=\"javascript:editUser($uid);\">" .
5917a8e4 3679 $access_level_names[$line["access_level"]] . "</td>";
e6cb77a0
AD
3680
3681 } else if ($uid != $edit_uid) {
3682
72932a75 3683 print "<td align='center'><input disabled=\"true\" type=\"checkbox\"
e6cb77a0
AD
3684 id=\"UMCHK-".$line["id"]."\"></td>";
3685
3686 print "<td>".$line["login"]."</td>";
72932a75 3687 print "<td>".$line["email"]."</td>";
5917a8e4 3688 print "<td>".$access_level_names[$line["access_level"]]."</td>";
e6cb77a0
AD
3689
3690 } else {
3691
72932a75
AD
3692 print "<td align='center'>
3693 <input disabled=\"true\" type=\"checkbox\" checked></td>";
e6cb77a0
AD
3694
3695 print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"].
3696 "\"></td>";
3697
72932a75
AD
3698 print "<td><input id=\"iedit_email\" value=\"".$line["email"].
3699 "\"></td>";
3700
5917a8e4
AD
3701// print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"].
3702// "\"></td>";
3703
3704 print "<td>";
3705 print "<select id=\"iedit_ulevel\">";
3706 foreach (array_keys($access_level_names) as $al) {
3707 if ($al == $line["access_level"]) {
3708 $selected = "selected";
3709 } else {
3710 $selected = "";
3711 }
3712 print "<option $selected id=\"$al\">" .
3713 $access_level_names[$al] . "</option>";
3714 }
3715 print "</select>";
3716 print "</td>";
3717
e6cb77a0
AD
3718 }
3719
f6f32198
AD
3720 print "<td>".$line["last_login"]."</td>";
3721
e6cb77a0
AD
3722 print "</tr>";
3723
3724 ++$lnum;
3725 }
3726
3727 print "</table>";
3728
3729 print "<p>";
3730
3731 if ($subop == "edit") {
d10fabe4 3732 print "Edit user:
e6cb77a0 3733 <input type=\"submit\" class=\"button\"
d10fabe4 3734 onclick=\"javascript:userEditSave()\" value=\"Save\">
e6cb77a0 3735 <input type=\"submit\" class=\"button\"
d10fabe4 3736 onclick=\"javascript:userEditCancel()\" value=\"Cancel\">";
e6cb77a0
AD
3737
3738 } else {
3739
3740 print "
3741 Selection:
3742 <input type=\"submit\" class=\"button\"
717f5e64 3743 onclick=\"javascript:selectedUserDetails()\" value=\"User details\">
e6cb77a0
AD
3744 <input type=\"submit\" class=\"button\"
3745 onclick=\"javascript:editSelectedUser()\" value=\"Edit\">
3746 <input type=\"submit\" class=\"button\"
717f5e64
AD
3747 onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\">
3748 <input type=\"submit\" class=\"button\"
3749 onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">";
3750
3751 }
3752 }
3753
3754 if ($op == "user-details") {
3755
3756 if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) {
3757 return;
3758 }
3759
1a7572cb 3760/* print "<html><head>
717f5e64
AD
3761 <title>Tiny Tiny RSS : User Details</title>
3762 <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
3763 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
1a7572cb 3764 </head><body>"; */
717f5e64
AD
3765
3766 $uid = sprintf("%d", $_GET["id"]);
3767
c6c3a07f 3768 print "<div class='infoBoxContents'>";
717f5e64 3769
fe99ab12
AD
3770 $result = db_query($link, "SELECT login,
3771 SUBSTRING(last_login,1,16) AS last_login,
3772 access_level,
c6c3a07f
AD
3773 (SELECT COUNT(int_id) FROM ttrss_user_entries
3774 WHERE owner_uid = id) AS stored_articles
717f5e64
AD
3775 FROM ttrss_users
3776 WHERE id = '$uid'");
3777
3778 if (db_num_rows($result) == 0) {
3779 print "<h1>User not found</h1>";
3780 return;
3781 }
3782
3783 print "<h1>User Details</h1>";
3784
3785 print "<table width='100%'>";
3786
3787 $login = db_fetch_result($result, 0, "login");
6be6bc03
AD
3788 $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'),
3789 strtotime(db_fetch_result($result, 0, "last_login")));
717f5e64 3790 $access_level = db_fetch_result($result, 0, "access_level");
c6c3a07f 3791 $stored_articles = db_fetch_result($result, 0, "stored_articles");
717f5e64
AD
3792
3793 print "<tr><td>Username</td><td>$login</td></tr>";
3794 print "<tr><td>Access level</td><td>$access_level</td></tr>";
3795 print "<tr><td>Last logged in</td><td>$last_login</td></tr>";
c6c3a07f 3796 print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>";
717f5e64
AD
3797
3798 $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds
3799 WHERE owner_uid = '$uid'");
3800
3801 $num_feeds = db_fetch_result($result, 0, "num_feeds");
3802
3803 print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>";
3804
5d15d3ea 3805/* $result = db_query($link, "SELECT
717f5e64 3806 SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size
c6c3a07f
AD
3807 FROM ttrss_user_entries,ttrss_entries
3808 WHERE owner_uid = '$uid' AND ref_id = id");
717f5e64 3809
d9f115c3 3810 $db_size = round(db_fetch_result($result, 0, "db_size") / 1024);
717f5e64 3811
c6c3a07f 3812 print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */
717f5e64
AD
3813
3814 print "</table>";
3815
3816 print "<h1>Subscribed feeds</h1>";
3817
e94645ca 3818 $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds
9b3e2cc7 3819 WHERE owner_uid = '$uid' ORDER BY title");
717f5e64 3820
9b3e2cc7 3821 print "<ul class=\"userFeedList\">";
717f5e64
AD
3822
3823 while ($line = db_fetch_assoc($result)) {
3824
3825 $icon_file = ICONS_URL."/".$line["id"].".ico";
3826
3827 if (file_exists($icon_file) && filesize($icon_file) > 0) {
6c56687e 3828 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">";
717f5e64 3829 } else {
5951ded1 3830 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
717f5e64
AD
3831 }
3832
e94645ca 3833 print "<li>$feed_icon&nbsp;<a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>";
e6cb77a0 3834 }
717f5e64 3835
a88c1f36
AD
3836 if (db_num_rows($result) < $num_feeds) {
3837 // FIXME - add link to show ALL subscribed feeds here somewhere
3838 print "<li><img
3839 class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">&nbsp;...</li>";
3840 }
3841
717f5e64
AD
3842 print "</ul>";
3843
717f5e64
AD
3844 print "</div>";
3845
1a7572cb
AD
3846 print "<div align='center'>
3847 <input type='submit' class='button'
c6c3a07f 3848 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
1a7572cb
AD
3849
3850// print "</body></html>";
717f5e64 3851
e6cb77a0
AD
3852 }
3853
c6c3a07f
AD
3854 if ($op == "feed-details") {
3855
df268d47 3856// $feed_id = $_GET["id"];
4fec9fd7 3857
df268d47 3858 $feed_ids = split(",", db_escape_string($_GET["id"]));
c6c3a07f 3859
df268d47 3860 print "<div class=\"infoBoxContents\">";
bca02305 3861
df268d47 3862 foreach ($feed_ids as $feed_id) {
c6c3a07f 3863
df268d47
AD
3864 $result = db_query($link,
3865 "SELECT
3866 title,feed_url,
3867 SUBSTRING(last_updated,1,16) as last_updated,
3868 icon_url,site_url,
3869 (SELECT COUNT(int_id) FROM ttrss_user_entries
3870 WHERE feed_id = id) AS total,
3871 (SELECT COUNT(int_id) FROM ttrss_user_entries
3872 WHERE feed_id = id AND unread = true) AS unread,
3873 (SELECT COUNT(int_id) FROM ttrss_user_entries
3874 WHERE feed_id = id AND marked = true) AS marked
3875 FROM ttrss_feeds
3876 WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
3877
3878 if (db_num_rows($result) == 0) return;
3879
3880 $title = db_unescape_string(db_fetch_result($result, 0, "title"));
3881 $last_updated = date(get_pref($link, 'LONG_DATE_FORMAT'),
3882 strtotime(db_fetch_result($result, 0, "last_updated")));
3883 $feed_url = db_fetch_result($result, 0, "feed_url");
3884 $icon_url = db_fetch_result($result, 0, "icon_url");
3885 $total = db_fetch_result($result, 0, "total");
3886 $unread = db_fetch_result($result, 0, "unread");
3887 $marked = db_fetch_result($result, 0, "marked");
3888 $site_url = db_fetch_result($result, 0, "site_url");
bca02305 3889
df268d47 3890 $result = db_query($link, "SELECT COUNT(id) AS subscribed
3803fa6a 3891 FROM ttrss_feeds WHERE feed_url = '$feed_url' AND private = false");
df268d47
AD
3892
3893 $subscribed = db_fetch_result($result, 0, "subscribed");
3894
3895 $icon_file = ICONS_DIR . "/$feed_id.ico";
3896
3897 if (file_exists($icon_file) && filesize($icon_file) > 0) {
3898 $feed_icon = "<img width=\"16\" height=\"16\"
3899 src=\"" . ICONS_URL . "/$feed_id.ico\">";
3900 } else {
3901 $feed_icon = "";
bca02305
AD
3902 }
3903
df268d47 3904 print "<h1>$feed_icon $title</h1>";
bca02305 3905
df268d47 3906 print "<table width='100%'>";
bca02305 3907
df268d47
AD
3908 if ($site_url) {
3909 print "<tr><td width='30%'>Link</td>
3910 <td><a href=\"$site_url\">$site_url</a>
3911 <a href=\"$feed_url\">(feed)</a></td>
3912 </td></tr>";
3913 } else {
3914 print "<tr><td width='30%'>Feed URL</td>
3915 <td><a href=\"$feed_url\">$feed_url</a></td></tr>";
3916 }
3917 print "<tr><td>Last updated</td><td>$last_updated</td></tr>";
3918 print "<tr><td>Total articles</td><td>$total</td></tr>";
3919 print "<tr><td>Unread articles</td><td>$unread</td></tr>";
3920 print "<tr><td>Starred articles</td><td>$marked</td></tr>";
3921 print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>";
3922
3923 print "</table>";
3924
3925/* $result = db_query($link, "SELECT title,
3926 SUBSTRING(updated,1,16) AS updated,unread
3927 FROM ttrss_entries,ttrss_user_entries
3928 WHERE ref_id = id AND feed_id = '$feed_id'
3929 ORDER BY date_entered DESC LIMIT 5");
3930
3931 if (db_num_rows($result) > 0) {
3932
3933 print "<h1>Latest headlines</h1>";
3934
3935 print "<ul class=\"nomarks\">";
3936
3937 while ($line = db_fetch_assoc($result)) {
3938 if ($line["unread"] == "t" || $line["unread"] == "1") {
3939 $line["title"] = "<b>" . $line["title"] . "</b>";
3940 }
3941 print "<li>" . $line["title"].
3942 "&nbsp;<span class=\"insensitive\">(" .
3943 date(get_pref($link, 'SHORT_DATE_FORMAT'),
3944 strtotime($line["updated"])).
3945 ")</span></li>";
3946 }
3947
3948 print "</ul>";
3949
3950 } */
bca02305 3951 }
df268d47
AD
3952
3953 print "</div>";
3954
3955 print "<div align='center'>
3956 <input type='submit' class='button'
3957 onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
3958 }
c6c3a07f 3959
c6232e43
AD
3960 if ($op == "pref-feed-browser") {
3961
e2f728be
AD
3962 if (!ENABLE_FEED_BROWSER) {
3963 print "Feed browser is administratively disabled.";
3964 return;
3965 }
3966
c6232e43
AD
3967 $subop = $_REQUEST["subop"];
3968
3969 if ($subop == "details") {
3970 $id = db_escape_string($_GET["id"]);
c2b2aee0 3971
072f1ee2
AD
3972 print "<div class=\"browserFeedInfo\">";
3973 print "<b>Feed information:</b>";
3974 print "<div class=\"detailsPart\">";
3975
3976 $result = db_query($link, "SELECT
3977 feed_url,site_url,
3978 SUBSTRING(last_updated,1,19) AS last_updated
3979 FROM ttrss_feeds WHERE id = '$id'");
3980
3981 $feed_url = db_fetch_result($result, 0, "feed_url");
3982 $site_url = db_fetch_result($result, 0, "site_url");
3983 $last_updated = db_fetch_result($result, 0, "last_updated");
3984
3985 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
3986 $last_updated = smart_date_time(strtotime($last_updated));
3987 } else {
3988 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
3989 $last_updated = date($short_date, strtotime($last_updated));
3990 }
3991
3992 print "Site: <a href='$site_url'>$site_url</a> ".
3993 "(<a href='$feed_url'>feed</a>), ".
3994 "Last updated: $last_updated";
3995
3996 print "</div>";
3997
3998 $result = db_query($link, "SELECT
3999 ttrss_entries.title,
4000 content,
c2b2aee0
AD
4001 substring(date_entered,1,19) as date_entered,
4002 substring(updated,1,19) as updated
072f1ee2
AD
4003 FROM ttrss_entries,ttrss_user_entries
4004 WHERE ttrss_entries.id = ref_id AND feed_id = '$id'
c2b2aee0
AD
4005 ORDER BY updated DESC LIMIT 5");
4006
4007 if (db_num_rows($result) > 0) {
c2b2aee0
AD
4008
4009 print "<b>Last headlines:</b><br>";
4010
4011 print "<div class=\"detailsPart\">";
4012 print "<ul class=\"compact\">";
4013 while ($line = db_fetch_assoc($result)) {
4014
4015 if (get_pref($link, 'HEADLINES_SMART_DATE')) {
4016 $entry_dt = smart_date_time(strtotime($line["updated"]));
4017 } else {
4018 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
4019 $entry_dt = date($short_date, strtotime($line["updated"]));
4020 }
4021
4022 print "<li>" . $line["title"] .
4023 "&nbsp;<span class=\"insensitive\">($entry_dt)</span></li>";
4024 }
4025 print "</ul></div>";
4026 }
072f1ee2
AD
4027
4028 print "</div>";
c2b2aee0 4029
c6232e43
AD
4030 return;
4031 }
65f28a40 4032
c6232e43
AD
4033 $result = db_query($link, "SELECT feed_url,count(id) AS subscribers
4034 FROM ttrss_feeds
4035 WHERE auth_login = '' AND auth_pass = '' AND private = false
65f28a40 4036 GROUP BY feed_url ORDER BY subscribers DESC LIMIT 100");
c6232e43 4037
0fefdacc 4038 print "<ul class='nomarks' id='browseBigFeedList'>";
c6232e43
AD
4039
4040 $feedctr = 0;
4041
4042 while ($line = db_fetch_assoc($result)) {
4043 $feed_url = $line["feed_url"];
4044 $subscribers = $line["subscribers"];
4045
4046 $sub_result = db_query($link, "SELECT id
4047 FROM ttrss_feeds WHERE feed_url = '$feed_url' AND owner_uid =" .
4048 $_SESSION["uid"]);
4049
4050 if (db_num_rows($sub_result) > 0) {
4051 continue; // already subscribed
4052 }
4053
4054 $det_result = db_query($link, "SELECT site_url,title,id
4055 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
4056
4057 $details = db_fetch_assoc($det_result);
4058
4059 $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
4060
4061 if (file_exists($icon_file) && filesize($icon_file) > 0) {
4062 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
4063 "/".$details["id"].".ico\">";
4064 } else {
4065 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
4066 }
4067
4068 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
4069 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
4070
4071 $class = ($feedctr % 2) ? "even" : "odd";
4072
4073 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
4074 "$feed_icon ";
4075
c2b2aee0 4076 print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" .
c6232e43
AD
4077 $details["title"] ."</a>&nbsp;" .
4078 "<span class='subscribers'>($subscribers)</span>";
4079
4080 print "<div class=\"browserDetails\" id=\"BRDET-" . $details["id"] . "\">";
4081 print "</div>";
4082
4083 print "</li>";
4084
4085 ++$feedctr;
4086 }
4087
4088 if ($feedctr == 0) {
4089 print "<li>No feeds found to subscribe.</li>";
4090 }
4091
4092 print "</ul>";
4093
0010d872
AD
4094 print "<p>Selection:
4095 <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\"
4096 value=\"Subscribe\"></p>";
c6232e43
AD
4097
4098 print "</div>";
4099
4100 }
4101
4b3dff6e 4102 db_close($link);
1cd17194 4103?>
406d9489
AD
4104
4105<!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> -->
4106