]> git.wh0rd.org - tt-rss.git/blob - classes/api.php
merge new hu_HU translation
[tt-rss.git] / classes / api.php
1 <?php
2
3 class API extends Handler {
4
5 const API_LEVEL = 5;
6
7 const STATUS_OK = 0;
8 const STATUS_ERR = 1;
9
10 private $seq;
11
12 function before($method) {
13 if (parent::before($method)) {
14 header("Content-Type: text/json");
15
16 if (!$_SESSION["uid"] && $method != "login" && $method != "isloggedin") {
17 print $this->wrap(self::STATUS_ERR, array("error" => 'NOT_LOGGED_IN'));
18 return false;
19 }
20
21 if ($_SESSION["uid"] && $method != "logout" && !get_pref($this->link, 'ENABLE_API_ACCESS')) {
22 print $this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED'));
23 return false;
24 }
25
26 $this->seq = (int) $_REQUEST['seq'];
27
28 return true;
29 }
30 return false;
31 }
32
33 function wrap($status, $reply) {
34 print json_encode(array("seq" => $this->seq,
35 "status" => $status,
36 "content" => $reply));
37 }
38
39 function getVersion() {
40 $rv = array("version" => VERSION);
41 print $this->wrap(self::STATUS_OK, $rv);
42 }
43
44 function getApiLevel() {
45 $rv = array("level" => self::API_LEVEL);
46 print $this->wrap(self::STATUS_OK, $rv);
47 }
48
49 function login() {
50 $login = db_escape_string($this->link, $_REQUEST["user"]);
51 $password = $_REQUEST["password"];
52 $password_base64 = base64_decode($_REQUEST["password"]);
53
54 if (SINGLE_USER_MODE) $login = "admin";
55
56 $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$login'");
57
58 if (db_num_rows($result) != 0) {
59 $uid = db_fetch_result($result, 0, "id");
60 } else {
61 $uid = 0;
62 }
63
64 if (!$uid) {
65 print $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
66 return;
67 }
68
69 if (get_pref($this->link, "ENABLE_API_ACCESS", $uid)) {
70 if (authenticate_user($this->link, $login, $password)) { // try login with normal password
71 print $this->wrap(self::STATUS_OK, array("session_id" => session_id(),
72 "api_level" => self::API_LEVEL));
73 } else if (authenticate_user($this->link, $login, $password_base64)) { // else try with base64_decoded password
74 print $this->wrap(self::STATUS_OK, array("session_id" => session_id(),
75 "api_level" => self::API_LEVEL));
76 } else { // else we are not logged in
77 print $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
78 }
79 } else {
80 print $this->wrap(self::STATUS_ERR, array("error" => "API_DISABLED"));
81 }
82
83 }
84
85 function logout() {
86 logout_user();
87 print $this->wrap(self::STATUS_OK, array("status" => "OK"));
88 }
89
90 function isLoggedIn() {
91 print $this->wrap(self::STATUS_OK, array("status" => $_SESSION["uid"] != ''));
92 }
93
94 function getUnread() {
95 $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
96 $is_cat = db_escape_string($this->link, $_REQUEST["is_cat"]);
97
98 if ($feed_id) {
99 print $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($this->link, $feed_id, $is_cat)));
100 } else {
101 print $this->wrap(self::STATUS_OK, array("unread" => getGlobalUnread($this->link)));
102 }
103 }
104
105 /* Method added for ttrss-reader for Android */
106 function getCounters() {
107 print $this->wrap(self::STATUS_OK, getAllCounters($this->link));
108 }
109
110 function getFeeds() {
111 $cat_id = db_escape_string($this->link, $_REQUEST["cat_id"]);
112 $unread_only = sql_bool_to_bool($_REQUEST["unread_only"]);
113 $limit = (int) db_escape_string($this->link, $_REQUEST["limit"]);
114 $offset = (int) db_escape_string($this->link, $_REQUEST["offset"]);
115 $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
116
117 $feeds = $this->api_get_feeds($this->link, $cat_id, $unread_only, $limit, $offset, $include_nested);
118
119 print $this->wrap(self::STATUS_OK, $feeds);
120 }
121
122 function getCategories() {
123 $unread_only = sql_bool_to_bool($_REQUEST["unread_only"]);
124 $enable_nested = sql_bool_to_bool($_REQUEST["enable_nested"]);
125
126 // TODO do not return empty categories, return Uncategorized and standard virtual cats
127
128 if ($enable_nested)
129 $nested_qpart = "parent_cat IS NULL";
130 else
131 $nested_qpart = "true";
132
133 $result = db_query($this->link, "SELECT
134 id, title, order_id, (SELECT COUNT(id) FROM
135 ttrss_feeds WHERE
136 ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds,
137 (SELECT COUNT(id) FROM
138 ttrss_feed_categories AS c2 WHERE
139 c2.parent_cat = ttrss_feed_categories.id) AS num_cats
140 FROM ttrss_feed_categories
141 WHERE $nested_qpart AND owner_uid = " .
142 $_SESSION["uid"]);
143
144 $cats = array();
145
146 while ($line = db_fetch_assoc($result)) {
147 if ($line["num_feeds"] > 0 || $line["num_cats"] > 0) {
148 $unread = getFeedUnread($this->link, $line["id"], true);
149
150 if ($enable_nested)
151 $unread += getCategoryChildrenUnread($this->link, $line["id"]);
152
153 if ($unread || !$unread_only) {
154 array_push($cats, array("id" => $line["id"],
155 "title" => $line["title"],
156 "unread" => $unread,
157 "order_id" => (int) $line["order_id"],
158 ));
159 }
160 }
161 }
162
163 foreach (array(-2,-1,0) as $cat_id) {
164 $unread = getFeedUnread($this->link, $cat_id, true);
165
166 if ($unread || !$unread_only) {
167 array_push($cats, array("id" => $cat_id,
168 "title" => getCategoryTitle($this->link, $cat_id),
169 "unread" => $unread));
170 }
171 }
172
173 print $this->wrap(self::STATUS_OK, $cats);
174 }
175
176 function getHeadlines() {
177 $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
178 if ($feed_id != "") {
179
180 $limit = (int)db_escape_string($this->link, $_REQUEST["limit"]);
181
182 if (!$limit || $limit >= 60) $limit = 60;
183
184 $offset = (int)db_escape_string($this->link, $_REQUEST["skip"]);
185 $filter = db_escape_string($this->link, $_REQUEST["filter"]);
186 $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
187 $show_excerpt = sql_bool_to_bool($_REQUEST["show_excerpt"]);
188 $show_content = sql_bool_to_bool($_REQUEST["show_content"]);
189 /* all_articles, unread, adaptive, marked, updated */
190 $view_mode = db_escape_string($this->link, $_REQUEST["view_mode"]);
191 $include_attachments = sql_bool_to_bool($_REQUEST["include_attachments"]);
192 $since_id = (int)db_escape_string($this->link, $_REQUEST["since_id"]);
193 $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
194 $sanitize_content = true;
195
196 /* do not rely on params below */
197
198 $search = db_escape_string($this->link, $_REQUEST["search"]);
199 $search_mode = db_escape_string($this->link, $_REQUEST["search_mode"]);
200
201 $headlines = $this->api_get_headlines($this->link, $feed_id, $limit, $offset,
202 $filter, $is_cat, $show_excerpt, $show_content, $view_mode, false,
203 $include_attachments, $since_id, $search, $search_mode,
204 $include_nested, $sanitize_content);
205
206 print $this->wrap(self::STATUS_OK, $headlines);
207 } else {
208 print $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
209 }
210 }
211
212 function updateArticle() {
213 $article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
214 $mode = (int) db_escape_string($this->link, $_REQUEST["mode"]);
215 $data = db_escape_string($this->link, $_REQUEST["data"]);
216 $field_raw = (int)db_escape_string($this->link, $_REQUEST["field"]);
217
218 $field = "";
219 $set_to = "";
220
221 switch ($field_raw) {
222 case 0:
223 $field = "marked";
224 $additional_fields = ",last_marked = NOW()";
225 break;
226 case 1:
227 $field = "published";
228 $additional_fields = ",last_published = NOW()";
229 break;
230 case 2:
231 $field = "unread";
232 $additional_fields = ",last_read = NOW()";
233 break;
234 case 3:
235 $field = "note";
236 };
237
238 switch ($mode) {
239 case 1:
240 $set_to = "true";
241 break;
242 case 0:
243 $set_to = "false";
244 break;
245 case 2:
246 $set_to = "NOT $field";
247 break;
248 }
249
250 if ($field == "note") $set_to = "'$data'";
251
252 if ($field && $set_to && count($article_ids) > 0) {
253
254 $article_ids = join(", ", $article_ids);
255
256 $result = db_query($this->link, "UPDATE ttrss_user_entries SET $field = $set_to $additional_fields WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
257
258 $num_updated = db_affected_rows($this->link, $result);
259
260 if ($num_updated > 0 && $field == "unread") {
261 $result = db_query($this->link, "SELECT DISTINCT feed_id FROM ttrss_user_entries
262 WHERE ref_id IN ($article_ids)");
263
264 while ($line = db_fetch_assoc($result)) {
265 ccache_update($this->link, $line["feed_id"], $_SESSION["uid"]);
266 }
267 }
268
269 if ($num_updated > 0 && $field == "published") {
270 if (PUBSUBHUBBUB_HUB) {
271 $rss_link = get_self_url_prefix() .
272 "/public.php?op=rss&id=-2&key=" .
273 get_feed_access_key($this->link, -2, false);
274
275 $p = new Publisher(PUBSUBHUBBUB_HUB);
276 $pubsub_result = $p->publish_update($rss_link);
277 }
278 }
279
280 print $this->wrap(self::STATUS_OK, array("status" => "OK",
281 "updated" => $num_updated));
282
283 } else {
284 print $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
285 }
286
287 }
288
289 function getArticle() {
290
291 $article_id = join(",", array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_id"])), is_numeric));
292
293 $query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id,
294 marked,unread,published,
295 ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
296 author
297 FROM ttrss_entries,ttrss_user_entries
298 WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
299 $_SESSION["uid"] ;
300
301 $result = db_query($this->link, $query);
302
303 $articles = array();
304
305 if (db_num_rows($result) != 0) {
306
307 while ($line = db_fetch_assoc($result)) {
308
309 $attachments = get_article_enclosures($this->link, $line['id']);
310
311 $article = array(
312 "id" => $line["id"],
313 "title" => $line["title"],
314 "link" => $line["link"],
315 "labels" => get_article_labels($this->link, $line['id']),
316 "unread" => sql_bool_to_bool($line["unread"]),
317 "marked" => sql_bool_to_bool($line["marked"]),
318 "published" => sql_bool_to_bool($line["published"]),
319 "comments" => $line["comments"],
320 "author" => $line["author"],
321 "updated" => (int) strtotime($line["updated"]),
322 "content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"],
323 "feed_id" => $line["feed_id"],
324 "attachments" => $attachments
325 );
326
327 array_push($articles, $article);
328
329 }
330 }
331
332 print $this->wrap(self::STATUS_OK, $articles);
333
334 }
335
336 function getConfig() {
337 $config = array(
338 "icons_dir" => ICONS_DIR,
339 "icons_url" => ICONS_URL);
340
341 $config["daemon_is_running"] = file_is_locked("update_daemon.lock");
342
343 $result = db_query($this->link, "SELECT COUNT(*) AS cf FROM
344 ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
345
346 $num_feeds = db_fetch_result($result, 0, "cf");
347
348 $config["num_feeds"] = (int)$num_feeds;
349
350 print $this->wrap(self::STATUS_OK, $config);
351 }
352
353 function updateFeed() {
354 require_once "include/rssfuncs.php";
355
356 $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]);
357
358 update_rss_feed($this->link, $feed_id, true);
359
360 print $this->wrap(self::STATUS_OK, array("status" => "OK"));
361 }
362
363 function catchupFeed() {
364 $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
365 $is_cat = db_escape_string($this->link, $_REQUEST["is_cat"]);
366
367 catchup_feed($this->link, $feed_id, $is_cat);
368
369 print $this->wrap(self::STATUS_OK, array("status" => "OK"));
370 }
371
372 function getPref() {
373 $pref_name = db_escape_string($this->link, $_REQUEST["pref_name"]);
374
375 print $this->wrap(self::STATUS_OK, array("value" => get_pref($this->link, $pref_name)));
376 }
377
378 function getLabels() {
379 //$article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
380
381 $article_id = (int)$_REQUEST['article_id'];
382
383 $rv = array();
384
385 $result = db_query($this->link, "SELECT id, caption, fg_color, bg_color
386 FROM ttrss_labels2
387 WHERE owner_uid = '".$_SESSION['uid']."' ORDER BY caption");
388
389 if ($article_id)
390 $article_labels = get_article_labels($this->link, $article_id);
391 else
392 $article_labels = array();
393
394 while ($line = db_fetch_assoc($result)) {
395
396 $checked = false;
397 foreach ($article_labels as $al) {
398 if ($al[0] == $line['id']) {
399 $checked = true;
400 break;
401 }
402 }
403
404 array_push($rv, array(
405 "id" => (int)$line['id'],
406 "caption" => $line['caption'],
407 "fg_color" => $line['fg_color'],
408 "bg_color" => $line['bg_color'],
409 "checked" => $checked));
410 }
411
412 print $this->wrap(self::STATUS_OK, $rv);
413 }
414
415 function setArticleLabel() {
416
417 $article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
418 $label_id = (int) db_escape_string($this->link, $_REQUEST['label_id']);
419 $assign = (bool) db_escape_string($this->link, $_REQUEST['assign']) == "true";
420
421 $label = db_escape_string($this->link, label_find_caption($this->link,
422 $label_id, $_SESSION["uid"]));
423
424 $num_updated = 0;
425
426 if ($label) {
427
428 foreach ($article_ids as $id) {
429
430 if ($assign)
431 label_add_article($this->link, $id, $label, $_SESSION["uid"]);
432 else
433 label_remove_article($this->link, $id, $label, $_SESSION["uid"]);
434
435 ++$num_updated;
436
437 }
438 }
439
440 print $this->wrap(self::STATUS_OK, array("status" => "OK",
441 "updated" => $num_updated));
442
443 }
444
445 function index() {
446 print $this->wrap(self::STATUS_ERR, array("error" => 'UNKNOWN_METHOD'));
447 }
448
449 function shareToPublished() {
450 $title = db_escape_string($this->link, strip_tags($_REQUEST["title"]));
451 $url = db_escape_string($this->link, strip_tags($_REQUEST["url"]));
452 $content = db_escape_string($this->link, strip_tags($_REQUEST["content"]));
453
454 if (Article::create_published_article($this->link, $title, $url, $content, "", $_SESSION["uid"])) {
455 print $this->wrap(self::STATUS_OK, array("status" => 'OK'));
456 } else {
457 print $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed'));
458 }
459 }
460
461 static function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset, $include_nested = false) {
462
463 $feeds = array();
464
465 /* Labels */
466
467 if ($cat_id == -4 || $cat_id == -2) {
468 $counters = getLabelCounters($link, true);
469
470 foreach (array_values($counters) as $cv) {
471
472 $unread = $cv["counter"];
473
474 if ($unread || !$unread_only) {
475
476 $row = array(
477 "id" => $cv["id"],
478 "title" => $cv["description"],
479 "unread" => $cv["counter"],
480 "cat_id" => -2,
481 );
482
483 array_push($feeds, $row);
484 }
485 }
486 }
487
488 /* Virtual feeds */
489
490 if ($cat_id == -4 || $cat_id == -1) {
491 foreach (array(-1, -2, -3, -4, -6, 0) as $i) {
492 $unread = getFeedUnread($link, $i);
493
494 if ($unread || !$unread_only) {
495 $title = getFeedTitle($link, $i);
496
497 $row = array(
498 "id" => $i,
499 "title" => $title,
500 "unread" => $unread,
501 "cat_id" => -1,
502 );
503 array_push($feeds, $row);
504 }
505
506 }
507 }
508
509 /* Child cats */
510
511 if ($include_nested && $cat_id) {
512 $result = db_query($link, "SELECT
513 id, title FROM ttrss_feed_categories
514 WHERE parent_cat = '$cat_id' AND owner_uid = " . $_SESSION["uid"] .
515 " ORDER BY id, title");
516
517 while ($line = db_fetch_assoc($result)) {
518 $unread = getFeedUnread($link, $line["id"], true) +
519 getCategoryChildrenUnread($link, $line["id"]);
520
521 if ($unread || !$unread_only) {
522 $row = array(
523 "id" => $line["id"],
524 "title" => $line["title"],
525 "unread" => $unread,
526 "is_cat" => true,
527 );
528 array_push($feeds, $row);
529 }
530 }
531 }
532
533 /* Real feeds */
534
535 if ($limit) {
536 $limit_qpart = "LIMIT $limit OFFSET $offset";
537 } else {
538 $limit_qpart = "";
539 }
540
541 if ($cat_id == -4 || $cat_id == -3) {
542 $result = db_query($link, "SELECT
543 id, feed_url, cat_id, title, order_id, ".
544 SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
545 FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] .
546 " ORDER BY cat_id, title " . $limit_qpart);
547 } else {
548
549 if ($cat_id)
550 $cat_qpart = "cat_id = '$cat_id'";
551 else
552 $cat_qpart = "cat_id IS NULL";
553
554 $result = db_query($link, "SELECT
555 id, feed_url, cat_id, title, order_id, ".
556 SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
557 FROM ttrss_feeds WHERE
558 $cat_qpart AND owner_uid = " . $_SESSION["uid"] .
559 " ORDER BY cat_id, title " . $limit_qpart);
560 }
561
562 while ($line = db_fetch_assoc($result)) {
563
564 $unread = getFeedUnread($link, $line["id"]);
565
566 $has_icon = feed_has_icon($line['id']);
567
568 if ($unread || !$unread_only) {
569
570 $row = array(
571 "feed_url" => $line["feed_url"],
572 "title" => $line["title"],
573 "id" => (int)$line["id"],
574 "unread" => (int)$unread,
575 "has_icon" => $has_icon,
576 "cat_id" => (int)$line["cat_id"],
577 "last_updated" => (int) strtotime($line["last_updated"]),
578 "order_id" => (int) $line["order_id"],
579 );
580
581 array_push($feeds, $row);
582 }
583 }
584
585 return $feeds;
586 }
587
588 static function api_get_headlines($link, $feed_id, $limit, $offset,
589 $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
590 $include_attachments, $since_id,
591 $search = "", $search_mode = "",
592 $include_nested = false, $sanitize_content = true) {
593
594 $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
595 $view_mode, $is_cat, $search, $search_mode,
596 $order, $offset, 0, false, $since_id, $include_nested);
597
598 $result = $qfh_ret[0];
599 $feed_title = $qfh_ret[1];
600
601 $headlines = array();
602
603 while ($line = db_fetch_assoc($result)) {
604 $is_updated = ($line["last_read"] == "" &&
605 ($line["unread"] != "t" && $line["unread"] != "1"));
606
607 $tags = explode(",", $line["tag_cache"]);
608 $labels = json_decode($line["label_cache"], true);
609
610 //if (!$tags) $tags = get_article_tags($link, $line["id"]);
611 //if (!$labels) $labels = get_article_labels($link, $line["id"]);
612
613 $headline_row = array(
614 "id" => (int)$line["id"],
615 "unread" => sql_bool_to_bool($line["unread"]),
616 "marked" => sql_bool_to_bool($line["marked"]),
617 "published" => sql_bool_to_bool($line["published"]),
618 "updated" => (int) strtotime($line["updated"]),
619 "is_updated" => $is_updated,
620 "title" => $line["title"],
621 "link" => $line["link"],
622 "feed_id" => $line["feed_id"],
623 "tags" => $tags,
624 );
625
626 if ($include_attachments)
627 $headline_row['attachments'] = get_article_enclosures($link,
628 $line['id']);
629
630 if ($show_excerpt) {
631 $excerpt = truncate_string(strip_tags($line["content_preview"]), 100);
632 $headline_row["excerpt"] = $excerpt;
633 }
634
635 if ($show_content) {
636
637 if ($line["cached_content"] != "") {
638 $line["content_preview"] =& $line["cached_content"];
639 }
640
641 if ($sanitize_content) {
642 $headline_row["content"] = sanitize($link,
643 $line["content_preview"],
644 sql_bool_to_bool($line['hide_images']),
645 false, $line["site_url"]);
646 } else {
647 $headline_row["content"] = $line["content_preview"];
648 }
649 }
650
651 // unify label output to ease parsing
652 if ($labels["no-labels"] == 1) $labels = array();
653
654 $headline_row["labels"] = $labels;
655
656 $headline_row["feed_title"] = $line["feed_title"];
657
658 $headline_row["comments_count"] = (int)$line["num_comments"];
659 $headline_row["comments_link"] = $line["comments"];
660
661 $headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
662
663 global $pluginhost;
664 foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_API) as $p) {
665 $headline_row = $p->hook_render_article_api($headline_row);
666 }
667
668 array_push($headlines, $headline_row);
669 }
670
671 return $headlines;
672 }
673
674 function unsubscribeFeed() {
675 $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]);
676
677 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
678 id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
679
680 if (db_num_rows($result) != 0) {
681 Pref_Feeds::remove_feed($this->link, $feed_id, $_SESSION["uid"]);
682 print $this->wrap(self::STATUS_OK, array("status" => "OK"));
683 } else {
684 print $this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND"));
685 }
686 }
687
688 function subscribeToFeed() {
689 $feed_url = db_escape_string($this->link, $_REQUEST["feed_url"]);
690 $category_id = (int) db_escape_string($this->link, $_REQUEST["category_id"]);
691 $login = db_escape_string($this->link, $_REQUEST["login"]);
692 $password = db_escape_string($this->link, $_REQUEST["password"]);
693
694 if ($feed_url) {
695 $rc = subscribe_to_feed($this->link, $feed_url, $category_id,
696 $login, $password, false);
697
698 print $this->wrap(self::STATUS_OK, array("status" => $rc));
699 } else {
700 print $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
701 }
702 }
703
704 }
705
706 ?>