]>
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 "functions.php";
41 require_once "sessions.php";
42 require_once "config.php";
43 require_once "db.php";
44 require_once "db-prefs.php";
46 no_cache_incantation();
50 $script_started = getmicrotime();
52 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
54 if (!init_connection($link)) return;
56 header("Content-Type: text/plain; charset=utf-8");
58 if (ENABLE_GZIP_OUTPUT
&& function_exists("ob_gzhandler")) {
59 ob_start("ob_gzhandler");
62 if (SINGLE_USER_MODE
) {
63 authenticate_user($link, "admin", null);
66 $purge_intervals = array(
67 0 => __("Use default"),
68 -1 => __("Never purge"),
69 5 => __("1 week old"),
70 14 => __("2 weeks old"),
71 31 => __("1 month old"),
72 60 => __("2 months old"),
73 90 => __("3 months old"));
75 $update_intervals = array(
76 0 => __("Default interval"),
77 -1 => __("Disable updates"),
78 15 => __("Each 15 minutes"),
79 30 => __("Each 30 minutes"),
81 240 => __("Each 4 hours"),
82 720 => __("Each 12 hours"),
84 10080 => __("Weekly"));
86 $update_intervals_nodefault = array(
87 -1 => __("Disable updates"),
88 15 => __("Each 15 minutes"),
89 30 => __("Each 30 minutes"),
91 240 => __("Each 4 hours"),
92 720 => __("Each 12 hours"),
94 10080 => __("Weekly"));
96 $access_level_names = array(
98 5 => __("Power User"),
99 10 => __("Administrator"));
101 #$error = sanity_check($link);
103 #if ($error['code'] != 0 && $op != "logout") {
104 # print json_encode(array("error" => $error));
108 $op = str_replace("-", "_", $op);
111 $override = $pluginhost->lookup_handler($op, $method);
113 if (class_exists($op) ||
$override) {
116 $handler = $override;
118 $handler = new $op($link, $_REQUEST);
121 if ($handler && implements_interface($handler, 'IHandler')) {
122 if (validate_csrf($csrf_token) ||
$handler->csrf_ignore($method)) {
123 if ($handler->before($method)) {
124 if ($method && method_exists($handler, $method)) {
127 if (method_exists($handler, "catchall")) {
128 $handler->catchall($method);
134 header("Content-Type: text/plain");
135 print json_encode(array("error" => array("code" => 6)));
139 header("Content-Type: text/plain");
140 print json_encode(array("error" => array("code" => 6)));
146 header("Content-Type: text/plain");
147 print json_encode(array("error" => array("code" => 7)));
149 // We close the connection to database.