]>
git.wh0rd.org - tt-rss.git/blob - api/index.php
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 "db.php";
17 require_once "db-prefs.php";
18 require_once "functions.php";
19 require_once "sessions.php";
21 ini_set("session.gc_maxlifetime", 86400);
23 define('AUTH_DISABLE_OTP', true);
25 if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT
&&
26 function_exists("ob_gzhandler")) {
28 ob_start("ob_gzhandler");
33 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
35 $input = file_get_contents("php://input");
37 if (defined('_API_DEBUG_HTTP_ENABLED') && _API_DEBUG_HTTP_ENABLED
) {
38 // Override $_REQUEST with JSON-encoded data if available
39 // fallback on HTTP parameters
41 $input = json_decode($input, true);
42 if ($input) $_REQUEST = $input;
46 $input = json_decode($input, true);
50 if ($_REQUEST["sid"]) {
51 session_id($_REQUEST["sid"]);
53 } else if (defined('_API_DEBUG_HTTP_ENABLED')) {
57 if (!init_connection($link)) return;
59 $method = strtolower($_REQUEST["op"]);
61 $handler = new API($link, $_REQUEST);
63 if ($handler->before($method)) {
64 if ($method && method_exists($handler, $method)) {
66 } else if (method_exists($handler, 'index')) {
67 $handler->index($method);
74 header("Api-Content-Length: " . ob_get_length());