X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=api%2Findex.php;h=9b92dcaddfff0d1e3173d2adc8d31be5014f82af;hb=88e8fb3a7132d1321ab65b66a19a67df890c402d;hp=b8a6d4c4a5807f924879abb4b97c19de54710fd2;hpb=de8260cb10da0ac4e49e4b3fc3a42c3578eff007;p=tt-rss.git diff --git a/api/index.php b/api/index.php index b8a6d4c4..9b92dcad 100644 --- a/api/index.php +++ b/api/index.php @@ -3,42 +3,45 @@ require_once "../config.php"; - set_include_path(get_include_path() . PATH_SEPARATOR . - dirname(__FILE__) . PATH_SEPARATOR . + set_include_path(dirname(__FILE__) . PATH_SEPARATOR . dirname(dirname(__FILE__)) . PATH_SEPARATOR . - dirname(dirname(__FILE__)) . "/include" ); + dirname(dirname(__FILE__)) . "/include" . PATH_SEPARATOR . + get_include_path()); - function __autoload($class) { - $file = "classes/".strtolower(basename($class)).".php"; - if (file_exists($file)) { - require $file; - } - } + chdir(".."); + + define('TTRSS_SESSION_NAME', 'ttrss_api_sid'); require_once "db.php"; require_once "db-prefs.php"; require_once "functions.php"; + require_once "sessions.php"; - chdir(".."); + define('AUTH_DISABLE_OTP', true); + + if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT && + function_exists("ob_gzhandler")) { - if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT) { ob_start("ob_gzhandler"); + } else { + ob_start(); } $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - $session_expire = SESSION_EXPIRE_TIME; //seconds - $session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid_api" : TTRSS_SESSION_NAME . "_api"; - - session_name($session_name); - $input = file_get_contents("php://input"); - // Override $_REQUEST with JSON-encoded data if available - if ($input) { + if (defined('_API_DEBUG_HTTP_ENABLED') && _API_DEBUG_HTTP_ENABLED) { + // Override $_REQUEST with JSON-encoded data if available + // fallback on HTTP parameters + if ($input) { + $input = json_decode($input, true); + if ($input) $_REQUEST = $input; + } + } else { + // Accept JSON only $input = json_decode($input, true); - - if ($input) $_REQUEST = $input; + $_REQUEST = $input; } if ($_REQUEST["sid"]) { @@ -64,4 +67,7 @@ db_close($link); + header("Api-Content-Length: " . ob_get_length()); + + ob_end_flush(); ?>