]> git.wh0rd.org - tt-rss.git/blob - classes/rpc.php
7d39261b13d8973ed1e0dd943e74f0be6116955f
[tt-rss.git] / classes / rpc.php
1 <?php
2 class RPC extends Handler_Protected {
3
4 function csrf_ignore($method) {
5 $csrf_ignored = array("sanitycheck", "completelabels");
6
7 return array_search($method, $csrf_ignored) !== false;
8 }
9
10 function setprofile() {
11 $id = $this->dbh->escape_string($_REQUEST["id"]);
12
13 $_SESSION["profile"] = $id;
14 }
15
16 function remprofiles() {
17 $ids = explode(",", $this->dbh->escape_string(trim($_REQUEST["ids"])));
18
19 foreach ($ids as $id) {
20 if ($_SESSION["profile"] != $id) {
21 $this->dbh->query("DELETE FROM ttrss_settings_profiles WHERE id = '$id' AND
22 owner_uid = " . $_SESSION["uid"]);
23 }
24 }
25 }
26
27 // Silent
28 function addprofile() {
29 $title = $this->dbh->escape_string(trim($_REQUEST["title"]));
30 if ($title) {
31 $this->dbh->query("BEGIN");
32
33 $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles
34 WHERE title = '$title' AND owner_uid = " . $_SESSION["uid"]);
35
36 if ($this->dbh->num_rows($result) == 0) {
37
38 $this->dbh->query("INSERT INTO ttrss_settings_profiles (title, owner_uid)
39 VALUES ('$title', ".$_SESSION["uid"] .")");
40
41 $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles WHERE
42 title = '$title'");
43
44 if ($this->dbh->num_rows($result) != 0) {
45 $profile_id = $this->dbh->fetch_result($result, 0, "id");
46
47 if ($profile_id) {
48 initialize_user_prefs($_SESSION["uid"], $profile_id);
49 }
50 }
51 }
52
53 $this->dbh->query("COMMIT");
54 }
55 }
56
57 // Silent
58 function saveprofile() {
59 $id = $this->dbh->escape_string($_REQUEST["id"]);
60 $title = $this->dbh->escape_string(trim($_REQUEST["value"]));
61
62 if ($id == 0) {
63 print __("Default profile");
64 return;
65 }
66
67 if ($title) {
68 $this->dbh->query("BEGIN");
69
70 $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles
71 WHERE title = '$title' AND owner_uid =" . $_SESSION["uid"]);
72
73 if ($this->dbh->num_rows($result) == 0) {
74 $this->dbh->query("UPDATE ttrss_settings_profiles
75 SET title = '$title' WHERE id = '$id' AND
76 owner_uid = " . $_SESSION["uid"]);
77 print $title;
78 } else {
79 $result = $this->dbh->query("SELECT title FROM ttrss_settings_profiles
80 WHERE id = '$id' AND owner_uid =" . $_SESSION["uid"]);
81 print $this->dbh->fetch_result($result, 0, "title");
82 }
83
84 $this->dbh->query("COMMIT");
85 }
86 }
87
88 // Silent
89 function remarchive() {
90 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
91
92 foreach ($ids as $id) {
93 $result = $this->dbh->query("DELETE FROM ttrss_archived_feeds WHERE
94 (SELECT COUNT(*) FROM ttrss_user_entries
95 WHERE orig_feed_id = '$id') = 0 AND
96 id = '$id' AND owner_uid = ".$_SESSION["uid"]);
97
98 $this->dbh->affected_rows($result);
99 }
100 }
101
102 function addfeed() {
103 $feed = $this->dbh->escape_string($_REQUEST['feed']);
104 $cat = $this->dbh->escape_string($_REQUEST['cat']);
105 $login = $this->dbh->escape_string($_REQUEST['login']);
106 $pass = trim($_REQUEST['pass']); // escaped later
107
108 $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass);
109
110 print json_encode(array("result" => $rc));
111 }
112
113 function togglepref() {
114 $key = $this->dbh->escape_string($_REQUEST["key"]);
115 set_pref($key, !get_pref($key));
116 $value = get_pref($key);
117
118 print json_encode(array("param" =>$key, "value" => $value));
119 }
120
121 function setpref() {
122 // set_pref escapes input, so no need to double escape it here
123 $key = $_REQUEST['key'];
124 $value = str_replace("\n", "<br/>", $_REQUEST['value']);
125
126 set_pref($key, $value, false, $key != 'USER_STYLESHEET');
127
128 print json_encode(array("param" =>$key, "value" => $value));
129 }
130
131 function mark() {
132 $mark = $_REQUEST["mark"];
133 $id = $this->dbh->escape_string($_REQUEST["id"]);
134
135 if ($mark == "1") {
136 $mark = "true";
137 } else {
138 $mark = "false";
139 }
140
141 $this->dbh->query("UPDATE ttrss_user_entries SET marked = $mark,
142 last_marked = NOW()
143 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
144
145 print json_encode(array("message" => "UPDATE_COUNTERS"));
146 }
147
148 function delete() {
149 $ids = $this->dbh->escape_string($_REQUEST["ids"]);
150
151 $this->dbh->query("DELETE FROM ttrss_user_entries
152 WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
153
154 Article::purge_orphans();
155
156 print json_encode(array("message" => "UPDATE_COUNTERS"));
157 }
158
159 function unarchive() {
160 $ids = explode(",", $_REQUEST["ids"]);
161
162 foreach ($ids as $id) {
163 $id = $this->dbh->escape_string(trim($id));
164 $this->dbh->query("BEGIN");
165
166 $result = $this->dbh->query("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
167 WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = $id
168 AND owner_uid = ".$_SESSION["uid"].") AND owner_uid = " . $_SESSION["uid"]);
169
170 if ($this->dbh->num_rows($result) != 0) {
171 $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
172 $site_url = $this->dbh->escape_string(db_fetch_result($result, 0, "site_url"));
173 $title = $this->dbh->escape_string(db_fetch_result($result, 0, "title"));
174
175 $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
176 AND owner_uid = " .$_SESSION["uid"]);
177
178 if ($this->dbh->num_rows($result) == 0) {
179
180 if (!$title) $title = '[Unknown]';
181
182 $result = $this->dbh->query(
183 "INSERT INTO ttrss_feeds
184 (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method)
185 VALUES (".$_SESSION["uid"].",
186 '$feed_url',
187 '$site_url',
188 '$title',
189 NULL, '', '', 0)");
190
191 $result = $this->dbh->query(
192 "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
193 AND owner_uid = ".$_SESSION["uid"]);
194
195 if ($this->dbh->num_rows($result) != 0) {
196 $feed_id = $this->dbh->fetch_result($result, 0, "id");
197 }
198
199 } else {
200 $feed_id = $this->dbh->fetch_result($result, 0, "id");
201 }
202
203 if ($feed_id) {
204 $result = $this->dbh->query("UPDATE ttrss_user_entries
205 SET feed_id = '$feed_id', orig_feed_id = NULL
206 WHERE ref_id = $id AND owner_uid = " . $_SESSION["uid"]);
207 }
208 }
209
210 $this->dbh->query("COMMIT");
211 }
212
213 print json_encode(array("message" => "UPDATE_COUNTERS"));
214 }
215
216 function archive() {
217 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
218
219 foreach ($ids as $id) {
220 $this->archive_article($id, $_SESSION["uid"]);
221 }
222
223 print json_encode(array("message" => "UPDATE_COUNTERS"));
224 }
225
226 private function archive_article($id, $owner_uid) {
227 $this->dbh->query("BEGIN");
228
229 $result = $this->dbh->query("SELECT feed_id FROM ttrss_user_entries
230 WHERE ref_id = '$id' AND owner_uid = $owner_uid");
231
232 if ($this->dbh->num_rows($result) != 0) {
233
234 /* prepare the archived table */
235
236 $feed_id = (int) $this->dbh->fetch_result($result, 0, "feed_id");
237
238 if ($feed_id) {
239 $result = $this->dbh->query("SELECT id FROM ttrss_archived_feeds
240 WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
241
242 if ($this->dbh->num_rows($result) == 0) {
243 $result = db_query("SELECT MAX(id) AS id FROM ttrss_archived_feeds");
244 $new_feed_id = (int)db_fetch_result($result, 0, "id") + 1;
245
246 $this->dbh->query("INSERT INTO ttrss_archived_feeds
247 (id, owner_uid, title, feed_url, site_url)
248 SELECT $new_feed_id, owner_uid, title, feed_url, site_url from ttrss_feeds
249 WHERE id = '$feed_id'");
250 } else {
251 $new_feed_id = $this->dbh->fetch_result($result, 0, "id");
252 }
253
254 $this->dbh->query("UPDATE ttrss_user_entries
255 SET orig_feed_id = $new_feed_id, feed_id = NULL
256 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
257 }
258 }
259
260 $this->dbh->query("COMMIT");
261 }
262
263 function publ() {
264 $pub = $_REQUEST["pub"];
265 $id = $this->dbh->escape_string($_REQUEST["id"]);
266
267 if ($pub == "1") {
268 $pub = "true";
269 } else {
270 $pub = "false";
271 }
272
273 $this->dbh->query("UPDATE ttrss_user_entries SET
274 published = $pub, last_published = NOW()
275 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
276
277 print json_encode(array("message" => "UPDATE_COUNTERS"));
278 }
279
280 function getAllCounters() {
281 $last_article_id = (int) $_REQUEST["last_article_id"];
282
283 $reply = array();
284
285 if (!empty($_REQUEST['seq'])) $reply['seq'] = (int) $_REQUEST['seq'];
286
287 if ($last_article_id != Article::getLastArticleId()) {
288 $reply['counters'] = Counters::getAllCounters();
289 }
290
291 $reply['runtime-info'] = make_runtime_info();
292
293 print json_encode($reply);
294 }
295
296 /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
297 function catchupSelected() {
298 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
299 $cmode = sprintf("%d", $_REQUEST["cmode"]);
300
301 Article::catchupArticlesById($ids, $cmode);
302
303 print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids));
304 }
305
306 function markSelected() {
307 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
308 $cmode = sprintf("%d", $_REQUEST["cmode"]);
309
310 $this->markArticlesById($ids, $cmode);
311
312 print json_encode(array("message" => "UPDATE_COUNTERS"));
313 }
314
315 function publishSelected() {
316 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
317 $cmode = sprintf("%d", $_REQUEST["cmode"]);
318
319 $this->publishArticlesById($ids, $cmode);
320
321 print json_encode(array("message" => "UPDATE_COUNTERS"));
322 }
323
324 function sanityCheck() {
325 $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
326 $_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true";
327 $_SESSION["hasMp3"] = $_REQUEST["hasMp3"] === "true";
328 $_SESSION["clientTzOffset"] = $_REQUEST["clientTzOffset"];
329
330 $reply = array();
331
332 $reply['error'] = sanity_check();
333
334 if ($reply['error']['code'] == 0) {
335 $reply['init-params'] = make_init_params();
336 $reply['runtime-info'] = make_runtime_info(true);
337 }
338
339 print json_encode($reply);
340 }
341
342 function completeLabels() {
343 $search = $this->dbh->escape_string($_REQUEST["search"]);
344
345 $result = $this->dbh->query("SELECT DISTINCT caption FROM
346 ttrss_labels2
347 WHERE owner_uid = '".$_SESSION["uid"]."' AND
348 LOWER(caption) LIKE LOWER('$search%') ORDER BY caption
349 LIMIT 5");
350
351 print "<ul>";
352 while ($line = $this->dbh->fetch_assoc($result)) {
353 print "<li>" . $line["caption"] . "</li>";
354 }
355 print "</ul>";
356 }
357
358 function purge() {
359 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
360 $days = sprintf("%d", $_REQUEST["days"]);
361
362 foreach ($ids as $id) {
363
364 $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
365 id = '$id' AND owner_uid = ".$_SESSION["uid"]);
366
367 if ($this->dbh->num_rows($result) == 1) {
368 purge_feed($id, $days);
369 }
370 }
371 }
372
373 function updateFeedBrowser() {
374 if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
375
376 $search = $this->dbh->escape_string($_REQUEST["search"]);
377 $limit = $this->dbh->escape_string($_REQUEST["limit"]);
378 $mode = (int) $this->dbh->escape_string($_REQUEST["mode"]);
379
380 require_once "feedbrowser.php";
381
382 print json_encode(array("content" =>
383 make_feed_browser($search, $limit, $mode),
384 "mode" => $mode));
385 }
386
387 // Silent
388 function massSubscribe() {
389
390 $payload = json_decode($_REQUEST["payload"], false);
391 $mode = $_REQUEST["mode"];
392
393 if (!$payload || !is_array($payload)) return;
394
395 if ($mode == 1) {
396 foreach ($payload as $feed) {
397
398 $title = $this->dbh->escape_string($feed[0]);
399 $feed_url = $this->dbh->escape_string($feed[1]);
400
401 $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
402 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
403
404 if ($this->dbh->num_rows($result) == 0) {
405 $result = $this->dbh->query("INSERT INTO ttrss_feeds
406 (owner_uid,feed_url,title,cat_id,site_url)
407 VALUES ('".$_SESSION["uid"]."',
408 '$feed_url', '$title', NULL, '')");
409 }
410 }
411 } else if ($mode == 2) {
412 // feed archive
413 foreach ($payload as $id) {
414 $result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
415 WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
416
417 if ($this->dbh->num_rows($result) != 0) {
418 $site_url = $this->dbh->escape_string(db_fetch_result($result, 0, "site_url"));
419 $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
420 $title = $this->dbh->escape_string(db_fetch_result($result, 0, "title"));
421
422 $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
423 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
424
425 if ($this->dbh->num_rows($result) == 0) {
426 $result = $this->dbh->query("INSERT INTO ttrss_feeds
427 (owner_uid,feed_url,title,cat_id,site_url)
428 VALUES ('".$_SESSION["uid"]."',
429 '$feed_url', '$title', NULL, '$site_url')");
430 }
431 }
432 }
433 }
434 }
435
436 function catchupFeed() {
437 $feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
438 $is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
439 $mode = $this->dbh->escape_string($_REQUEST['mode']);
440 $search_query = $this->dbh->escape_string($_REQUEST['search_query']);
441 $search_lang = $this->dbh->escape_string($_REQUEST['search_lang']);
442
443 Feeds::catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]);
444
445 print json_encode(array("message" => "UPDATE_COUNTERS"));
446 }
447
448 function quickAddCat() {
449 $cat = $this->dbh->escape_string($_REQUEST["cat"]);
450
451 add_feed_category($cat);
452
453 $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
454 title = '$cat' AND owner_uid = " . $_SESSION["uid"]);
455
456 if ($this->dbh->num_rows($result) == 1) {
457 $id = $this->dbh->fetch_result($result, 0, "id");
458 } else {
459 $id = 0;
460 }
461
462 print_feed_cat_select("cat_id", $id, '');
463 }
464
465 function setpanelmode() {
466 $wide = (int) $_REQUEST["wide"];
467
468 setcookie("ttrss_widescreen", $wide,
469 time() + COOKIE_LIFETIME_LONG);
470
471 print json_encode(array("wide" => $wide));
472 }
473
474 static function updaterandomfeed_real($dbh) {
475
476 // Test if the feed need a update (update interval exceded).
477 if (DB_TYPE == "pgsql") {
478 $update_limit_qpart = "AND ((
479 ttrss_feeds.update_interval = 0
480 AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL)
481 ) OR (
482 ttrss_feeds.update_interval > 0
483 AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL)
484 ) OR ttrss_feeds.last_updated IS NULL
485 OR last_updated = '1970-01-01 00:00:00')";
486 } else {
487 $update_limit_qpart = "AND ((
488 ttrss_feeds.update_interval = 0
489 AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE)
490 ) OR (
491 ttrss_feeds.update_interval > 0
492 AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE)
493 ) OR ttrss_feeds.last_updated IS NULL
494 OR last_updated = '1970-01-01 00:00:00')";
495 }
496
497 // Test if feed is currently being updated by another process.
498 if (DB_TYPE == "pgsql") {
499 $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
500 } else {
501 $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
502 }
503
504 $random_qpart = sql_random_function();
505
506 // we could be invoked from public.php with no active session
507 if ($_SESSION["uid"]) {
508 $owner_check_qpart = "AND ttrss_feeds.owner_uid = '".$_SESSION["uid"]."'";
509 } else {
510 $owner_check_qpart = "";
511 }
512
513 // We search for feed needing update.
514 $result = $dbh->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
515 FROM
516 ttrss_feeds, ttrss_users, ttrss_user_prefs
517 WHERE
518 ttrss_feeds.owner_uid = ttrss_users.id
519 AND ttrss_users.id = ttrss_user_prefs.owner_uid
520 AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
521 $owner_check_qpart
522 $update_limit_qpart
523 $updstart_thresh_qpart
524 ORDER BY $random_qpart LIMIT 30");
525
526 $feed_id = -1;
527
528 $num_updated = 0;
529
530 $tstart = time();
531
532 while ($line = $dbh->fetch_assoc($result)) {
533 $feed_id = $line["id"];
534
535 if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
536 RSSUtils::update_rss_feed($feed_id, true);
537 ++$num_updated;
538 } else {
539 break;
540 }
541 }
542
543 // Purge orphans and cleanup tags
544 Article::purge_orphans();
545 //cleanup_tags(14, 50000);
546
547 if ($num_updated > 0) {
548 print json_encode(array("message" => "UPDATE_COUNTERS",
549 "num_updated" => $num_updated));
550 } else {
551 print json_encode(array("message" => "NOTHING_TO_UPDATE"));
552 }
553
554 }
555
556 function updaterandomfeed() {
557 RPC::updaterandomfeed_real($this->dbh);
558 }
559
560 private function markArticlesById($ids, $cmode) {
561
562 $tmp_ids = array();
563
564 foreach ($ids as $id) {
565 array_push($tmp_ids, "ref_id = '$id'");
566 }
567
568 $ids_qpart = join(" OR ", $tmp_ids);
569
570 if ($cmode == 0) {
571 $this->dbh->query("UPDATE ttrss_user_entries SET
572 marked = false, last_marked = NOW()
573 WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
574 } else if ($cmode == 1) {
575 $this->dbh->query("UPDATE ttrss_user_entries SET
576 marked = true, last_marked = NOW()
577 WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
578 } else {
579 $this->dbh->query("UPDATE ttrss_user_entries SET
580 marked = NOT marked,last_marked = NOW()
581 WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
582 }
583 }
584
585 private function publishArticlesById($ids, $cmode) {
586
587 $tmp_ids = array();
588
589 foreach ($ids as $id) {
590 array_push($tmp_ids, "ref_id = '$id'");
591 }
592
593 $ids_qpart = join(" OR ", $tmp_ids);
594
595 if ($cmode == 0) {
596 $this->dbh->query("UPDATE ttrss_user_entries SET
597 published = false,last_published = NOW()
598 WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
599 } else if ($cmode == 1) {
600 $this->dbh->query("UPDATE ttrss_user_entries SET
601 published = true,last_published = NOW()
602 WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
603 } else {
604 $this->dbh->query("UPDATE ttrss_user_entries SET
605 published = NOT published,last_published = NOW()
606 WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
607 }
608 }
609
610 function getlinktitlebyid() {
611 $id = $this->dbh->escape_string($_REQUEST['id']);
612
613 $result = $this->dbh->query("SELECT link, title FROM ttrss_entries, ttrss_user_entries
614 WHERE ref_id = '$id' AND ref_id = id AND owner_uid = ". $_SESSION["uid"]);
615
616 if ($this->dbh->num_rows($result) != 0) {
617 $link = $this->dbh->fetch_result($result, 0, "link");
618 $title = $this->dbh->fetch_result($result, 0, "title");
619
620 echo json_encode(array("link" => $link, "title" => $title));
621 } else {
622 echo json_encode(array("error" => "ARTICLE_NOT_FOUND"));
623 }
624 }
625
626 function log() {
627 $msg = $this->dbh->escape_string($_REQUEST['msg']);
628 $file = $this->dbh->escape_string(basename($_REQUEST['file']));
629 $line = (int) $_REQUEST['line'];
630 $context = $this->dbh->escape_string($_REQUEST['context']);
631
632 if ($msg) {
633 Logger::get()->log_error(E_USER_WARNING,
634 $msg, 'client-js:' . $file, $line, $context);
635
636 echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
637 } else {
638 echo json_encode(array("error" => "MESSAGE_NOT_FOUND"));
639 }
640
641 }
642 }