]> git.wh0rd.org - tt-rss.git/blob - classes/api.php
Merge pull request #77 from scarabeusiv/master
[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 $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
355
356 update_rss_feed($this->link, $feed_id, true);
357
358 print $this->wrap(self::STATUS_OK, array("status" => "OK"));
359 }
360
361 function catchupFeed() {
362 $feed_id = db_escape_string($this->link, $_REQUEST["feed_id"]);
363 $is_cat = db_escape_string($this->link, $_REQUEST["is_cat"]);
364
365 catchup_feed($this->link, $feed_id, $is_cat);
366
367 print $this->wrap(self::STATUS_OK, array("status" => "OK"));
368 }
369
370 function getPref() {
371 $pref_name = db_escape_string($this->link, $_REQUEST["pref_name"]);
372
373 print $this->wrap(self::STATUS_OK, array("value" => get_pref($this->link, $pref_name)));
374 }
375
376 function getLabels() {
377 //$article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
378
379 $article_id = (int)$_REQUEST['article_id'];
380
381 $rv = array();
382
383 $result = db_query($this->link, "SELECT id, caption, fg_color, bg_color
384 FROM ttrss_labels2
385 WHERE owner_uid = '".$_SESSION['uid']."' ORDER BY caption");
386
387 if ($article_id)
388 $article_labels = get_article_labels($this->link, $article_id);
389 else
390 $article_labels = array();
391
392 while ($line = db_fetch_assoc($result)) {
393
394 $checked = false;
395 foreach ($article_labels as $al) {
396 if ($al[0] == $line['id']) {
397 $checked = true;
398 break;
399 }
400 }
401
402 array_push($rv, array(
403 "id" => (int)$line['id'],
404 "caption" => $line['caption'],
405 "fg_color" => $line['fg_color'],
406 "bg_color" => $line['bg_color'],
407 "checked" => $checked));
408 }
409
410 print $this->wrap(self::STATUS_OK, $rv);
411 }
412
413 function setArticleLabel() {
414
415 $article_ids = array_filter(explode(",", db_escape_string($this->link, $_REQUEST["article_ids"])), is_numeric);
416 $label_id = (int) db_escape_string($this->link, $_REQUEST['label_id']);
417 $assign = (bool) db_escape_string($this->link, $_REQUEST['assign']) == "true";
418
419 $label = db_escape_string($this->link, label_find_caption($this->link,
420 $label_id, $_SESSION["uid"]));
421
422 $num_updated = 0;
423
424 if ($label) {
425
426 foreach ($article_ids as $id) {
427
428 if ($assign)
429 label_add_article($this->link, $id, $label, $_SESSION["uid"]);
430 else
431 label_remove_article($this->link, $id, $label, $_SESSION["uid"]);
432
433 ++$num_updated;
434
435 }
436 }
437
438 print $this->wrap(self::STATUS_OK, array("status" => "OK",
439 "updated" => $num_updated));
440
441 }
442
443 function index() {
444 print $this->wrap(self::STATUS_ERR, array("error" => 'UNKNOWN_METHOD'));
445 }
446
447 function shareToPublished() {
448 $title = db_escape_string($this->link, strip_tags($_REQUEST["title"]));
449 $url = db_escape_string($this->link, strip_tags($_REQUEST["url"]));
450 $content = db_escape_string($this->link, strip_tags($_REQUEST["content"]));
451
452 if (Article::create_published_article($this->link, $title, $url, $content, "", $_SESSION["uid"])) {
453 print $this->wrap(self::STATUS_OK, array("status" => 'OK'));
454 } else {
455 print $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed'));
456 }
457 }
458
459 static function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset, $include_nested = false) {
460
461 $feeds = array();
462
463 /* Labels */
464
465 if ($cat_id == -4 || $cat_id == -2) {
466 $counters = getLabelCounters($link, true);
467
468 foreach (array_values($counters) as $cv) {
469
470 $unread = $cv["counter"];
471
472 if ($unread || !$unread_only) {
473
474 $row = array(
475 "id" => $cv["id"],
476 "title" => $cv["description"],
477 "unread" => $cv["counter"],
478 "cat_id" => -2,
479 );
480
481 array_push($feeds, $row);
482 }
483 }
484 }
485
486 /* Virtual feeds */
487
488 if ($cat_id == -4 || $cat_id == -1) {
489 foreach (array(-1, -2, -3, -4, -6, 0) as $i) {
490 $unread = getFeedUnread($link, $i);
491
492 if ($unread || !$unread_only) {
493 $title = getFeedTitle($link, $i);
494
495 $row = array(
496 "id" => $i,
497 "title" => $title,
498 "unread" => $unread,
499 "cat_id" => -1,
500 );
501 array_push($feeds, $row);
502 }
503
504 }
505 }
506
507 /* Child cats */
508
509 if ($include_nested && $cat_id) {
510 $result = db_query($link, "SELECT
511 id, title FROM ttrss_feed_categories
512 WHERE parent_cat = '$cat_id' AND owner_uid = " . $_SESSION["uid"] .
513 " ORDER BY id, title");
514
515 while ($line = db_fetch_assoc($result)) {
516 $unread = getFeedUnread($link, $line["id"], true) +
517 getCategoryChildrenUnread($link, $line["id"]);
518
519 if ($unread || !$unread_only) {
520 $row = array(
521 "id" => $line["id"],
522 "title" => $line["title"],
523 "unread" => $unread,
524 "is_cat" => true,
525 );
526 array_push($feeds, $row);
527 }
528 }
529 }
530
531 /* Real feeds */
532
533 if ($limit) {
534 $limit_qpart = "LIMIT $limit OFFSET $offset";
535 } else {
536 $limit_qpart = "";
537 }
538
539 if ($cat_id == -4 || $cat_id == -3) {
540 $result = db_query($link, "SELECT
541 id, feed_url, cat_id, title, order_id, ".
542 SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
543 FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] .
544 " ORDER BY cat_id, title " . $limit_qpart);
545 } else {
546
547 if ($cat_id)
548 $cat_qpart = "cat_id = '$cat_id'";
549 else
550 $cat_qpart = "cat_id IS NULL";
551
552 $result = db_query($link, "SELECT
553 id, feed_url, cat_id, title, order_id, ".
554 SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
555 FROM ttrss_feeds WHERE
556 $cat_qpart AND owner_uid = " . $_SESSION["uid"] .
557 " ORDER BY cat_id, title " . $limit_qpart);
558 }
559
560 while ($line = db_fetch_assoc($result)) {
561
562 $unread = getFeedUnread($link, $line["id"]);
563
564 $has_icon = feed_has_icon($line['id']);
565
566 if ($unread || !$unread_only) {
567
568 $row = array(
569 "feed_url" => $line["feed_url"],
570 "title" => $line["title"],
571 "id" => (int)$line["id"],
572 "unread" => (int)$unread,
573 "has_icon" => $has_icon,
574 "cat_id" => (int)$line["cat_id"],
575 "last_updated" => (int) strtotime($line["last_updated"]),
576 "order_id" => (int) $line["order_id"],
577 );
578
579 array_push($feeds, $row);
580 }
581 }
582
583 return $feeds;
584 }
585
586 static function api_get_headlines($link, $feed_id, $limit, $offset,
587 $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
588 $include_attachments, $since_id,
589 $search = "", $search_mode = "",
590 $include_nested = false, $sanitize_content = true) {
591
592 $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
593 $view_mode, $is_cat, $search, $search_mode,
594 $order, $offset, 0, false, $since_id, $include_nested);
595
596 $result = $qfh_ret[0];
597 $feed_title = $qfh_ret[1];
598
599 $headlines = array();
600
601 while ($line = db_fetch_assoc($result)) {
602 $is_updated = ($line["last_read"] == "" &&
603 ($line["unread"] != "t" && $line["unread"] != "1"));
604
605 $tags = explode(",", $line["tag_cache"]);
606 $labels = json_decode($line["label_cache"], true);
607
608 //if (!$tags) $tags = get_article_tags($link, $line["id"]);
609 //if (!$labels) $labels = get_article_labels($link, $line["id"]);
610
611 $headline_row = array(
612 "id" => (int)$line["id"],
613 "unread" => sql_bool_to_bool($line["unread"]),
614 "marked" => sql_bool_to_bool($line["marked"]),
615 "published" => sql_bool_to_bool($line["published"]),
616 "updated" => (int) strtotime($line["updated"]),
617 "is_updated" => $is_updated,
618 "title" => $line["title"],
619 "link" => $line["link"],
620 "feed_id" => $line["feed_id"],
621 "tags" => $tags,
622 );
623
624 if ($include_attachments)
625 $headline_row['attachments'] = get_article_enclosures($link,
626 $line['id']);
627
628 if ($show_excerpt) {
629 $excerpt = truncate_string(strip_tags($line["content_preview"]), 100);
630 $headline_row["excerpt"] = $excerpt;
631 }
632
633 if ($show_content) {
634
635 if ($line["cached_content"] != "") {
636 $line["content_preview"] =& $line["cached_content"];
637 }
638
639 if ($sanitize_content) {
640 $headline_row["content"] = sanitize($link,
641 $line["content_preview"],
642 sql_bool_to_bool($line['hide_images']),
643 false, $line["site_url"]);
644 } else {
645 $headline_row["content"] = $line["content_preview"];
646 }
647 }
648
649 // unify label output to ease parsing
650 if ($labels["no-labels"] == 1) $labels = array();
651
652 $headline_row["labels"] = $labels;
653
654 $headline_row["feed_title"] = $line["feed_title"];
655
656 $headline_row["comments_count"] = (int)$line["num_comments"];
657 $headline_row["comments_link"] = $line["comments"];
658
659 $headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
660
661 global $pluginhost;
662 foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_API) as $p) {
663 $headline_row = $p->hook_render_article_api($headline_row);
664 }
665
666 array_push($headlines, $headline_row);
667 }
668
669 return $headlines;
670 }
671
672 function unsubscribeFeed() {
673 $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]);
674
675 $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
676 id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
677
678 if (db_num_rows($result) != 0) {
679 Pref_Feeds::remove_feed($this->link, $feed_id, $_SESSION["uid"]);
680 print $this->wrap(self::STATUS_OK, array("status" => "OK"));
681 } else {
682 print $this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND"));
683 }
684 }
685
686 function subscribeToFeed() {
687 $feed_url = db_escape_string($this->link, $_REQUEST["feed_url"]);
688 $category_id = (int) db_escape_string($this->link, $_REQUEST["category_id"]);
689 $login = db_escape_string($this->link, $_REQUEST["login"]);
690 $password = db_escape_string($this->link, $_REQUEST["password"]);
691
692 if ($feed_url) {
693 $rc = subscribe_to_feed($this->link, $feed_url, $category_id,
694 $login, $password, false);
695
696 print $this->wrap(self::STATUS_OK, array("status" => $rc));
697 } else {
698 print $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
699 }
700 }
701
702 }
703
704 ?>