]> git.wh0rd.org - tt-rss.git/blame - api/index.php
temporarily enable entity loader when importing opml because idk
[tt-rss.git] / api / index.php
CommitLineData
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
404e2e36 16 require_once "autoload.php";
4a0500fb
AD
17 require_once "db.php";
18 require_once "db-prefs.php";
19 require_once "functions.php";
964f1533 20 require_once "sessions.php";
378a548c 21
3f009418
AD
22 ini_set("session.gc_maxlifetime", 86400);
23
02cd6de1
AD
24 define('AUTH_DISABLE_OTP', true);
25
6a79e8af
AD
26 if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
27 function_exists("ob_gzhandler")) {
28
70543b6a 29 ob_start("ob_gzhandler");
839b0658
AD
30 } else {
31 ob_start();
70543b6a
AD
32 }
33
90e71380
AD
34 $input = file_get_contents("php://input");
35
6eaf3193
AD
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
39 if ($input) {
40 $input = json_decode($input, true);
41 if ($input) $_REQUEST = $input;
42 }
43 } else {
44 // Accept JSON only
90e71380 45 $input = json_decode($input, true);
6eaf3193 46 $_REQUEST = $input;
90e71380
AD
47 }
48
3bb7e191
AD
49 if ($_REQUEST["sid"]) {
50 session_id($_REQUEST["sid"]);
5160620c 51 @session_start();
0bb5833b
AD
52 } else if (defined('_API_DEBUG_HTTP_ENABLED')) {
53 @session_start();
3bb7e191
AD
54 }
55
4a70edea 56 if (!init_plugins()) return;
378a548c 57
de8260cb 58 $method = strtolower($_REQUEST["op"]);
378a548c 59
6f7798b6 60 $handler = new API($_REQUEST);
b792cd70 61
de8260cb
AD
62 if ($handler->before($method)) {
63 if ($method && method_exists($handler, $method)) {
64 $handler->$method();
65 } else if (method_exists($handler, 'index')) {
66 $handler->index($method);
67 }
68 $handler->after();
378a548c
AD
69 }
70
839b0658
AD
71 header("Api-Content-Length: " . ob_get_length());
72
73 ob_end_flush();
378a548c 74?>