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