]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
36bfab86 | 2 | require_once "sessions.php"; |
c339343b | 3 | require_once "modules/backend-rpc.php"; |
36bfab86 | 4 | |
59b8192f | 5 | header("Cache-Control: no-cache, must-revalidate"); |
6002818b AD |
6 | header("Cache-Control: no-cache, must-revalidate"); |
7 | ||
ce0619bb AD |
8 | header("Pragma: no-cache"); |
9 | header("Expires: -1"); | |
de696427 | 10 | |
894ebcf5 | 11 | /* if ($_GET["debug"]) { |
cce28758 AD |
12 | define('DEFAULT_ERROR_LEVEL', E_ALL); |
13 | } else { | |
14 | define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); | |
15 | } | |
894ebcf5 AD |
16 | |
17 | error_reporting(DEFAULT_ERROR_LEVEL); */ | |
cce28758 | 18 | |
262bd8ea AD |
19 | $op = $_REQUEST["op"]; |
20 | ||
9ebaec05 | 21 | define('SCHEMA_VERSION', 12); |
657770a0 AD |
22 | |
23 | require_once "sanity_check.php"; | |
24 | require_once "config.php"; | |
af106b0e AD |
25 | |
26 | require_once "db.php"; | |
27 | require_once "db-prefs.php"; | |
28 | require_once "functions.php"; | |
657770a0 | 29 | |
c339343b | 30 | $print_exec_time = false; |
7e3634d9 | 31 | |
4803eed2 | 32 | if ((!$op || $op == "rpc" || $op == "rss" || $op == "digestSend" || |
18664970 | 33 | $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { |
6002818b AD |
34 | header("Content-Type: application/xml; charset=utf-8"); |
35 | } else { | |
36 | header("Content-Type: text/html; charset=utf-8"); | |
262bd8ea AD |
37 | } |
38 | ||
f3acc32e AD |
39 | if (!$op) { |
40 | header("Content-Type: application/xml"); | |
41 | print_error_xml(7); exit; | |
42 | } | |
43 | ||
44 | if (!$_SESSION["uid"] && $op != "globalUpdateFeeds" && $op != "rss" && $op != "getUnread") { | |
262bd8ea | 45 | |
a2770077 | 46 | if ($op == "rpc") { |
af106b0e | 47 | print_error_xml(6); die; |
04269460 AD |
48 | } else { |
49 | print " | |
50 | <html><body> | |
51 | <p>Error: Not logged in.</p> | |
52 | <script type=\"text/javascript\"> | |
53 | if (parent.window != 'undefined') { | |
54 | parent.window.location = \"login.php\"; | |
55 | } else { | |
56 | window.location = \"login.php\"; | |
57 | } | |
58 | </script> | |
59 | </body></html> | |
60 | "; | |
262bd8ea AD |
61 | } |
62 | exit; | |
63 | } | |
1c7f75ed | 64 | |
ad815c71 | 65 | $purge_intervals = array( |
b8699345 AD |
66 | 0 => _("Use default"), |
67 | -1 => _("Never purge"), | |
68 | 5 => _("1 week old"), | |
69 | 14 => _("2 weeks old"), | |
70 | 31 => _("1 month old"), | |
71 | 60 => _("2 months old"), | |
72 | 90 => _("3 months old")); | |
ad815c71 AD |
73 | |
74 | $update_intervals = array( | |
b8699345 AD |
75 | 0 => _("Use default"), |
76 | -1 => _("Disable updates"), | |
77 | 30 => _("Each 30 minutes"), | |
78 | 60 => _("Hourly"), | |
79 | 240 => _("Each 4 hours"), | |
80 | 720 => _("Each 12 hours"), | |
81 | 1440 => _("Daily"), | |
2677796d | 82 | 10080 => _("Weekly")); |
ad815c71 | 83 | |
d20f3544 | 84 | |
3c5783b7 | 85 | $access_level_names = array( |
b8699345 AD |
86 | 0 => _("User"), |
87 | 10 => _("Administrator")); | |
3c5783b7 | 88 | |
f27d955a | 89 | require_once "modules/pref-prefs.php"; |
ef8be8ea AD |
90 | require_once "modules/popup-dialog.php"; |
91 | require_once "modules/help.php"; | |
92 | require_once "modules/pref-feeds.php"; | |
93 | require_once "modules/pref-filters.php"; | |
94 | require_once "modules/pref-labels.php"; | |
95 | require_once "modules/pref-users.php"; | |
c339343b | 96 | require_once "modules/pref-feed-browser.php"; |
ef8be8ea | 97 | |
406d9489 AD |
98 | $script_started = getmicrotime(); |
99 | ||
648472a7 | 100 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
d76a3b03 | 101 | |
5136011e AD |
102 | if (!$link) { |
103 | if (DB_TYPE == "mysql") { | |
104 | print mysql_error(); | |
105 | } | |
106 | // PG seems to display its own errors just fine by default. | |
107 | return; | |
108 | } | |
109 | ||
648472a7 AD |
110 | if (DB_TYPE == "pgsql") { |
111 | pg_query("set client_encoding = 'utf-8'"); | |
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) { | |
b8699345 | 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 | |
b8699345 | 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) { |
b8699345 | 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 | |
476cac42 | 306 | if ($subop == "undefined") $subop = ""; |
1cd17194 | 307 | |
472782e8 AD |
308 | if ($subop == "CatchupSelected") { |
309 | $ids = split(",", db_escape_string($_GET["ids"])); | |
310 | $cmode = sprintf("%d", $_GET["cmode"]); | |
311 | ||
312 | catchupArticlesById($link, $ids, $cmode); | |
313 | } | |
314 | ||
e0998414 AD |
315 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { |
316 | update_generic_feed($link, $feed, $cat_view); | |
317 | } | |
318 | ||
319 | if ($subop == "MarkAllRead") { | |
320 | catchup_feed($link, $feed, $cat_view); | |
321 | ||
322 | if (get_pref($link, 'ON_CATCHUP_SHOW_NEXT_FEED')) { | |
adba6b85 AD |
323 | if ($next_unread_feed) { |
324 | $feed = $next_unread_feed; | |
325 | } | |
e0998414 AD |
326 | } |
327 | } | |
328 | ||
a6b4a12a AD |
329 | if ($feed_id > 0) { |
330 | $result = db_query($link, | |
331 | "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1"); | |
e33a1fda | 332 | |
a6b4a12a | 333 | if (db_num_rows($result) == 0) { |
b8699345 | 334 | print "<div align='center'>"._('Feed not found.')."</div>"; |
a6b4a12a AD |
335 | return; |
336 | } | |
e33a1fda AD |
337 | } |
338 | ||
2e915ba9 AD |
339 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
340 | ||
341 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
342 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
70f6dbb1 | 343 | |
2e915ba9 AD |
344 | if (db_num_rows($result) == 1) { |
345 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
346 | } else { | |
347 | $rtl_content = false; | |
348 | } | |
349 | ||
350 | if ($rtl_content) { | |
351 | $rtl_tag = "dir=\"RTL\""; | |
352 | } else { | |
353 | $rtl_tag = ""; | |
354 | } | |
70f6dbb1 AD |
355 | } else { |
356 | $rtl_tag = ""; | |
2e915ba9 | 357 | $rtl_content = false; |
70f6dbb1 AD |
358 | } |
359 | ||
8911ac8b AD |
360 | $script_dt_add = get_script_dt_add(); |
361 | ||
6b4163cb | 362 | /* print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
86b682ce | 363 | <script type=\"text/javascript\" src=\"prototype.js\"></script> |
53515ff1 AD |
364 | <script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> |
365 | <script type=\"text/javascript\" src=\"viewfeed.js?$script_dt_add\"></script> | |
59b8192f AD |
366 | <!--[if gte IE 5.5000]> |
367 | <script type=\"text/javascript\" src=\"pngfix.js\"></script> | |
368 | <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\"> | |
369 | <![endif]--> | |
10031c3b | 370 | </head><body $rtl_tag> |
59b8192f AD |
371 | <script type=\"text/javascript\"> |
372 | if (document.addEventListener) { | |
373 | document.addEventListener(\"DOMContentLoaded\", init, null); | |
374 | } | |
375 | window.onload = init; | |
6b4163cb | 376 | </script>"; */ |
59b8192f | 377 | |
ef393de7 AD |
378 | /// START ///////////////////////////////////////////////////////////////////////////////// |
379 | ||
86b682ce AD |
380 | $search = db_escape_string($_GET["query"]); |
381 | $search_mode = db_escape_string($_GET["search_mode"]); | |
382 | $match_on = db_escape_string($_GET["match_on"]); | |
52b51244 | 383 | |
86b682ce AD |
384 | if (!$match_on) { |
385 | $match_on = "both"; | |
386 | } | |
5c365f60 | 387 | |
203de776 AD |
388 | $real_offset = $offset * $limit; |
389 | ||
390 | $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, | |
391 | $search, $search_mode, $match_on, false, $real_offset); | |
b0005823 | 392 | |
ef393de7 AD |
393 | $result = $qfh_ret[0]; |
394 | $feed_title = $qfh_ret[1]; | |
c7188969 AD |
395 | $feed_site_url = $qfh_ret[2]; |
396 | $last_error = $qfh_ret[3]; | |
48f0adb0 | 397 | |
ef393de7 | 398 | /// STOP ////////////////////////////////////////////////////////////////////////////////// |
48f0adb0 | 399 | |
b15442c6 | 400 | print "<div id=\"headlinesContainer\" $rtl_tag>"; |
386cbf27 | 401 | |
48f0adb0 | 402 | if (!$result) { |
b8699345 | 403 | print "<div align='center'>"._("Could not display feed (query failed). Please check label match syntax or local configuration.")."</div>"; |
386cbf27 | 404 | return; |
adccd201 | 405 | } |
98bea1b1 | 406 | |
e6c115b2 AD |
407 | print_headline_subtoolbar($link, $feed_site_url, $feed_title, false, |
408 | $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode, $offset); | |
98bea1b1 | 409 | |
e6c115b2 AD |
410 | print "<div id=\"headlinesInnerContainer\">"; |
411 | ||
412 | if (db_num_rows($result) > 0) { | |
11befbb2 | 413 | |
203de776 AD |
414 | # print "\{$offset}"; |
415 | ||
386cbf27 | 416 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 417 | print "<table class=\"headlinesList\" id=\"headlinesList\" |
10031c3b | 418 | cellspacing=\"0\" width=\"100%\">"; |
f4c10d44 | 419 | } |
386cbf27 | 420 | |
e5a99b88 AD |
421 | $lnum = 0; |
422 | ||
423 | error_reporting (DEFAULT_ERROR_LEVEL); | |
424 | ||
425 | $num_unread = 0; | |
426 | ||
427 | while ($line = db_fetch_assoc($result)) { | |
adccd201 | 428 | |
e5a99b88 AD |
429 | $class = ($lnum % 2) ? "even" : "odd"; |
430 | ||
431 | $id = $line["id"]; | |
432 | $feed_id = $line["feed_id"]; | |
433 | ||
434 | if ($line["last_read"] == "" && | |
435 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
436 | ||
437 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
438 | alt=\"Updated\">"; | |
439 | } else { | |
440 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
441 | alt=\"Updated\">"; | |
442 | } | |
443 | ||
444 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
445 | $class .= "Unread"; | |
446 | ++$num_unread; | |
386cbf27 | 447 | $is_unread = true; |
adccd201 | 448 | } else { |
386cbf27 | 449 | $is_unread = false; |
e5a99b88 AD |
450 | } |
451 | ||
452 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
453 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" | |
9932fb06 | 454 | alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
455 | } else { |
456 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
9932fb06 | 457 | alt=\"Set mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 | 458 | } |
a753538d AD |
459 | |
460 | # $content_link = "<a target=\"_new\" href=\"".$line["link"]."\">" . | |
461 | # $line["title"] . "</a>"; | |
462 | ||
e454a889 | 463 | $content_link = "<a href=\"javascript:view($id,$feed_id);\">" . |
e5a99b88 | 464 | $line["title"] . "</a>"; |
adccd201 | 465 | |
a753538d AD |
466 | # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" . |
467 | # $line["title"] . "</a>"; | |
468 | ||
e5a99b88 AD |
469 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
470 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
471 | } else { | |
472 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
473 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
474 | } | |
adccd201 AD |
475 | |
476 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
8fd0c717 | 477 | $content_preview = truncate_string(strip_tags($line["content_preview"]), |
070d0d2a | 478 | 100); |
adccd201 AD |
479 | } |
480 | ||
d4b4b9de AD |
481 | $entry_author = $line["author"]; |
482 | ||
483 | if ($entry_author) { | |
484 | $entry_author = " - by $entry_author"; | |
485 | } | |
486 | ||
386cbf27 | 487 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 AD |
488 | |
489 | print "<tr class='$class' id='RROW-$id'>"; | |
adccd201 AD |
490 | |
491 | print "<td class='hlUpdatePic'>$update_pic</td>"; | |
492 | ||
493 | print "<td class='hlSelectRow'> | |
494 | <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\" | |
495 | class=\"feedCheckBox\" id=\"RCHK-$id\"> | |
496 | </td>"; | |
497 | ||
498 | print "<td class='hlMarkedPic'>$marked_pic</td>"; | |
d4b4b9de | 499 | |
adccd201 AD |
500 | if ($line["feed_title"]) { |
501 | print "<td class='hlContent'>$content_link</td>"; | |
502 | print "<td class='hlFeed'> | |
faf40998 | 503 | <a href=\"javascript:viewfeed($feed_id, '', false)\">". |
9b1424fe | 504 | $line["feed_title"]."</a> </td>"; |
adccd201 | 505 | } else { |
de244d27 | 506 | print "<td class='hlContent' valign='middle'>"; |
e688bab8 | 507 | |
00dacdc1 AD |
508 | print "<a href=\"javascript:view($id,$feed_id);\">" . |
509 | $line["title"]; | |
510 | ||
3145d0ea | 511 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { |
adccd201 AD |
512 | if ($content_preview) { |
513 | print "<span class=\"contentPreview\"> - $content_preview</span>"; | |
514 | } | |
515 | } | |
516 | ||
517 | print "</a>"; | |
518 | print "</td>"; | |
519 | } | |
520 | ||
521 | print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>"; | |
522 | ||
523 | print "</tr>"; | |
524 | ||
525 | } else { | |
386cbf27 AD |
526 | |
527 | if ($is_unread) { | |
528 | $add_class = "Unread"; | |
529 | } else { | |
530 | $add_class = ""; | |
531 | } | |
532 | ||
533 | print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">"; | |
534 | ||
535 | print "<div class=\"cdmHeader\">"; | |
adccd201 | 536 | |
13f08f75 | 537 | print "<div style=\"float : right\">$updated_fmt |
ba0978c8 AD |
538 | <!-- <a class=\"cdmToggleLink\" |
539 | href=\"javascript:toggleUnread($id)\">Toggle unread</a> --> | |
5f51022a | 540 | </div>"; |
386cbf27 | 541 | |
5f51022a AD |
542 | print "<a class=\"title\" |
543 | onclick=\"javascript:toggleUnread($id, 0)\" | |
544 | target=\"new\" href=\"".$line["link"]."\">".$line["title"]."</a>"; | |
adccd201 | 545 | |
d4b4b9de AD |
546 | print $entry_author; |
547 | ||
386cbf27 AD |
548 | if ($line["feed_title"]) { |
549 | print " (<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)"; | |
adccd201 | 550 | } |
adccd201 | 551 | |
386cbf27 AD |
552 | print "</div>"; |
553 | ||
752bd598 | 554 | print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div><br clear=\"all\">"; |
5f51022a | 555 | |
386cbf27 | 556 | print "<div style=\"float : right\">$marked_pic</div> |
13f08f75 AD |
557 | <div class=\"cdmFooter\">"; |
558 | ||
559 | ||
560 | print "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this, | |
561 | 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\">"; | |
562 | ||
563 | $tags = get_article_tags($link, $id); | |
564 | ||
565 | $tags_str = ""; | |
566 | ||
567 | foreach ($tags as $tag) { | |
568 | $num_tags++; | |
569 | $tags_str .= "<a href=\"javascript:viewfeed('$tag')\">$tag</a>, "; | |
570 | } | |
571 | ||
572 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
573 | ||
574 | print " $tags_str <a title=\"Edit tags for this article\" | |
575 | href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>"; | |
576 | ||
577 | print "</div>"; | |
386cbf27 | 578 | |
5f51022a AD |
579 | # print "<div align=\"center\"><a class=\"cdmToggleLink\" |
580 | # href=\"javascript:toggleUnread($id)\"> | |
581 | # Toggle unread</a></div>"; | |
582 | ||
386cbf27 AD |
583 | print "</div>"; |
584 | ||
585 | } | |
e5a99b88 AD |
586 | |
587 | ++$lnum; | |
254e0e4b | 588 | } |
adccd201 | 589 | |
386cbf27 | 590 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 591 | print "</table>"; |
adccd201 | 592 | } |
d76a3b03 | 593 | |
11befbb2 AD |
594 | // print_headline_subtoolbar($link, |
595 | // "javascript:catchupPage()", "Mark page as read", true, $rtl_content); | |
98bea1b1 AD |
596 | |
597 | ||
e5a99b88 | 598 | } else { |
b8699345 | 599 | print "<div class='whiteBox'>"._('No articles found.')."</div>"; |
a1a8a2be | 600 | } |
d76a3b03 | 601 | |
386cbf27 | 602 | print "</div>"; |
e6c115b2 AD |
603 | |
604 | print "</div>"; | |
1cd17194 AD |
605 | } |
606 | ||
0e091d38 | 607 | if ($op == "pref-feeds") { |
ef8be8ea AD |
608 | module_pref_feeds($link); |
609 | } | |
a7f22b70 | 610 | |
ef8be8ea AD |
611 | if ($op == "pref-filters") { |
612 | module_pref_filters($link); | |
613 | } | |
a0476535 | 614 | |
ef8be8ea AD |
615 | if ($op == "pref-labels") { |
616 | module_pref_labels($link); | |
617 | } | |
d0000401 | 618 | |
f27d955a AD |
619 | if ($op == "pref-prefs") { |
620 | module_pref_prefs($link); | |
621 | } | |
622 | ||
623 | if ($op == "pref-users") { | |
624 | module_pref_users($link); | |
ef8be8ea | 625 | } |
a0476535 | 626 | |
ef8be8ea AD |
627 | if ($op == "help") { |
628 | module_help($link); | |
629 | } | |
a0476535 | 630 | |
ef8be8ea AD |
631 | if ($op == "dlg") { |
632 | module_popup_dialog($link); | |
633 | } | |
a7f22b70 | 634 | |
ef8be8ea AD |
635 | // update feeds of all users, may be used anonymously |
636 | if ($op == "globalUpdateFeeds") { | |
a7f22b70 | 637 | |
ef8be8ea | 638 | $result = db_query($link, "SELECT id FROM ttrss_users"); |
a0476535 | 639 | |
ef8be8ea AD |
640 | while ($line = db_fetch_assoc($result)) { |
641 | $user_id = $line["id"]; | |
642 | // print "<!-- updating feeds of uid $user_id -->"; | |
643 | update_all_feeds($link, false, $user_id); | |
644 | } | |
e2f728be | 645 | |
ef8be8ea AD |
646 | print "<rpc-reply> |
647 | <message msg=\"All feeds updated\"/> | |
648 | </rpc-reply>"; | |
e5d758e3 | 649 | |
ef8be8ea | 650 | } |
f9cb39ac | 651 | |
ef8be8ea | 652 | if ($op == "user-details") { |
0af33e87 | 653 | |
ef8be8ea AD |
654 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { |
655 | return; | |
656 | } | |
657 | ||
658 | /* print "<html><head> | |
659 | <title>Tiny Tiny RSS : User Details</title> | |
660 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
661 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
662 | </head><body>"; */ | |
0af33e87 | 663 | |
ef8be8ea | 664 | $uid = sprintf("%d", $_GET["id"]); |
dc932d0a | 665 | |
ef8be8ea | 666 | print "<div id=\"infoBoxTitle\">User details</div>"; |
dc932d0a | 667 | |
ef8be8ea | 668 | print "<div class='infoBoxContents'>"; |
f9cb39ac | 669 | |
ef8be8ea AD |
670 | $result = db_query($link, "SELECT login, |
671 | SUBSTRING(last_login,1,16) AS last_login, | |
672 | access_level, | |
673 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
674 | WHERE owner_uid = id) AS stored_articles | |
675 | FROM ttrss_users | |
676 | WHERE id = '$uid'"); | |
f9cb39ac | 677 | |
ef8be8ea AD |
678 | if (db_num_rows($result) == 0) { |
679 | print "<h1>User not found</h1>"; | |
680 | return; | |
681 | } | |
682 | ||
683 | # print "<h1>User Details</h1>"; | |
f9cb39ac | 684 | |
ef8be8ea | 685 | $login = db_fetch_result($result, 0, "login"); |
b92e6209 | 686 | |
ef8be8ea | 687 | # print "<h1>$login</h1>"; |
dc932d0a | 688 | |
ef8be8ea | 689 | print "<table width='100%'>"; |
dc932d0a | 690 | |
ef8be8ea AD |
691 | $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), |
692 | strtotime(db_fetch_result($result, 0, "last_login"))); | |
693 | $access_level = db_fetch_result($result, 0, "access_level"); | |
694 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); | |
f9cb39ac | 695 | |
ef8be8ea AD |
696 | # print "<tr><td>Username</td><td>$login</td></tr>"; |
697 | # print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
698 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
699 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; | |
f9cb39ac | 700 | |
ef8be8ea AD |
701 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds |
702 | WHERE owner_uid = '$uid'"); | |
f9cb39ac | 703 | |
ef8be8ea | 704 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); |
f9cb39ac | 705 | |
ef8be8ea | 706 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; |
0ea4fb50 | 707 | |
ef8be8ea AD |
708 | /* $result = db_query($link, "SELECT |
709 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size | |
710 | FROM ttrss_user_entries,ttrss_entries | |
711 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
0ea4fb50 | 712 | |
ef8be8ea | 713 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
0ea4fb50 | 714 | |
ef8be8ea | 715 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ |
e5d758e3 | 716 | |
ef8be8ea | 717 | print "</table>"; |
e5d758e3 | 718 | |
ef8be8ea | 719 | print "<h1>Subscribed feeds</h1>"; |
e5d758e3 | 720 | |
ef8be8ea AD |
721 | $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds |
722 | WHERE owner_uid = '$uid' ORDER BY title"); | |
0ea4fb50 | 723 | |
ef8be8ea | 724 | print "<ul class=\"userFeedList\">"; |
0ea4fb50 | 725 | |
ef8be8ea | 726 | $row_class = "odd"; |
0ea4fb50 | 727 | |
ef8be8ea | 728 | while ($line = db_fetch_assoc($result)) { |
0ea4fb50 | 729 | |
ef8be8ea | 730 | $icon_file = ICONS_URL."/".$line["id"].".ico"; |
ad815c71 | 731 | |
ef8be8ea AD |
732 | if (file_exists($icon_file) && filesize($icon_file) > 0) { |
733 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; | |
734 | } else { | |
735 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
736 | } | |
0ea4fb50 | 737 | |
ef8be8ea | 738 | print "<li class=\"$row_class\">$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>"; |
0ea4fb50 | 739 | |
ef8be8ea | 740 | $row_class = toggleEvenOdd($row_class); |
0ea4fb50 | 741 | |
ef8be8ea | 742 | } |
a283b8d1 | 743 | |
ef8be8ea AD |
744 | if (db_num_rows($result) < $num_feeds) { |
745 | // FIXME - add link to show ALL subscribed feeds here somewhere | |
746 | print "<li><img | |
747 | class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>"; | |
748 | } | |
749 | ||
750 | print "</ul>"; | |
a283b8d1 | 751 | |
ef8be8ea | 752 | print "</div>"; |
0ea4fb50 | 753 | |
ef8be8ea AD |
754 | print "<div align='center'> |
755 | <input type='submit' class='button' | |
756 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
0ea4fb50 | 757 | |
ef8be8ea | 758 | // print "</body></html>"; |
0ea4fb50 | 759 | |
ef8be8ea | 760 | } |
ad815c71 | 761 | |
ef8be8ea | 762 | if ($op == "pref-feed-browser") { |
f27d955a | 763 | module_pref_feed_browser($link); |
c6232e43 AD |
764 | } |
765 | ||
18664970 AD |
766 | if ($op == "rss") { |
767 | $feed = db_escape_string($_GET["id"]); | |
768 | $user = db_escape_string($_GET["user"]); | |
769 | $pass = db_escape_string($_GET["pass"]); | |
770 | $is_cat = $_GET["is_cat"] != false; | |
771 | ||
e1eb2147 AD |
772 | $search = db_escape_string($_GET["q"]); |
773 | $match_on = db_escape_string($_GET["m"]); | |
774 | $search_mode = db_escape_string($_GET["smode"]); | |
775 | ||
18664970 AD |
776 | if (!$_SESSION["uid"] && $user && $pass) { |
777 | authenticate_user($link, $user, $pass); | |
778 | } | |
779 | ||
780 | if ($_SESSION["uid"] || | |
781 | http_authenticate_user($link)) { | |
782 | ||
e1eb2147 AD |
783 | generate_syndicated_feed($link, $feed, $is_cat, |
784 | $search, $search_mode, $match_on); | |
18664970 AD |
785 | } |
786 | } | |
787 | ||
88040f57 AD |
788 | if ($op == "labelFromSearch") { |
789 | $search = db_escape_string($_GET["search"]); | |
790 | $search_mode = db_escape_string($_GET["smode"]); | |
791 | $match_on = db_escape_string($_GET["match"]); | |
792 | $is_cat = db_escape_string($_GET["is_cat"]); | |
793 | $title = db_escape_string($_GET["title"]); | |
794 | $feed = sprintf("%d", $_GET["feed"]); | |
795 | ||
796 | $label_qparts = array(); | |
797 | ||
798 | $search_expr = getSearchSql($search, $match_on); | |
799 | ||
800 | if ($is_cat) { | |
801 | if ($feed != 0) { | |
802 | $search_expr .= " AND ttrss_feeds.cat_id = $feed "; | |
803 | } else { | |
804 | $search_expr .= " AND ttrss_feeds.cat_id IS NULL "; | |
805 | } | |
806 | } else { | |
807 | if ($search_mode == "all_feeds") { | |
808 | // NOOP | |
809 | } else if ($search_mode == "this_cat") { | |
810 | ||
811 | $tmp_result = db_query($link, "SELECT cat_id | |
812 | FROM ttrss_feeds WHERE id = '$feed'"); | |
813 | ||
814 | $cat_id = db_fetch_result($tmp_result, 0, "cat_id"); | |
815 | ||
816 | if ($cat_id > 0) { | |
817 | $search_expr .= " AND ttrss_feeds.cat_id = $cat_id "; | |
818 | } else { | |
819 | $search_expr .= " AND ttrss_feeds.cat_id IS NULL "; | |
820 | } | |
821 | } else { | |
822 | $search_expr .= " AND ttrss_feeds.id = $feed "; | |
823 | } | |
824 | ||
825 | } | |
826 | ||
827 | $search_expr = db_escape_string($search_expr); | |
828 | ||
829 | print $search_expr; | |
830 | ||
831 | if ($title) { | |
832 | $result = db_query($link, | |
833 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) | |
834 | VALUES ('$search_expr', '$title', '".$_SESSION["uid"]."')"); | |
835 | } | |
836 | } | |
837 | ||
f3acc32e AD |
838 | if ($op == "getUnread") { |
839 | $login = db_escape_string($_GET["login"]); | |
840 | ||
7e3634d9 | 841 | header("Content-Type: text/plain; charset=utf-8"); |
f3acc32e AD |
842 | |
843 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'"); | |
844 | ||
845 | if (db_num_rows($result) == 1) { | |
846 | $uid = db_fetch_result($result, 0, "id"); | |
847 | print getGlobalUnread($link, $uid); | |
848 | } else { | |
0599d09e | 849 | print "-1;User not found"; |
f3acc32e | 850 | } |
7e3634d9 AD |
851 | |
852 | $print_exec_time = false; | |
853 | } | |
854 | ||
855 | if ($op == "digestTest") { | |
856 | header("Content-Type: text/plain"); | |
9cd7c995 AD |
857 | print_r(prepare_headlines_digest($link, $_SESSION["uid"])); |
858 | $print_exec_time = false; | |
859 | ||
860 | } | |
448b0abd | 861 | |
9cd7c995 AD |
862 | if ($op == "digestSend") { |
863 | header("Content-Type: text/plain"); | |
864 | send_headlines_digests($link); | |
7e3634d9 AD |
865 | $print_exec_time = false; |
866 | ||
f3acc32e AD |
867 | } |
868 | ||
4b3dff6e | 869 | db_close($link); |
1cd17194 | 870 | ?> |
406d9489 | 871 | |
7e3634d9 | 872 | <?php if ($print_exec_time) { ?> |
1d3a17c7 | 873 | <!-- <?php echo sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> |
f3acc32e | 874 | <?php } ?> |