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