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