]> git.wh0rd.org - tt-rss.git/blame - api/index.php
implement a proper fix of cached images URL (refs #305, closes #300)
[tt-rss.git] / api / index.php
CommitLineData
378a548c 1<?php
378a548c
AD
2 error_reporting(E_ERROR | E_PARSE);
3
4 require_once "../config.php";
5
6 require_once "../db.php";
7 require_once "../db-prefs.php";
8 require_once "../functions.php";
9
3acc0da6
AD
10 define('API_STATUS_OK', 0);
11 define('API_STATUS_ERR', 1);
12
70543b6a
AD
13 if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT) {
14 ob_start("ob_gzhandler");
15 }
16
378a548c
AD
17 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
18
19 $session_expire = SESSION_EXPIRE_TIME; //seconds
20 $session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid_api" : TTRSS_SESSION_NAME . "_api";
21
3bb7e191
AD
22 session_name($session_name);
23
24 if ($_REQUEST["sid"]) {
25 session_id($_REQUEST["sid"]);
26 }
27
378a548c
AD
28 session_start();
29
30 if (!$link) {
31 if (DB_TYPE == "mysql") {
32 print mysql_error();
33 }
34 // PG seems to display its own errors just fine by default.
35 return;
36 }
37
38 init_connection($link);
39
40 $op = db_escape_string($_REQUEST["op"]);
3acc0da6 41 $seq = (int) $_REQUEST["seq"];
378a548c
AD
42
43// header("Content-Type: application/json");
44
3acc0da6
AD
45 function api_wrap_reply($status, $seq, $reply) {
46 print json_encode(array("seq" => $seq,
47 "status" => $status,
48 "content" => $reply));
49 }
50
378a548c 51 if (!$_SESSION["uid"] && $op != "login" && $op != "isLoggedIn") {
3acc0da6 52 print api_wrap_reply(API_STATUS_ERR, $seq, array("error" => 'NOT_LOGGED_IN'));
378a548c
AD
53 return;
54 }
55
3a216db4 56 if ($_SESSION["uid"] && $op != "logout" && !get_pref($link, 'ENABLE_API_ACCESS')) {
3acc0da6 57 print api_wrap_reply(API_STATUS_ERR, $seq, array("error" => 'API_DISABLED'));
378a548c 58 return;
3a216db4 59 }
378a548c
AD
60
61 switch ($op) {
70543b6a 62
378a548c
AD
63 case "getVersion":
64 $rv = array("version" => VERSION);
3acc0da6 65 print api_wrap_reply(API_STATUS_OK, $seq, $rv);
70543b6a
AD
66 break;
67
378a548c
AD
68 case "login":
69 $login = db_escape_string($_REQUEST["user"]);
70 $password = db_escape_string($_REQUEST["password"]);
70543b6a 71 $password_base64 = db_escape_string(base64_decode($_REQUEST["password"]));
378a548c 72
2bebdd34
AD
73 $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'");
74
75 if (db_num_rows($result) != 0) {
76 $uid = db_fetch_result($result, 0, "id");
77 } else {
78 $uid = 0;
79 }
80
a7a99686 81 if ($uid && get_pref($link, "ENABLE_API_ACCESS", $uid)) {
70543b6a 82 if (authenticate_user($link, $login, $password)) { // try login with normal password
3acc0da6
AD
83 print api_wrap_reply(API_STATUS_OK, $seq,
84 array("session_id" => session_id()));
70543b6a 85 } else if (authenticate_user($link, $login, $password_base64)) { // else try with base64_decoded password
3acc0da6
AD
86 print api_wrap_reply(API_STATUS_OK, $seq,
87 array("session_id" => session_id()));
70543b6a 88 } else { // else we are not logged in
3acc0da6
AD
89 print api_wrap_reply(API_STATUS_ERR, $seq,
90 array("error" => "LOGIN_ERROR"));
4cdd0d7c 91 }
378a548c 92 } else {
3acc0da6
AD
93 print api_wrap_reply(API_STATUS_ERR, $seq,
94 array("error" => "API_DISABLED"));
378a548c
AD
95 }
96
97 break;
70543b6a 98
378a548c
AD
99 case "logout":
100 logout_user();
3acc0da6 101 print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));
378a548c 102 break;
70543b6a 103
378a548c 104 case "isLoggedIn":
3acc0da6
AD
105 print api_wrap_reply(API_STATUS_OK, $seq,
106 array("status" => $_SESSION["uid"] != ''));
378a548c 107 break;
70543b6a 108
03e5f9eb
AD
109 case "getUnread":
110 $feed_id = db_escape_string($_REQUEST["feed_id"]);
111 $is_cat = db_escape_string($_REQUEST["is_cat"]);
112
113 if ($feed_id) {
3acc0da6
AD
114 print api_wrap_reply(API_STATUS_OK, $seq,
115 array("unread" => getFeedUnread($link, $feed_id, $is_cat)));
03e5f9eb 116 } else {
3acc0da6
AD
117 print api_wrap_reply(API_STATUS_OK, $seq,
118 array("unread" => getGlobalUnread($link)));
03e5f9eb 119 }
285f7597 120 break;
70543b6a
AD
121
122 /* Method added for ttrss-reader for Android */
285f7597 123 case "getCounters":
70543b6a 124
9798b2b4
AD
125 /* flct (flc is the default) FIXME: document */
126 $output_mode = db_escape_string($_REQUEST["output_mode"]);
70543b6a 127
3acc0da6
AD
128 print api_wrap_reply(API_STATUS_OK, $seq,
129 getAllCounters($link, $output_mode));
03e5f9eb 130 break;
70543b6a 131
378a548c
AD
132 case "getFeeds":
133 $cat_id = db_escape_string($_REQUEST["cat_id"]);
134 $unread_only = (bool)db_escape_string($_REQUEST["unread_only"]);
37882ef3
AD
135 $limit = (int) db_escape_string($_REQUEST["limit"]);
136 $offset = (int) db_escape_string($_REQUEST["offset"]);
137
35aa08bb
AD
138 chdir(".."); // so feed_has_icon() would work properly for relative ICONS_DIR
139
911d4c08 140 $feeds = api_get_feeds($link, $cat_id, $unread_only, $limit, $offset);
53aff642 141
3acc0da6 142 print api_wrap_reply(API_STATUS_OK, $seq, $feeds);
378a548c
AD
143
144 break;
70543b6a 145
378a548c 146 case "getCategories":
730c97c7
AD
147 $unread_only = (bool)db_escape_string($_REQUEST["unread_only"]);
148
378a548c
AD
149 $result = db_query($link, "SELECT
150 id, title FROM ttrss_feed_categories
151 WHERE owner_uid = " .
152 $_SESSION["uid"]);
153
154 $cats = array();
155
156 while ($line = db_fetch_assoc($result)) {
157 $unread = getFeedUnread($link, $line["id"], true);
730c97c7
AD
158
159 if ($unread || !$unread_only) {
f1c2b672
AD
160 array_push($cats, array("id" => $line["id"],
161 "title" => $line["title"],
162 "unread" => $unread));
730c97c7 163 }
378a548c
AD
164 }
165
3acc0da6 166 print api_wrap_reply(API_STATUS_OK, $seq, $cats);
378a548c 167 break;
70543b6a 168
378a548c
AD
169 case "getHeadlines":
170 $feed_id = db_escape_string($_REQUEST["feed_id"]);
171 $limit = (int)db_escape_string($_REQUEST["limit"]);
285f7597 172 $offset = (int)db_escape_string($_REQUEST["skip"]);
378a548c
AD
173 $filter = db_escape_string($_REQUEST["filter"]);
174 $is_cat = (bool)db_escape_string($_REQUEST["is_cat"]);
d5e71621
AD
175 $show_excerpt = (bool)db_escape_string($_REQUEST["show_excerpt"]);
176 $show_content = (bool)db_escape_string($_REQUEST["show_content"]);
ef6c9ba4
AD
177 /* all_articles, unread, adaptive, marked, updated */
178 $view_mode = db_escape_string($_REQUEST["view_mode"]);
378a548c 179
911d4c08
AD
180 $headlines = api_get_headlines($link, $feed_id, $limit, $offset,
181 $filter, $is_cat, $show_excerpt, $show_content, $view_mode, false);
378a548c 182
3acc0da6 183 print api_wrap_reply(API_STATUS_OK, $seq, $headlines);
378a548c 184
730c97c7 185 break;
70543b6a 186
1c3fffbb 187 case "updateArticle":
ef6c9ba4 188 $article_ids = split(",", db_escape_string($_REQUEST["article_ids"]));
1c3fffbb
AD
189 $mode = (int) db_escape_string($_REQUEST["mode"]);
190 $field_raw = (int)db_escape_string($_REQUEST["field"]);
191
192 $field = "";
193 $set_to = "";
194
195 switch ($field_raw) {
196 case 0:
197 $field = "marked";
198 break;
199 case 1:
200 $field = "published";
201 break;
202 case 2:
203 $field = "unread";
204 break;
205 };
206
207 switch ($mode) {
208 case 1:
209 $set_to = "true";
210 break;
211 case 0:
212 $set_to = "false";
213 break;
214 case 2:
215 $set_to = "NOT $field";
216 break;
217 }
218
ef6c9ba4
AD
219 if ($field && $set_to && count($article_ids) > 0) {
220
221 $article_ids = join(", ", $article_ids);
222
1c3fffbb
AD
223 if ($field == "unread") {
224 $result = db_query($link, "UPDATE ttrss_user_entries SET $field = $set_to,
225 last_read = NOW()
ef6c9ba4 226 WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
1c3fffbb
AD
227 } else {
228 $result = db_query($link, "UPDATE ttrss_user_entries SET $field = $set_to
ef6c9ba4 229 WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
1c3fffbb 230 }
48317f5a 231
b4fdbcf4
AD
232 $num_updated = db_affected_rows($link, $result);
233
234 if ($num_updated > 0 && $field == "unread") {
235 $result = db_query($link, "SELECT DISTINCT feed_id FROM ttrss_user_entries
236 WHERE ref_id IN ($article_ids)");
237
238 while ($line = db_fetch_assoc($result)) {
239 ccache_update($link, $line["feed_id"], $_SESSION["uid"]);
240 }
241 }
242
3acc0da6 243 print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK",
b4fdbcf4
AD
244 "updated" => $num_updated));
245
246 } else {
3acc0da6
AD
247 print api_wrap_reply(API_STATUS_ERR, $seq,
248 array("error" => 'INCORRECT_USAGE'));
1c3fffbb
AD
249 }
250
251 break;
252
730c97c7
AD
253 case "getArticle":
254
f95ac275 255 $article_id = db_escape_string($_REQUEST["article_id"]);
730c97c7 256
f95ac275 257 $query = "SELECT id,title,link,content,feed_id,comments,int_id,
1c3fffbb 258 marked,unread,published,
730c97c7
AD
259 ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
260 author
261 FROM ttrss_entries,ttrss_user_entries
f95ac275 262 WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
730c97c7
AD
263 $_SESSION["uid"] ;
264
265 $result = db_query($link, $query);
3acc0da6
AD
266
267 $articles = array();
268
730c97c7 269 if (db_num_rows($result) != 0) {
730c97c7 270
f95ac275
AD
271 while ($line = db_fetch_assoc($result)) {
272
273 $attachments = get_article_enclosures($link, $line['id']);
274
275 $article = array(
276 "id" => $line["id"],
277 "title" => $line["title"],
278 "link" => $line["link"],
279 "labels" => get_article_labels($link, $line['id']),
280 "unread" => sql_bool_to_bool($line["unread"]),
281 "marked" => sql_bool_to_bool($line["marked"]),
282 "published" => sql_bool_to_bool($line["published"]),
283 "comments" => $line["comments"],
284 "author" => $line["author"],
285 "updated" => strtotime($line["updated"]),
286 "content" => $line["content"],
287 "feed_id" => $line["feed_id"],
288 "attachments" => $attachments
289 );
290
3acc0da6
AD
291 array_push($articles, $article);
292
f95ac275
AD
293 }
294 }
730c97c7 295
3acc0da6
AD
296 print api_wrap_reply(API_STATUS_OK, $seq, $articles);
297
7c6d05cd 298 break;
70543b6a 299
7c6d05cd
AD
300 case "getConfig":
301 $config = array(
302 "icons_dir" => ICONS_DIR,
303 "icons_url" => ICONS_URL);
304
305 if (ENABLE_UPDATE_DAEMON) {
306 $config["daemon_is_running"] = file_is_locked("update_daemon.lock");
307 }
308
309 $result = db_query($link, "SELECT COUNT(*) AS cf FROM
310 ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
311
312 $num_feeds = db_fetch_result($result, 0, "cf");
313
314 $config["num_feeds"] = (int)$num_feeds;
315
3acc0da6 316 print api_wrap_reply(API_STATUS_OK, $seq, $config);
7c6d05cd 317
4d557a13 318 break;
7c6d05cd 319
cc374435
AD
320 case "updateFeed":
321 $feed_id = db_escape_string($_REQUEST["feed_id"]);
322
c633e370 323 update_rss_feed($link, $feed_id, true);
cc374435 324
3acc0da6 325 print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));
c45ffc0c 326
cc374435
AD
327 break;
328
ca75c2e2
AD
329 case "catchupFeed":
330 $feed_id = db_escape_string($_REQUEST["feed_id"]);
ee273da6 331 $is_cat = db_escape_string($_REQUEST["is_cat"]);
ca75c2e2 332
423e6e55 333 catchup_feed($link, $feed_id, $is_cat);
ca75c2e2 334
3acc0da6 335 print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK"));
ca75c2e2
AD
336
337 break;
338
4d557a13
AD
339 case "getPref":
340 $pref_name = db_escape_string($_REQUEST["pref_name"]);
3acc0da6
AD
341
342 print api_wrap_reply(API_STATUS_OK, $seq,
343 array("value" => get_pref($link, $pref_name)));
378a548c 344 break;
70543b6a
AD
345
346 /* Method added for ttrss-reader for Android */
347 case "getArticles":
ee273da6 348 $isCategory = (int)db_escape_string($_REQUEST["is_cat"]);
70543b6a
AD
349 $id = (int)db_escape_string($_REQUEST["id"]);
350 $displayUnread = (int)db_escape_string($_REQUEST["unread"]);
351 $limit = (int)db_escape_string($_REQUEST["limit"]);
352 $feeds = array();
353
354 if ($isCategory > 0) {
355 // Get Feeds of the category
356
357 if ($id == 0) {
358 $category_part = "cat_id is NULL";
359 } else {
360 $category_part = "cat_id = '$id'";
361 }
362
363 $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE ".
364 $category_part." AND owner_uid = '".$_SESSION["uid"]."'");
365
366 while ($line = db_fetch_assoc($result)) {
367 array_push($feeds, $line["id"]);
368 }
369
370 // Virtual feeds
371 $match_part = "";
372 if ($id == -1) {
373 $match_part = "marked = true";
374 array_push($feeds, -1);
375 } else if ($id == -2) {
376 $match_part = "published = true";
377 array_push($feeds, -2);
378 } else if ($id == -3) {
379 $match_part = "unread = true";
380 array_push($feeds, -3);
381
382 $intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE", $owner_uid);
383
384 if (DB_TYPE == "pgsql") {
385 $match_part .= " AND updated > NOW() - INTERVAL '$intl hour' ";
386 } else {
387 $match_part .= " AND updated > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
388 }
389 } else if ($id == -4) {
390 $match_part = "true";
391 array_push($feeds, -4);
392 }
393 } else {
394 // Only add one feed
395 array_push($feeds, $id);
396 }
397
398 $ret = array();
399
400 if (DB_TYPE == "mysql") {
401 $limit_part = " LIMIT 0,".$limit;
402 } else if (DB_TYPE == "pgsql") {
403 $limit_part = " LIMIT ".$limit;
404 } else {
405 $limit_part = "";
406 }
407
408 // Fetch articles for the feeds
409 foreach ($feeds as $feed) {
410
411 if ($match_part) {
412 $from_qpart = "ttrss_user_entries,ttrss_feeds,ttrss_entries";
413 $feeds_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND";
414
415 $query = "SELECT ttrss_entries.id,ttrss_entries.title,link,content,feed_id,comments,int_id,
416 marked,unread,published,".SUBSTRING_FOR_DATE."(updated,1,16) as updated,author
417 FROM $from_qpart WHERE
418 ttrss_user_entries.ref_id = ttrss_entries.id AND
419 $feeds_qpart ($match_part) AND ttrss_user_entries.owner_uid = ".$_SESSION["uid"]." ORDER BY updated DESC".$limit_part;
420
421 $result = db_query($link, $query);
422 } else {
423 $query = "SELECT ttrss_entries.id,ttrss_entries.title,link,content,feed_id,comments,int_id,
424 marked,unread,published,".SUBSTRING_FOR_DATE."(updated,1,16) as updated,author
425 FROM ttrss_entries,ttrss_user_entries
426 WHERE feed_id = '".$feed."' AND ref_id = id AND owner_uid = ".
427 $_SESSION["uid"]." AND unread >= '".$displayUnread."' ORDER BY updated DESC".$limit_part;
428
429 $result = db_query($link, $query);
430 }
431
432 $articles = array();
433 $i=0;
434 while ($i < mysql_numrows($result)) {
435
436 $article_id = db_fetch_result($result, $i, "id");
437
438 $attachments = get_article_enclosures($link, $article_id);
439
440 $article = array(
441 "id" => db_fetch_result($result, $i, "ttrss_entries.id"),
442 "title" => db_fetch_result($result, $i, "ttrss_entries.title"),
443 "link" => db_fetch_result($result, $i, "link"),
444 "labels" => get_article_labels($link, $article_id),
445 "unread" => sql_bool_to_bool(db_fetch_result($result, $i, "unread")),
446 "marked" => sql_bool_to_bool(db_fetch_result($result, $i, "marked")),
447 "published" => sql_bool_to_bool(db_fetch_result($result, $i, "published")),
448 "comments" => db_fetch_result($result, $i, "comments"),
449 "author" => db_fetch_result($result, $i, "author"),
450 "updated" => strtotime(db_fetch_result($result, $i, "updated")),
451 "content" => db_fetch_result($result, $i, "content"),
452 "feed_id" => db_fetch_result($result, $i, "feed_id"),
453 "attachments" => $attachments
454 );
455
456 array_push($ret, $article);
457
458 $i++;
459 }
460 }
461
3acc0da6 462 print api_wrap_reply(API_STATUS_OK, $seq, $ret);
70543b6a
AD
463 break;
464
465 /* Method added for ttrss-reader for Android */
466 case "getNewArticles":
467 $time = (int) db_escape_string($_REQUEST["time"]);
468 // unread=1 zeigt alle an, unread=0 nur ungelesene
469 $displayUnread = (int) db_escape_string($_REQUEST["unread"]);
470
471 if (DB_TYPE == "mysql") {
472 $db_time_function = " AND last_updated > FROM_UNIXTIME(".$time.")";
473 } else if (DB_TYPE == "pgsql") {
474 $db_time_function = " AND last_updated > to_timestamp(".$time.")";
475 } else {
476 $db_time_function = "";
477 }
478
479 if (DB_TYPE == "mysql") {
480 $db_time_function2 = " AND updated > FROM_UNIXTIME(".$time.")";
481 } else if (DB_TYPE == "pgsql") {
482 $db_time_function2 = " AND updated > to_timestamp(".$time.")";
483 } else {
484 $db_time_function2 = "";
485 }
486
487 $cats = array();
488
489
490 // Add uncategorized feeds
491 $unread = getFeedUnread($link, 0, true);
492 if ($unread || $displayUnread > 0) {
493 $feeds = array();
494 $result_0 = db_query($link, "SELECT id, feed_url, cat_id, title, ".
495 SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated ".
496 "FROM ttrss_feeds WHERE cat_id IS null AND owner_uid = '".$_SESSION["uid"]."'" . $db_time_function);
497
498 while ($line_feeds = db_fetch_assoc($result_0)) {
499 $unread_feed = getFeedUnread($link, $line_feeds["id"], false);
500 if ($unread || $displayUnread > 0) {
501
502 $result_1 = db_query($link, "SELECT id,title,link,content,feed_id,comments,int_id,
503 marked,unread,published,".
504 SUBSTRING_FOR_DATE."(updated,1,16) as updated,author
505 FROM ttrss_entries,ttrss_user_entries
506 WHERE feed_id = '".$line_feeds["id"]."' AND ref_id = id AND owner_uid = " .
507 $_SESSION["uid"]." AND unread >= '".$displayUnread."'" . $db_time_function2);
508
509 $articles = array();
510 while ($line_articles = db_fetch_assoc($result_1)) {
511 $article_id = db_fetch_result($result, $i, "id");
512 $attachments = get_article_enclosures($link, $article_id);
513 array_push($articles, $article = array(
514 "id" => $line_articles["id"],
515 "title" => $line_articles["title"],
516 "link" => $line_articles["link"],
517 "labels" => $article_id,
518 "unread" => $line_articles["unread"],
519 "marked" => $line_articles["marked"],
520 "published" => $line_articles["published"],
521 "comments" => $line_articles["comments"],
522 "author" => $line_articles["author"],
523 "updated" => strtotime($line_articles["updated"]),
524 "content" => $line_articles["content"],
525 "feed_id" => $line_articles["feed_id"],
526 "attachments" => $attachments));
527 }
528
529 array_push($feeds, array(
530 "feed_url" => $line_feeds["feed_url"],
531 "title" => $line_feeds["title"],
532 "id" => (int)$line_feeds["id"],
533 "unread" => (int)$unread_feed,
534 "has_icon" => $has_icon,
535 "cat_id" => (int)$line_feeds["cat_id"],
536 "last_updated" => strtotime($line_feeds["last_updated"]),
537 "articles" => $articles
538 ));
539 }
540 }
541
542 array_push($cats,
543 array(
544 "id" => 0,
545 "title" => "Uncategorized Feeds",
546 "unread" => $unread,
547 "feeds" => $feeds));
548 }
b792cd70 549
70543b6a
AD
550
551 $result = db_query($link, "SELECT id, title FROM ttrss_feed_categories WHERE owner_uid = " . $_SESSION["uid"]);
552 while ($line = db_fetch_assoc($result)) {
553 $unread = getFeedUnread($link, $line["id"], true);
554
555 if ($unread || $displayUnread > 0) {
556 $feeds = array();
557 $result_0 = db_query($link, "SELECT id, feed_url, cat_id, title, ".
558 SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated ".
559 "FROM ttrss_feeds WHERE cat_id = '".
560 $line["id"]."' AND owner_uid = '".$_SESSION["uid"]."'" . $db_time_function);
561
562 while ($line_feeds = db_fetch_assoc($result_0)) {
563 $unread_feed = getFeedUnread($link, $line_feeds["id"], false);
564 if ($unread_feed || $displayUnread > 0) {
565
566 $result_1 = db_query($link, "SELECT id,title,link,content,feed_id,comments,int_id,
567 marked,unread,published,".
568 SUBSTRING_FOR_DATE."(updated,1,16) as updated,author
569 FROM ttrss_entries,ttrss_user_entries
570 WHERE feed_id = '".$line_feeds["id"]."' AND ref_id = id AND owner_uid = " .
571 $_SESSION["uid"]." AND unread >= '".$displayUnread."'" . $db_time_function2);
572
573 $articles = array();
574 while ($line_articles = db_fetch_assoc($result_1)) {
575 $article_id = db_fetch_result($result, $i, "id");
576 $attachments = get_article_enclosures($link, $article_id);
577 array_push($articles, $article = array(
578 "id" => $line_articles["id"],
579 "title" => $line_articles["title"],
580 "link" => $line_articles["link"],
581 "labels" => $article_id,
582 "unread" => $line_articles["unread"],
583 "marked" => $line_articles["marked"],
584 "published" => $line_articles["published"],
585 "comments" => $line_articles["comments"],
586 "author" => $line_articles["author"],
587 "updated" => strtotime($line_articles["updated"]),
588 "content" => $line_articles["content"],
589 "feed_id" => $line_articles["feed_id"],
590 "attachments" => $attachments));
591 }
592
593 array_push($feeds, array(
594 "feed_url" => $line_feeds["feed_url"],
595 "title" => $line_feeds["title"],
596 "id" => (int)$line_feeds["id"],
597 "unread" => (int)$unread_feed,
598 "cat_id" => (int)$line_feeds["cat_id"],
599 "last_updated" => strtotime($line_feeds["last_updated"]),
600 "articles" => $articles
601 ));
602
603 }
604 }
605
606 array_push($cats,
607 array(
608 "id" => $line["id"],
609 "title" => $line["title"],
610 "unread" => $unread,
611 "feeds" => $feeds));
612 }
613 }
3acc0da6 614 print api_wrap_reply(API_STATUS_OK, $seq, $cats);
70543b6a
AD
615 break;
616
b792cd70 617 default:
3acc0da6
AD
618 print api_wrap_reply(API_STATUS_ERR, $seq,
619 array("error" => 'UNKNOWN_METHOD'));
b792cd70
AD
620 break;
621
378a548c
AD
622 }
623
624 db_close($link);
625
626?>