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