Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ref = (isset($_SERVER['HTTP_REFERER']))?$_SERVER['HTTP_REFERER']:'';
- if (isset($ref) && !empty($ref) && isset($_GET['apikey']) && !empty($_GET['apikey'])) {
- include "api_auth.php";
- foreach($auth as $key => $referer) {
- if ($_GET['apikey'] == $key && strpos($ref,$referer) !== false) { header('Access-Control-Allow-Origin: *'); break; }
- }
- }
- // OR
- header('Access-Control-Allow-Origin: *');
- $ref = (isset($_SERVER['HTTP_REFERER']))?$_SERVER['HTTP_REFERER']:'';
- if (isset($ref) && !empty($ref) && isset($_GET['apikey']) && !empty($_GET['apikey'])) {
- $allow = false;
- $auth = array(
- "hnsapi"=>"agerst.webs.com",
- "hnsapi"=>"localhost"
- );
- foreach($auth as $key => $referer) {
- if ($_GET['apikey'] == $key && strpos($ref,$referer) !== false) { $allow = true; break; }
- }
- if (!$allow) die('Bad API Key!');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement