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