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