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