]>
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 | ||
2e915ba9 AD |
724 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
725 | ||
726 | $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds | |
727 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
70f6dbb1 | 728 | |
2e915ba9 AD |
729 | if (db_num_rows($result) == 1) { |
730 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
731 | } else { | |
732 | $rtl_content = false; | |
733 | } | |
734 | ||
735 | if ($rtl_content) { | |
736 | $rtl_tag = "dir=\"RTL\""; | |
737 | } else { | |
738 | $rtl_tag = ""; | |
739 | } | |
70f6dbb1 AD |
740 | } else { |
741 | $rtl_tag = ""; | |
2e915ba9 | 742 | $rtl_content = false; |
70f6dbb1 AD |
743 | } |
744 | ||
8911ac8b AD |
745 | $script_dt_add = get_script_dt_add(); |
746 | ||
59b8192f | 747 | print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
86b682ce | 748 | <script type=\"text/javascript\" src=\"prototype.js\"></script> |
53515ff1 AD |
749 | <script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> |
750 | <script type=\"text/javascript\" src=\"viewfeed.js?$script_dt_add\"></script> | |
59b8192f AD |
751 | <!--[if gte IE 5.5000]> |
752 | <script type=\"text/javascript\" src=\"pngfix.js\"></script> | |
753 | <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss-ie.css\"> | |
754 | <![endif]--> | |
10031c3b | 755 | </head><body $rtl_tag> |
59b8192f AD |
756 | <script type=\"text/javascript\"> |
757 | if (document.addEventListener) { | |
758 | document.addEventListener(\"DOMContentLoaded\", init, null); | |
759 | } | |
760 | window.onload = init; | |
761 | </script>"; | |
762 | ||
86b682ce AD |
763 | $search = db_escape_string($_GET["query"]); |
764 | $search_mode = db_escape_string($_GET["search_mode"]); | |
765 | $match_on = db_escape_string($_GET["match_on"]); | |
52b51244 | 766 | |
86b682ce AD |
767 | if (!$match_on) { |
768 | $match_on = "both"; | |
769 | } | |
770 | ||
f175937c | 771 | if ($search) { |
86b682ce AD |
772 | if ($match_on == "both") { |
773 | $search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%') | |
774 | OR upper(ttrss_entries.content) LIKE '%$search%') AND"; | |
775 | } else if ($match_on == "title") { | |
776 | $search_query_part = "upper(ttrss_entries.title) LIKE upper('%$search%') | |
777 | AND"; | |
778 | } else if ($match_on == "content") { | |
779 | $search_query_part = "upper(ttrss_entries.content) LIKE upper('%$search%') AND"; | |
780 | } | |
f175937c AD |
781 | } else { |
782 | $search_query_part = ""; | |
783 | } | |
784 | ||
785 | $view_query_part = ""; | |
786 | ||
86b682ce | 787 | if ($view_mode == "adaptive") { |
f18d0d94 AD |
788 | if ($search) { |
789 | $view_query_part = " "; | |
790 | } else if ($feed != -1) { | |
0ee2d12f AD |
791 | $unread = getFeedUnread($link, $feed); |
792 | if ($unread > 0) { | |
793 | $view_query_part = " unread = true AND "; | |
794 | } | |
795 | } | |
796 | } | |
797 | ||
86b682ce | 798 | if ($view_mode == "marked") { |
f175937c | 799 | $view_query_part = " marked = true AND "; |
ac53063a AD |
800 | } |
801 | ||
86b682ce | 802 | if ($view_mode == "unread") { |
ac43eba1 AD |
803 | $view_query_part = " unread = true AND "; |
804 | } | |
805 | ||
86b682ce | 806 | if ($limit > 0) { |
82c9223c | 807 | $limit_query_part = "LIMIT " . $limit; |
ad3cb710 | 808 | } |
f0601b87 | 809 | |
254e0e4b AD |
810 | $vfeed_query_part = ""; |
811 | ||
52b51244 | 812 | // override query strategy and enable feed display when searching globally |
86b682ce | 813 | if ($search && $search_mode == "all_feeds") { |
8e84993b | 814 | $query_strategy_part = "ttrss_entries.id > 0"; |
b0005823 | 815 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
d0bb308e | 816 | } else if (preg_match("/^-?[0-9][0-9]*$/", $feed) == false) { |
8143ae1f AD |
817 | $query_strategy_part = "ttrss_entries.id > 0"; |
818 | $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE | |
819 | id = feed_id) as feed_title,"; | |
86b682ce | 820 | } else if ($feed >= 0 && $search && $search_mode == "this_cat") { |
b0005823 AD |
821 | |
822 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
823 | ||
824 | $tmp_result = db_query($link, "SELECT id | |
825 | FROM ttrss_feeds WHERE cat_id = | |
826 | (SELECT cat_id FROM ttrss_feeds WHERE id = '$feed') AND id != '$feed'"); | |
827 | ||
828 | $cat_siblings = array(); | |
829 | ||
830 | if (db_num_rows($tmp_result) > 0) { | |
831 | while ($p = db_fetch_assoc($tmp_result)) { | |
832 | array_push($cat_siblings, "feed_id = " . $p["id"]); | |
833 | } | |
834 | ||
835 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
836 | $feed, implode(" OR ", $cat_siblings)); | |
837 | ||
838 | } else { | |
839 | $query_strategy_part = "ttrss_entries.id > 0"; | |
840 | } | |
ff2c6e6a | 841 | |
8143ae1f | 842 | } else if ($feed >= 0) { |
60103089 | 843 | |
ff2c6e6a | 844 | if ($cat_view) { |
b0005823 | 845 | |
99ff73f4 AD |
846 | if ($feed > 0) { |
847 | $query_strategy_part = "cat_id = '$feed'"; | |
848 | } else { | |
849 | $query_strategy_part = "cat_id IS NULL"; | |
850 | } | |
851 | ||
60103089 | 852 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
ff2c6e6a AD |
853 | |
854 | } else { | |
855 | $tmp_result = db_query($link, "SELECT id | |
856 | FROM ttrss_feeds WHERE parent_feed = '$feed' | |
857 | ORDER BY cat_id,title"); | |
858 | ||
859 | $parent_ids = array(); | |
860 | ||
861 | if (db_num_rows($tmp_result) > 0) { | |
862 | while ($p = db_fetch_assoc($tmp_result)) { | |
863 | array_push($parent_ids, "feed_id = " . $p["id"]); | |
864 | } | |
865 | ||
866 | $query_strategy_part = sprintf("(feed_id = %d OR %s)", | |
867 | $feed, implode(" OR ", $parent_ids)); | |
868 | ||
869 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; | |
870 | } else { | |
871 | $query_strategy_part = "feed_id = '$feed'"; | |
872 | } | |
60103089 | 873 | } |
48f0adb0 | 874 | } else if ($feed == -1) { // starred virtual feed |
254e0e4b | 875 | $query_strategy_part = "marked = true"; |
60103089 | 876 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
48f0adb0 AD |
877 | } else if ($feed <= -10) { // labels |
878 | $label_id = -$feed - 11; | |
879 | ||
880 | $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels | |
881 | WHERE id = '$label_id'"); | |
882 | ||
883 | $query_strategy_part = db_fetch_result($tmp_result, 0, "sql_exp"); | |
884 | ||
60103089 | 885 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
254e0e4b | 886 | } else { |
48f0adb0 | 887 | $query_strategy_part = "id > 0"; // dumb |
254e0e4b AD |
888 | } |
889 | ||
f99321a3 AD |
890 | $order_by = "updated DESC"; |
891 | ||
892 | // if ($feed < -10) { | |
893 | // $order_by = "feed_id,updated DESC"; | |
894 | // } | |
895 | ||
1572afe5 AD |
896 | $feed_title = ""; |
897 | ||
86b682ce | 898 | if ($search && $search_mode == "all_feeds") { |
49b7cbd3 | 899 | $feed_title = "Global search results ($search)"; |
d0bb308e | 900 | } else if ($search && preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { |
49b7cbd3 | 901 | $feed_title = "Feed search results ($search, $feed)"; |
d0bb308e AD |
902 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) == false) { |
903 | $feed_title = $feed; | |
904 | } else if (preg_match('/^-?[0-9][0-9]*$/', $feed) != false && $feed >= 0) { | |
1572afe5 | 905 | |
ff2c6e6a | 906 | if ($cat_view) { |
ff2c6e6a | 907 | |
019ce9f3 AD |
908 | if ($feed != 0) { |
909 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
910 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
911 | $feed_title = db_fetch_result($result, 0, "title"); | |
912 | } else { | |
913 | $feed_title = "Uncategorized"; | |
914 | } | |
ff2c6e6a AD |
915 | } else { |
916 | ||
917 | $result = db_query($link, "SELECT title,site_url,last_error FROM ttrss_feeds | |
918 | WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); | |
919 | ||
920 | $feed_title = db_fetch_result($result, 0, "title"); | |
921 | $feed_site_url = db_fetch_result($result, 0, "site_url"); | |
922 | $last_error = db_fetch_result($result, 0, "last_error"); | |
923 | ||
924 | } | |
1572afe5 AD |
925 | |
926 | } else if ($feed == -1) { | |
927 | $feed_title = "Starred articles"; | |
928 | } else if ($feed < -10) { | |
929 | $label_id = -$feed - 11; | |
930 | $result = db_query($link, "SELECT description FROM ttrss_labels | |
931 | WHERE id = '$label_id'"); | |
932 | $feed_title = db_fetch_result($result, 0, "description"); | |
933 | } else { | |
934 | $feed_title = "?"; | |
935 | } | |
936 | ||
3fdaa067 AD |
937 | $feed_title = db_unescape_string($feed_title); |
938 | ||
48f0adb0 AD |
939 | if ($feed < -10) error_reporting (0); |
940 | ||
386cbf27 AD |
941 | print "<div id=\"headlinesContainer\">"; |
942 | ||
d0bb308e | 943 | if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { |
8143ae1f | 944 | |
99ff73f4 | 945 | if ($feed >= 0) { |
21703604 AD |
946 | $feed_kind = "Feeds"; |
947 | } else { | |
948 | $feed_kind = "Labels"; | |
949 | } | |
950 | ||
386cbf27 AD |
951 | // if (!$vfeed_query_part) { |
952 | $content_query_part = "content as content_preview,"; | |
953 | // } else { | |
954 | // $content_query_part = ""; | |
955 | // } | |
bd34c528 | 956 | |
894ebcf5 | 957 | $query = "SELECT |
60103089 | 958 | ttrss_entries.id,ttrss_entries.title, |
1572afe5 AD |
959 | SUBSTRING(updated,1,16) as updated, |
960 | unread,feed_id,marked,link,last_read, | |
8143ae1f AD |
961 | SUBSTRING(last_read,1,19) as last_read_noms, |
962 | $vfeed_query_part | |
bd34c528 AD |
963 | $content_query_part |
964 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 965 | FROM |
60103089 | 966 | ttrss_entries,ttrss_user_entries,ttrss_feeds |
8143ae1f | 967 | WHERE |
60103089 | 968 | ttrss_user_entries.feed_id = ttrss_feeds.id AND |
4c193675 | 969 | ttrss_user_entries.ref_id = ttrss_entries.id AND |
60103089 | 970 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND |
8143ae1f AD |
971 | $search_query_part |
972 | $view_query_part | |
973 | $query_strategy_part ORDER BY $order_by | |
894ebcf5 AD |
974 | $limit_query_part"; |
975 | ||
976 | $result = db_query($link, $query); | |
977 | ||
978 | if ($_GET["debug"]) print $query; | |
8143ae1f AD |
979 | |
980 | } else { | |
981 | // browsing by tag | |
982 | ||
21703604 AD |
983 | $feed_kind = "Tags"; |
984 | ||
8143ae1f | 985 | $result = db_query($link, "SELECT |
1572afe5 AD |
986 | ttrss_entries.id as id,title, |
987 | SUBSTRING(updated,1,16) as updated, | |
988 | unread,feed_id, | |
1e471f3b | 989 | marked,link,last_read, |
c05a19f3 | 990 | SUBSTRING(last_read,1,19) as last_read_noms, |
254e0e4b | 991 | $vfeed_query_part |
bd34c528 AD |
992 | $content_query_part |
993 | SUBSTRING(updated,1,19) as updated_noms | |
8143ae1f | 994 | FROM |
05732aa0 | 995 | ttrss_entries,ttrss_user_entries,ttrss_tags |
8143ae1f | 996 | WHERE |
05732aa0 AD |
997 | ref_id = ttrss_entries.id AND |
998 | ttrss_user_entries.owner_uid = '".$_SESSION["uid"]."' AND | |
999 | post_int_id = int_id AND tag_name = '$feed' AND | |
8143ae1f AD |
1000 | $view_query_part |
1001 | $search_query_part | |
1002 | $query_strategy_part ORDER BY $order_by | |
1003 | $limit_query_part"); | |
1004 | } | |
d76a3b03 | 1005 | |
48f0adb0 | 1006 | if (!$result) { |
386cbf27 AD |
1007 | print "<div align='center'> |
1008 | Could not display feed (query failed). Please check label match syntax or local configuration.</div>"; | |
1009 | return; | |
adccd201 | 1010 | } |
98bea1b1 | 1011 | |
e0a7121b | 1012 | function print_headline_subtoolbar($link, $feed_site_url, $feed_title, |
c1c9df00 | 1013 | $bottom = false, $rtl_content = false) { |
f56ec297 | 1014 | |
e0a7121b AD |
1015 | if (!$bottom) { |
1016 | $class = "headlinesSubToolbar"; | |
1017 | $tid = "headlineActionsTop"; | |
1018 | } else { | |
1019 | $class = "invisible"; | |
1020 | $tid = "headlineActionsBottom"; | |
1021 | } | |
1022 | ||
1023 | print "<table class=\"$class\" id=\"$tid\" | |
386cbf27 AD |
1024 | width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>"; |
1025 | ||
c1c9df00 AD |
1026 | if ($rtl_content) { |
1027 | $rtl_cpart = "RTL"; | |
1028 | } else { | |
1029 | $rtl_cpart = ""; | |
1030 | } | |
1031 | ||
386cbf27 | 1032 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 1033 | |
c1c9df00 | 1034 | print "<td class=\"headlineActions$rtl_cpart\"> |
adccd201 | 1035 | Select: |
e7811ea5 AD |
1036 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, '', true)\">All</a>, |
1037 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true)\">Unread</a>, | |
1038 | <a href='#' onclick=\"javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false)\">None</a> | |
386cbf27 | 1039 | |
e7811ea5 AD |
1040 | Toggle: <a href='#' onclick=\"javascript:selectionToggleUnread()\">Unread</a>, |
1041 | <a href='#' onclick=\"javascript:selectionToggleMarked()\">Starred</a>"; | |
adccd201 | 1042 | print "</td>"; |
386cbf27 AD |
1043 | |
1044 | } else { | |
1045 | ||
c1c9df00 | 1046 | print "<td class=\"headlineActions$rtl_cpart\"> |
386cbf27 | 1047 | Select: |
e7811ea5 AD |
1048 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('all')\">All</a>, |
1049 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('unread')\">Unread</a>, | |
1050 | <a href=\"#\" onclick=\"javascript:cdmSelectArticles('none')\">None</a> | |
386cbf27 | 1051 | |
e7811ea5 AD |
1052 | Toggle: <a href=\"#\" onclick=\"javascript:selectionToggleUnread(true)\">Unread</a>, |
1053 | <a href=\"#\" onclick=\"javascript:selectionToggleMarked(true)\">Starred</a>"; | |
386cbf27 | 1054 | |
adccd201 | 1055 | print "</td>"; |
386cbf27 | 1056 | |
386cbf27 AD |
1057 | } |
1058 | ||
c1c9df00 | 1059 | print "<td class=\"headlineTitle$rtl_cpart\">"; |
adccd201 | 1060 | |
386cbf27 | 1061 | if ($feed_site_url) { |
c7a8abe6 AD |
1062 | if (!$bottom) { |
1063 | $target = "target=\"_blank\""; | |
1064 | } | |
1065 | print "<a $target href=\"$feed_site_url\">$feed_title</a>"; | |
386cbf27 AD |
1066 | } else { |
1067 | print $feed_title; | |
1068 | } | |
1069 | ||
1070 | print "</td>"; | |
1071 | print "</tr></table>"; | |
1072 | ||
98bea1b1 AD |
1073 | } |
1074 | ||
1075 | if (db_num_rows($result) > 0) { | |
1076 | ||
c1c9df00 AD |
1077 | print_headline_subtoolbar($link, $feed_site_url, $feed_title, false, |
1078 | $rtl_content); | |
98bea1b1 | 1079 | |
386cbf27 | 1080 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 1081 | print "<table class=\"headlinesList\" id=\"headlinesList\" |
10031c3b | 1082 | cellspacing=\"0\" width=\"100%\">"; |
f4c10d44 | 1083 | } |
386cbf27 | 1084 | |
e5a99b88 AD |
1085 | $lnum = 0; |
1086 | ||
1087 | error_reporting (DEFAULT_ERROR_LEVEL); | |
1088 | ||
1089 | $num_unread = 0; | |
1090 | ||
1091 | while ($line = db_fetch_assoc($result)) { | |
adccd201 | 1092 | |
e5a99b88 AD |
1093 | $class = ($lnum % 2) ? "even" : "odd"; |
1094 | ||
1095 | $id = $line["id"]; | |
1096 | $feed_id = $line["feed_id"]; | |
1097 | ||
1098 | if ($line["last_read"] == "" && | |
1099 | ($line["unread"] != "t" && $line["unread"] != "1")) { | |
1100 | ||
1101 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/updated.png\" | |
1102 | alt=\"Updated\">"; | |
1103 | } else { | |
1104 | $update_pic = "<img id='FUPDPIC-$id' src=\"images/blank_icon.gif\" | |
1105 | alt=\"Updated\">"; | |
1106 | } | |
1107 | ||
1108 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
1109 | $class .= "Unread"; | |
1110 | ++$num_unread; | |
386cbf27 | 1111 | $is_unread = true; |
adccd201 | 1112 | } else { |
386cbf27 | 1113 | $is_unread = false; |
e5a99b88 AD |
1114 | } |
1115 | ||
1116 | if ($line["marked"] == "t" || $line["marked"] == "1") { | |
1117 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" | |
9932fb06 | 1118 | alt=\"Reset mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
1119 | } else { |
1120 | $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" | |
9932fb06 | 1121 | alt=\"Set mark\" onclick='javascript:toggleMark($id)'>"; |
e5a99b88 AD |
1122 | } |
1123 | ||
e454a889 | 1124 | $content_link = "<a href=\"javascript:view($id,$feed_id);\">" . |
e5a99b88 | 1125 | $line["title"] . "</a>"; |
adccd201 | 1126 | |
e5a99b88 AD |
1127 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
1128 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
1129 | } else { | |
1130 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1131 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
1132 | } | |
adccd201 AD |
1133 | |
1134 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { | |
8fd0c717 | 1135 | $content_preview = truncate_string(strip_tags($line["content_preview"]), |
070d0d2a | 1136 | 100); |
adccd201 AD |
1137 | } |
1138 | ||
386cbf27 | 1139 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 AD |
1140 | |
1141 | print "<tr class='$class' id='RROW-$id'>"; | |
adccd201 AD |
1142 | |
1143 | print "<td class='hlUpdatePic'>$update_pic</td>"; | |
1144 | ||
1145 | print "<td class='hlSelectRow'> | |
1146 | <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\" | |
1147 | class=\"feedCheckBox\" id=\"RCHK-$id\"> | |
1148 | </td>"; | |
1149 | ||
1150 | print "<td class='hlMarkedPic'>$marked_pic</td>"; | |
1151 | ||
1152 | if ($line["feed_title"]) { | |
1153 | print "<td class='hlContent'>$content_link</td>"; | |
1154 | print "<td class='hlFeed'> | |
9b1424fe AD |
1155 | <a href='javascript:viewfeed($feed_id)'>". |
1156 | $line["feed_title"]."</a> </td>"; | |
adccd201 | 1157 | } else { |
de244d27 | 1158 | print "<td class='hlContent' valign='middle'>"; |
adccd201 | 1159 | |
e454a889 | 1160 | print "<a href=\"javascript:view($id,$feed_id);\">" . |
adccd201 AD |
1161 | $line["title"]; |
1162 | ||
70f6dbb1 | 1163 | if (get_pref($link, 'SHOW_CONTENT_PREVIEW') && !$rtl_tag) { |
adccd201 AD |
1164 | if ($content_preview) { |
1165 | print "<span class=\"contentPreview\"> - $content_preview</span>"; | |
1166 | } | |
1167 | } | |
1168 | ||
1169 | print "</a>"; | |
1170 | print "</td>"; | |
1171 | } | |
1172 | ||
1173 | print "<td class=\"hlUpdated\"><nobr>$updated_fmt </nobr></td>"; | |
1174 | ||
1175 | print "</tr>"; | |
1176 | ||
1177 | } else { | |
386cbf27 AD |
1178 | |
1179 | if ($is_unread) { | |
1180 | $add_class = "Unread"; | |
1181 | } else { | |
1182 | $add_class = ""; | |
1183 | } | |
1184 | ||
1185 | print "<div class=\"cdmArticle$add_class\" id=\"RROW-$id\">"; | |
1186 | ||
1187 | print "<div class=\"cdmHeader\">"; | |
adccd201 | 1188 | |
5f51022a AD |
1189 | print "<div style=\"float : right\">$updated_fmt, |
1190 | <a class=\"cdmToggleLink\" | |
1191 | href=\"javascript:toggleUnread($id)\">Toggle unread</a> | |
1192 | </div>"; | |
386cbf27 | 1193 | |
5f51022a AD |
1194 | print "<a class=\"title\" |
1195 | onclick=\"javascript:toggleUnread($id, 0)\" | |
1196 | target=\"new\" href=\"".$line["link"]."\">".$line["title"]."</a>"; | |
adccd201 | 1197 | |
386cbf27 AD |
1198 | if ($line["feed_title"]) { |
1199 | print " (<a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a>)"; | |
adccd201 | 1200 | } |
adccd201 | 1201 | |
386cbf27 AD |
1202 | print "</div>"; |
1203 | ||
1204 | print "<div class=\"cdmContent\">" . $line["content_preview"] . "</div>"; | |
5f51022a | 1205 | |
386cbf27 | 1206 | print "<div style=\"float : right\">$marked_pic</div> |
5f51022a | 1207 | <div lass=\"cdmFooter\"> |
386cbf27 AD |
1208 | <input type=\"checkbox\" onclick=\"toggleSelectRowById(this, |
1209 | 'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"></div>"; | |
1210 | ||
5f51022a AD |
1211 | # print "<div align=\"center\"><a class=\"cdmToggleLink\" |
1212 | # href=\"javascript:toggleUnread($id)\"> | |
1213 | # Toggle unread</a></div>"; | |
1214 | ||
386cbf27 AD |
1215 | print "</div>"; |
1216 | ||
1217 | } | |
e5a99b88 AD |
1218 | |
1219 | ++$lnum; | |
254e0e4b | 1220 | } |
adccd201 | 1221 | |
386cbf27 | 1222 | if (!get_pref($link, 'COMBINED_DISPLAY_MODE')) { |
adccd201 | 1223 | print "</table>"; |
adccd201 | 1224 | } |
d76a3b03 | 1225 | |
e0a7121b | 1226 | print_headline_subtoolbar($link, |
f90372c4 | 1227 | "javascript:catchupPage()", "Mark page as read", true, $rtl_content); |
98bea1b1 AD |
1228 | |
1229 | ||
e5a99b88 AD |
1230 | } else { |
1231 | print "<div width='100%' align='center'>No articles found.</div>"; | |
a1a8a2be | 1232 | } |
d76a3b03 | 1233 | |
386cbf27 | 1234 | print "</div>"; |
d76a3b03 | 1235 | |
0a17ba5e AD |
1236 | print " |
1237 | <script type=\"text/javascript\"> | |
1238 | try { | |
1239 | document.onkeydown = hotkey_handler; | |
1240 | parent.update_all_counters(\"$feed\"); | |
1241 | } catch (e) { | |
1242 | exception_error(\"viewfeed/footer1\", e); | |
1243 | } | |
1244 | ||
97dcd654 AD |
1245 | /* for IE */ |
1246 | function statechange() { | |
0a17ba5e | 1247 | if (document.readyState == \"interactive\") init(); |
97dcd654 | 1248 | } |
0a17ba5e | 1249 | |
97dcd654 | 1250 | if (document.readyState) { |
0a17ba5e | 1251 | if (document.readyState == \"interactive\" || document.readyState == \"complete\") { |
97dcd654 AD |
1252 | init(); |
1253 | } else { | |
1254 | document.onreadystatechange = statechange; | |
1255 | } | |
1256 | } | |
0a17ba5e | 1257 | </script>"; |
97dcd654 | 1258 | |
59b8192f | 1259 | print "</body></html>"; |
1cd17194 AD |
1260 | } |
1261 | ||
0e091d38 AD |
1262 | if ($op == "pref-feeds") { |
1263 | ||
47c6c988 AD |
1264 | $subop = $_REQUEST["subop"]; |
1265 | $quiet = $_REQUEST["quiet"]; | |
0e091d38 | 1266 | |
a0476535 AD |
1267 | if ($subop == "massSubscribe") { |
1268 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1269 | ||
a7f22b70 AD |
1270 | $subscribed = array(); |
1271 | ||
a0476535 AD |
1272 | foreach ($ids as $id) { |
1273 | $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds | |
1274 | WHERE id = '$id'"); | |
1275 | ||
1276 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1277 | $title = db_fetch_result($result, 0, "title"); | |
1278 | ||
1279 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
1280 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
1281 | ||
1282 | if (db_num_rows($result) == 0) { | |
1283 | $result = db_query($link, | |
1284 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) | |
1285 | VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); | |
a7f22b70 AD |
1286 | |
1287 | array_push($subscribed, $title); | |
1288 | } | |
1289 | } | |
1290 | ||
1291 | if (count($subscribed) > 0) { | |
1292 | print "<div class=\"notice\">"; | |
1293 | print "<b>Subscribed to feeds:</b>"; | |
1294 | print "<ul class=\"nomarks\">"; | |
1295 | foreach ($subscribed as $title) { | |
1296 | print "<li>$title</li>"; | |
a0476535 | 1297 | } |
a7f22b70 AD |
1298 | print "</ul>"; |
1299 | print "</div>"; | |
a0476535 AD |
1300 | } |
1301 | } | |
1302 | ||
f9cb39ac | 1303 | if ($subop == "browse") { |
e2f728be AD |
1304 | |
1305 | if (!ENABLE_FEED_BROWSER) { | |
1306 | print "Feed browser is administratively disabled."; | |
1307 | return; | |
1308 | } | |
e5d758e3 | 1309 | |
6311acbe | 1310 | print "<div id=\"infoBoxTitle\">Other feeds: Top 25</div>"; |
f9cb39ac AD |
1311 | |
1312 | print "<div class=\"infoBoxContents\">"; | |
1313 | ||
6311acbe | 1314 | print "<p>Showing top 25 registered feeds, sorted by popularity:</p>"; |
f9cb39ac | 1315 | |
0af33e87 AD |
1316 | # $result = db_query($link, "SELECT feed_url,count(id) AS subscribers |
1317 | # FROM ttrss_feeds | |
1318 | # WHERE auth_login = '' AND auth_pass = '' AND private = false | |
1319 | # GROUP BY feed_url ORDER BY subscribers DESC LIMIT 25"); | |
1320 | ||
1321 | $owner_uid = $_SESSION["uid"]; | |
1322 | ||
1323 | $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers | |
1324 | FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
1325 | WHERE tf.feed_url = ttrss_feeds.feed_url | |
1326 | AND owner_uid = '$owner_uid') GROUP BY feed_url | |
1327 | ORDER BY subscribers DESC LIMIT 25"); | |
1328 | ||
f9cb39ac | 1329 | print "<ul class='browseFeedList' id='browseFeedList'>"; |
dc932d0a AD |
1330 | |
1331 | $feedctr = 0; | |
f9cb39ac AD |
1332 | |
1333 | while ($line = db_fetch_assoc($result)) { | |
1334 | $feed_url = $line["feed_url"]; | |
1335 | $subscribers = $line["subscribers"]; | |
dc932d0a | 1336 | |
f9cb39ac AD |
1337 | $det_result = db_query($link, "SELECT site_url,title,id |
1338 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
1339 | ||
1340 | $details = db_fetch_assoc($det_result); | |
1341 | ||
1342 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
1343 | ||
1344 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1345 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
1346 | "/".$details["id"].".ico\">"; | |
1347 | } else { | |
1348 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1349 | } | |
1350 | ||
b92e6209 AD |
1351 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' |
1352 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; | |
f9cb39ac | 1353 | |
b92e6209 AD |
1354 | $class = ($feedctr % 2) ? "even" : "odd"; |
1355 | ||
1356 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
1357 | "$feed_icon " . db_unescape_string($details["title"]) . | |
f9cb39ac | 1358 | " <span class='subscribers'>($subscribers)</span></li>"; |
dc932d0a AD |
1359 | |
1360 | ++$feedctr; | |
1361 | } | |
1362 | ||
1363 | if ($feedctr == 0) { | |
1364 | print "<li>No feeds found to subscribe.</li>"; | |
1365 | } | |
f9cb39ac AD |
1366 | |
1367 | print "</ul>"; | |
1368 | ||
1369 | print "<div align='center'> | |
f9cb39ac | 1370 | <input type=\"submit\" class=\"button\" |
d10fabe4 AD |
1371 | onclick=\"feedBrowserSubscribe()\" value=\"Subscribe\"> |
1372 | <input type='submit' class='button' | |
1373 | onclick=\"closeInfoBox()\" value=\"Cancel\"></div>"; | |
f9cb39ac AD |
1374 | |
1375 | print "</div>"; | |
1376 | return; | |
1377 | } | |
1378 | ||
0ea4fb50 | 1379 | if ($subop == "editfeed") { |
86b682ce | 1380 | $feed_id = db_escape_string($_REQUEST["id"]); |
0ea4fb50 AD |
1381 | |
1382 | $result = db_query($link, | |
1383 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
1384 | owner_uid = " . $_SESSION["uid"]); | |
1385 | ||
1386 | $title = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1387 | 0, "title"))); | |
1388 | ||
0ea4fb50 AD |
1389 | $icon_file = ICONS_DIR . "/$feed_id.ico"; |
1390 | ||
1391 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1392 | $feed_icon = "<img width=\"16\" height=\"16\" | |
1393 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1394 | } else { | |
1395 | $feed_icon = ""; | |
1396 | } | |
e5d758e3 AD |
1397 | |
1398 | print "<div id=\"infoBoxTitle\">Feed editor</div>"; | |
1399 | ||
1400 | print "<div class=\"infoBoxContents\">"; | |
1401 | ||
14f69488 | 1402 | print "<form id=\"edit_feed_form\">"; |
0ea4fb50 | 1403 | |
14f69488 AD |
1404 | print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">"; |
1405 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
1406 | print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; | |
0ea4fb50 | 1407 | |
14f69488 | 1408 | print "<table width='100%'>"; |
0ea4fb50 | 1409 | |
14f69488 | 1410 | print "<tr><td>Title:</td>"; |
ac2cc246 AD |
1411 | print "<td><input class=\"iedit\" onkeypress=\"return filterCR(event)\" |
1412 | name=\"title\" value=\"$title\"></td></tr>"; | |
0ea4fb50 AD |
1413 | |
1414 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1415 | $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1416 | 0, "feed_url"))); | |
14f69488 AD |
1417 | |
1418 | print "<tr><td>Feed URL:</td>"; | |
ac2cc246 AD |
1419 | print "<td><input class=\"iedit\" onkeypress=\"return filterCR(event)\" |
1420 | name=\"feed_url\" value=\"$feed_url\"></td></tr>"; | |
ad815c71 | 1421 | |
0ea4fb50 AD |
1422 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1423 | ||
1424 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
1425 | ||
14f69488 | 1426 | print "<tr><td>Category:</td>"; |
0ea4fb50 | 1427 | print "<td>"; |
0ea4fb50 | 1428 | |
8c2f0ed7 | 1429 | print_feed_cat_select($link, "cat_id", $cat_id, "class=\"iedit\""); |
0ea4fb50 | 1430 | |
673d54ca | 1431 | print "</td>"; |
0ea4fb50 AD |
1432 | print "</td></tr>"; |
1433 | ||
1434 | } | |
1435 | ||
1436 | $update_interval = db_fetch_result($result, 0, "update_interval"); | |
0ea4fb50 | 1437 | |
14f69488 | 1438 | print "<tr><td>Update Interval:</td>"; |
ad815c71 AD |
1439 | |
1440 | print "<td>"; | |
1441 | ||
8c2f0ed7 AD |
1442 | print_select_hash("update_interval", $update_interval, $update_intervals, |
1443 | "class=\"iedit\""); | |
ad815c71 AD |
1444 | |
1445 | print "</td>"; | |
0ea4fb50 | 1446 | |
14f69488 | 1447 | print "<tr><td>Link to:</td><td>"; |
1da7e457 | 1448 | |
3b0027a4 AD |
1449 | $tmp_result = db_query($link, "SELECT COUNT(id) AS count |
1450 | FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); | |
1451 | ||
1452 | $linked_count = db_fetch_result($tmp_result, 0, "count"); | |
1453 | ||
1da7e457 | 1454 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); |
3b0027a4 AD |
1455 | |
1456 | if ($linked_count > 0) { | |
1457 | $disabled = "disabled"; | |
1458 | } | |
1459 | ||
8c2f0ed7 | 1460 | print "<select class=\"iedit\" $disabled name=\"parent_feed\">"; |
3b0027a4 | 1461 | |
14f69488 | 1462 | print "<option value=\"0\">Not linked</option>"; |
1da7e457 | 1463 | |
8a53e029 AD |
1464 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1465 | if ($cat_id) { | |
1466 | $cat_qpart = "AND cat_id = '$cat_id'"; | |
1467 | } else { | |
1468 | $cat_qpart = "AND cat_id IS NULL"; | |
1469 | } | |
1470 | } | |
1471 | ||
1da7e457 | 1472 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds |
262c2426 AD |
1473 | WHERE id != '$feed_id' AND owner_uid = ".$_SESSION["uid"]." |
1474 | $cat_qpart ORDER BY title"); | |
1da7e457 AD |
1475 | |
1476 | if (db_num_rows($tmp_result) > 0) { | |
1477 | print "<option disabled>--------</option>"; | |
1478 | } | |
1479 | ||
1480 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1481 | if ($tmp_line["id"] == $parent_feed) { | |
1482 | $is_selected = "selected"; | |
1483 | } else { | |
1484 | $is_selected = ""; | |
1485 | } | |
14f69488 | 1486 | printf("<option $is_selected value='%d'>%s</option>", |
1da7e457 AD |
1487 | $tmp_line["id"], $tmp_line["title"]); |
1488 | } | |
1489 | ||
d1793994 AD |
1490 | print "</select>"; |
1491 | print "</td></tr>"; | |
1da7e457 | 1492 | |
0ea4fb50 | 1493 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); |
0ea4fb50 | 1494 | |
14f69488 | 1495 | print "<tr><td>Article purging:</td>"; |
ad815c71 AD |
1496 | |
1497 | print "<td>"; | |
1498 | ||
8c2f0ed7 AD |
1499 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, |
1500 | "class=\"iedit\""); | |
ad815c71 | 1501 | |
ad815c71 | 1502 | print "</td>"; |
0ea4fb50 | 1503 | |
47c6c988 AD |
1504 | $auth_login = db_fetch_result($result, 0, "auth_login"); |
1505 | ||
14f69488 | 1506 | print "<tr><td>Login:</td>"; |
ac2cc246 AD |
1507 | print "<td><input class=\"iedit\" onkeypress=\"return filterCR(event)\" |
1508 | name=\"auth_login\" value=\"$auth_login\"></td></tr>"; | |
47c6c988 | 1509 | |
47c6c988 AD |
1510 | $auth_pass = db_fetch_result($result, 0, "auth_pass"); |
1511 | ||
14f69488 AD |
1512 | print "<tr><td>Password:</td>"; |
1513 | print "<td><input class=\"iedit\" type=\"password\" name=\"auth_pass\" | |
ac2cc246 | 1514 | onkeypress=\"return filterCR(event)\" |
47c6c988 AD |
1515 | value=\"$auth_pass\"></td></tr>"; |
1516 | ||
e3c99f3b AD |
1517 | $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); |
1518 | ||
1519 | if ($private) { | |
1520 | $checked = "checked"; | |
1521 | } else { | |
1522 | $checked = ""; | |
1523 | } | |
1524 | ||
14f69488 AD |
1525 | print "<tr><td valign='top'>Options:</td>"; |
1526 | print "<td><input type=\"checkbox\" name=\"private\" id=\"private\" | |
1527 | $checked><label for=\"private\">Hide from feed browser</label>"; | |
70f6dbb1 AD |
1528 | |
1529 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
1530 | ||
1531 | if ($rtl_content) { | |
1532 | $checked = "checked"; | |
1533 | } else { | |
1534 | $checked = ""; | |
1535 | } | |
1536 | ||
14f69488 AD |
1537 | print "<br><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" |
1538 | $checked><label for=\"rtl_content\">Right-to-left content</label>"; | |
70f6dbb1 AD |
1539 | |
1540 | print "</td></tr>"; | |
e3c99f3b | 1541 | |
0ea4fb50 | 1542 | print "</table>"; |
14f69488 AD |
1543 | |
1544 | print "</form>"; | |
1545 | ||
0ea4fb50 AD |
1546 | print "</div>"; |
1547 | ||
1548 | print "<div align='center'> | |
0ea4fb50 | 1549 | <input type=\"submit\" class=\"button\" |
c14b5566 | 1550 | onclick=\"return feedEditSave()\" value=\"Save\"> |
d10fabe4 | 1551 | <input type='submit' class='button' |
c14b5566 | 1552 | onclick=\"return feedEditCancel()\" value=\"Cancel\"></div>"; |
0ea4fb50 AD |
1553 | return; |
1554 | } | |
1555 | ||
508a81e1 | 1556 | if ($subop == "editSave") { |
a88c1f36 | 1557 | |
14f69488 AD |
1558 | $feed_title = db_escape_string(trim($_POST["title"])); |
1559 | $feed_link = db_escape_string(trim($_POST["feed_url"])); | |
1560 | $upd_intl = db_escape_string($_POST["update_interval"]); | |
1561 | $purge_intl = db_escape_string($_POST["purge_interval"]); | |
1562 | $feed_id = db_escape_string($_POST["id"]); | |
1563 | $cat_id = db_escape_string($_POST["cat_id"]); | |
1564 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
1565 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
1566 | $parent_feed = db_escape_string($_POST["parent_feed"]); | |
1567 | $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); | |
1568 | $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); | |
1569 | ||
a2db6a4a AD |
1570 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1571 | if ($cat_id && $cat_id != 0) { | |
1572 | $category_qpart = "cat_id = '$cat_id',"; | |
1573 | } else { | |
1574 | $category_qpart = 'cat_id = NULL,'; | |
1575 | } | |
91ff844a | 1576 | } else { |
a2db6a4a | 1577 | $category_qpart = ""; |
91ff844a AD |
1578 | } |
1579 | ||
14f69488 | 1580 | if ($parent_feed && $parent_feed != 0) { |
a2db6a4a | 1581 | $parent_qpart = "parent_feed = '$parent_feed',"; |
1da7e457 | 1582 | } else { |
a2db6a4a | 1583 | $parent_qpart = 'parent_feed = NULL,'; |
1da7e457 AD |
1584 | } |
1585 | ||
648472a7 | 1586 | $result = db_query($link, "UPDATE ttrss_feeds SET |
a2db6a4a AD |
1587 | $category_qpart |
1588 | $parent_qpart | |
d148926e | 1589 | title = '$feed_title', feed_url = '$feed_link', |
5d73494a | 1590 | update_interval = '$upd_intl', |
47c6c988 AD |
1591 | purge_interval = '$purge_intl', |
1592 | auth_login = '$auth_login', | |
e3c99f3b | 1593 | auth_pass = '$auth_pass', |
ac92cb46 AD |
1594 | private = $private, |
1595 | rtl_content = $rtl_content | |
1596 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); | |
5ddadb4c AD |
1597 | } |
1598 | ||
1599 | if ($subop == "saveCat") { | |
605f7d46 | 1600 | $cat_title = db_escape_string(trim($_GET["title"])); |
5ddadb4c AD |
1601 | $cat_id = db_escape_string($_GET["id"]); |
1602 | ||
1603 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
1604 | title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
508a81e1 | 1605 | |
83fe4d6d AD |
1606 | } |
1607 | ||
331900c6 | 1608 | if ($subop == "remove") { |
331900c6 | 1609 | |
b0b4abcf | 1610 | if (!WEB_DEMO_MODE) { |
331900c6 | 1611 | |
f932bc9f | 1612 | $ids = split(",", db_escape_string($_GET["ids"])); |
b0b4abcf AD |
1613 | |
1614 | foreach ($ids as $id) { | |
f72dbbde AD |
1615 | db_query($link, "DELETE FROM ttrss_feeds |
1616 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
4769ddaf | 1617 | |
273a2f6b | 1618 | $icons_dir = ICONS_DIR; |
d5caaae5 | 1619 | |
4769ddaf AD |
1620 | if (file_exists($icons_dir . "/$id.ico")) { |
1621 | unlink($icons_dir . "/$id.ico"); | |
d5caaae5 | 1622 | } |
b0b4abcf | 1623 | } |
331900c6 AD |
1624 | } |
1625 | } | |
1626 | ||
1627 | if ($subop == "add") { | |
b0b4abcf AD |
1628 | |
1629 | if (!WEB_DEMO_MODE) { | |
331900c6 | 1630 | |
07eb9178 AD |
1631 | $feed_url = db_escape_string(trim($_GET["feed_url"])); |
1632 | $cat_id = db_escape_string($_GET["cat_id"]); | |
15da5cc1 | 1633 | |
07eb9178 | 1634 | if (subscribe_to_feed($link, $feed_url, $cat_id)) { |
956c7629 | 1635 | print "Added feed."; |
15da5cc1 | 1636 | } else { |
7e9a3986 | 1637 | print "<div class=\"warning\"> |
07eb9178 | 1638 | Feed <b>$feed_url</b> already exists in the database. |
7e9a3986 | 1639 | </div>"; |
b0b4abcf AD |
1640 | } |
1641 | } | |
331900c6 | 1642 | } |
a0d53889 | 1643 | |
91ff844a AD |
1644 | if ($subop == "addCat") { |
1645 | ||
1646 | if (!WEB_DEMO_MODE) { | |
1647 | ||
1648 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
1649 | ||
1650 | $result = db_query($link, | |
1651 | "SELECT id FROM ttrss_feed_categories | |
1652 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
1653 | ||
1654 | if (db_num_rows($result) == 0) { | |
1655 | ||
1656 | $result = db_query($link, | |
1657 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
1658 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
1659 | ||
1660 | } else { | |
1661 | ||
1662 | print "<div class=\"warning\"> | |
1663 | Category <b>$feed_cat</b> already exists in the database. | |
1664 | </div>"; | |
1665 | } | |
1666 | ||
1667 | ||
1668 | } | |
1669 | } | |
1670 | ||
1671 | if ($subop == "removeCats") { | |
1672 | ||
1673 | if (!WEB_DEMO_MODE) { | |
1674 | ||
f932bc9f | 1675 | $ids = split(",", db_escape_string($_GET["ids"])); |
91ff844a AD |
1676 | |
1677 | foreach ($ids as $id) { | |
1678 | ||
1679 | db_query($link, "BEGIN"); | |
1680 | ||
1681 | $result = db_query($link, | |
1682 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
1683 | WHERE cat_id = '$id'"); | |
1684 | ||
1685 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
1686 | ||
1687 | if ($num_feeds == 0) { | |
1688 | db_query($link, "DELETE FROM ttrss_feed_categories | |
1689 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1690 | } else { | |
1691 | ||
1692 | print "<div class=\"warning\"> | |
1693 | Unable to delete non empty feed categories.</div>"; | |
1694 | ||
1695 | } | |
1696 | ||
1697 | db_query($link, "COMMIT"); | |
1698 | } | |
1699 | } | |
1700 | } | |
1701 | ||
f932bc9f AD |
1702 | if ($subop == "categorize") { |
1703 | ||
1704 | if (!WEB_DEMO_MODE) { | |
1705 | ||
1706 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1707 | ||
1708 | $cat_id = db_escape_string($_GET["cat_id"]); | |
1709 | ||
1710 | if ($cat_id == 0) { | |
1711 | $cat_id_qpart = 'NULL'; | |
1712 | } else { | |
1713 | $cat_id_qpart = "'$cat_id'"; | |
1714 | } | |
1715 | ||
1716 | db_query($link, "BEGIN"); | |
1717 | ||
1718 | foreach ($ids as $id) { | |
1719 | ||
1720 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
1721 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1722 | } | |
1723 | ||
1724 | db_query($link, "COMMIT"); | |
1725 | } | |
1726 | ||
1727 | } | |
1728 | ||
a24f525c AD |
1729 | if ($quiet) return; |
1730 | ||
c64d5b03 | 1731 | // print "<h3>Edit Feeds</h3>"; |
91ff844a | 1732 | |
4904f845 AD |
1733 | $result = db_query($link, "SELECT id,title,feed_url,last_error |
1734 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1735 | ||
1736 | if (db_num_rows($result) > 0) { | |
1737 | ||
1738 | print "<div class=\"warning\">"; | |
a9b0bfd5 AD |
1739 | |
1740 | // print"<img class=\"closeButton\" | |
1741 | // onclick=\"javascript:hideParentElement(this);\" src=\"images/close.png\">"; | |
1742 | ||
36aab70f | 1743 | print "<a href=\"javascript:showBlockElement('feedUpdateErrors')\"> |
0ceded7a | 1744 | <b>Some feeds have update errors (click for details)</b></a>"; |
4904f845 | 1745 | |
36aab70f | 1746 | print "<ul id=\"feedUpdateErrors\" class=\"nomarks\">"; |
4904f845 AD |
1747 | |
1748 | while ($line = db_fetch_assoc($result)) { | |
1749 | print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " . | |
1750 | $line["last_error"]; | |
1751 | } | |
1752 | ||
1753 | print "</ul>"; | |
1754 | print "</div>"; | |
1755 | ||
1756 | } | |
1757 | ||
f932bc9f AD |
1758 | $feed_search = db_escape_string($_GET["search"]); |
1759 | ||
1760 | if (array_key_exists("search", $_GET)) { | |
1761 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1762 | } else { | |
1763 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1764 | } | |
1765 | ||
1766 | print "<table width='100%' class=\"prefGenericAddBox\" | |
1767 | cellspacing='0' cellpadding='0'><tr> | |
1768 | <td> | |
1769 | <input id=\"fadd_link\" | |
2371c520 AD |
1770 | onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\" |
1771 | size=\"40\"> | |
f932bc9f | 1772 | <input type=\"submit\" class=\"button\" |
2371c520 AD |
1773 | disabled=\"true\" id=\"fadd_submit_btn\" |
1774 | onclick=\"addFeed()\" value=\"Subscribe\">"; | |
e2f728be | 1775 | |
0b68215c | 1776 | if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) { |
e5d758e3 | 1777 | print " <input type=\"submit\" class=\"button\" |
6311acbe | 1778 | onclick=\"javascript:browseFeeds()\" value=\"Top 25\">"; |
e2f728be AD |
1779 | } |
1780 | ||
1781 | print "</td><td align='right'> | |
f932bc9f | 1782 | <input id=\"feed_search\" size=\"20\" |
2371c520 | 1783 | onchange=\"javascript:updateFeedList()\" value=\"$feed_search\"> |
f932bc9f AD |
1784 | <input type=\"submit\" class=\"button\" |
1785 | onclick=\"javascript:updateFeedList()\" value=\"Search\"> | |
1786 | </td> | |
1787 | </tr></table>"; | |
a0d53889 | 1788 | |
b83c7545 AD |
1789 | $feeds_sort = db_escape_string($_GET["sort"]); |
1790 | ||
1791 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
1792 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
1793 | if (!$feeds_sort) $feeds_sort = "title"; | |
1794 | } | |
1795 | ||
1796 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
1797 | ||
f932bc9f | 1798 | if ($feed_search) { |
11de82c3 AD |
1799 | $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR |
1800 | UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND"; | |
f932bc9f AD |
1801 | } else { |
1802 | $search_qpart = ""; | |
1803 | } | |
1804 | ||
a2db6a4a AD |
1805 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1806 | $order_by_qpart = "category,$feeds_sort,title"; | |
1807 | } else { | |
1808 | $order_by_qpart = "$feeds_sort,title"; | |
1809 | } | |
1810 | ||
648472a7 | 1811 | $result = db_query($link, "SELECT |
db42b934 AD |
1812 | F1.id, |
1813 | F1.title, | |
1814 | F1.feed_url, | |
1815 | substring(F1.last_updated,1,16) AS last_updated, | |
1816 | F1.parent_feed, | |
1817 | F1.update_interval, | |
1818 | F1.purge_interval, | |
1819 | F1.cat_id, | |
1820 | F2.title AS parent_title, | |
1821 | C1.title AS category | |
c0e5a40e | 1822 | FROM |
db42b934 AD |
1823 | ttrss_feeds AS F1 |
1824 | LEFT JOIN ttrss_feeds AS F2 | |
1825 | ON (F1.parent_feed = F2.id) | |
1826 | LEFT JOIN ttrss_feed_categories AS C1 | |
1827 | ON (F1.cat_id = C1.id) | |
f932bc9f | 1828 | WHERE |
db42b934 | 1829 | $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' |
a2db6a4a | 1830 | ORDER by $order_by_qpart"); |
1cd17194 | 1831 | |
3b0feb9b | 1832 | if (db_num_rows($result) != 0) { |
91ff844a | 1833 | |
59a543f0 | 1834 | // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
35f3c923 | 1835 | |
f4fe2cde AD |
1836 | print "<p><table width=\"100%\" cellspacing=\"0\" |
1837 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
35f3c923 AD |
1838 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
1839 | Select: | |
ce3bf408 AD |
1840 | <a href=\"javascript:selectPrefRows('feed', true)\">All</a>, |
1841 | <a href=\"javascript:selectPrefRows('feed', false)\">None</a> | |
35f3c923 AD |
1842 | </td</tr>"; |
1843 | ||
0ea4fb50 AD |
1844 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { |
1845 | print "<tr class=\"title\"> | |
6e69e9c2 AD |
1846 | <td width='5%' align='center'> </td>"; |
1847 | ||
1848 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
1849 | print "<td width='3%'> </td>"; | |
1850 | } | |
1851 | ||
1852 | print " | |
01b3e191 AD |
1853 | <td width='40%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> |
1854 | <td width='45%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> | |
1855 | <td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>"; | |
603c27f8 | 1856 | } |
603c27f8 | 1857 | |
c64d5b03 | 1858 | $lnum = 0; |
0ea4fb50 AD |
1859 | |
1860 | $cur_cat_id = -1; | |
c64d5b03 AD |
1861 | |
1862 | while ($line = db_fetch_assoc($result)) { | |
1863 | ||
3b0feb9b | 1864 | $feed_id = $line["id"]; |
0ea4fb50 AD |
1865 | $cat_id = $line["cat_id"]; |
1866 | ||
1867 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
1868 | $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); | |
1869 | $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); | |
0ea4fb50 AD |
1870 | |
1871 | if (!$edit_cat) $edit_cat = "Uncategorized"; | |
1872 | ||
01b3e191 AD |
1873 | $last_updated = $line["last_updated"]; |
1874 | ||
1875 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
1876 | $last_updated = smart_date_time(strtotime($last_updated)); | |
1877 | } else { | |
1878 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
1879 | $last_updated = date($short_date, strtotime($last_updated)); | |
1880 | } | |
1881 | ||
0ea4fb50 | 1882 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { |
cb58d0df AD |
1883 | $lnum = 0; |
1884 | ||
0ea4fb50 AD |
1885 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; |
1886 | ||
1887 | print "<tr class=\"title\"> | |
2eb15f6f | 1888 | <td width='5%'> </td>"; |
d1793994 AD |
1889 | |
1890 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { | |
2eb15f6f | 1891 | print "<td width='3%'> </td>"; |
d1793994 AD |
1892 | } |
1893 | ||
1894 | print "<td width='40%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> | |
01b3e191 AD |
1895 | <td width='45%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> |
1896 | <td width='15%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">Updated</a></td>"; | |
0ea4fb50 AD |
1897 | |
1898 | $cur_cat_id = $cat_id; | |
c64d5b03 | 1899 | } |
0ea4fb50 | 1900 | |
cb58d0df | 1901 | $class = ($lnum % 2) ? "even" : "odd"; |
0ea4fb50 AD |
1902 | $this_row_id = "id=\"FEEDR-$feed_id\""; |
1903 | ||
53226edc | 1904 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
1905 | |
1906 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1907 | ||
1908 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
327a3bbe | 1909 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; |
3b0feb9b | 1910 | } else { |
327a3bbe | 1911 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
3b0feb9b | 1912 | } |
d1793994 | 1913 | |
ce3bf408 | 1914 | print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");' |
0ea4fb50 | 1915 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
3547842a | 1916 | |
d1793994 AD |
1917 | if (get_pref($link, 'ENABLE_FEED_ICONS')) { |
1918 | print "<td class='feedIcon'>$feed_icon</td>"; | |
1919 | } | |
1920 | ||
0ea4fb50 AD |
1921 | $edit_title = truncate_string($edit_title, 40); |
1922 | $edit_link = truncate_string($edit_link, 60); | |
a88c1f36 | 1923 | |
1da7e457 AD |
1924 | $parent_title = $line["parent_title"]; |
1925 | if ($parent_title) { | |
1926 | $parent_title = "<span class='groupPrompt'>(linked to | |
1927 | $parent_title)</span>"; | |
1928 | } | |
1929 | ||
0ea4fb50 | 1930 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
d1793994 | 1931 | "$edit_title $parent_title" . "</a></td>"; |
0ea4fb50 AD |
1932 | |
1933 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
1934 | $edit_link . "</a></td>"; | |
3547842a | 1935 | |
01b3e191 AD |
1936 | print "<td align='right'><a href=\"javascript:editFeed($feed_id);\">" . |
1937 | "$last_updated</a></td>"; | |
1938 | ||
c64d5b03 AD |
1939 | print "</tr>"; |
1940 | ||
1941 | ++$lnum; | |
1942 | } | |
1943 | ||
c64d5b03 | 1944 | print "</table>"; |
3b0feb9b | 1945 | |
ce3bf408 | 1946 | print "<p><span id=\"feedOpToolbar\">"; |
c64d5b03 | 1947 | |
3b0feb9b AD |
1948 | if ($subop == "edit") { |
1949 | print "Edit feed: | |
c64d5b03 | 1950 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 1951 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> |
c64d5b03 | 1952 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
1953 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
1954 | } else { | |
c64d5b03 AD |
1955 | |
1956 | print " | |
1957 | Selection: | |
ce3bf408 | 1958 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
3b0feb9b | 1959 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> |
ce3bf408 | 1960 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
e5d758e3 | 1961 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Unsubscribe\">"; |
f932bc9f AD |
1962 | |
1963 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1964 | ||
e5d758e3 | 1965 | print " | "; |
f932bc9f | 1966 | |
673d54ca | 1967 | print_feed_cat_select($link, "sfeed_set_fcat", "", "disabled"); |
f932bc9f | 1968 | |
ce3bf408 | 1969 | print " <input type=\"submit\" class=\"button\" disabled=\"true\" |
6d1e02a2 | 1970 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Recategorize\">"; |
f932bc9f AD |
1971 | |
1972 | } | |
3b0feb9b | 1973 | |
ce3bf408 | 1974 | print "</span> |
f932bc9f | 1975 | All feeds: <input type=\"submit\" |
3b0feb9b AD |
1976 | class=\"button\" onclick=\"gotoExportOpml()\" |
1977 | value=\"Export OPML\">"; | |
1978 | } | |
1979 | } else { | |
1980 | ||
1981 | print "<p>No feeds defined.</p>"; | |
1982 | ||
1983 | } | |
1984 | ||
1985 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1986 | ||
1987 | print "<h3>Edit Categories</h3>"; | |
1988 | ||
3b0feb9b | 1989 | print "<div class=\"prefGenericAddBox\"> |
f932bc9f | 1990 | <input id=\"fadd_cat\" |
ce3bf408 | 1991 | onkeyup=\"toggleSubmitNotEmpty(this, 'catadd_submit_btn')\" |
f932bc9f AD |
1992 | size=\"40\"> |
1993 | <input | |
ce3bf408 | 1994 | type=\"submit\" class=\"button\" disabled=\"true\" id=\"catadd_submit_btn\" |
e5d758e3 | 1995 | onclick=\"javascript:addFeedCat()\" value=\"Create category\"></div>"; |
3b0feb9b AD |
1996 | |
1997 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
1998 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1999 | ORDER BY title"); | |
2000 | ||
2001 | if (db_num_rows($result) != 0) { | |
2002 | ||
0666e120 AD |
2003 | print "<form id=\"feed_cat_edit_form\">"; |
2004 | ||
35f3c923 | 2005 | print "<p><table width=\"100%\" class=\"prefFeedCatList\" |
f4fe2cde | 2006 | cellspacing=\"0\" id=\"prefFeedCatList\">"; |
35f3c923 AD |
2007 | |
2008 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2009 | Select: | |
ce3bf408 AD |
2010 | <a href=\"javascript:selectPrefRows('fcat', true)\">All</a>, |
2011 | <a href=\"javascript:selectPrefRows('fcat', false)\">None</a> | |
35f3c923 AD |
2012 | </td</tr>"; |
2013 | ||
3b0feb9b | 2014 | print "<tr class=\"title\"> |
0b68215c | 2015 | <td width=\"5%\"> </td><td width=\"80%\">Title</td> |
3b0feb9b AD |
2016 | </tr>"; |
2017 | ||
2018 | $lnum = 0; | |
2019 | ||
2020 | while ($line = db_fetch_assoc($result)) { | |
2021 | ||
2022 | $class = ($lnum % 2) ? "even" : "odd"; | |
2023 | ||
2024 | $cat_id = $line["id"]; | |
2025 | ||
2026 | $edit_cat_id = $_GET["id"]; | |
2027 | ||
3c5783b7 | 2028 | if ($subop == "editCat" && $cat_id != $edit_cat_id) { |
0666e120 AD |
2029 | $class .= "Grayed"; |
2030 | $this_row_id = ""; | |
53226edc AD |
2031 | } else { |
2032 | $this_row_id = "id=\"FCATR-$cat_id\""; | |
3b0feb9b AD |
2033 | } |
2034 | ||
53226edc | 2035 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2036 | |
2037 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
2038 | ||
2039 | if (!$edit_cat_id || $subop != "editCat") { | |
2040 | ||
ce3bf408 AD |
2041 | print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"fcat\");' |
2042 | type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>"; | |
3b0feb9b AD |
2043 | |
2044 | print "<td><a href=\"javascript:editFeedCat($cat_id);\">" . | |
2045 | $edit_title . "</a></td>"; | |
2046 | ||
2047 | } else if ($cat_id != $edit_cat_id) { | |
2048 | ||
0666e120 | 2049 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
3b0feb9b AD |
2050 | id=\"FRCHK-".$line["id"]."\"></td>"; |
2051 | ||
2052 | print "<td>$edit_title</td>"; | |
2053 | ||
2054 | } else { | |
2055 | ||
0666e120 AD |
2056 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked>"; |
2057 | ||
2058 | print "<input type=\"hidden\" name=\"id\" value=\"$cat_id\">"; | |
2059 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
2060 | print "<input type=\"hidden\" name=\"subop\" value=\"saveCat\">"; | |
2061 | ||
2062 | print "</td>"; | |
3b0feb9b | 2063 | |
ac2cc246 AD |
2064 | print "<td><input onkeypress=\"return filterCR(event)\" |
2065 | name=\"title\" class=\"iedit\" value=\"$edit_title\"></td>"; | |
3b0feb9b AD |
2066 | |
2067 | } | |
2068 | ||
2069 | print "</tr>"; | |
2070 | ||
2071 | ++$lnum; | |
2072 | } | |
2073 | ||
2074 | print "</table>"; | |
0666e120 AD |
2075 | |
2076 | print "</form>"; | |
3b0feb9b | 2077 | |
ce3bf408 | 2078 | print "<p id=\"catOpToolbar\">"; |
3b0feb9b AD |
2079 | |
2080 | if ($subop == "editCat") { | |
2081 | print "Edit category: | |
ce3bf408 | 2082 | <input type=\"submit\" class=\"button\" |
0666e120 | 2083 | onclick=\"javascript:feedCatEditSave()\" value=\"Save\"> |
ce3bf408 | 2084 | <input type=\"submit\" class=\"button\" |
0666e120 | 2085 | onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\">"; |
3b0feb9b AD |
2086 | } else { |
2087 | ||
2088 | print " | |
2089 | Selection: | |
ce3bf408 | 2090 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
3b0feb9b | 2091 | onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\"> |
ce3bf408 | 2092 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
3b0feb9b AD |
2093 | onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">"; |
2094 | ||
2095 | } | |
2096 | ||
2097 | } else { | |
2098 | print "<p>No feed categories defined.</p>"; | |
2099 | } | |
c64d5b03 AD |
2100 | } |
2101 | ||
2102 | print "<h3>Import OPML</h3> | |
f5a50b25 AD |
2103 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
2104 | File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
2105 | <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\" | |
2106 | type=\"submit\" value=\"Import\"> | |
2107 | </form>"; | |
2108 | ||
007bda35 AD |
2109 | } |
2110 | ||
a0d53889 AD |
2111 | if ($op == "pref-filters") { |
2112 | ||
2113 | $subop = $_GET["subop"]; | |
a24f525c | 2114 | $quiet = $_GET["quiet"]; |
a0d53889 | 2115 | |
07164479 AD |
2116 | if ($subop == "edit") { |
2117 | ||
2118 | $filter_id = db_escape_string($_GET["id"]); | |
2119 | ||
2120 | $result = db_query($link, | |
9cd30721 | 2121 | "SELECT * FROM ttrss_filters WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]); |
07164479 AD |
2122 | |
2123 | $reg_exp = htmlspecialchars(db_unescape_string(db_fetch_result($result, 0, "reg_exp"))); | |
2124 | $filter_type = db_fetch_result($result, 0, "filter_type"); | |
2125 | $feed_id = db_fetch_result($result, 0, "feed_id"); | |
2126 | $action_id = db_fetch_result($result, 0, "action_id"); | |
2127 | ||
2128 | print "<div id=\"infoBoxTitle\">Filter editor</div>"; | |
2129 | print "<div class=\"infoBoxContents\">"; | |
2130 | ||
2131 | print "<form id=\"filter_edit_form\">"; | |
2132 | ||
2133 | print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">"; | |
2134 | print "<input type=\"hidden\" name=\"id\" value=\"$filter_id\">"; | |
2135 | print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; | |
2136 | ||
2137 | // print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>"; | |
2138 | ||
2139 | $result = db_query($link, "SELECT id,description | |
2140 | FROM ttrss_filter_types ORDER BY description"); | |
2141 | ||
2142 | $filter_types = array(); | |
2143 | ||
2144 | while ($line = db_fetch_assoc($result)) { | |
2145 | //array_push($filter_types, $line["description"]); | |
2146 | $filter_types[$line["id"]] = $line["description"]; | |
2147 | } | |
2148 | ||
2149 | print "<table width='100%'>"; | |
2150 | ||
2151 | print "<tr><td>Match:</td> | |
2152 | <td><input onkeypress=\"return filterCR(event)\" | |
2153 | onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\" | |
4220b0bd | 2154 | name=\"reg_exp\" class=\"iedit\" value=\"$reg_exp\">"; |
07164479 | 2155 | |
4220b0bd AD |
2156 | print "</td><td>"; |
2157 | ||
2158 | print_select_hash("filter_type", $filter_type, $filter_types, "class=\"iedit\""); | |
07164479 AD |
2159 | |
2160 | print "</td></tr>"; | |
4220b0bd | 2161 | print "<tr><td>Feed:</td><td colspan='2'>"; |
07164479 AD |
2162 | |
2163 | print_feed_select($link, "feed_id", $feed_id); | |
2164 | ||
2165 | print "</td></tr>"; | |
2166 | ||
2167 | print "<tr><td>Action:</td>"; | |
2168 | ||
4220b0bd | 2169 | print "<td colspan='2'><select name=\"action_id\">"; |
07164479 AD |
2170 | |
2171 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2172 | ORDER BY name"); | |
2173 | ||
2174 | while ($line = db_fetch_assoc($result)) { | |
2175 | $is_sel = ($line["id"] == $action_id) ? "selected" : ""; | |
2176 | printf("<option value='%d' $is_sel>%s</option>", $line["id"], $line["description"]); | |
2177 | } | |
2178 | ||
2179 | print "</select>"; | |
2180 | ||
2181 | print "</td></tr></table>"; | |
2182 | ||
2183 | print "</form>"; | |
2184 | ||
2185 | print "<div align='right'>"; | |
2186 | ||
2187 | print "<input type=\"submit\" | |
2188 | id=\"infobox_submit\" | |
2189 | class=\"button\" onclick=\"filterEditSave()\" | |
2190 | value=\"Save\"> "; | |
2191 | ||
2192 | print "<input class=\"button\" | |
2193 | type=\"submit\" onclick=\"filterEditCancel()\" | |
2194 | value=\"Cancel\">"; | |
2195 | ||
2196 | print "</div>"; | |
2197 | ||
2198 | return; | |
2199 | } | |
2200 | ||
2201 | ||
a0d53889 | 2202 | if ($subop == "editSave") { |
a0d53889 | 2203 | |
7e939457 AD |
2204 | $reg_exp = db_escape_string(trim($_GET["reg_exp"])); |
2205 | $filter_type = db_escape_string(trim($_GET["filter_type"])); | |
648472a7 | 2206 | $filter_id = db_escape_string($_GET["id"]); |
7e939457 AD |
2207 | $feed_id = db_escape_string($_GET["feed_id"]); |
2208 | $action_id = db_escape_string($_GET["action_id"]); | |
ead60402 AD |
2209 | |
2210 | if (!$feed_id) { | |
2211 | $feed_id = 'NULL'; | |
2212 | } else { | |
2213 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2214 | } | |
0afbd851 | 2215 | |
648472a7 | 2216 | $result = db_query($link, "UPDATE ttrss_filters SET |
7e939457 AD |
2217 | reg_exp = '$reg_exp', |
2218 | feed_id = $feed_id, | |
2219 | action_id = '$action_id', | |
2220 | filter_type = '$filter_type' | |
9cd30721 | 2221 | WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]); |
a0d53889 AD |
2222 | } |
2223 | ||
2224 | if ($subop == "remove") { | |
2225 | ||
2226 | if (!WEB_DEMO_MODE) { | |
2227 | ||
f932bc9f | 2228 | $ids = split(",", db_escape_string($_GET["ids"])); |
a0d53889 AD |
2229 | |
2230 | foreach ($ids as $id) { | |
9cd30721 | 2231 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]); |
a0d53889 AD |
2232 | |
2233 | } | |
2234 | } | |
2235 | } | |
2236 | ||
2237 | if ($subop == "add") { | |
2238 | ||
de435974 | 2239 | if (!WEB_DEMO_MODE) { |
a0d53889 | 2240 | |
79f3553b | 2241 | $regexp = db_escape_string(trim($_GET["reg_exp"])); |
07164479 | 2242 | $filter_type = db_escape_string(trim($_GET["filter_type"])); |
79f3553b AD |
2243 | $feed_id = db_escape_string($_GET["feed_id"]); |
2244 | $action_id = db_escape_string($_GET["action_id"]); | |
ead60402 AD |
2245 | |
2246 | if (!$feed_id) { | |
2247 | $feed_id = 'NULL'; | |
2248 | } else { | |
2249 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2250 | } | |
4401bf04 | 2251 | |
648472a7 | 2252 | $result = db_query($link, |
19c9cb11 AD |
2253 | "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, |
2254 | action_id) | |
2255 | VALUES | |
07164479 | 2256 | ('$regexp', '$filter_type','".$_SESSION["uid"]."', |
19c9cb11 | 2257 | $feed_id, '$action_id')"); |
de435974 | 2258 | } |
a0d53889 AD |
2259 | } |
2260 | ||
a24f525c AD |
2261 | if ($quiet) return; |
2262 | ||
59a543f0 | 2263 | // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
7b5c6012 | 2264 | |
7e939457 | 2265 | $result = db_query($link, "SELECT id,description |
a0d53889 AD |
2266 | FROM ttrss_filter_types ORDER BY description"); |
2267 | ||
2268 | $filter_types = array(); | |
2269 | ||
648472a7 | 2270 | while ($line = db_fetch_assoc($result)) { |
7e939457 AD |
2271 | //array_push($filter_types, $line["description"]); |
2272 | $filter_types[$line["id"]] = $line["description"]; | |
a0d53889 AD |
2273 | } |
2274 | ||
7b5c6012 AD |
2275 | print "<input type=\"submit\" |
2276 | class=\"button\" | |
2277 | onclick=\"javascript:displayDlg('quickAddFilter', false)\" | |
4220b0bd | 2278 | id=\"create_filter_btn\" |
7b5c6012 AD |
2279 | value=\"Create filter\">"; |
2280 | ||
648472a7 | 2281 | $result = db_query($link, "SELECT |
ead60402 | 2282 | ttrss_filters.id AS id,reg_exp, |
ead60402 AD |
2283 | ttrss_filter_types.name AS filter_type_name, |
2284 | ttrss_filter_types.description AS filter_type_descr, | |
2285 | feed_id, | |
19c9cb11 | 2286 | ttrss_filter_actions.description AS action_description, |
11de82c3 | 2287 | ttrss_feeds.title AS feed_title |
a0d53889 | 2288 | FROM |
5890c3f4 AD |
2289 | ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN |
2290 | ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id) | |
4356293a | 2291 | WHERE |
ead60402 | 2292 | filter_type = ttrss_filter_types.id AND |
19c9cb11 | 2293 | ttrss_filter_actions.id = action_id AND |
ead60402 | 2294 | ttrss_filters.owner_uid = ".$_SESSION["uid"]." |
4356293a | 2295 | ORDER by reg_exp"); |
a0d53889 | 2296 | |
3b0feb9b | 2297 | if (db_num_rows($result) != 0) { |
a0d53889 | 2298 | |
7e939457 AD |
2299 | print "<form id=\"filter_edit_form\">"; |
2300 | ||
f4fe2cde AD |
2301 | print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" |
2302 | id=\"prefFilterList\">"; | |
35f3c923 AD |
2303 | |
2304 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2305 | Select: | |
ce3bf408 AD |
2306 | <a href=\"javascript:selectPrefRows('filter', true)\">All</a>, |
2307 | <a href=\"javascript:selectPrefRows('filter', false)\">None</a> | |
35f3c923 AD |
2308 | </td</tr>"; |
2309 | ||
3b0feb9b | 2310 | print "<tr class=\"title\"> |
e325c6e7 | 2311 | <td align='center' width=\"5%\"> </td> |
19c9cb11 AD |
2312 | <td width=\"20%\">Filter expression</td> |
2313 | <td width=\"20%\">Feed</td> | |
2314 | <td width=\"15%\">Match</td> | |
01b3e191 AD |
2315 | <td width=\"15%\">Action</td>"; |
2316 | ||
3b0feb9b AD |
2317 | $lnum = 0; |
2318 | ||
2319 | while ($line = db_fetch_assoc($result)) { | |
2320 | ||
2321 | $class = ($lnum % 2) ? "even" : "odd"; | |
2322 | ||
2323 | $filter_id = $line["id"]; | |
2324 | $edit_filter_id = $_GET["id"]; | |
2325 | ||
2326 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
2327 | $class .= "Grayed"; | |
53226edc AD |
2328 | $this_row_id = ""; |
2329 | } else { | |
2330 | $this_row_id = "id=\"FILRR-$filter_id\""; | |
ead60402 | 2331 | } |
3b0feb9b | 2332 | |
53226edc | 2333 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b | 2334 | |
07164479 | 2335 | $line["reg_exp"] = htmlspecialchars(db_unescape_string($line["reg_exp"])); |
3b0feb9b AD |
2336 | |
2337 | if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; | |
7e939457 | 2338 | |
07164479 AD |
2339 | $line["feed_title"] = htmlspecialchars(db_unescape_string($line["feed_title"])); |
2340 | ||
2341 | print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"filter\");' | |
3b0feb9b AD |
2342 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; |
2343 | ||
07164479 AD |
2344 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . |
2345 | $line["reg_exp"] . "</td>"; | |
3b0feb9b | 2346 | |
07164479 AD |
2347 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . |
2348 | $line["feed_title"] . "</td>"; | |
3b0feb9b | 2349 | |
07164479 AD |
2350 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . |
2351 | $line["filter_type_descr"] . "</td>"; | |
19c9cb11 | 2352 | |
07164479 AD |
2353 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . |
2354 | $line["action_description"] . "</td>"; | |
3b0feb9b AD |
2355 | |
2356 | print "</tr>"; | |
2357 | ||
2358 | ++$lnum; | |
a0d53889 | 2359 | } |
3b0feb9b AD |
2360 | |
2361 | if ($lnum == 0) { | |
2362 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
2363 | } | |
2364 | ||
2365 | print "</table>"; | |
7e939457 AD |
2366 | |
2367 | print "</form>"; | |
3b0feb9b | 2368 | |
ce3bf408 | 2369 | print "<p id=\"filterOpToolbar\">"; |
3b0feb9b | 2370 | |
4220b0bd | 2371 | print " |
3b0feb9b | 2372 | Selection: |
ce3bf408 | 2373 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
3b0feb9b | 2374 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> |
ce3bf408 | 2375 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
3b0feb9b | 2376 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; |
4220b0bd AD |
2377 | |
2378 | print "</p>"; | |
3b0feb9b | 2379 | |
a0d53889 AD |
2380 | } else { |
2381 | ||
3b0feb9b AD |
2382 | print "<p>No filters defined.</p>"; |
2383 | ||
a0d53889 AD |
2384 | } |
2385 | } | |
2386 | ||
80dce858 AD |
2387 | // We need to accept raw SQL data in label queries, so not everything is escaped |
2388 | // here, this is by design. If you don't like the whole idea, disable labels | |
2389 | // altogether with GLOBAL_ENABLE_LABELS = false | |
2390 | ||
48f0adb0 AD |
2391 | if ($op == "pref-labels") { |
2392 | ||
cfaba6df AD |
2393 | if (!GLOBAL_ENABLE_LABELS) { |
2394 | return; | |
2395 | } | |
2396 | ||
48f0adb0 AD |
2397 | $subop = $_GET["subop"]; |
2398 | ||
d9dde1d6 AD |
2399 | if ($subop == "test") { |
2400 | ||
9a35e16d AD |
2401 | $expr = trim($_GET["expr"]); |
2402 | $descr = trim($_GET["descr"]); | |
d9dde1d6 | 2403 | |
e5d758e3 AD |
2404 | print "<div id=\"infoBoxTitle\">Test label: $descr</div>"; |
2405 | ||
d9dde1d6 AD |
2406 | print "<div class='infoBoxContents'>"; |
2407 | ||
e5d758e3 | 2408 | # print "<h1>Label «$descr»</h1>"; |
d9dde1d6 AD |
2409 | |
2410 | // print "<p><b>Expression</b>: $expr</p>"; | |
2411 | ||
2412 | $result = db_query($link, | |
2413 | "SELECT count(id) AS num_matches | |
2414 | FROM ttrss_entries,ttrss_user_entries | |
2415 | WHERE ($expr) AND | |
2416 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
2417 | owner_uid = " . $_SESSION["uid"]); | |
2418 | ||
2419 | $num_matches = db_fetch_result($result, 0, "num_matches");; | |
2420 | ||
2421 | if ($num_matches > 0) { | |
2422 | ||
673d54ca | 2423 | print "<p>Query returned <b>$num_matches</b> matches, showing first 15:</p>"; |
d9dde1d6 AD |
2424 | |
2425 | $result = db_query($link, | |
2426 | "SELECT title, | |
2427 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title | |
2428 | FROM ttrss_entries,ttrss_user_entries | |
2429 | WHERE ($expr) AND | |
2430 | ttrss_user_entries.ref_id = ttrss_entries.id | |
2431 | AND owner_uid = " . $_SESSION["uid"] . " | |
673d54ca | 2432 | ORDER BY date_entered DESC LIMIT 15"); |
d9dde1d6 | 2433 | |
673d54ca AD |
2434 | print "<ul class=\"filterTestResults\">"; |
2435 | ||
2436 | $row_class = "even"; | |
2437 | ||
d9dde1d6 | 2438 | while ($line = db_fetch_assoc($result)) { |
673d54ca AD |
2439 | $row_class = toggleEvenOdd($row_class); |
2440 | ||
2441 | print "<li class=\"$row_class\">".$line["title"]. | |
d9dde1d6 AD |
2442 | " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>"; |
2443 | } | |
2444 | print "</ul>"; | |
2445 | ||
2446 | } else { | |
2447 | print "<p>Query didn't return any matches.</p>"; | |
2448 | } | |
2449 | ||
2450 | print "</div>"; | |
2451 | ||
2452 | print "<div align='center'> | |
2453 | <input type='submit' class='button' | |
2454 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
2455 | return; | |
2456 | } | |
2457 | ||
48f0adb0 AD |
2458 | if ($subop == "editSave") { |
2459 | ||
f3120e5a AD |
2460 | $sql_exp = trim($_GET["sql_exp"]); |
2461 | $descr = db_escape_string(trim($_GET["description"])); | |
48f0adb0 AD |
2462 | $label_id = db_escape_string($_GET["id"]); |
2463 | ||
48f0adb0 AD |
2464 | $result = db_query($link, "UPDATE ttrss_labels SET |
2465 | sql_exp = '$sql_exp', | |
2466 | description = '$descr' | |
2467 | WHERE id = '$label_id'"); | |
2468 | } | |
2469 | ||
2470 | if ($subop == "remove") { | |
2471 | ||
2472 | if (!WEB_DEMO_MODE) { | |
2473 | ||
f932bc9f | 2474 | $ids = split(",", db_escape_string($_GET["ids"])); |
48f0adb0 AD |
2475 | |
2476 | foreach ($ids as $id) { | |
2477 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
2478 | ||
2479 | } | |
2480 | } | |
2481 | } | |
2482 | ||
2483 | if ($subop == "add") { | |
2484 | ||
2485 | if (!WEB_DEMO_MODE) { | |
2486 | ||
4401bf04 AD |
2487 | // no escaping is done here on purpose |
2488 | $exp = trim($_GET["exp"]); | |
48f0adb0 AD |
2489 | |
2490 | $result = db_query($link, | |
4356293a AD |
2491 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) |
2492 | VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); | |
48f0adb0 AD |
2493 | } |
2494 | } | |
2495 | ||
2c7070b5 | 2496 | print "<div class=\"prefGenericAddBox\"> |
2371c520 AD |
2497 | <input size=\"40\" |
2498 | onkeyup=\"toggleSubmitNotEmpty(this, 'label_create_btn')\" | |
2499 | id=\"ladd_expr\"> "; | |
48f0adb0 | 2500 | |
2c7070b5 | 2501 | print"<input type=\"submit\" class=\"button\" |
2371c520 AD |
2502 | disabled=\"true\" id=\"label_create_btn\" |
2503 | onclick=\"javascript:addLabel()\" value=\"Create label\"></div>"; | |
48f0adb0 AD |
2504 | |
2505 | $result = db_query($link, "SELECT | |
2506 | id,sql_exp,description | |
2507 | FROM | |
4356293a AD |
2508 | ttrss_labels |
2509 | WHERE | |
2510 | owner_uid = ".$_SESSION["uid"]." | |
2511 | ORDER by description"); | |
48f0adb0 | 2512 | |
59a543f0 | 2513 | // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
d9dde1d6 | 2514 | |
3b0feb9b | 2515 | if (db_num_rows($result) != 0) { |
48f0adb0 | 2516 | |
f3120e5a AD |
2517 | print "<form id=\"label_edit_form\">"; |
2518 | ||
f4fe2cde AD |
2519 | print "<p><table width=\"100%\" cellspacing=\"0\" |
2520 | class=\"prefLabelList\" id=\"prefLabelList\">"; | |
35f3c923 AD |
2521 | |
2522 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2523 | Select: | |
ce3bf408 AD |
2524 | <a href=\"javascript:selectPrefRows('label', true)\">All</a>, |
2525 | <a href=\"javascript:selectPrefRows('label', false)\">None</a> | |
35f3c923 AD |
2526 | </td</tr>"; |
2527 | ||
3b0feb9b | 2528 | print "<tr class=\"title\"> |
673d54ca | 2529 | <td width=\"5%\"> </td> |
e325c6e7 | 2530 | <td width=\"40%\">SQL expression |
01c9c74a | 2531 | <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a> |
3b0feb9b AD |
2532 | </td> |
2533 | <td width=\"40%\">Caption</td></tr>"; | |
2534 | ||
2535 | $lnum = 0; | |
2536 | ||
2537 | while ($line = db_fetch_assoc($result)) { | |
2538 | ||
2539 | $class = ($lnum % 2) ? "even" : "odd"; | |
2540 | ||
2541 | $label_id = $line["id"]; | |
2542 | $edit_label_id = $_GET["id"]; | |
2543 | ||
2544 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
2545 | $class .= "Grayed"; | |
53226edc AD |
2546 | $this_row_id = ""; |
2547 | } else { | |
2548 | $this_row_id = "id=\"LILRR-$label_id\""; | |
3b0feb9b AD |
2549 | } |
2550 | ||
53226edc | 2551 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2552 | |
2553 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
2554 | $line["description"] = htmlspecialchars($line["description"]); | |
2555 | ||
2556 | if (!$edit_label_id || $subop != "edit") { | |
2557 | ||
2558 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
2559 | ||
ce3bf408 | 2560 | print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"label\");' |
3b0feb9b AD |
2561 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; |
2562 | ||
2563 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
2564 | $line["sql_exp"] . "</td>"; | |
48f0adb0 | 2565 | |
3b0feb9b AD |
2566 | print "<td><a href=\"javascript:editLabel($label_id);\">" . |
2567 | $line["description"] . "</td>"; | |
2568 | ||
2569 | } else if ($label_id != $edit_label_id) { | |
2570 | ||
2571 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2572 | ||
673d54ca | 2573 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
3b0feb9b AD |
2574 | id=\"LICHK-".$line["id"]."\"></td>"; |
2575 | ||
2576 | print "<td>".$line["sql_exp"]."</td>"; | |
2577 | print "<td>".$line["description"]."</td>"; | |
2578 | ||
2579 | } else { | |
2580 | ||
f3120e5a AD |
2581 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked>"; |
2582 | ||
2583 | print "<input type=\"hidden\" name=\"id\" value=\"$label_id\">"; | |
2584 | print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">"; | |
2585 | print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; | |
2586 | ||
2587 | print "</td>"; | |
3b0feb9b | 2588 | |
ac2cc246 AD |
2589 | print "<td><input onkeypress=\"return filterCR(event)\" |
2590 | class=\"iedit\" name=\"sql_exp\" value=\"".$line["sql_exp"]."\"></td>"; | |
3b0feb9b | 2591 | |
ac2cc246 AD |
2592 | print "<td><input onkeypress=\"return filterCR(event)\" |
2593 | class=\"iedit\" name=\"description\" value=\"".$line["description"]."\"></td>"; | |
3b0feb9b AD |
2594 | } |
2595 | ||
48f0adb0 | 2596 | |
3b0feb9b AD |
2597 | print "</tr>"; |
2598 | ||
2599 | ++$lnum; | |
2600 | } | |
2601 | ||
2602 | if ($lnum == 0) { | |
2603 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
2604 | } | |
2605 | ||
2606 | print "</table>"; | |
f3120e5a AD |
2607 | |
2608 | print "</form>"; | |
3b0feb9b | 2609 | |
ce3bf408 | 2610 | print "<p id=\"labelOpToolbar\">"; |
3b0feb9b AD |
2611 | |
2612 | if ($subop == "edit") { | |
2613 | print "Edit label: | |
d9dde1d6 AD |
2614 | <input type=\"submit\" class=\"button\" |
2615 | onclick=\"javascript:labelTest()\" value=\"Test\"> | |
3b0feb9b | 2616 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2617 | onclick=\"javascript:labelEditSave()\" value=\"Save\"> |
3b0feb9b | 2618 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2619 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">"; |
3b0feb9b | 2620 | |
ce3bf408 | 2621 | } else { |
3b0feb9b AD |
2622 | print " |
2623 | Selection: | |
ce3bf408 | 2624 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
3b0feb9b | 2625 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> |
ce3bf408 | 2626 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
3b0feb9b AD |
2627 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; |
2628 | } | |
48f0adb0 | 2629 | } else { |
3b0feb9b | 2630 | print "<p>No labels defined.</p>"; |
48f0adb0 AD |
2631 | } |
2632 | } | |
2633 | ||
e828e31e AD |
2634 | if ($op == "error") { |
2635 | print "<div width=\"100%\" align='center'>"; | |
2636 | $msg = $_GET["msg"]; | |
2637 | print $msg; | |
2638 | print "</div>"; | |
2639 | } | |
2640 | ||
7dc66a61 | 2641 | if ($op == "help") { |
01c9c74a AD |
2642 | if (!$_GET["noheaders"]) { |
2643 | print "<html><head> | |
2644 | <title>Tiny Tiny RSS : Help</title> | |
2645 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
86b682ce | 2646 | <script type=\"text/javascript\" src=\"prototype.js\"></script> |
53515ff1 | 2647 | <script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script> |
01c9c74a AD |
2648 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
2649 | </head><body>"; | |
2650 | } | |
7dc66a61 AD |
2651 | |
2652 | $tid = sprintf("%d", $_GET["tid"]); | |
2653 | ||
e5d758e3 AD |
2654 | print "<div id=\"infoBoxTitle\">Help</div>"; |
2655 | ||
01c9c74a | 2656 | print "<div class='infoBoxContents'>"; |
7dc66a61 | 2657 | |
01c9c74a AD |
2658 | if (file_exists("help/$tid.php")) { |
2659 | include("help/$tid.php"); | |
2660 | } else { | |
2661 | print "<p>Help topic not found.</p>"; | |
2662 | } | |
7dc66a61 | 2663 | |
01c9c74a | 2664 | print "</div>"; |
7dc66a61 AD |
2665 | |
2666 | print "<div align='center'> | |
01c9c74a AD |
2667 | <input type='submit' class='button' |
2668 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
7dc66a61 | 2669 | |
01c9c74a AD |
2670 | if (!$_GET["noheaders"]) { |
2671 | print "</body></html>"; | |
2672 | } | |
7dc66a61 AD |
2673 | |
2674 | } | |
2675 | ||
f84a97a3 AD |
2676 | if ($op == "dlg") { |
2677 | $id = $_GET["id"]; | |
6de5d056 | 2678 | $param = $_GET["param"]; |
f84a97a3 AD |
2679 | |
2680 | if ($id == "quickAddFeed") { | |
e5d758e3 AD |
2681 | |
2682 | print "<div id=\"infoBoxTitle\">Subscribe to feed</div>"; | |
2683 | print "<div class=\"infoBoxContents\">"; | |
2684 | ||
07eb9178 AD |
2685 | print "<form id='feed_add_form'>"; |
2686 | ||
2687 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
2688 | print "<input type=\"hidden\" name=\"quiet\" value=\"1\">"; | |
2689 | print "<input type=\"hidden\" name=\"subop\" value=\"add\">"; | |
2690 | ||
e5d758e3 AD |
2691 | print "<table width='100%'> |
2692 | <tr><td>Feed URL:</td><td> | |
07eb9178 | 2693 | <input class=\"iedit\" onblur=\"javascript:enableHotkeys()\" |
ac2cc246 | 2694 | onkeypress=\"return filterCR(event)\" |
2371c520 | 2695 | onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\" |
07eb9178 | 2696 | onfocus=\"javascript:disableHotkeys()\" name=\"feed_url\"></td></tr>"; |
15da5cc1 AD |
2697 | |
2698 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
e5d758e3 | 2699 | print "<tr><td>Category:</td><td>"; |
07eb9178 | 2700 | print_feed_cat_select($link, "cat_id"); |
e5d758e3 | 2701 | print "</td></tr>"; |
15da5cc1 | 2702 | } |
07eb9178 AD |
2703 | |
2704 | print "</table>"; | |
2705 | print "</form>"; | |
2706 | ||
2707 | print "<div align='right'> | |
2371c520 AD |
2708 | <input class=\"button\" |
2709 | id=\"fadd_submit_btn\" disabled=\"true\" | |
2710 | type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Subscribe\"> | |
2711 | <input class=\"button\" | |
07eb9178 AD |
2712 | type=\"submit\" onclick=\"javascript:closeInfoBox()\" |
2713 | value=\"Cancel\"></div>"; | |
c14b5566 | 2714 | |
f84a97a3 | 2715 | } |
6de5d056 | 2716 | |
033e47e0 AD |
2717 | if ($id == "search") { |
2718 | ||
e5d758e3 AD |
2719 | print "<div id=\"infoBoxTitle\">Search</div>"; |
2720 | print "<div class=\"infoBoxContents\">"; | |
2721 | ||
86b682ce AD |
2722 | print "<form id='search_form'>"; |
2723 | ||
49b7cbd3 AD |
2724 | $active_feed_id = db_escape_string($_GET["param"]); |
2725 | ||
e5d758e3 | 2726 | print "<table width='100%'><tr><td>Search:</td><td>"; |
86b682ce AD |
2727 | |
2728 | print "<input name=\"query\" class=\"iedit\" | |
2729 | onkeypress=\"return filterCR(event)\" | |
2371c520 | 2730 | onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\" |
86b682ce AD |
2731 | value=\"\"> |
2732 | </td></tr>"; | |
2733 | ||
2734 | print "<tr><td>Where:</td><td>"; | |
2735 | ||
2736 | print "<select name=\"search_mode\"> | |
2737 | <option value=\"all_feeds\">All feeds</option>"; | |
2738 | ||
2739 | $feed_title = getFeedTitle($link, $active_feed_id); | |
2740 | $feed_cat_title = getFeedCatTitle($link, $active_feed_id); | |
2741 | ||
49b7cbd3 | 2742 | if ($active_feed_id) { |
86b682ce | 2743 | print "<option selected value=\"this_feed\">This feed ($feed_title)</option>"; |
49b7cbd3 AD |
2744 | } else { |
2745 | print "<option disabled>This feed</option>"; | |
2746 | } | |
b0005823 | 2747 | |
86b682ce AD |
2748 | if (get_pref($link, 'ENABLE_FEED_CATS') && $active_feed_id && $active_feed_id > 0) { |
2749 | print "<option value=\"this_cat\">This category ($feed_cat_title)</option>"; | |
2750 | } else { | |
2751 | print "<option disabled>This category</option>"; | |
b0005823 AD |
2752 | } |
2753 | ||
86b682ce AD |
2754 | print "</select></td></tr>"; |
2755 | ||
2756 | print "<tr><td>Match on:</td><td>"; | |
2757 | ||
2758 | $search_fields = array( | |
2759 | "title" => "Title", | |
2760 | "content" => "Content", | |
2761 | "both" => "Title or content"); | |
e5d758e3 | 2762 | |
86b682ce AD |
2763 | print_select_hash("match_on", 3, $search_fields); |
2764 | ||
2765 | print "</td></tr></table>"; | |
2766 | ||
2767 | print "</form>"; | |
2768 | ||
2769 | print "<div align=\"right\"> | |
033e47e0 | 2770 | <input type=\"submit\" |
2371c520 AD |
2771 | class=\"button\" onclick=\"javascript:search()\" |
2772 | id=\"search_submit_btn\" disabled=\"true\" | |
2773 | value=\"Search\"> | |
033e47e0 | 2774 | <input class=\"button\" |
86b682ce AD |
2775 | type=\"submit\" onclick=\"javascript:searchCancel()\" |
2776 | value=\"Cancel\"></div>"; | |
2777 | ||
2778 | print "</div>"; | |
033e47e0 AD |
2779 | |
2780 | } | |
2781 | ||
a24f525c AD |
2782 | if ($id == "quickAddFilter") { |
2783 | ||
757e8a2d AD |
2784 | $active_feed_id = db_escape_string($_GET["param"]); |
2785 | ||
e5d758e3 AD |
2786 | print "<div id=\"infoBoxTitle\">Create filter</div>"; |
2787 | print "<div class=\"infoBoxContents\">"; | |
2788 | ||
79f3553b AD |
2789 | print "<form id=\"filter_add_form\">"; |
2790 | ||
2791 | print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">"; | |
2792 | print "<input type=\"hidden\" name=\"quiet\" value=\"1\">"; | |
c14b5566 | 2793 | print "<input type=\"hidden\" name=\"subop\" value=\"add\">"; |
79f3553b | 2794 | |
c6932f8d | 2795 | // print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>"; |
757e8a2d | 2796 | |
79f3553b | 2797 | $result = db_query($link, "SELECT id,description |
a24f525c AD |
2798 | FROM ttrss_filter_types ORDER BY description"); |
2799 | ||
2800 | $filter_types = array(); | |
2801 | ||
2802 | while ($line = db_fetch_assoc($result)) { | |
79f3553b AD |
2803 | //array_push($filter_types, $line["description"]); |
2804 | $filter_types[$line["id"]] = $line["description"]; | |
a24f525c AD |
2805 | } |
2806 | ||
e5d758e3 | 2807 | print "<table width='100%'>"; |
a24f525c | 2808 | |
2371c520 | 2809 | print "<tr><td>Match:</td> |
86b682ce AD |
2810 | <td><input onkeypress=\"return filterCR(event)\" |
2811 | onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\" | |
4220b0bd AD |
2812 | name=\"reg_exp\" class=\"iedit\">"; |
2813 | print "</td><td>"; | |
2814 | ||
2815 | print_select_hash("filter_type", 1, $filter_types, "class=\"iedit\""); | |
a24f525c AD |
2816 | |
2817 | print "</td></tr>"; | |
4220b0bd | 2818 | print "<tr><td>Feed:</td><td colspan='2'>"; |
673d54ca | 2819 | |
757e8a2d | 2820 | print_feed_select($link, "feed_id", $active_feed_id); |
673d54ca AD |
2821 | |
2822 | print "</td></tr>"; | |
a24f525c AD |
2823 | |
2824 | print "<tr><td>Action:</td>"; | |
2825 | ||
4220b0bd | 2826 | print "<td colspan='2'><select name=\"action_id\">"; |
a24f525c AD |
2827 | |
2828 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2829 | ORDER BY name"); | |
2830 | ||
2831 | while ($line = db_fetch_assoc($result)) { | |
79f3553b | 2832 | printf("<option value='%d'>%s</option>", $line["id"], $line["description"]); |
a24f525c AD |
2833 | } |
2834 | ||
2835 | print "</select>"; | |
c14b5566 AD |
2836 | |
2837 | print "</td></tr></table>"; | |
2838 | ||
2839 | print "</form>"; | |
2840 | ||
2841 | print "<div align='right'>"; | |
2842 | ||
a24f525c | 2843 | print "<input type=\"submit\" |
2371c520 | 2844 | id=\"infobox_submit\" |
c14b5566 | 2845 | class=\"button\" onclick=\"qaddFilter()\" |
2371c520 | 2846 | disabled=\"true\" value=\"Create\"> "; |
a24f525c AD |
2847 | |
2848 | print "<input class=\"button\" | |
c14b5566 | 2849 | type=\"submit\" onclick=\"closeInfoBox()\" |
e5d758e3 | 2850 | value=\"Cancel\">"; |
a24f525c | 2851 | |
c14b5566 | 2852 | print "</div>"; |
e5d758e3 | 2853 | |
c14b5566 | 2854 | // print "</td></tr></table>"; |
79f3553b | 2855 | |
a24f525c | 2856 | } |
7b5c6012 AD |
2857 | |
2858 | print "</div>"; | |
2859 | ||
f84a97a3 AD |
2860 | } |
2861 | ||
a2770077 AD |
2862 | // update feeds of all users, may be used anonymously |
2863 | if ($op == "globalUpdateFeeds") { | |
2864 | ||
2865 | $result = db_query($link, "SELECT id FROM ttrss_users"); | |
2866 | ||
2867 | while ($line = db_fetch_assoc($result)) { | |
2868 | $user_id = $line["id"]; | |
2869 | // print "<!-- updating feeds of uid $user_id -->"; | |
2870 | update_all_feeds($link, false, $user_id); | |
2871 | } | |
e65af9c1 | 2872 | |
a2770077 AD |
2873 | print "<rpc-reply> |
2874 | <message msg=\"All feeds updated\"/> | |
2875 | </rpc-reply>"; | |
e65af9c1 AD |
2876 | |
2877 | } | |
2878 | ||
77e96719 AD |
2879 | if ($op == "pref-prefs") { |
2880 | ||
b1895692 | 2881 | $subop = $_REQUEST["subop"]; |
77e96719 AD |
2882 | |
2883 | if ($subop == "Save configuration") { | |
2884 | ||
d2892032 AD |
2885 | if (WEB_DEMO_MODE) { |
2886 | header("Location: prefs.php"); | |
2887 | return; | |
2888 | } | |
01d68cf9 | 2889 | |
93cb4442 AD |
2890 | $_SESSION["prefs_op_result"] = "save-config"; |
2891 | ||
11de82c3 AD |
2892 | $_SESSION["prefs_cache"] = false; |
2893 | ||
77e96719 AD |
2894 | foreach (array_keys($_POST) as $pref_name) { |
2895 | ||
2896 | $pref_name = db_escape_string($pref_name); | |
2897 | $value = db_escape_string($_POST[$pref_name]); | |
2898 | ||
2899 | $result = db_query($link, "SELECT type_name | |
2900 | FROM ttrss_prefs,ttrss_prefs_types | |
2901 | WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id"); | |
2902 | ||
2903 | if (db_num_rows($result) > 0) { | |
2904 | ||
2905 | $type_name = db_fetch_result($result, 0, "type_name"); | |
2906 | ||
5da169d9 AD |
2907 | // print "$pref_name : $type_name : $value<br>"; |
2908 | ||
77e96719 | 2909 | if ($type_name == "bool") { |
5da169d9 | 2910 | if ($value == "1") { |
77e96719 AD |
2911 | $value = "true"; |
2912 | } else { | |
2913 | $value = "false"; | |
2914 | } | |
2915 | } else if ($type_name == "integer") { | |
2916 | $value = sprintf("%d", $value); | |
2917 | } | |
2918 | ||
2919 | // print "$pref_name : $type_name : $value<br>"; | |
2920 | ||
ff485f1d AD |
2921 | db_query($link, "UPDATE ttrss_user_prefs SET value = '$value' |
2922 | WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]); | |
77e96719 AD |
2923 | |
2924 | } | |
2925 | ||
2926 | header("Location: prefs.php"); | |
2927 | ||
2928 | } | |
2929 | ||
b1895692 AD |
2930 | } else if ($subop == "getHelp") { |
2931 | ||
2932 | $pref_name = db_escape_string($_GET["pn"]); | |
2933 | ||
2934 | $result = db_query($link, "SELECT help_text FROM ttrss_prefs | |
2935 | WHERE pref_name = '$pref_name'"); | |
2936 | ||
2937 | if (db_num_rows($result) > 0) { | |
2938 | $help_text = db_fetch_result($result, 0, "help_text"); | |
2939 | print $help_text; | |
2940 | } else { | |
2941 | print "Unknown option: $pref_name"; | |
2942 | } | |
2943 | ||
cbb01696 AD |
2944 | } else if ($subop == "Change e-mail") { |
2945 | ||
2946 | if (WEB_DEMO_MODE) { | |
2947 | header("Location: prefs.php"); | |
2948 | return; | |
2949 | } | |
2950 | ||
2951 | $email = db_escape_string($_GET["email"]); | |
2952 | $active_uid = $_SESSION["uid"]; | |
2953 | ||
2954 | if ($email) { | |
2955 | db_query($link, "UPDATE ttrss_users SET email = '$email' | |
2956 | WHERE id = '$active_uid'"); | |
2957 | } | |
2958 | ||
2959 | header("Location: prefs.php"); | |
2960 | ||
1c7f75ed AD |
2961 | } else if ($subop == "Change password") { |
2962 | ||
d2892032 AD |
2963 | if (WEB_DEMO_MODE) { |
2964 | header("Location: prefs.php"); | |
2965 | return; | |
2966 | } | |
1c7f75ed AD |
2967 | |
2968 | $old_pw = $_POST["OLD_PASSWORD"]; | |
2969 | $new_pw = $_POST["OLD_PASSWORD"]; | |
2970 | ||
2971 | $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]); | |
2972 | $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]); | |
2973 | ||
2974 | $active_uid = $_SESSION["uid"]; | |
2975 | ||
2976 | if ($old_pw && $new_pw) { | |
2977 | ||
2978 | $login = db_escape_string($_SERVER['PHP_AUTH_USER']); | |
2979 | ||
2980 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
2981 | id = '$active_uid' AND (pwd_hash = '$old_pw' OR | |
2982 | pwd_hash = '$old_pw_hash')"); | |
2983 | ||
2984 | if (db_num_rows($result) == 1) { | |
2985 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash' | |
2986 | WHERE id = '$active_uid'"); | |
b791095d AD |
2987 | |
2988 | $_SESSION["pwd_change_result"] = "ok"; | |
2989 | } else { | |
2990 | $_SESSION["pwd_change_result"] = "failed"; | |
1c7f75ed AD |
2991 | } |
2992 | } | |
2993 | ||
2994 | header("Location: prefs.php"); | |
b791095d | 2995 | |
77e96719 AD |
2996 | } else if ($subop == "Reset to defaults") { |
2997 | ||
d2892032 AD |
2998 | if (WEB_DEMO_MODE) { |
2999 | header("Location: prefs.php"); | |
3000 | return; | |
3001 | } | |
01d68cf9 | 3002 | |
93cb4442 AD |
3003 | $_SESSION["prefs_op_result"] = "reset-to-defaults"; |
3004 | ||
e1aa0559 AD |
3005 | if (DB_TYPE == "pgsql") { |
3006 | db_query($link,"UPDATE ttrss_user_prefs | |
3007 | SET value = ttrss_prefs.def_value | |
3008 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
3009 | ttrss_prefs.pref_name = ttrss_user_prefs.pref_name"); | |
3010 | } else { | |
3011 | db_query($link, "DELETE FROM ttrss_user_prefs | |
3012 | WHERE owner_uid = ".$_SESSION["uid"]); | |
3013 | initialize_user_prefs($link, $_SESSION["uid"]); | |
3014 | } | |
5da169d9 | 3015 | |
77e96719 AD |
3016 | header("Location: prefs.php"); |
3017 | ||
58f8ad54 AD |
3018 | } else if ($subop == "Change theme") { |
3019 | ||
3020 | $theme = db_escape_string($_POST["theme"]); | |
3021 | ||
3022 | if ($theme == "Default") { | |
3023 | $theme_qpart = 'NULL'; | |
3024 | } else { | |
3025 | $theme_qpart = "'$theme'"; | |
3026 | } | |
3027 | ||
6752e330 AD |
3028 | $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes |
3029 | WHERE theme_name = '$theme'"); | |
3030 | ||
3031 | if (db_num_rows($result) == 1) { | |
3032 | $theme_id = db_fetch_result($result, 0, "id"); | |
3033 | $theme_path = db_fetch_result($result, 0, "theme_path"); | |
3034 | } else { | |
3035 | $theme_id = "NULL"; | |
3036 | $theme_path = ""; | |
3037 | } | |
3038 | ||
58f8ad54 | 3039 | db_query($link, "UPDATE ttrss_users SET |
6752e330 | 3040 | theme_id = $theme_id WHERE id = " . $_SESSION["uid"]); |
58f8ad54 | 3041 | |
6752e330 | 3042 | $_SESSION["theme"] = $theme_path; |
503eb349 | 3043 | |
58f8ad54 AD |
3044 | header("Location: prefs.php"); |
3045 | ||
77e96719 AD |
3046 | } else { |
3047 | ||
7d4c898a | 3048 | if (!SINGLE_USER_MODE) { |
1c7f75ed | 3049 | |
cbb01696 | 3050 | $result = db_query($link, "SELECT id,email FROM ttrss_users |
a029d530 AD |
3051 | WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR |
3052 | pwd_hash = 'SHA1:".sha1("password")."')"); | |
3053 | ||
3054 | if (db_num_rows($result) != 0) { | |
b791095d | 3055 | print "<div class=\"warning\"> |
a029d530 AD |
3056 | Your password is at default value, please change it. |
3057 | </div>"; | |
3058 | } | |
3059 | ||
b791095d AD |
3060 | if ($_SESSION["pwd_change_result"] == "failed") { |
3061 | print "<div class=\"warning\"> | |
3062 | There was an error while changing your password. | |
3063 | </div>"; | |
3064 | } | |
3065 | ||
3066 | if ($_SESSION["pwd_change_result"] == "ok") { | |
3067 | print "<div class=\"notice\"> | |
3068 | Password changed successfully. | |
3069 | </div>"; | |
3070 | } | |
3071 | ||
3072 | $_SESSION["pwd_change_result"] = ""; | |
3073 | ||
93cb4442 AD |
3074 | if ($_SESSION["prefs_op_result"] == "reset-to-defaults") { |
3075 | print "<div class=\"notice\"> | |
3076 | Your configuration was reset to defaults. | |
3077 | </div>"; | |
3078 | } | |
3079 | ||
3080 | if ($_SESSION["prefs_op_result"] == "save-config") { | |
3081 | print "<div class=\"notice\"> | |
3082 | Your configuration was saved successfully. | |
3083 | </div>"; | |
3084 | } | |
3085 | ||
3086 | $_SESSION["prefs_op_result"] = ""; | |
3087 | ||
cbb01696 AD |
3088 | print "<form action=\"backend.php\" method=\"GET\">"; |
3089 | ||
3090 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3091 | print "<tr><td colspan='3'><h3>Personal data</h3></tr></td>"; | |
3092 | ||
3093 | $result = db_query($link, "SELECT email FROM ttrss_users | |
3094 | WHERE id = ".$_SESSION["uid"]); | |
3095 | ||
3096 | $email = db_fetch_result($result, 0, "email"); | |
3097 | ||
3098 | print "<tr><td width=\"40%\">E-mail</td>"; | |
3099 | print "<td><input class=\"editbox\" name=\"email\" | |
3100 | value=\"$email\"></td></tr>"; | |
3101 | ||
3102 | print "</table>"; | |
3103 | ||
3104 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3105 | ||
3106 | print "<p><input class=\"button\" type=\"submit\" | |
3107 | value=\"Change e-mail\" name=\"subop\">"; | |
3108 | ||
a132b8b1 AD |
3109 | print "</form>"; |
3110 | ||
64dc5976 | 3111 | print "<form action=\"backend.php\" method=\"POST\" name=\"changePassForm\">"; |
7d4c898a AD |
3112 | |
3113 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3114 | print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>"; | |
3115 | ||
3116 | print "<tr><td width=\"40%\">Old password</td>"; | |
3117 | print "<td><input class=\"editbox\" type=\"password\" | |
3118 | name=\"OLD_PASSWORD\"></td></tr>"; | |
3119 | ||
3120 | print "<tr><td width=\"40%\">New password</td>"; | |
3121 | ||
3122 | print "<td><input class=\"editbox\" type=\"password\" | |
3123 | name=\"NEW_PASSWORD\"></td></tr>"; | |
3124 | ||
3125 | print "</table>"; | |
3126 | ||
3127 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3128 | ||
3129 | print "<p><input class=\"button\" type=\"submit\" | |
64dc5976 | 3130 | onclick=\"return validateNewPassword(this.form)\" |
7d4c898a AD |
3131 | value=\"Change password\" name=\"subop\">"; |
3132 | ||
3133 | print "</form>"; | |
1c7f75ed | 3134 | |
7d4c898a | 3135 | } |
1c7f75ed | 3136 | |
58f8ad54 AD |
3137 | $result = db_query($link, "SELECT |
3138 | theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]); | |
3139 | ||
3140 | $user_theme_id = db_fetch_result($result, 0, "theme_id"); | |
3141 | ||
3142 | $result = db_query($link, "SELECT | |
3143 | id,theme_name FROM ttrss_themes ORDER BY theme_name"); | |
3144 | ||
3145 | if (db_num_rows($result) > 0) { | |
6752e330 AD |
3146 | |
3147 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3148 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3149 | print "<tr><td colspan='3'><h3>Themes</h3></tr></td>"; | |
3150 | print "<tr><td width=\"40%\">Select theme</td>"; | |
3151 | print "<td><select name=\"theme\">"; | |
3152 | print "<option>Default</option>"; | |
58f8ad54 | 3153 | print "<option disabled>--------</option>"; |
6752e330 | 3154 | |
58f8ad54 AD |
3155 | while ($line = db_fetch_assoc($result)) { |
3156 | if ($line["id"] == $user_theme_id) { | |
3157 | $selected = "selected"; | |
3158 | } else { | |
3159 | $selected = ""; | |
3160 | } | |
3161 | print "<option $selected>" . $line["theme_name"] . "</option>"; | |
3162 | } | |
6752e330 AD |
3163 | print "</select></td></tr>"; |
3164 | print "</table>"; | |
3165 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3166 | print "<p><input class=\"button\" type=\"submit\" | |
3167 | value=\"Change theme\" name=\"subop\">"; | |
3168 | print "</form>"; | |
58f8ad54 AD |
3169 | } |
3170 | ||
77e96719 | 3171 | $result = db_query($link, "SELECT |
ff485f1d | 3172 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, |
77e96719 | 3173 | section_name,def_value |
ff485f1d | 3174 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs |
77e96719 | 3175 | WHERE type_id = ttrss_prefs_types.id AND |
ff485f1d | 3176 | section_id = ttrss_prefs_sections.id AND |
a2411bd9 AD |
3177 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND |
3178 | owner_uid = ".$_SESSION["uid"]." | |
650bc435 | 3179 | ORDER BY section_id,short_desc"); |
77e96719 AD |
3180 | |
3181 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3182 | ||
77e96719 AD |
3183 | $lnum = 0; |
3184 | ||
3185 | $active_section = ""; | |
3186 | ||
3187 | while ($line = db_fetch_assoc($result)) { | |
3188 | ||
3189 | if ($active_section != $line["section_name"]) { | |
59a654ba AD |
3190 | |
3191 | if ($active_section != "") { | |
1c7f75ed | 3192 | print "</table>"; |
59a654ba | 3193 | } |
1c7f75ed AD |
3194 | |
3195 | print "<p><table width=\"100%\" class=\"prefPrefsList\">"; | |
59a654ba AD |
3196 | |
3197 | $active_section = $line["section_name"]; | |
3198 | ||
77e96719 | 3199 | print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>"; |
59a654ba AD |
3200 | // print "<tr class=\"title\"> |
3201 | // <td width=\"25%\">Option</td><td>Value</td></tr>"; | |
7268adf7 AD |
3202 | |
3203 | $lnum = 0; | |
77e96719 AD |
3204 | } |
3205 | ||
650bc435 | 3206 | // $class = ($lnum % 2) ? "even" : "odd"; |
77e96719 | 3207 | |
650bc435 | 3208 | print "<tr>"; |
77e96719 | 3209 | |
77e96719 AD |
3210 | $type_name = $line["type_name"]; |
3211 | $pref_name = $line["pref_name"]; | |
3212 | $value = $line["value"]; | |
3213 | $def_value = $line["def_value"]; | |
b1895692 AD |
3214 | $help_text = $line["help_text"]; |
3215 | ||
3216 | print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"]; | |
3217 | ||
3218 | if ($help_text) print "<div class=\"prefHelp\">$help_text</div>"; | |
3219 | ||
3220 | print "</td>"; | |
77e96719 AD |
3221 | |
3222 | print "<td>"; | |
3223 | ||
3224 | if ($type_name == "bool") { | |
3225 | // print_select($pref_name, $value, array("true", "false")); | |
3226 | ||
3227 | if ($value == "true") { | |
3228 | $value = "Yes"; | |
3229 | } else { | |
3230 | $value = "No"; | |
3231 | } | |
3232 | ||
3233 | print_radio($pref_name, $value, array("Yes", "No")); | |
3234 | ||
3235 | } else { | |
3236 | print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">"; | |
3237 | } | |
3238 | ||
3239 | print "</td>"; | |
3240 | ||
3241 | print "</tr>"; | |
3242 | ||
3243 | $lnum++; | |
3244 | } | |
3245 | ||
3246 | print "</table>"; | |
3247 | ||
3248 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3249 | ||
3250 | print "<p><input class=\"button\" type=\"submit\" | |
3251 | name=\"subop\" value=\"Save configuration\">"; | |
3252 | ||
3253 | print " <input class=\"button\" type=\"submit\" | |
69668465 AD |
3254 | name=\"subop\" onclick=\"return validatePrefsReset()\" |
3255 | value=\"Reset to defaults\"></p>"; | |
77e96719 AD |
3256 | |
3257 | print "</form>"; | |
3258 | ||
3259 | } | |
3260 | ||
3261 | } | |
3262 | ||
e6cb77a0 AD |
3263 | if ($op == "pref-users") { |
3264 | ||
3265 | $subop = $_GET["subop"]; | |
3266 | ||
3c5783b7 AD |
3267 | if ($subop == "edit") { |
3268 | ||
3269 | $id = db_escape_string($_GET["id"]); | |
3270 | ||
3271 | print "<div id=\"infoBoxTitle\">User editor</div>"; | |
3272 | ||
3273 | print "<div class=\"infoBoxContents\">"; | |
3274 | ||
3275 | print "<form id=\"user_edit_form\">"; | |
3276 | ||
3277 | print "<input type=\"hidden\" name=\"id\" value=\"$id\">"; | |
3278 | print "<input type=\"hidden\" name=\"op\" value=\"pref-users\">"; | |
3279 | print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; | |
3280 | ||
3281 | $result = db_query($link, "SELECT * FROM ttrss_users WHERE id = '$id'"); | |
3282 | ||
3283 | $login = db_fetch_result($result, 0, "login"); | |
3284 | $access_level = db_fetch_result($result, 0, "access_level"); | |
3285 | $email = db_fetch_result($result, 0, "email"); | |
3286 | ||
3287 | print "<table width='100%'>"; | |
3288 | print "<tr><td>Login:</td><td> | |
ac2cc246 AD |
3289 | <input class=\"iedit\" onkeypress=\"return filterCR(event)\" |
3290 | name=\"login\" value=\"$login\"></td></tr>"; | |
3c5783b7 AD |
3291 | |
3292 | print "<tr><td>Change password:</td><td> | |
ac2cc246 AD |
3293 | <input class=\"iedit\" onkeypress=\"return filterCR(event)\" |
3294 | name=\"password\"></td></tr>"; | |
3c5783b7 AD |
3295 | |
3296 | print "<tr><td>E-mail:</td><td> | |
ac2cc246 AD |
3297 | <input class=\"iedit\" name=\"email\" onkeypress=\"return filterCR(event)\" |
3298 | value=\"$email\"></td></tr>"; | |
3c5783b7 AD |
3299 | |
3300 | $sel_disabled = ($id == $_SESSION["uid"]) ? "disabled" : ""; | |
3301 | ||
3302 | print "<tr><td>Access level:</td><td>"; | |
3303 | print_select_hash("access_level", $access_level, $access_level_names, | |
3304 | $sel_disabled); | |
3305 | print "</td></tr>"; | |
3306 | ||
3307 | print "</table>"; | |
3308 | ||
3309 | print "</form>"; | |
3310 | ||
3311 | print "<div align='right'> | |
3312 | <input class=\"button\" | |
3313 | type=\"submit\" onclick=\"javascript:userEditSave()\" value=\"Save\"> | |
3314 | <input class=\"button\" | |
3315 | type=\"submit\" onclick=\"javascript:userEditCancel()\" | |
3316 | value=\"Cancel\"></div>"; | |
3317 | ||
3318 | print "</div>"; | |
3319 | ||
3320 | return; | |
3321 | } | |
3322 | ||
e6cb77a0 AD |
3323 | if ($subop == "editSave") { |
3324 | ||
3c5783b7 | 3325 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { |
e6cb77a0 | 3326 | |
3c5783b7 | 3327 | $login = db_escape_string(trim($_GET["login"])); |
e6cb77a0 | 3328 | $uid = db_escape_string($_GET["id"]); |
3c5783b7 AD |
3329 | $access_level = sprintf("%d", $_GET["access_level"]); |
3330 | $email = db_escape_string(trim($_GET["email"])); | |
3331 | $password = db_escape_string(trim($_GET["password"])); | |
3332 | ||
3333 | if ($password) { | |
3334 | $pwd_hash = 'SHA1:' . sha1($password); | |
3335 | $pass_query_part = "pwd_hash = '$pwd_hash', "; | |
3336 | print "<div class='notice'>Changed password for user <b>$login</b>.</div>"; | |
3337 | } else { | |
3338 | $pass_query_part = ""; | |
3339 | } | |
e6cb77a0 | 3340 | |
3c5783b7 | 3341 | db_query($link, "UPDATE ttrss_users SET $pass_query_part login = '$login', |
72932a75 | 3342 | access_level = '$access_level', email = '$email' WHERE id = '$uid'"); |
e6cb77a0 AD |
3343 | |
3344 | } | |
3345 | } else if ($subop == "remove") { | |
3346 | ||
3347 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3348 | ||
f932bc9f | 3349 | $ids = split(",", db_escape_string($_GET["ids"])); |
e6cb77a0 AD |
3350 | |
3351 | foreach ($ids as $id) { | |
3352 | db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]); | |
3353 | ||
3354 | } | |
3355 | } | |
3356 | } else if ($subop == "add") { | |
3357 | ||
3358 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3359 | ||
b6b535ca | 3360 | $login = db_escape_string(trim($_GET["login"])); |
e6cb77a0 AD |
3361 | $tmp_user_pwd = make_password(8); |
3362 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3363 | ||
e6cb77a0 | 3364 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE |
ce3bf408 | 3365 | login = '$login'"); |
e6cb77a0 | 3366 | |
ce3bf408 | 3367 | if (db_num_rows($result) == 0) { |
e6cb77a0 | 3368 | |
ce3bf408 AD |
3369 | db_query($link, "INSERT INTO ttrss_users |
3370 | (login,pwd_hash,access_level,last_login) | |
3371 | VALUES ('$login', '$pwd_hash', 0, NOW())"); | |
3372 | ||
3373 | ||
3374 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3375 | login = '$login' AND pwd_hash = '$pwd_hash'"); | |
3376 | ||
3377 | if (db_num_rows($result) == 1) { | |
3378 | ||
3379 | $new_uid = db_fetch_result($result, 0, "id"); | |
3380 | ||
3381 | print "<div class=\"notice\">Added user <b>".$_GET["login"]. | |
3382 | "</b> with password <b>$tmp_user_pwd</b>.</div>"; | |
3383 | ||
3384 | initialize_user($link, $new_uid); | |
3385 | ||
3386 | } else { | |
3387 | ||
3388 | print "<div class=\"warning\">Could not create user <b>". | |
3389 | $_GET["login"]."</b></div>"; | |
3390 | ||
3391 | } | |
e6cb77a0 | 3392 | } else { |
ce3bf408 AD |
3393 | print "<div class=\"warning\">User <b>". |
3394 | $_GET["login"]."</b> already exists.</div>"; | |
e6cb77a0 AD |
3395 | } |
3396 | } | |
3397 | } else if ($subop == "resetPass") { | |
3398 | ||
3399 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3400 | ||
3401 | $uid = db_escape_string($_GET["id"]); | |
3402 | ||
72932a75 AD |
3403 | $result = db_query($link, "SELECT login,email |
3404 | FROM ttrss_users WHERE id = '$uid'"); | |
e6cb77a0 AD |
3405 | |
3406 | $login = db_fetch_result($result, 0, "login"); | |
72932a75 | 3407 | $email = db_fetch_result($result, 0, "email"); |
e6cb77a0 AD |
3408 | $tmp_user_pwd = make_password(8); |
3409 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3410 | ||
3411 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash' | |
3412 | WHERE id = '$uid'"); | |
3413 | ||
3414 | print "<div class=\"notice\">Changed password of | |
72932a75 AD |
3415 | user <b>$login</b> to <b>$tmp_user_pwd</b>."; |
3416 | ||
3417 | if (MAIL_RESET_PASS && $email) { | |
3418 | print " Notifying <b>$email</b>."; | |
3419 | ||
3420 | mail("$login <$email>", "Password reset notification", | |
3421 | "Hi, $login.\n". | |
3422 | "\n". | |
3423 | "Your password for this TT-RSS installation was reset by". | |
3424 | " an administrator.\n". | |
3425 | "\n". | |
3426 | "Your new password is $tmp_user_pwd, please remember". | |
3427 | " it for later reference.\n". | |
3428 | "\n". | |
3429 | "Sincerely, TT-RSS Mail Daemon.", "From: " . MAIL_FROM); | |
3430 | } | |
3431 | ||
3432 | print "</div>"; | |
e6cb77a0 AD |
3433 | |
3434 | } | |
3435 | } | |
3436 | ||
2c7070b5 | 3437 | print "<div class=\"prefGenericAddBox\"> |
2371c520 AD |
3438 | <input id=\"uadd_box\" |
3439 | onkeyup=\"toggleSubmitNotEmpty(this, 'user_add_btn')\" | |
292a8a12 | 3440 | size=\"40\"> "; |
e6cb77a0 | 3441 | |
2c7070b5 | 3442 | print"<input type=\"submit\" class=\"button\" |
2371c520 AD |
3443 | id=\"user_add_btn\" disabled=\"true\" |
3444 | onclick=\"javascript:addUser()\" value=\"Create user\"></div>"; | |
e6cb77a0 AD |
3445 | |
3446 | $result = db_query($link, "SELECT | |
72932a75 | 3447 | id,login,access_level,email, |
fe99ab12 | 3448 | SUBSTRING(last_login,1,16) as last_login |
e6cb77a0 AD |
3449 | FROM |
3450 | ttrss_users | |
3451 | ORDER by login"); | |
3452 | ||
59a543f0 | 3453 | // print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
1a7572cb | 3454 | |
f4fe2cde AD |
3455 | print "<p><table width=\"100%\" cellspacing=\"0\" |
3456 | class=\"prefUserList\" id=\"prefUserList\">"; | |
e6cb77a0 | 3457 | |
35f3c923 AD |
3458 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
3459 | Select: | |
ce3bf408 AD |
3460 | <a href=\"javascript:selectPrefRows('user', true)\">All</a>, |
3461 | <a href=\"javascript:selectPrefRows('user', false)\">None</a> | |
35f3c923 AD |
3462 | </td</tr>"; |
3463 | ||
e6cb77a0 | 3464 | print "<tr class=\"title\"> |
e325c6e7 | 3465 | <td align='center' width=\"5%\"> </td> |
3c5783b7 AD |
3466 | <td width='40%'>Login</td> |
3467 | <td width='40%'>Access Level</td> | |
3468 | <td width='30%'>Last login</td></tr>"; | |
e6cb77a0 AD |
3469 | |
3470 | $lnum = 0; | |
3471 | ||
3472 | while ($line = db_fetch_assoc($result)) { | |
3473 | ||
3474 | $class = ($lnum % 2) ? "even" : "odd"; | |
3475 | ||
3476 | $uid = $line["id"]; | |
3477 | $edit_uid = $_GET["id"]; | |
3478 | ||
4154a415 | 3479 | if ($subop == "edit" && $uid != $edit_uid) { |
e6cb77a0 | 3480 | $class .= "Grayed"; |
53226edc AD |
3481 | $this_row_id = ""; |
3482 | } else { | |
3483 | $this_row_id = "id=\"UMRR-$uid\""; | |
3484 | } | |
3485 | ||
3486 | print "<tr class=\"$class\" $this_row_id>"; | |
e6cb77a0 AD |
3487 | |
3488 | $line["login"] = htmlspecialchars($line["login"]); | |
3489 | ||
6be6bc03 AD |
3490 | $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'), |
3491 | strtotime($line["last_login"])); | |
3492 | ||
5917a8e4 AD |
3493 | $access_level_names = array(0 => "User", 10 => "Administrator"); |
3494 | ||
3c5783b7 | 3495 | // if (!$edit_uid || $subop != "edit") { |
e6cb77a0 | 3496 | |
ce3bf408 | 3497 | print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"user\");' |
1a7572cb | 3498 | type=\"checkbox\" id=\"UMCHK-$uid\"></td>"; |
e6cb77a0 AD |
3499 | |
3500 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3501 | $line["login"] . "</td>"; | |
72932a75 | 3502 | |
0b68215c AD |
3503 | if (!$line["email"]) $line["email"] = " "; |
3504 | ||
e6cb77a0 | 3505 | print "<td><a href=\"javascript:editUser($uid);\">" . |
5917a8e4 | 3506 | $access_level_names[$line["access_level"]] . "</td>"; |
e6cb77a0 | 3507 | |
3c5783b7 | 3508 | /* } else if ($uid != $edit_uid) { |
e6cb77a0 | 3509 | |
0b68215c AD |
3510 | if (!$line["email"]) $line["email"] = " "; |
3511 | ||
72932a75 | 3512 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
e6cb77a0 AD |
3513 | id=\"UMCHK-".$line["id"]."\"></td>"; |
3514 | ||
3515 | print "<td>".$line["login"]."</td>"; | |
72932a75 | 3516 | print "<td>".$line["email"]."</td>"; |
5917a8e4 | 3517 | print "<td>".$access_level_names[$line["access_level"]]."</td>"; |
e6cb77a0 AD |
3518 | |
3519 | } else { | |
3520 | ||
72932a75 AD |
3521 | print "<td align='center'> |
3522 | <input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
e6cb77a0 AD |
3523 | |
3524 | print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"]. | |
3525 | "\"></td>"; | |
3526 | ||
72932a75 AD |
3527 | print "<td><input id=\"iedit_email\" value=\"".$line["email"]. |
3528 | "\"></td>"; | |
3529 | ||
5917a8e4 AD |
3530 | print "<td>"; |
3531 | print "<select id=\"iedit_ulevel\">"; | |
3532 | foreach (array_keys($access_level_names) as $al) { | |
3533 | if ($al == $line["access_level"]) { | |
3534 | $selected = "selected"; | |
3535 | } else { | |
3536 | $selected = ""; | |
3537 | } | |
3538 | print "<option $selected id=\"$al\">" . | |
3539 | $access_level_names[$al] . "</option>"; | |
3540 | } | |
3541 | print "</select>"; | |
3542 | print "</td>"; | |
3543 | ||
3c5783b7 | 3544 | } */ |
e6cb77a0 | 3545 | |
f6f32198 AD |
3546 | print "<td>".$line["last_login"]."</td>"; |
3547 | ||
e6cb77a0 AD |
3548 | print "</tr>"; |
3549 | ||
3550 | ++$lnum; | |
3551 | } | |
3552 | ||
3553 | print "</table>"; | |
3554 | ||
ce3bf408 | 3555 | print "<p id='userOpToolbar'>"; |
e6cb77a0 | 3556 | |
3c5783b7 | 3557 | /* if ($subop == "edit") { |
d10fabe4 | 3558 | print "Edit user: |
e6cb77a0 | 3559 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 3560 | onclick=\"javascript:userEditSave()\" value=\"Save\"> |
e6cb77a0 | 3561 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 3562 | onclick=\"javascript:userEditCancel()\" value=\"Cancel\">"; |
e6cb77a0 | 3563 | |
3c5783b7 | 3564 | } else { */ |
e6cb77a0 AD |
3565 | |
3566 | print " | |
3567 | Selection: | |
ce3bf408 | 3568 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
717f5e64 | 3569 | onclick=\"javascript:selectedUserDetails()\" value=\"User details\"> |
ce3bf408 | 3570 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
e6cb77a0 | 3571 | onclick=\"javascript:editSelectedUser()\" value=\"Edit\"> |
ce3bf408 | 3572 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
717f5e64 | 3573 | onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\"> |
ce3bf408 | 3574 | <input type=\"submit\" class=\"button\" disabled=\"true\" |
717f5e64 AD |
3575 | onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">"; |
3576 | ||
3c5783b7 | 3577 | // } |
717f5e64 AD |
3578 | } |
3579 | ||
3580 | if ($op == "user-details") { | |
3581 | ||
3582 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { | |
3583 | return; | |
3584 | } | |
3585 | ||
1a7572cb | 3586 | /* print "<html><head> |
717f5e64 AD |
3587 | <title>Tiny Tiny RSS : User Details</title> |
3588 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
3589 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
1a7572cb | 3590 | </head><body>"; */ |
717f5e64 AD |
3591 | |
3592 | $uid = sprintf("%d", $_GET["id"]); | |
3593 | ||
e5d758e3 AD |
3594 | print "<div id=\"infoBoxTitle\">User details</div>"; |
3595 | ||
c6c3a07f | 3596 | print "<div class='infoBoxContents'>"; |
717f5e64 | 3597 | |
fe99ab12 AD |
3598 | $result = db_query($link, "SELECT login, |
3599 | SUBSTRING(last_login,1,16) AS last_login, | |
3600 | access_level, | |
c6c3a07f AD |
3601 | (SELECT COUNT(int_id) FROM ttrss_user_entries |
3602 | WHERE owner_uid = id) AS stored_articles | |
717f5e64 AD |
3603 | FROM ttrss_users |
3604 | WHERE id = '$uid'"); | |
3605 | ||
3606 | if (db_num_rows($result) == 0) { | |
3607 | print "<h1>User not found</h1>"; | |
3608 | return; | |
3609 | } | |
3610 | ||
adba6b85 AD |
3611 | # print "<h1>User Details</h1>"; |
3612 | ||
3613 | $login = db_fetch_result($result, 0, "login"); | |
3614 | ||
c0ae0fdb | 3615 | # print "<h1>$login</h1>"; |
717f5e64 AD |
3616 | |
3617 | print "<table width='100%'>"; | |
3618 | ||
6be6bc03 AD |
3619 | $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), |
3620 | strtotime(db_fetch_result($result, 0, "last_login"))); | |
717f5e64 | 3621 | $access_level = db_fetch_result($result, 0, "access_level"); |
c6c3a07f | 3622 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); |
717f5e64 | 3623 | |
adba6b85 | 3624 | # print "<tr><td>Username</td><td>$login</td></tr>"; |
c0ae0fdb | 3625 | # print "<tr><td>Access level</td><td>$access_level</td></tr>"; |
717f5e64 | 3626 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; |
c6c3a07f | 3627 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; |
717f5e64 AD |
3628 | |
3629 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds | |
3630 | WHERE owner_uid = '$uid'"); | |
3631 | ||
3632 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
3633 | ||
3634 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; | |
3635 | ||
5d15d3ea | 3636 | /* $result = db_query($link, "SELECT |
717f5e64 | 3637 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size |
c6c3a07f AD |
3638 | FROM ttrss_user_entries,ttrss_entries |
3639 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
717f5e64 | 3640 | |
d9f115c3 | 3641 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
717f5e64 | 3642 | |
c6c3a07f | 3643 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ |
717f5e64 AD |
3644 | |
3645 | print "</table>"; | |
3646 | ||
3647 | print "<h1>Subscribed feeds</h1>"; | |
3648 | ||
e94645ca | 3649 | $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds |
9b3e2cc7 | 3650 | WHERE owner_uid = '$uid' ORDER BY title"); |
717f5e64 | 3651 | |
9b3e2cc7 | 3652 | print "<ul class=\"userFeedList\">"; |
717f5e64 | 3653 | |
adba6b85 AD |
3654 | $row_class = "odd"; |
3655 | ||
717f5e64 AD |
3656 | while ($line = db_fetch_assoc($result)) { |
3657 | ||
3658 | $icon_file = ICONS_URL."/".$line["id"].".ico"; | |
3659 | ||
3660 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
6c56687e | 3661 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; |
717f5e64 | 3662 | } else { |
5951ded1 | 3663 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
717f5e64 AD |
3664 | } |
3665 | ||
adba6b85 AD |
3666 | print "<li class=\"$row_class\">$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>"; |
3667 | ||
3668 | $row_class = toggleEvenOdd($row_class); | |
3669 | ||
e6cb77a0 | 3670 | } |
717f5e64 | 3671 | |
a88c1f36 AD |
3672 | if (db_num_rows($result) < $num_feeds) { |
3673 | // FIXME - add link to show ALL subscribed feeds here somewhere | |
3674 | print "<li><img | |
3675 | class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>"; | |
3676 | } | |
3677 | ||
717f5e64 AD |
3678 | print "</ul>"; |
3679 | ||
717f5e64 AD |
3680 | print "</div>"; |
3681 | ||
1a7572cb AD |
3682 | print "<div align='center'> |
3683 | <input type='submit' class='button' | |
c6c3a07f | 3684 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; |
1a7572cb AD |
3685 | |
3686 | // print "</body></html>"; | |
717f5e64 | 3687 | |
e6cb77a0 AD |
3688 | } |
3689 | ||
c6232e43 AD |
3690 | if ($op == "pref-feed-browser") { |
3691 | ||
e2f728be AD |
3692 | if (!ENABLE_FEED_BROWSER) { |
3693 | print "Feed browser is administratively disabled."; | |
3694 | return; | |
3695 | } | |
3696 | ||
c6232e43 AD |
3697 | $subop = $_REQUEST["subop"]; |
3698 | ||
3699 | if ($subop == "details") { | |
3700 | $id = db_escape_string($_GET["id"]); | |
c2b2aee0 | 3701 | |
072f1ee2 AD |
3702 | print "<div class=\"browserFeedInfo\">"; |
3703 | print "<b>Feed information:</b>"; | |
3704 | print "<div class=\"detailsPart\">"; | |
3705 | ||
3706 | $result = db_query($link, "SELECT | |
3707 | feed_url,site_url, | |
3708 | SUBSTRING(last_updated,1,19) AS last_updated | |
3709 | FROM ttrss_feeds WHERE id = '$id'"); | |
3710 | ||
3711 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
3712 | $site_url = db_fetch_result($result, 0, "site_url"); | |
3713 | $last_updated = db_fetch_result($result, 0, "last_updated"); | |
3714 | ||
3715 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
3716 | $last_updated = smart_date_time(strtotime($last_updated)); | |
3717 | } else { | |
3718 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
3719 | $last_updated = date($short_date, strtotime($last_updated)); | |
3720 | } | |
3721 | ||
3722 | print "Site: <a href='$site_url'>$site_url</a> ". | |
3723 | "(<a href='$feed_url'>feed</a>), ". | |
3724 | "Last updated: $last_updated"; | |
3725 | ||
3726 | print "</div>"; | |
3727 | ||
3728 | $result = db_query($link, "SELECT | |
3729 | ttrss_entries.title, | |
3730 | content, | |
c2b2aee0 AD |
3731 | substring(date_entered,1,19) as date_entered, |
3732 | substring(updated,1,19) as updated | |
072f1ee2 AD |
3733 | FROM ttrss_entries,ttrss_user_entries |
3734 | WHERE ttrss_entries.id = ref_id AND feed_id = '$id' | |
c2b2aee0 AD |
3735 | ORDER BY updated DESC LIMIT 5"); |
3736 | ||
3737 | if (db_num_rows($result) > 0) { | |
c2b2aee0 AD |
3738 | |
3739 | print "<b>Last headlines:</b><br>"; | |
3740 | ||
3741 | print "<div class=\"detailsPart\">"; | |
3742 | print "<ul class=\"compact\">"; | |
3743 | while ($line = db_fetch_assoc($result)) { | |
3744 | ||
3745 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { | |
3746 | $entry_dt = smart_date_time(strtotime($line["updated"])); | |
3747 | } else { | |
3748 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
3749 | $entry_dt = date($short_date, strtotime($line["updated"])); | |
3750 | } | |
3751 | ||
3752 | print "<li>" . $line["title"] . | |
3753 | " <span class=\"insensitive\">($entry_dt)</span></li>"; | |
3754 | } | |
3755 | print "</ul></div>"; | |
3756 | } | |
072f1ee2 AD |
3757 | |
3758 | print "</div>"; | |
c2b2aee0 | 3759 | |
c6232e43 AD |
3760 | return; |
3761 | } | |
65f28a40 | 3762 | |
beccbed5 AD |
3763 | 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>"; |
3764 | ||
6311acbe AD |
3765 | $limit = db_escape_string($_GET["limit"]); |
3766 | ||
3767 | if (!$limit) $limit = 25; | |
3768 | ||
0af33e87 AD |
3769 | $owner_uid = $_SESSION["uid"]; |
3770 | ||
3771 | $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers | |
3772 | FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
3773 | WHERE tf.feed_url = ttrss_feeds.feed_url | |
3774 | AND owner_uid = '$owner_uid') GROUP BY feed_url | |
3775 | ORDER BY subscribers DESC LIMIT $limit"); | |
6311acbe | 3776 | |
0af33e87 | 3777 | |
6311acbe AD |
3778 | print "<div style=\"float : right\"> |
3779 | Top <select id=\"feedBrowserLimit\">"; | |
3780 | ||
3781 | foreach (array(25, 50, 100) as $l) { | |
3782 | $issel = ($l == $limit) ? "selected" : ""; | |
3783 | print "<option $issel>$l</option>"; | |
3784 | } | |
3785 | ||
3786 | print "</select> | |
3787 | <input type=\"submit\" class=\"button\" | |
3788 | onclick=\"updateBigFeedBrowser()\" value=\"Show\"> | |
3789 | </div>"; | |
0b68215c | 3790 | |
c0ae0fdb | 3791 | print "<p id=\"fbrOpToolbar\">Selection: |
0b68215c | 3792 | <input type='submit' class='button' onclick=\"feedBrowserSubscribe()\" |
c0ae0fdb | 3793 | disabled=\"true\" value=\"Subscribe\">"; |
0b68215c | 3794 | |
0fefdacc | 3795 | print "<ul class='nomarks' id='browseBigFeedList'>"; |
c6232e43 AD |
3796 | |
3797 | $feedctr = 0; | |
3798 | ||
3799 | while ($line = db_fetch_assoc($result)) { | |
3800 | $feed_url = $line["feed_url"]; | |
3801 | $subscribers = $line["subscribers"]; | |
c6232e43 AD |
3802 | |
3803 | $det_result = db_query($link, "SELECT site_url,title,id | |
3804 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
3805 | ||
3806 | $details = db_fetch_assoc($det_result); | |
3807 | ||
3808 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
3809 | ||
3810 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
3811 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
3812 | "/".$details["id"].".ico\">"; | |
3813 | } else { | |
3814 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
3815 | } | |
3816 | ||
c0ae0fdb | 3817 | $check_box = "<input onclick='toggleSelectFBListRow(this)' class='feedBrowseCB' |
c6232e43 AD |
3818 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; |
3819 | ||
3820 | $class = ($feedctr % 2) ? "even" : "odd"; | |
3821 | ||
3822 | print "<li class='$class' id=\"FBROW-".$details["id"]."\">$check_box". | |
3823 | "$feed_icon "; | |
3824 | ||
c2b2aee0 | 3825 | print "<a href=\"javascript:browserToggleExpand('".$details["id"]."')\">" . |
c6232e43 AD |
3826 | $details["title"] ."</a> " . |
3827 | "<span class='subscribers'>($subscribers)</span>"; | |
3828 | ||
3829 | print "<div class=\"browserDetails\" id=\"BRDET-" . $details["id"] . "\">"; | |
3830 | print "</div>"; | |
3831 | ||
3832 | print "</li>"; | |
3833 | ||
3834 | ++$feedctr; | |
3835 | } | |
3836 | ||
3837 | if ($feedctr == 0) { | |
3838 | print "<li>No feeds found to subscribe.</li>"; | |
3839 | } | |
3840 | ||
3841 | print "</ul>"; | |
3842 | ||
c6232e43 AD |
3843 | print "</div>"; |
3844 | ||
3845 | } | |
3846 | ||
657770a0 AD |
3847 | function check_configuration_variables() { |
3848 | if (!defined('SESSION_EXPIRE_TIME')) { | |
adf702d6 | 3849 | return "config: SESSION_EXPIRE_TIME is undefined"; |
657770a0 AD |
3850 | } |
3851 | ||
3852 | if (SESSION_EXPIRE_TIME < 60) { | |
adf702d6 AD |
3853 | return "config: SESSION_EXPIRE_TIME is too low (less than 60)"; |
3854 | } | |
3855 | ||
3856 | if (SESSION_EXPIRE_TIME < SESSION_COOKIE_LIFETIME_REMEMBER) { | |
3857 | return "config: SESSION_EXPIRE_TIME should be greater or equal to" . | |
3858 | "SESSION_COOKIE_LIFETIME_REMEMBER"; | |
3859 | } | |
3860 | ||
9a3bb96a | 3861 | if (defined('DISABLE_SESSIONS')) { |
adf702d6 | 3862 | return "config: you have enabled DISABLE_SESSIONS. Please disable this option."; |
657770a0 AD |
3863 | } |
3864 | ||
8a414837 AD |
3865 | if (DATABASE_BACKED_SESSIONS && SINGLE_USER_MODE) { |
3866 | return "config: DATABASE_BACKED_SESSIONS is incompatible with SINGLE_USER_MODE"; | |
3867 | } | |
3868 | ||
657770a0 AD |
3869 | return false; |
3870 | } | |
3871 | ||
4b3dff6e | 3872 | db_close($link); |
1cd17194 | 3873 | ?> |
406d9489 AD |
3874 | |
3875 | <!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> | |
3876 |