greader.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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. return $headerAuthX[0];
  111. }
  112. }
  113. return null;
  114. }
  115. function clientLogin($email, $pass) { //http://web.archive.org/web/20130604091042/http://undoc.in/clientLogin.html
  116. logMe('clientLogin(' . $email . ")\n");
  117. if ($pass !== TEMP_PASSWORD) {
  118. unauthorized();
  119. }
  120. header('Content-Type: text/plain; charset=UTF-8');
  121. $auth = $email . '/' . TEMP_AUTH;
  122. echo 'SID=', $auth, "\n",
  123. 'Auth=', $auth, "\n";
  124. exit();
  125. }
  126. function token($user) {
  127. //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
  128. logMe('token('. $user . ")\n");
  129. $token = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ01234'; //Must have 57 characters...
  130. echo $token, "\n";
  131. exit();
  132. }
  133. function checkToken($user, $token) {
  134. //http://code.google.com/p/google-reader-api/wiki/ActionToken
  135. logMe('checkToken(' . $token . ")\n");
  136. if ($token === 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ01234') {
  137. return true;
  138. }
  139. unauthorized();
  140. }
  141. function tagList() {
  142. logMe("tagList()\n");
  143. header('Content-Type: application/json; charset=UTF-8');
  144. $pdo = new MyPDO();
  145. $stm = $pdo->prepare('SELECT c.name FROM `%_category` c');
  146. $stm->execute();
  147. $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
  148. $tags = array(
  149. array('id' => 'user/-/state/com.google/starred'),
  150. //array('id' => 'user/-/state/com.google/broadcast', 'sortid' => '2'),
  151. );
  152. foreach ($res as $cName) {
  153. $tags[] = array(
  154. 'id' => 'user/-/label/' . $cName,
  155. //'sortid' => $cName,
  156. );
  157. }
  158. echo json_encode(array('tags' => $tags)), "\n";
  159. exit();
  160. }
  161. function subscriptionList() {
  162. logMe("subscriptionList()\n");
  163. header('Content-Type: application/json; charset=UTF-8');
  164. $pdo = new MyPDO();
  165. $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
  166. INNER JOIN `%_category` c ON c.id = f.category');
  167. $stm->execute();
  168. $res = $stm->fetchAll(PDO::FETCH_ASSOC);
  169. $subscriptions = array();
  170. foreach ($res as $line) {
  171. $subscriptions[] = array(
  172. 'id' => 'feed/' . $line['id'],
  173. 'title' => $line['name'],
  174. 'categories' => array(
  175. array(
  176. 'id' => 'user/-/label/' . $line['c_name'],
  177. 'label' => $line['c_name'],
  178. ),
  179. ),
  180. //'sortid' => $line['name'],
  181. //'firstitemmsec' => 0,
  182. 'url' => $line['url'],
  183. 'htmlUrl' => $line['website'],
  184. //'iconUrl' => '',
  185. );
  186. }
  187. echo json_encode(array('subscriptions' => $subscriptions)), "\n";
  188. exit();
  189. }
  190. function unreadCount() {
  191. logMe("unreadCount()\n");
  192. header('Content-Type: application/json; charset=UTF-8');
  193. $pdo = new MyPDO();
  194. $stm = $pdo->prepare('SELECT f.id, f.lastUpdate, f.cache_nbUnreads FROM `%_feed` f');
  195. $stm->execute();
  196. $res = $stm->fetchAll(PDO::FETCH_ASSOC);
  197. $unreadcounts = array();
  198. $totalUnreads = 0;
  199. $totalLastUpdate = 0;
  200. foreach ($res as $line) {
  201. $nbUnreads = $line['cache_nbUnreads'];
  202. $totalUnreads += $nbUnreads;
  203. $lastUpdate = $line['lastUpdate'];
  204. if ($totalLastUpdate < $lastUpdate) {
  205. $totalLastUpdate = $lastUpdate;
  206. }
  207. $unreadcounts[] = array(
  208. 'id' => 'feed/' . $line['id'],
  209. 'count' => $nbUnreads,
  210. 'newestItemTimestampUsec' => $lastUpdate . '000000',
  211. );
  212. }
  213. $unreadcounts[] = array(
  214. 'id' => 'user/-/state/com.google/reading-list',
  215. 'count' => $totalUnreads,
  216. 'newestItemTimestampUsec' => $totalLastUpdate . '000000',
  217. );
  218. echo json_encode(array(
  219. 'max' => $totalUnreads,
  220. 'unreadcounts' => $unreadcounts,
  221. )), "\n";
  222. exit();
  223. }
  224. function streamContents($path, $include_target, $start_time, $count, $order, $exclude_target)
  225. {//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
  226. logMe('streamContents(' . $include_target . ")\n");
  227. header('Content-Type: application/json; charset=UTF-8');
  228. $feedDAO = new FreshRSS_FeedDAO();
  229. $feedCategoryNames = $feedDAO->listCategoryNames();
  230. switch ($path) {
  231. case 'reading-list':
  232. $type = 'A';
  233. break;
  234. case 'starred':
  235. $type = 's';
  236. break;
  237. case 'label':
  238. $type = 'c';
  239. break;
  240. default:
  241. $type = 'A';
  242. break;
  243. }
  244. switch ($exclude_target) {
  245. case 'user/-/state/com.google/read':
  246. $state = 'not_read';
  247. break;
  248. default:
  249. $state = 'all';
  250. break;
  251. }
  252. $entryDAO = new FreshRSS_EntryDAO();
  253. $entries = $entryDAO->listWhere($type, $include_target, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', '', $start_time);
  254. $items = array();
  255. foreach ($entries as $entry) {
  256. $f_id = $entry->feed();
  257. $c_name = isset($feedCategoryNames[$f_id]) ? $feedCategoryNames[$f_id] : '_';
  258. $item = array(
  259. 'id' => /*'tag:google.com,2005:reader/item/' .*/ dec2hex($entry->id()), //64-bit hexa http://code.google.com/p/google-reader-api/wiki/ItemId
  260. 'crawlTimeMsec' => substr($entry->id(), 0, -3),
  261. 'published' => $entry->date(true),
  262. 'title' => $entry->title(),
  263. 'summary' => array('content' => $entry->content()),
  264. 'alternate' => array(
  265. array('href' => $entry->link()),
  266. ),
  267. 'categories' => array(
  268. 'user/-/state/com.google/reading-list',
  269. 'user/-/label/' . $c_name,
  270. ),
  271. 'origin' => array(
  272. 'streamId' => 'feed/' . $f_id,
  273. //'title' => $line['f_name'],
  274. //'htmlUrl' => $line['f_website'],
  275. ),
  276. );
  277. if ($entry->author() != '') {
  278. $item['author'] = $entry->author();
  279. }
  280. if ($entry->isRead()) {
  281. $item['categories'][] = 'user/-/state/com.google/read';
  282. }
  283. if ($entry->isFavorite()) {
  284. $item['categories'][] = 'user/-/state/com.google/starred';
  285. }
  286. $items[] = $item;
  287. }
  288. echo json_encode(array(
  289. 'id' => 'user/-/state/com.google/reading-list',
  290. 'updated' => time(),
  291. 'items' => $items,
  292. )), "\n";
  293. exit();
  294. }
  295. function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target)
  296. {//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
  297. logMe('streamContentsItemsIds(' . $streamId . ")\n");
  298. $type = 'A';
  299. $id = '';
  300. if ($streamId === 'user/-/state/com.google/reading-list') {
  301. $type = 'A';
  302. } elseif ('user/-/state/com.google/starred') {
  303. $type = 's';
  304. } elseif (strpos($streamId, 'feed/') === 0) {
  305. $type = 'f';
  306. $id = basename($streamId);
  307. } elseif (strpos($streamId, 'user/-/label/') === 0) {
  308. $type = 'C';
  309. $c_name = basename($streamId);
  310. notImplemented(); //TODO
  311. }
  312. switch ($exclude_target) {
  313. case 'user/-/state/com.google/read':
  314. $state = 'not_read';
  315. break;
  316. default:
  317. $state = 'all';
  318. break;
  319. }
  320. $entryDAO = new FreshRSS_EntryDAO();
  321. $entries = $entryDAO->listWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', '', $start_time);
  322. $itemRefs = array();
  323. foreach ($entries as $entry) {
  324. $f_id = $entry->feed();
  325. $itemRefs[] = array(
  326. 'id' => $entry->id(), //64-bit decimal
  327. //'timestampUsec' => $entry->dateAdded(true),
  328. /*'directStreamIds' => array(
  329. 'feed/' . $entry->feed()
  330. ),*/
  331. );
  332. }
  333. echo json_encode(array(
  334. 'itemRefs' => $itemRefs,
  335. )), "\n";
  336. exit();
  337. }
  338. function editTag($e_ids, $a, $r) {
  339. logMe("editTag()\n");
  340. $entryDAO = new FreshRSS_EntryDAO();
  341. foreach ($e_ids as $e_id) { //TODO: User WHERE...IN
  342. $e_id = hex2dec(basename($e_id)); //Strip prefix 'tag:google.com,2005:reader/item/'
  343. switch ($a) {
  344. case 'user/-/state/com.google/read':
  345. $entryDAO->markRead($e_id, true);
  346. break;
  347. case 'user/-/state/com.google/starred':
  348. $entryDAO->markFavorite($e_id, true);
  349. break;
  350. /*case 'user/-/state/com.google/tracking-kept-unread':
  351. break;
  352. case 'user/-/state/com.google/like':
  353. break;
  354. case 'user/-/state/com.google/broadcast':
  355. break;*/
  356. }
  357. switch ($r) {
  358. case 'user/-/state/com.google/read':
  359. $entryDAO->markRead($e_id, false);
  360. break;
  361. case 'user/-/state/com.google/starred':
  362. $entryDAO->markFavorite($e_id, false);
  363. break;
  364. }
  365. }
  366. echo 'OK';
  367. exit();
  368. }
  369. function markAllAsRead($streamId, $olderThanId) {
  370. logMe('markAllAsRead(' . $streamId . ")\n");
  371. $entryDAO = new FreshRSS_EntryDAO();
  372. if (strpos($streamId, 'feed/') === 0) {
  373. $f_id = basename($streamId);
  374. $entryDAO->markReadFeed($f_id, $olderThanId);
  375. } elseif (strpos($streamId, 'user/-/label/') === 0) {
  376. $c_name = basename($streamId);
  377. $entryDAO->markReadCatName($c_name, $olderThanId);
  378. } elseif ($streamId === 'user/-/state/com.google/reading-list') {
  379. $entryDAO->markReadEntries($olderThanId, false, -1);
  380. }
  381. echo 'OK';
  382. exit();
  383. }
  384. logMe('----------------------------------------------------------------'."\n");
  385. logMe(print_r($debugInfo, true));
  386. $pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : $_SERVER['PATH_INFO'];
  387. $pathInfos = explode('/', $pathInfo);
  388. logMe('pathInfos => ' . print_r($pathInfos, true));
  389. Minz_Configuration::init();
  390. if (!Minz_Configuration::apiEnabled()) {
  391. serviceUnavailable();
  392. }
  393. Minz_Session::init('FreshRSS');
  394. $user = authorizationToUser();
  395. $conf = null;
  396. logMe('User => ' . $user . "\n");
  397. if ($user != null) {
  398. try {
  399. $conf = new FreshRSS_Configuration($user);
  400. } catch (Exception $e) {
  401. logMe($e->getMessage());
  402. $user = null;
  403. badRequest();
  404. }
  405. }
  406. Minz_Session::_param('currentUser', $user);
  407. if (count($pathInfos)<3) badRequest();
  408. elseif ($pathInfos[1] === 'accounts') {
  409. if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd']))
  410. clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']);
  411. }
  412. elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfos[3]) && $pathInfos[3] === '0' && isset($pathInfos[4])) {
  413. if ($user == null) {
  414. unauthorized();
  415. }
  416. $timestamp = isset($_GET['ck']) ? intval($_GET['ck']) : 0; //ck=[unix timestamp] : Use the current Unix time here, helps Google with caching.
  417. switch ($pathInfos[4]) {
  418. case 'stream':
  419. $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).
  420. $count = isset($_GET['n']) ? intval($_GET['n']) : 20; //n=[integer] : The maximum number of results to return.
  421. $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.
  422. $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.
  423. if (isset($pathInfos[5]) && $pathInfos[5] === 'contents' && isset($pathInfos[6]) && isset($pathInfos[7])) {
  424. if ($pathInfos[6] === 'feed') {
  425. $include_target = $pathInfos[7];
  426. StreamContents($pathInfos[6], $include_target, $start_time, $count, $order, $exclude_target);
  427. } elseif ($pathInfos[6] === 'user' && isset($pathInfos[8]) && isset($pathInfos[9])) {
  428. if ($pathInfos[8] === 'state') {
  429. if ($pathInfos[9] === 'com.google' && isset($pathInfos[10])) {
  430. if ($pathInfos[10] === 'reading-list' || $pathInfos[10] === 'starred') {
  431. $include_target = '';
  432. streamContents($pathInfos[10], $include_target, $start_time, $count, $order, $exclude_target);
  433. }
  434. }
  435. } elseif ($pathInfos[8] === 'label') {
  436. $include_target = $pathInfos[9];
  437. streamContents($pathInfos[8], $include_target, $start_time, $count, $order, $exclude_target);
  438. }
  439. }
  440. } elseif ($pathInfos[5] === 'items') {
  441. if ($pathInfos[6] === 'ids' && isset($_GET['s'])) {
  442. $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).
  443. streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target);
  444. }
  445. }
  446. break;
  447. case 'tag':
  448. if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
  449. $output = isset($_GET['output']) ? $_GET['output'] : '';
  450. if ($output !== 'json') notImplemented();
  451. tagList($_GET['output']);
  452. }
  453. break;
  454. case 'subscription':
  455. if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
  456. $output = isset($_GET['output']) ? $_GET['output'] : '';
  457. if ($output !== 'json') notImplemented();
  458. subscriptionList($_GET['output']);
  459. }
  460. break;
  461. case 'unread-count':
  462. $output = isset($_GET['output']) ? $_GET['output'] : '';
  463. if ($output !== 'json') notImplemented();
  464. $all = isset($_GET['all']) ? $_GET['all'] : '';
  465. unreadCount($all);
  466. break;
  467. case 'edit-tag': //http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-part-3/
  468. $token = isset($_POST['T']) ? trim($_POST['T']) : '';
  469. checkToken($user, $token);
  470. $a = isset($_POST['a']) ? $_POST['a'] : ''; //Add: user/-/state/com.google/read user/-/state/com.google/starred
  471. $r = isset($_POST['r']) ? $_POST['r'] : ''; //Remove: user/-/state/com.google/read user/-/state/com.google/starred
  472. $e_ids = multiplePosts('i'); //item IDs
  473. editTag($e_ids, $a, $r);
  474. break;
  475. case 'mark-all-as-read':
  476. $token = isset($_POST['T']) ? trim($_POST['T']) : '';
  477. checkToken($user, $token);
  478. $streamId = $_POST['s']; //StreamId
  479. $ts = isset($_POST['ts']) ? $_POST['ts'] : '0'; //Older than timestamp in nanoseconds
  480. if (!ctype_digit($ts)) {
  481. $ts = '0';
  482. }
  483. markAllAsRead($streamId, $ts);
  484. break;
  485. case 'token':
  486. Token($user);
  487. break;
  488. }
  489. } elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') {
  490. checkCompatibility();
  491. }
  492. badRequest();