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