]> git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
531396cf5b45af2d94691d55c6e886b72be5ef4a
[tt-rss.git] / modules / pref-feeds.php
1 <?php
2
3 function batch_edit_cbox($elem, $label = false) {
4 print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
5 onchange=\"batchFeedsToggleField(this, '$elem', '$label')\">";
6 }
7
8 function module_pref_feeds($link) {
9
10 global $update_intervals;
11 global $purge_intervals;
12 global $update_methods;
13
14 $subop = $_REQUEST["subop"];
15 $quiet = $_REQUEST["quiet"];
16 $mode = $_REQUEST["mode"];
17
18 /* if ($subop == "massSubscribe") {
19 $ids = split(",", db_escape_string($_REQUEST["ids"]));
20
21 $subscribed = array();
22
23 foreach ($ids as $id) {
24
25 if ($mode == 1) {
26 $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds
27 WHERE id = '$id'");
28 } else if ($mode == 2) {
29 $result = db_query($link, "SELECT * FROM ttrss_archived_feeds
30 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
31 $orig_id = db_escape_string(db_fetch_result($result, 0, "id"));
32 $site_url = db_escape_string(db_fetch_result($result, 0, "site_url"));
33 }
34
35 $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url"));
36 $title = db_escape_string(db_fetch_result($result, 0, "title"));
37
38 $title_orig = db_fetch_result($result, 0, "title");
39
40 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
41 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
42
43 if (db_num_rows($result) == 0) {
44 if ($mode == 1) {
45 $result = db_query($link,
46 "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
47 VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
48 } else if ($mode == 2) {
49 $result = db_query($link,
50 "INSERT INTO ttrss_feeds (id,owner_uid,feed_url,title,cat_id,site_url)
51 VALUES ('$orig_id','".$_SESSION["uid"]."', '$feed_url', '$title', NULL, '$site_url')");
52 }
53 array_push($subscribed, $title_orig);
54 }
55 }
56
57 if (count($subscribed) > 0) {
58 $msg = "<b>".__('Subscribed to feeds:')."</b>".
59 "<ul class=\"nomarks\">";
60
61 foreach ($subscribed as $title) {
62 $msg .= "<li>$title</li>";
63 }
64 $msg .= "</ul>";
65
66 print format_notice($msg);
67 }
68
69 return;
70 } */
71
72 /* if ($subop == "browse") {
73
74 print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
75
76 print "<div class=\"infoBoxContents\">";
77
78 $browser_search = db_escape_string($_REQUEST["search"]);
79
80 //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
81
82 print "<form onsubmit='return false;' display='inline' name='feed_browser' id='feed_browser'>";
83
84 print "
85 <div style='float : right'>
86 <img style='display : none'
87 id='feed_browser_spinner' src='images/indicator_white.gif'>
88 <input name=\"search\" size=\"20\" type=\"search\"
89 onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
90 <button onclick=\"javascript:updateFeedBrowser()\">".__('Search')."</button>
91 </div>";
92
93 print " <select name=\"mode\" onchange=\"updateFeedBrowser()\">
94 <option value='1'>" . __('Popular feeds') . "</option>
95 <option value='2'>" . __('Feed archive') . "</option>
96 </select> ";
97
98 print __("limit:");
99
100 print " <select name=\"limit\" onchange='updateFeedBrowser()'>";
101
102 foreach (array(25, 50, 100, 200) as $l) {
103 $issel = ($l == $limit) ? "selected" : "";
104 print "<option $issel>$l</option>";
105 }
106
107 print "</select> ";
108
109 print "<p>";
110
111 $owner_uid = $_SESSION["uid"];
112
113 print "<ul class='browseFeedList' id='browseFeedList'>";
114 print_feed_browser($link, $search, 25);
115 print "</ul>";
116
117 print "<div align='center'>
118 <button onclick=\"feedBrowserSubscribe()\">".__('Subscribe')."</button>
119 <button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
120
121 print "</div>";
122 return;
123 } */
124
125 if ($subop == "editfeed") {
126 $feed_id = db_escape_string($_REQUEST["id"]);
127
128 $result = db_query($link,
129 "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
130 owner_uid = " . $_SESSION["uid"]);
131
132 $title = htmlspecialchars(db_fetch_result($result,
133 0, "title"));
134
135 $icon_file = ICONS_DIR . "/$feed_id.ico";
136
137 if (file_exists($icon_file) && filesize($icon_file) > 0) {
138 $feed_icon = "<img width=\"16\" height=\"16\"
139 src=\"" . ICONS_URL . "/$feed_id.ico\">";
140 } else {
141 $feed_icon = "";
142 }
143
144 print "<div id=\"infoBoxTitle\">".__('Feed Editor')."</div>";
145
146 print "<div class=\"infoBoxContents\">";
147
148 print "<form id=\"edit_feed_form\" onsubmit=\"return false\">";
149
150 print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">";
151 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
152 print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
153
154 print "<div class=\"dlgSec\">".__("Feed")."</div>";
155 print "<div class=\"dlgSecCont\">";
156
157 /* Title */
158
159 print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
160 name=\"title\" value=\"$title\">";
161
162 /* Feed URL */
163
164 $feed_url = db_fetch_result($result, 0, "feed_url");
165 $feed_url = htmlspecialchars(db_fetch_result($result,
166 0, "feed_url"));
167
168 print "<br/>";
169
170 print __('URL:') . " ";
171 print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
172 name=\"feed_url\" value=\"$feed_url\">";
173
174 /* Category */
175
176 if (get_pref($link, 'ENABLE_FEED_CATS')) {
177
178 $cat_id = db_fetch_result($result, 0, "cat_id");
179
180 print "<br/>";
181
182 print __('Place in category:') . " ";
183
184 $parent_feed = db_fetch_result($result, 0, "parent_feed");
185
186 if (sprintf("%d", $parent_feed) > 0) {
187 $disabled = "disabled";
188 } else {
189 $disabled = "";
190 }
191
192 print_feed_cat_select($link, "cat_id", $cat_id, $disabled);
193 }
194
195 /* Link to */
196
197 print "<br/>";
198
199 print __('Link to feed:') . " ";
200
201 $tmp_result = db_query($link, "SELECT COUNT(id) AS count
202 FROM ttrss_feeds WHERE parent_feed = '$feed_id'");
203
204 $linked_count = db_fetch_result($tmp_result, 0, "count");
205
206 $parent_feed = db_fetch_result($result, 0, "parent_feed");
207
208 if ($linked_count > 0) {
209 $disabled = "disabled";
210 } else {
211 $disabled = "";
212 }
213
214 print "<select $disabled name=\"parent_feed\">";
215
216 print "<option value=\"0\">".__('Not linked')."</option>";
217
218 if (get_pref($link, 'ENABLE_FEED_CATS')) {
219 if ($cat_id) {
220 $cat_qpart = "AND cat_id = '$cat_id'";
221 } else {
222 $cat_qpart = "AND cat_id IS NULL";
223 }
224 }
225
226 $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds
227 WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." AND
228 (SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0
229 $cat_qpart ORDER BY title");
230
231 if (db_num_rows($tmp_result) > 0) {
232 print "<option disabled>--------</option>";
233 }
234
235 while ($tmp_line = db_fetch_assoc($tmp_result)) {
236 if ($tmp_line["id"] == $parent_feed) {
237 $is_selected = "selected";
238 } else {
239 $is_selected = "";
240 }
241
242 $linked_title = truncate_string(htmlspecialchars($tmp_line["title"]), 40);
243
244 printf("<option $is_selected value='%d'>%s</option>",
245 $tmp_line["id"], $linked_title);
246 }
247
248 print "</select>";
249
250
251 print "</div>";
252
253 print "<div class=\"dlgSec\">".__("Update")."</div>";
254 print "<div class=\"dlgSecCont\">";
255
256 /* Update Interval */
257
258 $update_interval = db_fetch_result($result, 0, "update_interval");
259
260 print_select_hash("update_interval", $update_interval, $update_intervals);
261
262 /* Update method */
263
264 if (ALLOW_SELECT_UPDATE_METHOD) {
265 $update_method = db_fetch_result($result, 0, "update_method");
266
267 print " " . __('using') . " ";
268 print_select_hash("update_method", $update_method, $update_methods);
269 }
270
271 $purge_interval = db_fetch_result($result, 0, "purge_interval");
272
273 if (FORCE_ARTICLE_PURGE == 0) {
274
275 /* Purge intl */
276
277 print "<br/>";
278
279 print __('Article purging:') . " ";
280
281 print_select_hash("purge_interval", $purge_interval, $purge_intervals);
282
283 } else {
284 print "<input type='hidden' name='purge_interval' value='$purge_interval'>";
285
286 }
287
288 print "</div>";
289 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
290 print "<div class=\"dlgSecCont\">";
291
292 $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
293
294 print "<table>";
295
296 print "<tr><td>" . __('Login:') . "</td><td>";
297
298 print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\"
299 name=\"auth_login\" value=\"$auth_login\">";
300
301 print "</tr><tr><td>" . __("Password:") . "</td><td>";
302
303 $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass"));
304
305 print "<input size=\"20\" type=\"password\" name=\"auth_pass\"
306 onkeypress=\"return filterCR(event, feedEditSave)\"
307 value=\"$auth_pass\">";
308
309 print "</td></tr></table>";
310
311 print "</div>";
312 print "<div class=\"dlgSec\">".__("Options")."</div>";
313 print "<div class=\"dlgSecCont\">";
314
315 print "<div style=\"line-height : 100%\">";
316
317 $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
318
319 if ($private) {
320 $checked = "checked";
321 } else {
322 $checked = "";
323 }
324
325 print "<input type=\"checkbox\" name=\"private\" id=\"private\"
326 $checked>&nbsp;<label for=\"private\">".__('Hide from Popular feeds')."</label>";
327
328 $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
329
330 if ($rtl_content) {
331 $checked = "checked";
332 } else {
333 $checked = "";
334 }
335
336 print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
337 $checked>&nbsp;<label for=\"rtl_content\">".__('Right-to-left content')."</label>";
338
339 $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
340
341 if ($include_in_digest) {
342 $checked = "checked";
343 } else {
344 $checked = "";
345 }
346
347 print "<br/><input type=\"checkbox\" id=\"include_in_digest\"
348 name=\"include_in_digest\"
349 $checked>&nbsp;<label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
350
351
352 $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
353
354 if ($always_display_enclosures) {
355 $checked = "checked";
356 } else {
357 $checked = "";
358 }
359
360 print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\"
361 name=\"always_display_enclosures\"
362 $checked>&nbsp;<label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
363
364
365 $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
366
367 if ($cache_images) {
368 $checked = "checked";
369 } else {
370 $checked = "";
371 }
372
373 if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
374 $disabled = "";
375 $label_class = "";
376 } else {
377 $disabled = "disabled";
378 $label_class = "class='insensitive'";
379 }
380
381 print "<br/><input type=\"checkbox\" id=\"cache_images\"
382 name=\"cache_images\" $disabled
383 $checked>&nbsp;<label $label_class for=\"cache_images\">".
384 __('Cache images locally')."</label>";
385
386
387 print "</div>";
388 print "</div>";
389
390 print "</form>";
391
392 $title = htmlspecialchars($title, ENT_QUOTES);
393
394 print "<div class='dlgButtons'>
395 <div style=\"float : left\">
396 <button onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
397 __('Unsubscribe')."</button>
398 </div>
399 <button onclick=\"return feedEditSave()\">".__('Save')."</button>
400 <button onclick=\"return feedEditCancel()\">".__('Cancel')."</button>
401 </div>";
402
403 return;
404 }
405
406 if ($subop == "editfeeds") {
407
408 $feed_ids = db_escape_string($_REQUEST["ids"]);
409
410 print "<div id=\"infoBoxTitle\">".__('Multiple Feed Editor')."</div>";
411
412 print "<div class=\"infoBoxContents\">";
413
414 print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";
415
416 print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">";
417 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
418 print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">";
419
420 print "<div class=\"dlgSec\">".__("Feed")."</div>";
421 print "<div class=\"dlgSecCont\">";
422
423 /* Title */
424
425 print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\"
426 name=\"title\" value=\"$title\">";
427
428 batch_edit_cbox("title");
429
430 /* Feed URL */
431
432 print "<br/>";
433
434 print __('URL:') . " ";
435 print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
436 name=\"feed_url\" value=\"$feed_url\">";
437
438 batch_edit_cbox("feed_url");
439
440 /* Category */
441
442 if (get_pref($link, 'ENABLE_FEED_CATS')) {
443
444 print "<br/>";
445
446 print __('Place in category:') . " ";
447
448 print_feed_cat_select($link, "cat_id", $cat_id, "disabled");
449
450 batch_edit_cbox("cat_id");
451
452 }
453
454 print "</div>";
455
456 print "<div class=\"dlgSec\">".__("Update")."</div>";
457 print "<div class=\"dlgSecCont\">";
458
459 /* Update Interval */
460
461 print_select_hash("update_interval", $update_interval, $update_intervals,
462 "disabled");
463
464 batch_edit_cbox("update_interval");
465
466 /* Update method */
467
468 if (ALLOW_SELECT_UPDATE_METHOD) {
469 print " " . __('using') . " ";
470 print_select_hash("update_method", $update_method, $update_methods,
471 "disabled");
472 batch_edit_cbox("update_method");
473 }
474
475 /* Purge intl */
476
477 if (FORCE_ARTICLE_PURGE != 0) {
478
479 print "<br/>";
480
481 print __('Article purging:') . " ";
482
483 print_select_hash("purge_interval", $purge_interval, $purge_intervals,
484 "disabled");
485
486 batch_edit_cbox("purge_interval");
487 }
488
489 print "</div>";
490 print "<div class=\"dlgSec\">".__("Authentication")."</div>";
491 print "<div class=\"dlgSecCont\">";
492
493 print __('Login:') . " ";
494 print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\"
495 name=\"auth_login\" value=\"$auth_login\">";
496
497 batch_edit_cbox("auth_login");
498
499 print " " . __("Password:") . " ";
500
501 print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\"
502 onkeypress=\"return filterCR(event, feedEditSave)\"
503 value=\"$auth_pass\">";
504
505 batch_edit_cbox("auth_pass");
506
507 print "</div>";
508 print "<div class=\"dlgSec\">".__("Options")."</div>";
509 print "<div class=\"dlgSecCont\">";
510
511 print "<div style=\"line-height : 100%\">";
512
513 print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\"
514 $checked>&nbsp;<label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>";
515
516 print "&nbsp;"; batch_edit_cbox("private", "private_l");
517
518 print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
519 $checked>&nbsp;<label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
520
521 print "&nbsp;"; batch_edit_cbox("rtl_content", "rtl_content_l");
522
523 print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\"
524 name=\"include_in_digest\"
525 $checked>&nbsp;<label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
526
527 print "&nbsp;"; batch_edit_cbox("include_in_digest", "include_in_digest_l");
528
529 print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\"
530 name=\"always_display_enclosures\"
531 $checked>&nbsp;<label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
532
533 print "&nbsp;"; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
534
535 print "<br/><input disabled type=\"checkbox\" id=\"cache_images\"
536 name=\"cache_images\"
537 $checked>&nbsp;<label class='insensitive' id=\"cache_images_l\"
538 for=\"cache_images\">".
539 __('Cache images locally')."</label>";
540
541
542 if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
543 print "&nbsp;"; batch_edit_cbox("cache_images", "cache_images_l");
544 }
545
546 print "</div>";
547 print "</div>";
548
549 print "</form>";
550
551 print "<div class='dlgButtons'>
552 <input type=\"submit\" class=\"button\"
553 onclick=\"return feedsEditSave()\" value=\"".__('Save')."\">
554 <input type='submit' class='button'
555 onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\">
556 </div>";
557
558 return;
559 }
560
561 if ($subop == "editSave" || $subop == "batchEditSave") {
562
563 $feed_title = db_escape_string(trim($_POST["title"]));
564 $feed_link = db_escape_string(trim($_POST["feed_url"]));
565 $upd_intl = db_escape_string($_POST["update_interval"]);
566 $purge_intl = db_escape_string($_POST["purge_interval"]);
567 $feed_id = db_escape_string($_POST["id"]); /* editSave */
568 $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */
569 $cat_id = db_escape_string($_POST["cat_id"]);
570 $auth_login = db_escape_string(trim($_POST["auth_login"]));
571 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
572 $parent_feed = db_escape_string($_POST["parent_feed"]);
573 $private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
574 $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"]));
575 $include_in_digest = checkbox_to_sql_bool(
576 db_escape_string($_POST["include_in_digest"]));
577 $cache_images = checkbox_to_sql_bool(
578 db_escape_string($_POST["cache_images"]));
579 $update_method = (int) db_escape_string($_POST["update_method"]);
580
581 $always_display_enclosures = checkbox_to_sql_bool(
582 db_escape_string($_POST["always_display_enclosures"]));
583
584 if (get_pref($link, 'ENABLE_FEED_CATS')) {
585 if ($cat_id && $cat_id != 0) {
586 $category_qpart = "cat_id = '$cat_id',";
587 $category_qpart_nocomma = "cat_id = '$cat_id'";
588 } else {
589 $category_qpart = 'cat_id = NULL,';
590 $category_qpart_nocomma = 'cat_id = NULL';
591 }
592 } else {
593 $category_qpart = "";
594 $category_qpart_nocomma = "";
595 }
596
597 if ($parent_feed && $parent_feed != 0) {
598 $parent_qpart = "parent_feed = '$parent_feed'";
599 } else {
600 $parent_qpart = 'parent_feed = NULL';
601 }
602
603 if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
604 $cache_images_qpart = "cache_images = $cache_images,";
605 } else {
606 $cache_images_qpart = "";
607 }
608
609 if ($subop == "editSave") {
610
611 $result = db_query($link, "UPDATE ttrss_feeds SET
612 $category_qpart $parent_qpart,
613 title = '$feed_title', feed_url = '$feed_link',
614 update_interval = '$upd_intl',
615 purge_interval = '$purge_intl',
616 auth_login = '$auth_login',
617 auth_pass = '$auth_pass',
618 private = $private,
619 rtl_content = $rtl_content,
620 $cache_images_qpart
621 include_in_digest = $include_in_digest,
622 always_display_enclosures = $always_display_enclosures,
623 update_method = '$update_method'
624 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
625
626 if (get_pref($link, 'ENABLE_FEED_CATS')) {
627 # update linked feed categories
628 $result = db_query($link, "UPDATE ttrss_feeds SET
629 $category_qpart_nocomma WHERE parent_feed = '$feed_id' AND
630 owner_uid = " . $_SESSION["uid"]);
631 }
632 } else if ($subop == "batchEditSave") {
633 $feed_data = array();
634
635 foreach (array_keys($_POST) as $k) {
636 if ($k != "op" && $k != "subop" && $k != "ids") {
637 $feed_data[$k] = $_POST[$k];
638 }
639 }
640
641 db_query($link, "BEGIN");
642
643 foreach (array_keys($feed_data) as $k) {
644
645 $qpart = "";
646
647 switch ($k) {
648 case "title":
649 $qpart = "title = '$feed_title'";
650 break;
651
652 case "feed_url":
653 $qpart = "feed_url = '$feed_link'";
654 break;
655
656 case "update_interval":
657 $qpart = "update_interval = '$upd_intl'";
658 break;
659
660 case "purge_interval":
661 $qpart = "purge_interval = '$purge_intl'";
662 break;
663
664 case "auth_login":
665 $qpart = "auth_login = '$auth_login'";
666 break;
667
668 case "auth_pass":
669 $qpart = "auth_pass = '$auth_pass'";
670 break;
671
672 case "private":
673 $qpart = "private = '$private'";
674 break;
675
676 case "include_in_digest":
677 $qpart = "include_in_digest = '$include_in_digest'";
678 break;
679
680 case "always_display_enclosures":
681 $qpart = "always_display_enclosures = '$always_display_enclosures'";
682 break;
683
684 case "cache_images":
685 $qpart = "cache_images = '$cache_images'";
686 break;
687
688 case "rtl_content":
689 $qpart = "rtl_content = '$rtl_content'";
690 break;
691
692 case "update_method":
693 $qpart = "update_method = '$update_method'";
694 break;
695
696 case "cat_id":
697 $qpart = $category_qpart_nocomma;
698 break;
699
700 }
701
702 if ($qpart) {
703 db_query($link,
704 "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids)
705 AND owner_uid = " . $_SESSION["uid"]);
706 print "<br/>";
707 }
708 }
709
710 db_query($link, "COMMIT");
711 }
712
713 }
714
715 if ($subop == "remove") {
716
717 $ids = split(",", db_escape_string($_REQUEST["ids"]));
718
719 foreach ($ids as $id) {
720 remove_feed($link, $id, $_SESSION["uid"]);
721 }
722 }
723
724 if ($subop == "clear") {
725 $id = db_escape_string($_REQUEST["id"]);
726 clear_feed_articles($link, $id);
727 }
728
729 if ($subop == "rescore") {
730 $ids = split(",", db_escape_string($_REQUEST["ids"]));
731
732 foreach ($ids as $id) {
733
734 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
735
736 $result = db_query($link, "SELECT title, content, link, ref_id FROM
737 ttrss_user_entries, ttrss_entries
738 WHERE ref_id = id AND feed_id = '$id' AND
739 owner_uid = " .$_SESSION['uid']."
740 ");
741
742 $scores = array();
743
744 while ($line = db_fetch_assoc($result)) {
745
746 $article_filters = get_article_filters($filters, $line['title'],
747 $line['content'], $line['link']);
748
749 $new_score = calculate_article_score($article_filters);
750
751 if (!$scores[$new_score]) $scores[$new_score] = array();
752
753 array_push($scores[$new_score], $line['ref_id']);
754 }
755
756 foreach (array_keys($scores) as $s) {
757 if ($s > 1000) {
758 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
759 marked = true WHERE
760 ref_id IN (" . join(',', $scores[$s]) . ")");
761 } else if ($s < -500) {
762 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
763 unread = false WHERE
764 ref_id IN (" . join(',', $scores[$s]) . ")");
765 } else {
766 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
767 ref_id IN (" . join(',', $scores[$s]) . ")");
768 }
769 }
770 }
771
772 print __("All done.");
773
774 }
775
776 if ($subop == "rescoreAll") {
777
778 $result = db_query($link,
779 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
780
781 while ($feed_line = db_fetch_assoc($result)) {
782
783 $id = $feed_line["id"];
784
785 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
786
787 $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM
788 ttrss_user_entries, ttrss_entries
789 WHERE ref_id = id AND feed_id = '$id' AND
790 owner_uid = " .$_SESSION['uid']."
791 ");
792
793 $scores = array();
794
795 while ($line = db_fetch_assoc($tmp_result)) {
796
797 $article_filters = get_article_filters($filters, $line['title'],
798 $line['content'], $line['link']);
799
800 $new_score = calculate_article_score($article_filters);
801
802 if (!$scores[$new_score]) $scores[$new_score] = array();
803
804 array_push($scores[$new_score], $line['ref_id']);
805 }
806
807 foreach (array_keys($scores) as $s) {
808 if ($s > 1000) {
809 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
810 marked = true WHERE
811 ref_id IN (" . join(',', $scores[$s]) . ")");
812 } else {
813 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
814 ref_id IN (" . join(',', $scores[$s]) . ")");
815 }
816 }
817 }
818
819 print __("All done.");
820
821 }
822
823 if ($subop == "add") {
824
825 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
826 $cat_id = db_escape_string($_REQUEST["cat_id"]);
827 $p_from = db_escape_string($_REQUEST["from"]);
828
829 /* only read authentication information from POST */
830
831 $auth_login = db_escape_string(trim($_POST["auth_login"]));
832 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
833
834 if ($p_from != 'tt-rss') {
835 print "<html>
836 <head>
837 <title>Tiny Tiny RSS</title>
838 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
839 </head>
840 <body>
841 <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
842 alt=\"Tiny Tiny RSS\"/>
843 <h1>Subscribe to feed...</h1>";
844 }
845
846 $rc = subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass);
847
848 switch ($rc) {
849 case 1:
850 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
851 break;
852 case 2:
853 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
854 break;
855 case 0:
856 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
857 break;
858 }
859
860 if ($p_from != 'tt-rss') {
861 $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]);
862
863
864 $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
865
866 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
867 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
868
869 $feed_id = db_fetch_result($result, 0, "id");
870
871 print "<p>";
872
873 if ($feed_id) {
874 print "<form method=\"GET\" style='display: inline'
875 action=\"$tp_uri\">
876 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
877 <input type=\"hidden\" name=\"subop\" value=\"editFeed\">
878 <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\">
879 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
880 </form>";
881 }
882
883 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
884 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
885 </form></p>";
886
887 print "</body></html>";
888 return;
889 }
890 }
891
892 if ($subop == "categorize") {
893
894 if (!WEB_DEMO_MODE) {
895
896 $ids = split(",", db_escape_string($_REQUEST["ids"]));
897
898 $cat_id = db_escape_string($_REQUEST["cat_id"]);
899
900 if ($cat_id == 0) {
901 $cat_id_qpart = 'NULL';
902 } else {
903 $cat_id_qpart = "'$cat_id'";
904 }
905
906 db_query($link, "BEGIN");
907
908 foreach ($ids as $id) {
909
910 db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
911 WHERE id = '$id' AND parent_feed IS NULL
912 AND owner_uid = " . $_SESSION["uid"]);
913
914 # update linked feed categories
915 db_query($link, "UPDATE ttrss_feeds SET
916 cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND
917 owner_uid = " . $_SESSION["uid"]);
918
919 }
920
921 db_query($link, "COMMIT");
922 }
923
924 }
925
926 if ($subop == "editCats") {
927
928 $action = $_REQUEST["action"];
929
930 if ($action == "save") {
931
932 $cat_title = db_escape_string(trim($_REQUEST["value"]));
933 $cat_id = db_escape_string($_REQUEST["cid"]);
934
935 db_query($link, "BEGIN");
936
937 $result = db_query($link, "SELECT title FROM ttrss_feed_categories
938 WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
939
940 if (db_num_rows($result) == 1) {
941
942 $old_title = db_fetch_result($result, 0, "title");
943
944 if ($cat_title != "") {
945 $result = db_query($link, "UPDATE ttrss_feed_categories SET
946 title = '$cat_title' WHERE id = '$cat_id' AND
947 owner_uid = ".$_SESSION["uid"]);
948
949 print $cat_title;
950 } else {
951 print $old_title;
952 }
953 } else {
954 print $_REQUEST["value"];
955 }
956
957 db_query($link, "COMMIT");
958
959 return;
960
961 }
962
963 print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
964
965 print "<div class=\"infoBoxContents\">";
966
967
968 if ($action == "add") {
969
970 if (!WEB_DEMO_MODE) {
971
972 $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
973
974 $result = db_query($link,
975 "SELECT id FROM ttrss_feed_categories
976 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
977
978 if (db_num_rows($result) == 0) {
979
980 $result = db_query($link,
981 "INSERT INTO ttrss_feed_categories (owner_uid,title)
982 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
983
984 } else {
985
986 print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.",
987 $feed_cat));
988 }
989
990 }
991 }
992
993 if ($action == "remove") {
994
995 $ids = split(",", db_escape_string($_REQUEST["ids"]));
996
997 foreach ($ids as $id) {
998 remove_feed_category($link, $id, $_SESSION["uid"]);
999 }
1000 }
1001
1002 print "<div class=\"prefGenericAddBox\">
1003 <input id=\"fadd_cat\"
1004 onkeypress=\"return filterCR(event, addFeedCat)\"
1005 size=\"40\">
1006 <button onclick=\"javascript:addFeedCat()\">".
1007 __('Create category')."</button></div>";
1008
1009 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
1010 WHERE owner_uid = ".$_SESSION["uid"]."
1011 ORDER BY title");
1012
1013 print "<p>";
1014
1015 if (db_num_rows($result) != 0) {
1016
1017 print __('Select:')."
1018 <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
1019 <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>";
1020
1021 print "<div class=\"prefFeedCatHolder\">";
1022
1023 print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1024
1025 print "<table width=\"100%\" class=\"prefFeedCatList\"
1026 cellspacing=\"0\" id=\"prefFeedCatList\">";
1027
1028 $lnum = 0;
1029
1030 while ($line = db_fetch_assoc($result)) {
1031
1032 $class = ($lnum % 2) ? "even" : "odd";
1033
1034 $cat_id = $line["id"];
1035 $this_row_id = "id=\"FCATR-$cat_id\"";
1036
1037 print "<tr class=\"$class\" $this_row_id>";
1038
1039 $edit_title = htmlspecialchars($line["title"]);
1040
1041 print "<td width='5%' align='center'><input
1042 onclick='toggleSelectPrefRow(this, \"fcat\");'
1043 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
1044
1045 print "<td><span id=\"FCATT-$cat_id\">" .
1046 $edit_title . "</span></td>";
1047
1048 print "</tr>";
1049
1050 ++$lnum;
1051 }
1052
1053 print "</table>";
1054
1055 print "</form>";
1056
1057 print "</div>";
1058
1059 } else {
1060 print "<p>".__('No feed categories defined.')."</p>";
1061 }
1062
1063 print "<div class='dlgButtons'>
1064 <div style='float : left'>
1065 <button onclick=\"return removeSelectedFeedCats()\">".
1066 __('Remove')."</button>
1067 </div>";
1068
1069 print "<button onclick=\"selectTab('feedConfig')\">".
1070 __('Close this window')."</button></div>";
1071
1072 print "</div>";
1073
1074 return;
1075
1076 }
1077
1078 if ($quiet) return;
1079
1080 set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig");
1081
1082 $result = db_query($link, "SELECT COUNT(id) AS num_errors
1083 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1084
1085 $num_errors = db_fetch_result($result, 0, "num_errors");
1086
1087 if ($num_errors > 0) {
1088
1089 print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1090 __('Some feeds have update errors (click for details)')."</a>");
1091 }
1092
1093 $feed_search = db_escape_string($_REQUEST["search"]);
1094
1095 if (array_key_exists("search", $_REQUEST)) {
1096 $_SESSION["prefs_feed_search"] = $feed_search;
1097 } else {
1098 $feed_search = $_SESSION["prefs_feed_search"];
1099 }
1100
1101 print "<div style='float : right'>
1102 <input id=\"feed_search\" size=\"20\" type=\"search\"
1103 onfocus=\"javascript:disableHotkeys();\"
1104 onblur=\"javascript:enableHotkeys();\"
1105 onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
1106 <button onclick=\"javascript:updateFeedList()\">".
1107 __('Search')."</button>
1108 </div>";
1109
1110 print "<button onclick=\"javascript:displayDlg('quickAddFeed')\">"
1111 .__('Subscribe to feed')."</button> ";
1112
1113 print "<button onclick=\"javascript:editSelectedFeed()\">".
1114 __('Edit feeds')."</button> ";
1115
1116 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1117
1118 print "<button onclick=\"javascript:editFeedCats()\">".
1119 __('Edit categories')."</button> ";
1120 }
1121
1122 print "<button onclick=\"javascript:removeSelectedFeeds()\">"
1123 .__('Unsubscribe')."</button> ";
1124
1125 /* print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
1126 <option value=\"facDefault\" selected>".__('Other actions...')."</option>";
1127
1128 if (FORCE_ARTICLE_PURGE == 0) {
1129 print
1130 "<option value=\"facPurge\">".__('Manual purge')."</option>";
1131 }
1132
1133 print "
1134 <option value=\"facClear\">".__('Clear feed data')."</option>
1135 <option value=\"facRescore\">".__('Rescore articles')."</option>
1136 <option value=\"facUnsubscribe\">".__('Unsubscribe')."</option>";
1137
1138 print "</select>"; */
1139
1140 /* if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) {
1141 print " <input type=\"submit\" class=\"button\"
1142 id=\"top25_feeds_btn\"
1143 onclick=\"javascript:browseFeeds()\" value=\"".__('More feeds')."\">";
1144 } */
1145
1146 $feeds_sort = db_escape_string($_REQUEST["sort"]);
1147
1148 if (!$feeds_sort || $feeds_sort == "undefined") {
1149 $feeds_sort = $_SESSION["pref_sort_feeds"];
1150 if (!$feeds_sort) $feeds_sort = "title";
1151 }
1152
1153 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1154
1155 if ($feed_search) {
1156
1157 $feed_search = split(" ", $feed_search);
1158 $tokens = array();
1159
1160 foreach ($feed_search as $token) {
1161
1162 $token = trim($token);
1163
1164 array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%$token%') OR
1165 UPPER(C1.title) LIKE UPPER('%$token%') OR
1166 UPPER(F1.feed_url) LIKE UPPER('%$token%'))");
1167 }
1168
1169 $search_qpart = "(" . join($tokens, " AND ") . ") AND ";
1170
1171 } else {
1172 $search_qpart = "";
1173 }
1174
1175 $show_last_article_info = false;
1176 $show_last_article_checked = "";
1177 $show_last_article_qpart = "";
1178
1179 if ($_REQUEST["slat"] == "true") {
1180 $show_last_article_info = true;
1181 $show_last_article_checked = "checked";
1182 $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries,
1183 ttrss_entries WHERE ref_id = ttrss_entries.id
1184 AND feed_id = F1.id) AS last_article";
1185 } else if ($feeds_sort == "last_article") {
1186 $feeds_sort = "title";
1187 }
1188
1189 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1190 $order_by_qpart = "category,$feeds_sort,title";
1191 } else {
1192 $order_by_qpart = "$feeds_sort,title";
1193 }
1194
1195 $result = db_query($link, "SELECT
1196 F1.id,
1197 F1.title,
1198 F1.feed_url,
1199 ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated,
1200 F1.parent_feed,
1201 F1.update_interval,
1202 F1.last_error,
1203 F1.purge_interval,
1204 F1.cat_id,
1205 F2.title AS parent_title,
1206 C1.title AS category,
1207 F1.include_in_digest
1208 $show_last_article_qpart
1209 FROM
1210 ttrss_feeds AS F1
1211 LEFT JOIN ttrss_feeds AS F2
1212 ON (F1.parent_feed = F2.id)
1213 LEFT JOIN ttrss_feed_categories AS C1
1214 ON (F1.cat_id = C1.id)
1215 WHERE
1216 $search_qpart F1.owner_uid = '".$_SESSION["uid"]."'
1217 ORDER by $order_by_qpart");
1218
1219 if (db_num_rows($result) != 0) {
1220
1221 // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1222
1223 print "<p><table width=\"100%\" cellspacing=\"0\"
1224 class=\"prefFeedList\" id=\"prefFeedList\">";
1225 print "<tr><td class=\"selectPrompt\" colspan=\"8\">".
1226 "<div style='float : right'>".
1227 "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()'
1228 $show_last_article_checked><label
1229 for='show_last_article_times'>".__('Show last article times')."</label></div>".
1230 __('Select:')."
1231 <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>,
1232 <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a>
1233 </td</tr>";
1234
1235 if (!get_pref($link, 'ENABLE_FEED_CATS')) {
1236 print "<tr class=\"title\">
1237 <td width='5%' align='center'>&nbsp;</td>";
1238
1239 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1240 print "<td width='3%'>&nbsp;</td>";
1241 }
1242
1243 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1244
1245 if ($show_last_article_info) {
1246 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
1247 }
1248
1249 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1250 }
1251
1252 $lnum = 0;
1253
1254 $cur_cat_id = -1;
1255
1256 while ($line = db_fetch_assoc($result)) {
1257
1258 $feed_id = $line["id"];
1259 $cat_id = $line["cat_id"];
1260
1261 $edit_title = htmlspecialchars($line["title"]);
1262 $edit_cat = htmlspecialchars($line["category"]);
1263
1264 $last_error = $line["last_error"];
1265
1266 if (!$edit_cat) $edit_cat = __("Uncategorized");
1267
1268 $last_updated = $line["last_updated"];
1269
1270 if (!$last_updated) {
1271 $last_updated = "&mdash;";
1272 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1273 $last_updated = smart_date_time(strtotime($last_updated));
1274 } else {
1275 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1276 $last_updated = date($short_date, strtotime($last_updated));
1277 }
1278
1279 $last_article = $line["last_article"];
1280
1281 if (!$last_article) {
1282 $last_article = "&mdash;";
1283 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1284 $last_article = smart_date_time(strtotime($last_article));
1285 } else {
1286 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1287 $last_article = date($short_date, strtotime($last_article));
1288 }
1289
1290 if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
1291 $lnum = 0;
1292
1293 print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>";
1294
1295 print "<tr class=\"title\">
1296 <td width='5%'>&nbsp;</td>";
1297
1298 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1299 print "<td width='3%'>&nbsp;</td>";
1300 }
1301
1302 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1303
1304 if ($show_last_article_info) {
1305 print "<td width='20%' align='right'>
1306 <a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
1307 }
1308
1309 print "<td width='20%' align='right'>
1310 <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1311
1312 $cur_cat_id = $cat_id;
1313 }
1314
1315 $class = ($lnum % 2) ? "even" : "odd";
1316 $this_row_id = "id=\"FEEDR-$feed_id\"";
1317
1318 print "<tr class=\"$class\" $this_row_id>";
1319
1320 $icon_file = ICONS_DIR . "/$feed_id.ico";
1321
1322 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1323 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">";
1324 } else {
1325 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1326 }
1327
1328 print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");'
1329 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1330
1331 $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'";
1332
1333 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1334 print "<td $onclick class='feedIcon'>$feed_icon</td>";
1335 }
1336
1337 if ($last_error) {
1338 $edit_title = "<span class=\"feed_error\">$edit_title</span>";
1339 $last_updated = "<span class=\"feed_error\">$last_updated</span>";
1340 $last_article = "<span class=\"feed_error\">$last_article</span>";
1341 }
1342
1343 $parent_title = $line["parent_title"];
1344 if ($parent_title) {
1345 $linked_to = sprintf(__("(linked to %s)"), $parent_title);
1346 $parent_title = "<span class='groupPrompt'>$linked_to</span>";
1347 }
1348
1349 print "<td $onclick>" . "$edit_title $parent_title" . "</td>";
1350
1351 if ($show_last_article_info) {
1352 print "<td align='right' $onclick>" .
1353 "$last_article</td>";
1354 }
1355
1356 print "<td $onclick align='right'>$last_updated</td>";
1357
1358 print "</tr>";
1359
1360 ++$lnum;
1361 }
1362
1363 print "</table>";
1364
1365 print "<p>";
1366
1367 } else {
1368
1369 print "<p>";
1370
1371 if (!$feed_search) {
1372 print_warning(__("You don't have any subscribed feeds."));
1373 } else {
1374 print_warning(__('No matching feeds found.'));
1375 }
1376 print "</p>";
1377
1378 }
1379
1380 print "<h3>".__('OPML')."</h3>
1381
1382 <div style='float : left'>
1383 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
1384 ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
1385 <input type=\"hidden\" name=\"op\" value=\"Import\">
1386 <button onclick=\"return validateOpmlImport();\"
1387 type=\"submit\">".__('Import')."</button>
1388 </form></div>";
1389
1390 print "&nbsp;";
1391
1392 print "<button onclick=\"gotoExportOpml()\">".
1393 __('Export OPML')."</button>";
1394
1395
1396 print "<h3>" . __("Firefox Integration") . "</h3>";
1397
1398 print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>";
1399
1400 print "<p";
1401
1402 print "<button onclick='window.navigator.registerContentHandler(" .
1403 "\"application/vnd.mozilla.maybe.feed\", " .
1404 "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" .
1405 __('Click here to register this site as a feed reader.') .
1406 "</button>";
1407
1408 print "</p>";
1409
1410 print "<h3>".__("Published articles")."</h3>";
1411
1412 if (!get_pref($link, "_PREFS_PUBLISH_KEY")) {
1413 set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
1414 }
1415
1416 print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
1417
1418 print "<button onclick=\"return displayDlg('pubUrl')\">".
1419 __('Display URL')."</button> ";
1420
1421
1422 }
1423
1424 function print_feed_browser($link, $search, $limit, $mode = 1) {
1425
1426 $owner_uid = $_SESSION["uid"];
1427
1428 if ($search) {
1429 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
1430 UPPER(title) LIKE UPPER('%$search%'))";
1431 } else {
1432 $search_qpart = "";
1433 }
1434
1435 if ($mode == 1) {
1436 $result = db_query($link, "SELECT feed_url, subscribers FROM
1437 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1438 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1439 AND owner_uid = '$owner_uid') $search_qpart
1440 ORDER BY subscribers DESC LIMIT $limit");
1441 } else if ($mode == 2) {
1442 $result = db_query($link, "SELECT *,
1443 (SELECT COUNT(*) FROM ttrss_user_entries WHERE
1444 orig_feed_id = ttrss_archived_feeds.id) AS articles_archived
1445 FROM
1446 ttrss_archived_feeds
1447 WHERE
1448 (SELECT COUNT(*) FROM ttrss_feeds
1449 WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND
1450 owner_uid = '$owner_uid') = 0 AND
1451 owner_uid = '$owner_uid' $search_qpart
1452 ORDER BY id DESC LIMIT $limit");
1453 }
1454
1455 $feedctr = 0;
1456
1457 while ($line = db_fetch_assoc($result)) {
1458
1459 if ($mode == 1) {
1460
1461 $feed_url = htmlspecialchars($line["feed_url"]);
1462 $subscribers = $line["subscribers"];
1463
1464 $det_result = db_query($link, "SELECT site_url,title,id
1465 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
1466
1467 $details = db_fetch_assoc($det_result);
1468
1469 $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
1470
1471 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1472 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
1473 "/".$details["id"].".ico\">";
1474 } else {
1475 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1476 }
1477
1478 $check_box = "<input onclick='toggleSelectListRow(this)'
1479 class='feedBrowseCB'
1480 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
1481
1482 $class = ($feedctr % 2) ? "even" : "odd";
1483
1484 if ($details["site_url"]) {
1485 $site_url = "<a target=\"_blank\" href=\"".
1486 htmlspecialchars($details["site_url"])."\">
1487 <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
1488 } else {
1489 $site_url = "";
1490 }
1491
1492 print "<li title=\"".htmlspecialchars($details["site_url"])."\"
1493 class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
1494 "$feed_icon " . htmlspecialchars($details["title"]) .
1495 "&nbsp;<span class='subscribers'>($subscribers)</span>
1496 $site_url</li>";
1497
1498 } else if ($mode == 2) {
1499 $feed_url = htmlspecialchars($line["feed_url"]);
1500 $site_url = htmlspecialchars($line["site_url"]);
1501 $title = htmlspecialchars($line["title"]);
1502
1503 $icon_file = ICONS_DIR . "/" . $line["id"] . ".ico";
1504
1505 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1506 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
1507 "/".$line["id"].".ico\">";
1508 } else {
1509 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1510 }
1511
1512 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1513 type=\"checkbox\" id=\"FBCHK-" . $line["id"] . "\">";
1514
1515 $class = ($feedctr % 2) ? "even" : "odd";
1516
1517 if ($line['articles_archived'] > 0) {
1518 $archived = sprintf(__("%d archived articles"), $line['articles_archived']);
1519 $archived = "&nbsp;<span class='subscribers'>($archived)</span>";
1520 } else {
1521 $archived = '';
1522 }
1523
1524 if ($line["site_url"]) {
1525 $site_url = "<a target=\"_blank\" href=\"$site_url\">
1526 <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
1527 } else {
1528 $site_url = "";
1529 }
1530
1531 print "<li title='".$line['site_url']."' class='$class'
1532 id=\"FBROW-".$line["id"]."\">".
1533 $check_box . "$feed_icon " . $title . $archived . $site_url . "</li>";
1534
1535
1536 }
1537
1538 ++$feedctr;
1539 }
1540
1541 if ($feedctr == 0) {
1542 print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
1543 }
1544
1545 return $feedctr;
1546
1547 }
1548
1549 ?>