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