]>
git.wh0rd.org - tt-rss.git/blob - backend.php
2 set_include_path(dirname(__FILE__
) ."/include" . PATH_SEPARATOR
.
5 /* remove ill effects of magic quotes */
7 if (get_magic_quotes_gpc()) {
8 function stripslashes_deep($value) {
9 $value = is_array($value) ?
10 array_map('stripslashes_deep', $value) : stripslashes($value);
14 $_POST = array_map('stripslashes_deep', $_POST);
15 $_GET = array_map('stripslashes_deep', $_GET);
16 $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
17 $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
20 $op = $_REQUEST["op"];
21 @$method = $_REQUEST['subop'] ?
$_REQUEST['subop'] : $_REQUEST["method"];
26 $method = strtolower($method);
28 /* Public calls compatibility shim */
30 $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share",
31 "fbexport", "logout", "pubsub");
33 if (array_search($op, $public_calls) !== false) {
34 header("Location: public.php?" . $_SERVER['QUERY_STRING']);
38 @$csrf_token = $_REQUEST['csrf_token'];
40 require_once "autoload.php";
41 require_once "sessions.php";
42 require_once "functions.php";
43 require_once "config.php";
44 require_once "db.php";
45 require_once "db-prefs.php";
49 $script_started = microtime(true);
51 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
53 if (!init_plugins()) return;
55 header("Content-Type: text/json; charset=utf-8");
57 if (ENABLE_GZIP_OUTPUT
&& function_exists("ob_gzhandler")) {
58 ob_start("ob_gzhandler");
61 if (SINGLE_USER_MODE
) {
62 authenticate_user( "admin", null);
65 if ($_SESSION["uid"]) {
66 if (!validate_session()) {
67 header("Content-Type: text/json");
68 print json_encode(array("error" => array("code" => 6)));
71 load_user_plugins( $_SESSION["uid"]);
74 $purge_intervals = array(
75 0 => __("Use default"),
76 -1 => __("Never purge"),
77 5 => __("1 week old"),
78 14 => __("2 weeks old"),
79 31 => __("1 month old"),
80 60 => __("2 months old"),
81 90 => __("3 months old"));
83 $update_intervals = array(
84 0 => __("Default interval"),
85 -1 => __("Disable updates"),
86 15 => __("Each 15 minutes"),
87 30 => __("Each 30 minutes"),
89 240 => __("Each 4 hours"),
90 720 => __("Each 12 hours"),
92 10080 => __("Weekly"));
94 $update_intervals_nodefault = array(
95 -1 => __("Disable updates"),
96 15 => __("Each 15 minutes"),
97 30 => __("Each 30 minutes"),
99 240 => __("Each 4 hours"),
100 720 => __("Each 12 hours"),
102 10080 => __("Weekly"));
104 $access_level_names = array(
106 5 => __("Power User"),
107 10 => __("Administrator"));
109 #$error = sanity_check();
111 #if ($error['code'] != 0 && $op != "logout") {
112 # print json_encode(array("error" => $error));
116 $op = str_replace("-", "_", $op);
119 $override = $pluginhost->lookup_handler($op, $method);
121 if (class_exists($op) ||
$override) {
124 $handler = $override;
126 $handler = new $op(Db
::get(), $_REQUEST);
129 if ($handler && implements_interface($handler, 'IHandler')) {
130 if (validate_csrf($csrf_token) ||
$handler->csrf_ignore($method)) {
131 if ($handler->before($method)) {
132 if ($method && method_exists($handler, $method)) {
135 if (method_exists($handler, "catchall")) {
136 $handler->catchall($method);
142 header("Content-Type: text/json");
143 print json_encode(array("error" => array("code" => 6)));
147 header("Content-Type: text/json");
148 print json_encode(array("error" => array("code" => 6)));
154 header("Content-Type: text/json");
155 print json_encode(array("error" => array("code" => 7)));
157 // We close the connection to database.