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