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