]>
git.wh0rd.org - tt-rss.git/blob - backend.php
2 set_include_path(get_include_path() . PATH_SEPARATOR
.
3 dirname(__FILE__
) . "/include");
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"];
23 /* Public calls compatibility shim */
25 $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share",
26 "fbexport", "logout", "pubsub");
28 if (array_search($op, $public_calls) !== false) {
29 header("Location: public.php?" . $_SERVER['QUERY_STRING']);
33 require_once "functions.php";
34 require_once "sessions.php";
35 require_once "sanity_check.php";
36 require_once "config.php";
37 require_once "db.php";
38 require_once "db-prefs.php";
40 no_cache_incantation();
44 $script_started = getmicrotime();
46 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
48 if (!init_connection($link)) return;
50 header("Content-Type: text/plain; charset=utf-8");
52 if (ENABLE_GZIP_OUTPUT
) {
53 ob_start("ob_gzhandler");
56 if (SINGLE_USER_MODE
) {
57 authenticate_user($link, "admin", null);
60 // TODO remove and handle within Handlers
62 if (!($_SESSION["uid"] && validate_session($link))) {
63 if ($op == 'pref-feeds' && $method == 'add') {
64 header("Content-Type: text/html");
65 login_sequence($link);
66 render_login_form($link);
68 header("Content-Type: text/plain");
69 print json_encode(array("error" => array("code" => 6)));
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 $update_methods = array(
107 2 => __("SimplePie"),
108 3 => __("Twitter OAuth"));
110 if (DEFAULT_UPDATE_METHOD
== "1") {
111 $update_methods[0] .= ' (SimplePie)';
113 $update_methods[0] .= ' (Magpie)';
116 $access_level_names = array(
118 5 => __("Power User"),
119 10 => __("Administrator"));
121 $error = sanity_check($link);
123 if ($error['code'] != 0 && $op != "logout") {
124 print json_encode(array("error" => $error));
128 function __autoload($class) {
129 $file = "classes/".strtolower(basename($class)).".php";
130 if (file_exists($file)) {
135 $op = str_replace("-", "_", $op);
137 if (class_exists($op)) {
138 $handler = new $op($link, $_REQUEST);
141 if ($handler->before($method)) {
142 if ($method && method_exists($handler, $method)) {
144 } else if (method_exists($handler, 'index')) {
153 header("Content-Type: text/plain");
154 print json_encode(array("error" => array("code" => 7)));
156 // We close the connection to database.