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