2009-12-16 09:50:32 +00:00
|
|
|
<?php
|
|
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
|
2021-02-22 14:38:46 +00:00
|
|
|
set_include_path(__DIR__ . PATH_SEPARATOR .
|
|
|
|
dirname(__DIR__) . PATH_SEPARATOR .
|
|
|
|
dirname(__DIR__) . "/include" . PATH_SEPARATOR .
|
2012-12-09 09:41:22 +00:00
|
|
|
get_include_path());
|
2011-12-11 20:13:14 +00:00
|
|
|
|
2012-08-16 14:33:08 +00:00
|
|
|
chdir("..");
|
2011-12-13 11:40:42 +00:00
|
|
|
|
2013-04-04 11:33:14 +00:00
|
|
|
define('NO_SESSION_AUTOSTART', true);
|
2012-09-19 08:45:01 +00:00
|
|
|
|
2013-04-17 11:36:34 +00:00
|
|
|
require_once "autoload.php";
|
2011-12-11 20:13:14 +00:00
|
|
|
require_once "functions.php";
|
2012-09-19 08:45:01 +00:00
|
|
|
require_once "sessions.php";
|
2009-12-16 09:50:32 +00:00
|
|
|
|
2021-02-22 11:41:09 +00:00
|
|
|
ini_set('session.use_cookies', "0");
|
|
|
|
ini_set("session.gc_maxlifetime", "86400");
|
2013-03-28 05:48:14 +00:00
|
|
|
|
2021-02-12 18:43:38 +00:00
|
|
|
ob_start();
|
2010-10-25 09:31:37 +00:00
|
|
|
|
2021-02-23 06:01:27 +00:00
|
|
|
$_REQUEST = json_decode((string)file_get_contents("php://input"), true);
|
2011-04-14 17:22:55 +00:00
|
|
|
|
2021-02-09 05:47:41 +00:00
|
|
|
if (!empty($_REQUEST["sid"])) {
|
2009-12-16 13:40:15 +00:00
|
|
|
session_id($_REQUEST["sid"]);
|
2021-02-25 12:28:27 +00:00
|
|
|
session_start();
|
2009-12-16 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
2015-07-29 15:11:52 +00:00
|
|
|
startup_gettext();
|
|
|
|
|
2013-04-17 14:58:30 +00:00
|
|
|
if (!init_plugins()) return;
|
2009-12-16 09:50:32 +00:00
|
|
|
|
2021-02-09 05:47:41 +00:00
|
|
|
if (!empty($_SESSION["uid"])) {
|
2021-02-16 14:13:16 +00:00
|
|
|
if (!\Sessions\validate_session()) {
|
2016-07-20 10:55:51 +00:00
|
|
|
header("Content-Type: text/json");
|
|
|
|
|
2021-02-23 19:26:07 +00:00
|
|
|
print json_encode([
|
|
|
|
"seq" => -1,
|
|
|
|
"status" => API::STATUS_ERR,
|
|
|
|
"content" => [ "error" => API::E_NOT_LOGGED_IN ]
|
|
|
|
]);
|
2016-07-20 10:55:51 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-09 05:47:41 +00:00
|
|
|
UserHelper::load_user_plugins($_SESSION["uid"]);
|
2016-07-20 10:52:22 +00:00
|
|
|
}
|
|
|
|
|
2021-03-01 12:24:18 +00:00
|
|
|
$method = strtolower($_REQUEST["op"] ?? "");
|
2009-12-16 09:50:32 +00:00
|
|
|
|
2013-05-07 07:35:10 +00:00
|
|
|
$handler = new API($_REQUEST);
|
2009-12-17 10:31:12 +00:00
|
|
|
|
2011-12-13 11:40:42 +00:00
|
|
|
if ($handler->before($method)) {
|
|
|
|
if ($method && method_exists($handler, $method)) {
|
|
|
|
$handler->$method();
|
2021-02-09 05:47:41 +00:00
|
|
|
} else /* if (method_exists($handler, 'index')) */ {
|
2011-12-13 11:40:42 +00:00
|
|
|
$handler->index($method);
|
|
|
|
}
|
|
|
|
$handler->after();
|
2009-12-16 09:50:32 +00:00
|
|
|
}
|
|
|
|
|
2012-09-19 11:54:55 +00:00
|
|
|
header("Api-Content-Length: " . ob_get_length());
|
|
|
|
|
|
|
|
ob_end_flush();
|
2017-04-26 17:24:18 +00:00
|
|
|
|