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