2009-12-16 10:50:32 +01:00
|
|
|
<?php
|
|
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
|
|
|
|
require_once "../config.php";
|
2011-04-12 17:33:12 +02:00
|
|
|
|
2011-12-11 21:13:14 +01:00
|
|
|
set_include_path(get_include_path() . PATH_SEPARATOR .
|
|
|
|
dirname(__FILE__) . PATH_SEPARATOR .
|
|
|
|
dirname(dirname(__FILE__)) . PATH_SEPARATOR .
|
|
|
|
dirname(dirname(__FILE__)) . "/include" );
|
|
|
|
|
2012-08-16 16:33:08 +02:00
|
|
|
chdir("..");
|
2011-12-13 12:40:42 +01:00
|
|
|
|
2011-12-11 21:13:14 +01:00
|
|
|
require_once "db.php";
|
|
|
|
require_once "db-prefs.php";
|
|
|
|
require_once "functions.php";
|
2009-12-16 10:50:32 +01:00
|
|
|
|
2012-09-03 20:32:24 +02:00
|
|
|
define('AUTH_DISABLE_OTP', true);
|
|
|
|
|
2012-03-20 11:45:43 +01:00
|
|
|
if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
|
|
|
|
function_exists("ob_gzhandler")) {
|
|
|
|
|
2010-10-25 11:31:37 +02:00
|
|
|
ob_start("ob_gzhandler");
|
|
|
|
}
|
|
|
|
|
2011-04-12 17:33:12 +02:00
|
|
|
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
2009-12-16 10:50:32 +01:00
|
|
|
|
|
|
|
$session_expire = SESSION_EXPIRE_TIME; //seconds
|
|
|
|
$session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid_api" : TTRSS_SESSION_NAME . "_api";
|
|
|
|
|
2009-12-16 14:40:15 +01:00
|
|
|
session_name($session_name);
|
|
|
|
|
2011-04-14 19:22:55 +02:00
|
|
|
$input = file_get_contents("php://input");
|
|
|
|
|
2012-08-17 13:16:13 +02:00
|
|
|
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
|
2011-04-14 19:22:55 +02:00
|
|
|
$input = json_decode($input, true);
|
2012-08-17 13:16:13 +02:00
|
|
|
$_REQUEST = $input;
|
2011-04-14 19:22:55 +02:00
|
|
|
}
|
|
|
|
|
2009-12-16 14:40:15 +01:00
|
|
|
if ($_REQUEST["sid"]) {
|
|
|
|
session_id($_REQUEST["sid"]);
|
|
|
|
}
|
|
|
|
|
2009-12-16 10:50:32 +01:00
|
|
|
session_start();
|
|
|
|
|
2011-12-13 12:40:42 +01:00
|
|
|
if (!init_connection($link)) return;
|
2009-12-16 10:50:32 +01:00
|
|
|
|
2011-12-13 12:40:42 +01:00
|
|
|
$method = strtolower($_REQUEST["op"]);
|
2009-12-16 10:50:32 +01:00
|
|
|
|
2011-12-13 12:40:42 +01:00
|
|
|
$handler = new API($link, $_REQUEST);
|
2009-12-17 11:31:12 +01:00
|
|
|
|
2011-12-13 12:40:42 +01:00
|
|
|
if ($handler->before($method)) {
|
|
|
|
if ($method && method_exists($handler, $method)) {
|
|
|
|
$handler->$method();
|
|
|
|
} else if (method_exists($handler, 'index')) {
|
|
|
|
$handler->index($method);
|
|
|
|
}
|
|
|
|
$handler->after();
|
2009-12-16 10:50:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
db_close($link);
|
2011-04-12 17:33:12 +02:00
|
|
|
|
2009-12-16 10:50:32 +01:00
|
|
|
?>
|