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