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