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