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