]>
Commit | Line | Data |
---|---|---|
1 | <? | |
2 | require_once "sessions.php"; | |
3 | require_once "backend-rpc.php"; | |
4 | ||
5 | header("Cache-Control: no-cache, must-revalidate"); | |
6 | header("Pragma: no-cache"); | |
7 | header("Expires: -1"); | |
8 | ||
9 | /* if ($_GET["debug"]) { | |
10 | define('DEFAULT_ERROR_LEVEL', E_ALL); | |
11 | } else { | |
12 | define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); | |
13 | } | |
14 | ||
15 | error_reporting(DEFAULT_ERROR_LEVEL); */ | |
16 | ||
17 | $op = $_REQUEST["op"]; | |
18 | ||
19 | define('SCHEMA_VERSION', 7); | |
20 | ||
21 | require_once "sanity_check.php"; | |
22 | require_once "config.php"; | |
23 | ||
24 | require_once "db.php"; | |
25 | require_once "db-prefs.php"; | |
26 | require_once "functions.php"; | |
27 | require_once "magpierss/rss_fetch.inc"; | |
28 | ||
29 | $err_msg = check_configuration_variables(); | |
30 | ||
31 | if ($err_msg) { | |
32 | header("Content-Type: application/xml"); | |
33 | print_error_xml(9, $err_msg); die; | |
34 | } | |
35 | ||
36 | if ((!$op || $op == "rpc" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { | |
37 | header("Content-Type: application/xml"); | |
38 | } | |
39 | ||
40 | if (!$_SESSION["uid"] && $op != "globalUpdateFeeds") { | |
41 | ||
42 | if ($op == "rpc") { | |
43 | print_error_xml(6); die; | |
44 | } else { | |
45 | print " | |
46 | <html><body> | |
47 | <p>Error: Not logged in.</p> | |
48 | <script type=\"text/javascript\"> | |
49 | if (parent.window != 'undefined') { | |
50 | parent.window.location = \"login.php\"; | |
51 | } else { | |
52 | window.location = \"login.php\"; | |
53 | } | |
54 | </script> | |
55 | </body></html> | |
56 | "; | |
57 | } | |
58 | exit; | |
59 | } | |
60 | ||
61 | if (!$op) { | |
62 | print_error_xml(7); exit; | |
63 | } | |
64 | ||
65 | $purge_intervals = array( | |
66 | 0 => "Default", | |
67 | -1 => "Never purge", | |
68 | 5 => "1 week", | |
69 | 14 => "2 weeks", | |
70 | 31 => "1 month", | |
71 | 60 => "2 months", | |
72 | 90 => "3 months"); | |
73 | ||
74 | $update_intervals = array( | |
75 | 0 => "Default", | |
76 | -1 => "Disable updates", | |
77 | 30 => "30 minutes", | |
78 | 60 => "1 hour", | |
79 | 240 => "4 hours", | |
80 | 720 => "12 hours", | |
81 | 1440 => "Daily", | |
82 | 10080 => "Weekly"); | |
83 | ||
84 | $script_started = getmicrotime(); | |
85 | ||
86 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
87 | ||
88 | if (!$link) { | |
89 | if (DB_TYPE == "mysql") { | |
90 | print mysql_error(); | |
91 | } | |
92 | // PG seems to display its own errors just fine by default. | |
93 | return; | |
94 | } | |
95 | ||
96 | if (DB_TYPE == "pgsql") { | |
97 | pg_query("set client_encoding = 'utf-8'"); | |
98 | } | |
99 | ||
100 | if ($_SESSION["uid"]) { | |
101 | if (get_pref($link, "HIDE_READ_FEEDS") == "true") { | |
102 | setcookie("ttrss_vf_hreadf", 1); | |
103 | } else { | |
104 | setcookie("ttrss_vf_hreadf", 0); | |
105 | } | |
106 | ||
107 | setcookie('ttrss_vf_refresh', FEEDS_FRAME_REFRESH); | |
108 | setcookie('ttrss_vf_daemon', ENABLE_UPDATE_DAEMON); | |
109 | } | |
110 | ||
111 | $fetch = $_GET["fetch"]; | |
112 | ||
113 | // setcookie("ttrss_icons_url", ICONS_URL); | |
114 | ||
115 | if (!sanity_check($link)) { return; } | |
116 | ||
117 | function outputFeedList($link, $tags = false) { | |
118 | ||
119 | print "<html><head> | |
120 | <title>Tiny Tiny RSS : Feedlist</title> | |
121 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; | |
122 | ||
123 | $user_theme = $_SESSION["theme"]; | |
124 | if ($user_theme) { | |
125 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
126 | href=\"themes/$user_theme/theme.css\">"; | |
127 | } | |
128 | ||
129 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { | |
130 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
131 | href=\"tt-rss_compact.css\"/>"; | |
132 | } else { | |
133 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
134 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
135 | } | |
136 | ||
137 | $script_dt_add = get_script_dt_add(); | |
138 | ||
139 | print "<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> | |
140 | <script type=\"text/javascript\" src=\"feedlist.js?$script_dt_add\"></script> | |
141 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
142 | <!--[if gte IE 5.5000]> | |
143 | <script type=\"text/javascript\" src=\"pngfix.js\"></script> | |
144 | <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\"> | |
145 | <![endif]--> | |
146 | </head><body> | |
147 | <script type=\"text/javascript\"> | |
148 | if (document.addEventListener) { | |
149 | document.addEventListener(\"DOMContentLoaded\", init, null); | |
150 | } | |
151 | window.onload = init; | |
152 | </script>"; | |
153 | ||
154 | print "<ul class=\"feedList\" id=\"feedList\">\n"; | |
155 | ||
156 | $owner_uid = $_SESSION["uid"]; | |
157 | ||
158 | if (!$tags) { | |
159 | ||
160 | /* virtual feeds */ | |
161 | ||
162 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
163 | print "<li class=\"feedCat\">Special</li>"; | |
164 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; | |
165 | } | |
166 | ||
167 | $result = db_query($link, "SELECT count(id) as num_starred | |
168 | FROM ttrss_entries,ttrss_user_entries | |
169 | WHERE marked = true AND | |
170 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
171 | unread = true AND owner_uid = '$owner_uid'"); | |
172 | $num_starred = db_fetch_result($result, 0, "num_starred"); | |
173 | ||
174 | $class = "virt"; | |
175 | ||
176 | if ($num_starred > 0) $class .= "Unread"; | |
177 | ||
178 | printFeedEntry(-1, $class, "Starred articles", $num_starred, | |
179 | "images/mark_set.png", $link); | |
180 | ||
181 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
182 | print "</ul>\n"; | |
183 | } | |
184 | ||
185 | if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) { | |
186 | ||
187 | $result = db_query($link, "SELECT id,sql_exp,description FROM | |
188 | ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description"); | |
189 | ||
190 | if (db_num_rows($result) > 0) { | |
191 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
192 | print "<li class=\"feedCat\">Labels</li>"; | |
193 | print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">"; | |
194 | } else { | |
195 | print "<li><hr></li>"; | |
196 | } | |
197 | } | |
198 | ||
199 | while ($line = db_fetch_assoc($result)) { | |
200 | ||
201 | error_reporting (0); | |
202 | ||
203 | $tmp_result = db_query($link, "SELECT count(id) as count | |
204 | FROM ttrss_entries,ttrss_user_entries | |
205 | WHERE (" . $line["sql_exp"] . ") AND unread = true AND | |
206 | ttrss_user_entries.ref_id = ttrss_entries.id | |
207 | AND owner_uid = '$owner_uid'"); | |
208 | ||
209 | $count = db_fetch_result($tmp_result, 0, "count"); | |
210 | ||
211 | $class = "label"; | |
212 | ||
213 | if ($count > 0) { | |
214 | $class .= "Unread"; | |
215 | } | |
216 | ||
217 | error_reporting (DEFAULT_ERROR_LEVEL); | |
218 | ||
219 | printFeedEntry(-$line["id"]-11, | |
220 | $class, $line["description"], $count, "images/label.png", $link); | |
221 | ||
222 | } | |
223 | ||
224 | if (db_num_rows($result) > 0) { | |
225 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
226 | print "</ul>"; | |
227 | } | |
228 | } | |
229 | ||
230 | } | |
231 | ||
232 | // if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
233 | print "<li><hr></li>"; | |
234 | // } | |
235 | ||
236 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
237 | $order_by_qpart = "category,title"; | |
238 | } else { | |
239 | $order_by_qpart = "title"; | |
240 | } | |
241 | ||
242 | $result = db_query($link, "SELECT ttrss_feeds.*, | |
243 | SUBSTRING(last_updated,1,19) AS last_updated_noms, | |
244 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
245 | WHERE feed_id = ttrss_feeds.id AND | |
246 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
247 | owner_uid = '$owner_uid') AS total, | |
248 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
249 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
250 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
251 | AND owner_uid = '$owner_uid') as unread, | |
252 | cat_id,last_error, | |
253 | ttrss_feed_categories.title AS category, | |
254 | ttrss_feed_categories.collapsed | |
255 | FROM ttrss_feeds LEFT JOIN ttrss_feed_categories | |
256 | ON (ttrss_feed_categories.id = cat_id) | |
257 | WHERE | |
258 | ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL | |
259 | ORDER BY $order_by_qpart"); | |
260 | ||
261 | $actid = $_GET["actid"]; | |
262 | ||
263 | /* real feeds */ | |
264 | ||
265 | $lnum = 0; | |
266 | ||
267 | $total_unread = 0; | |
268 | ||
269 | $category = ""; | |
270 | ||
271 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
272 | ||
273 | while ($line = db_fetch_assoc($result)) { | |
274 | ||
275 | $feed = db_unescape_string($line["title"]); | |
276 | $feed_id = $line["id"]; | |
277 | ||
278 | $subop = $_GET["subop"]; | |
279 | ||
280 | $total = $line["total"]; | |
281 | $unread = $line["unread"]; | |
282 | ||
283 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
284 | $last_updated = smart_date_time(strtotime($line["last_updated_noms"])); | |
285 | } else { | |
286 | $last_updated = date($short_date, strtotime($line["last_updated_noms"])); | |
287 | } | |
288 | ||
289 | $rtl_content = sql_bool_to_bool($line["rtl_content"]); | |
290 | ||
291 | if ($rtl_content) { | |
292 | $rtl_tag = "dir=\"RTL\""; | |
293 | } else { | |
294 | $rtl_tag = ""; | |
295 | } | |
296 | ||
297 | $tmp_result = db_query($link, | |
298 | "SELECT id,COUNT(unread) AS unread | |
299 | FROM ttrss_feeds LEFT JOIN ttrss_user_entries | |
300 | ON (ttrss_feeds.id = ttrss_user_entries.feed_id) | |
301 | WHERE parent_feed = '$feed_id' AND unread = true | |
302 | GROUP BY ttrss_feeds.id"); | |
303 | ||
304 | if (db_num_rows($tmp_result) > 0) { | |
305 | while ($l = db_fetch_assoc($tmp_result)) { | |
306 | $unread += $l["unread"]; | |
307 | } | |
308 | } | |
309 | ||
310 | $cat_id = $line["cat_id"]; | |
311 | ||
312 | $tmp_category = $line["category"]; | |
313 | ||
314 | if (!$tmp_category) { | |
315 | $tmp_category = "Uncategorized"; | |
316 | } | |
317 | ||
318 | // $class = ($lnum % 2) ? "even" : "odd"; | |
319 | ||
320 | if ($line["last_error"]) { | |
321 | $class = "error"; | |
322 | } else { | |
323 | $class = "feed"; | |
324 | } | |
325 | ||
326 | if ($unread > 0) $class .= "Unread"; | |
327 | ||
328 | if ($actid == $feed_id) { | |
329 | $class .= "Selected"; | |
330 | } | |
331 | ||
332 | $total_unread += $unread; | |
333 | ||
334 | if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) { | |
335 | ||
336 | if ($category) { | |
337 | print "</ul></li>"; | |
338 | } | |
339 | ||
340 | $category = $tmp_category; | |
341 | ||
342 | $collapsed = $line["collapsed"]; | |
343 | ||
344 | // workaround for NULL category | |
345 | if ($category == "Uncategorized") { | |
346 | if ($_COOKIE["ttrss_vf_uclps"] == 1) { | |
347 | $collapsed = "t"; | |
348 | } | |
349 | } | |
350 | ||
351 | if ($collapsed == "t" || $collapsed == "1") { | |
352 | $holder_class = "invisible"; | |
353 | $ellipsis = "..."; | |
354 | } else { | |
355 | $holder_class = ""; | |
356 | $ellipsis = ""; | |
357 | } | |
358 | ||
359 | if ($cat_id) { | |
360 | $cat_id_qpart = "cat_id = '$cat_id'"; | |
361 | } else { | |
362 | $cat_id_qpart = "cat_id IS NULL"; | |
363 | } | |
364 | ||
365 | $tmp_result = db_query($link, "SELECT count(int_id) AS unread | |
366 | FROM ttrss_user_entries,ttrss_feeds WHERE | |
367 | unread = true AND | |
368 | feed_id = ttrss_feeds.id AND $cat_id_qpart AND | |
369 | ttrss_user_entries.owner_uid = " . $_SESSION["uid"]); | |
370 | ||
371 | $cat_unread = db_fetch_result($tmp_result, 0, "unread"); | |
372 | ||
373 | $cat_id = sprintf("%d", $cat_id); | |
374 | ||
375 | print "<li class=\"feedCat\" id=\"FCAT-$cat_id\"> | |
376 | <a href=\"javascript:toggleCollapseCat($cat_id)\">$tmp_category</a> | |
377 | <a href=\"javascript:viewCategory($cat_id)\" id=\"FCAP-$cat_id\"> | |
378 | <span id=\"FCATCTR-$cat_id\" | |
379 | class=\"$catctr_class\">($cat_unread unread)$ellipsis</span> | |
380 | </a></li>"; | |
381 | ||
382 | // !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function | |
383 | // -> keyboard navigation, etc. | |
384 | print "<li id=\"feedCatHolder\" class=\"$holder_class\"><ul class=\"feedCatList\" id=\"FCATLIST-$cat_id\">"; | |
385 | } | |
386 | ||
387 | printFeedEntry($feed_id, $class, $feed, $unread, | |
388 | "icons/$feed_id.ico", $link, $rtl_content, | |
389 | $last_updated, $line["last_error"]); | |
390 | ||
391 | ++$lnum; | |
392 | } | |
393 | ||
394 | } else { | |
395 | ||
396 | // tags | |
397 | ||
398 | /* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count | |
399 | FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE | |
400 | post_int_id = ttrss_user_entries.int_id AND | |
401 | unread = true AND ref_id = ttrss_entries.id | |
402 | AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name | |
403 | UNION | |
404 | select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid' | |
405 | ORDER BY tag_name"); */ | |
406 | ||
407 | $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) | |
408 | FROM ttrss_user_entries WHERE int_id = post_int_id | |
409 | AND unread = true)) AS count FROM ttrss_tags | |
410 | WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name"); | |
411 | ||
412 | $tags = array(); | |
413 | ||
414 | while ($line = db_fetch_assoc($result)) { | |
415 | $tags[$line["tag_name"]] += $line["count"]; | |
416 | } | |
417 | ||
418 | foreach (array_keys($tags) as $tag) { | |
419 | ||
420 | $unread = $tags[$tag]; | |
421 | ||
422 | $class = "tag"; | |
423 | ||
424 | if ($unread > 0) { | |
425 | $class .= "Unread"; | |
426 | } | |
427 | ||
428 | printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link); | |
429 | ||
430 | } | |
431 | ||
432 | } | |
433 | ||
434 | if (db_num_rows($result) == 0) { | |
435 | if ($tags) { | |
436 | $what = "tags"; | |
437 | } else { | |
438 | $what = "feeds"; | |
439 | } | |
440 | print "<li>No $what to display.</li>"; | |
441 | } | |
442 | ||
443 | print "</ul>"; | |
444 | ||
445 | print ' | |
446 | <script type="text/javascript"> | |
447 | /* for IE */ | |
448 | function statechange() { | |
449 | if (document.readyState == "interactive") init(); | |
450 | } | |
451 | ||
452 | if (document.readyState) { | |
453 | if (document.readyState == "interactive" || document.readyState == "complete") { | |
454 | init(); | |
455 | } else { | |
456 | document.onreadystatechange = statechange; | |
457 | } | |
458 | } | |
459 | </script></body></html>'; | |
460 | } | |
461 | ||
462 | ||
463 | if ($op == "rpc") { | |
464 | handle_rpc_request($link); | |
465 | } | |
466 | ||
467 | if ($op == "feeds") { | |
468 | ||
469 | $tags = $_GET["tags"]; | |
470 | ||
471 | $subop = $_GET["subop"]; | |
472 | ||
473 | if ($subop == "catchupAll") { | |
474 | db_query($link, "UPDATE ttrss_user_entries SET | |
475 | last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]); | |
476 | } | |
477 | ||
478 | if ($subop == "collapse") { | |
479 | $cat_id = db_escape_string($_GET["cid"]); | |
480 | ||
481 | db_query($link, "UPDATE ttrss_feed_categories SET | |
482 | collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . | |
483 | $_SESSION["uid"]); | |
484 | return; | |
485 | } | |
486 | ||
487 | outputFeedList($link, $tags); | |
488 | ||
489 | } | |
490 | ||
491 | if ($op == "view") { | |
492 | ||
493 | $id = db_escape_string($_GET["id"]); | |
494 | $feed_id = db_escape_string($_GET["feed"]); | |
495 | ||
496 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
497 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
498 | ||
499 | if (db_num_rows($result) == 1) { | |
500 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
501 | } else { | |
502 | $rtl_content = false; | |
503 | } | |
504 | ||
505 | if ($rtl_content) { | |
506 | $rtl_tag = "dir=\"RTL\""; | |
507 | $rtl_class = "RTL"; | |
508 | } else { | |
509 | $rtl_tag = ""; | |
510 | $rtl_class = ""; | |
511 | } | |
512 | ||
513 | $result = db_query($link, "UPDATE ttrss_user_entries | |
514 | SET unread = false,last_read = NOW() | |
515 | WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
516 | ||
517 | $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, | |
518 | SUBSTRING(updated,1,16) as updated, | |
519 | (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, | |
520 | num_comments, | |
521 | author | |
522 | FROM ttrss_entries,ttrss_user_entries | |
523 | WHERE id = '$id' AND ref_id = id"); | |
524 | ||
525 | print "<html><head> | |
526 | <title>Tiny Tiny RSS : Article $id</title> | |
527 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; | |
528 | ||
529 | $user_theme = $_SESSION["theme"]; | |
530 | if ($user_theme) { | |
531 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
532 | href=\"themes/$user_theme/theme.css\">"; | |
533 | } | |
534 | ||
535 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { | |
536 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
537 | href=\"tt-rss_compact.css\"/>"; | |
538 | } else { | |
539 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
540 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
541 | } | |
542 | ||
543 | $script_dt_add = get_script_dt_add(); | |
544 | ||
545 | print "<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> | |
546 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
547 | </head><body $rtl_tag>"; | |
548 | ||
549 | if ($result) { | |
550 | ||
551 | $line = db_fetch_assoc($result); | |
552 | ||
553 | if ($line["icon_url"]) { | |
554 | $feed_icon = "<img class=\"feedIcon\" src=\"" . $line["icon_url"] . "\">"; | |
555 | } else { | |
556 | $feed_icon = " "; | |
557 | } | |
558 | ||
559 | /* if ($line["comments"] && $line["link"] != $line["comments"]) { | |
560 | $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)"; | |
561 | } else { | |
562 | $entry_comments = ""; | |
563 | } */ | |
564 | ||
565 | $num_comments = $line["num_comments"]; | |
566 | $entry_comments = ""; | |
567 | ||
568 | if ($num_comments > 0) { | |
569 | if ($line["comments"]) { | |
570 | $comments_url = $line["comments"]; | |
571 | } else { | |
572 | $comments_url = $line["link"]; | |
573 | } | |
574 | $entry_comments = "<a href=\"$comments_url\">$num_comments comments</a>"; | |
575 | } else { | |
576 | if ($line["comments"] && $line["link"] != $line["comments"]) { | |
577 | $entry_comments = "<a href=\"".$line["comments"]."\">comments</a>"; | |
578 | } | |
579 | } | |
580 | ||
581 | print "<div class=\"postReply\">"; | |
582 | ||
583 | print "<div class=\"postHeader\"><table width=\"100%\">"; | |
584 | ||
585 | $entry_author = $line["author"]; | |
586 | ||
587 | if ($entry_author) { | |
588 | $entry_author = " - by $entry_author"; | |
589 | } | |
590 | ||
591 | print "<tr><td><a href=\"" . $line["link"] . "\">" . $line["title"] . | |
592 | "</a>$entry_author</td>"; | |
593 | ||
594 | $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
595 | strtotime($line["updated"])); | |
596 | ||
597 | print "<td class=\"postDate$rtl_class\">$parsed_updated</td>"; | |
598 | ||
599 | print "</tr>"; | |
600 | ||
601 | $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM | |
602 | ttrss_tags WHERE post_int_id = " . $line["int_id"] . " | |
603 | ORDER BY tag_name"); | |
604 | ||
605 | $tags_str = ""; | |
606 | $f_tags_str = ""; | |
607 | ||
608 | $num_tags = 0; | |
609 | ||
610 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
611 | $num_tags++; | |
612 | $tag = $tmp_line["tag_name"]; | |
613 | $tag_str = "<a href=\"javascript:parent.viewfeed('$tag')\">$tag</a>, "; | |
614 | ||
615 | if ($num_tags == 5) { | |
616 | $tags_str .= "<a href=\"javascript:showBlockElement('allEntryTags')\">...</a>"; | |
617 | } else if ($num_tags < 5) { | |
618 | $tags_str .= $tag_str; | |
619 | } | |
620 | $f_tags_str .= $tag_str; | |
621 | } | |
622 | ||
623 | $tags_str = preg_replace("/, $/", "", $tags_str); | |
624 | $f_tags_str = preg_replace("/, $/", "", $f_tags_str); | |
625 | ||
626 | // $truncated_link = truncate_string($line["link"], 60); | |
627 | ||
628 | if ($tags_str || $entry_comments) { | |
629 | print "<tr><td width='50%'> | |
630 | $entry_comments</td> | |
631 | <td align=\"right\">$tags_str</td></tr>"; | |
632 | } | |
633 | ||
634 | print "</table></div>"; | |
635 | ||
636 | print "<div class=\"postIcon\">" . $feed_icon . "</div>"; | |
637 | print "<div class=\"postContent\">"; | |
638 | ||
639 | if (db_num_rows($tmp_result) > 5) { | |
640 | print "<div id=\"allEntryTags\">Tags: $f_tags_str</div>"; | |
641 | } | |
642 | ||
643 | if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) { | |
644 | $line["content"] = preg_replace("/href=/i", "target=\"_new\" href=", $line["content"]); | |
645 | } | |
646 | ||
647 | print $line["content"] . "</div>"; | |
648 | ||
649 | print "</div>"; | |
650 | ||
651 | print "<script type=\"text/javascript\"> | |
652 | update_all_counters('$feed_id'); | |
653 | </script>"; | |
654 | } | |
655 | ||
656 | print "</body></html>"; | |
657 | } | |
658 | ||
659 | if ($op == "viewfeed") { | |
660 | ||
661 | $feed = db_escape_string($_GET["feed"]); | |
662 | $skip = db_escape_string($_GET["skip"]); | |
663 | $subop = db_escape_string($_GET["subop"]); | |
664 | $view_mode = db_escape_string($_GET["view"]); | |
665 | $limit = db_escape_string($_GET["limit"]); | |
666 | $cat_view = db_escape_string($_GET["cat"]); | |
667 | ||
668 | if (!$skip) $skip = 0; | |
669 | ||
670 | if ($subop == "undefined") $subop = ""; | |
671 | ||
672 | print "<html><head> | |
673 | <title>Tiny Tiny RSS : Feed $feed</title> | |
674 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">"; | |
675 | ||
676 | $user_theme = $_SESSION["theme"]; | |
677 | if ($user_theme) { | |
678 | print "<link rel=\"stylesheet\" type=\"text/css\" | |
679 | href=\"themes/$user_theme/theme.css\">"; | |
680 | } | |
681 | ||
682 | if (get_pref($link, 'USE_COMPACT_STYLESHEET')) { | |
683 | print "<link rel=\"stylesheet\" | |
684 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
685 | ||
686 | } else { | |
687 | print "<link title=\"Compact Stylesheet\" rel=\"alternate stylesheet\" | |
688 | type=\"text/css\" href=\"tt-rss_compact.css\"/>"; | |
689 | } | |
690 | ||
691 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { | |
692 | ||
693 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
694 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
695 | ||
696 | if (db_num_rows($result) == 1) { | |
697 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
698 | } else { | |
699 | $rtl_content = false; | |
700 | } | |
701 | ||
702 | if ($rtl_content) { | |
703 | $rtl_tag = "dir=\"RTL\""; | |
704 | } else { | |
705 | $rtl_tag = ""; | |
706 | } | |
707 | } else { | |
708 | $rtl_tag = ""; | |
709 | $rtl_content = false; | |
710 | } | |
711 | ||
712 | $script_dt_add = get_script_dt_add(); | |
713 | ||
714 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
715 | <script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> | |
716 | <script type=\"text/javascript\" src=\"viewfeed.js?$script_dt_add\"></script> | |
717 | <!--[if gte IE 5.5000]> | |
718 | <script type=\"text/javascript\" src=\"pngfix.js\"></script> | |
719 | <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\"> | |
720 | <![endif]--> | |
721 | </head><body $rtl_tag> | |
722 | <script type=\"text/javascript\"> | |
723 | if (document.addEventListener) { | |
724 | document.addEventListener(\"DOMContentLoaded\", init, null); | |
725 | } | |
726 | window.onload = init; | |
727 | </script>"; | |
728 | ||
729 | if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { | |
730 | update_generic_feed($link, $feed, $cat_view); | |
731 | } | |
732 | ||
733 | if ($subop == "MarkAllRead") { | |
734 | catchup_feed($link, $feed, $cat_view); | |
735 | } | |
736 | ||
737 | $search = db_escape_string($_GET["search"]); | |
738 | $search_mode = db_escape_string($_GET["smode"]); | |
739 | ||
740 | if ($search) { | |
741 | $search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%') | |
742 | OR ttrss_entries.content LIKE '%$search%') AND"; | |
743 | } else { | |
744 | $search_query_part = ""; | |
745 | } | |
746 | ||
747 | $view_query_part = ""; | |
748 | ||
749 | if ($view_mode == "Adaptive") { | |
750 | if ($search) { | |
751 | $view_query_part = " "; | |
752 | } else if ($feed != -1) { | |
753 | $unread = getFeedUnread($link, $feed); | |
754 | if ($unread > 0) { | |
755 | $view_query_part = " unread = true AND "; | |
756 | } | |
757 | } | |
758 | } | |
759 | ||
760 | if ($view_mode == "Starred") { | |
761 | $view_query_part = " marked = true AND "; | |
762 | } | |
763 | ||
764 | if ($view_mode == "Unread") { | |
765 | $view_query_part = " unread = true AND "; | |
766 | } | |
767 | ||
768 | if ($limit && $limit != "All") { | |
769 | $limit_query_part = "LIMIT " . $limit; | |
770 | } | |
771 | ||
772 | $vfeed_query_part = ""; | |
773 | ||
774 | // override query strategy and enable feed display when searching globally | |
775 | if ($search && $search_mode == "All feeds") { | |
776 | $query_strategy_part = "ttrss_entries.id > 0"; | |
777 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
778 | } else if (preg_match("/^-?[0-9][0-9]*$/", $feed) == false) { | |
779 | $query_strategy_part = "ttrss_entries.id > 0"; | |
780 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
781 | id = feed_id) as feed_title,"; | |
782 | } else if ($feed >= 0 && $search && $search_mode == "This category") { | |
783 | ||
784 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
785 | ||
786 | $tmp_result = db_query($link, "SELECT id | |
787 | FROM ttrss_feeds WHERE cat_id = | |
788 | (SELECT cat_id FROM ttrss_feeds WHERE id = '$feed') AND id != '$feed'"); | |
789 | ||
790 | $cat_siblings = array(); | |
791 | ||
792 | if (db_num_rows($tmp_result) > 0) { | |
793 | while ($p = db_fetch_assoc($tmp_result)) { | |
794 | array_push($cat_siblings, "feed_id = " . $p["id"]); | |
795 | } | |
796 | ||
797 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
798 | $feed, implode(" OR ", $cat_siblings)); | |
799 | ||
800 | } else { | |
801 | $query_strategy_part = "ttrss_entries.id > 0"; | |
802 | } | |
803 | ||
804 | } else if ($feed >= 0) { | |
805 | ||
806 | if ($cat_view) { | |
807 | ||
808 | if ($feed > 0) { | |
809 | $query_strategy_part = "cat_id = '$feed'"; | |
810 | } else { | |
811 | $query_strategy_part = "cat_id IS NULL"; | |
812 | } | |
813 | ||
814 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
815 | ||
816 | } else { | |
817 | $tmp_result = db_query($link, "SELECT id | |
818 | FROM ttrss_feeds WHERE parent_feed = '$feed' | |
819 | ORDER BY cat_id,title"); | |
820 | ||
821 | $parent_ids = array(); | |
822 | ||
823 | if (db_num_rows($tmp_result) > 0) { | |
824 | while ($p = db_fetch_assoc($tmp_result)) { | |
825 | array_push($parent_ids, "feed_id = " . $p["id"]); | |
826 | } | |
827 | ||
828 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
829 | $feed, implode(" OR ", $parent_ids)); | |
830 | ||
831 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
832 | } else { | |
833 | $query_strategy_part = "feed_id = '$feed'"; | |
834 | } | |
835 | } | |
836 | } else if ($feed == -1) { // starred virtual feed | |
837 | $query_strategy_part = "marked = true"; | |
838 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
839 | } else if ($feed <= -10) { // labels | |
840 | $label_id = -$feed - 11; | |
841 | ||
842 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
843 | WHERE id = '$label_id'"); | |
844 | ||
845 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
846 | ||
847 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
848 | } else { | |
849 | $query_strategy_part = "id > 0"; // dumb | |
850 | } | |
851 | ||
852 | $order_by = "updated DESC"; | |
853 | ||
854 | // if ($feed < -10) { | |
855 | // $order_by = "feed_id,updated DESC"; | |
856 | // } | |
857 | ||
858 | $feed_title = ""; | |
859 | ||
860 | if ($search && $search_mode == "All feeds") { | |
861 | $feed_title = "Global search results ($search)"; | |
862 | } else if ($search && preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { | |
863 | $feed_title = "Feed search results ($search, $feed)"; | |
864 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { | |
865 | $feed_title = $feed; | |
866 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) != false && $feed >= 0) { | |
867 | ||
868 | if ($cat_view) { | |
869 | ||
870 | if ($feed != 0) { | |
871 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
872 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
873 | $feed_title = db_fetch_result($result, 0, "title"); | |
874 | } else { | |
875 | $feed_title = "Uncategorized"; | |
876 | } | |
877 | } else { | |
878 | ||
879 | $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds | |
880 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
881 | ||
882 | $feed_title = db_fetch_result($result, 0, "title"); | |
883 | $feed_site_url = db_fetch_result($result, 0, "site_url"); | |
884 | $last_error = db_fetch_result($result, 0, "last_error"); | |
885 | ||
886 | } | |
887 | ||
888 | } else if ($feed == -1) { | |
889 | $feed_title = "Starred articles"; | |
890 | } else if ($feed < -10) { | |
891 | $label_id = -$feed - 11; | |
892 | $result = db_query($link, "SELECT description FROM ttrss_labels | |
893 | WHERE id = '$label_id'"); | |
894 | $feed_title = db_fetch_result($result, 0, "description"); | |
895 | } else { | |
896 | $feed_title = "?"; | |
897 | } | |
898 | ||
899 | if ($feed < -10) error_reporting (0); | |
900 | ||
901 | print "<div id=\"headlinesContainer\">"; | |
902 | ||
903 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { | |
904 | ||
905 | if ($feed >= 0) { | |
906 | $feed_kind = "Feeds"; | |
907 | } else { | |
908 | $feed_kind = "Labels"; | |
909 | } | |
910 | ||
911 | // if (!$vfeed_query_part) { | |
912 | $content_query_part = "content as content_preview,"; | |
913 | // } else { | |
914 | // $content_query_part = ""; | |
915 | // } | |
916 | ||
917 | $query = "SELECT | |
918 | ttrss_entries.id,ttrss_entries.title, | |
919 | SUBSTRING(updated,1,16) as updated, | |
920 | unread,feed_id,marked,link,last_read, | |
921 | SUBSTRING(last_read,1,19) as last_read_noms, | |
922 | $vfeed_query_part | |
923 | $content_query_part | |
924 | SUBSTRING(updated,1,19) as updated_noms | |
925 | FROM | |
926 | ttrss_entries,ttrss_user_entries,ttrss_feeds | |
927 | WHERE | |
928 | ttrss_user_entries.feed_id = ttrss_feeds.id AND | |
929 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
930 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
931 | $search_query_part | |
932 | $view_query_part | |
933 | $query_strategy_part ORDER BY $order_by | |
934 | $limit_query_part"; | |
935 | ||
936 | $result = db_query($link, $query); | |
937 | ||
938 | if ($_GET["debug"]) print $query; | |
939 | ||
940 | } else { | |
941 | // browsing by tag | |
942 | ||
943 | $feed_kind = "Tags"; | |
944 | ||
945 | $result = db_query($link, "SELECT | |
946 | ttrss_entries.id as id,title, | |
947 | SUBSTRING(updated,1,16) as updated, | |
948 | unread,feed_id, | |
949 | marked,link,last_read, | |
950 | SUBSTRING(last_read,1,19) as last_read_noms, | |
951 | $vfeed_query_part | |
952 | $content_query_part | |
953 | SUBSTRING(updated,1,19) as updated_noms | |
954 | FROM | |
955 | ttrss_entries,ttrss_user_entries,ttrss_tags | |
956 | WHERE | |
957 | ref_id = ttrss_entries.id AND | |
958 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
959 | post_int_id = int_id AND tag_name = '$feed' AND | |
960 | $view_query_part | |
961 | $search_query_part | |
962 | $query_strategy_part ORDER BY $order_by | |
963 | $limit_query_part"); | |
964 | } | |
965 | ||
966 | if (!$result) { | |
967 | print "<div align='center'> | |
968 | Could not display feed (query failed). Please check label match syntax or local configuration.</div>"; | |
969 | return; | |
970 | } | |
971 | ||
972 | function print_headline_subtoolbar($link, $feed_site_url, $feed_title, | |
973 | $bottom = false, $rtl_content = false) { | |
974 | ||
975 | if (!$bottom) { | |
976 | $class = "headlinesSubToolbar"; | |
977 | $tid = "headlineActionsTop"; | |
978 | } else { | |
979 | $class = "invisible"; | |
980 | $tid = "headlineActionsBottom"; | |
981 | } | |
982 | ||
983 | print "<table class=\"$class\" id=\"$tid\" | |
984 | width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>"; | |
985 | ||
986 | if ($rtl_content) { | |
987 | $rtl_cpart = "RTL"; | |
988 | } else { | |
989 | $rtl_cpart = ""; | |
990 | } | |
991 | ||
992 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { | |
993 | ||
994 | print "<td class=\"headlineActions$rtl_cpart\"> | |
995 | Select: | |
996 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, '', true)\">All</a>, | |
997 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true)\">Unread</a>, | |
998 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false)\">None</a> | |
999 | | |
1000 | Toggle: <a href='#' onclick=\"javascript:selectionToggleUnread()\">Unread</a>, | |
1001 | <a href='#' onclick=\"javascript:selectionToggleMarked()\">Starred</a>"; | |
1002 | print "</td>"; | |
1003 | ||
1004 | } else { | |
1005 | ||
1006 | print "<td class=\"headlineActions$rtl_cpart\"> | |
1007 | Select: | |
1008 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('all')\">All</a>, | |
1009 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('unread')\">Unread</a>, | |
1010 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('none')\">None</a> | |
1011 | | |
1012 | Toggle: <a href=\"#\" onclick=\"javascript:selectionToggleUnread(true)\">Unread</a>, | |
1013 | <a href=\"#\" onclick=\"javascript:selectionToggleMarked(true)\">Starred</a>"; | |
1014 | ||
1015 | print "</td>"; | |
1016 | ||
1017 | } | |
1018 | ||
1019 | print "<td class=\"headlineTitle$rtl_cpart\">"; | |
1020 | ||
1021 | if ($feed_site_url) { | |
1022 | if (!$bottom) { | |
1023 | $target = "target=\"_blank\""; | |
1024 | } | |
1025 | print "<a $target href=\"$feed_site_url\">$feed_title</a>"; | |
1026 | } else { | |
1027 | print $feed_title; | |
1028 | } | |
1029 | ||
1030 | print "</td>"; | |
1031 | print "</tr></table>"; | |
1032 | ||
1033 | } | |
1034 | ||
1035 | if (db_num_rows($result) > 0) { | |
1036 | ||
1037 | print_headline_subtoolbar($link, $feed_site_url, $feed_title, false, | |
1038 | $rtl_content); | |
1039 | ||
1040 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { | |
1041 | print "<table class=\"headlinesList\" id=\"headlinesList\" | |
1042 | cellspacing=\"0\" width=\"100%\">"; | |
1043 | } | |
1044 | ||
1045 | $lnum = 0; | |
1046 | ||
1047 | error_reporting (DEFAULT_ERROR_LEVEL); | |
1048 | ||
1049 | $num_unread = 0; | |
1050 | ||
1051 | while ($line = db_fetch_assoc($result)) { | |
1052 | ||
1053 | $class = ($lnum % 2) ? "even" : "odd"; | |
1054 | ||
1055 | $id = $line["id"]; | |
1056 | $feed_id = $line["feed_id"]; | |
1057 | ||
1058 | if ($line["last_read"] == "" && | |
1059 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
1060 | ||
1061 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
1062 | alt=\"Updated\">"; | |
1063 | } else { | |
1064 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
1065 | alt=\"Updated\">"; | |
1066 | } | |
1067 | ||
1068 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
1069 | $class .= "Unread"; | |
1070 | ++$num_unread; | |
1071 | $is_unread = true; | |
1072 | } else { | |
1073 | $is_unread = false; | |
1074 | } | |
1075 | ||
1076 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
1077 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" | |
1078 | alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>"; | |
1079 | } else { | |
1080 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
1081 | alt=\"Set mark\" onclick='javascript:toggleMark($id)'>"; | |
1082 | } | |
1083 | ||
1084 | $content_link = "<a href=\"javascript:view($id,$feed_id);\">" . | |
1085 | $line["title"] . "</a>"; | |
1086 | ||
1087 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
1088 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
1089 | } else { | |
1090 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1091 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
1092 | } | |
1093 | ||
1094 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
1095 | $content_preview = truncate_string(strip_tags($line["content_preview"]), | |
1096 | 100); | |
1097 | } | |
1098 | ||
1099 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { | |
1100 | ||
1101 | print "<tr class='$class' id='RROW-$id'>"; | |
1102 | ||
1103 | print "<td class='hlUpdatePic'>$update_pic</td>"; | |
1104 | ||
1105 | print "<td class='hlSelectRow'> | |
1106 | <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\" | |
1107 | class=\"feedCheckBox\" id=\"RCHK-$id\"> | |
1108 | </td>"; | |
1109 | ||
1110 | print "<td class='hlMarkedPic'>$marked_pic</td>"; | |
1111 | ||
1112 | if ($line["feed_title"]) { | |
1113 | print "<td class='hlContent'>$content_link</td>"; | |
1114 | print "<td class='hlFeed'> | |
1115 | <a href='javascript:viewfeed($feed_id)'>". | |
1116 | $line["feed_title"]."</a> </td>"; | |
1117 | } else { | |
1118 | print "<td class='hlContent' valign='middle'>"; | |
1119 | ||
1120 | print "<a href=\"javascript:view($id,$feed_id);\">" . | |
1121 | $line["title"]; | |
1122 | ||
1123 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW') && !$rtl_tag) { | |
1124 | if ($content_preview) { | |
1125 | print "<span class=\"contentPreview\"> - $content_preview</span>"; | |
1126 | } | |
1127 | } | |
1128 | ||
1129 | print "</a>"; | |
1130 | print "</td>"; | |
1131 | } | |
1132 | ||
1133 | print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>"; | |
1134 | ||
1135 | print "</tr>"; | |
1136 | ||
1137 | } else { | |
1138 | ||
1139 | if ($is_unread) { | |
1140 | $add_class = "Unread"; | |
1141 | } else { | |
1142 | $add_class = ""; | |
1143 | } | |
1144 | ||
1145 | print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">"; | |
1146 | ||
1147 | print "<div class=\"cdmHeader\">"; | |
1148 | ||
1149 | print "<div style=\"float : right\">$updated_fmt</div>"; | |
1150 | ||
1151 | print "<a target=\"new\" href=\"".$line["link"]."\">".$line["title"]."</a>"; | |
1152 | ||
1153 | if ($line["feed_title"]) { | |
1154 | print " (<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)"; | |
1155 | } | |
1156 | ||
1157 | print "</div>"; | |
1158 | ||
1159 | print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div>"; | |
1160 | ||
1161 | print "<div style=\"float : right\">$marked_pic</div> | |
1162 | <div class=\"cdmFooter\"> | |
1163 | <input type=\"checkbox\" onclick=\"toggleSelectRowById(this, | |
1164 | 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"></div>"; | |
1165 | ||
1166 | print "</div>"; | |
1167 | ||
1168 | } | |
1169 | ||
1170 | ++$lnum; | |
1171 | } | |
1172 | ||
1173 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { | |
1174 | print "</table>"; | |
1175 | } | |
1176 | ||
1177 | print_headline_subtoolbar($link, | |
1178 | "javascript:catchupPage()", "Mark page as read", true, $rtl_content); | |
1179 | ||
1180 | ||
1181 | } else { | |
1182 | print "<div width='100%' align='center'>No articles found.</div>"; | |
1183 | } | |
1184 | ||
1185 | print "</div>"; | |
1186 | ||
1187 | print "<script type=\"text/javascript\"> | |
1188 | document.onkeydown = hotkey_handler; | |
1189 | // if (parent.daemon_enabled) parent.updateTitle('$feed_title'); | |
1190 | update_all_counters('$feed'); | |
1191 | </script>"; | |
1192 | ||
1193 | print ' | |
1194 | <script type="text/javascript"> | |
1195 | /* for IE */ | |
1196 | function statechange() { | |
1197 | if (document.readyState == "interactive") init(); | |
1198 | } | |
1199 | ||
1200 | if (document.readyState) { | |
1201 | if (document.readyState == "interactive" || document.readyState == "complete") { | |
1202 | init(); | |
1203 | } else { | |
1204 | document.onreadystatechange = statechange; | |
1205 | } | |
1206 | } | |
1207 | </script>'; | |
1208 | ||
1209 | print "</body></html>"; | |
1210 | } | |
1211 | ||
1212 | if ($op == "pref-rpc") { | |
1213 | ||
1214 | $subop = $_GET["subop"]; | |
1215 | ||
1216 | if ($subop == "unread") { | |
1217 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1218 | foreach ($ids as $id) { | |
1219 | db_query($link, "UPDATE ttrss_user_entries SET unread = true | |
1220 | WHERE feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
1221 | } | |
1222 | ||
1223 | print "Marked selected feeds as unread."; | |
1224 | } | |
1225 | ||
1226 | if ($subop == "read") { | |
1227 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1228 | foreach ($ids as $id) { | |
1229 | db_query($link, "UPDATE ttrss_user_entries | |
1230 | SET unread = false,last_read = NOW() WHERE | |
1231 | feed_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
1232 | } | |
1233 | ||
1234 | print "Marked selected feeds as read."; | |
1235 | ||
1236 | } | |
1237 | ||
1238 | } | |
1239 | ||
1240 | if ($op == "pref-feeds") { | |
1241 | ||
1242 | $subop = $_REQUEST["subop"]; | |
1243 | $quiet = $_REQUEST["quiet"]; | |
1244 | ||
1245 | if ($subop == "massSubscribe") { | |
1246 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1247 | ||
1248 | $subscribed = array(); | |
1249 | ||
1250 | foreach ($ids as $id) { | |
1251 | $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds | |
1252 | WHERE id = '$id'"); | |
1253 | ||
1254 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1255 | $title = db_fetch_result($result, 0, "title"); | |
1256 | ||
1257 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
1258 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
1259 | ||
1260 | if (db_num_rows($result) == 0) { | |
1261 | $result = db_query($link, | |
1262 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) | |
1263 | VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); | |
1264 | ||
1265 | array_push($subscribed, $title); | |
1266 | } | |
1267 | } | |
1268 | ||
1269 | if (count($subscribed) > 0) { | |
1270 | print "<div class=\"notice\">"; | |
1271 | print "<b>Subscribed to feeds:</b>"; | |
1272 | print "<ul class=\"nomarks\">"; | |
1273 | foreach ($subscribed as $title) { | |
1274 | print "<li>$title</li>"; | |
1275 | } | |
1276 | print "</ul>"; | |
1277 | print "</div>"; | |
1278 | } | |
1279 | } | |
1280 | ||
1281 | if ($subop == "browse") { | |
1282 | ||
1283 | if (!ENABLE_FEED_BROWSER) { | |
1284 | print "Feed browser is administratively disabled."; | |
1285 | return; | |
1286 | } | |
1287 | ||
1288 | print "<div class=\"infoBoxContents\">"; | |
1289 | ||
1290 | print "<h1>Feed browser</h1>"; | |
1291 | ||
1292 | print "<p>Showing top 50 registered feeds, sorted by popularity:</p>"; | |
1293 | ||
1294 | $result = db_query($link, "SELECT feed_url,count(id) AS subscribers | |
1295 | FROM ttrss_feeds | |
1296 | WHERE auth_login = '' AND auth_pass = '' AND private = false | |
1297 | GROUP BY feed_url ORDER BY subscribers DESC LIMIT 50"); | |
1298 | ||
1299 | print "<ul class='browseFeedList' id='browseFeedList'>"; | |
1300 | ||
1301 | $feedctr = 0; | |
1302 | ||
1303 | while ($line = db_fetch_assoc($result)) { | |
1304 | $feed_url = $line["feed_url"]; | |
1305 | $subscribers = $line["subscribers"]; | |
1306 | ||
1307 | $sub_result = db_query($link, "SELECT id | |
1308 | FROM ttrss_feeds WHERE feed_url = '$feed_url' AND owner_uid =" . | |
1309 | $_SESSION["uid"]); | |
1310 | ||
1311 | if (db_num_rows($sub_result) > 0) { | |
1312 | continue; // already subscribed | |
1313 | } | |
1314 | ||
1315 | $det_result = db_query($link, "SELECT site_url,title,id | |
1316 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
1317 | ||
1318 | $details = db_fetch_assoc($det_result); | |
1319 | ||
1320 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
1321 | ||
1322 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1323 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
1324 | "/".$details["id"].".ico\">"; | |
1325 | } else { | |
1326 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1327 | } | |
1328 | ||
1329 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' | |
1330 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
1331 | ||
1332 | $class = ($feedctr % 2) ? "even" : "odd"; | |
1333 | ||
1334 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
1335 | "$feed_icon " . db_unescape_string($details["title"]) . | |
1336 | " <span class='subscribers'>($subscribers)</span></li>"; | |
1337 | ||
1338 | ++$feedctr; | |
1339 | } | |
1340 | ||
1341 | if ($feedctr == 0) { | |
1342 | print "<li>No feeds found to subscribe.</li>"; | |
1343 | } | |
1344 | ||
1345 | print "</ul>"; | |
1346 | ||
1347 | print "<div align='center'> | |
1348 | <input type=\"submit\" class=\"button\" | |
1349 | onclick=\"feedBrowserSubscribe()\" value=\"Subscribe\"> | |
1350 | <input type='submit' class='button' | |
1351 | onclick=\"closeInfoBox()\" value=\"Cancel\"></div>"; | |
1352 | ||
1353 | print "</div>"; | |
1354 | return; | |
1355 | } | |
1356 | ||
1357 | if ($subop == "editfeed") { | |
1358 | $feed_id = db_escape_string($_GET["id"]); | |
1359 | ||
1360 | $result = db_query($link, | |
1361 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
1362 | owner_uid = " . $_SESSION["uid"]); | |
1363 | ||
1364 | $title = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1365 | 0, "title"))); | |
1366 | ||
1367 | print "<div class=\"infoBoxContents\">"; | |
1368 | ||
1369 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1370 | ||
1371 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1372 | $feed_icon = "<img width=\"16\" height=\"16\" | |
1373 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1374 | } else { | |
1375 | $feed_icon = ""; | |
1376 | } | |
1377 | ||
1378 | print "<h1>$feed_icon $title</h1>"; | |
1379 | ||
1380 | print "<table width='100%'>"; | |
1381 | ||
1382 | $row_class = "odd"; | |
1383 | ||
1384 | print "<tr class='$row_class'><td>Title:</td>"; | |
1385 | print "<td><input id=\"iedit_title\" value=\"$title\"></td></tr>"; | |
1386 | ||
1387 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1388 | $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1389 | 0, "feed_url"))); | |
1390 | $row_class = toggleEvenOdd($row_class); | |
1391 | ||
1392 | print "<tr class='$row_class'><td>Feed URL:</td>"; | |
1393 | print "<td><input id=\"iedit_link\" value=\"$feed_url\"></td></tr>"; | |
1394 | ||
1395 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1396 | ||
1397 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
1398 | ||
1399 | $row_class = toggleEvenOdd($row_class); | |
1400 | ||
1401 | print "<tr class='$row_class'><td>Category:</td>"; | |
1402 | print "<td>"; | |
1403 | print "<select id=\"iedit_fcat\">"; | |
1404 | print "<option id=\"0\">Uncategorized</option>"; | |
1405 | ||
1406 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories | |
1407 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
1408 | ||
1409 | if (db_num_rows($tmp_result) > 0) { | |
1410 | print "<option disabled>--------</option>"; | |
1411 | } | |
1412 | ||
1413 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1414 | if ($tmp_line["id"] == $cat_id) { | |
1415 | $is_selected = "selected"; | |
1416 | } else { | |
1417 | $is_selected = ""; | |
1418 | } | |
1419 | printf("<option $is_selected id='%d'>%s</option>", | |
1420 | $tmp_line["id"], $tmp_line["title"]); | |
1421 | } | |
1422 | ||
1423 | print "</select></td>"; | |
1424 | print "</td></tr>"; | |
1425 | ||
1426 | } | |
1427 | ||
1428 | $update_interval = db_fetch_result($result, 0, "update_interval"); | |
1429 | $row_class = toggleEvenOdd($row_class); | |
1430 | ||
1431 | print "<tr class='$row_class'><td>Update Interval:</td>"; | |
1432 | // print "<td><input id=\"iedit_updintl\" | |
1433 | // value=\"$update_interval\"></td></tr>"; | |
1434 | ||
1435 | print "<td>"; | |
1436 | ||
1437 | print "<select id=\"iedit_updintl\">"; | |
1438 | ||
1439 | foreach (array_keys($update_intervals) as $i) { | |
1440 | ||
1441 | if ($i == $update_interval) { | |
1442 | $selected = "selected"; | |
1443 | } else { | |
1444 | $selected = ""; | |
1445 | } | |
1446 | print "<option $selected id=\"$i\">" . $update_intervals[$i] . "</option>"; | |
1447 | } | |
1448 | ||
1449 | print "</select>"; | |
1450 | ||
1451 | print "</td>"; | |
1452 | ||
1453 | $row_class = toggleEvenOdd($row_class); | |
1454 | print "<tr class='$row_class'><td>Link to:</td>"; | |
1455 | ||
1456 | $tmp_result = db_query($link, "SELECT COUNT(id) AS count | |
1457 | FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); | |
1458 | ||
1459 | $linked_count = db_fetch_result($tmp_result, 0, "count"); | |
1460 | ||
1461 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); | |
1462 | ||
1463 | if ($linked_count > 0) { | |
1464 | $disabled = "disabled"; | |
1465 | } | |
1466 | ||
1467 | print "<select $disabled id=\"iedit_parent_feed\">"; | |
1468 | ||
1469 | print "<option id=\"0\">Not linked</option>"; | |
1470 | ||
1471 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1472 | if ($cat_id) { | |
1473 | $cat_qpart = "AND cat_id = '$cat_id'"; | |
1474 | } else { | |
1475 | $cat_qpart = "AND cat_id IS NULL"; | |
1476 | } | |
1477 | } | |
1478 | ||
1479 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
1480 | WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." | |
1481 | $cat_qpart ORDER BY title"); | |
1482 | ||
1483 | if (db_num_rows($tmp_result) > 0) { | |
1484 | print "<option disabled>--------</option>"; | |
1485 | } | |
1486 | ||
1487 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1488 | if ($tmp_line["id"] == $parent_feed) { | |
1489 | $is_selected = "selected"; | |
1490 | } else { | |
1491 | $is_selected = ""; | |
1492 | } | |
1493 | printf("<option $is_selected id='%d'>%s</option>", | |
1494 | $tmp_line["id"], $tmp_line["title"]); | |
1495 | } | |
1496 | ||
1497 | print "</select></td>"; | |
1498 | print "</td></tr>"; | |
1499 | ||
1500 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); | |
1501 | $row_class = toggleEvenOdd($row_class); | |
1502 | ||
1503 | print "<tr class='$row_class'><td>Purge Days:</td>"; | |
1504 | // print "<td><input id=\"iedit_purgintl\" | |
1505 | // value=\"$purge_interval\"></td></tr>"; | |
1506 | ||
1507 | print "<td>"; | |
1508 | ||
1509 | print "<select id=\"iedit_purgintl\">"; | |
1510 | ||
1511 | foreach (array_keys($purge_intervals) as $i) { | |
1512 | ||
1513 | if ($i == $purge_interval) { | |
1514 | $selected = "selected"; | |
1515 | } else { | |
1516 | $selected = ""; | |
1517 | } | |
1518 | print "<option $selected id=\"$i\">" . $purge_intervals[$i] . "</option>"; | |
1519 | } | |
1520 | ||
1521 | print "</select>"; | |
1522 | ||
1523 | print "</td>"; | |
1524 | ||
1525 | // print "<tr><td colspan=\"2\"><b>Authentication</b></td></tr>"; | |
1526 | ||
1527 | $row_class = toggleEvenOdd($row_class); | |
1528 | $auth_login = db_fetch_result($result, 0, "auth_login"); | |
1529 | ||
1530 | print "<tr class='$row_class'><td>Login:</td>"; | |
1531 | print "<td><input id=\"iedit_login\" | |
1532 | value=\"$auth_login\"></td></tr>"; | |
1533 | ||
1534 | $row_class = toggleEvenOdd($row_class); | |
1535 | $auth_pass = db_fetch_result($result, 0, "auth_pass"); | |
1536 | ||
1537 | print "<tr class='$row_class'><td>Password:</td>"; | |
1538 | print "<td><input type=\"password\" id=\"iedit_pass\" | |
1539 | value=\"$auth_pass\"></td></tr>"; | |
1540 | ||
1541 | $row_class = toggleEvenOdd($row_class); | |
1542 | $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); | |
1543 | ||
1544 | if ($private) { | |
1545 | $checked = "checked"; | |
1546 | } else { | |
1547 | $checked = ""; | |
1548 | } | |
1549 | ||
1550 | print "<tr class='$row_class'><td valign='top'>Options:</td>"; | |
1551 | print "<td><input type=\"checkbox\" id=\"iedit_private\" | |
1552 | $checked><label for=\"iedit_private\">Hide from feed browser</label>"; | |
1553 | ||
1554 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
1555 | ||
1556 | if ($rtl_content) { | |
1557 | $checked = "checked"; | |
1558 | } else { | |
1559 | $checked = ""; | |
1560 | } | |
1561 | ||
1562 | print "<br><input type=\"checkbox\" id=\"iedit_rtl\" | |
1563 | $checked><label for=\"iedit_rtl\">Right-to-left content</label>"; | |
1564 | ||
1565 | print "</td></tr>"; | |
1566 | ||
1567 | print "</table>"; | |
1568 | print "</div>"; | |
1569 | ||
1570 | print "<div align='center'> | |
1571 | <input type=\"submit\" class=\"button\" | |
1572 | onclick=\"feedEditSave()\" value=\"Save\"> | |
1573 | <input type='submit' class='button' | |
1574 | onclick=\"feedEditCancel()\" value=\"Cancel\"></div>"; | |
1575 | return; | |
1576 | } | |
1577 | ||
1578 | if ($subop == "editSave") { | |
1579 | $feed_title = db_escape_string($_POST["t"]); | |
1580 | $feed_link = db_escape_string($_POST["l"]); | |
1581 | $upd_intl = db_escape_string($_POST["ui"]); | |
1582 | $purge_intl = db_escape_string($_POST["pi"]); | |
1583 | $feed_id = db_escape_string($_POST["id"]); | |
1584 | $cat_id = db_escape_string($_POST["catid"]); | |
1585 | $auth_login = db_escape_string($_POST["login"]); | |
1586 | $auth_pass = db_escape_string($_POST["pass"]); | |
1587 | $parent_feed = db_escape_string($_POST["pfeed"]); | |
1588 | $private = db_escape_string($_POST["is_pvt"]); | |
1589 | $rtl_content = db_escape_string($_POST["is_rtl"]); | |
1590 | ||
1591 | if (strtoupper($upd_intl) == "DEFAULT") | |
1592 | $upd_intl = 0; | |
1593 | ||
1594 | if (strtoupper($upd_intl) == "DISABLED") | |
1595 | $upd_intl = -1; | |
1596 | ||
1597 | if (strtoupper($purge_intl) == "DEFAULT") | |
1598 | $purge_intl = 0; | |
1599 | ||
1600 | if (strtoupper($purge_intl) == "DISABLED") | |
1601 | $purge_intl = -1; | |
1602 | ||
1603 | if ($cat_id != 0) { | |
1604 | $category_qpart = "cat_id = '$cat_id'"; | |
1605 | } else { | |
1606 | $category_qpart = 'cat_id = NULL'; | |
1607 | } | |
1608 | ||
1609 | if ($parent_feed != 0) { | |
1610 | $parent_qpart = "parent_feed = '$parent_feed'"; | |
1611 | } else { | |
1612 | $parent_qpart = 'parent_feed = NULL'; | |
1613 | } | |
1614 | ||
1615 | $result = db_query($link, "UPDATE ttrss_feeds SET | |
1616 | $category_qpart, | |
1617 | $parent_qpart, | |
1618 | title = '$feed_title', feed_url = '$feed_link', | |
1619 | update_interval = '$upd_intl', | |
1620 | purge_interval = '$purge_intl', | |
1621 | auth_login = '$auth_login', | |
1622 | auth_pass = '$auth_pass', | |
1623 | private = $private, | |
1624 | rtl_content = $rtl_content | |
1625 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
1626 | } | |
1627 | ||
1628 | if ($subop == "saveCat") { | |
1629 | $cat_title = db_escape_string($_GET["title"]); | |
1630 | $cat_id = db_escape_string($_GET["id"]); | |
1631 | ||
1632 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
1633 | title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
1634 | ||
1635 | } | |
1636 | ||
1637 | if ($subop == "remove") { | |
1638 | ||
1639 | if (!WEB_DEMO_MODE) { | |
1640 | ||
1641 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1642 | ||
1643 | foreach ($ids as $id) { | |
1644 | db_query($link, "DELETE FROM ttrss_feeds | |
1645 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1646 | ||
1647 | $icons_dir = ICONS_DIR; | |
1648 | ||
1649 | if (file_exists($icons_dir . "/$id.ico")) { | |
1650 | unlink($icons_dir . "/$id.ico"); | |
1651 | } | |
1652 | } | |
1653 | } | |
1654 | } | |
1655 | ||
1656 | if ($subop == "add") { | |
1657 | ||
1658 | if (!WEB_DEMO_MODE) { | |
1659 | ||
1660 | $feed_link = db_escape_string(trim($_GET["link"])); | |
1661 | $cat_id = db_escape_string($_GET["cid"]); | |
1662 | ||
1663 | if ($cat_id == "0" || !$cat_id) { | |
1664 | $cat_qpart = "NULL"; | |
1665 | } else { | |
1666 | $cat_qpart = "'$cat_id'"; | |
1667 | } | |
1668 | ||
1669 | $result = db_query($link, | |
1670 | "SELECT id FROM ttrss_feeds | |
1671 | WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]); | |
1672 | ||
1673 | if (db_num_rows($result) == 0) { | |
1674 | ||
1675 | $result = db_query($link, | |
1676 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) | |
1677 | VALUES ('".$_SESSION["uid"]."', '$feed_link', | |
1678 | '[Unknown]', $cat_qpart)"); | |
1679 | ||
1680 | $result = db_query($link, | |
1681 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link' | |
1682 | AND owner_uid = " . $_SESSION["uid"]); | |
1683 | ||
1684 | $feed_id = db_fetch_result($result, 0, "id"); | |
1685 | ||
1686 | if ($feed_id) { | |
1687 | update_rss_feed($link, $feed_link, $feed_id, true); | |
1688 | } | |
1689 | } else { | |
1690 | ||
1691 | print "<div class=\"warning\"> | |
1692 | Feed <b>$feed_link</b> already exists in the database. | |
1693 | </div>"; | |
1694 | } | |
1695 | } | |
1696 | } | |
1697 | ||
1698 | if ($subop == "addCat") { | |
1699 | ||
1700 | if (!WEB_DEMO_MODE) { | |
1701 | ||
1702 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
1703 | ||
1704 | $result = db_query($link, | |
1705 | "SELECT id FROM ttrss_feed_categories | |
1706 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
1707 | ||
1708 | if (db_num_rows($result) == 0) { | |
1709 | ||
1710 | $result = db_query($link, | |
1711 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
1712 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
1713 | ||
1714 | } else { | |
1715 | ||
1716 | print "<div class=\"warning\"> | |
1717 | Category <b>$feed_cat</b> already exists in the database. | |
1718 | </div>"; | |
1719 | } | |
1720 | ||
1721 | ||
1722 | } | |
1723 | } | |
1724 | ||
1725 | if ($subop == "removeCats") { | |
1726 | ||
1727 | if (!WEB_DEMO_MODE) { | |
1728 | ||
1729 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1730 | ||
1731 | foreach ($ids as $id) { | |
1732 | ||
1733 | db_query($link, "BEGIN"); | |
1734 | ||
1735 | $result = db_query($link, | |
1736 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
1737 | WHERE cat_id = '$id'"); | |
1738 | ||
1739 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
1740 | ||
1741 | if ($num_feeds == 0) { | |
1742 | db_query($link, "DELETE FROM ttrss_feed_categories | |
1743 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1744 | } else { | |
1745 | ||
1746 | print "<div class=\"warning\"> | |
1747 | Unable to delete non empty feed categories.</div>"; | |
1748 | ||
1749 | } | |
1750 | ||
1751 | db_query($link, "COMMIT"); | |
1752 | } | |
1753 | } | |
1754 | } | |
1755 | ||
1756 | if ($subop == "categorize") { | |
1757 | ||
1758 | if (!WEB_DEMO_MODE) { | |
1759 | ||
1760 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1761 | ||
1762 | $cat_id = db_escape_string($_GET["cat_id"]); | |
1763 | ||
1764 | if ($cat_id == 0) { | |
1765 | $cat_id_qpart = 'NULL'; | |
1766 | } else { | |
1767 | $cat_id_qpart = "'$cat_id'"; | |
1768 | } | |
1769 | ||
1770 | db_query($link, "BEGIN"); | |
1771 | ||
1772 | foreach ($ids as $id) { | |
1773 | ||
1774 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
1775 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1776 | } | |
1777 | ||
1778 | db_query($link, "COMMIT"); | |
1779 | } | |
1780 | ||
1781 | } | |
1782 | ||
1783 | if ($quiet) return; | |
1784 | ||
1785 | // print "<h3>Edit Feeds</h3>"; | |
1786 | ||
1787 | $result = db_query($link, "SELECT id,title,feed_url,last_error | |
1788 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1789 | ||
1790 | if (db_num_rows($result) > 0) { | |
1791 | ||
1792 | print "<div class=\"warning\">"; | |
1793 | ||
1794 | // print"<img class=\"closeButton\" | |
1795 | // onclick=\"javascript:hideParentElement(this);\" src=\"images/close.png\">"; | |
1796 | ||
1797 | print "<a href=\"javascript:showBlockElement('feedUpdateErrors')\"> | |
1798 | <b>Feeds with update errors</b> (click to expand)</a>"; | |
1799 | ||
1800 | print "<ul id=\"feedUpdateErrors\" class=\"nomarks\">"; | |
1801 | ||
1802 | while ($line = db_fetch_assoc($result)) { | |
1803 | print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " . | |
1804 | $line["last_error"]; | |
1805 | } | |
1806 | ||
1807 | print "</ul>"; | |
1808 | print "</div>"; | |
1809 | ||
1810 | } | |
1811 | ||
1812 | $feed_search = db_escape_string($_GET["search"]); | |
1813 | ||
1814 | if (array_key_exists("search", $_GET)) { | |
1815 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1816 | } else { | |
1817 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1818 | } | |
1819 | ||
1820 | print "<table width='100%' class=\"prefGenericAddBox\" | |
1821 | cellspacing='0' cellpadding='0'><tr> | |
1822 | <td> | |
1823 | <input id=\"fadd_link\" | |
1824 | onchange=\"javascript:addFeed()\" | |
1825 | size=\"40\"> | |
1826 | <input type=\"submit\" class=\"button\" | |
1827 | onclick=\"javascript:addFeed()\" value=\"Add feed\">"; | |
1828 | ||
1829 | if (ENABLE_FEED_BROWSER) { | |
1830 | print " (<a href='javascript:browseFeeds()'>Top 50</a>)"; | |
1831 | } | |
1832 | ||
1833 | print "</td><td align='right'> | |
1834 | <input id=\"feed_search\" size=\"20\" | |
1835 | onchange=\"javascript:updateFeedList()\" | |
1836 | value=\"$feed_search\"> | |
1837 | <input type=\"submit\" class=\"button\" | |
1838 | onclick=\"javascript:updateFeedList()\" value=\"Search\"> | |
1839 | </td> | |
1840 | </tr></table>"; | |
1841 | ||
1842 | $feeds_sort = db_escape_string($_GET["sort"]); | |
1843 | ||
1844 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
1845 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
1846 | if (!$feeds_sort) $feeds_sort = "title"; | |
1847 | } | |
1848 | ||
1849 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
1850 | ||
1851 | if ($feed_search) { | |
1852 | $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR | |
1853 | UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND"; | |
1854 | } else { | |
1855 | $search_qpart = ""; | |
1856 | } | |
1857 | ||
1858 | $result = db_query($link, "SELECT | |
1859 | F1.id, | |
1860 | F1.title, | |
1861 | F1.feed_url, | |
1862 | substring(F1.last_updated,1,16) AS last_updated, | |
1863 | F1.parent_feed, | |
1864 | F1.update_interval, | |
1865 | F1.purge_interval, | |
1866 | F1.cat_id, | |
1867 | F2.title AS parent_title, | |
1868 | C1.title AS category | |
1869 | FROM | |
1870 | ttrss_feeds AS F1 | |
1871 | LEFT JOIN ttrss_feeds AS F2 | |
1872 | ON (F1.parent_feed = F2.id) | |
1873 | LEFT JOIN ttrss_feed_categories AS C1 | |
1874 | ON (F1.cat_id = C1.id) | |
1875 | WHERE | |
1876 | $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' | |
1877 | ORDER by category,$feeds_sort,title"); | |
1878 | ||
1879 | if (db_num_rows($result) != 0) { | |
1880 | ||
1881 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; | |
1882 | ||
1883 | print "<p><table width=\"100%\" cellspacing=\"0\" | |
1884 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
1885 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
1886 | Select: | |
1887 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', | |
1888 | 'FEEDR-', 'FRCHK-', true)\">All</a>, | |
1889 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', | |
1890 | 'FEEDR-', 'FRCHK-', false)\">None</a> | |
1891 | </td</tr>"; | |
1892 | ||
1893 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { | |
1894 | print "<tr class=\"title\"> | |
1895 | <td width='5%' align='center'> </td> | |
1896 | <td width='40%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> | |
1897 | <td width='45%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> | |
1898 | <td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>"; | |
1899 | } | |
1900 | ||
1901 | $lnum = 0; | |
1902 | ||
1903 | $cur_cat_id = -1; | |
1904 | ||
1905 | while ($line = db_fetch_assoc($result)) { | |
1906 | ||
1907 | $feed_id = $line["id"]; | |
1908 | $cat_id = $line["cat_id"]; | |
1909 | ||
1910 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
1911 | $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); | |
1912 | $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); | |
1913 | ||
1914 | if (!$edit_cat) $edit_cat = "Uncategorized"; | |
1915 | ||
1916 | $last_updated = $line["last_updated"]; | |
1917 | ||
1918 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
1919 | $last_updated = smart_date_time(strtotime($last_updated)); | |
1920 | } else { | |
1921 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1922 | $last_updated = date($short_date, strtotime($last_updated)); | |
1923 | } | |
1924 | ||
1925 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { | |
1926 | $lnum = 0; | |
1927 | ||
1928 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; | |
1929 | ||
1930 | print "<tr class=\"title\"> | |
1931 | <td width='5%' align='center'> </td> | |
1932 | <td width='40%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> | |
1933 | <td width='45%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> | |
1934 | <td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>"; | |
1935 | ||
1936 | $cur_cat_id = $cat_id; | |
1937 | } | |
1938 | ||
1939 | $class = ($lnum % 2) ? "even" : "odd"; | |
1940 | $this_row_id = "id=\"FEEDR-$feed_id\""; | |
1941 | ||
1942 | print "<tr class=\"$class\" $this_row_id>"; | |
1943 | ||
1944 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1945 | ||
1946 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1947 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1948 | } else { | |
1949 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1950 | } | |
1951 | // print "<td class='feedIcon'>$feed_icon</td>"; | |
1952 | ||
1953 | print "<td class='feedSelect'><input onclick='toggleSelectRow(this);' | |
1954 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; | |
1955 | ||
1956 | $edit_title = truncate_string($edit_title, 40); | |
1957 | $edit_link = truncate_string($edit_link, 60); | |
1958 | ||
1959 | $parent_title = $line["parent_title"]; | |
1960 | if ($parent_title) { | |
1961 | $parent_title = "<span class='groupPrompt'>(linked to | |
1962 | $parent_title)</span>"; | |
1963 | } | |
1964 | ||
1965 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1966 | "$feed_icon $edit_title $parent_title" . "</a></td>"; | |
1967 | ||
1968 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1969 | $edit_link . "</a></td>"; | |
1970 | ||
1971 | /* if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1972 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1973 | $edit_cat . "</a></td>"; | |
1974 | } */ | |
1975 | ||
1976 | /* print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1977 | $update_intervals[$line["update_interval"]] . "</a></td>"; | |
1978 | ||
1979 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1980 | $purge_intervals[$line["purge_interval"]] . "</a></td>"; */ | |
1981 | ||
1982 | print "<td align='right'><a href=\"javascript:editFeed($feed_id);\">" . | |
1983 | "$last_updated</a></td>"; | |
1984 | ||
1985 | print "</tr>"; | |
1986 | ||
1987 | ++$lnum; | |
1988 | } | |
1989 | ||
1990 | print "</table>"; | |
1991 | ||
1992 | print "<p>"; | |
1993 | ||
1994 | if ($subop == "edit") { | |
1995 | print "Edit feed: | |
1996 | <input type=\"submit\" class=\"button\" | |
1997 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> | |
1998 | <input type=\"submit\" class=\"button\" | |
1999 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; | |
2000 | } else { | |
2001 | ||
2002 | print " | |
2003 | Selection: | |
2004 | <input type=\"submit\" class=\"button\" | |
2005 | onclick=\"javascript:selectedFeedDetails()\" value=\"Details\"> | |
2006 | <input type=\"submit\" class=\"button\" | |
2007 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> | |
2008 | <input type=\"submit\" class=\"button\" | |
2009 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
2010 | ||
2011 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2012 | ||
2013 | print " "; | |
2014 | ||
2015 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2016 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2017 | ORDER BY title"); | |
2018 | ||
2019 | print "<select id=\"sfeed_set_fcat\">"; | |
2020 | print "<option id=\"0\">Uncategorized</option>"; | |
2021 | ||
2022 | if (db_num_rows($result) != 0) { | |
2023 | ||
2024 | print "<option disabled>--------</option>"; | |
2025 | ||
2026 | while ($line = db_fetch_assoc($result)) { | |
2027 | printf("<option id='%d'>%s</option>", | |
2028 | $line["id"], $line["title"]); | |
2029 | } | |
2030 | } | |
2031 | ||
2032 | print "</select>"; | |
2033 | ||
2034 | print " <input type=\"submit\" class=\"button\" | |
2035 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Set category\">"; | |
2036 | ||
2037 | } | |
2038 | ||
2039 | print " | |
2040 | All feeds: <input type=\"submit\" | |
2041 | class=\"button\" onclick=\"gotoExportOpml()\" | |
2042 | value=\"Export OPML\">"; | |
2043 | } | |
2044 | } else { | |
2045 | ||
2046 | print "<p>No feeds defined.</p>"; | |
2047 | ||
2048 | } | |
2049 | ||
2050 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2051 | ||
2052 | print "<h3>Edit Categories</h3>"; | |
2053 | ||
2054 | // print "<h3>Categories</h3>"; | |
2055 | ||
2056 | print "<div class=\"prefGenericAddBox\"> | |
2057 | <input id=\"fadd_cat\" | |
2058 | onchange=\"javascript:addFeedCat()\" | |
2059 | size=\"40\"> | |
2060 | <input | |
2061 | type=\"submit\" class=\"button\" | |
2062 | onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>"; | |
2063 | ||
2064 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2065 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2066 | ORDER BY title"); | |
2067 | ||
2068 | if (db_num_rows($result) != 0) { | |
2069 | ||
2070 | print "<p><table width=\"100%\" class=\"prefFeedCatList\" | |
2071 | cellspacing=\"0\" id=\"prefFeedCatList\">"; | |
2072 | ||
2073 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2074 | Select: | |
2075 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', | |
2076 | 'FCATR-', 'FCCHK-', true)\">All</a>, | |
2077 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', | |
2078 | 'FCATR-', 'FCCHK-', false)\">None</a> | |
2079 | </td</tr>"; | |
2080 | ||
2081 | print "<tr class=\"title\"> | |
2082 | <td width=\"5%\"></td><td width=\"80%\">Title</td> | |
2083 | </tr>"; | |
2084 | ||
2085 | $lnum = 0; | |
2086 | ||
2087 | while ($line = db_fetch_assoc($result)) { | |
2088 | ||
2089 | $class = ($lnum % 2) ? "even" : "odd"; | |
2090 | ||
2091 | $cat_id = $line["id"]; | |
2092 | ||
2093 | $edit_cat_id = $_GET["id"]; | |
2094 | ||
2095 | if ($subop == "editCat" && $cat_id != $edit_cat_id) { | |
2096 | $class .= "Grayed"; | |
2097 | $this_row_id = ""; | |
2098 | } else { | |
2099 | $this_row_id = "id=\"FCATR-$cat_id\""; | |
2100 | } | |
2101 | ||
2102 | print "<tr class=\"$class\" $this_row_id>"; | |
2103 | ||
2104 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
2105 | ||
2106 | if (!$edit_cat_id || $subop != "editCat") { | |
2107 | ||
2108 | print "<td align='center'><input onclick='toggleSelectRow(this);' | |
2109 | type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>"; | |
2110 | ||
2111 | print "<td><a href=\"javascript:editFeedCat($cat_id);\">" . | |
2112 | $edit_title . "</a></td>"; | |
2113 | ||
2114 | } else if ($cat_id != $edit_cat_id) { | |
2115 | ||
2116 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2117 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
2118 | ||
2119 | print "<td>$edit_title</td>"; | |
2120 | ||
2121 | } else { | |
2122 | ||
2123 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2124 | ||
2125 | print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>"; | |
2126 | ||
2127 | } | |
2128 | ||
2129 | print "</tr>"; | |
2130 | ||
2131 | ++$lnum; | |
2132 | } | |
2133 | ||
2134 | print "</table>"; | |
2135 | ||
2136 | print "<p>"; | |
2137 | ||
2138 | if ($subop == "editCat") { | |
2139 | print "Edit category: | |
2140 | <input type=\"submit\" class=\"button\" | |
2141 | onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\"> | |
2142 | <input type=\"submit\" class=\"button\" | |
2143 | onclick=\"javascript:feedCatEditSave()\" value=\"Save\">"; | |
2144 | } else { | |
2145 | ||
2146 | print " | |
2147 | Selection: | |
2148 | <input type=\"submit\" class=\"button\" | |
2149 | onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\"> | |
2150 | <input type=\"submit\" class=\"button\" | |
2151 | onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">"; | |
2152 | ||
2153 | } | |
2154 | ||
2155 | } else { | |
2156 | print "<p>No feed categories defined.</p>"; | |
2157 | } | |
2158 | } | |
2159 | ||
2160 | print "<h3>Import OPML</h3> | |
2161 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> | |
2162 | File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
2163 | <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\" | |
2164 | type=\"submit\" value=\"Import\"> | |
2165 | </form>"; | |
2166 | ||
2167 | } | |
2168 | ||
2169 | if ($op == "pref-filters") { | |
2170 | ||
2171 | $subop = $_GET["subop"]; | |
2172 | $quiet = $_GET["quiet"]; | |
2173 | ||
2174 | if ($subop == "editSave") { | |
2175 | ||
2176 | $regexp = db_escape_string($_GET["r"]); | |
2177 | $match = db_escape_string($_GET["m"]); | |
2178 | $filter_id = db_escape_string($_GET["id"]); | |
2179 | $feed_id = db_escape_string($_GET["fid"]); | |
2180 | $action_id = db_escape_string($_GET["aid"]); | |
2181 | ||
2182 | if (!$feed_id) { | |
2183 | $feed_id = 'NULL'; | |
2184 | } else { | |
2185 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2186 | } | |
2187 | ||
2188 | $result = db_query($link, "UPDATE ttrss_filters SET | |
2189 | reg_exp = '$regexp', | |
2190 | feed_id = $feed_id, | |
2191 | action_id = '$action_id', | |
2192 | filter_type = (SELECT id FROM ttrss_filter_types WHERE | |
2193 | description = '$match') | |
2194 | WHERE id = '$filter_id'"); | |
2195 | } | |
2196 | ||
2197 | if ($subop == "remove") { | |
2198 | ||
2199 | if (!WEB_DEMO_MODE) { | |
2200 | ||
2201 | $ids = split(",", db_escape_string($_GET["ids"])); | |
2202 | ||
2203 | foreach ($ids as $id) { | |
2204 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); | |
2205 | ||
2206 | } | |
2207 | } | |
2208 | } | |
2209 | ||
2210 | if ($subop == "add") { | |
2211 | ||
2212 | if (!WEB_DEMO_MODE) { | |
2213 | ||
2214 | $regexp = db_escape_string(trim($_GET["regexp"])); | |
2215 | $match = db_escape_string(trim($_GET["match"])); | |
2216 | $feed_id = db_escape_string($_GET["fid"]); | |
2217 | $action_id = db_escape_string($_GET["aid"]); | |
2218 | ||
2219 | if (!$feed_id) { | |
2220 | $feed_id = 'NULL'; | |
2221 | } else { | |
2222 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2223 | } | |
2224 | ||
2225 | $result = db_query($link, | |
2226 | "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, | |
2227 | action_id) | |
2228 | VALUES | |
2229 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE | |
2230 | description = '$match'),'".$_SESSION["uid"]."', | |
2231 | $feed_id, '$action_id')"); | |
2232 | } | |
2233 | } | |
2234 | ||
2235 | if ($quiet) return; | |
2236 | ||
2237 | $result = db_query($link, "SELECT description | |
2238 | FROM ttrss_filter_types ORDER BY description"); | |
2239 | ||
2240 | $filter_types = array(); | |
2241 | ||
2242 | while ($line = db_fetch_assoc($result)) { | |
2243 | array_push($filter_types, $line["description"]); | |
2244 | } | |
2245 | ||
2246 | print "<div class=\"prefGenericAddBox\"> | |
2247 | <input id=\"fadd_regexp\" size=\"40\"> "; | |
2248 | ||
2249 | print_select("fadd_match", "Title", $filter_types); | |
2250 | ||
2251 | print " <select id=\"fadd_feed\">"; | |
2252 | ||
2253 | print "<option selected id=\"0\">All feeds</option>"; | |
2254 | ||
2255 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2256 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2257 | ||
2258 | if (db_num_rows($result) > 0) { | |
2259 | print "<option disabled>--------</option>"; | |
2260 | } | |
2261 | ||
2262 | while ($line = db_fetch_assoc($result)) { | |
2263 | printf("<option id='%d'>%s</option>", $line["id"], $line["title"]); | |
2264 | } | |
2265 | ||
2266 | print "</select> "; | |
2267 | ||
2268 | print " Action: "; | |
2269 | ||
2270 | print "<select id=\"fadd_action\">"; | |
2271 | ||
2272 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2273 | ORDER BY name"); | |
2274 | ||
2275 | while ($line = db_fetch_assoc($result)) { | |
2276 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
2277 | } | |
2278 | ||
2279 | print "</select> "; | |
2280 | ||
2281 | /* print "<input type=\"submit\" | |
2282 | class=\"button\" onclick=\"javascript:testFilter()\" | |
2283 | value=\"Test filter\"> "; */ | |
2284 | ||
2285 | print "<input type=\"submit\" | |
2286 | class=\"button\" onclick=\"javascript:addFilter()\" | |
2287 | value=\"Add filter\">"; | |
2288 | ||
2289 | print "</div>"; | |
2290 | ||
2291 | $result = db_query($link, "SELECT | |
2292 | ttrss_filters.id AS id,reg_exp, | |
2293 | ttrss_filter_types.name AS filter_type_name, | |
2294 | ttrss_filter_types.description AS filter_type_descr, | |
2295 | feed_id, | |
2296 | ttrss_filter_actions.description AS action_description, | |
2297 | ttrss_feeds.title AS feed_title | |
2298 | FROM | |
2299 | ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN | |
2300 | ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id) | |
2301 | WHERE | |
2302 | filter_type = ttrss_filter_types.id AND | |
2303 | ttrss_filter_actions.id = action_id AND | |
2304 | ttrss_filters.owner_uid = ".$_SESSION["uid"]." | |
2305 | ORDER by reg_exp"); | |
2306 | ||
2307 | if (db_num_rows($result) != 0) { | |
2308 | ||
2309 | print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" | |
2310 | id=\"prefFilterList\">"; | |
2311 | ||
2312 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2313 | Select: | |
2314 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', | |
2315 | 'FILRR-', 'FICHK-', true)\">All</a>, | |
2316 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', | |
2317 | 'FILRR-', 'FICHK-', false)\">None</a> | |
2318 | </td</tr>"; | |
2319 | ||
2320 | print "<tr class=\"title\"> | |
2321 | <td align='center' width=\"5%\"> </td> | |
2322 | <td width=\"20%\">Filter expression</td> | |
2323 | <td width=\"20%\">Feed</td> | |
2324 | <td width=\"15%\">Match</td> | |
2325 | <td width=\"15%\">Action</td>"; | |
2326 | ||
2327 | $lnum = 0; | |
2328 | ||
2329 | while ($line = db_fetch_assoc($result)) { | |
2330 | ||
2331 | $class = ($lnum % 2) ? "even" : "odd"; | |
2332 | ||
2333 | $filter_id = $line["id"]; | |
2334 | $edit_filter_id = $_GET["id"]; | |
2335 | ||
2336 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
2337 | $class .= "Grayed"; | |
2338 | $this_row_id = ""; | |
2339 | } else { | |
2340 | $this_row_id = "id=\"FILRR-$filter_id\""; | |
2341 | } | |
2342 | ||
2343 | print "<tr class=\"$class\" $this_row_id>"; | |
2344 | ||
2345 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); | |
2346 | ||
2347 | if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; | |
2348 | ||
2349 | if (!$edit_filter_id || $subop != "edit") { | |
2350 | ||
2351 | print "<td align='center'><input onclick='toggleSelectRow(this);' | |
2352 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; | |
2353 | ||
2354 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2355 | $line["reg_exp"] . "</td>"; | |
2356 | ||
2357 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2358 | $line["feed_title"] . "</td>"; | |
2359 | ||
2360 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2361 | $line["filter_type_descr"] . "</td>"; | |
2362 | ||
2363 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2364 | $line["action_description"] . "</td>"; | |
2365 | ||
2366 | } else if ($filter_id != $edit_filter_id) { | |
2367 | ||
2368 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2369 | ||
2370 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2371 | id=\"FICHK-".$line["id"]."\"></td>"; | |
2372 | ||
2373 | print "<td>".$line["reg_exp"]."</td>"; | |
2374 | print "<td>".$line["feed_title"]."</td>"; | |
2375 | print "<td>".$line["filter_type_descr"]."</td>"; | |
2376 | print "<td>".$line["action_description"]."</td>"; | |
2377 | ||
2378 | } else { | |
2379 | ||
2380 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2381 | ||
2382 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. | |
2383 | "\"></td>"; | |
2384 | ||
2385 | print "<td>"; | |
2386 | print "<select id=\"iedit_feed\">"; | |
2387 | print "<option id=\"0\">All feeds</option>"; | |
2388 | ||
2389 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2390 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2391 | ||
2392 | if (db_num_rows($tmp_result) > 0) { | |
2393 | print "<option disabled>--------</option>"; | |
2394 | } | |
2395 | ||
2396 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
2397 | if ($tmp_line["id"] == $line["feed_id"]) { | |
2398 | $is_selected = "selected"; | |
2399 | } else { | |
2400 | $is_selected = ""; | |
2401 | } | |
2402 | printf("<option $is_selected id='%d'>%s</option>", | |
2403 | $tmp_line["id"], $tmp_line["title"]); | |
2404 | } | |
2405 | ||
2406 | print "</select></td>"; | |
2407 | ||
2408 | print "<td>"; | |
2409 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
2410 | print "</td>"; | |
2411 | ||
2412 | print "<td>"; | |
2413 | print "<select id=\"iedit_filter_action\">"; | |
2414 | ||
2415 | $tmp_result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2416 | ORDER BY description"); | |
2417 | ||
2418 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
2419 | if ($tmp_line["description"] == $line["action_description"]) { | |
2420 | $is_selected = "selected"; | |
2421 | } else { | |
2422 | $is_selected = ""; | |
2423 | } | |
2424 | printf("<option $is_selected id='%d'>%s</option>", | |
2425 | $tmp_line["id"], $tmp_line["description"]); | |
2426 | } | |
2427 | ||
2428 | print "</select></td>"; | |
2429 | ||
2430 | print "</td>"; | |
2431 | } | |
2432 | ||
2433 | print "</tr>"; | |
2434 | ||
2435 | ++$lnum; | |
2436 | } | |
2437 | ||
2438 | if ($lnum == 0) { | |
2439 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
2440 | } | |
2441 | ||
2442 | print "</table>"; | |
2443 | ||
2444 | print "<p>"; | |
2445 | ||
2446 | if ($subop == "edit") { | |
2447 | print "Edit filter: | |
2448 | <input type=\"submit\" class=\"button\" | |
2449 | onclick=\"javascript:filterEditSave()\" value=\"Save\"> | |
2450 | <input type=\"submit\" class=\"button\" | |
2451 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">"; | |
2452 | ||
2453 | } else { | |
2454 | ||
2455 | print " | |
2456 | Selection: | |
2457 | <input type=\"submit\" class=\"button\" | |
2458 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> | |
2459 | <input type=\"submit\" class=\"button\" | |
2460 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; | |
2461 | } | |
2462 | ||
2463 | } else { | |
2464 | ||
2465 | print "<p>No filters defined.</p>"; | |
2466 | ||
2467 | } | |
2468 | } | |
2469 | ||
2470 | // We need to accept raw SQL data in label queries, so not everything is escaped | |
2471 | // here, this is by design. If you don't like the whole idea, disable labels | |
2472 | // altogether with GLOBAL_ENABLE_LABELS = false | |
2473 | ||
2474 | if ($op == "pref-labels") { | |
2475 | ||
2476 | if (!GLOBAL_ENABLE_LABELS) { | |
2477 | return; | |
2478 | } | |
2479 | ||
2480 | $subop = $_GET["subop"]; | |
2481 | ||
2482 | if ($subop == "test") { | |
2483 | ||
2484 | $expr = $_GET["expr"]; | |
2485 | $descr = $_GET["descr"]; | |
2486 | ||
2487 | print "<div class='infoBoxContents'>"; | |
2488 | ||
2489 | print "<h1>Label «$descr»</h1>"; | |
2490 | ||
2491 | // print "<p><b>Expression</b>: $expr</p>"; | |
2492 | ||
2493 | $result = db_query($link, | |
2494 | "SELECT count(id) AS num_matches | |
2495 | FROM ttrss_entries,ttrss_user_entries | |
2496 | WHERE ($expr) AND | |
2497 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
2498 | owner_uid = " . $_SESSION["uid"]); | |
2499 | ||
2500 | $num_matches = db_fetch_result($result, 0, "num_matches");; | |
2501 | ||
2502 | if ($num_matches > 0) { | |
2503 | ||
2504 | print "<p>Query returned <b>$num_matches</b> matches, first 5 follow:</p>"; | |
2505 | ||
2506 | $result = db_query($link, | |
2507 | "SELECT title, | |
2508 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title | |
2509 | FROM ttrss_entries,ttrss_user_entries | |
2510 | WHERE ($expr) AND | |
2511 | ttrss_user_entries.ref_id = ttrss_entries.id | |
2512 | AND owner_uid = " . $_SESSION["uid"] . " | |
2513 | ORDER BY date_entered DESC LIMIT 5"); | |
2514 | ||
2515 | print "<ul class=\"nomarks\">"; | |
2516 | while ($line = db_fetch_assoc($result)) { | |
2517 | print "<li>".$line["title"]. | |
2518 | " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>"; | |
2519 | } | |
2520 | print "</ul>"; | |
2521 | ||
2522 | } else { | |
2523 | print "<p>Query didn't return any matches.</p>"; | |
2524 | } | |
2525 | ||
2526 | print "</div>"; | |
2527 | ||
2528 | print "<div align='center'> | |
2529 | <input type='submit' class='button' | |
2530 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
2531 | return; | |
2532 | } | |
2533 | ||
2534 | if ($subop == "editSave") { | |
2535 | ||
2536 | $sql_exp = $_GET["s"]; | |
2537 | $descr = $_GET["d"]; | |
2538 | $label_id = db_escape_string($_GET["id"]); | |
2539 | ||
2540 | // print "$sql_exp : $descr : $label_id"; | |
2541 | ||
2542 | $result = db_query($link, "UPDATE ttrss_labels SET | |
2543 | sql_exp = '$sql_exp', | |
2544 | description = '$descr' | |
2545 | WHERE id = '$label_id'"); | |
2546 | } | |
2547 | ||
2548 | if ($subop == "remove") { | |
2549 | ||
2550 | if (!WEB_DEMO_MODE) { | |
2551 | ||
2552 | $ids = split(",", db_escape_string($_GET["ids"])); | |
2553 | ||
2554 | foreach ($ids as $id) { | |
2555 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
2556 | ||
2557 | } | |
2558 | } | |
2559 | } | |
2560 | ||
2561 | if ($subop == "add") { | |
2562 | ||
2563 | if (!WEB_DEMO_MODE) { | |
2564 | ||
2565 | // no escaping is done here on purpose | |
2566 | $exp = trim($_GET["exp"]); | |
2567 | ||
2568 | $result = db_query($link, | |
2569 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) | |
2570 | VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); | |
2571 | } | |
2572 | } | |
2573 | ||
2574 | print "<div class=\"prefGenericAddBox\"> | |
2575 | <input size=\"40\" id=\"ladd_expr\"> "; | |
2576 | ||
2577 | print"<input type=\"submit\" class=\"button\" | |
2578 | onclick=\"javascript:addLabel()\" value=\"Add label\"></div>"; | |
2579 | ||
2580 | $result = db_query($link, "SELECT | |
2581 | id,sql_exp,description | |
2582 | FROM | |
2583 | ttrss_labels | |
2584 | WHERE | |
2585 | owner_uid = ".$_SESSION["uid"]." | |
2586 | ORDER by description"); | |
2587 | ||
2588 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; | |
2589 | ||
2590 | if (db_num_rows($result) != 0) { | |
2591 | ||
2592 | print "<p><table width=\"100%\" cellspacing=\"0\" | |
2593 | class=\"prefLabelList\" id=\"prefLabelList\">"; | |
2594 | ||
2595 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2596 | Select: | |
2597 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', | |
2598 | 'LILRR-', 'LICHK-', true)\">All</a>, | |
2599 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', | |
2600 | 'LILRR-', 'LICHK-', false)\">None</a> | |
2601 | </td</tr>"; | |
2602 | ||
2603 | print "<tr class=\"title\"> | |
2604 | <td align='center' width=\"5%\"> </td> | |
2605 | <td width=\"40%\">SQL expression | |
2606 | <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a> | |
2607 | </td> | |
2608 | <td width=\"40%\">Caption</td></tr>"; | |
2609 | ||
2610 | $lnum = 0; | |
2611 | ||
2612 | while ($line = db_fetch_assoc($result)) { | |
2613 | ||
2614 | $class = ($lnum % 2) ? "even" : "odd"; | |
2615 | ||
2616 | $label_id = $line["id"]; | |
2617 | $edit_label_id = $_GET["id"]; | |
2618 | ||
2619 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
2620 | $class .= "Grayed"; | |
2621 | $this_row_id = ""; | |
2622 | } else { | |
2623 | $this_row_id = "id=\"LILRR-$label_id\""; | |
2624 | } | |
2625 | ||
2626 | print "<tr class=\"$class\" $this_row_id>"; | |
2627 | ||
2628 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
2629 | $line["description"] = htmlspecialchars($line["description"]); | |
2630 | ||
2631 | if (!$edit_label_id || $subop != "edit") { | |
2632 | ||
2633 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
2634 | ||
2635 | print "<td align='center'><input onclick='toggleSelectRow(this);' | |
2636 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; | |
2637 | ||
2638 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
2639 | $line["sql_exp"] . "</td>"; | |
2640 | ||
2641 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
2642 | $line["description"] . "</td>"; | |
2643 | ||
2644 | } else if ($label_id != $edit_label_id) { | |
2645 | ||
2646 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2647 | ||
2648 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2649 | id=\"LICHK-".$line["id"]."\"></td>"; | |
2650 | ||
2651 | print "<td>".$line["sql_exp"]."</td>"; | |
2652 | print "<td>".$line["description"]."</td>"; | |
2653 | ||
2654 | } else { | |
2655 | ||
2656 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2657 | ||
2658 | print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. | |
2659 | "\"></td>"; | |
2660 | ||
2661 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
2662 | "\"></td>"; | |
2663 | ||
2664 | } | |
2665 | ||
2666 | ||
2667 | print "</tr>"; | |
2668 | ||
2669 | ++$lnum; | |
2670 | } | |
2671 | ||
2672 | if ($lnum == 0) { | |
2673 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
2674 | } | |
2675 | ||
2676 | print "</table>"; | |
2677 | ||
2678 | print "<p>"; | |
2679 | ||
2680 | if ($subop == "edit") { | |
2681 | print "Edit label: | |
2682 | <input type=\"submit\" class=\"button\" | |
2683 | onclick=\"javascript:labelTest()\" value=\"Test\"> | |
2684 | <input type=\"submit\" class=\"button\" | |
2685 | onclick=\"javascript:labelEditSave()\" value=\"Save\"> | |
2686 | <input type=\"submit\" class=\"button\" | |
2687 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">"; | |
2688 | ||
2689 | } else { | |
2690 | ||
2691 | print " | |
2692 | Selection: | |
2693 | <input type=\"submit\" class=\"button\" | |
2694 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> | |
2695 | <input type=\"submit\" class=\"button\" | |
2696 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; | |
2697 | } | |
2698 | } else { | |
2699 | print "<p>No labels defined.</p>"; | |
2700 | } | |
2701 | } | |
2702 | ||
2703 | if ($op == "error") { | |
2704 | print "<div width=\"100%\" align='center'>"; | |
2705 | $msg = $_GET["msg"]; | |
2706 | print $msg; | |
2707 | print "</div>"; | |
2708 | } | |
2709 | ||
2710 | if ($op == "help") { | |
2711 | if (!$_GET["noheaders"]) { | |
2712 | print "<html><head> | |
2713 | <title>Tiny Tiny RSS : Help</title> | |
2714 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
2715 | <script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> | |
2716 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
2717 | </head><body>"; | |
2718 | } | |
2719 | ||
2720 | $tid = sprintf("%d", $_GET["tid"]); | |
2721 | ||
2722 | print "<div class='infoBoxContents'>"; | |
2723 | ||
2724 | if (file_exists("help/$tid.php")) { | |
2725 | include("help/$tid.php"); | |
2726 | } else { | |
2727 | print "<p>Help topic not found.</p>"; | |
2728 | } | |
2729 | ||
2730 | print "</div>"; | |
2731 | ||
2732 | print "<div align='center'> | |
2733 | <input type='submit' class='button' | |
2734 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
2735 | ||
2736 | if (!$_GET["noheaders"]) { | |
2737 | print "</body></html>"; | |
2738 | } | |
2739 | ||
2740 | } | |
2741 | ||
2742 | if ($op == "dlg") { | |
2743 | $id = $_GET["id"]; | |
2744 | $param = $_GET["param"]; | |
2745 | ||
2746 | if ($id == "quickAddFeed") { | |
2747 | print " | |
2748 | Feed URL: <input | |
2749 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
2750 | id=\"qafInput\">"; | |
2751 | ||
2752 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2753 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2754 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2755 | ORDER BY title"); | |
2756 | ||
2757 | print " <select id=\"qafCat\">"; | |
2758 | print "<option id=\"0\">Uncategorized</option>"; | |
2759 | ||
2760 | if (db_num_rows($result) != 0) { | |
2761 | ||
2762 | print "<option disabled>--------</option>"; | |
2763 | ||
2764 | while ($line = db_fetch_assoc($result)) { | |
2765 | printf("<option id='%d'>%s</option>", | |
2766 | $line["id"], $line["title"]); | |
2767 | } | |
2768 | } | |
2769 | ||
2770 | print "</select>"; | |
2771 | } | |
2772 | ||
2773 | print " <input class=\"button\" | |
2774 | type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\"> | |
2775 | <input class=\"button\" | |
2776 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2777 | value=\"Cancel\">"; | |
2778 | } | |
2779 | ||
2780 | if ($id == "quickDelFeed") { | |
2781 | ||
2782 | $param = db_escape_string($param); | |
2783 | ||
2784 | $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'"); | |
2785 | ||
2786 | if ($result) { | |
2787 | ||
2788 | $f_title = db_fetch_result($result, 0, "title"); | |
2789 | ||
2790 | print "Remove current feed (<b>$f_title</b>)? | |
2791 | <input class=\"button\" | |
2792 | type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\"> | |
2793 | <input class=\"button\" | |
2794 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2795 | value=\"Cancel\">"; | |
2796 | } else { | |
2797 | print "Error: Feed $param not found. | |
2798 | <input class=\"button\" | |
2799 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2800 | value=\"Cancel\">"; | |
2801 | } | |
2802 | } | |
2803 | ||
2804 | if ($id == "search") { | |
2805 | ||
2806 | $active_feed_id = db_escape_string($_GET["param"]); | |
2807 | ||
2808 | print "<input id=\"searchbox\" class=\"extSearch\" | |
2809 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
2810 | onchange=\"javascript:search()\"> | |
2811 | <select id=\"searchmodebox\"> | |
2812 | <option selected>All feeds</option>"; | |
2813 | ||
2814 | if ($active_feed_id) { | |
2815 | print "<option>This feed</option>"; | |
2816 | } else { | |
2817 | print "<option disabled>This feed</option>"; | |
2818 | } | |
2819 | ||
2820 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2821 | print "<option>This category</option>"; | |
2822 | } | |
2823 | ||
2824 | print "</select> | |
2825 | <input type=\"submit\" | |
2826 | class=\"button\" onclick=\"javascript:search()\" value=\"Search\"> | |
2827 | <input class=\"button\" | |
2828 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2829 | value=\"Close\">"; | |
2830 | ||
2831 | } | |
2832 | ||
2833 | if ($id == "quickAddFilter") { | |
2834 | ||
2835 | $result = db_query($link, "SELECT description | |
2836 | FROM ttrss_filter_types ORDER BY description"); | |
2837 | ||
2838 | $filter_types = array(); | |
2839 | ||
2840 | while ($line = db_fetch_assoc($result)) { | |
2841 | array_push($filter_types, $line["description"]); | |
2842 | } | |
2843 | ||
2844 | print "<table>"; | |
2845 | ||
2846 | print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"40\"> "; | |
2847 | ||
2848 | print_select("fadd_match", "Title", $filter_types); | |
2849 | ||
2850 | print "</td></tr>"; | |
2851 | print "<tr><td>Feed:</td><td><select id=\"fadd_feed\">"; | |
2852 | ||
2853 | print "<option selected id=\"0\">All feeds</option>"; | |
2854 | ||
2855 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2856 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2857 | ||
2858 | if (db_num_rows($result) > 0) { | |
2859 | print "<option disabled>--------</option>"; | |
2860 | } | |
2861 | ||
2862 | while ($line = db_fetch_assoc($result)) { | |
2863 | if ($param == $line["id"]) { | |
2864 | $selected = "selected"; | |
2865 | } else { | |
2866 | $selected = ""; | |
2867 | } | |
2868 | printf("<option id='%d' %s>%s</option>", $line["id"], $selected, $line["title"]); | |
2869 | } | |
2870 | ||
2871 | print "</select></td></tr>"; | |
2872 | ||
2873 | print "<tr><td>Action:</td>"; | |
2874 | ||
2875 | print "<td><select id=\"fadd_action\">"; | |
2876 | ||
2877 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2878 | ORDER BY name"); | |
2879 | ||
2880 | while ($line = db_fetch_assoc($result)) { | |
2881 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
2882 | } | |
2883 | ||
2884 | print "</select>"; | |
2885 | ||
2886 | print "</td></tr><tr><td colspan=\"2\" align=\"right\">"; | |
2887 | ||
2888 | print "<input type=\"submit\" | |
2889 | class=\"button\" onclick=\"javascript:qaddFilter()\" | |
2890 | value=\"Add filter\"> "; | |
2891 | ||
2892 | print "<input class=\"button\" | |
2893 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2894 | value=\"Close\">"; | |
2895 | ||
2896 | print "</td></tr></table>"; | |
2897 | } | |
2898 | } | |
2899 | ||
2900 | // update feeds of all users, may be used anonymously | |
2901 | if ($op == "globalUpdateFeeds") { | |
2902 | ||
2903 | $result = db_query($link, "SELECT id FROM ttrss_users"); | |
2904 | ||
2905 | while ($line = db_fetch_assoc($result)) { | |
2906 | $user_id = $line["id"]; | |
2907 | // print "<!-- updating feeds of uid $user_id -->"; | |
2908 | update_all_feeds($link, false, $user_id); | |
2909 | } | |
2910 | ||
2911 | print "<rpc-reply> | |
2912 | <message msg=\"All feeds updated\"/> | |
2913 | </rpc-reply>"; | |
2914 | ||
2915 | } | |
2916 | ||
2917 | if ($op == "pref-prefs") { | |
2918 | ||
2919 | $subop = $_REQUEST["subop"]; | |
2920 | ||
2921 | if ($subop == "Save configuration") { | |
2922 | ||
2923 | if (WEB_DEMO_MODE) { | |
2924 | header("Location: prefs.php"); | |
2925 | return; | |
2926 | } | |
2927 | ||
2928 | $_SESSION["prefs_op_result"] = "save-config"; | |
2929 | ||
2930 | $_SESSION["prefs_cache"] = false; | |
2931 | ||
2932 | foreach (array_keys($_POST) as $pref_name) { | |
2933 | ||
2934 | $pref_name = db_escape_string($pref_name); | |
2935 | $value = db_escape_string($_POST[$pref_name]); | |
2936 | ||
2937 | $result = db_query($link, "SELECT type_name | |
2938 | FROM ttrss_prefs,ttrss_prefs_types | |
2939 | WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id"); | |
2940 | ||
2941 | if (db_num_rows($result) > 0) { | |
2942 | ||
2943 | $type_name = db_fetch_result($result, 0, "type_name"); | |
2944 | ||
2945 | // print "$pref_name : $type_name : $value<br>"; | |
2946 | ||
2947 | if ($type_name == "bool") { | |
2948 | if ($value == "1") { | |
2949 | $value = "true"; | |
2950 | } else { | |
2951 | $value = "false"; | |
2952 | } | |
2953 | } else if ($type_name == "integer") { | |
2954 | $value = sprintf("%d", $value); | |
2955 | } | |
2956 | ||
2957 | // print "$pref_name : $type_name : $value<br>"; | |
2958 | ||
2959 | db_query($link, "UPDATE ttrss_user_prefs SET value = '$value' | |
2960 | WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]); | |
2961 | ||
2962 | } | |
2963 | ||
2964 | header("Location: prefs.php"); | |
2965 | ||
2966 | } | |
2967 | ||
2968 | } else if ($subop == "getHelp") { | |
2969 | ||
2970 | $pref_name = db_escape_string($_GET["pn"]); | |
2971 | ||
2972 | $result = db_query($link, "SELECT help_text FROM ttrss_prefs | |
2973 | WHERE pref_name = '$pref_name'"); | |
2974 | ||
2975 | if (db_num_rows($result) > 0) { | |
2976 | $help_text = db_fetch_result($result, 0, "help_text"); | |
2977 | print $help_text; | |
2978 | } else { | |
2979 | print "Unknown option: $pref_name"; | |
2980 | } | |
2981 | ||
2982 | } else if ($subop == "Change e-mail") { | |
2983 | ||
2984 | if (WEB_DEMO_MODE) { | |
2985 | header("Location: prefs.php"); | |
2986 | return; | |
2987 | } | |
2988 | ||
2989 | $email = db_escape_string($_GET["email"]); | |
2990 | $active_uid = $_SESSION["uid"]; | |
2991 | ||
2992 | if ($email) { | |
2993 | db_query($link, "UPDATE ttrss_users SET email = '$email' | |
2994 | WHERE id = '$active_uid'"); | |
2995 | } | |
2996 | ||
2997 | header("Location: prefs.php"); | |
2998 | ||
2999 | } else if ($subop == "Change password") { | |
3000 | ||
3001 | if (WEB_DEMO_MODE) { | |
3002 | header("Location: prefs.php"); | |
3003 | return; | |
3004 | } | |
3005 | ||
3006 | $old_pw = $_POST["OLD_PASSWORD"]; | |
3007 | $new_pw = $_POST["OLD_PASSWORD"]; | |
3008 | ||
3009 | $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]); | |
3010 | $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]); | |
3011 | ||
3012 | $active_uid = $_SESSION["uid"]; | |
3013 | ||
3014 | if ($old_pw && $new_pw) { | |
3015 | ||
3016 | $login = db_escape_string($_SERVER['PHP_AUTH_USER']); | |
3017 | ||
3018 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3019 | id = '$active_uid' AND (pwd_hash = '$old_pw' OR | |
3020 | pwd_hash = '$old_pw_hash')"); | |
3021 | ||
3022 | if (db_num_rows($result) == 1) { | |
3023 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash' | |
3024 | WHERE id = '$active_uid'"); | |
3025 | ||
3026 | $_SESSION["pwd_change_result"] = "ok"; | |
3027 | } else { | |
3028 | $_SESSION["pwd_change_result"] = "failed"; | |
3029 | } | |
3030 | } | |
3031 | ||
3032 | header("Location: prefs.php"); | |
3033 | ||
3034 | } else if ($subop == "Reset to defaults") { | |
3035 | ||
3036 | if (WEB_DEMO_MODE) { | |
3037 | header("Location: prefs.php"); | |
3038 | return; | |
3039 | } | |
3040 | ||
3041 | $_SESSION["prefs_op_result"] = "reset-to-defaults"; | |
3042 | ||
3043 | if (DB_TYPE == "pgsql") { | |
3044 | db_query($link,"UPDATE ttrss_user_prefs | |
3045 | SET value = ttrss_prefs.def_value | |
3046 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
3047 | ttrss_prefs.pref_name = ttrss_user_prefs.pref_name"); | |
3048 | } else { | |
3049 | db_query($link, "DELETE FROM ttrss_user_prefs | |
3050 | WHERE owner_uid = ".$_SESSION["uid"]); | |
3051 | initialize_user_prefs($link, $_SESSION["uid"]); | |
3052 | } | |
3053 | ||
3054 | header("Location: prefs.php"); | |
3055 | ||
3056 | } else if ($subop == "Change theme") { | |
3057 | ||
3058 | $theme = db_escape_string($_POST["theme"]); | |
3059 | ||
3060 | if ($theme == "Default") { | |
3061 | $theme_qpart = 'NULL'; | |
3062 | } else { | |
3063 | $theme_qpart = "'$theme'"; | |
3064 | } | |
3065 | ||
3066 | $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes | |
3067 | WHERE theme_name = '$theme'"); | |
3068 | ||
3069 | if (db_num_rows($result) == 1) { | |
3070 | $theme_id = db_fetch_result($result, 0, "id"); | |
3071 | $theme_path = db_fetch_result($result, 0, "theme_path"); | |
3072 | } else { | |
3073 | $theme_id = "NULL"; | |
3074 | $theme_path = ""; | |
3075 | } | |
3076 | ||
3077 | db_query($link, "UPDATE ttrss_users SET | |
3078 | theme_id = $theme_id WHERE id = " . $_SESSION["uid"]); | |
3079 | ||
3080 | $_SESSION["theme"] = $theme_path; | |
3081 | ||
3082 | header("Location: prefs.php"); | |
3083 | ||
3084 | } else { | |
3085 | ||
3086 | if (!SINGLE_USER_MODE) { | |
3087 | ||
3088 | $result = db_query($link, "SELECT id,email FROM ttrss_users | |
3089 | WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR | |
3090 | pwd_hash = 'SHA1:".sha1("password")."')"); | |
3091 | ||
3092 | if (db_num_rows($result) != 0) { | |
3093 | print "<div class=\"warning\"> | |
3094 | Your password is at default value, please change it. | |
3095 | </div>"; | |
3096 | } | |
3097 | ||
3098 | if ($_SESSION["pwd_change_result"] == "failed") { | |
3099 | print "<div class=\"warning\"> | |
3100 | There was an error while changing your password. | |
3101 | </div>"; | |
3102 | } | |
3103 | ||
3104 | if ($_SESSION["pwd_change_result"] == "ok") { | |
3105 | print "<div class=\"notice\"> | |
3106 | Password changed successfully. | |
3107 | </div>"; | |
3108 | } | |
3109 | ||
3110 | $_SESSION["pwd_change_result"] = ""; | |
3111 | ||
3112 | if ($_SESSION["prefs_op_result"] == "reset-to-defaults") { | |
3113 | print "<div class=\"notice\"> | |
3114 | Your configuration was reset to defaults. | |
3115 | </div>"; | |
3116 | } | |
3117 | ||
3118 | if ($_SESSION["prefs_op_result"] == "save-config") { | |
3119 | print "<div class=\"notice\"> | |
3120 | Your configuration was saved successfully. | |
3121 | </div>"; | |
3122 | } | |
3123 | ||
3124 | $_SESSION["prefs_op_result"] = ""; | |
3125 | ||
3126 | print "<form action=\"backend.php\" method=\"GET\">"; | |
3127 | ||
3128 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3129 | print "<tr><td colspan='3'><h3>Personal data</h3></tr></td>"; | |
3130 | ||
3131 | $result = db_query($link, "SELECT email FROM ttrss_users | |
3132 | WHERE id = ".$_SESSION["uid"]); | |
3133 | ||
3134 | $email = db_fetch_result($result, 0, "email"); | |
3135 | ||
3136 | print "<tr><td width=\"40%\">E-mail</td>"; | |
3137 | print "<td><input class=\"editbox\" name=\"email\" | |
3138 | value=\"$email\"></td></tr>"; | |
3139 | ||
3140 | print "</table>"; | |
3141 | ||
3142 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3143 | ||
3144 | print "<p><input class=\"button\" type=\"submit\" | |
3145 | value=\"Change e-mail\" name=\"subop\">"; | |
3146 | ||
3147 | print "</form>"; | |
3148 | ||
3149 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3150 | ||
3151 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3152 | print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>"; | |
3153 | ||
3154 | print "<tr><td width=\"40%\">Old password</td>"; | |
3155 | print "<td><input class=\"editbox\" type=\"password\" | |
3156 | name=\"OLD_PASSWORD\"></td></tr>"; | |
3157 | ||
3158 | print "<tr><td width=\"40%\">New password</td>"; | |
3159 | ||
3160 | print "<td><input class=\"editbox\" type=\"password\" | |
3161 | name=\"NEW_PASSWORD\"></td></tr>"; | |
3162 | ||
3163 | print "</table>"; | |
3164 | ||
3165 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3166 | ||
3167 | print "<p><input class=\"button\" type=\"submit\" | |
3168 | value=\"Change password\" name=\"subop\">"; | |
3169 | ||
3170 | print "</form>"; | |
3171 | ||
3172 | } | |
3173 | ||
3174 | $result = db_query($link, "SELECT | |
3175 | theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]); | |
3176 | ||
3177 | $user_theme_id = db_fetch_result($result, 0, "theme_id"); | |
3178 | ||
3179 | $result = db_query($link, "SELECT | |
3180 | id,theme_name FROM ttrss_themes ORDER BY theme_name"); | |
3181 | ||
3182 | if (db_num_rows($result) > 0) { | |
3183 | ||
3184 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3185 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3186 | print "<tr><td colspan='3'><h3>Themes</h3></tr></td>"; | |
3187 | print "<tr><td width=\"40%\">Select theme</td>"; | |
3188 | print "<td><select name=\"theme\">"; | |
3189 | print "<option>Default</option>"; | |
3190 | print "<option disabled>--------</option>"; | |
3191 | ||
3192 | while ($line = db_fetch_assoc($result)) { | |
3193 | if ($line["id"] == $user_theme_id) { | |
3194 | $selected = "selected"; | |
3195 | } else { | |
3196 | $selected = ""; | |
3197 | } | |
3198 | print "<option $selected>" . $line["theme_name"] . "</option>"; | |
3199 | } | |
3200 | print "</select></td></tr>"; | |
3201 | print "</table>"; | |
3202 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3203 | print "<p><input class=\"button\" type=\"submit\" | |
3204 | value=\"Change theme\" name=\"subop\">"; | |
3205 | print "</form>"; | |
3206 | } | |
3207 | ||
3208 | $result = db_query($link, "SELECT | |
3209 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, | |
3210 | section_name,def_value | |
3211 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs | |
3212 | WHERE type_id = ttrss_prefs_types.id AND | |
3213 | section_id = ttrss_prefs_sections.id AND | |
3214 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND | |
3215 | owner_uid = ".$_SESSION["uid"]." | |
3216 | ORDER BY section_id,short_desc"); | |
3217 | ||
3218 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3219 | ||
3220 | $lnum = 0; | |
3221 | ||
3222 | $active_section = ""; | |
3223 | ||
3224 | while ($line = db_fetch_assoc($result)) { | |
3225 | ||
3226 | if ($active_section != $line["section_name"]) { | |
3227 | ||
3228 | if ($active_section != "") { | |
3229 | print "</table>"; | |
3230 | } | |
3231 | ||
3232 | print "<p><table width=\"100%\" class=\"prefPrefsList\">"; | |
3233 | ||
3234 | $active_section = $line["section_name"]; | |
3235 | ||
3236 | print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>"; | |
3237 | // print "<tr class=\"title\"> | |
3238 | // <td width=\"25%\">Option</td><td>Value</td></tr>"; | |
3239 | ||
3240 | $lnum = 0; | |
3241 | } | |
3242 | ||
3243 | // $class = ($lnum % 2) ? "even" : "odd"; | |
3244 | ||
3245 | print "<tr>"; | |
3246 | ||
3247 | $type_name = $line["type_name"]; | |
3248 | $pref_name = $line["pref_name"]; | |
3249 | $value = $line["value"]; | |
3250 | $def_value = $line["def_value"]; | |
3251 | $help_text = $line["help_text"]; | |
3252 | ||
3253 | print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"]; | |
3254 | ||
3255 | if ($help_text) print "<div class=\"prefHelp\">$help_text</div>"; | |
3256 | ||
3257 | print "</td>"; | |
3258 | ||
3259 | print "<td>"; | |
3260 | ||
3261 | if ($type_name == "bool") { | |
3262 | // print_select($pref_name, $value, array("true", "false")); | |
3263 | ||
3264 | if ($value == "true") { | |
3265 | $value = "Yes"; | |
3266 | } else { | |
3267 | $value = "No"; | |
3268 | } | |
3269 | ||
3270 | print_radio($pref_name, $value, array("Yes", "No")); | |
3271 | ||
3272 | } else { | |
3273 | print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">"; | |
3274 | } | |
3275 | ||
3276 | print "</td>"; | |
3277 | ||
3278 | print "</tr>"; | |
3279 | ||
3280 | $lnum++; | |
3281 | } | |
3282 | ||
3283 | print "</table>"; | |
3284 | ||
3285 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3286 | ||
3287 | print "<p><input class=\"button\" type=\"submit\" | |
3288 | name=\"subop\" value=\"Save configuration\">"; | |
3289 | ||
3290 | print " <input class=\"button\" type=\"submit\" | |
3291 | name=\"subop\" onclick=\"return validatePrefsReset()\" | |
3292 | value=\"Reset to defaults\"></p>"; | |
3293 | ||
3294 | print "</form>"; | |
3295 | ||
3296 | } | |
3297 | ||
3298 | } | |
3299 | ||
3300 | if ($op == "pref-users") { | |
3301 | ||
3302 | $subop = $_GET["subop"]; | |
3303 | ||
3304 | if ($subop == "editSave") { | |
3305 | ||
3306 | if (!WEB_DEMO_MODE) { | |
3307 | ||
3308 | $login = db_escape_string($_GET["l"]); | |
3309 | $uid = db_escape_string($_GET["id"]); | |
3310 | $access_level = sprintf("%d", $_GET["al"]); | |
3311 | $email = db_escape_string($_GET["e"]); | |
3312 | ||
3313 | db_query($link, "UPDATE ttrss_users SET login = '$login', | |
3314 | access_level = '$access_level', email = '$email' WHERE id = '$uid'"); | |
3315 | ||
3316 | } | |
3317 | } else if ($subop == "remove") { | |
3318 | ||
3319 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3320 | ||
3321 | $ids = split(",", db_escape_string($_GET["ids"])); | |
3322 | ||
3323 | foreach ($ids as $id) { | |
3324 | db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]); | |
3325 | ||
3326 | } | |
3327 | } | |
3328 | } else if ($subop == "add") { | |
3329 | ||
3330 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3331 | ||
3332 | $login = db_escape_string(trim($_GET["login"])); | |
3333 | $tmp_user_pwd = make_password(8); | |
3334 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3335 | ||
3336 | db_query($link, "INSERT INTO ttrss_users | |
3337 | (login,pwd_hash,access_level,last_login) | |
3338 | VALUES ('$login', '$pwd_hash', 0, NOW())"); | |
3339 | ||
3340 | ||
3341 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3342 | login = '$login' AND pwd_hash = '$pwd_hash'"); | |
3343 | ||
3344 | if (db_num_rows($result) == 1) { | |
3345 | ||
3346 | $new_uid = db_fetch_result($result, 0, "id"); | |
3347 | ||
3348 | print "<div class=\"notice\">Added user <b>".$_GET["login"]. | |
3349 | "</b> with password <b>$tmp_user_pwd</b>.</div>"; | |
3350 | ||
3351 | initialize_user($link, $new_uid); | |
3352 | ||
3353 | } else { | |
3354 | ||
3355 | print "<div class=\"warning\">Error while adding user <b>". | |
3356 | $_GET["login"].".</b></div>"; | |
3357 | ||
3358 | } | |
3359 | } | |
3360 | } else if ($subop == "resetPass") { | |
3361 | ||
3362 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3363 | ||
3364 | $uid = db_escape_string($_GET["id"]); | |
3365 | ||
3366 | $result = db_query($link, "SELECT login,email | |
3367 | FROM ttrss_users WHERE id = '$uid'"); | |
3368 | ||
3369 | $login = db_fetch_result($result, 0, "login"); | |
3370 | $email = db_fetch_result($result, 0, "email"); | |
3371 | $tmp_user_pwd = make_password(8); | |
3372 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3373 | ||
3374 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash' | |
3375 | WHERE id = '$uid'"); | |
3376 | ||
3377 | print "<div class=\"notice\">Changed password of | |
3378 | user <b>$login</b> to <b>$tmp_user_pwd</b>."; | |
3379 | ||
3380 | if (MAIL_RESET_PASS && $email) { | |
3381 | print " Notifying <b>$email</b>."; | |
3382 | ||
3383 | mail("$login <$email>", "Password reset notification", | |
3384 | "Hi, $login.\n". | |
3385 | "\n". | |
3386 | "Your password for this TT-RSS installation was reset by". | |
3387 | " an administrator.\n". | |
3388 | "\n". | |
3389 | "Your new password is $tmp_user_pwd, please remember". | |
3390 | " it for later reference.\n". | |
3391 | "\n". | |
3392 | "Sincerely, TT-RSS Mail Daemon.", "From: " . MAIL_FROM); | |
3393 | } | |
3394 | ||
3395 | print "</div>"; | |
3396 | ||
3397 | } | |
3398 | } | |
3399 | ||
3400 | print "<div class=\"prefGenericAddBox\"> | |
3401 | <input id=\"uadd_box\" onchange=\"javascript:addUser()\" size=\"40\"> "; | |
3402 | ||
3403 | print"<input type=\"submit\" class=\"button\" | |
3404 | onclick=\"javascript:addUser()\" value=\"Add user\"></div>"; | |
3405 | ||
3406 | $result = db_query($link, "SELECT | |
3407 | id,login,access_level,email, | |
3408 | SUBSTRING(last_login,1,16) as last_login | |
3409 | FROM | |
3410 | ttrss_users | |
3411 | ORDER by login"); | |
3412 | ||
3413 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; | |
3414 | ||
3415 | print "<p><table width=\"100%\" cellspacing=\"0\" | |
3416 | class=\"prefUserList\" id=\"prefUserList\">"; | |
3417 | ||
3418 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
3419 | Select: | |
3420 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', | |
3421 | 'UMRR-', 'UMCHK-', true)\">All</a>, | |
3422 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', | |
3423 | 'UMRR-', 'UMCHK-', false)\">None</a> | |
3424 | </td</tr>"; | |
3425 | ||
3426 | print "<tr class=\"title\"> | |
3427 | <td align='center' width=\"5%\"> </td> | |
3428 | <td width='20%'>Username</td> | |
3429 | <td width='20%'>E-mail</td> | |
3430 | <td width='20%'>Access Level</td> | |
3431 | <td width='20%'>Last login</td></tr>"; | |
3432 | ||
3433 | $lnum = 0; | |
3434 | ||
3435 | while ($line = db_fetch_assoc($result)) { | |
3436 | ||
3437 | $class = ($lnum % 2) ? "even" : "odd"; | |
3438 | ||
3439 | $uid = $line["id"]; | |
3440 | $edit_uid = $_GET["id"]; | |
3441 | ||
3442 | if ($subop == "edit" && $uid != $edit_uid) { | |
3443 | $class .= "Grayed"; | |
3444 | $this_row_id = ""; | |
3445 | } else { | |
3446 | $this_row_id = "id=\"UMRR-$uid\""; | |
3447 | } | |
3448 | ||
3449 | print "<tr class=\"$class\" $this_row_id>"; | |
3450 | ||
3451 | $line["login"] = htmlspecialchars($line["login"]); | |
3452 | ||
3453 | $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'), | |
3454 | strtotime($line["last_login"])); | |
3455 | ||
3456 | $access_level_names = array(0 => "User", 10 => "Administrator"); | |
3457 | ||
3458 | /* if ($uid == $_SESSION["uid"]) { | |
3459 | ||
3460 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" | |
3461 | id=\"UMCHK-".$line["id"]."\"></td>"; | |
3462 | ||
3463 | print "<td>".$line["login"]."</td>"; | |
3464 | print "<td>".$line["email"]."</td>"; | |
3465 | print "<td>".$line["access_level"]."</td>"; | |
3466 | ||
3467 | } else */ if (!$edit_uid || $subop != "edit") { | |
3468 | ||
3469 | print "<td align='center'><input onclick='toggleSelectRow(this);' | |
3470 | type=\"checkbox\" id=\"UMCHK-$uid\"></td>"; | |
3471 | ||
3472 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3473 | $line["login"] . "</td>"; | |
3474 | ||
3475 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3476 | $line["email"] . "</td>"; | |
3477 | ||
3478 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3479 | $access_level_names[$line["access_level"]] . "</td>"; | |
3480 | ||
3481 | } else if ($uid != $edit_uid) { | |
3482 | ||
3483 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" | |
3484 | id=\"UMCHK-".$line["id"]."\"></td>"; | |
3485 | ||
3486 | print "<td>".$line["login"]."</td>"; | |
3487 | print "<td>".$line["email"]."</td>"; | |
3488 | print "<td>".$access_level_names[$line["access_level"]]."</td>"; | |
3489 | ||
3490 | } else { | |
3491 | ||
3492 | print "<td align='center'> | |
3493 | <input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
3494 | ||
3495 | print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"]. | |
3496 | "\"></td>"; | |
3497 | ||
3498 | print "<td><input id=\"iedit_email\" value=\"".$line["email"]. | |
3499 | "\"></td>"; | |
3500 | ||
3501 | // print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"]. | |
3502 | // "\"></td>"; | |
3503 | ||
3504 | print "<td>"; | |
3505 | print "<select id=\"iedit_ulevel\">"; | |
3506 | foreach (array_keys($access_level_names) as $al) { | |
3507 | if ($al == $line["access_level"]) { | |
3508 | $selected = "selected"; | |
3509 | } else { | |
3510 | $selected = ""; | |
3511 | } | |
3512 | print "<option $selected id=\"$al\">" . | |
3513 | $access_level_names[$al] . "</option>"; | |
3514 | } | |
3515 | print "</select>"; | |
3516 | print "</td>"; | |
3517 | ||
3518 | } | |
3519 | ||
3520 | print "<td>".$line["last_login"]."</td>"; | |
3521 | ||
3522 | print "</tr>"; | |
3523 | ||
3524 | ++$lnum; | |
3525 | } | |
3526 | ||
3527 | print "</table>"; | |
3528 | ||
3529 | print "<p>"; | |
3530 | ||
3531 | if ($subop == "edit") { | |
3532 | print "Edit user: | |
3533 | <input type=\"submit\" class=\"button\" | |
3534 | onclick=\"javascript:userEditSave()\" value=\"Save\"> | |
3535 | <input type=\"submit\" class=\"button\" | |
3536 | onclick=\"javascript:userEditCancel()\" value=\"Cancel\">"; | |
3537 | ||
3538 | } else { | |
3539 | ||
3540 | print " | |
3541 | Selection: | |
3542 | <input type=\"submit\" class=\"button\" | |
3543 | onclick=\"javascript:selectedUserDetails()\" value=\"User details\"> | |
3544 | <input type=\"submit\" class=\"button\" | |
3545 | onclick=\"javascript:editSelectedUser()\" value=\"Edit\"> | |
3546 | <input type=\"submit\" class=\"button\" | |
3547 | onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\"> | |
3548 | <input type=\"submit\" class=\"button\" | |
3549 | onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">"; | |
3550 | ||
3551 | } | |
3552 | } | |
3553 | ||
3554 | if ($op == "user-details") { | |
3555 | ||
3556 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { | |
3557 | return; | |
3558 | } | |
3559 | ||
3560 | /* print "<html><head> | |
3561 | <title>Tiny Tiny RSS : User Details</title> | |
3562 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
3563 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
3564 | </head><body>"; */ | |
3565 | ||
3566 | $uid = sprintf("%d", $_GET["id"]); | |
3567 | ||
3568 | print "<div class='infoBoxContents'>"; | |
3569 | ||
3570 | $result = db_query($link, "SELECT login, | |
3571 | SUBSTRING(last_login,1,16) AS last_login, | |
3572 | access_level, | |
3573 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3574 | WHERE owner_uid = id) AS stored_articles | |
3575 | FROM ttrss_users | |
3576 | WHERE id = '$uid'"); | |
3577 | ||
3578 | if (db_num_rows($result) == 0) { | |
3579 | print "<h1>User not found</h1>"; | |
3580 | return; | |
3581 | } | |
3582 | ||
3583 | print "<h1>User Details</h1>"; | |
3584 | ||
3585 | print "<table width='100%'>"; | |
3586 | ||
3587 | $login = db_fetch_result($result, 0, "login"); | |
3588 | $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
3589 | strtotime(db_fetch_result($result, 0, "last_login"))); | |
3590 | $access_level = db_fetch_result($result, 0, "access_level"); | |
3591 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); | |
3592 | ||
3593 | print "<tr><td>Username</td><td>$login</td></tr>"; | |
3594 | print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
3595 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
3596 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; | |
3597 | ||
3598 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds | |
3599 | WHERE owner_uid = '$uid'"); | |
3600 | ||
3601 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
3602 | ||
3603 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; | |
3604 | ||
3605 | /* $result = db_query($link, "SELECT | |
3606 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size | |
3607 | FROM ttrss_user_entries,ttrss_entries | |
3608 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
3609 | ||
3610 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); | |
3611 | ||
3612 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ | |
3613 | ||
3614 | print "</table>"; | |
3615 | ||
3616 | print "<h1>Subscribed feeds</h1>"; | |
3617 | ||
3618 | $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds | |
3619 | WHERE owner_uid = '$uid' ORDER BY title"); | |
3620 | ||
3621 | print "<ul class=\"userFeedList\">"; | |
3622 | ||
3623 | while ($line = db_fetch_assoc($result)) { | |
3624 | ||
3625 | $icon_file = ICONS_URL."/".$line["id"].".ico"; | |
3626 | ||
3627 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
3628 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; | |
3629 | } else { | |
3630 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
3631 | } | |
3632 | ||
3633 | print "<li>$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>"; | |
3634 | } | |
3635 | ||
3636 | if (db_num_rows($result) < $num_feeds) { | |
3637 | // FIXME - add link to show ALL subscribed feeds here somewhere | |
3638 | print "<li><img | |
3639 | class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>"; | |
3640 | } | |
3641 | ||
3642 | print "</ul>"; | |
3643 | ||
3644 | print "</div>"; | |
3645 | ||
3646 | print "<div align='center'> | |
3647 | <input type='submit' class='button' | |
3648 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
3649 | ||
3650 | // print "</body></html>"; | |
3651 | ||
3652 | } | |
3653 | ||
3654 | if ($op == "feed-details") { | |
3655 | ||
3656 | // $feed_id = $_GET["id"]; | |
3657 | ||
3658 | $feed_ids = split(",", db_escape_string($_GET["id"])); | |
3659 | ||
3660 | print "<div class=\"infoBoxContents\">"; | |
3661 | ||
3662 | foreach ($feed_ids as $feed_id) { | |
3663 | ||
3664 | $result = db_query($link, | |
3665 | "SELECT | |
3666 | title,feed_url, | |
3667 | SUBSTRING(last_updated,1,16) as last_updated, | |
3668 | icon_url,site_url, | |
3669 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3670 | WHERE feed_id = id) AS total, | |
3671 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3672 | WHERE feed_id = id AND unread = true) AS unread, | |
3673 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3674 | WHERE feed_id = id AND marked = true) AS marked | |
3675 | FROM ttrss_feeds | |
3676 | WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]); | |
3677 | ||
3678 | if (db_num_rows($result) == 0) return; | |
3679 | ||
3680 | $title = db_unescape_string(db_fetch_result($result, 0, "title")); | |
3681 | $last_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
3682 | strtotime(db_fetch_result($result, 0, "last_updated"))); | |
3683 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
3684 | $icon_url = db_fetch_result($result, 0, "icon_url"); | |
3685 | $total = db_fetch_result($result, 0, "total"); | |
3686 | $unread = db_fetch_result($result, 0, "unread"); | |
3687 | $marked = db_fetch_result($result, 0, "marked"); | |
3688 | $site_url = db_fetch_result($result, 0, "site_url"); | |
3689 | ||
3690 | $result = db_query($link, "SELECT COUNT(id) AS subscribed | |
3691 | FROM ttrss_feeds WHERE feed_url = '$feed_url' AND private = false"); | |
3692 | ||
3693 | $subscribed = db_fetch_result($result, 0, "subscribed"); | |
3694 | ||
3695 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
3696 | ||
3697 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
3698 | $feed_icon = "<img width=\"16\" height=\"16\" | |
3699 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
3700 | } else { | |
3701 | $feed_icon = ""; | |
3702 | } | |
3703 | ||
3704 | print "<h1>$feed_icon $title</h1>"; | |
3705 | ||
3706 | print "<table width='100%'>"; | |
3707 | ||
3708 | if ($site_url) { | |
3709 | print "<tr><td width='30%'>Link</td> | |
3710 | <td><a href=\"$site_url\">$site_url</a> | |
3711 | <a href=\"$feed_url\">(feed)</a></td> | |
3712 | </td></tr>"; | |
3713 | } else { | |
3714 | print "<tr><td width='30%'>Feed URL</td> | |
3715 | <td><a href=\"$feed_url\">$feed_url</a></td></tr>"; | |
3716 | } | |
3717 | print "<tr><td>Last updated</td><td>$last_updated</td></tr>"; | |
3718 | print "<tr><td>Total articles</td><td>$total</td></tr>"; | |
3719 | print "<tr><td>Unread articles</td><td>$unread</td></tr>"; | |
3720 | print "<tr><td>Starred articles</td><td>$marked</td></tr>"; | |
3721 | print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>"; | |
3722 | ||
3723 | print "</table>"; | |
3724 | ||
3725 | /* $result = db_query($link, "SELECT title, | |
3726 | SUBSTRING(updated,1,16) AS updated,unread | |
3727 | FROM ttrss_entries,ttrss_user_entries | |
3728 | WHERE ref_id = id AND feed_id = '$feed_id' | |
3729 | ORDER BY date_entered DESC LIMIT 5"); | |
3730 | ||
3731 | if (db_num_rows($result) > 0) { | |
3732 | ||
3733 | print "<h1>Latest headlines</h1>"; | |
3734 | ||
3735 | print "<ul class=\"nomarks\">"; | |
3736 | ||
3737 | while ($line = db_fetch_assoc($result)) { | |
3738 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
3739 | $line["title"] = "<b>" . $line["title"] . "</b>"; | |
3740 | } | |
3741 | print "<li>" . $line["title"]. | |
3742 | " <span class=\"insensitive\">(" . | |
3743 | date(get_pref($link, 'SHORT_DATE_FORMAT'), | |
3744 | strtotime($line["updated"])). | |
3745 | ")</span></li>"; | |
3746 | } | |
3747 | ||
3748 | print "</ul>"; | |
3749 | ||
3750 | } */ | |
3751 | } | |
3752 | ||
3753 | print "</div>"; | |
3754 | ||
3755 | print "<div align='center'> | |
3756 | <input type='submit' class='button' | |
3757 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
3758 | } | |
3759 | ||
3760 | if ($op == "pref-feed-browser") { | |
3761 | ||
3762 | if (!ENABLE_FEED_BROWSER) { | |
3763 | print "Feed browser is administratively disabled."; | |
3764 | return; | |
3765 | } | |
3766 | ||
3767 | $subop = $_REQUEST["subop"]; | |
3768 | ||
3769 | if ($subop == "details") { | |
3770 | $id = db_escape_string($_GET["id"]); | |
3771 | ||
3772 | print "<div class=\"browserFeedInfo\">"; | |
3773 | print "<b>Feed information:</b>"; | |
3774 | print "<div class=\"detailsPart\">"; | |
3775 | ||
3776 | $result = db_query($link, "SELECT | |
3777 | feed_url,site_url, | |
3778 | SUBSTRING(last_updated,1,19) AS last_updated | |
3779 | FROM ttrss_feeds WHERE id = '$id'"); | |
3780 | ||
3781 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
3782 | $site_url = db_fetch_result($result, 0, "site_url"); | |
3783 | $last_updated = db_fetch_result($result, 0, "last_updated"); | |
3784 | ||
3785 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
3786 | $last_updated = smart_date_time(strtotime($last_updated)); | |
3787 | } else { | |
3788 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
3789 | $last_updated = date($short_date, strtotime($last_updated)); | |
3790 | } | |
3791 | ||
3792 | print "Site: <a href='$site_url'>$site_url</a> ". | |
3793 | "(<a href='$feed_url'>feed</a>), ". | |
3794 | "Last updated: $last_updated"; | |
3795 | ||
3796 | print "</div>"; | |
3797 | ||
3798 | $result = db_query($link, "SELECT | |
3799 | ttrss_entries.title, | |
3800 | content, | |
3801 | substring(date_entered,1,19) as date_entered, | |
3802 | substring(updated,1,19) as updated | |
3803 | FROM ttrss_entries,ttrss_user_entries | |
3804 | WHERE ttrss_entries.id = ref_id AND feed_id = '$id' | |
3805 | ORDER BY updated DESC LIMIT 5"); | |
3806 | ||
3807 | if (db_num_rows($result) > 0) { | |
3808 | ||
3809 | print "<b>Last headlines:</b><br>"; | |
3810 | ||
3811 | print "<div class=\"detailsPart\">"; | |
3812 | print "<ul class=\"compact\">"; | |
3813 | while ($line = db_fetch_assoc($result)) { | |
3814 | ||
3815 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
3816 | $entry_dt = smart_date_time(strtotime($line["updated"])); | |
3817 | } else { | |
3818 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
3819 | $entry_dt = date($short_date, strtotime($line["updated"])); | |
3820 | } | |
3821 | ||
3822 | print "<li>" . $line["title"] . | |
3823 | " <span class=\"insensitive\">($entry_dt)</span></li>"; | |
3824 | } | |
3825 | print "</ul></div>"; | |
3826 | } | |
3827 | ||
3828 | print "</div>"; | |
3829 | ||
3830 | return; | |
3831 | } | |
3832 | ||
3833 | $result = db_query($link, "SELECT feed_url,count(id) AS subscribers | |
3834 | FROM ttrss_feeds | |
3835 | WHERE auth_login = '' AND auth_pass = '' AND private = false | |
3836 | GROUP BY feed_url ORDER BY subscribers DESC LIMIT 100"); | |
3837 | ||
3838 | print "<ul class='nomarks' id='browseBigFeedList'>"; | |
3839 | ||
3840 | $feedctr = 0; | |
3841 | ||
3842 | while ($line = db_fetch_assoc($result)) { | |
3843 | $feed_url = $line["feed_url"]; | |
3844 | $subscribers = $line["subscribers"]; | |
3845 | ||
3846 | $sub_result = db_query($link, "SELECT id | |
3847 | FROM ttrss_feeds WHERE feed_url = '$feed_url' AND owner_uid =" . | |
3848 | $_SESSION["uid"]); | |
3849 | ||
3850 | if (db_num_rows($sub_result) > 0) { | |
3851 | continue; // already subscribed | |
3852 | } | |
3853 | ||
3854 | $det_result = db_query($link, "SELECT site_url,title,id | |
3855 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
3856 | ||
3857 | $details = db_fetch_assoc($det_result); | |
3858 | ||
3859 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
3860 | ||
3861 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
3862 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
3863 | "/".$details["id"].".ico\">"; | |
3864 | } else { | |
3865 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
3866 | } | |
3867 | ||
3868 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' | |
3869 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
3870 | ||
3871 | $class = ($feedctr % 2) ? "even" : "odd"; | |
3872 | ||
3873 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
3874 | "$feed_icon "; | |
3875 | ||
3876 | print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" . | |
3877 | $details["title"] ."</a> " . | |
3878 | "<span class='subscribers'>($subscribers)</span>"; | |
3879 | ||
3880 | print "<div class=\"browserDetails\" id=\"BRDET-" . $details["id"] . "\">"; | |
3881 | print "</div>"; | |
3882 | ||
3883 | print "</li>"; | |
3884 | ||
3885 | ++$feedctr; | |
3886 | } | |
3887 | ||
3888 | if ($feedctr == 0) { | |
3889 | print "<li>No feeds found to subscribe.</li>"; | |
3890 | } | |
3891 | ||
3892 | print "</ul>"; | |
3893 | ||
3894 | print "<p>Selection: | |
3895 | <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\" | |
3896 | value=\"Subscribe\"></p>"; | |
3897 | ||
3898 | print "</div>"; | |
3899 | ||
3900 | } | |
3901 | ||
3902 | function check_configuration_variables() { | |
3903 | if (!defined('SESSION_EXPIRE_TIME')) { | |
3904 | return "config: SESSION_EXPIRE_TIME is undefined"; | |
3905 | } | |
3906 | ||
3907 | if (SESSION_EXPIRE_TIME < 60) { | |
3908 | return "config: SESSION_EXPIRE_TIME is too low (less than 60)"; | |
3909 | } | |
3910 | ||
3911 | if (SESSION_EXPIRE_TIME < SESSION_COOKIE_LIFETIME_REMEMBER) { | |
3912 | return "config: SESSION_EXPIRE_TIME should be greater or equal to" . | |
3913 | "SESSION_COOKIE_LIFETIME_REMEMBER"; | |
3914 | } | |
3915 | ||
3916 | if (defined('DISABLE_SESSIONS') && DISABLE_SESSIONS) { | |
3917 | return "config: you have enabled DISABLE_SESSIONS. Please disable this option."; | |
3918 | } | |
3919 | ||
3920 | if (DATABASE_BACKED_SESSIONS && SINGLE_USER_MODE) { | |
3921 | return "config: DATABASE_BACKED_SESSIONS is incompatible with SINGLE_USER_MODE"; | |
3922 | } | |
3923 | ||
3924 | return false; | |
3925 | } | |
3926 | ||
3927 | db_close($link); | |
3928 | ?> | |
3929 | ||
3930 | <!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> | |
3931 |