public.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* remove ill effects of magic quotes */
  3. if (get_magic_quotes_gpc()) {
  4. function stripslashes_deep($value) {
  5. $value = is_array($value) ?
  6. array_map('stripslashes_deep', $value) : stripslashes($value);
  7. return $value;
  8. }
  9. $_POST = array_map('stripslashes_deep', $_POST);
  10. $_GET = array_map('stripslashes_deep', $_GET);
  11. $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
  12. $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
  13. }
  14. $op = $_REQUEST["op"];
  15. require_once "functions.php";
  16. if ($op != "share") require_once "sessions.php";
  17. require_once "modules/backend-rpc.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 (!$link) {
  27. if (DB_TYPE == "mysql") {
  28. print mysql_error();
  29. }
  30. // PG seems to display its own errors just fine by default.
  31. return;
  32. }
  33. init_connection($link);
  34. $subop = $_REQUEST["subop"];
  35. $mode = $_REQUEST["mode"];
  36. if ((!$op || $op == "rss" || $op == "dlg") && !$_REQUEST["noxml"]) {
  37. header("Content-Type: application/xml; charset=utf-8");
  38. } else {
  39. header("Content-Type: text/plain; charset=utf-8");
  40. }
  41. if (ENABLE_GZIP_OUTPUT) {
  42. ob_start("ob_gzhandler");
  43. }
  44. handle_public_request($link, $op);
  45. // We close the connection to database.
  46. db_close($link);
  47. ?>