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