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