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