2 error_reporting(E_ERROR | E_PARSE);
4 require_once "../config.php";
6 set_include_path(dirname(__FILE__) . PATH_SEPARATOR .
7 dirname(dirname(__FILE__)) . PATH_SEPARATOR .
8 dirname(dirname(__FILE__)) . "/include" . PATH_SEPARATOR .
13 define('TTRSS_SESSION_NAME', 'ttrss_api_sid');
14 define('NO_SESSION_AUTOSTART', true);
16 require_once "autoload.php";
17 require_once "db.php";
18 require_once "db-prefs.php";
19 require_once "functions.php";
20 require_once "sessions.php";
22 ini_set("session.gc_maxlifetime", 86400);
24 define('AUTH_DISABLE_OTP', true);
26 if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
27 function_exists("ob_gzhandler")) {
29 ob_start("ob_gzhandler");
34 $input = file_get_contents("php://input");
36 if (defined('_API_DEBUG_HTTP_ENABLED') && _API_DEBUG_HTTP_ENABLED) {
37 // Override $_REQUEST with JSON-encoded data if available
38 // fallback on HTTP parameters
40 $input = json_decode($input, true);
41 if ($input) $_REQUEST = $input;
45 $input = json_decode($input, true);
49 if ($_REQUEST["sid"]) {
50 session_id($_REQUEST["sid"]);
52 } else if (defined('_API_DEBUG_HTTP_ENABLED')) {
56 if (!init_plugins()) return;
58 $method = strtolower($_REQUEST["op"]);
60 $handler = new API($_REQUEST);
62 if ($handler->before($method)) {
63 if ($method && method_exists($handler, $method)) {
65 } else if (method_exists($handler, 'index')) {
66 $handler->index($method);
71 header("Api-Content-Length: " . ob_get_length());