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