Advertisement
Gerst20051

HnS API Stuff

Jul 3rd, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. $ref = (isset($_SERVER['HTTP_REFERER']))?$_SERVER['HTTP_REFERER']:'';
  2. if (isset($ref) && !empty($ref) && isset($_GET['apikey']) && !empty($_GET['apikey'])) {
  3.     include "api_auth.php";
  4.     foreach($auth as $key => $referer) {
  5.         if ($_GET['apikey'] == $key && strpos($ref,$referer) !== false) { header('Access-Control-Allow-Origin: *'); break; }
  6.     }
  7. }
  8.  
  9. // OR
  10.  
  11. header('Access-Control-Allow-Origin: *');
  12. $ref = (isset($_SERVER['HTTP_REFERER']))?$_SERVER['HTTP_REFERER']:'';
  13. if (isset($ref) && !empty($ref) && isset($_GET['apikey']) && !empty($_GET['apikey'])) {
  14.     $allow = false;
  15.     $auth = array(
  16.         "hnsapi"=>"agerst.webs.com",
  17.         "hnsapi"=>"localhost"
  18.     );
  19.     foreach($auth as $key => $referer) {
  20.         if ($_GET['apikey'] == $key && strpos($ref,$referer) !== false) { $allow = true; break; }
  21.     }
  22.     if (!$allow) die('Bad API Key!');
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement