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