greader.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <?php
  2. /**
  3. == Description ==
  4. Server-side API compatible with Google Reader API layer 2
  5. for the FreshRSS project http://freshrss.org
  6. == Credits ==
  7. * 2014-02: Released by Alexandre Alapetite http://alexandre.alapetite.fr
  8. under GNU AGPL 3 license http://www.gnu.org/licenses/agpl-3.0.html
  9. == Documentation ==
  10. * http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
  11. * http://web.archive.org/web/20130718025427/http://undoc.in/
  12. * http://ranchero.com/downloads/GoogleReaderAPI-2009.pdf
  13. * http://code.google.com/p/google-reader-api/w/list
  14. * http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/
  15. * https://github.com/noinnion/newsplus/blob/master/extensions/GoogleReaderCloneExtension/src/com/noinnion/android/newsplus/extension/google_reader/GoogleReaderClient.java
  16. * https://github.com/ericmann/gReader-Library/blob/master/greader.class.php
  17. * https://github.com/devongovett/reader
  18. * https://github.com/theoldreader/api
  19. */
  20. define('TEMP_PASSWORD', 'temp123'); //Change to another ASCII password
  21. define('TEMP_AUTH', 'XtofqkkOkCULRLH8'); //Change to another random ASCII auth
  22. require('../../constants.php');
  23. require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
  24. $ORIGINAL_INPUT = file_get_contents('php://input');
  25. $ALL_HEADERS = getallheaders();
  26. $debugInfo = array('date' => date('c'), 'headers' => $ALL_HEADERS, '_SERVER' => $_SERVER, '_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE, 'INPUT' => $ORIGINAL_INPUT);
  27. if (PHP_INT_SIZE < 8) { //32-bit
  28. function dec2hex($dec) {
  29. return str_pad(gmp_strval(gmp_init($dec, 10), 16), 16, '0', STR_PAD_LEFT);
  30. }
  31. function hex2dec($hex) {
  32. return gmp_strval(gmp_init($hex, 16), 10);
  33. }
  34. } else { //64-bit
  35. function dec2hex($dec) { //http://code.google.com/p/google-reader-api/wiki/ItemId
  36. return str_pad(dechex($dec), 16, '0', STR_PAD_LEFT);
  37. }
  38. function hex2dec($hex) {
  39. return hexdec($hex);
  40. }
  41. }
  42. function headerVariable($headerName, $varName) {
  43. global $ALL_HEADERS;
  44. if (empty($ALL_HEADERS[$headerName])) {
  45. return null;
  46. }
  47. parse_str($ALL_HEADERS[$headerName], $pairs);
  48. //logMe('headerVariable(' . $headerName . ') => ' . print_r($pairs, true));
  49. return isset($pairs[$varName]) ? $pairs[$varName] : null;
  50. }
  51. function multiplePosts($name) { //https://bugs.php.net/bug.php?id=51633
  52. global $ORIGINAL_INPUT;
  53. $inputs = explode('&', $ORIGINAL_INPUT);
  54. $result = array();
  55. $prefix = $name . '=';
  56. $prefixLength = strlen($prefix);
  57. foreach ($inputs as $input) {
  58. if (strpos($input, $prefix) === 0) {
  59. $result[] = urldecode(substr($input, $prefixLength));
  60. }
  61. }
  62. return $result;
  63. }
  64. class MyPDO extends Minz_ModelPdo {
  65. function prepare($sql) {
  66. return $this->bd->prepare(str_replace('%_', $this->prefix, $sql));
  67. }
  68. }
  69. function logMe($text) {
  70. file_put_contents(LOG_PATH . '/api.log', $text, FILE_APPEND);
  71. }
  72. function badRequest() {
  73. logMe("badRequest()\n");
  74. header('HTTP/1.1 400 Bad Request');
  75. header('Content-Type: text/plain; charset=UTF-8');
  76. die('Bad Request!');
  77. }
  78. function unauthorized() {
  79. logMe("unauthorized()\n");
  80. header('HTTP/1.1 401 Unauthorized');
  81. header('Content-Type: text/plain; charset=UTF-8');
  82. header('Google-Bad-Token: true');
  83. die('Unauthorized!');
  84. }
  85. function notImplemented() {
  86. logMe("notImplemented()\n");
  87. header('HTTP/1.1 501 Not Implemented');
  88. header('Content-Type: text/plain; charset=UTF-8');
  89. die('Not Implemented!');
  90. }
  91. function serviceUnavailable() {
  92. logMe("serviceUnavailable()\n");
  93. header('HTTP/1.1 503 Service Unavailable');
  94. header('Content-Type: text/plain; charset=UTF-8');
  95. die('Service Unavailable!');
  96. }
  97. function checkCompatibility() {
  98. logMe("checkCompatibility()\n");
  99. header('Content-Type: text/plain; charset=UTF-8');
  100. $ok = true;
  101. $ok &= function_exists('getallheaders');
  102. echo $ok ? 'PASS' : 'FAIL';
  103. exit();
  104. }
  105. function authorizationToUser() {
  106. $headerAuth = headerVariable('Authorization', 'GoogleLogin_auth'); //Input is 'GoogleLogin auth', but PHP replaces spaces by '_' http://php.net/language.variables.external
  107. if ($headerAuth != '') {
  108. $headerAuthX = explode('/', $headerAuth, 2);
  109. if ((count($headerAuthX) === 2) && ($headerAuthX[1] === TEMP_AUTH)) {
  110. $user = $headerAuthX[0];
  111. if (ctype_alnum($user)) {
  112. return $user;
  113. }
  114. }
  115. }
  116. return null;
  117. }
  118. function clientLogin($email, $pass) { //http://web.archive.org/web/20130604091042/http://undoc.in/clientLogin.html
  119. logMe('clientLogin(' . $email . ")\n");
  120. if ($pass !== TEMP_PASSWORD) {
  121. unauthorized();
  122. }
  123. header('Content-Type: text/plain; charset=UTF-8');
  124. $auth = $email . '/' . TEMP_AUTH;
  125. echo 'SID=', $auth, "\n",
  126. 'Auth=', $auth, "\n";
  127. exit();
  128. }
  129. function token($user) {
  130. //http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/ https://github.com/ericmann/gReader-Library/blob/master/greader.class.php
  131. logMe('token('. $user . ")\n");
  132. $token = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ01234'; //Must have 57 characters...
  133. echo $token, "\n";
  134. exit();
  135. }
  136. function checkToken($user, $token) {
  137. //http://code.google.com/p/google-reader-api/wiki/ActionToken
  138. logMe('checkToken(' . $token . ")\n");
  139. if ($token === 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ01234') {
  140. return true;
  141. }
  142. unauthorized();
  143. }
  144. function tagList() {
  145. logMe("tagList()\n");
  146. header('Content-Type: application/json; charset=UTF-8');
  147. $pdo = new MyPDO();
  148. $stm = $pdo->prepare('SELECT c.name FROM `%_category` c');
  149. $stm->execute();
  150. $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
  151. $tags = array(
  152. array('id' => 'user/-/state/com.google/starred'),
  153. //array('id' => 'user/-/state/com.google/broadcast', 'sortid' => '2'),
  154. );
  155. foreach ($res as $cName) {
  156. $tags[] = array(
  157. 'id' => 'user/-/label/' . $cName,
  158. //'sortid' => $cName,
  159. );
  160. }
  161. echo json_encode(array('tags' => $tags)), "\n";
  162. exit();
  163. }
  164. function subscriptionList() {
  165. logMe("subscriptionList()\n");
  166. header('Content-Type: application/json; charset=UTF-8');
  167. $pdo = new MyPDO();
  168. $stm = $pdo->prepare('SELECT f.id, f.name, f.url, f.website, c.id as c_id, c.name as c_name FROM `%_feed` f
  169. INNER JOIN `%_category` c ON c.id = f.category');
  170. $stm->execute();
  171. $res = $stm->fetchAll(PDO::FETCH_ASSOC);
  172. $subscriptions = array();
  173. foreach ($res as $line) {
  174. $subscriptions[] = array(
  175. 'id' => 'feed/' . $line['id'],
  176. 'title' => $line['name'],
  177. 'categories' => array(
  178. array(
  179. 'id' => 'user/-/label/' . $line['c_name'],
  180. 'label' => $line['c_name'],
  181. ),
  182. ),
  183. //'sortid' => $line['name'],
  184. //'firstitemmsec' => 0,
  185. 'url' => $line['url'],
  186. 'htmlUrl' => $line['website'],
  187. //'iconUrl' => '',
  188. );
  189. }
  190. echo json_encode(array('subscriptions' => $subscriptions)), "\n";
  191. exit();
  192. }
  193. function unreadCount() {
  194. logMe("unreadCount()\n");
  195. header('Content-Type: application/json; charset=UTF-8');
  196. $pdo = new MyPDO();
  197. $stm = $pdo->prepare('SELECT f.id, f.lastUpdate, f.cache_nbUnreads FROM `%_feed` f');
  198. $stm->execute();
  199. $res = $stm->fetchAll(PDO::FETCH_ASSOC);
  200. $unreadcounts = array();
  201. $totalUnreads = 0;
  202. $totalLastUpdate = 0;
  203. foreach ($res as $line) {
  204. $nbUnreads = $line['cache_nbUnreads'];
  205. $totalUnreads += $nbUnreads;
  206. $lastUpdate = $line['lastUpdate'];
  207. if ($totalLastUpdate < $lastUpdate) {
  208. $totalLastUpdate = $lastUpdate;
  209. }
  210. $unreadcounts[] = array(
  211. 'id' => 'feed/' . $line['id'],
  212. 'count' => $nbUnreads,
  213. 'newestItemTimestampUsec' => $lastUpdate . '000000',
  214. );
  215. }
  216. $unreadcounts[] = array(
  217. 'id' => 'user/-/state/com.google/reading-list',
  218. 'count' => $totalUnreads,
  219. 'newestItemTimestampUsec' => $totalLastUpdate . '000000',
  220. );
  221. echo json_encode(array(
  222. 'max' => $totalUnreads,
  223. 'unreadcounts' => $unreadcounts,
  224. )), "\n";
  225. exit();
  226. }
  227. function streamContents($path, $include_target, $start_time, $count, $order, $exclude_target)
  228. {//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
  229. logMe('streamContents(' . $include_target . ")\n");
  230. header('Content-Type: application/json; charset=UTF-8');
  231. $feedDAO = new FreshRSS_FeedDAO();
  232. $feedCategoryNames = $feedDAO->listCategoryNames();
  233. switch ($path) {
  234. case 'reading-list':
  235. $type = 'A';
  236. break;
  237. case 'starred':
  238. $type = 's';
  239. break;
  240. case 'label':
  241. $type = 'c';
  242. break;
  243. default:
  244. $type = 'A';
  245. break;
  246. }
  247. switch ($exclude_target) {
  248. case 'user/-/state/com.google/read':
  249. $state = 'not_read';
  250. break;
  251. default:
  252. $state = 'all';
  253. break;
  254. }
  255. $entryDAO = new FreshRSS_EntryDAO();
  256. $entries = $entryDAO->listWhere($type, $include_target, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', '', $start_time);
  257. $items = array();
  258. foreach ($entries as $entry) {
  259. $f_id = $entry->feed();
  260. $c_name = isset($feedCategoryNames[$f_id]) ? $feedCategoryNames[$f_id] : '_';
  261. $item = array(
  262. 'id' => /*'tag:google.com,2005:reader/item/' .*/ dec2hex($entry->id()), //64-bit hexa http://code.google.com/p/google-reader-api/wiki/ItemId
  263. 'crawlTimeMsec' => substr($entry->id(), 0, -3),
  264. 'published' => $entry->date(true),
  265. 'title' => $entry->title(),
  266. 'summary' => array('content' => $entry->content()),
  267. 'alternate' => array(
  268. array('href' => $entry->link()),
  269. ),
  270. 'categories' => array(
  271. 'user/-/state/com.google/reading-list',
  272. 'user/-/label/' . $c_name,
  273. ),
  274. 'origin' => array(
  275. 'streamId' => 'feed/' . $f_id,
  276. //'title' => $line['f_name'],
  277. //'htmlUrl' => $line['f_website'],
  278. ),
  279. );
  280. if ($entry->author() != '') {
  281. $item['author'] = $entry->author();
  282. }
  283. if ($entry->isRead()) {
  284. $item['categories'][] = 'user/-/state/com.google/read';
  285. }
  286. if ($entry->isFavorite()) {
  287. $item['categories'][] = 'user/-/state/com.google/starred';
  288. }
  289. $items[] = $item;
  290. }
  291. echo json_encode(array(
  292. 'id' => 'user/-/state/com.google/reading-list',
  293. 'updated' => time(),
  294. 'items' => $items,
  295. )), "\n";
  296. exit();
  297. }
  298. function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target)
  299. {//http://code.google.com/p/google-reader-api/wiki/ApiStreamItemsIds http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
  300. logMe('streamContentsItemsIds(' . $streamId . ")\n");
  301. $type = 'A';
  302. $id = '';
  303. if ($streamId === 'user/-/state/com.google/reading-list') {
  304. $type = 'A';
  305. } elseif ('user/-/state/com.google/starred') {
  306. $type = 's';
  307. } elseif (strpos($streamId, 'feed/') === 0) {
  308. $type = 'f';
  309. $id = basename($streamId);
  310. } elseif (strpos($streamId, 'user/-/label/') === 0) {
  311. $type = 'C';
  312. $c_name = basename($streamId);
  313. notImplemented(); //TODO
  314. }
  315. switch ($exclude_target) {
  316. case 'user/-/state/com.google/read':
  317. $state = 'not_read';
  318. break;
  319. default:
  320. $state = 'all';
  321. break;
  322. }
  323. $entryDAO = new FreshRSS_EntryDAO();
  324. $entries = $entryDAO->listWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', '', $start_time);
  325. $itemRefs = array();
  326. foreach ($entries as $entry) {
  327. $f_id = $entry->feed();
  328. $itemRefs[] = array(
  329. 'id' => $entry->id(), //64-bit decimal
  330. //'timestampUsec' => $entry->dateAdded(true),
  331. /*'directStreamIds' => array(
  332. 'feed/' . $entry->feed()
  333. ),*/
  334. );
  335. }
  336. echo json_encode(array(
  337. 'itemRefs' => $itemRefs,
  338. )), "\n";
  339. exit();
  340. }
  341. function editTag($e_ids, $a, $r) {
  342. logMe("editTag()\n");
  343. $entryDAO = new FreshRSS_EntryDAO();
  344. foreach ($e_ids as $e_id) { //TODO: User WHERE...IN
  345. $e_id = hex2dec(basename($e_id)); //Strip prefix 'tag:google.com,2005:reader/item/'
  346. switch ($a) {
  347. case 'user/-/state/com.google/read':
  348. $entryDAO->markRead($e_id, true);
  349. break;
  350. case 'user/-/state/com.google/starred':
  351. $entryDAO->markFavorite($e_id, true);
  352. break;
  353. /*case 'user/-/state/com.google/tracking-kept-unread':
  354. break;
  355. case 'user/-/state/com.google/like':
  356. break;
  357. case 'user/-/state/com.google/broadcast':
  358. break;*/
  359. }
  360. switch ($r) {
  361. case 'user/-/state/com.google/read':
  362. $entryDAO->markRead($e_id, false);
  363. break;
  364. case 'user/-/state/com.google/starred':
  365. $entryDAO->markFavorite($e_id, false);
  366. break;
  367. }
  368. }
  369. echo 'OK';
  370. exit();
  371. }
  372. function markAllAsRead($streamId, $olderThanId) {
  373. logMe('markAllAsRead(' . $streamId . ")\n");
  374. $entryDAO = new FreshRSS_EntryDAO();
  375. if (strpos($streamId, 'feed/') === 0) {
  376. $f_id = basename($streamId);
  377. $entryDAO->markReadFeed($f_id, $olderThanId);
  378. } elseif (strpos($streamId, 'user/-/label/') === 0) {
  379. $c_name = basename($streamId);
  380. $entryDAO->markReadCatName($c_name, $olderThanId);
  381. } elseif ($streamId === 'user/-/state/com.google/reading-list') {
  382. $entryDAO->markReadEntries($olderThanId, false, -1);
  383. }
  384. echo 'OK';
  385. exit();
  386. }
  387. logMe('----------------------------------------------------------------'."\n");
  388. logMe(print_r($debugInfo, true));
  389. $pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : $_SERVER['PATH_INFO'];
  390. $pathInfos = explode('/', $pathInfo);
  391. logMe('pathInfos => ' . print_r($pathInfos, true));
  392. Minz_Configuration::init();
  393. if (!Minz_Configuration::apiEnabled()) {
  394. serviceUnavailable();
  395. }
  396. Minz_Session::init('FreshRSS');
  397. $user = authorizationToUser();
  398. $conf = null;
  399. logMe('User => ' . $user . "\n");
  400. if ($user != null) {
  401. try {
  402. $conf = new FreshRSS_Configuration($user);
  403. } catch (Exception $e) {
  404. logMe($e->getMessage());
  405. $user = null;
  406. badRequest();
  407. }
  408. }
  409. Minz_Session::_param('currentUser', $user);
  410. if (count($pathInfos)<3) badRequest();
  411. elseif ($pathInfos[1] === 'accounts') {
  412. if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd']))
  413. clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']);
  414. }
  415. elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfos[3]) && $pathInfos[3] === '0' && isset($pathInfos[4])) {
  416. if ($user == null) {
  417. unauthorized();
  418. }
  419. $timestamp = isset($_GET['ck']) ? intval($_GET['ck']) : 0; //ck=[unix timestamp] : Use the current Unix time here, helps Google with caching.
  420. switch ($pathInfos[4]) {
  421. case 'stream':
  422. $exclude_target = isset($_GET['xt']) ? $_GET['xt'] : ''; //xt=[exclude target] : Used to exclude certain items from the feed. For example, using xt=user/-/state/com.google/read will exclude items that the current user has marked as read, or xt=feed/[feedurl] will exclude items from a particular feed (obviously not useful in this request, but xt appears in other listing requests).
  423. $count = isset($_GET['n']) ? intval($_GET['n']) : 20; //n=[integer] : The maximum number of results to return.
  424. $order = isset($_GET['r']) ? $_GET['r'] : 'd'; //r=[d|n|o] : Sort order of item results. d or n gives items in descending date order, o in ascending order.
  425. $start_time = isset($_GET['ot']) ? intval($_GET['ot']) : 0; //ot=[unix timestamp] : The time from which you want to retrieve items. Only items that have been crawled by Google Reader after this time will be returned.
  426. if (isset($pathInfos[5]) && $pathInfos[5] === 'contents' && isset($pathInfos[6]) && isset($pathInfos[7])) {
  427. if ($pathInfos[6] === 'feed') {
  428. $include_target = $pathInfos[7];
  429. StreamContents($pathInfos[6], $include_target, $start_time, $count, $order, $exclude_target);
  430. } elseif ($pathInfos[6] === 'user' && isset($pathInfos[8]) && isset($pathInfos[9])) {
  431. if ($pathInfos[8] === 'state') {
  432. if ($pathInfos[9] === 'com.google' && isset($pathInfos[10])) {
  433. if ($pathInfos[10] === 'reading-list' || $pathInfos[10] === 'starred') {
  434. $include_target = '';
  435. streamContents($pathInfos[10], $include_target, $start_time, $count, $order, $exclude_target);
  436. }
  437. }
  438. } elseif ($pathInfos[8] === 'label') {
  439. $include_target = $pathInfos[9];
  440. streamContents($pathInfos[8], $include_target, $start_time, $count, $order, $exclude_target);
  441. }
  442. }
  443. } elseif ($pathInfos[5] === 'items') {
  444. if ($pathInfos[6] === 'ids' && isset($_GET['s'])) {
  445. $streamId = $_GET['s']; //StreamId for which to fetch the item IDs. The parameter may be repeated to fetch the item IDs from multiple streams at once (more efficient from a backend perspective than multiple requests).
  446. streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target);
  447. }
  448. }
  449. break;
  450. case 'tag':
  451. if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
  452. $output = isset($_GET['output']) ? $_GET['output'] : '';
  453. if ($output !== 'json') notImplemented();
  454. tagList($_GET['output']);
  455. }
  456. break;
  457. case 'subscription':
  458. if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
  459. $output = isset($_GET['output']) ? $_GET['output'] : '';
  460. if ($output !== 'json') notImplemented();
  461. subscriptionList($_GET['output']);
  462. }
  463. break;
  464. case 'unread-count':
  465. $output = isset($_GET['output']) ? $_GET['output'] : '';
  466. if ($output !== 'json') notImplemented();
  467. $all = isset($_GET['all']) ? $_GET['all'] : '';
  468. unreadCount($all);
  469. break;
  470. case 'edit-tag': //http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-part-3/
  471. $token = isset($_POST['T']) ? trim($_POST['T']) : '';
  472. checkToken($user, $token);
  473. $a = isset($_POST['a']) ? $_POST['a'] : ''; //Add: user/-/state/com.google/read user/-/state/com.google/starred
  474. $r = isset($_POST['r']) ? $_POST['r'] : ''; //Remove: user/-/state/com.google/read user/-/state/com.google/starred
  475. $e_ids = multiplePosts('i'); //item IDs
  476. editTag($e_ids, $a, $r);
  477. break;
  478. case 'mark-all-as-read':
  479. $token = isset($_POST['T']) ? trim($_POST['T']) : '';
  480. checkToken($user, $token);
  481. $streamId = $_POST['s']; //StreamId
  482. $ts = isset($_POST['ts']) ? $_POST['ts'] : '0'; //Older than timestamp in nanoseconds
  483. if (!ctype_digit($ts)) {
  484. $ts = '0';
  485. }
  486. markAllAsRead($streamId, $ts);
  487. break;
  488. case 'token':
  489. Token($user);
  490. break;
  491. }
  492. } elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') {
  493. checkCompatibility();
  494. }
  495. badRequest();