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