public.php 1.5 KB

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