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