public.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
  3. get_include_path());
  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 "sessions.php";
  17. require_once "functions.php";
  18. require_once "sanity_check.php";
  19. require_once "config.php";
  20. require_once "db.php";
  21. require_once "db-prefs.php";
  22. startup_gettext();
  23. $script_started = microtime(true);
  24. $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  25. if (!init_connection($link)) return;
  26. if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) {
  27. ob_start("ob_gzhandler");
  28. }
  29. $method = $_REQUEST["op"];
  30. global $pluginhost;
  31. $override = $pluginhost->lookup_handler("public", $method);
  32. if ($override) {
  33. $handler = $override;
  34. } else {
  35. $handler = new Handler_Public($link, $_REQUEST);
  36. }
  37. if (implements_interface($handler, "IHandler") && $handler->before($method)) {
  38. if ($method && method_exists($handler, $method)) {
  39. $handler->$method();
  40. } else if (method_exists($handler, 'index')) {
  41. $handler->index();
  42. }
  43. $handler->after();
  44. return;
  45. }
  46. header("Content-Type: text/plain");
  47. print json_encode(array("error" => array("code" => 7)));
  48. // We close the connection to database.
  49. db_close($link);
  50. ?>