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