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