]> git.wh0rd.org - tt-rss.git/blob - modules/pref-feeds.php
fae1fbe2fd2a4fc3caeae2165a443803f94f3b5e
[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 } else {
706 label_remove($link, -11-$id, $_SESSION["uid"]);
707 }
708 }
709 }
710
711 if ($subop == "clear") {
712 $id = db_escape_string($_GET["id"]);
713 clear_feed_articles($link, $id);
714 }
715
716 if ($subop == "rescore") {
717 $ids = split(",", db_escape_string($_GET["ids"]));
718
719 foreach ($ids as $id) {
720
721 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
722
723 $result = db_query($link, "SELECT title, content, link, ref_id FROM
724 ttrss_user_entries, ttrss_entries
725 WHERE ref_id = id AND feed_id = '$id' AND
726 owner_uid = " .$_SESSION['uid']."
727 ");
728
729 $scores = array();
730
731 while ($line = db_fetch_assoc($result)) {
732
733 $article_filters = get_article_filters($filters, $line['title'],
734 $line['content'], $line['link']);
735
736 $new_score = calculate_article_score($article_filters);
737
738 if (!$scores[$new_score]) $scores[$new_score] = array();
739
740 array_push($scores[$new_score], $line['ref_id']);
741 }
742
743 foreach (array_keys($scores) as $s) {
744 if ($s > 1000) {
745 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
746 marked = true WHERE
747 ref_id IN (" . join(',', $scores[$s]) . ")");
748 } else if ($s < -500) {
749 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
750 unread = false WHERE
751 ref_id IN (" . join(',', $scores[$s]) . ")");
752 } else {
753 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
754 ref_id IN (" . join(',', $scores[$s]) . ")");
755 }
756 }
757 }
758
759 print __("All done.");
760
761 }
762
763 if ($subop == "rescoreAll") {
764
765 $result = db_query($link,
766 "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
767
768 while ($feed_line = db_fetch_assoc($result)) {
769
770 $id = $feed_line["id"];
771
772 $filters = load_filters($link, $id, $_SESSION["uid"], 6);
773
774 $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM
775 ttrss_user_entries, ttrss_entries
776 WHERE ref_id = id AND feed_id = '$id' AND
777 owner_uid = " .$_SESSION['uid']."
778 ");
779
780 $scores = array();
781
782 while ($line = db_fetch_assoc($tmp_result)) {
783
784 $article_filters = get_article_filters($filters, $line['title'],
785 $line['content'], $line['link']);
786
787 $new_score = calculate_article_score($article_filters);
788
789 if (!$scores[$new_score]) $scores[$new_score] = array();
790
791 array_push($scores[$new_score], $line['ref_id']);
792 }
793
794 foreach (array_keys($scores) as $s) {
795 if ($s > 1000) {
796 db_query($link, "UPDATE ttrss_user_entries SET score = '$s',
797 marked = true WHERE
798 ref_id IN (" . join(',', $scores[$s]) . ")");
799 } else {
800 db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE
801 ref_id IN (" . join(',', $scores[$s]) . ")");
802 }
803 }
804 }
805
806 print __("All done.");
807
808 }
809
810 if ($subop == "add") {
811
812 if (!WEB_DEMO_MODE) {
813
814 $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
815 $cat_id = db_escape_string($_REQUEST["cat_id"]);
816 $p_from = db_escape_string($_REQUEST["from"]);
817
818 /* only read authentication information from POST */
819
820 $auth_login = db_escape_string(trim($_POST["auth_login"]));
821 $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
822
823 if ($p_from != 'tt-rss') {
824 print "<html>
825 <head>
826 <title>Tiny Tiny RSS</title>
827 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
828 </head>
829 <body>
830 <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"
831 alt=\"Tiny Tiny RSS\"/>
832 <h1>Subscribe to feed...</h1>";
833 }
834
835 if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) {
836 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
837 } else {
838 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
839 }
840
841 if ($p_from != 'tt-rss') {
842 $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]);
843
844
845 $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
846
847 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
848 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
849
850 $feed_id = db_fetch_result($result, 0, "id");
851
852 print "<p>";
853
854 if ($feed_id) {
855 print "<form method=\"GET\" style='display: inline'
856 action=\"$tp_uri\">
857 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
858 <input type=\"hidden\" name=\"subop\" value=\"editFeed\">
859 <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\">
860 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
861 </form>";
862 }
863
864 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
865 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
866 </form></p>";
867
868 print "</body></html>";
869 return;
870 }
871
872 }
873 }
874
875 if ($subop == "categorize") {
876
877 if (!WEB_DEMO_MODE) {
878
879 $ids = split(",", db_escape_string($_GET["ids"]));
880
881 $cat_id = db_escape_string($_GET["cat_id"]);
882
883 if ($cat_id == 0) {
884 $cat_id_qpart = 'NULL';
885 } else {
886 $cat_id_qpart = "'$cat_id'";
887 }
888
889 db_query($link, "BEGIN");
890
891 foreach ($ids as $id) {
892
893 db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart
894 WHERE id = '$id' AND parent_feed IS NULL
895 AND owner_uid = " . $_SESSION["uid"]);
896
897 # update linked feed categories
898 db_query($link, "UPDATE ttrss_feeds SET
899 cat_id = $cat_id_qpart WHERE parent_feed = '$id' AND
900 owner_uid = " . $_SESSION["uid"]);
901
902 }
903
904 db_query($link, "COMMIT");
905 }
906
907 }
908
909 if ($subop == "editCats") {
910
911 $action = $_REQUEST["action"];
912
913 if ($action == "save") {
914
915 $cat_title = db_escape_string(trim($_REQUEST["value"]));
916 $cat_id = db_escape_string($_GET["cid"]);
917
918 db_query($link, "BEGIN");
919
920 $result = db_query($link, "SELECT title FROM ttrss_feed_categories
921 WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
922
923 if (db_num_rows($result) == 1) {
924
925 $old_title = db_fetch_result($result, 0, "title");
926
927 if ($cat_title != "") {
928 $result = db_query($link, "UPDATE ttrss_feed_categories SET
929 title = '$cat_title' WHERE id = '$cat_id' AND
930 owner_uid = ".$_SESSION["uid"]);
931
932 print $cat_title;
933 } else {
934 print $old_title;
935 }
936 } else {
937 print $_REQUEST["value"];
938 }
939
940 db_query($link, "COMMIT");
941
942 return;
943
944 }
945
946 print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
947
948 print "<div class=\"infoBoxContents\">";
949
950
951 if ($action == "add") {
952
953 if (!WEB_DEMO_MODE) {
954
955 $feed_cat = db_escape_string(trim($_GET["cat"]));
956
957 $result = db_query($link,
958 "SELECT id FROM ttrss_feed_categories
959 WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
960
961 if (db_num_rows($result) == 0) {
962
963 $result = db_query($link,
964 "INSERT INTO ttrss_feed_categories (owner_uid,title)
965 VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
966
967 } else {
968
969 print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.",
970 $feed_cat));
971 }
972
973 }
974 }
975
976 if ($action == "remove") {
977
978 if (!WEB_DEMO_MODE) {
979
980 $ids = split(",", db_escape_string($_GET["ids"]));
981
982 foreach ($ids as $id) {
983
984 db_query($link, "BEGIN");
985
986 $result = db_query($link,
987 "SELECT count(id) as num_feeds FROM ttrss_feeds
988 WHERE cat_id = '$id'");
989
990 $num_feeds = db_fetch_result($result, 0, "num_feeds");
991
992 if ($num_feeds == 0) {
993 db_query($link, "DELETE FROM ttrss_feed_categories
994 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
995 } else {
996
997 print format_warning(__("Unable to delete non empty feed categories."));
998
999 }
1000
1001 db_query($link, "COMMIT");
1002 }
1003 }
1004 }
1005
1006 print "<div class=\"prefGenericAddBox\">
1007 <input id=\"fadd_cat\"
1008 onkeypress=\"return filterCR(event, addFeedCat)\"
1009 onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\"
1010 onchange=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\"
1011 size=\"40\">&nbsp;
1012 <input
1013 type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\"
1014 onclick=\"javascript:addFeedCat()\" value=\"".__('Create category')."\"></div>";
1015
1016 $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
1017 WHERE owner_uid = ".$_SESSION["uid"]."
1018 ORDER BY title");
1019
1020 print "<p>";
1021
1022 if (db_num_rows($result) != 0) {
1023
1024 print "<table width=\"100%\" class=\"prefFeedCatList\"
1025 cellspacing=\"0\">";
1026
1027 print "<tr><td class=\"selectPrompt\" colspan=\"8\">
1028 ".__('Select:')."
1029 <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
1030 <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>
1031 </td></tr>";
1032
1033 print "</table>";
1034
1035 print "<div class=\"prefFeedCatHolder\">";
1036
1037 print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
1038
1039 print "<table width=\"100%\" class=\"prefFeedCatList\"
1040 cellspacing=\"0\" id=\"prefFeedCatList\">";
1041
1042 $lnum = 0;
1043
1044 while ($line = db_fetch_assoc($result)) {
1045
1046 $class = ($lnum % 2) ? "even" : "odd";
1047
1048 $cat_id = $line["id"];
1049 $this_row_id = "id=\"FCATR-$cat_id\"";
1050
1051 print "<tr class=\"$class\" $this_row_id>";
1052
1053 $edit_title = htmlspecialchars($line["title"]);
1054
1055 print "<td width='5%' align='center'><input
1056 onclick='toggleSelectPrefRow(this, \"fcat\");'
1057 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
1058
1059 print "<td><span id=\"FCATT-$cat_id\">" .
1060 $edit_title . "</span></td>";
1061
1062 print "</tr>";
1063
1064 ++$lnum;
1065 }
1066
1067 print "</table>";
1068
1069 print "</form>";
1070
1071 print "</div>";
1072
1073 } else {
1074 print "<p>".__('No feed categories defined.')."</p>";
1075 }
1076
1077 print "<div style='float : right'>
1078 <input type='submit' class='button'
1079 onclick=\"selectTab('feedConfig')\" value=\"".__('Close this window')."\"></div>";
1080
1081 print "<div id=\"catOpToolbar\">";
1082
1083 print "
1084 <input type=\"submit\" class=\"button\" disabled=\"true\"
1085 onclick=\"return removeSelectedFeedCats()\" value=\"".__('Remove')."\">";
1086
1087 print "</div>";
1088
1089 print "</div>";
1090
1091 return;
1092
1093 }
1094
1095 if ($quiet) return;
1096
1097 set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig");
1098
1099 $result = db_query($link, "SELECT COUNT(id) AS num_errors
1100 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
1101
1102 $num_errors = db_fetch_result($result, 0, "num_errors");
1103
1104 if ($num_errors > 0) {
1105
1106 print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
1107 __('Some feeds have update errors (click for details)')."</a>");
1108 }
1109
1110 $feed_search = db_escape_string($_GET["search"]);
1111
1112 if (array_key_exists("search", $_GET)) {
1113 $_SESSION["prefs_feed_search"] = $feed_search;
1114 } else {
1115 $feed_search = $_SESSION["prefs_feed_search"];
1116 }
1117
1118 print "<div class=\"feedEditSearch\">
1119 <input id=\"feed_search\" size=\"20\" type=\"search\"
1120 onfocus=\"javascript:disableHotkeys();\"
1121 onblur=\"javascript:enableHotkeys();\"
1122 onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
1123 <input type=\"submit\" class=\"button\"
1124 onclick=\"javascript:updateFeedList()\" value=\"".__('Search')."\">
1125 </div>";
1126
1127 print "<input onclick=\"javascript:displayDlg('quickAddFeed')\"
1128 type=\"submit\" id=\"subscribe_to_feed_btn\"
1129 class=\"button\" value=\"".__('Subscribe to feed')."\">";
1130
1131 if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) {
1132 print " <input type=\"submit\" class=\"button\"
1133 id=\"top25_feeds_btn\"
1134 onclick=\"javascript:browseFeeds()\" value=\"".__('More Feeds')."\">";
1135 }
1136
1137 $feeds_sort = db_escape_string($_GET["sort"]);
1138
1139 if (!$feeds_sort || $feeds_sort == "undefined") {
1140 $feeds_sort = $_SESSION["pref_sort_feeds"];
1141 if (!$feeds_sort) $feeds_sort = "title";
1142 }
1143
1144 $_SESSION["pref_sort_feeds"] = $feeds_sort;
1145
1146 if ($feed_search) {
1147 $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR
1148 UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND";
1149 } else {
1150 $search_qpart = "";
1151 }
1152
1153 $show_last_article_info = false;
1154 $show_last_article_checked = "";
1155 $show_last_article_qpart = "";
1156
1157 if ($_GET["slat"] == "true") {
1158 $show_last_article_info = true;
1159 $show_last_article_checked = "checked";
1160 $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries,
1161 ttrss_entries WHERE ref_id = ttrss_entries.id
1162 AND feed_id = F1.id) AS last_article";
1163 } else if ($feeds_sort == "last_article") {
1164 $feeds_sort = "title";
1165 }
1166
1167 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1168 $order_by_qpart = "category,$feeds_sort,title";
1169 } else {
1170 $order_by_qpart = "$feeds_sort,title";
1171 }
1172
1173 $result = db_query($link, "SELECT
1174 F1.id,
1175 F1.title,
1176 F1.feed_url,
1177 ".SUBSTRING_FOR_DATE."(F1.last_updated,1,16) AS last_updated,
1178 F1.parent_feed,
1179 F1.update_interval,
1180 F1.last_error,
1181 F1.purge_interval,
1182 F1.cat_id,
1183 F2.title AS parent_title,
1184 C1.title AS category,
1185 F1.hidden,
1186 F1.include_in_digest
1187 $show_last_article_qpart
1188 FROM
1189 ttrss_feeds AS F1
1190 LEFT JOIN ttrss_feeds AS F2
1191 ON (F1.parent_feed = F2.id)
1192 LEFT JOIN ttrss_feed_categories AS C1
1193 ON (F1.cat_id = C1.id)
1194 WHERE
1195 $search_qpart F1.owner_uid = '".$_SESSION["uid"]."'
1196 ORDER by $order_by_qpart");
1197
1198 if (db_num_rows($result) != 0) {
1199
1200 // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
1201
1202 print "<p><table width=\"100%\" cellspacing=\"0\"
1203 class=\"prefFeedList\" id=\"prefFeedList\">";
1204 print "<tr><td class=\"selectPrompt\" colspan=\"8\">".
1205 "<div style='float : right'>".
1206 "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()'
1207 $show_last_article_checked><label
1208 for='show_last_article_times'>".__('Show last article times')."</label></div>".
1209 __('Select:')."
1210 <a href=\"javascript:selectPrefRows('feed', true)\">".__('All')."</a>,
1211 <a href=\"javascript:selectPrefRows('feed', false)\">".__('None')."</a>
1212 </td</tr>";
1213
1214 if (!get_pref($link, 'ENABLE_FEED_CATS')) {
1215 print "<tr class=\"title\">
1216 <td width='5%' align='center'>&nbsp;</td>";
1217
1218 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1219 print "<td width='3%'>&nbsp;</td>";
1220 }
1221
1222 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1223
1224 if ($show_last_article_info) {
1225 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
1226 }
1227
1228 print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1229 }
1230
1231 $lnum = 0;
1232
1233 $cur_cat_id = -1;
1234
1235 while ($line = db_fetch_assoc($result)) {
1236
1237 $feed_id = $line["id"];
1238 $cat_id = $line["cat_id"];
1239
1240 $edit_title = htmlspecialchars($line["title"]);
1241 $edit_cat = htmlspecialchars($line["category"]);
1242
1243 $hidden = sql_bool_to_bool($line["hidden"]);
1244
1245 $last_error = $line["last_error"];
1246
1247 if (!$edit_cat) $edit_cat = __("Uncategorized");
1248
1249 $last_updated = $line["last_updated"];
1250
1251 if (!$last_updated) {
1252 $last_updated = "&mdash;";
1253 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1254 $last_updated = smart_date_time(strtotime($last_updated));
1255 } else {
1256 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1257 $last_updated = date($short_date, strtotime($last_updated));
1258 }
1259
1260 $last_article = $line["last_article"];
1261
1262 if (!$last_article) {
1263 $last_article = "&mdash;";
1264 } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
1265 $last_article = smart_date_time(strtotime($last_article));
1266 } else {
1267 $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
1268 $last_article = date($short_date, strtotime($last_article));
1269 }
1270
1271 if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
1272 $lnum = 0;
1273
1274 print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>";
1275
1276 print "<tr class=\"title\">
1277 <td width='5%'>&nbsp;</td>";
1278
1279 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1280 print "<td width='3%'>&nbsp;</td>";
1281 }
1282
1283 print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">".__('Title')."</a></td>";
1284
1285 if ($show_last_article_info) {
1286 print "<td width='20%' align='right'>
1287 <a href=\"javascript:updateFeedList('last_article')\">".__('Last&nbsp;Article')."</a></td>";
1288 }
1289
1290 print "<td width='20%' align='right'>
1291 <a href=\"javascript:updateFeedList('last_updated')\">".__('Updated')."</a></td>";
1292
1293 $cur_cat_id = $cat_id;
1294 }
1295
1296 $class = ($lnum % 2) ? "even" : "odd";
1297 $this_row_id = "id=\"FEEDR-$feed_id\"";
1298
1299 print "<tr class=\"$class\" $this_row_id>";
1300
1301 $icon_file = ICONS_DIR . "/$feed_id.ico";
1302
1303 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1304 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">";
1305 } else {
1306 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1307 }
1308
1309 print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");'
1310 type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
1311
1312 $onclick = "onclick='editFeed($feed_id)' title='".__('Click to edit')."'";
1313
1314 if (get_pref($link, 'ENABLE_FEED_ICONS')) {
1315 print "<td $onclick class='feedIcon'>$feed_icon</td>";
1316 }
1317
1318 if ($hidden) {
1319 $edit_title = "<span class=\"insensitive\">$edit_title ".
1320 __('(Hidden)')."</span>";
1321 $last_updated = "<span class=\"insensitive\">$last_updated</span>";
1322 $last_article = "<span class=\"insensitive\">$last_article</span>";
1323 }
1324
1325 if ($last_error) {
1326 $edit_title = "<span class=\"feed_error\">$edit_title</span>";
1327 $last_updated = "<span class=\"feed_error\">$last_updated</span>";
1328 $last_article = "<span class=\"feed_error\">$last_article</span>";
1329 }
1330
1331 $parent_title = $line["parent_title"];
1332 if ($parent_title) {
1333 $linked_to = sprintf(__("(linked to %s)"), $parent_title);
1334 $parent_title = "<span class='groupPrompt'>$linked_to</span>";
1335 }
1336
1337 print "<td $onclick>" . "$edit_title $parent_title" . "</td>";
1338
1339 if ($show_last_article_info) {
1340 print "<td align='right' $onclick>" .
1341 "$last_article</td>";
1342 }
1343
1344 print "<td $onclick align='right'>$last_updated</td>";
1345
1346 print "</tr>";
1347
1348 ++$lnum;
1349 }
1350
1351 print "</table>";
1352
1353 print "<p>";
1354
1355 print "<div id=\"feedOpToolbar\">";
1356
1357 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1358
1359 print __('Selection:') . " ";
1360
1361 print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled");
1362
1363 print " <input type=\"submit\" class=\"button\" disabled=\"true\"
1364 onclick=\"javascript:categorizeSelectedFeeds()\" value=\"".
1365 __('Recategorize')."\">";
1366 }
1367
1368 print "</div>";
1369
1370 print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">
1371 <option value=\"facDefault\" selected>".__('Actions...')."</option>
1372 <option disabled>--------</option>
1373 <option style=\"color : #5050aa\" disabled>".__('Selection:')."</option>
1374 <option value=\"facEdit\">&nbsp;&nbsp;".__('Edit')."</option>";
1375
1376 if (FORCE_ARTICLE_PURGE == 0) {
1377 print
1378 "<option value=\"facPurge\">&nbsp;&nbsp;".__('Manual purge')."</option>";
1379 }
1380
1381 print "
1382 <option value=\"facClear\">&nbsp;&nbsp;".__('Clear feed data')."</option>
1383 <option value=\"facRescore\">&nbsp;&nbsp;".__('Rescore articles')."</option>
1384 <option value=\"facUnsubscribe\">&nbsp;&nbsp;".__('Unsubscribe')."</option>";
1385
1386 if (get_pref($link, 'ENABLE_FEED_CATS')) {
1387
1388 print "<option disabled>--------</option>
1389 <option style=\"color : #5050aa\" disabled>".__('Other:')."</option>
1390 <option value=\"facEditCats\">&nbsp;&nbsp;".__('Edit categories')."
1391 </option>";
1392 }
1393
1394 print "</select>";
1395 }
1396
1397 print "<h3>".__('OPML')."</h3>
1398
1399 <div style='float : left'>
1400 <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
1401 ".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
1402 <input type=\"hidden\" name=\"op\" value=\"Import\">
1403 <input class=\"button\" onclick=\"return validateOpmlImport();\"
1404 type=\"submit\" value=\"".__('Import')."\">
1405 </form></div>";
1406
1407 print "&nbsp;";
1408
1409 print "<input type=\"submit\"
1410 class=\"button\" onclick=\"gotoExportOpml()\"
1411 value=\"".__('Export OPML')."\">";
1412
1413
1414 print "<h3>" . __("Firefox Integration") . "</h3>";
1415
1416 print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.');
1417 print "</p><p> <a class='visibleLinkB' href='javascript:window.navigator.registerContentHandler(" .
1418 "\"application/vnd.mozilla.maybe.feed\", " .
1419 "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" .
1420 __('Click here to register this site as a feed reader.') . "</a></p>";
1421
1422
1423 print "<h3>".__("Published articles")."</h3>";
1424
1425 if (!get_pref($link, "_PREFS_PUBLISH_KEY")) {
1426 set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
1427 }
1428
1429 print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
1430
1431 $url_path = article_publish_url($link);
1432
1433 print "<p><a class=\"visibleLinkB\" id=\"pubGenAddress\" target=\"_blank\" href=\"$url_path\">".__("Link to published articles feed.")."</a></p>";
1434
1435 print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\" class=\"button\"
1436 value=\"".__('Generate another link')."\">";
1437 /* print " <input type=\"submit\" onclick=\"return pubToClipboard()\" class=\"button\"
1438 value=\"".__('Copy link to clipboard')."\">"; */
1439 print "</p>";
1440
1441 }
1442
1443 function print_feed_browser($link, $search, $limit) {
1444
1445 $owner_uid = $_SESSION["uid"];
1446
1447 if ($search) {
1448 $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR
1449 UPPER(title) LIKE UPPER('%$search%'))";
1450 } else {
1451 $search_qpart = "";
1452 }
1453
1454 $result = db_query($link, "SELECT feed_url, subscribers FROM
1455 ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
1456 WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
1457 AND owner_uid = '$owner_uid') $search_qpart
1458 ORDER BY subscribers DESC LIMIT $limit");
1459
1460 $feedctr = 0;
1461
1462 while ($line = db_fetch_assoc($result)) {
1463 $feed_url = $line["feed_url"];
1464 $subscribers = $line["subscribers"];
1465
1466 $det_result = db_query($link, "SELECT site_url,title,id
1467 FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1");
1468
1469 $details = db_fetch_assoc($det_result);
1470
1471 $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico";
1472
1473 if (file_exists($icon_file) && filesize($icon_file) > 0) {
1474 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL .
1475 "/".$details["id"].".ico\">";
1476 } else {
1477 $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
1478 }
1479
1480 $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB'
1481 type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">";
1482
1483 $class = ($feedctr % 2) ? "even" : "odd";
1484
1485 if ($details["site_url"]) {
1486 $site_url = "<a target=\"_blank\" href=\"".$details["site_url"]."\">
1487 <img style='border-width : 0px' src='images/www.png' alt='www'></a>";
1488 } else {
1489 $site_url = "";
1490 }
1491
1492 print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box".
1493 "$feed_icon " . $details["title"] .
1494 "&nbsp;<span class='subscribers'>($subscribers)</span>
1495 $site_url
1496 </li>";
1497
1498 ++$feedctr;
1499 }
1500
1501 if ($feedctr == 0) {
1502 print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>";
1503 }
1504
1505 return $feedctr;
1506
1507 }
1508 ?>