]> git.wh0rd.org - tt-rss.git/blame - api/index.php
only enable ob_gzhandler if it exists
[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
4a0500fb
AD
6 set_include_path(get_include_path() . PATH_SEPARATOR .
7 dirname(__FILE__) . PATH_SEPARATOR .
8 dirname(dirname(__FILE__)) . PATH_SEPARATOR .
9 dirname(dirname(__FILE__)) . "/include" );
10
de8260cb
AD
11 function __autoload($class) {
12 $file = "classes/".strtolower(basename($class)).".php";
13 if (file_exists($file)) {
14 require $file;
15 }
16 }
17
4a0500fb
AD
18 require_once "db.php";
19 require_once "db-prefs.php";
20 require_once "functions.php";
378a548c 21
8ad4bac0
AD
22 chdir("..");
23
6a79e8af
AD
24 if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
25 function_exists("ob_gzhandler")) {
26
70543b6a
AD
27 ob_start("ob_gzhandler");
28 }
29
dbaa4e4a 30 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
378a548c
AD
31
32 $session_expire = SESSION_EXPIRE_TIME; //seconds
33 $session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid_api" : TTRSS_SESSION_NAME . "_api";
34
3bb7e191
AD
35 session_name($session_name);
36
90e71380
AD
37 $input = file_get_contents("php://input");
38
39 // Override $_REQUEST with JSON-encoded data if available
40 if ($input) {
41 $input = json_decode($input, true);
42
de8260cb 43 if ($input) $_REQUEST = $input;
90e71380
AD
44 }
45
3bb7e191
AD
46 if ($_REQUEST["sid"]) {
47 session_id($_REQUEST["sid"]);
48 }
49
378a548c
AD
50 session_start();
51
de8260cb 52 if (!init_connection($link)) return;
378a548c 53
de8260cb 54 $method = strtolower($_REQUEST["op"]);
378a548c 55
de8260cb 56 $handler = new API($link, $_REQUEST);
b792cd70 57
de8260cb
AD
58 if ($handler->before($method)) {
59 if ($method && method_exists($handler, $method)) {
60 $handler->$method();
61 } else if (method_exists($handler, 'index')) {
62 $handler->index($method);
63 }
64 $handler->after();
378a548c
AD
65 }
66
67 db_close($link);
dbaa4e4a 68
378a548c 69?>