]> git.wh0rd.org - tt-rss.git/blame - public.php
Merge branch 'tiny-oop'
[tt-rss.git] / public.php
CommitLineData
e0d91d84 1<?php
3f363052
AD
2 set_include_path(get_include_path() . PATH_SEPARATOR . "include");
3
e0d91d84
AD
4 /* remove ill effects of magic quotes */
5
6 if (get_magic_quotes_gpc()) {
7 function stripslashes_deep($value) {
8 $value = is_array($value) ?
9 array_map('stripslashes_deep', $value) : stripslashes($value);
10 return $value;
11 }
12
13 $_POST = array_map('stripslashes_deep', $_POST);
14 $_GET = array_map('stripslashes_deep', $_GET);
15 $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
16 $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
17 }
18
e0d91d84 19 require_once "functions.php";
5f0a3741 20 require_once "sessions.php";
e0d91d84
AD
21 require_once "sanity_check.php";
22 require_once "config.php";
23 require_once "db.php";
24 require_once "db-prefs.php";
25
26 no_cache_incantation();
27
28 startup_gettext();
29
30 $script_started = getmicrotime();
31
32 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
33
5f0a3741
AD
34 if (!init_connection($link)) return;
35
36 if (ENABLE_GZIP_OUTPUT) {
37 ob_start("ob_gzhandler");
e0d91d84
AD
38 }
39
5f0a3741
AD
40 function __autoload($class) {
41 $file = "classes/".strtolower(basename($class)).".php";
42 if (file_exists($file)) {
43 require $file;
44 }
45 }
e0d91d84 46
5f0a3741 47 $method = $_REQUEST["op"];
e0d91d84 48
5f0a3741 49 $handler = new Public_Handler($link, $_REQUEST);
e0d91d84 50
5f0a3741
AD
51 if ($handler) {
52 if ($handler->before()) {
53 if ($method && method_exists($handler, $method)) {
54 $handler->$method();
55 } else if (method_exists($handler, 'index')) {
56 $handler->index();
57 }
58 $handler->after();
59 return;
60 }
e0d91d84
AD
61 }
62
5f0a3741
AD
63 header("Content-Type: text/plain");
64 print json_encode(array("error" => array("code" => 7)));
e0d91d84
AD
65
66 // We close the connection to database.
67 db_close($link);
68?>