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