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