]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
d65981e2 AD |
2 | error_reporting(E_ERROR | E_WARNING | E_PARSE); |
3 | ||
36bfab86 | 4 | require_once "sessions.php"; |
c339343b | 5 | require_once "modules/backend-rpc.php"; |
dc56b3b7 | 6 | |
894ebcf5 | 7 | /* if ($_GET["debug"]) { |
cce28758 AD |
8 | define('DEFAULT_ERROR_LEVEL', E_ALL); |
9 | } else { | |
10 | define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); | |
11 | } | |
894ebcf5 AD |
12 | |
13 | error_reporting(DEFAULT_ERROR_LEVEL); */ | |
cce28758 | 14 | |
657770a0 AD |
15 | require_once "sanity_check.php"; |
16 | require_once "config.php"; | |
af106b0e AD |
17 | |
18 | require_once "db.php"; | |
19 | require_once "db-prefs.php"; | |
20 | require_once "functions.php"; | |
657770a0 | 21 | |
dc56b3b7 | 22 | no_cache_incantation(); |
1025ad87 | 23 | startup_gettext(); |
dc56b3b7 | 24 | |
7f0acba7 AD |
25 | $script_started = getmicrotime(); |
26 | ||
27 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
28 | ||
29 | if (!$link) { | |
30 | if (DB_TYPE == "mysql") { | |
31 | print mysql_error(); | |
32 | } | |
33 | // PG seems to display its own errors just fine by default. | |
34 | return; | |
35 | } | |
36 | ||
37 | if (DB_TYPE == "pgsql") { | |
38 | pg_query("set client_encoding = 'UTF-8'"); | |
39 | pg_set_client_encoding("UNICODE"); | |
40 | } | |
41 | ||
42 | $op = $_REQUEST["op"]; | |
43 | ||
c339343b | 44 | $print_exec_time = false; |
7e3634d9 | 45 | |
4803eed2 | 46 | if ((!$op || $op == "rpc" || $op == "rss" || $op == "digestSend" || |
18664970 | 47 | $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { |
6002818b AD |
48 | header("Content-Type: application/xml; charset=utf-8"); |
49 | } else { | |
50 | header("Content-Type: text/html; charset=utf-8"); | |
262bd8ea AD |
51 | } |
52 | ||
f3acc32e AD |
53 | if (!$op) { |
54 | header("Content-Type: application/xml"); | |
55 | print_error_xml(7); exit; | |
56 | } | |
42c32916 | 57 | |
7f0acba7 AD |
58 | if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" |
59 | && $op != "rss" && $op != "getUnread") { | |
262bd8ea | 60 | |
a2770077 | 61 | if ($op == "rpc") { |
af106b0e | 62 | print_error_xml(6); die; |
04269460 AD |
63 | } else { |
64 | print " | |
65 | <html><body> | |
66 | <p>Error: Not logged in.</p> | |
67 | <script type=\"text/javascript\"> | |
68 | if (parent.window != 'undefined') { | |
01a87dff | 69 | parent.window.location = \"tt-rss.php\"; |
04269460 | 70 | } else { |
01a87dff | 71 | window.location = \"tt-rss.php\"; |
04269460 AD |
72 | } |
73 | </script> | |
74 | </body></html> | |
75 | "; | |
262bd8ea AD |
76 | } |
77 | exit; | |
78 | } | |
1c7f75ed | 79 | |
ad815c71 | 80 | $purge_intervals = array( |
d1db26aa AD |
81 | 0 => __("Use default"), |
82 | -1 => __("Never purge"), | |
83 | 5 => __("1 week old"), | |
84 | 14 => __("2 weeks old"), | |
85 | 31 => __("1 month old"), | |
86 | 60 => __("2 months old"), | |
87 | 90 => __("3 months old")); | |
ad815c71 AD |
88 | |
89 | $update_intervals = array( | |
d1db26aa AD |
90 | 0 => __("Use default"), |
91 | -1 => __("Disable updates"), | |
92 | 30 => __("Each 30 minutes"), | |
93 | 60 => __("Hourly"), | |
94 | 240 => __("Each 4 hours"), | |
95 | 720 => __("Each 12 hours"), | |
96 | 1440 => __("Daily"), | |
97 | 10080 => __("Weekly")); | |
ad815c71 | 98 | |
d20f3544 | 99 | |
3c5783b7 | 100 | $access_level_names = array( |
d1db26aa AD |
101 | 0 => __("User"), |
102 | 10 => __("Administrator")); | |
3c5783b7 | 103 | |
f27d955a | 104 | require_once "modules/pref-prefs.php"; |
ef8be8ea AD |
105 | require_once "modules/popup-dialog.php"; |
106 | require_once "modules/help.php"; | |
107 | require_once "modules/pref-feeds.php"; | |
108 | require_once "modules/pref-filters.php"; | |
109 | require_once "modules/pref-labels.php"; | |
110 | require_once "modules/pref-users.php"; | |
c339343b | 111 | require_once "modules/pref-feed-browser.php"; |
ef8be8ea | 112 | |
7ec2a838 | 113 | |
b2804af7 | 114 | if (!sanity_check($link)) { return; } |
023fe037 | 115 | |
c3b81db0 | 116 | if ($op == "rpc") { |
01b3e191 | 117 | handle_rpc_request($link); |
c3b81db0 AD |
118 | } |
119 | ||
120 | if ($op == "feeds") { | |
121 | ||
8143ae1f AD |
122 | $tags = $_GET["tags"]; |
123 | ||
c3b81db0 AD |
124 | $subop = $_GET["subop"]; |
125 | ||
126 | if ($subop == "catchupAll") { | |
b018b49b | 127 | db_query($link, "UPDATE ttrss_user_entries SET |
6d15e1ef | 128 | last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]); |
c3b81db0 AD |
129 | } |
130 | ||
fe14aeb8 AD |
131 | if ($subop == "collapse") { |
132 | $cat_id = db_escape_string($_GET["cid"]); | |
280ee9a3 | 133 | |
fe14aeb8 AD |
134 | db_query($link, "UPDATE ttrss_feed_categories SET |
135 | collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . | |
136 | $_SESSION["uid"]); | |
137 | return; | |
138 | } | |
139 | ||
8143ae1f | 140 | outputFeedList($link, $tags); |
c3b81db0 | 141 | |
1cd17194 AD |
142 | } |
143 | ||
144 | if ($op == "view") { | |
145 | ||
70f6dbb1 AD |
146 | $id = db_escape_string($_GET["id"]); |
147 | $feed_id = db_escape_string($_GET["feed"]); | |
148 | ||
149 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
150 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
151 | ||
152 | if (db_num_rows($result) == 1) { | |
153 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
154 | } else { | |
155 | $rtl_content = false; | |
156 | } | |
157 | ||
158 | if ($rtl_content) { | |
159 | $rtl_tag = "dir=\"RTL\""; | |
ed51e128 | 160 | $rtl_class = "RTL"; |
70f6dbb1 AD |
161 | } else { |
162 | $rtl_tag = ""; | |
ed51e128 | 163 | $rtl_class = ""; |
70f6dbb1 | 164 | } |
d76a3b03 | 165 | |
4c193675 AD |
166 | $result = db_query($link, "UPDATE ttrss_user_entries |
167 | SET unread = false,last_read = NOW() | |
276eecef | 168 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); |
a1a8a2be | 169 | |
21703604 | 170 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, |
9167e250 | 171 | SUBSTRING(updated,1,16) as updated, |
11b0dce2 | 172 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, |
a545b564 AD |
173 | num_comments, |
174 | author | |
4c193675 | 175 | FROM ttrss_entries,ttrss_user_entries |
12fb24b9 | 176 | WHERE id = '$id' AND ref_id = id AND owner_uid = " . $_SESSION["uid"]); |
1cd17194 | 177 | |
d76a3b03 | 178 | if ($result) { |
1cd17194 | 179 | |
c1826240 AD |
180 | $link_target = ""; |
181 | ||
182 | if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) { | |
183 | $link_target = "target=\"_new\""; | |
184 | } | |
185 | ||
648472a7 | 186 | $line = db_fetch_assoc($result); |
1cd17194 | 187 | |
b7f4bda2 AD |
188 | if ($line["icon_url"]) { |
189 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
190 | } else { | |
191 | $feed_icon = " "; | |
192 | } | |
d76a3b03 | 193 | |
11b0dce2 | 194 | /* if ($line["comments"] && $line["link"] != $line["comments"]) { |
f7181e9b AD |
195 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; |
196 | } else { | |
197 | $entry_comments = ""; | |
11b0dce2 AD |
198 | } */ |
199 | ||
200 | $num_comments = $line["num_comments"]; | |
201 | $entry_comments = ""; | |
202 | ||
203 | if ($num_comments > 0) { | |
204 | if ($line["comments"]) { | |
205 | $comments_url = $line["comments"]; | |
206 | } else { | |
207 | $comments_url = $line["link"]; | |
208 | } | |
c1826240 | 209 | $entry_comments = "<a $link_target href=\"$comments_url\">$num_comments comments</a>"; |
11b0dce2 AD |
210 | } else { |
211 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
c1826240 | 212 | $entry_comments = "<a $link_target href=\"".$line["comments"]."\">comments</a>"; |
11b0dce2 | 213 | } |
f7181e9b AD |
214 | } |
215 | ||
e828e31e AD |
216 | print "<div class=\"postReply\">"; |
217 | ||
b810a0f1 | 218 | print "<div class=\"postHeader\">"; |
21703604 | 219 | |
a545b564 AD |
220 | $entry_author = $line["author"]; |
221 | ||
222 | if ($entry_author) { | |
d1db26aa | 223 | $entry_author = __(" - by ") . $entry_author; |
a545b564 | 224 | } |
1f64b1be | 225 | |
9167e250 AD |
226 | $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), |
227 | strtotime($line["updated"])); | |
228 | ||
b810a0f1 AD |
229 | print "<div class=\"postDate$rtl_class\">$parsed_updated</div>"; |
230 | ||
231 | if ($line["link"]) { | |
232 | print "<div clear='both'><a $link_target href=\"" . $line["link"] . "\">" . | |
233 | $line["title"] . "</a>$entry_author</div>"; | |
234 | } else { | |
235 | print "<div clear='both'>" . $line["title"] . "$entry_author</div>"; | |
236 | } | |
21703604 AD |
237 | |
238 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM | |
239 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
240 | ORDER BY tag_name"); | |
241 | ||
242 | $tags_str = ""; | |
42918a07 AD |
243 | $f_tags_str = ""; |
244 | ||
245 | $num_tags = 0; | |
21703604 AD |
246 | |
247 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
42918a07 AD |
248 | $num_tags++; |
249 | $tag = $tmp_line["tag_name"]; | |
ca676fb5 | 250 | $tag_str = "<a href=\"javascript:viewfeed('$tag')\">$tag</a>, "; |
42918a07 | 251 | |
b810a0f1 | 252 | if ($num_tags == 6) { |
42918a07 | 253 | $tags_str .= "<a href=\"javascript:showBlockElement('allEntryTags')\">...</a>"; |
b810a0f1 | 254 | } else if ($num_tags < 6) { |
42918a07 AD |
255 | $tags_str .= $tag_str; |
256 | } | |
257 | $f_tags_str .= $tag_str; | |
258 | } | |
21703604 | 259 | |
42918a07 AD |
260 | $tags_str = preg_replace("/, $/", "", $tags_str); |
261 | $f_tags_str = preg_replace("/, $/", "", $f_tags_str); | |
e828e31e | 262 | |
b810a0f1 | 263 | if (!$entry_comments) $entry_comments = " "; # placeholder |
21703604 | 264 | |
d1db26aa | 265 | if (!$tags_str) $tags_str = '<span class="tagList">'.__('no tags').'</span>'; |
3db880c6 | 266 | |
b810a0f1 | 267 | print "<div style='float : right'>$tags_str |
ffb761c9 AD |
268 | <a title=\"Edit tags for this article\" |
269 | href=\"javascript:editArticleTags($id, $feed_id)\">(+)</a></div> | |
b810a0f1 | 270 | <div clear='both'>$entry_comments</div>"; |
21703604 | 271 | |
b810a0f1 | 272 | print "</div>"; |
e828e31e AD |
273 | |
274 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
42918a07 AD |
275 | print "<div class=\"postContent\">"; |
276 | ||
0b126ac2 | 277 | if (db_num_rows($tmp_result) > 0) { |
d1db26aa | 278 | print "<div id=\"allEntryTags\">".__('Tags:')."$f_tags_str</div>"; |
42918a07 AD |
279 | } |
280 | ||
68511f86 AD |
281 | if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) { |
282 | $line["content"] = preg_replace("/href=/i", "target=\"_new\" href=", $line["content"]); | |
283 | } | |
284 | ||
a262b161 AD |
285 | $line["content"] = sanitize_rss($line["content"]); |
286 | ||
42918a07 | 287 | print $line["content"] . "</div>"; |
e828e31e AD |
288 | |
289 | print "</div>"; | |
290 | ||
d76a3b03 | 291 | } |
1cd17194 AD |
292 | } |
293 | ||
294 | if ($op == "viewfeed") { | |
295 | ||
3c81ae1a | 296 | $feed = db_escape_string($_GET["feed"]); |
3c81ae1a | 297 | $subop = db_escape_string($_GET["subop"]); |
86b682ce | 298 | $view_mode = db_escape_string($_GET["view_mode"]); |
3c81ae1a AD |
299 | $limit = db_escape_string($_GET["limit"]); |
300 | $cat_view = db_escape_string($_GET["cat"]); | |
e0998414 | 301 | $next_unread_feed = db_escape_string($_GET["nuf"]); |
203de776 AD |
302 | $offset = db_escape_string($_GET["skip"]); |
303 | ||
304 | if (!$offset) $offset = 0; | |
a1a8a2be | 305 | |
40496720 AD |
306 | set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode); |
307 | set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit); | |
308 | ||
476cac42 | 309 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 310 | |
472782e8 AD |
311 | if ($subop == "CatchupSelected") { |
312 | $ids = split(",", db_escape_string($_GET["ids"])); | |
313 | $cmode = sprintf("%d", $_GET["cmode"]); | |
314 | ||
315 | catchupArticlesById($link, $ids, $cmode); | |
316 | } | |
317 | ||
e0998414 AD |
318 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { |
319 | update_generic_feed($link, $feed, $cat_view); | |
320 | } | |
321 | ||
322 | if ($subop == "MarkAllRead") { | |
323 | catchup_feed($link, $feed, $cat_view); | |
324 | ||
325 | if (get_pref($link, 'ON_CATCHUP_SHOW_NEXT_FEED')) { | |
adba6b85 AD |
326 | if ($next_unread_feed) { |
327 | $feed = $next_unread_feed; | |
328 | } | |
e0998414 AD |
329 | } |
330 | } | |
331 | ||
a6b4a12a AD |
332 | if ($feed_id > 0) { |
333 | $result = db_query($link, | |
334 | "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1"); | |
e33a1fda | 335 | |
a6b4a12a | 336 | if (db_num_rows($result) == 0) { |
d1db26aa | 337 | print "<div align='center'>".__('Feed not found.')."</div>"; |
a6b4a12a AD |
338 | return; |
339 | } | |
e33a1fda AD |
340 | } |
341 | ||
2e915ba9 AD |
342 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
343 | ||
344 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
345 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
70f6dbb1 | 346 | |
2e915ba9 AD |
347 | if (db_num_rows($result) == 1) { |
348 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
349 | } else { | |
350 | $rtl_content = false; | |
351 | } | |
352 | ||
353 | if ($rtl_content) { | |
354 | $rtl_tag = "dir=\"RTL\""; | |
355 | } else { | |
356 | $rtl_tag = ""; | |
357 | } | |
70f6dbb1 AD |
358 | } else { |
359 | $rtl_tag = ""; | |
2e915ba9 | 360 | $rtl_content = false; |
70f6dbb1 AD |
361 | } |
362 | ||
8911ac8b AD |
363 | $script_dt_add = get_script_dt_add(); |
364 | ||
6b4163cb | 365 | /* print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
86b682ce | 366 | <script type=\"text/javascript\" src=\"prototype.js\"></script> |
53515ff1 AD |
367 | <script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> |
368 | <script type=\"text/javascript\" src=\"viewfeed.js?$script_dt_add\"></script> | |
59b8192f AD |
369 | <!--[if gte IE 5.5000]> |
370 | <script type=\"text/javascript\" src=\"pngfix.js\"></script> | |
371 | <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\"> | |
372 | <![endif]--> | |
10031c3b | 373 | </head><body $rtl_tag> |
59b8192f AD |
374 | <script type=\"text/javascript\"> |
375 | if (document.addEventListener) { | |
376 | document.addEventListener(\"DOMContentLoaded\", init, null); | |
377 | } | |
378 | window.onload = init; | |
6b4163cb | 379 | </script>"; */ |
59b8192f | 380 | |
ef393de7 AD |
381 | /// START ///////////////////////////////////////////////////////////////////////////////// |
382 | ||
86b682ce AD |
383 | $search = db_escape_string($_GET["query"]); |
384 | $search_mode = db_escape_string($_GET["search_mode"]); | |
385 | $match_on = db_escape_string($_GET["match_on"]); | |
52b51244 | 386 | |
86b682ce AD |
387 | if (!$match_on) { |
388 | $match_on = "both"; | |
389 | } | |
5c365f60 | 390 | |
203de776 AD |
391 | $real_offset = $offset * $limit; |
392 | ||
393 | $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, | |
394 | $search, $search_mode, $match_on, false, $real_offset); | |
b0005823 | 395 | |
ef393de7 AD |
396 | $result = $qfh_ret[0]; |
397 | $feed_title = $qfh_ret[1]; | |
c7188969 AD |
398 | $feed_site_url = $qfh_ret[2]; |
399 | $last_error = $qfh_ret[3]; | |
48f0adb0 | 400 | |
ef393de7 | 401 | /// STOP ////////////////////////////////////////////////////////////////////////////////// |
48f0adb0 | 402 | |
b15442c6 | 403 | print "<div id=\"headlinesContainer\" $rtl_tag>"; |
386cbf27 | 404 | |
48f0adb0 | 405 | if (!$result) { |
d1db26aa | 406 | print "<div align='center'>".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."</div>"; |
386cbf27 | 407 | return; |
adccd201 | 408 | } |
98bea1b1 | 409 | |
e6c115b2 | 410 | print_headline_subtoolbar($link, $feed_site_url, $feed_title, false, |
95a82c08 AD |
411 | $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode, |
412 | $offset, $limit); | |
98bea1b1 | 413 | |
e6c115b2 AD |
414 | print "<div id=\"headlinesInnerContainer\">"; |
415 | ||
416 | if (db_num_rows($result) > 0) { | |
11befbb2 | 417 | |
203de776 AD |
418 | # print "\{$offset}"; |
419 | ||
386cbf27 | 420 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 421 | print "<table class=\"headlinesList\" id=\"headlinesList\" |
972385a5 | 422 | cellspacing=\"0\">"; |
f4c10d44 | 423 | } |
386cbf27 | 424 | |
e5a99b88 AD |
425 | $lnum = 0; |
426 | ||
427 | error_reporting (DEFAULT_ERROR_LEVEL); | |
428 | ||
429 | $num_unread = 0; | |
430 | ||
431 | while ($line = db_fetch_assoc($result)) { | |
adccd201 | 432 | |
e5a99b88 AD |
433 | $class = ($lnum % 2) ? "even" : "odd"; |
434 | ||
435 | $id = $line["id"]; | |
436 | $feed_id = $line["feed_id"]; | |
437 | ||
438 | if ($line["last_read"] == "" && | |
439 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
440 | ||
441 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
442 | alt=\"Updated\">"; | |
443 | } else { | |
444 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
445 | alt=\"Updated\">"; | |
446 | } | |
447 | ||
448 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
449 | $class .= "Unread"; | |
450 | ++$num_unread; | |
386cbf27 | 451 | $is_unread = true; |
adccd201 | 452 | } else { |
386cbf27 | 453 | $is_unread = false; |
e5a99b88 AD |
454 | } |
455 | ||
456 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
457 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" | |
c50e2b30 | 458 | class=\"markedPic\" |
9932fb06 | 459 | alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
460 | } else { |
461 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
c50e2b30 | 462 | class=\"markedPic\" |
9932fb06 | 463 | alt=\"Set mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 | 464 | } |
a753538d AD |
465 | |
466 | # $content_link = "<a target=\"_new\" href=\"".$line["link"]."\">" . | |
467 | # $line["title"] . "</a>"; | |
468 | ||
e454a889 | 469 | $content_link = "<a href=\"javascript:view($id,$feed_id);\">" . |
e5a99b88 | 470 | $line["title"] . "</a>"; |
adccd201 | 471 | |
a753538d AD |
472 | # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" . |
473 | # $line["title"] . "</a>"; | |
474 | ||
e5a99b88 AD |
475 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
476 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
477 | } else { | |
478 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
479 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
480 | } | |
adccd201 AD |
481 | |
482 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
8fd0c717 | 483 | $content_preview = truncate_string(strip_tags($line["content_preview"]), |
070d0d2a | 484 | 100); |
adccd201 AD |
485 | } |
486 | ||
d4b4b9de AD |
487 | $entry_author = $line["author"]; |
488 | ||
489 | if ($entry_author) { | |
490 | $entry_author = " - by $entry_author"; | |
491 | } | |
492 | ||
386cbf27 | 493 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 AD |
494 | |
495 | print "<tr class='$class' id='RROW-$id'>"; | |
adccd201 AD |
496 | |
497 | print "<td class='hlUpdatePic'>$update_pic</td>"; | |
498 | ||
499 | print "<td class='hlSelectRow'> | |
500 | <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\" | |
501 | class=\"feedCheckBox\" id=\"RCHK-$id\"> | |
502 | </td>"; | |
503 | ||
504 | print "<td class='hlMarkedPic'>$marked_pic</td>"; | |
d4b4b9de | 505 | |
adccd201 AD |
506 | if ($line["feed_title"]) { |
507 | print "<td class='hlContent'>$content_link</td>"; | |
508 | print "<td class='hlFeed'> | |
faf40998 | 509 | <a href=\"javascript:viewfeed($feed_id, '', false)\">". |
9b1424fe | 510 | $line["feed_title"]."</a> </td>"; |
adccd201 | 511 | } else { |
de244d27 | 512 | print "<td class='hlContent' valign='middle'>"; |
e688bab8 | 513 | |
00dacdc1 AD |
514 | print "<a href=\"javascript:view($id,$feed_id);\">" . |
515 | $line["title"]; | |
516 | ||
3145d0ea | 517 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { |
adccd201 AD |
518 | if ($content_preview) { |
519 | print "<span class=\"contentPreview\"> - $content_preview</span>"; | |
520 | } | |
521 | } | |
522 | ||
523 | print "</a>"; | |
524 | print "</td>"; | |
525 | } | |
526 | ||
527 | print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>"; | |
528 | ||
529 | print "</tr>"; | |
530 | ||
531 | } else { | |
386cbf27 AD |
532 | |
533 | if ($is_unread) { | |
534 | $add_class = "Unread"; | |
535 | } else { | |
536 | $add_class = ""; | |
537 | } | |
538 | ||
539 | print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">"; | |
540 | ||
541 | print "<div class=\"cdmHeader\">"; | |
adccd201 | 542 | |
c50e2b30 | 543 | print "<div class=\"articleUpdated\">$updated_fmt</div>"; |
386cbf27 | 544 | |
5f51022a AD |
545 | print "<a class=\"title\" |
546 | onclick=\"javascript:toggleUnread($id, 0)\" | |
547 | target=\"new\" href=\"".$line["link"]."\">".$line["title"]."</a>"; | |
adccd201 | 548 | |
d4b4b9de AD |
549 | print $entry_author; |
550 | ||
386cbf27 AD |
551 | if ($line["feed_title"]) { |
552 | print " (<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)"; | |
adccd201 | 553 | } |
adccd201 | 554 | |
386cbf27 AD |
555 | print "</div>"; |
556 | ||
752bd598 | 557 | print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div><br clear=\"all\">"; |
5f51022a | 558 | |
c50e2b30 AD |
559 | print "<div class=\"cdmFooter\">"; |
560 | ||
561 | print "$marked_pic"; | |
13f08f75 | 562 | |
13f08f75 AD |
563 | print "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this, |
564 | 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\">"; | |
565 | ||
566 | $tags = get_article_tags($link, $id); | |
567 | ||
568 | $tags_str = ""; | |
569 | ||
570 | foreach ($tags as $tag) { | |
571 | $num_tags++; | |
572 | $tags_str .= "<a href=\"javascript:viewfeed('$tag')\">$tag</a>, "; | |
573 | } | |
574 | ||
575 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
c50e2b30 AD |
576 | |
577 | if ($tags_str == "") $tags_str = "no tags"; | |
13f08f75 | 578 | |
c50e2b30 | 579 | print " $tags_str <a title=\"Edit tags for this article\" |
13f08f75 AD |
580 | href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>"; |
581 | ||
582 | print "</div>"; | |
386cbf27 | 583 | |
5f51022a AD |
584 | # print "<div align=\"center\"><a class=\"cdmToggleLink\" |
585 | # href=\"javascript:toggleUnread($id)\"> | |
586 | # Toggle unread</a></div>"; | |
587 | ||
386cbf27 AD |
588 | print "</div>"; |
589 | ||
590 | } | |
e5a99b88 AD |
591 | |
592 | ++$lnum; | |
254e0e4b | 593 | } |
adccd201 | 594 | |
386cbf27 | 595 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 596 | print "</table>"; |
adccd201 | 597 | } |
d76a3b03 | 598 | |
11befbb2 AD |
599 | // print_headline_subtoolbar($link, |
600 | // "javascript:catchupPage()", "Mark page as read", true, $rtl_content); | |
98bea1b1 AD |
601 | |
602 | ||
e5a99b88 | 603 | } else { |
d1db26aa | 604 | print "<div class='whiteBox'>".__('No articles found.')."</div>"; |
a1a8a2be | 605 | } |
d76a3b03 | 606 | |
386cbf27 | 607 | print "</div>"; |
e6c115b2 AD |
608 | |
609 | print "</div>"; | |
1cd17194 AD |
610 | } |
611 | ||
0e091d38 | 612 | if ($op == "pref-feeds") { |
ef8be8ea AD |
613 | module_pref_feeds($link); |
614 | } | |
a7f22b70 | 615 | |
ef8be8ea AD |
616 | if ($op == "pref-filters") { |
617 | module_pref_filters($link); | |
618 | } | |
a0476535 | 619 | |
ef8be8ea AD |
620 | if ($op == "pref-labels") { |
621 | module_pref_labels($link); | |
622 | } | |
d0000401 | 623 | |
f27d955a AD |
624 | if ($op == "pref-prefs") { |
625 | module_pref_prefs($link); | |
626 | } | |
627 | ||
628 | if ($op == "pref-users") { | |
629 | module_pref_users($link); | |
ef8be8ea | 630 | } |
a0476535 | 631 | |
ef8be8ea AD |
632 | if ($op == "help") { |
633 | module_help($link); | |
634 | } | |
a0476535 | 635 | |
ef8be8ea AD |
636 | if ($op == "dlg") { |
637 | module_popup_dialog($link); | |
638 | } | |
a7f22b70 | 639 | |
ef8be8ea AD |
640 | // update feeds of all users, may be used anonymously |
641 | if ($op == "globalUpdateFeeds") { | |
a7f22b70 | 642 | |
ef8be8ea | 643 | $result = db_query($link, "SELECT id FROM ttrss_users"); |
a0476535 | 644 | |
ef8be8ea AD |
645 | while ($line = db_fetch_assoc($result)) { |
646 | $user_id = $line["id"]; | |
647 | // print "<!-- updating feeds of uid $user_id -->"; | |
648 | update_all_feeds($link, false, $user_id); | |
649 | } | |
e2f728be | 650 | |
ef8be8ea AD |
651 | print "<rpc-reply> |
652 | <message msg=\"All feeds updated\"/> | |
653 | </rpc-reply>"; | |
e5d758e3 | 654 | |
ef8be8ea | 655 | } |
f9cb39ac | 656 | |
ef8be8ea | 657 | if ($op == "user-details") { |
0af33e87 | 658 | |
ef8be8ea AD |
659 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { |
660 | return; | |
661 | } | |
662 | ||
663 | /* print "<html><head> | |
664 | <title>Tiny Tiny RSS : User Details</title> | |
665 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
666 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
667 | </head><body>"; */ | |
0af33e87 | 668 | |
ef8be8ea | 669 | $uid = sprintf("%d", $_GET["id"]); |
dc932d0a | 670 | |
ef8be8ea | 671 | print "<div id=\"infoBoxTitle\">User details</div>"; |
dc932d0a | 672 | |
ef8be8ea | 673 | print "<div class='infoBoxContents'>"; |
f9cb39ac | 674 | |
ef8be8ea AD |
675 | $result = db_query($link, "SELECT login, |
676 | SUBSTRING(last_login,1,16) AS last_login, | |
677 | access_level, | |
678 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
679 | WHERE owner_uid = id) AS stored_articles | |
680 | FROM ttrss_users | |
681 | WHERE id = '$uid'"); | |
f9cb39ac | 682 | |
ef8be8ea AD |
683 | if (db_num_rows($result) == 0) { |
684 | print "<h1>User not found</h1>"; | |
685 | return; | |
686 | } | |
687 | ||
688 | # print "<h1>User Details</h1>"; | |
f9cb39ac | 689 | |
ef8be8ea | 690 | $login = db_fetch_result($result, 0, "login"); |
b92e6209 | 691 | |
ef8be8ea | 692 | # print "<h1>$login</h1>"; |
dc932d0a | 693 | |
ef8be8ea | 694 | print "<table width='100%'>"; |
dc932d0a | 695 | |
ef8be8ea AD |
696 | $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), |
697 | strtotime(db_fetch_result($result, 0, "last_login"))); | |
698 | $access_level = db_fetch_result($result, 0, "access_level"); | |
699 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); | |
f9cb39ac | 700 | |
ef8be8ea AD |
701 | # print "<tr><td>Username</td><td>$login</td></tr>"; |
702 | # print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
703 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
704 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; | |
f9cb39ac | 705 | |
ef8be8ea AD |
706 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds |
707 | WHERE owner_uid = '$uid'"); | |
f9cb39ac | 708 | |
ef8be8ea | 709 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); |
f9cb39ac | 710 | |
ef8be8ea | 711 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; |
0ea4fb50 | 712 | |
ef8be8ea AD |
713 | /* $result = db_query($link, "SELECT |
714 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size | |
715 | FROM ttrss_user_entries,ttrss_entries | |
716 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
0ea4fb50 | 717 | |
ef8be8ea | 718 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
0ea4fb50 | 719 | |
ef8be8ea | 720 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ |
e5d758e3 | 721 | |
ef8be8ea | 722 | print "</table>"; |
e5d758e3 | 723 | |
ef8be8ea | 724 | print "<h1>Subscribed feeds</h1>"; |
e5d758e3 | 725 | |
ef8be8ea AD |
726 | $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds |
727 | WHERE owner_uid = '$uid' ORDER BY title"); | |
0ea4fb50 | 728 | |
ef8be8ea | 729 | print "<ul class=\"userFeedList\">"; |
0ea4fb50 | 730 | |
ef8be8ea | 731 | $row_class = "odd"; |
0ea4fb50 | 732 | |
ef8be8ea | 733 | while ($line = db_fetch_assoc($result)) { |
0ea4fb50 | 734 | |
ef8be8ea | 735 | $icon_file = ICONS_URL."/".$line["id"].".ico"; |
ad815c71 | 736 | |
ef8be8ea AD |
737 | if (file_exists($icon_file) && filesize($icon_file) > 0) { |
738 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; | |
739 | } else { | |
740 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
741 | } | |
0ea4fb50 | 742 | |
ef8be8ea | 743 | print "<li class=\"$row_class\">$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>"; |
0ea4fb50 | 744 | |
ef8be8ea | 745 | $row_class = toggleEvenOdd($row_class); |
0ea4fb50 | 746 | |
ef8be8ea | 747 | } |
a283b8d1 | 748 | |
ef8be8ea AD |
749 | if (db_num_rows($result) < $num_feeds) { |
750 | // FIXME - add link to show ALL subscribed feeds here somewhere | |
751 | print "<li><img | |
752 | class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>"; | |
753 | } | |
754 | ||
755 | print "</ul>"; | |
a283b8d1 | 756 | |
ef8be8ea | 757 | print "</div>"; |
0ea4fb50 | 758 | |
ef8be8ea AD |
759 | print "<div align='center'> |
760 | <input type='submit' class='button' | |
761 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
0ea4fb50 | 762 | |
ef8be8ea | 763 | // print "</body></html>"; |
0ea4fb50 | 764 | |
ef8be8ea | 765 | } |
ad815c71 | 766 | |
ef8be8ea | 767 | if ($op == "pref-feed-browser") { |
f27d955a | 768 | module_pref_feed_browser($link); |
c6232e43 AD |
769 | } |
770 | ||
18664970 AD |
771 | if ($op == "rss") { |
772 | $feed = db_escape_string($_GET["id"]); | |
773 | $user = db_escape_string($_GET["user"]); | |
774 | $pass = db_escape_string($_GET["pass"]); | |
775 | $is_cat = $_GET["is_cat"] != false; | |
776 | ||
e1eb2147 AD |
777 | $search = db_escape_string($_GET["q"]); |
778 | $match_on = db_escape_string($_GET["m"]); | |
779 | $search_mode = db_escape_string($_GET["smode"]); | |
780 | ||
18664970 AD |
781 | if (!$_SESSION["uid"] && $user && $pass) { |
782 | authenticate_user($link, $user, $pass); | |
783 | } | |
784 | ||
785 | if ($_SESSION["uid"] || | |
786 | http_authenticate_user($link)) { | |
787 | ||
e1eb2147 AD |
788 | generate_syndicated_feed($link, $feed, $is_cat, |
789 | $search, $search_mode, $match_on); | |
18664970 AD |
790 | } |
791 | } | |
792 | ||
88040f57 AD |
793 | if ($op == "labelFromSearch") { |
794 | $search = db_escape_string($_GET["search"]); | |
795 | $search_mode = db_escape_string($_GET["smode"]); | |
796 | $match_on = db_escape_string($_GET["match"]); | |
797 | $is_cat = db_escape_string($_GET["is_cat"]); | |
798 | $title = db_escape_string($_GET["title"]); | |
799 | $feed = sprintf("%d", $_GET["feed"]); | |
800 | ||
801 | $label_qparts = array(); | |
802 | ||
803 | $search_expr = getSearchSql($search, $match_on); | |
804 | ||
805 | if ($is_cat) { | |
806 | if ($feed != 0) { | |
807 | $search_expr .= " AND ttrss_feeds.cat_id = $feed "; | |
808 | } else { | |
809 | $search_expr .= " AND ttrss_feeds.cat_id IS NULL "; | |
810 | } | |
811 | } else { | |
812 | if ($search_mode == "all_feeds") { | |
813 | // NOOP | |
814 | } else if ($search_mode == "this_cat") { | |
815 | ||
816 | $tmp_result = db_query($link, "SELECT cat_id | |
817 | FROM ttrss_feeds WHERE id = '$feed'"); | |
818 | ||
819 | $cat_id = db_fetch_result($tmp_result, 0, "cat_id"); | |
820 | ||
821 | if ($cat_id > 0) { | |
822 | $search_expr .= " AND ttrss_feeds.cat_id = $cat_id "; | |
823 | } else { | |
824 | $search_expr .= " AND ttrss_feeds.cat_id IS NULL "; | |
825 | } | |
826 | } else { | |
827 | $search_expr .= " AND ttrss_feeds.id = $feed "; | |
828 | } | |
829 | ||
830 | } | |
831 | ||
832 | $search_expr = db_escape_string($search_expr); | |
833 | ||
834 | print $search_expr; | |
835 | ||
836 | if ($title) { | |
837 | $result = db_query($link, | |
838 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) | |
839 | VALUES ('$search_expr', '$title', '".$_SESSION["uid"]."')"); | |
840 | } | |
841 | } | |
842 | ||
f3acc32e AD |
843 | if ($op == "getUnread") { |
844 | $login = db_escape_string($_GET["login"]); | |
845 | ||
7e3634d9 | 846 | header("Content-Type: text/plain; charset=utf-8"); |
f3acc32e AD |
847 | |
848 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'"); | |
849 | ||
850 | if (db_num_rows($result) == 1) { | |
851 | $uid = db_fetch_result($result, 0, "id"); | |
852 | print getGlobalUnread($link, $uid); | |
853 | } else { | |
0599d09e | 854 | print "-1;User not found"; |
f3acc32e | 855 | } |
7e3634d9 AD |
856 | |
857 | $print_exec_time = false; | |
858 | } | |
859 | ||
860 | if ($op == "digestTest") { | |
861 | header("Content-Type: text/plain"); | |
9cd7c995 AD |
862 | print_r(prepare_headlines_digest($link, $_SESSION["uid"])); |
863 | $print_exec_time = false; | |
864 | ||
865 | } | |
448b0abd | 866 | |
9cd7c995 AD |
867 | if ($op == "digestSend") { |
868 | header("Content-Type: text/plain"); | |
869 | send_headlines_digests($link); | |
7e3634d9 AD |
870 | $print_exec_time = false; |
871 | ||
f3acc32e AD |
872 | } |
873 | ||
4b3dff6e | 874 | db_close($link); |
1cd17194 | 875 | ?> |
406d9489 | 876 | |
7e3634d9 | 877 | <?php if ($print_exec_time) { ?> |
1d3a17c7 | 878 | <!-- <?php echo sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> |
f3acc32e | 879 | <?php } ?> |