diff options
Diffstat (limited to 'api/index.php')
-rw-r--r-- | api/index.php | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/api/index.php b/api/index.php index 77552af46..d85a1103c 100644 --- a/api/index.php +++ b/api/index.php @@ -1,55 +1,29 @@ <?php error_reporting(E_ERROR | E_PARSE); - require_once "../config.php"; - - set_include_path(dirname(__FILE__) . PATH_SEPARATOR . - dirname(dirname(__FILE__)) . PATH_SEPARATOR . - dirname(dirname(__FILE__)) . "/include" . PATH_SEPARATOR . + set_include_path(__DIR__ . PATH_SEPARATOR . + dirname(__DIR__) . PATH_SEPARATOR . + dirname(__DIR__) . "/include" . PATH_SEPARATOR . get_include_path()); chdir(".."); - define('TTRSS_SESSION_NAME', 'ttrss_api_sid'); define('NO_SESSION_AUTOSTART', true); require_once "autoload.php"; - require_once "db.php"; - require_once "db-prefs.php"; require_once "functions.php"; require_once "sessions.php"; - ini_set('session.use_cookies', 0); - ini_set("session.gc_maxlifetime", 86400); - - if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT && - function_exists("ob_gzhandler")) { + ini_set('session.use_cookies', "0"); + ini_set("session.gc_maxlifetime", "86400"); - ob_start("ob_gzhandler"); - } else { - ob_start(); - } + ob_start(); - $input = file_get_contents("php://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((string)$input, true); - $_REQUEST = $input; - } + $_REQUEST = json_decode((string)file_get_contents("php://input"), true); if (!empty($_REQUEST["sid"])) { session_id($_REQUEST["sid"]); @session_start(); - } else if (defined('_API_DEBUG_HTTP_ENABLED')) { - @session_start(); } startup_gettext(); @@ -57,12 +31,14 @@ if (!init_plugins()) return; if (!empty($_SESSION["uid"])) { - if (!validate_session()) { + if (!\Sessions\validate_session()) { header("Content-Type: text/json"); - print json_encode(array("seq" => -1, - "status" => 1, - "content" => array("error" => "NOT_LOGGED_IN"))); + print json_encode([ + "seq" => -1, + "status" => API::STATUS_ERR, + "content" => [ "error" => API::E_NOT_LOGGED_IN ] + ]); return; } |