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