]>
Commit | Line | Data |
---|---|---|
378a548c | 1 | <?php |
378a548c AD |
2 | error_reporting(E_ERROR | E_PARSE); |
3 | ||
4 | require_once "../config.php"; | |
dbaa4e4a | 5 | |
88e8fb3a | 6 | set_include_path(dirname(__FILE__) . PATH_SEPARATOR . |
4a0500fb | 7 | dirname(dirname(__FILE__)) . PATH_SEPARATOR . |
88e8fb3a AD |
8 | dirname(dirname(__FILE__)) . "/include" . PATH_SEPARATOR . |
9 | get_include_path()); | |
4a0500fb | 10 | |
f1d65e50 | 11 | chdir(".."); |
de8260cb | 12 | |
964f1533 | 13 | define('TTRSS_SESSION_NAME', 'ttrss_api_sid'); |
9ce7a554 | 14 | define('NO_SESSION_AUTOSTART', true); |
964f1533 | 15 | |
4a0500fb AD |
16 | require_once "db.php"; |
17 | require_once "db-prefs.php"; | |
18 | require_once "functions.php"; | |
964f1533 | 19 | require_once "sessions.php"; |
378a548c | 20 | |
3f009418 AD |
21 | ini_set("session.gc_maxlifetime", 86400); |
22 | ||
02cd6de1 AD |
23 | define('AUTH_DISABLE_OTP', true); |
24 | ||
6a79e8af AD |
25 | if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT && |
26 | function_exists("ob_gzhandler")) { | |
27 | ||
70543b6a | 28 | ob_start("ob_gzhandler"); |
839b0658 AD |
29 | } else { |
30 | ob_start(); | |
70543b6a AD |
31 | } |
32 | ||
dbaa4e4a | 33 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
378a548c | 34 | |
90e71380 AD |
35 | $input = file_get_contents("php://input"); |
36 | ||
6eaf3193 AD |
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 | |
40 | if ($input) { | |
41 | $input = json_decode($input, true); | |
42 | if ($input) $_REQUEST = $input; | |
43 | } | |
44 | } else { | |
45 | // Accept JSON only | |
90e71380 | 46 | $input = json_decode($input, true); |
6eaf3193 | 47 | $_REQUEST = $input; |
90e71380 AD |
48 | } |
49 | ||
3bb7e191 AD |
50 | if ($_REQUEST["sid"]) { |
51 | session_id($_REQUEST["sid"]); | |
5160620c | 52 | @session_start(); |
0bb5833b AD |
53 | } else if (defined('_API_DEBUG_HTTP_ENABLED')) { |
54 | @session_start(); | |
3bb7e191 AD |
55 | } |
56 | ||
de8260cb | 57 | if (!init_connection($link)) return; |
378a548c | 58 | |
de8260cb | 59 | $method = strtolower($_REQUEST["op"]); |
378a548c | 60 | |
de8260cb | 61 | $handler = new API($link, $_REQUEST); |
b792cd70 | 62 | |
de8260cb AD |
63 | if ($handler->before($method)) { |
64 | if ($method && method_exists($handler, $method)) { | |
65 | $handler->$method(); | |
66 | } else if (method_exists($handler, 'index')) { | |
67 | $handler->index($method); | |
68 | } | |
69 | $handler->after(); | |
378a548c AD |
70 | } |
71 | ||
72 | db_close($link); | |
dbaa4e4a | 73 | |
839b0658 AD |
74 | header("Api-Content-Length: " . ob_get_length()); |
75 | ||
76 | ob_end_flush(); | |
378a548c | 77 | ?> |