]> git.wh0rd.org - tt-rss.git/blame - public.php
db updates, remove init_connection()
[tt-rss.git] / public.php
CommitLineData
e0d91d84 1<?php
88e8fb3a
AD
2 set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
3 get_include_path());
3f363052 4
e0d91d84
AD
5 /* remove ill effects of magic quotes */
6
7 if (get_magic_quotes_gpc()) {
8 function stripslashes_deep($value) {
9 $value = is_array($value) ?
10 array_map('stripslashes_deep', $value) : stripslashes($value);
11 return $value;
12 }
13
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);
18 }
19
5f0a3741 20 require_once "sessions.php";
23419d11 21 require_once "functions.php";
e0d91d84
AD
22 require_once "sanity_check.php";
23 require_once "config.php";
24 require_once "db.php";
25 require_once "db-prefs.php";
26
e0d91d84
AD
27 startup_gettext();
28
1ebf3b97 29 $script_started = microtime(true);
e0d91d84
AD
30
31 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
32
ba68b681 33 if (!init_plugins($link)) return;
5f0a3741 34
6a79e8af 35 if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) {
5f0a3741 36 ob_start("ob_gzhandler");
e0d91d84
AD
37 }
38
5f0a3741 39 $method = $_REQUEST["op"];
e0d91d84 40
8dcb2b47
AD
41 global $pluginhost;
42 $override = $pluginhost->lookup_handler("public", $method);
e0d91d84 43
8dcb2b47
AD
44 if ($override) {
45 $handler = $override;
46 } else {
47 $handler = new Handler_Public($link, $_REQUEST);
48 }
49
50 if (implements_interface($handler, "IHandler") && $handler->before($method)) {
de8260cb
AD
51 if ($method && method_exists($handler, $method)) {
52 $handler->$method();
53 } else if (method_exists($handler, 'index')) {
54 $handler->index();
5f0a3741 55 }
de8260cb
AD
56 $handler->after();
57 return;
e0d91d84
AD
58 }
59
5f0a3741
AD
60 header("Content-Type: text/plain");
61 print json_encode(array("error" => array("code" => 7)));
e0d91d84
AD
62
63 // We close the connection to database.
64 db_close($link);
65?>