url.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * URL redirector to avoid leaking Referer with some sensitive information.
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. /**
  9. * Gets core libraries and defines some variables
  10. */
  11. define('PMA_MINIMUM_COMMON', true);
  12. require_once './libraries/common.inc.php';
  13. /**
  14. * JavaScript escaping.
  15. */
  16. require_once './libraries/js_escape.lib.php';
  17. require_once './libraries/Response.class.php';
  18. // Only output the http headers
  19. $response = PMA_Response::getInstance();
  20. $response->getHeader()->sendHttpHeaders();
  21. $response->disable();
  22. if (! PMA_isValid($_GET['url'])
  23. || ! preg_match('/^https?:\/\/[^\n\r]*$/', $_GET['url'])
  24. || ! PMA_isAllowedDomain($_GET['url'])
  25. ) {
  26. header('Location: ' . $cfg['PmaAbsoluteUri']);
  27. } else {
  28. // JavaScript redirection is necessary. Because if header() is used
  29. // then web browser sometimes does not change the HTTP_REFERER
  30. // field and so with old URL as Referer, token also goes to
  31. // external site.
  32. echo "<script type='text/javascript'>
  33. window.onload=function(){
  34. window.location='" . PMA_escapeJsString($_GET['url']) . "';
  35. }
  36. </script>";
  37. // Display redirecting msg on screen.
  38. printf(__('Taking you to %s.'), htmlspecialchars($_GET['url']));
  39. }
  40. die();
  41. ?>