]>
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 | ||
41765fef | 31 | define('SCHEMA_VERSION', 4); |
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 | |
f9cb39ac AD |
1504 | if ($subop == "browse") { |
1505 | ||
1506 | print "<div class=\"infoBoxContents\">"; | |
1507 | ||
1508 | print "<h1>Feed browser</h1>"; | |
1509 | ||
1510 | print "<p>Showing top 50 registered feeds, sorted by popularity:</p>"; | |
1511 | ||
1512 | $result = db_query($link, "SELECT feed_url,count(id) AS subscribers | |
1513 | FROM ttrss_feeds WHERE auth_login = '' AND auth_pass = '' | |
24b18114 | 1514 | GROUP BY feed_url ORDER BY subscribers DESC LIMIT 50"); |
f9cb39ac AD |
1515 | |
1516 | print "<ul class='browseFeedList' id='browseFeedList'>"; | |
1517 | ||
1518 | while ($line = db_fetch_assoc($result)) { | |
1519 | $feed_url = $line["feed_url"]; | |
1520 | $subscribers = $line["subscribers"]; | |
1521 | ||
1522 | $det_result = db_query($link, "SELECT site_url,title,id | |
1523 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
1524 | ||
1525 | $details = db_fetch_assoc($det_result); | |
1526 | ||
1527 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
1528 | ||
1529 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1530 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
1531 | "/".$details["id"].".ico\">"; | |
1532 | } else { | |
1533 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1534 | } | |
1535 | ||
1536 | $check_box = "<input class='feedBrowseCB' type=\"checkbox\" id=\"BFCHK-" . $details["id"] . "\">"; | |
1537 | ||
1538 | print "<li>$check_box $feed_icon" . $details["title"] . | |
1539 | " <span class='subscribers'>($subscribers)</span></li>"; | |
1540 | } | |
1541 | ||
1542 | print "</ul>"; | |
1543 | ||
1544 | print "<div align='center'> | |
f9cb39ac | 1545 | <input type=\"submit\" class=\"button\" |
d10fabe4 AD |
1546 | onclick=\"feedBrowserSubscribe()\" value=\"Subscribe\"> |
1547 | <input type='submit' class='button' | |
1548 | onclick=\"closeInfoBox()\" value=\"Cancel\"></div>"; | |
f9cb39ac AD |
1549 | |
1550 | print "</div>"; | |
1551 | return; | |
1552 | } | |
1553 | ||
0ea4fb50 AD |
1554 | if ($subop == "editfeed") { |
1555 | $feed_id = db_escape_string($_GET["id"]); | |
1556 | ||
1557 | $result = db_query($link, | |
1558 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
1559 | owner_uid = " . $_SESSION["uid"]); | |
1560 | ||
1561 | $title = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1562 | 0, "title"))); | |
1563 | ||
1564 | print "<div class=\"infoBoxContents\">"; | |
1565 | ||
1566 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
1567 | ||
1568 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
1569 | $feed_icon = "<img width=\"16\" height=\"16\" | |
1570 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
1571 | } else { | |
1572 | $feed_icon = ""; | |
1573 | } | |
1574 | ||
1575 | print "<h1>$feed_icon $title</h1>"; | |
1576 | ||
1577 | print "<table width='100%'>"; | |
1578 | ||
1579 | $row_class = "odd"; | |
1580 | ||
1581 | print "<tr class='$row_class'><td>Title:</td>"; | |
1582 | print "<td><input id=\"iedit_title\" value=\"$title\"></td></tr>"; | |
1583 | ||
1584 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
1585 | $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, | |
1586 | 0, "feed_url"))); | |
1587 | $row_class = toggleEvenOdd($row_class); | |
1588 | ||
1589 | print "<tr class='$row_class'><td>Feed URL:</td>"; | |
1590 | print "<td><input id=\"iedit_link\" value=\"$feed_url\"></td></tr>"; | |
1591 | ||
1592 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
1593 | ||
1594 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
1595 | ||
1596 | $row_class = toggleEvenOdd($row_class); | |
1597 | ||
1598 | print "<tr class='$row_class'><td>Category:</td>"; | |
1599 | print "<td>"; | |
1600 | print "<select id=\"iedit_fcat\">"; | |
1601 | print "<option id=\"0\">Uncategorized</option>"; | |
1602 | ||
1603 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories | |
1604 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
1605 | ||
1606 | if (db_num_rows($tmp_result) > 0) { | |
1607 | print "<option disabled>--------</option>"; | |
1608 | } | |
1609 | ||
1610 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1611 | if ($tmp_line["id"] == $cat_id) { | |
1612 | $is_selected = "selected"; | |
1613 | } else { | |
1614 | $is_selected = ""; | |
1615 | } | |
1616 | printf("<option $is_selected id='%d'>%s</option>", | |
1617 | $tmp_line["id"], $tmp_line["title"]); | |
1618 | } | |
1619 | ||
1620 | print "</select></td>"; | |
1621 | print "</td></tr>"; | |
1622 | ||
1623 | } | |
1624 | ||
1625 | $update_interval = db_fetch_result($result, 0, "update_interval"); | |
1626 | $row_class = toggleEvenOdd($row_class); | |
1627 | ||
1628 | print "<tr class='$row_class'><td>Update Interval:</td>"; | |
1629 | print "<td><input id=\"iedit_updintl\" | |
1630 | value=\"$update_interval\"></td></tr>"; | |
1631 | ||
1da7e457 AD |
1632 | $row_class = toggleEvenOdd($row_class); |
1633 | print "<tr class='$row_class'><td>Link to:</td>"; | |
1634 | ||
3b0027a4 AD |
1635 | $tmp_result = db_query($link, "SELECT COUNT(id) AS count |
1636 | FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); | |
1637 | ||
1638 | $linked_count = db_fetch_result($tmp_result, 0, "count"); | |
1639 | ||
1640 | ||
1da7e457 | 1641 | $parent_feed = db_fetch_result($result, 0, "parent_feed"); |
3b0027a4 AD |
1642 | |
1643 | if ($linked_count > 0) { | |
1644 | $disabled = "disabled"; | |
1645 | } | |
1646 | ||
1647 | print "<select $disabled id=\"iedit_parent_feed\">"; | |
1648 | ||
eac46afb | 1649 | print "<option id=\"0\">Not linked</option>"; |
1da7e457 | 1650 | |
8a53e029 AD |
1651 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
1652 | if ($cat_id) { | |
1653 | $cat_qpart = "AND cat_id = '$cat_id'"; | |
1654 | } else { | |
1655 | $cat_qpart = "AND cat_id IS NULL"; | |
1656 | } | |
1657 | } | |
1658 | ||
1da7e457 | 1659 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds |
8a53e029 | 1660 | WHERE owner_uid = ".$_SESSION["uid"]." $cat_qpart ORDER BY title"); |
1da7e457 AD |
1661 | |
1662 | if (db_num_rows($tmp_result) > 0) { | |
1663 | print "<option disabled>--------</option>"; | |
1664 | } | |
1665 | ||
1666 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
1667 | if ($tmp_line["id"] == $parent_feed) { | |
1668 | $is_selected = "selected"; | |
1669 | } else { | |
1670 | $is_selected = ""; | |
1671 | } | |
1672 | printf("<option $is_selected id='%d'>%s</option>", | |
1673 | $tmp_line["id"], $tmp_line["title"]); | |
1674 | } | |
1675 | ||
1676 | print "</select></td>"; | |
1677 | print "</td></tr>"; | |
1678 | ||
0ea4fb50 AD |
1679 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); |
1680 | $row_class = toggleEvenOdd($row_class); | |
1681 | ||
1682 | print "<tr class='$row_class'><td>Purge Days:</td>"; | |
1683 | print "<td><input id=\"iedit_purgintl\" | |
1684 | value=\"$purge_interval\"></td></tr>"; | |
1685 | ||
47c6c988 AD |
1686 | // print "<tr><td colspan=\"2\"><b>Authentication</b></td></tr>"; |
1687 | ||
1688 | $row_class = toggleEvenOdd($row_class); | |
1689 | $auth_login = db_fetch_result($result, 0, "auth_login"); | |
1690 | ||
1691 | print "<tr class='$row_class'><td>Login:</td>"; | |
1692 | print "<td><input id=\"iedit_login\" | |
1693 | value=\"$auth_login\"></td></tr>"; | |
1694 | ||
1695 | $row_class = toggleEvenOdd($row_class); | |
1696 | $auth_pass = db_fetch_result($result, 0, "auth_pass"); | |
1697 | ||
1698 | print "<tr class='$row_class'><td>Password:</td>"; | |
1699 | print "<td><input type=\"password\" id=\"iedit_pass\" | |
1700 | value=\"$auth_pass\"></td></tr>"; | |
1701 | ||
0ea4fb50 AD |
1702 | print "</table>"; |
1703 | print "</div>"; | |
1704 | ||
1705 | print "<div align='center'> | |
0ea4fb50 | 1706 | <input type=\"submit\" class=\"button\" |
d10fabe4 AD |
1707 | onclick=\"feedEditSave()\" value=\"Save\"> |
1708 | <input type='submit' class='button' | |
1709 | onclick=\"feedEditCancel()\" value=\"Cancel\"></div>"; | |
0ea4fb50 AD |
1710 | return; |
1711 | } | |
1712 | ||
508a81e1 | 1713 | if ($subop == "editSave") { |
47c6c988 AD |
1714 | $feed_title = db_escape_string($_POST["t"]); |
1715 | $feed_link = db_escape_string($_POST["l"]); | |
1716 | $upd_intl = db_escape_string($_POST["ui"]); | |
1717 | $purge_intl = db_escape_string($_POST["pi"]); | |
1718 | $feed_id = db_escape_string($_POST["id"]); | |
1719 | $cat_id = db_escape_string($_POST["catid"]); | |
1720 | $auth_login = db_escape_string($_POST["login"]); | |
1721 | $auth_pass = db_escape_string($_POST["pass"]); | |
1da7e457 | 1722 | $parent_feed = db_escape_string($_POST["pfeed"]); |
508a81e1 | 1723 | |
d148926e AD |
1724 | if (strtoupper($upd_intl) == "DEFAULT") |
1725 | $upd_intl = 0; | |
1726 | ||
a88c1f36 AD |
1727 | if (strtoupper($upd_intl) == "DISABLED") |
1728 | $upd_intl = -1; | |
1729 | ||
5d73494a AD |
1730 | if (strtoupper($purge_intl) == "DEFAULT") |
1731 | $purge_intl = 0; | |
1732 | ||
140aae81 AD |
1733 | if (strtoupper($purge_intl) == "DISABLED") |
1734 | $purge_intl = -1; | |
1735 | ||
91ff844a AD |
1736 | if ($cat_id != 0) { |
1737 | $category_qpart = "cat_id = '$cat_id'"; | |
1738 | } else { | |
1739 | $category_qpart = 'cat_id = NULL'; | |
1740 | } | |
1741 | ||
1da7e457 AD |
1742 | if ($parent_feed != 0) { |
1743 | $parent_qpart = "parent_feed = '$parent_feed'"; | |
1744 | } else { | |
1745 | $parent_qpart = 'parent_feed = NULL'; | |
1746 | } | |
1747 | ||
648472a7 | 1748 | $result = db_query($link, "UPDATE ttrss_feeds SET |
91ff844a | 1749 | $category_qpart, |
1da7e457 | 1750 | $parent_qpart, |
d148926e | 1751 | title = '$feed_title', feed_url = '$feed_link', |
5d73494a | 1752 | update_interval = '$upd_intl', |
47c6c988 AD |
1753 | purge_interval = '$purge_intl', |
1754 | auth_login = '$auth_login', | |
1755 | auth_pass = '$auth_pass' | |
f72dbbde | 1756 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
5ddadb4c AD |
1757 | } |
1758 | ||
1759 | if ($subop == "saveCat") { | |
1760 | $cat_title = db_escape_string($_GET["title"]); | |
1761 | $cat_id = db_escape_string($_GET["id"]); | |
1762 | ||
1763 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
1764 | title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
508a81e1 | 1765 | |
83fe4d6d AD |
1766 | } |
1767 | ||
331900c6 | 1768 | if ($subop == "remove") { |
331900c6 | 1769 | |
b0b4abcf | 1770 | if (!WEB_DEMO_MODE) { |
331900c6 | 1771 | |
f932bc9f | 1772 | $ids = split(",", db_escape_string($_GET["ids"])); |
b0b4abcf AD |
1773 | |
1774 | foreach ($ids as $id) { | |
f72dbbde AD |
1775 | db_query($link, "DELETE FROM ttrss_feeds |
1776 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
4769ddaf | 1777 | |
273a2f6b | 1778 | $icons_dir = ICONS_DIR; |
d5caaae5 | 1779 | |
4769ddaf AD |
1780 | if (file_exists($icons_dir . "/$id.ico")) { |
1781 | unlink($icons_dir . "/$id.ico"); | |
d5caaae5 | 1782 | } |
b0b4abcf | 1783 | } |
331900c6 AD |
1784 | } |
1785 | } | |
1786 | ||
1787 | if ($subop == "add") { | |
b0b4abcf AD |
1788 | |
1789 | if (!WEB_DEMO_MODE) { | |
331900c6 | 1790 | |
b6b535ca | 1791 | $feed_link = db_escape_string(trim($_GET["link"])); |
15da5cc1 AD |
1792 | $cat_id = db_escape_string($_GET["cid"]); |
1793 | ||
5edfe303 | 1794 | if ($cat_id == "0" || !$cat_id) { |
15da5cc1 AD |
1795 | $cat_qpart = "NULL"; |
1796 | } else { | |
1797 | $cat_qpart = "'$cat_id'"; | |
1798 | } | |
331900c6 | 1799 | |
648472a7 | 1800 | $result = db_query($link, |
7e9a3986 AD |
1801 | "SELECT id FROM ttrss_feeds |
1802 | WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]); | |
1803 | ||
1804 | if (db_num_rows($result) == 0) { | |
1805 | ||
1806 | $result = db_query($link, | |
15da5cc1 | 1807 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) |
746b249f AD |
1808 | VALUES ('".$_SESSION["uid"]."', '$feed_link', |
1809 | '[Unknown]', $cat_qpart)"); | |
331900c6 | 1810 | |
7e9a3986 | 1811 | $result = db_query($link, |
746b249f | 1812 | "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link' |
7e9a3986 AD |
1813 | AND owner_uid = " . $_SESSION["uid"]); |
1814 | ||
1815 | $feed_id = db_fetch_result($result, 0, "id"); | |
1816 | ||
1817 | if ($feed_id) { | |
ddb68b81 | 1818 | update_rss_feed($link, $feed_link, $feed_id, true); |
7e9a3986 AD |
1819 | } |
1820 | } else { | |
331900c6 | 1821 | |
7e9a3986 AD |
1822 | print "<div class=\"warning\"> |
1823 | Feed <b>$feed_link</b> already exists in the database. | |
1824 | </div>"; | |
b0b4abcf AD |
1825 | } |
1826 | } | |
331900c6 | 1827 | } |
a0d53889 | 1828 | |
91ff844a AD |
1829 | if ($subop == "addCat") { |
1830 | ||
1831 | if (!WEB_DEMO_MODE) { | |
1832 | ||
1833 | $feed_cat = db_escape_string(trim($_GET["cat"])); | |
1834 | ||
1835 | $result = db_query($link, | |
1836 | "SELECT id FROM ttrss_feed_categories | |
1837 | WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]); | |
1838 | ||
1839 | if (db_num_rows($result) == 0) { | |
1840 | ||
1841 | $result = db_query($link, | |
1842 | "INSERT INTO ttrss_feed_categories (owner_uid,title) | |
1843 | VALUES ('".$_SESSION["uid"]."', '$feed_cat')"); | |
1844 | ||
1845 | } else { | |
1846 | ||
1847 | print "<div class=\"warning\"> | |
1848 | Category <b>$feed_cat</b> already exists in the database. | |
1849 | </div>"; | |
1850 | } | |
1851 | ||
1852 | ||
1853 | } | |
1854 | } | |
1855 | ||
1856 | if ($subop == "removeCats") { | |
1857 | ||
1858 | if (!WEB_DEMO_MODE) { | |
1859 | ||
f932bc9f | 1860 | $ids = split(",", db_escape_string($_GET["ids"])); |
91ff844a AD |
1861 | |
1862 | foreach ($ids as $id) { | |
1863 | ||
1864 | db_query($link, "BEGIN"); | |
1865 | ||
1866 | $result = db_query($link, | |
1867 | "SELECT count(id) as num_feeds FROM ttrss_feeds | |
1868 | WHERE cat_id = '$id'"); | |
1869 | ||
1870 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
1871 | ||
1872 | if ($num_feeds == 0) { | |
1873 | db_query($link, "DELETE FROM ttrss_feed_categories | |
1874 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1875 | } else { | |
1876 | ||
1877 | print "<div class=\"warning\"> | |
1878 | Unable to delete non empty feed categories.</div>"; | |
1879 | ||
1880 | } | |
1881 | ||
1882 | db_query($link, "COMMIT"); | |
1883 | } | |
1884 | } | |
1885 | } | |
1886 | ||
f932bc9f AD |
1887 | if ($subop == "categorize") { |
1888 | ||
1889 | if (!WEB_DEMO_MODE) { | |
1890 | ||
1891 | $ids = split(",", db_escape_string($_GET["ids"])); | |
1892 | ||
1893 | $cat_id = db_escape_string($_GET["cat_id"]); | |
1894 | ||
1895 | if ($cat_id == 0) { | |
1896 | $cat_id_qpart = 'NULL'; | |
1897 | } else { | |
1898 | $cat_id_qpart = "'$cat_id'"; | |
1899 | } | |
1900 | ||
1901 | db_query($link, "BEGIN"); | |
1902 | ||
1903 | foreach ($ids as $id) { | |
1904 | ||
1905 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
1906 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
1907 | } | |
1908 | ||
1909 | db_query($link, "COMMIT"); | |
1910 | } | |
1911 | ||
1912 | } | |
1913 | ||
a24f525c AD |
1914 | if ($quiet) return; |
1915 | ||
c64d5b03 | 1916 | // print "<h3>Edit Feeds</h3>"; |
91ff844a | 1917 | |
4904f845 AD |
1918 | $result = db_query($link, "SELECT id,title,feed_url,last_error |
1919 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
1920 | ||
1921 | if (db_num_rows($result) > 0) { | |
1922 | ||
1923 | print "<div class=\"warning\">"; | |
a9b0bfd5 AD |
1924 | |
1925 | // print"<img class=\"closeButton\" | |
1926 | // onclick=\"javascript:hideParentElement(this);\" src=\"images/close.png\">"; | |
1927 | ||
36aab70f AD |
1928 | print "<a href=\"javascript:showBlockElement('feedUpdateErrors')\"> |
1929 | <b>Feeds with update errors</b> (click to expand)</a>"; | |
4904f845 | 1930 | |
36aab70f | 1931 | print "<ul id=\"feedUpdateErrors\" class=\"nomarks\">"; |
4904f845 AD |
1932 | |
1933 | while ($line = db_fetch_assoc($result)) { | |
1934 | print "<li>" . $line["title"] . " (" . $line["feed_url"] . "): " . | |
1935 | $line["last_error"]; | |
1936 | } | |
1937 | ||
1938 | print "</ul>"; | |
1939 | print "</div>"; | |
1940 | ||
1941 | } | |
1942 | ||
f932bc9f AD |
1943 | $feed_search = db_escape_string($_GET["search"]); |
1944 | ||
1945 | if (array_key_exists("search", $_GET)) { | |
1946 | $_SESSION["prefs_feed_search"] = $feed_search; | |
1947 | } else { | |
1948 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1949 | } | |
1950 | ||
1951 | print "<table width='100%' class=\"prefGenericAddBox\" | |
1952 | cellspacing='0' cellpadding='0'><tr> | |
1953 | <td> | |
1954 | <input id=\"fadd_link\" | |
1955 | onchange=\"javascript:addFeed()\" | |
1956 | size=\"40\"> | |
1957 | <input type=\"submit\" class=\"button\" | |
1958 | onclick=\"javascript:addFeed()\" value=\"Add feed\"> | |
f9cb39ac AD |
1959 | |
1960 | (<a href='javascript:browseFeeds()'>Browse feeds</a>) | |
f932bc9f AD |
1961 | </td><td align='right'> |
1962 | <input id=\"feed_search\" size=\"20\" | |
1963 | onchange=\"javascript:updateFeedList()\" | |
1964 | value=\"$feed_search\"> | |
1965 | <input type=\"submit\" class=\"button\" | |
1966 | onclick=\"javascript:updateFeedList()\" value=\"Search\"> | |
1967 | </td> | |
1968 | </tr></table>"; | |
a0d53889 | 1969 | |
b83c7545 AD |
1970 | $feeds_sort = db_escape_string($_GET["sort"]); |
1971 | ||
1972 | if (!$feeds_sort || $feeds_sort == "undefined") { | |
1973 | $feeds_sort = $_SESSION["pref_sort_feeds"]; | |
1974 | if (!$feeds_sort) $feeds_sort = "title"; | |
1975 | } | |
1976 | ||
1977 | $_SESSION["pref_sort_feeds"] = $feeds_sort; | |
1978 | ||
f932bc9f | 1979 | if ($feed_search) { |
11de82c3 AD |
1980 | $search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR |
1981 | UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND"; | |
f932bc9f AD |
1982 | } else { |
1983 | $search_qpart = ""; | |
1984 | } | |
1985 | ||
648472a7 | 1986 | $result = db_query($link, "SELECT |
db42b934 AD |
1987 | F1.id, |
1988 | F1.title, | |
1989 | F1.feed_url, | |
1990 | substring(F1.last_updated,1,16) AS last_updated, | |
1991 | F1.parent_feed, | |
1992 | F1.update_interval, | |
1993 | F1.purge_interval, | |
1994 | F1.cat_id, | |
1995 | F2.title AS parent_title, | |
1996 | C1.title AS category | |
c0e5a40e | 1997 | FROM |
db42b934 AD |
1998 | ttrss_feeds AS F1 |
1999 | LEFT JOIN ttrss_feeds AS F2 | |
2000 | ON (F1.parent_feed = F2.id) | |
2001 | LEFT JOIN ttrss_feed_categories AS C1 | |
2002 | ON (F1.cat_id = C1.id) | |
f932bc9f | 2003 | WHERE |
db42b934 | 2004 | $search_qpart F1.owner_uid = '".$_SESSION["uid"]."' |
0ea4fb50 | 2005 | ORDER by category,$feeds_sort,title"); |
1cd17194 | 2006 | |
3b0feb9b | 2007 | if (db_num_rows($result) != 0) { |
91ff844a | 2008 | |
3b0feb9b | 2009 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
35f3c923 | 2010 | |
f4fe2cde AD |
2011 | print "<p><table width=\"100%\" cellspacing=\"0\" |
2012 | class=\"prefFeedList\" id=\"prefFeedList\">"; | |
35f3c923 AD |
2013 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
2014 | Select: | |
2015 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', | |
3055bc41 | 2016 | 'FEEDR-', 'FRCHK-', true)\">All</a>, |
35f3c923 | 2017 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedList', |
3055bc41 | 2018 | 'FEEDR-', 'FRCHK-', false)\">None</a> |
35f3c923 AD |
2019 | </td</tr>"; |
2020 | ||
0ea4fb50 AD |
2021 | if (!get_pref($link, 'ENABLE_FEED_CATS')) { |
2022 | print "<tr class=\"title\"> | |
e325c6e7 | 2023 | <td width='5%' align='center'> </td> |
62ac0cc8 | 2024 | <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> |
f42e9435 | 2025 | <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> |
62ac0cc8 AD |
2026 | <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td> |
2027 | <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a></td></tr>"; | |
603c27f8 | 2028 | } |
603c27f8 | 2029 | |
c64d5b03 | 2030 | $lnum = 0; |
0ea4fb50 AD |
2031 | |
2032 | $cur_cat_id = -1; | |
c64d5b03 AD |
2033 | |
2034 | while ($line = db_fetch_assoc($result)) { | |
2035 | ||
3b0feb9b | 2036 | $feed_id = $line["id"]; |
0ea4fb50 AD |
2037 | $cat_id = $line["cat_id"]; |
2038 | ||
2039 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
2040 | $edit_link = htmlspecialchars(db_unescape_string($line["feed_url"])); | |
2041 | $edit_cat = htmlspecialchars(db_unescape_string($line["category"])); | |
c64d5b03 | 2042 | |
0ea4fb50 AD |
2043 | if ($line["update_interval"] == "0") $line["update_interval"] = "Default"; |
2044 | if ($line["update_interval"] == "-1") $line["update_interval"] = "Disabled"; | |
2045 | if ($line["purge_interval"] == "0") $line["purge_interval"] = "Default"; | |
2046 | if ($line["purge_interval"] < 0) $line["purge_interval"] = "Disabled"; | |
2047 | ||
2048 | if (!$edit_cat) $edit_cat = "Uncategorized"; | |
2049 | ||
2050 | ||
2051 | if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) { | |
cb58d0df AD |
2052 | $lnum = 0; |
2053 | ||
0ea4fb50 AD |
2054 | print "<tr><td colspan=\"6\" class=\"feedEditCat\">$edit_cat</td></tr>"; |
2055 | ||
2056 | print "<tr class=\"title\"> | |
e325c6e7 | 2057 | <td width='5%' align='center'> </td> |
62ac0cc8 | 2058 | <td width='30%'><a href=\"javascript:updateFeedList('title')\">Title</a></td> |
f42e9435 | 2059 | <td width='30%'><a href=\"javascript:updateFeedList('feed_url')\">Feed</a></td> |
62ac0cc8 AD |
2060 | <td width='15%'><a href=\"javascript:updateFeedList('update_interval')\">Update Interval</a></td> |
2061 | <td width='15%'><a href=\"javascript:updateFeedList('purge_interval')\">Purge Days</a></td></tr>"; | |
0ea4fb50 AD |
2062 | |
2063 | $cur_cat_id = $cat_id; | |
c64d5b03 | 2064 | } |
0ea4fb50 | 2065 | |
cb58d0df | 2066 | $class = ($lnum % 2) ? "even" : "odd"; |
0ea4fb50 AD |
2067 | $this_row_id = "id=\"FEEDR-$feed_id\""; |
2068 | ||
53226edc | 2069 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2070 | |
2071 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
2072 | ||
2073 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
327a3bbe | 2074 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/$feed_id.ico\">"; |
3b0feb9b | 2075 | } else { |
327a3bbe | 2076 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
3b0feb9b | 2077 | } |
327a3bbe | 2078 | // print "<td class='feedIcon'>$feed_icon</td>"; |
c64d5b03 | 2079 | |
62ac0cc8 | 2080 | print "<td class='feedSelect'><input onclick='toggleSelectRow(this);' |
0ea4fb50 | 2081 | type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>"; |
3547842a | 2082 | |
0ea4fb50 AD |
2083 | $edit_title = truncate_string($edit_title, 40); |
2084 | $edit_link = truncate_string($edit_link, 60); | |
a88c1f36 | 2085 | |
1da7e457 AD |
2086 | $parent_title = $line["parent_title"]; |
2087 | if ($parent_title) { | |
2088 | $parent_title = "<span class='groupPrompt'>(linked to | |
2089 | $parent_title)</span>"; | |
2090 | } | |
2091 | ||
0ea4fb50 | 2092 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
1da7e457 | 2093 | "$feed_icon $edit_title $parent_title" . "</a></td>"; |
0ea4fb50 AD |
2094 | |
2095 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
2096 | $edit_link . "</a></td>"; | |
3547842a | 2097 | |
0ea4fb50 AD |
2098 | /* if (get_pref($link, 'ENABLE_FEED_CATS')) { |
2099 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . | |
2100 | $edit_cat . "</a></td>"; | |
2101 | } */ | |
3547842a | 2102 | |
0ea4fb50 AD |
2103 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
2104 | $line["update_interval"] . "</a></td>"; | |
3b0feb9b | 2105 | |
0ea4fb50 AD |
2106 | print "<td><a href=\"javascript:editFeed($feed_id);\">" . |
2107 | $line["purge_interval"] . "</a></td>"; | |
3b0feb9b | 2108 | |
c64d5b03 AD |
2109 | print "</tr>"; |
2110 | ||
2111 | ++$lnum; | |
2112 | } | |
2113 | ||
c64d5b03 | 2114 | print "</table>"; |
3b0feb9b | 2115 | |
c64d5b03 AD |
2116 | print "<p>"; |
2117 | ||
3b0feb9b AD |
2118 | if ($subop == "edit") { |
2119 | print "Edit feed: | |
c64d5b03 | 2120 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2121 | onclick=\"javascript:feedEditCancel()\" value=\"Cancel\"> |
c64d5b03 | 2122 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2123 | onclick=\"javascript:feedEditSave()\" value=\"Save\">"; |
2124 | } else { | |
c64d5b03 AD |
2125 | |
2126 | print " | |
2127 | Selection: | |
2128 | <input type=\"submit\" class=\"button\" | |
3b0feb9b | 2129 | onclick=\"javascript:selectedFeedDetails()\" value=\"Details\"> |
c64d5b03 | 2130 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2131 | onclick=\"javascript:editSelectedFeed()\" value=\"Edit\"> |
2132 | <input type=\"submit\" class=\"button\" | |
2133 | onclick=\"javascript:removeSelectedFeeds()\" value=\"Remove\">"; | |
f932bc9f AD |
2134 | |
2135 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2136 | ||
2137 | print " "; | |
2138 | ||
2139 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2140 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2141 | ORDER BY title"); | |
2142 | ||
2143 | print "<select id=\"sfeed_set_fcat\">"; | |
2144 | print "<option id=\"0\">Uncategorized</option>"; | |
2145 | ||
2146 | if (db_num_rows($result) != 0) { | |
2147 | ||
2148 | print "<option disabled>--------</option>"; | |
2149 | ||
2150 | while ($line = db_fetch_assoc($result)) { | |
2151 | printf("<option id='%d'>%s</option>", | |
2152 | $line["id"], $line["title"]); | |
2153 | } | |
2154 | } | |
2155 | ||
2156 | print "</select>"; | |
2157 | ||
2158 | print " <input type=\"submit\" class=\"button\" | |
2159 | onclick=\"javascript:categorizeSelectedFeeds()\" value=\"Set category\">"; | |
2160 | ||
2161 | } | |
2162 | ||
3b0feb9b AD |
2163 | if (get_pref($link, 'ENABLE_PREFS_CATCHUP_UNCATCHUP')) { |
2164 | print " | |
2165 | <input type=\"submit\" class=\"button\" | |
4f3a84f4 | 2166 | onclick=\"javascript:readSelectedFeeds(true)\" value=\"Mark as read\"> |
3b0feb9b | 2167 | <input type=\"submit\" class=\"button\" |
4f3a84f4 | 2168 | onclick=\"javascript:readSelectedFeeds(false)\" |
3b0feb9b AD |
2169 | value=\"Mark as unread\"> "; |
2170 | } | |
2171 | ||
2172 | print " | |
f932bc9f | 2173 | All feeds: <input type=\"submit\" |
3b0feb9b AD |
2174 | class=\"button\" onclick=\"gotoExportOpml()\" |
2175 | value=\"Export OPML\">"; | |
2176 | } | |
2177 | } else { | |
2178 | ||
2179 | print "<p>No feeds defined.</p>"; | |
2180 | ||
2181 | } | |
2182 | ||
2183 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2184 | ||
2185 | print "<h3>Edit Categories</h3>"; | |
2186 | ||
2187 | // print "<h3>Categories</h3>"; | |
2188 | ||
2189 | print "<div class=\"prefGenericAddBox\"> | |
f932bc9f AD |
2190 | <input id=\"fadd_cat\" |
2191 | onchange=\"javascript:addFeedCat()\" | |
2192 | size=\"40\"> | |
2193 | <input | |
3b0feb9b AD |
2194 | type=\"submit\" class=\"button\" |
2195 | onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>"; | |
2196 | ||
2197 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2198 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2199 | ORDER BY title"); | |
2200 | ||
2201 | if (db_num_rows($result) != 0) { | |
2202 | ||
35f3c923 | 2203 | print "<p><table width=\"100%\" class=\"prefFeedCatList\" |
f4fe2cde | 2204 | cellspacing=\"0\" id=\"prefFeedCatList\">"; |
35f3c923 AD |
2205 | |
2206 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2207 | Select: | |
2208 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', | |
3055bc41 | 2209 | 'FCATR-', 'FCCHK-', true)\">All</a>, |
35f3c923 | 2210 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFeedCatList', |
3055bc41 | 2211 | 'FCATR-', 'FCCHK-', false)\">None</a> |
35f3c923 AD |
2212 | </td</tr>"; |
2213 | ||
3b0feb9b | 2214 | print "<tr class=\"title\"> |
a426e532 | 2215 | <td width=\"5%\"></td><td width=\"80%\">Title</td> |
3b0feb9b AD |
2216 | </tr>"; |
2217 | ||
2218 | $lnum = 0; | |
2219 | ||
2220 | while ($line = db_fetch_assoc($result)) { | |
2221 | ||
2222 | $class = ($lnum % 2) ? "even" : "odd"; | |
2223 | ||
2224 | $cat_id = $line["id"]; | |
2225 | ||
2226 | $edit_cat_id = $_GET["id"]; | |
2227 | ||
2228 | if ($subop == "editCat" && $cat_id != $edit_cat_id) { | |
2229 | $class .= "Grayed"; | |
53226edc AD |
2230 | $this_row_id = ""; |
2231 | } else { | |
2232 | $this_row_id = "id=\"FCATR-$cat_id\""; | |
3b0feb9b AD |
2233 | } |
2234 | ||
53226edc | 2235 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2236 | |
2237 | $edit_title = htmlspecialchars(db_unescape_string($line["title"])); | |
2238 | ||
2239 | if (!$edit_cat_id || $subop != "editCat") { | |
2240 | ||
a426e532 | 2241 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
2242 | type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>"; |
2243 | ||
2244 | print "<td><a href=\"javascript:editFeedCat($cat_id);\">" . | |
2245 | $edit_title . "</a></td>"; | |
2246 | ||
2247 | } else if ($cat_id != $edit_cat_id) { | |
2248 | ||
2249 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2250 | id=\"FRCHK-".$line["id"]."\"></td>"; | |
2251 | ||
2252 | print "<td>$edit_title</td>"; | |
2253 | ||
2254 | } else { | |
2255 | ||
2256 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2257 | ||
2258 | print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>"; | |
2259 | ||
2260 | } | |
2261 | ||
2262 | print "</tr>"; | |
2263 | ||
2264 | ++$lnum; | |
2265 | } | |
2266 | ||
2267 | print "</table>"; | |
2268 | ||
2269 | print "<p>"; | |
2270 | ||
2271 | if ($subop == "editCat") { | |
2272 | print "Edit category: | |
2273 | <input type=\"submit\" class=\"button\" | |
2274 | onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\"> | |
2275 | <input type=\"submit\" class=\"button\" | |
2276 | onclick=\"javascript:feedCatEditSave()\" value=\"Save\">"; | |
2277 | } else { | |
2278 | ||
2279 | print " | |
2280 | Selection: | |
2281 | <input type=\"submit\" class=\"button\" | |
2282 | onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\"> | |
2283 | <input type=\"submit\" class=\"button\" | |
2284 | onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">"; | |
2285 | ||
2286 | } | |
2287 | ||
2288 | } else { | |
2289 | print "<p>No feed categories defined.</p>"; | |
2290 | } | |
c64d5b03 AD |
2291 | } |
2292 | ||
2293 | print "<h3>Import OPML</h3> | |
f5a50b25 AD |
2294 | <form enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\"> |
2295 | File: <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
2296 | <input class=\"button\" name=\"op\" onclick=\"return validateOpmlImport();\" | |
2297 | type=\"submit\" value=\"Import\"> | |
2298 | </form>"; | |
2299 | ||
007bda35 AD |
2300 | } |
2301 | ||
a0d53889 AD |
2302 | if ($op == "pref-filters") { |
2303 | ||
2304 | $subop = $_GET["subop"]; | |
a24f525c | 2305 | $quiet = $_GET["quiet"]; |
a0d53889 AD |
2306 | |
2307 | if ($subop == "editSave") { | |
a0d53889 | 2308 | |
648472a7 AD |
2309 | $regexp = db_escape_string($_GET["r"]); |
2310 | $descr = db_escape_string($_GET["d"]); | |
2311 | $match = db_escape_string($_GET["m"]); | |
2312 | $filter_id = db_escape_string($_GET["id"]); | |
ead60402 | 2313 | $feed_id = db_escape_string($_GET["fid"]); |
19c9cb11 | 2314 | $action_id = db_escape_string($_GET["aid"]); |
ead60402 AD |
2315 | |
2316 | if (!$feed_id) { | |
2317 | $feed_id = 'NULL'; | |
2318 | } else { | |
2319 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2320 | } | |
0afbd851 | 2321 | |
648472a7 | 2322 | $result = db_query($link, "UPDATE ttrss_filters SET |
4b3dff6e | 2323 | reg_exp = '$regexp', |
0afbd851 | 2324 | description = '$descr', |
ead60402 | 2325 | feed_id = $feed_id, |
19c9cb11 | 2326 | action_id = '$action_id', |
0afbd851 AD |
2327 | filter_type = (SELECT id FROM ttrss_filter_types WHERE |
2328 | description = '$match') | |
2329 | WHERE id = '$filter_id'"); | |
a0d53889 AD |
2330 | } |
2331 | ||
2332 | if ($subop == "remove") { | |
2333 | ||
2334 | if (!WEB_DEMO_MODE) { | |
2335 | ||
f932bc9f | 2336 | $ids = split(",", db_escape_string($_GET["ids"])); |
a0d53889 AD |
2337 | |
2338 | foreach ($ids as $id) { | |
648472a7 | 2339 | db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id'"); |
a0d53889 AD |
2340 | |
2341 | } | |
2342 | } | |
2343 | } | |
2344 | ||
2345 | if ($subop == "add") { | |
2346 | ||
de435974 | 2347 | if (!WEB_DEMO_MODE) { |
a0d53889 | 2348 | |
b6b535ca AD |
2349 | $regexp = db_escape_string(trim($_GET["regexp"])); |
2350 | $match = db_escape_string(trim($_GET["match"])); | |
ead60402 | 2351 | $feed_id = db_escape_string($_GET["fid"]); |
19c9cb11 | 2352 | $action_id = db_escape_string($_GET["aid"]); |
ead60402 AD |
2353 | |
2354 | if (!$feed_id) { | |
2355 | $feed_id = 'NULL'; | |
2356 | } else { | |
2357 | $feed_id = sprintf("'%s'", db_escape_string($feed_id)); | |
2358 | } | |
4401bf04 | 2359 | |
648472a7 | 2360 | $result = db_query($link, |
19c9cb11 AD |
2361 | "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, |
2362 | action_id) | |
2363 | VALUES | |
de435974 | 2364 | ('$regexp', (SELECT id FROM ttrss_filter_types WHERE |
19c9cb11 AD |
2365 | description = '$match'),'".$_SESSION["uid"]."', |
2366 | $feed_id, '$action_id')"); | |
de435974 | 2367 | } |
a0d53889 AD |
2368 | } |
2369 | ||
a24f525c AD |
2370 | if ($quiet) return; |
2371 | ||
648472a7 | 2372 | $result = db_query($link, "SELECT description |
a0d53889 AD |
2373 | FROM ttrss_filter_types ORDER BY description"); |
2374 | ||
2375 | $filter_types = array(); | |
2376 | ||
648472a7 | 2377 | while ($line = db_fetch_assoc($result)) { |
a0d53889 AD |
2378 | array_push($filter_types, $line["description"]); |
2379 | } | |
2380 | ||
2c7070b5 | 2381 | print "<div class=\"prefGenericAddBox\"> |
7cc1e5d6 | 2382 | <input id=\"fadd_regexp\" size=\"40\"> "; |
2c7070b5 | 2383 | |
ead60402 AD |
2384 | print_select("fadd_match", "Title", $filter_types); |
2385 | ||
2386 | print " <select id=\"fadd_feed\">"; | |
2387 | ||
2388 | print "<option selected id=\"0\">All feeds</option>"; | |
2389 | ||
2390 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2391 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2392 | ||
2393 | if (db_num_rows($result) > 0) { | |
2394 | print "<option disabled>--------</option>"; | |
2395 | } | |
2396 | ||
2397 | while ($line = db_fetch_assoc($result)) { | |
2398 | printf("<option id='%d'>%s</option>", $line["id"], $line["title"]); | |
2399 | } | |
2400 | ||
2c7070b5 | 2401 | print "</select> "; |
19c9cb11 AD |
2402 | |
2403 | print " Action: "; | |
2404 | ||
2405 | print "<select id=\"fadd_action\">"; | |
2406 | ||
2407 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2408 | ORDER BY name"); | |
2409 | ||
2410 | while ($line = db_fetch_assoc($result)) { | |
2411 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
2412 | } | |
2413 | ||
2414 | print "</select> "; | |
2415 | ||
2c7070b5 AD |
2416 | print "<input type=\"submit\" |
2417 | class=\"button\" onclick=\"javascript:addFilter()\" | |
2418 | value=\"Add filter\">"; | |
a0d53889 | 2419 | |
19c9cb11 AD |
2420 | print "</div>"; |
2421 | ||
648472a7 | 2422 | $result = db_query($link, "SELECT |
ead60402 AD |
2423 | ttrss_filters.id AS id,reg_exp, |
2424 | ttrss_filters.description AS description, | |
2425 | ttrss_filter_types.name AS filter_type_name, | |
2426 | ttrss_filter_types.description AS filter_type_descr, | |
2427 | feed_id, | |
19c9cb11 | 2428 | ttrss_filter_actions.description AS action_description, |
11de82c3 | 2429 | ttrss_feeds.title AS feed_title |
a0d53889 | 2430 | FROM |
5890c3f4 AD |
2431 | ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN |
2432 | ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id) | |
4356293a | 2433 | WHERE |
ead60402 | 2434 | filter_type = ttrss_filter_types.id AND |
19c9cb11 | 2435 | ttrss_filter_actions.id = action_id AND |
ead60402 | 2436 | ttrss_filters.owner_uid = ".$_SESSION["uid"]." |
4356293a | 2437 | ORDER by reg_exp"); |
a0d53889 | 2438 | |
3b0feb9b | 2439 | if (db_num_rows($result) != 0) { |
a0d53889 | 2440 | |
f4fe2cde AD |
2441 | print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" |
2442 | id=\"prefFilterList\">"; | |
35f3c923 AD |
2443 | |
2444 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2445 | Select: | |
2446 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', | |
3055bc41 | 2447 | 'FILRR-', 'FICHK-', true)\">All</a>, |
35f3c923 | 2448 | <a href=\"javascript:selectTableRowsByIdPrefix('prefFilterList', |
3055bc41 | 2449 | 'FILRR-', 'FICHK-', false)\">None</a> |
35f3c923 AD |
2450 | </td</tr>"; |
2451 | ||
3b0feb9b | 2452 | print "<tr class=\"title\"> |
e325c6e7 | 2453 | <td align='center' width=\"5%\"> </td> |
19c9cb11 AD |
2454 | <td width=\"20%\">Filter expression</td> |
2455 | <td width=\"20%\">Feed</td> | |
2456 | <td width=\"15%\">Match</td> | |
2457 | <td width=\"15%\">Action</td> | |
3b0feb9b | 2458 | <td width=\"30%\">Description</td></tr>"; |
a0d53889 | 2459 | |
3b0feb9b AD |
2460 | $lnum = 0; |
2461 | ||
2462 | while ($line = db_fetch_assoc($result)) { | |
2463 | ||
2464 | $class = ($lnum % 2) ? "even" : "odd"; | |
2465 | ||
2466 | $filter_id = $line["id"]; | |
2467 | $edit_filter_id = $_GET["id"]; | |
2468 | ||
2469 | if ($subop == "edit" && $filter_id != $edit_filter_id) { | |
2470 | $class .= "Grayed"; | |
53226edc AD |
2471 | $this_row_id = ""; |
2472 | } else { | |
2473 | $this_row_id = "id=\"FILRR-$filter_id\""; | |
ead60402 | 2474 | } |
3b0feb9b | 2475 | |
53226edc | 2476 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2477 | |
2478 | $line["regexp"] = htmlspecialchars($line["reg_exp"]); | |
2479 | $line["description"] = htmlspecialchars($line["description"]); | |
2480 | ||
2481 | if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; | |
2482 | ||
2483 | if (!$edit_filter_id || $subop != "edit") { | |
2484 | ||
2485 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2486 | ||
a426e532 | 2487 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
2488 | type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; |
2489 | ||
2490 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2491 | $line["reg_exp"] . "</td>"; | |
2492 | ||
2493 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2494 | $line["feed_title"] . "</td>"; | |
2495 | ||
2496 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2497 | $line["filter_type_descr"] . "</td>"; | |
19c9cb11 AD |
2498 | |
2499 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . | |
2500 | $line["action_description"] . "</td>"; | |
2501 | ||
3b0feb9b AD |
2502 | print "<td><a href=\"javascript:editFilter($filter_id);\">" . |
2503 | $line["description"] . "</td>"; | |
2504 | ||
2505 | } else if ($filter_id != $edit_filter_id) { | |
2506 | ||
2507 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2508 | ||
2509 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2510 | id=\"FICHK-".$line["id"]."\"></td>"; | |
2511 | ||
2512 | print "<td>".$line["reg_exp"]."</td>"; | |
2513 | print "<td>".$line["feed_title"]."</td>"; | |
2514 | print "<td>".$line["filter_type_descr"]."</td>"; | |
19c9cb11 | 2515 | print "<td>".$line["action_description"]."</td>"; |
3b0feb9b | 2516 | print "<td>".$line["description"]."</td>"; |
19c9cb11 | 2517 | |
3b0feb9b AD |
2518 | } else { |
2519 | ||
2520 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2521 | ||
2522 | print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"]. | |
2523 | "\"></td>"; | |
2524 | ||
2525 | print "<td>"; | |
3b0feb9b | 2526 | print "<select id=\"iedit_feed\">"; |
3b0feb9b AD |
2527 | print "<option id=\"0\">All feeds</option>"; |
2528 | ||
3b0feb9b AD |
2529 | $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds |
2530 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
19c9cb11 AD |
2531 | |
2532 | if (db_num_rows($tmp_result) > 0) { | |
2533 | print "<option disabled>--------</option>"; | |
2534 | } | |
2535 | ||
3b0feb9b AD |
2536 | while ($tmp_line = db_fetch_assoc($tmp_result)) { |
2537 | if ($tmp_line["id"] == $line["feed_id"]) { | |
2538 | $is_selected = "selected"; | |
2539 | } else { | |
2540 | $is_selected = ""; | |
2541 | } | |
2542 | printf("<option $is_selected id='%d'>%s</option>", | |
2543 | $tmp_line["id"], $tmp_line["title"]); | |
ead60402 | 2544 | } |
3b0feb9b AD |
2545 | |
2546 | print "</select></td>"; | |
2547 | ||
2548 | print "<td>"; | |
2549 | print_select("iedit_match", $line["filter_type_descr"], $filter_types); | |
2550 | print "</td>"; | |
19c9cb11 AD |
2551 | |
2552 | print "<td>"; | |
2553 | print "<select id=\"iedit_filter_action\">"; | |
2554 | ||
2555 | $tmp_result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
2556 | ORDER BY description"); | |
2557 | ||
2558 | while ($tmp_line = db_fetch_assoc($tmp_result)) { | |
2559 | if ($tmp_line["description"] == $line["action_description"]) { | |
2560 | $is_selected = "selected"; | |
2561 | } else { | |
2562 | $is_selected = ""; | |
2563 | } | |
2564 | printf("<option $is_selected id='%d'>%s</option>", | |
2565 | $tmp_line["id"], $tmp_line["description"]); | |
2566 | } | |
3b0feb9b | 2567 | |
19c9cb11 AD |
2568 | print "</select></td>"; |
2569 | ||
2570 | ||
3b0feb9b AD |
2571 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. |
2572 | "\"></td>"; | |
2573 | ||
2574 | print "</td>"; | |
ead60402 | 2575 | } |
3b0feb9b AD |
2576 | |
2577 | print "</tr>"; | |
2578 | ||
2579 | ++$lnum; | |
a0d53889 | 2580 | } |
3b0feb9b AD |
2581 | |
2582 | if ($lnum == 0) { | |
2583 | print "<tr><td colspan=\"4\" align=\"center\">No filters defined.</td></tr>"; | |
2584 | } | |
2585 | ||
2586 | print "</table>"; | |
2587 | ||
2588 | print "<p>"; | |
2589 | ||
2590 | if ($subop == "edit") { | |
d10fabe4 | 2591 | print "Edit filter: |
3b0feb9b | 2592 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2593 | onclick=\"javascript:filterEditSave()\" value=\"Save\"> |
3b0feb9b | 2594 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2595 | onclick=\"javascript:filterEditCancel()\" value=\"Cancel\">"; |
3b0feb9b AD |
2596 | |
2597 | } else { | |
2598 | ||
2599 | print " | |
2600 | Selection: | |
e828e31e | 2601 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2602 | onclick=\"javascript:editSelectedFilter()\" value=\"Edit\"> |
e828e31e | 2603 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2604 | onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">"; |
2605 | } | |
2606 | ||
a0d53889 AD |
2607 | } else { |
2608 | ||
3b0feb9b AD |
2609 | print "<p>No filters defined.</p>"; |
2610 | ||
a0d53889 AD |
2611 | } |
2612 | } | |
2613 | ||
80dce858 AD |
2614 | // We need to accept raw SQL data in label queries, so not everything is escaped |
2615 | // here, this is by design. If you don't like the whole idea, disable labels | |
2616 | // altogether with GLOBAL_ENABLE_LABELS = false | |
2617 | ||
48f0adb0 AD |
2618 | if ($op == "pref-labels") { |
2619 | ||
cfaba6df AD |
2620 | if (!GLOBAL_ENABLE_LABELS) { |
2621 | return; | |
2622 | } | |
2623 | ||
48f0adb0 AD |
2624 | $subop = $_GET["subop"]; |
2625 | ||
d9dde1d6 AD |
2626 | if ($subop == "test") { |
2627 | ||
2628 | $expr = $_GET["expr"]; | |
2629 | $descr = $_GET["descr"]; | |
2630 | ||
2631 | print "<div class='infoBoxContents'>"; | |
2632 | ||
2633 | print "<h1>Label «$descr»</h1>"; | |
2634 | ||
2635 | // print "<p><b>Expression</b>: $expr</p>"; | |
2636 | ||
2637 | $result = db_query($link, | |
2638 | "SELECT count(id) AS num_matches | |
2639 | FROM ttrss_entries,ttrss_user_entries | |
2640 | WHERE ($expr) AND | |
2641 | ttrss_user_entries.ref_id = ttrss_entries.id AND | |
2642 | owner_uid = " . $_SESSION["uid"]); | |
2643 | ||
2644 | $num_matches = db_fetch_result($result, 0, "num_matches");; | |
2645 | ||
2646 | if ($num_matches > 0) { | |
2647 | ||
a31a7b39 | 2648 | print "<p>Query returned <b>$num_matches</b> matches, first 5 follow:</p>"; |
d9dde1d6 AD |
2649 | |
2650 | $result = db_query($link, | |
2651 | "SELECT title, | |
2652 | (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title | |
2653 | FROM ttrss_entries,ttrss_user_entries | |
2654 | WHERE ($expr) AND | |
2655 | ttrss_user_entries.ref_id = ttrss_entries.id | |
2656 | AND owner_uid = " . $_SESSION["uid"] . " | |
2657 | ORDER BY date_entered DESC LIMIT 5"); | |
2658 | ||
2659 | print "<ul class=\"nomarks\">"; | |
2660 | while ($line = db_fetch_assoc($result)) { | |
2661 | print "<li>".$line["title"]. | |
2662 | " <span class=\"insensitive\">(".$line["feed_title"].")</span></li>"; | |
2663 | } | |
2664 | print "</ul>"; | |
2665 | ||
2666 | } else { | |
2667 | print "<p>Query didn't return any matches.</p>"; | |
2668 | } | |
2669 | ||
2670 | print "</div>"; | |
2671 | ||
2672 | print "<div align='center'> | |
2673 | <input type='submit' class='button' | |
2674 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
2675 | return; | |
2676 | } | |
2677 | ||
48f0adb0 AD |
2678 | if ($subop == "editSave") { |
2679 | ||
2680 | $sql_exp = $_GET["s"]; | |
2681 | $descr = $_GET["d"]; | |
2682 | $label_id = db_escape_string($_GET["id"]); | |
2683 | ||
2684 | // print "$sql_exp : $descr : $label_id"; | |
2685 | ||
2686 | $result = db_query($link, "UPDATE ttrss_labels SET | |
2687 | sql_exp = '$sql_exp', | |
2688 | description = '$descr' | |
2689 | WHERE id = '$label_id'"); | |
2690 | } | |
2691 | ||
2692 | if ($subop == "remove") { | |
2693 | ||
2694 | if (!WEB_DEMO_MODE) { | |
2695 | ||
f932bc9f | 2696 | $ids = split(",", db_escape_string($_GET["ids"])); |
48f0adb0 AD |
2697 | |
2698 | foreach ($ids as $id) { | |
2699 | db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); | |
2700 | ||
2701 | } | |
2702 | } | |
2703 | } | |
2704 | ||
2705 | if ($subop == "add") { | |
2706 | ||
2707 | if (!WEB_DEMO_MODE) { | |
2708 | ||
4401bf04 AD |
2709 | // no escaping is done here on purpose |
2710 | $exp = trim($_GET["exp"]); | |
48f0adb0 AD |
2711 | |
2712 | $result = db_query($link, | |
4356293a AD |
2713 | "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) |
2714 | VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); | |
48f0adb0 AD |
2715 | } |
2716 | } | |
2717 | ||
2c7070b5 AD |
2718 | print "<div class=\"prefGenericAddBox\"> |
2719 | <input size=\"40\" id=\"ladd_expr\"> "; | |
48f0adb0 | 2720 | |
2c7070b5 AD |
2721 | print"<input type=\"submit\" class=\"button\" |
2722 | onclick=\"javascript:addLabel()\" value=\"Add label\"></div>"; | |
48f0adb0 AD |
2723 | |
2724 | $result = db_query($link, "SELECT | |
2725 | id,sql_exp,description | |
2726 | FROM | |
4356293a AD |
2727 | ttrss_labels |
2728 | WHERE | |
2729 | owner_uid = ".$_SESSION["uid"]." | |
2730 | ORDER by description"); | |
48f0adb0 | 2731 | |
d9dde1d6 AD |
2732 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
2733 | ||
3b0feb9b | 2734 | if (db_num_rows($result) != 0) { |
48f0adb0 | 2735 | |
f4fe2cde AD |
2736 | print "<p><table width=\"100%\" cellspacing=\"0\" |
2737 | class=\"prefLabelList\" id=\"prefLabelList\">"; | |
35f3c923 AD |
2738 | |
2739 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> | |
2740 | Select: | |
2741 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', | |
3055bc41 | 2742 | 'LILRR-', 'LICHK-', true)\">All</a>, |
35f3c923 | 2743 | <a href=\"javascript:selectTableRowsByIdPrefix('prefLabelList', |
3055bc41 | 2744 | 'LILRR-', 'LICHK-', false)\">None</a> |
35f3c923 AD |
2745 | </td</tr>"; |
2746 | ||
3b0feb9b | 2747 | print "<tr class=\"title\"> |
e325c6e7 AD |
2748 | <td align='center' width=\"5%\"> </td> |
2749 | <td width=\"40%\">SQL expression | |
01c9c74a | 2750 | <a class=\"helpLink\" href=\"javascript:displayHelpInfobox(1)\">(?)</a> |
3b0feb9b AD |
2751 | </td> |
2752 | <td width=\"40%\">Caption</td></tr>"; | |
2753 | ||
2754 | $lnum = 0; | |
2755 | ||
2756 | while ($line = db_fetch_assoc($result)) { | |
2757 | ||
2758 | $class = ($lnum % 2) ? "even" : "odd"; | |
2759 | ||
2760 | $label_id = $line["id"]; | |
2761 | $edit_label_id = $_GET["id"]; | |
2762 | ||
2763 | if ($subop == "edit" && $label_id != $edit_label_id) { | |
2764 | $class .= "Grayed"; | |
53226edc AD |
2765 | $this_row_id = ""; |
2766 | } else { | |
2767 | $this_row_id = "id=\"LILRR-$label_id\""; | |
3b0feb9b AD |
2768 | } |
2769 | ||
53226edc | 2770 | print "<tr class=\"$class\" $this_row_id>"; |
3b0feb9b AD |
2771 | |
2772 | $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); | |
2773 | $line["description"] = htmlspecialchars($line["description"]); | |
2774 | ||
2775 | if (!$edit_label_id || $subop != "edit") { | |
2776 | ||
2777 | if (!$line["description"]) $line["description"] = "[No caption]"; | |
2778 | ||
a426e532 | 2779 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
3b0feb9b AD |
2780 | type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>"; |
2781 | ||
2782 | print "<td><a href=\"javascript:editLabel($label_id);\">" . | |
2783 | $line["sql_exp"] . "</td>"; | |
48f0adb0 | 2784 | |
3b0feb9b AD |
2785 | print "<td><a href=\"javascript:editLabel($label_id);\">" . |
2786 | $line["description"] . "</td>"; | |
2787 | ||
2788 | } else if ($label_id != $edit_label_id) { | |
2789 | ||
2790 | if (!$line["description"]) $line["description"] = "[No description]"; | |
2791 | ||
2792 | print "<td><input disabled=\"true\" type=\"checkbox\" | |
2793 | id=\"LICHK-".$line["id"]."\"></td>"; | |
2794 | ||
2795 | print "<td>".$line["sql_exp"]."</td>"; | |
2796 | print "<td>".$line["description"]."</td>"; | |
2797 | ||
2798 | } else { | |
2799 | ||
2800 | print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
2801 | ||
2802 | print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. | |
2803 | "\"></td>"; | |
2804 | ||
2805 | print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. | |
2806 | "\"></td>"; | |
2807 | ||
2808 | } | |
2809 | ||
48f0adb0 | 2810 | |
3b0feb9b AD |
2811 | print "</tr>"; |
2812 | ||
2813 | ++$lnum; | |
2814 | } | |
2815 | ||
2816 | if ($lnum == 0) { | |
2817 | print "<tr><td colspan=\"4\" align=\"center\">No labels defined.</td></tr>"; | |
2818 | } | |
2819 | ||
2820 | print "</table>"; | |
2821 | ||
2822 | print "<p>"; | |
2823 | ||
2824 | if ($subop == "edit") { | |
2825 | print "Edit label: | |
d9dde1d6 AD |
2826 | <input type=\"submit\" class=\"button\" |
2827 | onclick=\"javascript:labelTest()\" value=\"Test\"> | |
3b0feb9b | 2828 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2829 | onclick=\"javascript:labelEditSave()\" value=\"Save\"> |
3b0feb9b | 2830 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 2831 | onclick=\"javascript:labelEditCancel()\" value=\"Cancel\">"; |
3b0feb9b AD |
2832 | |
2833 | } else { | |
2834 | ||
2835 | print " | |
2836 | Selection: | |
48f0adb0 | 2837 | <input type=\"submit\" class=\"button\" |
3b0feb9b | 2838 | onclick=\"javascript:editSelectedLabel()\" value=\"Edit\"> |
48f0adb0 | 2839 | <input type=\"submit\" class=\"button\" |
3b0feb9b AD |
2840 | onclick=\"javascript:removeSelectedLabels()\" value=\"Remove\">"; |
2841 | } | |
48f0adb0 | 2842 | } else { |
3b0feb9b | 2843 | print "<p>No labels defined.</p>"; |
48f0adb0 AD |
2844 | } |
2845 | } | |
2846 | ||
e828e31e AD |
2847 | if ($op == "error") { |
2848 | print "<div width=\"100%\" align='center'>"; | |
2849 | $msg = $_GET["msg"]; | |
2850 | print $msg; | |
2851 | print "</div>"; | |
2852 | } | |
2853 | ||
7dc66a61 | 2854 | if ($op == "help") { |
01c9c74a AD |
2855 | if (!$_GET["noheaders"]) { |
2856 | print "<html><head> | |
2857 | <title>Tiny Tiny RSS : Help</title> | |
2858 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
2859 | <script type=\"text/javascript\" src=\"functions.js\"></script> | |
2860 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
2861 | </head><body>"; | |
2862 | } | |
7dc66a61 AD |
2863 | |
2864 | $tid = sprintf("%d", $_GET["tid"]); | |
2865 | ||
01c9c74a | 2866 | print "<div class='infoBoxContents'>"; |
7dc66a61 | 2867 | |
01c9c74a AD |
2868 | if (file_exists("help/$tid.php")) { |
2869 | include("help/$tid.php"); | |
2870 | } else { | |
2871 | print "<p>Help topic not found.</p>"; | |
2872 | } | |
7dc66a61 | 2873 | |
01c9c74a | 2874 | print "</div>"; |
7dc66a61 AD |
2875 | |
2876 | print "<div align='center'> | |
01c9c74a AD |
2877 | <input type='submit' class='button' |
2878 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
7dc66a61 | 2879 | |
01c9c74a AD |
2880 | if (!$_GET["noheaders"]) { |
2881 | print "</body></html>"; | |
2882 | } | |
7dc66a61 AD |
2883 | |
2884 | } | |
2885 | ||
f84a97a3 AD |
2886 | if ($op == "dlg") { |
2887 | $id = $_GET["id"]; | |
6de5d056 | 2888 | $param = $_GET["param"]; |
f84a97a3 AD |
2889 | |
2890 | if ($id == "quickAddFeed") { | |
76332f3c AD |
2891 | print " |
2892 | Feed URL: <input | |
033e47e0 | 2893 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" |
15da5cc1 AD |
2894 | id=\"qafInput\">"; |
2895 | ||
2896 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
2897 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
2898 | WHERE owner_uid = ".$_SESSION["uid"]." | |
2899 | ORDER BY title"); | |
2900 | ||
2901 | print " <select id=\"qafCat\">"; | |
2902 | print "<option id=\"0\">Uncategorized</option>"; | |
2903 | ||
2904 | if (db_num_rows($result) != 0) { | |
2905 | ||
2906 | print "<option disabled>--------</option>"; | |
2907 | ||
2908 | while ($line = db_fetch_assoc($result)) { | |
2909 | printf("<option id='%d'>%s</option>", | |
2910 | $line["id"], $line["title"]); | |
2911 | } | |
2912 | } | |
2913 | ||
2914 | print "</select>"; | |
2915 | } | |
2916 | ||
2917 | print " <input class=\"button\" | |
f84a97a3 AD |
2918 | type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Add feed\"> |
2919 | <input class=\"button\" | |
2920 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2921 | value=\"Cancel\">"; | |
2922 | } | |
6de5d056 AD |
2923 | |
2924 | if ($id == "quickDelFeed") { | |
2925 | ||
2926 | $param = db_escape_string($param); | |
2927 | ||
2928 | $result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$param'"); | |
2929 | ||
2930 | if ($result) { | |
2931 | ||
2932 | $f_title = db_fetch_result($result, 0, "title"); | |
2933 | ||
76332f3c | 2934 | print "Remove current feed (<b>$f_title</b>)? |
6de5d056 AD |
2935 | <input class=\"button\" |
2936 | type=\"submit\" onclick=\"javascript:qfdDelete($param)\" value=\"Remove\"> | |
2937 | <input class=\"button\" | |
2938 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2939 | value=\"Cancel\">"; | |
2940 | } else { | |
2941 | print "Error: Feed $param not found. | |
2942 | <input class=\"button\" | |
2943 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2944 | value=\"Cancel\">"; | |
2945 | } | |
2946 | } | |
2947 | ||
033e47e0 AD |
2948 | if ($id == "search") { |
2949 | ||
2950 | print "<input id=\"searchbox\" class=\"extSearch\" | |
2951 | onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" | |
2952 | onchange=\"javascript:search()\"> | |
2953 | <select id=\"searchmodebox\"> | |
2954 | <option selected>All feeds</option> | |
2955 | <option>This feed</option> | |
2956 | </select> | |
2957 | <input type=\"submit\" | |
2958 | class=\"button\" onclick=\"javascript:search()\" value=\"Search\"> | |
2959 | <input class=\"button\" | |
2960 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
2961 | value=\"Close\">"; | |
2962 | ||
2963 | } | |
2964 | ||
a24f525c AD |
2965 | if ($id == "quickAddFilter") { |
2966 | ||
2967 | $result = db_query($link, "SELECT description | |
2968 | FROM ttrss_filter_types ORDER BY description"); | |
2969 | ||
2970 | $filter_types = array(); | |
2971 | ||
2972 | while ($line = db_fetch_assoc($result)) { | |
2973 | array_push($filter_types, $line["description"]); | |
2974 | } | |
2975 | ||
2976 | print "<table>"; | |
2977 | ||
2978 | print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"40\"> "; | |
2979 | ||
2980 | print_select("fadd_match", "Title", $filter_types); | |
2981 | ||
2982 | print "</td></tr>"; | |
2983 | print "<tr><td>Feed:</td><td><select id=\"fadd_feed\">"; | |
2984 | ||
2985 | print "<option selected id=\"0\">All feeds</option>"; | |
2986 | ||
2987 | $result = db_query($link, "SELECT id,title FROM ttrss_feeds | |
2988 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
2989 | ||
2990 | if (db_num_rows($result) > 0) { | |
2991 | print "<option disabled>--------</option>"; | |
2992 | } | |
2993 | ||
2994 | while ($line = db_fetch_assoc($result)) { | |
2995 | if ($param == $line["id"]) { | |
2996 | $selected = "selected"; | |
2997 | } else { | |
2998 | $selected = ""; | |
2999 | } | |
3000 | printf("<option id='%d' %s>%s</option>", $line["id"], $selected, $line["title"]); | |
3001 | } | |
3002 | ||
3003 | print "</select></td></tr>"; | |
3004 | ||
3005 | print "<tr><td>Action:</td>"; | |
3006 | ||
3007 | print "<td><select id=\"fadd_action\">"; | |
3008 | ||
3009 | $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions | |
3010 | ORDER BY name"); | |
3011 | ||
3012 | while ($line = db_fetch_assoc($result)) { | |
3013 | printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); | |
3014 | } | |
3015 | ||
3016 | print "</select>"; | |
3017 | ||
3018 | print "</td></tr><tr><td colspan=\"2\" align=\"right\">"; | |
3019 | ||
3020 | print "<input type=\"submit\" | |
3021 | class=\"button\" onclick=\"javascript:qaddFilter()\" | |
3022 | value=\"Add filter\"> "; | |
3023 | ||
3024 | print "<input class=\"button\" | |
3025 | type=\"submit\" onclick=\"javascript:closeDlg()\" | |
3026 | value=\"Close\">"; | |
3027 | ||
3028 | print "</td></tr></table>"; | |
3029 | } | |
f84a97a3 AD |
3030 | } |
3031 | ||
a2770077 AD |
3032 | // update feeds of all users, may be used anonymously |
3033 | if ($op == "globalUpdateFeeds") { | |
3034 | ||
3035 | $result = db_query($link, "SELECT id FROM ttrss_users"); | |
3036 | ||
3037 | while ($line = db_fetch_assoc($result)) { | |
3038 | $user_id = $line["id"]; | |
3039 | // print "<!-- updating feeds of uid $user_id -->"; | |
3040 | update_all_feeds($link, false, $user_id); | |
3041 | } | |
e65af9c1 | 3042 | |
a2770077 AD |
3043 | print "<rpc-reply> |
3044 | <message msg=\"All feeds updated\"/> | |
3045 | </rpc-reply>"; | |
e65af9c1 AD |
3046 | |
3047 | } | |
3048 | ||
77e96719 AD |
3049 | if ($op == "pref-prefs") { |
3050 | ||
b1895692 | 3051 | $subop = $_REQUEST["subop"]; |
77e96719 AD |
3052 | |
3053 | if ($subop == "Save configuration") { | |
3054 | ||
d2892032 AD |
3055 | if (WEB_DEMO_MODE) { |
3056 | header("Location: prefs.php"); | |
3057 | return; | |
3058 | } | |
01d68cf9 | 3059 | |
93cb4442 AD |
3060 | $_SESSION["prefs_op_result"] = "save-config"; |
3061 | ||
11de82c3 AD |
3062 | $_SESSION["prefs_cache"] = false; |
3063 | ||
77e96719 AD |
3064 | foreach (array_keys($_POST) as $pref_name) { |
3065 | ||
3066 | $pref_name = db_escape_string($pref_name); | |
3067 | $value = db_escape_string($_POST[$pref_name]); | |
3068 | ||
3069 | $result = db_query($link, "SELECT type_name | |
3070 | FROM ttrss_prefs,ttrss_prefs_types | |
3071 | WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id"); | |
3072 | ||
3073 | if (db_num_rows($result) > 0) { | |
3074 | ||
3075 | $type_name = db_fetch_result($result, 0, "type_name"); | |
3076 | ||
5da169d9 AD |
3077 | // print "$pref_name : $type_name : $value<br>"; |
3078 | ||
77e96719 | 3079 | if ($type_name == "bool") { |
5da169d9 | 3080 | if ($value == "1") { |
77e96719 AD |
3081 | $value = "true"; |
3082 | } else { | |
3083 | $value = "false"; | |
3084 | } | |
3085 | } else if ($type_name == "integer") { | |
3086 | $value = sprintf("%d", $value); | |
3087 | } | |
3088 | ||
3089 | // print "$pref_name : $type_name : $value<br>"; | |
3090 | ||
ff485f1d AD |
3091 | db_query($link, "UPDATE ttrss_user_prefs SET value = '$value' |
3092 | WHERE pref_name = '$pref_name' AND owner_uid = ".$_SESSION["uid"]); | |
77e96719 AD |
3093 | |
3094 | } | |
3095 | ||
3096 | header("Location: prefs.php"); | |
3097 | ||
3098 | } | |
3099 | ||
b1895692 AD |
3100 | } else if ($subop == "getHelp") { |
3101 | ||
3102 | $pref_name = db_escape_string($_GET["pn"]); | |
3103 | ||
3104 | $result = db_query($link, "SELECT help_text FROM ttrss_prefs | |
3105 | WHERE pref_name = '$pref_name'"); | |
3106 | ||
3107 | if (db_num_rows($result) > 0) { | |
3108 | $help_text = db_fetch_result($result, 0, "help_text"); | |
3109 | print $help_text; | |
3110 | } else { | |
3111 | print "Unknown option: $pref_name"; | |
3112 | } | |
3113 | ||
cbb01696 AD |
3114 | } else if ($subop == "Change e-mail") { |
3115 | ||
3116 | if (WEB_DEMO_MODE) { | |
3117 | header("Location: prefs.php"); | |
3118 | return; | |
3119 | } | |
3120 | ||
3121 | $email = db_escape_string($_GET["email"]); | |
3122 | $active_uid = $_SESSION["uid"]; | |
3123 | ||
3124 | if ($email) { | |
3125 | db_query($link, "UPDATE ttrss_users SET email = '$email' | |
3126 | WHERE id = '$active_uid'"); | |
3127 | } | |
3128 | ||
3129 | header("Location: prefs.php"); | |
3130 | ||
1c7f75ed AD |
3131 | } else if ($subop == "Change password") { |
3132 | ||
d2892032 AD |
3133 | if (WEB_DEMO_MODE) { |
3134 | header("Location: prefs.php"); | |
3135 | return; | |
3136 | } | |
1c7f75ed AD |
3137 | |
3138 | $old_pw = $_POST["OLD_PASSWORD"]; | |
3139 | $new_pw = $_POST["OLD_PASSWORD"]; | |
3140 | ||
3141 | $old_pw_hash = 'SHA1:' . sha1($_POST["OLD_PASSWORD"]); | |
3142 | $new_pw_hash = 'SHA1:' . sha1($_POST["NEW_PASSWORD"]); | |
3143 | ||
3144 | $active_uid = $_SESSION["uid"]; | |
3145 | ||
3146 | if ($old_pw && $new_pw) { | |
3147 | ||
3148 | $login = db_escape_string($_SERVER['PHP_AUTH_USER']); | |
3149 | ||
3150 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3151 | id = '$active_uid' AND (pwd_hash = '$old_pw' OR | |
3152 | pwd_hash = '$old_pw_hash')"); | |
3153 | ||
3154 | if (db_num_rows($result) == 1) { | |
3155 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$new_pw_hash' | |
3156 | WHERE id = '$active_uid'"); | |
b791095d AD |
3157 | |
3158 | $_SESSION["pwd_change_result"] = "ok"; | |
3159 | } else { | |
3160 | $_SESSION["pwd_change_result"] = "failed"; | |
1c7f75ed AD |
3161 | } |
3162 | } | |
3163 | ||
3164 | header("Location: prefs.php"); | |
b791095d | 3165 | |
77e96719 AD |
3166 | } else if ($subop == "Reset to defaults") { |
3167 | ||
d2892032 AD |
3168 | if (WEB_DEMO_MODE) { |
3169 | header("Location: prefs.php"); | |
3170 | return; | |
3171 | } | |
01d68cf9 | 3172 | |
93cb4442 AD |
3173 | $_SESSION["prefs_op_result"] = "reset-to-defaults"; |
3174 | ||
e1aa0559 AD |
3175 | if (DB_TYPE == "pgsql") { |
3176 | db_query($link,"UPDATE ttrss_user_prefs | |
3177 | SET value = ttrss_prefs.def_value | |
3178 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
3179 | ttrss_prefs.pref_name = ttrss_user_prefs.pref_name"); | |
3180 | } else { | |
3181 | db_query($link, "DELETE FROM ttrss_user_prefs | |
3182 | WHERE owner_uid = ".$_SESSION["uid"]); | |
3183 | initialize_user_prefs($link, $_SESSION["uid"]); | |
3184 | } | |
5da169d9 | 3185 | |
77e96719 AD |
3186 | header("Location: prefs.php"); |
3187 | ||
58f8ad54 AD |
3188 | } else if ($subop == "Change theme") { |
3189 | ||
3190 | $theme = db_escape_string($_POST["theme"]); | |
3191 | ||
3192 | if ($theme == "Default") { | |
3193 | $theme_qpart = 'NULL'; | |
3194 | } else { | |
3195 | $theme_qpart = "'$theme'"; | |
3196 | } | |
3197 | ||
6752e330 AD |
3198 | $result = db_query($link, "SELECT id,theme_path FROM ttrss_themes |
3199 | WHERE theme_name = '$theme'"); | |
3200 | ||
3201 | if (db_num_rows($result) == 1) { | |
3202 | $theme_id = db_fetch_result($result, 0, "id"); | |
3203 | $theme_path = db_fetch_result($result, 0, "theme_path"); | |
3204 | } else { | |
3205 | $theme_id = "NULL"; | |
3206 | $theme_path = ""; | |
3207 | } | |
3208 | ||
58f8ad54 | 3209 | db_query($link, "UPDATE ttrss_users SET |
6752e330 | 3210 | theme_id = $theme_id WHERE id = " . $_SESSION["uid"]); |
58f8ad54 | 3211 | |
6752e330 | 3212 | $_SESSION["theme"] = $theme_path; |
503eb349 | 3213 | |
58f8ad54 AD |
3214 | header("Location: prefs.php"); |
3215 | ||
77e96719 AD |
3216 | } else { |
3217 | ||
7d4c898a | 3218 | if (!SINGLE_USER_MODE) { |
1c7f75ed | 3219 | |
cbb01696 | 3220 | $result = db_query($link, "SELECT id,email FROM ttrss_users |
a029d530 AD |
3221 | WHERE id = ".$_SESSION["uid"]." AND (pwd_hash = 'password' OR |
3222 | pwd_hash = 'SHA1:".sha1("password")."')"); | |
3223 | ||
3224 | if (db_num_rows($result) != 0) { | |
b791095d | 3225 | print "<div class=\"warning\"> |
a029d530 AD |
3226 | Your password is at default value, please change it. |
3227 | </div>"; | |
3228 | } | |
3229 | ||
b791095d AD |
3230 | if ($_SESSION["pwd_change_result"] == "failed") { |
3231 | print "<div class=\"warning\"> | |
3232 | There was an error while changing your password. | |
3233 | </div>"; | |
3234 | } | |
3235 | ||
3236 | if ($_SESSION["pwd_change_result"] == "ok") { | |
3237 | print "<div class=\"notice\"> | |
3238 | Password changed successfully. | |
3239 | </div>"; | |
3240 | } | |
3241 | ||
3242 | $_SESSION["pwd_change_result"] = ""; | |
3243 | ||
93cb4442 AD |
3244 | if ($_SESSION["prefs_op_result"] == "reset-to-defaults") { |
3245 | print "<div class=\"notice\"> | |
3246 | Your configuration was reset to defaults. | |
3247 | </div>"; | |
3248 | } | |
3249 | ||
3250 | if ($_SESSION["prefs_op_result"] == "save-config") { | |
3251 | print "<div class=\"notice\"> | |
3252 | Your configuration was saved successfully. | |
3253 | </div>"; | |
3254 | } | |
3255 | ||
3256 | $_SESSION["prefs_op_result"] = ""; | |
3257 | ||
cbb01696 AD |
3258 | print "<form action=\"backend.php\" method=\"GET\">"; |
3259 | ||
3260 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3261 | print "<tr><td colspan='3'><h3>Personal data</h3></tr></td>"; | |
3262 | ||
3263 | $result = db_query($link, "SELECT email FROM ttrss_users | |
3264 | WHERE id = ".$_SESSION["uid"]); | |
3265 | ||
3266 | $email = db_fetch_result($result, 0, "email"); | |
3267 | ||
3268 | print "<tr><td width=\"40%\">E-mail</td>"; | |
3269 | print "<td><input class=\"editbox\" name=\"email\" | |
3270 | value=\"$email\"></td></tr>"; | |
3271 | ||
3272 | print "</table>"; | |
3273 | ||
3274 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3275 | ||
3276 | print "<p><input class=\"button\" type=\"submit\" | |
3277 | value=\"Change e-mail\" name=\"subop\">"; | |
3278 | ||
7d4c898a AD |
3279 | print "<form action=\"backend.php\" method=\"POST\">"; |
3280 | ||
3281 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3282 | print "<tr><td colspan='3'><h3>Authentication</h3></tr></td>"; | |
3283 | ||
3284 | print "<tr><td width=\"40%\">Old password</td>"; | |
3285 | print "<td><input class=\"editbox\" type=\"password\" | |
3286 | name=\"OLD_PASSWORD\"></td></tr>"; | |
3287 | ||
3288 | print "<tr><td width=\"40%\">New password</td>"; | |
3289 | ||
3290 | print "<td><input class=\"editbox\" type=\"password\" | |
3291 | name=\"NEW_PASSWORD\"></td></tr>"; | |
3292 | ||
3293 | print "</table>"; | |
3294 | ||
3295 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3296 | ||
3297 | print "<p><input class=\"button\" type=\"submit\" | |
3298 | value=\"Change password\" name=\"subop\">"; | |
3299 | ||
3300 | print "</form>"; | |
1c7f75ed | 3301 | |
7d4c898a | 3302 | } |
1c7f75ed | 3303 | |
58f8ad54 AD |
3304 | $result = db_query($link, "SELECT |
3305 | theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]); | |
3306 | ||
3307 | $user_theme_id = db_fetch_result($result, 0, "theme_id"); | |
3308 | ||
3309 | $result = db_query($link, "SELECT | |
3310 | id,theme_name FROM ttrss_themes ORDER BY theme_name"); | |
3311 | ||
3312 | if (db_num_rows($result) > 0) { | |
6752e330 AD |
3313 | |
3314 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3315 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
3316 | print "<tr><td colspan='3'><h3>Themes</h3></tr></td>"; | |
3317 | print "<tr><td width=\"40%\">Select theme</td>"; | |
3318 | print "<td><select name=\"theme\">"; | |
3319 | print "<option>Default</option>"; | |
58f8ad54 | 3320 | print "<option disabled>--------</option>"; |
6752e330 | 3321 | |
58f8ad54 AD |
3322 | while ($line = db_fetch_assoc($result)) { |
3323 | if ($line["id"] == $user_theme_id) { | |
3324 | $selected = "selected"; | |
3325 | } else { | |
3326 | $selected = ""; | |
3327 | } | |
3328 | print "<option $selected>" . $line["theme_name"] . "</option>"; | |
3329 | } | |
6752e330 AD |
3330 | print "</select></td></tr>"; |
3331 | print "</table>"; | |
3332 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3333 | print "<p><input class=\"button\" type=\"submit\" | |
3334 | value=\"Change theme\" name=\"subop\">"; | |
3335 | print "</form>"; | |
58f8ad54 AD |
3336 | } |
3337 | ||
77e96719 | 3338 | $result = db_query($link, "SELECT |
ff485f1d | 3339 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, |
77e96719 | 3340 | section_name,def_value |
ff485f1d | 3341 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs |
77e96719 | 3342 | WHERE type_id = ttrss_prefs_types.id AND |
ff485f1d | 3343 | section_id = ttrss_prefs_sections.id AND |
a2411bd9 AD |
3344 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND |
3345 | owner_uid = ".$_SESSION["uid"]." | |
650bc435 | 3346 | ORDER BY section_id,short_desc"); |
77e96719 AD |
3347 | |
3348 | print "<form action=\"backend.php\" method=\"POST\">"; | |
3349 | ||
77e96719 AD |
3350 | $lnum = 0; |
3351 | ||
3352 | $active_section = ""; | |
3353 | ||
3354 | while ($line = db_fetch_assoc($result)) { | |
3355 | ||
3356 | if ($active_section != $line["section_name"]) { | |
59a654ba AD |
3357 | |
3358 | if ($active_section != "") { | |
1c7f75ed | 3359 | print "</table>"; |
59a654ba | 3360 | } |
1c7f75ed AD |
3361 | |
3362 | print "<p><table width=\"100%\" class=\"prefPrefsList\">"; | |
59a654ba AD |
3363 | |
3364 | $active_section = $line["section_name"]; | |
3365 | ||
77e96719 | 3366 | print "<tr><td colspan=\"3\"><h3>$active_section</h3></td></tr>"; |
59a654ba AD |
3367 | // print "<tr class=\"title\"> |
3368 | // <td width=\"25%\">Option</td><td>Value</td></tr>"; | |
7268adf7 AD |
3369 | |
3370 | $lnum = 0; | |
77e96719 AD |
3371 | } |
3372 | ||
650bc435 | 3373 | // $class = ($lnum % 2) ? "even" : "odd"; |
77e96719 | 3374 | |
650bc435 | 3375 | print "<tr>"; |
77e96719 | 3376 | |
77e96719 AD |
3377 | $type_name = $line["type_name"]; |
3378 | $pref_name = $line["pref_name"]; | |
3379 | $value = $line["value"]; | |
3380 | $def_value = $line["def_value"]; | |
b1895692 AD |
3381 | $help_text = $line["help_text"]; |
3382 | ||
3383 | print "<td width=\"40%\" id=\"$pref_name\">" . $line["short_desc"]; | |
3384 | ||
3385 | if ($help_text) print "<div class=\"prefHelp\">$help_text</div>"; | |
3386 | ||
3387 | print "</td>"; | |
77e96719 AD |
3388 | |
3389 | print "<td>"; | |
3390 | ||
3391 | if ($type_name == "bool") { | |
3392 | // print_select($pref_name, $value, array("true", "false")); | |
3393 | ||
3394 | if ($value == "true") { | |
3395 | $value = "Yes"; | |
3396 | } else { | |
3397 | $value = "No"; | |
3398 | } | |
3399 | ||
3400 | print_radio($pref_name, $value, array("Yes", "No")); | |
3401 | ||
3402 | } else { | |
3403 | print "<input class=\"editbox\" name=\"$pref_name\" value=\"$value\">"; | |
3404 | } | |
3405 | ||
3406 | print "</td>"; | |
3407 | ||
3408 | print "</tr>"; | |
3409 | ||
3410 | $lnum++; | |
3411 | } | |
3412 | ||
3413 | print "</table>"; | |
3414 | ||
3415 | print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">"; | |
3416 | ||
3417 | print "<p><input class=\"button\" type=\"submit\" | |
3418 | name=\"subop\" value=\"Save configuration\">"; | |
3419 | ||
3420 | print " <input class=\"button\" type=\"submit\" | |
69668465 AD |
3421 | name=\"subop\" onclick=\"return validatePrefsReset()\" |
3422 | value=\"Reset to defaults\"></p>"; | |
77e96719 AD |
3423 | |
3424 | print "</form>"; | |
3425 | ||
3426 | } | |
3427 | ||
3428 | } | |
3429 | ||
e6cb77a0 AD |
3430 | if ($op == "pref-users") { |
3431 | ||
3432 | $subop = $_GET["subop"]; | |
3433 | ||
3434 | if ($subop == "editSave") { | |
3435 | ||
3436 | if (!WEB_DEMO_MODE) { | |
3437 | ||
3438 | $login = db_escape_string($_GET["l"]); | |
3439 | $uid = db_escape_string($_GET["id"]); | |
3440 | $access_level = sprintf("%d", $_GET["al"]); | |
72932a75 | 3441 | $email = db_escape_string($_GET["e"]); |
e6cb77a0 | 3442 | |
72932a75 AD |
3443 | db_query($link, "UPDATE ttrss_users SET login = '$login', |
3444 | access_level = '$access_level', email = '$email' WHERE id = '$uid'"); | |
e6cb77a0 AD |
3445 | |
3446 | } | |
3447 | } else if ($subop == "remove") { | |
3448 | ||
3449 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3450 | ||
f932bc9f | 3451 | $ids = split(",", db_escape_string($_GET["ids"])); |
e6cb77a0 AD |
3452 | |
3453 | foreach ($ids as $id) { | |
3454 | db_query($link, "DELETE FROM ttrss_users WHERE id = '$id' AND id != " . $_SESSION["uid"]); | |
3455 | ||
3456 | } | |
3457 | } | |
3458 | } else if ($subop == "add") { | |
3459 | ||
3460 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3461 | ||
b6b535ca | 3462 | $login = db_escape_string(trim($_GET["login"])); |
e6cb77a0 AD |
3463 | $tmp_user_pwd = make_password(8); |
3464 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3465 | ||
3466 | db_query($link, "INSERT INTO ttrss_users (login,pwd_hash,access_level) | |
3467 | VALUES ('$login', '$pwd_hash', 0)"); | |
3468 | ||
3469 | ||
3470 | $result = db_query($link, "SELECT id FROM ttrss_users WHERE | |
3471 | login = '$login' AND pwd_hash = '$pwd_hash'"); | |
3472 | ||
3473 | if (db_num_rows($result) == 1) { | |
3474 | ||
3475 | $new_uid = db_fetch_result($result, 0, "id"); | |
3476 | ||
3477 | print "<div class=\"notice\">Added user <b>".$_GET["login"]. | |
3478 | "</b> with password <b>$tmp_user_pwd</b>.</div>"; | |
3479 | ||
3480 | initialize_user($link, $new_uid); | |
3481 | ||
3482 | } else { | |
3483 | ||
3484 | print "<div class=\"warning\">Error while adding user <b>". | |
3485 | $_GET["login"].".</b></div>"; | |
3486 | ||
3487 | } | |
3488 | } | |
3489 | } else if ($subop == "resetPass") { | |
3490 | ||
3491 | if (!WEB_DEMO_MODE && $_SESSION["access_level"] >= 10) { | |
3492 | ||
3493 | $uid = db_escape_string($_GET["id"]); | |
3494 | ||
72932a75 AD |
3495 | $result = db_query($link, "SELECT login,email |
3496 | FROM ttrss_users WHERE id = '$uid'"); | |
e6cb77a0 AD |
3497 | |
3498 | $login = db_fetch_result($result, 0, "login"); | |
72932a75 | 3499 | $email = db_fetch_result($result, 0, "email"); |
e6cb77a0 AD |
3500 | $tmp_user_pwd = make_password(8); |
3501 | $pwd_hash = 'SHA1:' . sha1($tmp_user_pwd); | |
3502 | ||
3503 | db_query($link, "UPDATE ttrss_users SET pwd_hash = '$pwd_hash' | |
3504 | WHERE id = '$uid'"); | |
3505 | ||
3506 | print "<div class=\"notice\">Changed password of | |
72932a75 AD |
3507 | user <b>$login</b> to <b>$tmp_user_pwd</b>."; |
3508 | ||
3509 | if (MAIL_RESET_PASS && $email) { | |
3510 | print " Notifying <b>$email</b>."; | |
3511 | ||
3512 | mail("$login <$email>", "Password reset notification", | |
3513 | "Hi, $login.\n". | |
3514 | "\n". | |
3515 | "Your password for this TT-RSS installation was reset by". | |
3516 | " an administrator.\n". | |
3517 | "\n". | |
3518 | "Your new password is $tmp_user_pwd, please remember". | |
3519 | " it for later reference.\n". | |
3520 | "\n". | |
3521 | "Sincerely, TT-RSS Mail Daemon.", "From: " . MAIL_FROM); | |
3522 | } | |
3523 | ||
3524 | print "</div>"; | |
e6cb77a0 AD |
3525 | |
3526 | } | |
3527 | } | |
3528 | ||
2c7070b5 | 3529 | print "<div class=\"prefGenericAddBox\"> |
f932bc9f | 3530 | <input id=\"uadd_box\" onchange=\"javascript:addUser()\" size=\"40\"> "; |
e6cb77a0 | 3531 | |
2c7070b5 AD |
3532 | print"<input type=\"submit\" class=\"button\" |
3533 | onclick=\"javascript:addUser()\" value=\"Add user\"></div>"; | |
e6cb77a0 AD |
3534 | |
3535 | $result = db_query($link, "SELECT | |
72932a75 | 3536 | id,login,access_level,email, |
fe99ab12 | 3537 | SUBSTRING(last_login,1,16) as last_login |
e6cb77a0 AD |
3538 | FROM |
3539 | ttrss_users | |
3540 | ORDER by login"); | |
3541 | ||
2317ffaa | 3542 | print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>"; |
1a7572cb | 3543 | |
f4fe2cde AD |
3544 | print "<p><table width=\"100%\" cellspacing=\"0\" |
3545 | class=\"prefUserList\" id=\"prefUserList\">"; | |
e6cb77a0 | 3546 | |
35f3c923 AD |
3547 | print "<tr><td class=\"selectPrompt\" colspan=\"8\"> |
3548 | Select: | |
3549 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', | |
3055bc41 | 3550 | 'UMRR-', 'UMCHK-', true)\">All</a>, |
35f3c923 | 3551 | <a href=\"javascript:selectTableRowsByIdPrefix('prefUserList', |
3055bc41 | 3552 | 'UMRR-', 'UMCHK-', false)\">None</a> |
35f3c923 AD |
3553 | </td</tr>"; |
3554 | ||
e6cb77a0 | 3555 | print "<tr class=\"title\"> |
e325c6e7 | 3556 | <td align='center' width=\"5%\"> </td> |
72932a75 AD |
3557 | <td width='20%'>Username</td> |
3558 | <td width='20%'>E-mail</td> | |
3559 | <td width='20%'>Access Level</td> | |
3560 | <td width='20%'>Last login</td></tr>"; | |
e6cb77a0 AD |
3561 | |
3562 | $lnum = 0; | |
3563 | ||
3564 | while ($line = db_fetch_assoc($result)) { | |
3565 | ||
3566 | $class = ($lnum % 2) ? "even" : "odd"; | |
3567 | ||
3568 | $uid = $line["id"]; | |
3569 | $edit_uid = $_GET["id"]; | |
3570 | ||
4154a415 | 3571 | if ($subop == "edit" && $uid != $edit_uid) { |
e6cb77a0 | 3572 | $class .= "Grayed"; |
53226edc AD |
3573 | $this_row_id = ""; |
3574 | } else { | |
3575 | $this_row_id = "id=\"UMRR-$uid\""; | |
3576 | } | |
3577 | ||
3578 | print "<tr class=\"$class\" $this_row_id>"; | |
e6cb77a0 AD |
3579 | |
3580 | $line["login"] = htmlspecialchars($line["login"]); | |
3581 | ||
6be6bc03 AD |
3582 | $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'), |
3583 | strtotime($line["last_login"])); | |
3584 | ||
72932a75 | 3585 | /* if ($uid == $_SESSION["uid"]) { |
e6cb77a0 | 3586 | |
a426e532 | 3587 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
e6cb77a0 AD |
3588 | id=\"UMCHK-".$line["id"]."\"></td>"; |
3589 | ||
72932a75 AD |
3590 | print "<td>".$line["login"]."</td>"; |
3591 | print "<td>".$line["email"]."</td>"; | |
3592 | print "<td>".$line["access_level"]."</td>"; | |
e6cb77a0 | 3593 | |
72932a75 | 3594 | } else */ if (!$edit_uid || $subop != "edit") { |
e6cb77a0 | 3595 | |
a426e532 | 3596 | print "<td align='center'><input onclick='toggleSelectRow(this);' |
1a7572cb | 3597 | type=\"checkbox\" id=\"UMCHK-$uid\"></td>"; |
e6cb77a0 AD |
3598 | |
3599 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3600 | $line["login"] . "</td>"; | |
72932a75 AD |
3601 | |
3602 | print "<td><a href=\"javascript:editUser($uid);\">" . | |
3603 | $line["email"] . "</td>"; | |
3604 | ||
e6cb77a0 AD |
3605 | print "<td><a href=\"javascript:editUser($uid);\">" . |
3606 | $line["access_level"] . "</td>"; | |
3607 | ||
3608 | } else if ($uid != $edit_uid) { | |
3609 | ||
72932a75 | 3610 | print "<td align='center'><input disabled=\"true\" type=\"checkbox\" |
e6cb77a0 AD |
3611 | id=\"UMCHK-".$line["id"]."\"></td>"; |
3612 | ||
3613 | print "<td>".$line["login"]."</td>"; | |
72932a75 | 3614 | print "<td>".$line["email"]."</td>"; |
e6cb77a0 AD |
3615 | print "<td>".$line["access_level"]."</td>"; |
3616 | ||
3617 | } else { | |
3618 | ||
72932a75 AD |
3619 | print "<td align='center'> |
3620 | <input disabled=\"true\" type=\"checkbox\" checked></td>"; | |
e6cb77a0 AD |
3621 | |
3622 | print "<td><input id=\"iedit_ulogin\" value=\"".$line["login"]. | |
3623 | "\"></td>"; | |
3624 | ||
72932a75 AD |
3625 | print "<td><input id=\"iedit_email\" value=\"".$line["email"]. |
3626 | "\"></td>"; | |
3627 | ||
e6cb77a0 AD |
3628 | print "<td><input id=\"iedit_ulevel\" value=\"".$line["access_level"]. |
3629 | "\"></td>"; | |
3630 | ||
3631 | } | |
3632 | ||
f6f32198 AD |
3633 | print "<td>".$line["last_login"]."</td>"; |
3634 | ||
e6cb77a0 AD |
3635 | print "</tr>"; |
3636 | ||
3637 | ++$lnum; | |
3638 | } | |
3639 | ||
3640 | print "</table>"; | |
3641 | ||
3642 | print "<p>"; | |
3643 | ||
3644 | if ($subop == "edit") { | |
d10fabe4 | 3645 | print "Edit user: |
e6cb77a0 | 3646 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 3647 | onclick=\"javascript:userEditSave()\" value=\"Save\"> |
e6cb77a0 | 3648 | <input type=\"submit\" class=\"button\" |
d10fabe4 | 3649 | onclick=\"javascript:userEditCancel()\" value=\"Cancel\">"; |
e6cb77a0 AD |
3650 | |
3651 | } else { | |
3652 | ||
3653 | print " | |
3654 | Selection: | |
3655 | <input type=\"submit\" class=\"button\" | |
717f5e64 | 3656 | onclick=\"javascript:selectedUserDetails()\" value=\"User details\"> |
e6cb77a0 AD |
3657 | <input type=\"submit\" class=\"button\" |
3658 | onclick=\"javascript:editSelectedUser()\" value=\"Edit\"> | |
3659 | <input type=\"submit\" class=\"button\" | |
717f5e64 AD |
3660 | onclick=\"javascript:removeSelectedUsers()\" value=\"Remove\"> |
3661 | <input type=\"submit\" class=\"button\" | |
3662 | onclick=\"javascript:resetSelectedUserPass()\" value=\"Reset password\">"; | |
3663 | ||
3664 | } | |
3665 | } | |
3666 | ||
3667 | if ($op == "user-details") { | |
3668 | ||
3669 | if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { | |
3670 | return; | |
3671 | } | |
3672 | ||
1a7572cb | 3673 | /* print "<html><head> |
717f5e64 AD |
3674 | <title>Tiny Tiny RSS : User Details</title> |
3675 | <link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\"> | |
3676 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> | |
1a7572cb | 3677 | </head><body>"; */ |
717f5e64 AD |
3678 | |
3679 | $uid = sprintf("%d", $_GET["id"]); | |
3680 | ||
c6c3a07f | 3681 | print "<div class='infoBoxContents'>"; |
717f5e64 | 3682 | |
fe99ab12 AD |
3683 | $result = db_query($link, "SELECT login, |
3684 | SUBSTRING(last_login,1,16) AS last_login, | |
3685 | access_level, | |
c6c3a07f AD |
3686 | (SELECT COUNT(int_id) FROM ttrss_user_entries |
3687 | WHERE owner_uid = id) AS stored_articles | |
717f5e64 AD |
3688 | FROM ttrss_users |
3689 | WHERE id = '$uid'"); | |
3690 | ||
3691 | if (db_num_rows($result) == 0) { | |
3692 | print "<h1>User not found</h1>"; | |
3693 | return; | |
3694 | } | |
3695 | ||
3696 | print "<h1>User Details</h1>"; | |
3697 | ||
3698 | print "<table width='100%'>"; | |
3699 | ||
3700 | $login = db_fetch_result($result, 0, "login"); | |
6be6bc03 AD |
3701 | $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), |
3702 | strtotime(db_fetch_result($result, 0, "last_login"))); | |
717f5e64 | 3703 | $access_level = db_fetch_result($result, 0, "access_level"); |
c6c3a07f | 3704 | $stored_articles = db_fetch_result($result, 0, "stored_articles"); |
717f5e64 AD |
3705 | |
3706 | print "<tr><td>Username</td><td>$login</td></tr>"; | |
3707 | print "<tr><td>Access level</td><td>$access_level</td></tr>"; | |
3708 | print "<tr><td>Last logged in</td><td>$last_login</td></tr>"; | |
c6c3a07f | 3709 | print "<tr><td>Stored articles</td><td>$stored_articles</td></tr>"; |
717f5e64 AD |
3710 | |
3711 | $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds | |
3712 | WHERE owner_uid = '$uid'"); | |
3713 | ||
3714 | $num_feeds = db_fetch_result($result, 0, "num_feeds"); | |
3715 | ||
3716 | print "<tr><td>Subscribed feeds count</td><td>$num_feeds</td></tr>"; | |
3717 | ||
5d15d3ea | 3718 | /* $result = db_query($link, "SELECT |
717f5e64 | 3719 | SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size |
c6c3a07f AD |
3720 | FROM ttrss_user_entries,ttrss_entries |
3721 | WHERE owner_uid = '$uid' AND ref_id = id"); | |
717f5e64 | 3722 | |
d9f115c3 | 3723 | $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); |
717f5e64 | 3724 | |
c6c3a07f | 3725 | print "<tr><td>Approx. used DB size</td><td>$db_size KBytes</td></tr>"; */ |
717f5e64 AD |
3726 | |
3727 | print "</table>"; | |
3728 | ||
3729 | print "<h1>Subscribed feeds</h1>"; | |
3730 | ||
e94645ca | 3731 | $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds |
9b3e2cc7 | 3732 | WHERE owner_uid = '$uid' ORDER BY title"); |
717f5e64 | 3733 | |
9b3e2cc7 | 3734 | print "<ul class=\"userFeedList\">"; |
717f5e64 AD |
3735 | |
3736 | while ($line = db_fetch_assoc($result)) { | |
3737 | ||
3738 | $icon_file = ICONS_URL."/".$line["id"].".ico"; | |
3739 | ||
3740 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
6c56687e | 3741 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"$icon_file\">"; |
717f5e64 | 3742 | } else { |
5951ded1 | 3743 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; |
717f5e64 AD |
3744 | } |
3745 | ||
e94645ca | 3746 | print "<li>$feed_icon <a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>"; |
e6cb77a0 | 3747 | } |
717f5e64 | 3748 | |
a88c1f36 AD |
3749 | if (db_num_rows($result) < $num_feeds) { |
3750 | // FIXME - add link to show ALL subscribed feeds here somewhere | |
3751 | print "<li><img | |
3752 | class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\"> ...</li>"; | |
3753 | } | |
3754 | ||
717f5e64 AD |
3755 | print "</ul>"; |
3756 | ||
717f5e64 AD |
3757 | print "</div>"; |
3758 | ||
1a7572cb AD |
3759 | print "<div align='center'> |
3760 | <input type='submit' class='button' | |
c6c3a07f | 3761 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; |
1a7572cb AD |
3762 | |
3763 | // print "</body></html>"; | |
717f5e64 | 3764 | |
e6cb77a0 AD |
3765 | } |
3766 | ||
c6c3a07f AD |
3767 | if ($op == "feed-details") { |
3768 | ||
df268d47 | 3769 | // $feed_id = $_GET["id"]; |
4fec9fd7 | 3770 | |
df268d47 | 3771 | $feed_ids = split(",", db_escape_string($_GET["id"])); |
c6c3a07f | 3772 | |
df268d47 | 3773 | print "<div class=\"infoBoxContents\">"; |
bca02305 | 3774 | |
df268d47 | 3775 | foreach ($feed_ids as $feed_id) { |
c6c3a07f | 3776 | |
df268d47 AD |
3777 | $result = db_query($link, |
3778 | "SELECT | |
3779 | title,feed_url, | |
3780 | SUBSTRING(last_updated,1,16) as last_updated, | |
3781 | icon_url,site_url, | |
3782 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3783 | WHERE feed_id = id) AS total, | |
3784 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3785 | WHERE feed_id = id AND unread = true) AS unread, | |
3786 | (SELECT COUNT(int_id) FROM ttrss_user_entries | |
3787 | WHERE feed_id = id AND marked = true) AS marked | |
3788 | FROM ttrss_feeds | |
3789 | WHERE id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]); | |
3790 | ||
3791 | if (db_num_rows($result) == 0) return; | |
3792 | ||
3793 | $title = db_unescape_string(db_fetch_result($result, 0, "title")); | |
3794 | $last_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), | |
3795 | strtotime(db_fetch_result($result, 0, "last_updated"))); | |
3796 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
3797 | $icon_url = db_fetch_result($result, 0, "icon_url"); | |
3798 | $total = db_fetch_result($result, 0, "total"); | |
3799 | $unread = db_fetch_result($result, 0, "unread"); | |
3800 | $marked = db_fetch_result($result, 0, "marked"); | |
3801 | $site_url = db_fetch_result($result, 0, "site_url"); | |
bca02305 | 3802 | |
df268d47 AD |
3803 | $result = db_query($link, "SELECT COUNT(id) AS subscribed |
3804 | FROM ttrss_feeds WHERE feed_url = '$feed_url'"); | |
3805 | ||
3806 | $subscribed = db_fetch_result($result, 0, "subscribed"); | |
3807 | ||
3808 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
3809 | ||
3810 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
3811 | $feed_icon = "<img width=\"16\" height=\"16\" | |
3812 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
3813 | } else { | |
3814 | $feed_icon = ""; | |
bca02305 AD |
3815 | } |
3816 | ||
df268d47 | 3817 | print "<h1>$feed_icon $title</h1>"; |
bca02305 | 3818 | |
df268d47 | 3819 | print "<table width='100%'>"; |
bca02305 | 3820 | |
df268d47 AD |
3821 | if ($site_url) { |
3822 | print "<tr><td width='30%'>Link</td> | |
3823 | <td><a href=\"$site_url\">$site_url</a> | |
3824 | <a href=\"$feed_url\">(feed)</a></td> | |
3825 | </td></tr>"; | |
3826 | } else { | |
3827 | print "<tr><td width='30%'>Feed URL</td> | |
3828 | <td><a href=\"$feed_url\">$feed_url</a></td></tr>"; | |
3829 | } | |
3830 | print "<tr><td>Last updated</td><td>$last_updated</td></tr>"; | |
3831 | print "<tr><td>Total articles</td><td>$total</td></tr>"; | |
3832 | print "<tr><td>Unread articles</td><td>$unread</td></tr>"; | |
3833 | print "<tr><td>Starred articles</td><td>$marked</td></tr>"; | |
3834 | print "<tr><td>Subscribed users</td><td>$subscribed</td></tr>"; | |
3835 | ||
3836 | print "</table>"; | |
3837 | ||
3838 | /* $result = db_query($link, "SELECT title, | |
3839 | SUBSTRING(updated,1,16) AS updated,unread | |
3840 | FROM ttrss_entries,ttrss_user_entries | |
3841 | WHERE ref_id = id AND feed_id = '$feed_id' | |
3842 | ORDER BY date_entered DESC LIMIT 5"); | |
3843 | ||
3844 | if (db_num_rows($result) > 0) { | |
3845 | ||
3846 | print "<h1>Latest headlines</h1>"; | |
3847 | ||
3848 | print "<ul class=\"nomarks\">"; | |
3849 | ||
3850 | while ($line = db_fetch_assoc($result)) { | |
3851 | if ($line["unread"] == "t" || $line["unread"] == "1") { | |
3852 | $line["title"] = "<b>" . $line["title"] . "</b>"; | |
3853 | } | |
3854 | print "<li>" . $line["title"]. | |
3855 | " <span class=\"insensitive\">(" . | |
3856 | date(get_pref($link, 'SHORT_DATE_FORMAT'), | |
3857 | strtotime($line["updated"])). | |
3858 | ")</span></li>"; | |
3859 | } | |
3860 | ||
3861 | print "</ul>"; | |
3862 | ||
3863 | } */ | |
bca02305 | 3864 | } |
df268d47 AD |
3865 | |
3866 | print "</div>"; | |
3867 | ||
3868 | print "<div align='center'> | |
3869 | <input type='submit' class='button' | |
3870 | onclick=\"closeInfoBox()\" value=\"Close this window\"></div>"; | |
3871 | } | |
c6c3a07f | 3872 | |
4b3dff6e | 3873 | db_close($link); |
1cd17194 | 3874 | ?> |
406d9489 AD |
3875 | |
3876 | <!-- <?= sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> --> | |
3877 |