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