Last active
December 11, 2015 02:59
-
-
Save vladimir-light/4534241 to your computer and use it in GitHub Desktop.
Checks if request is a AJAX-Request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ajax = false; | |
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') | |
{ | |
$ajax = true; | |
} | |
if (!$ajax) | |
{ | |
header("HTTP/1.0 401 Not AJAX"); | |
echo "<h1>HTTP Status : 401 - Access is denied!</h1> | |
<h3>Message: You have no permission to access this page</h3>"; | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment