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