Advertisement
BrunoDeOliveira

prevent access from origin

Feb 9th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <?php
  2. function youShalDie() {
  3. echo "<h1>YOU SHALL NOT PASS!!</h1>";
  4. die;
  5. }
  6.  
  7. if ("GET" == $_SERVER["REQUEST_METHOD"]) {
  8. if (isset($_SERVER["HTTP_ORIGIN"]) || isset($_SERVER["HTTP_REFERER"])) {
  9. $allowedOrigin = "https://www.google.com.br/";
  10. if (
  11. strpos($allowedOrigin, $_SERVER["HTTP_ORIGIN"]) === FALSE &&
  12. strpos($allowedOrigin, $_SERVER["HTTP_REFERER"]) === FALSE
  13. ) {
  14. youShalDie();
  15. }
  16. } else {
  17. youShalDie();
  18. }
  19. }
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement