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