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