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