Advertisement
crazykid_ceh

PHP check IP and useragent

Jul 23rd, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. $guest_ip = $_SERVER['REMOTE_ADDR'];
  4. $guest_agent = $_SERVER['HTTP_USER_AGENT'];
  5. $ip_list = file('ip.txt');
  6. $agent_list = file('agent.txt');
  7. $success = false;
  8.  
  9.  
  10.  foreach($agent_list as $agent_num)
  11.     foreach ($ip_list as $ip_num)
  12.         if($agent_num == $guest_agent)
  13.             if($ip_num == $guest_ip)
  14.                 {
  15.                     $success = true;
  16.                      break;
  17.                 }
  18.            
  19.  
  20. if($success == true)
  21. nextgo();
  22. else
  23. drop();
  24.  
  25.  
  26. function nextgo()
  27. {
  28.     echo "congulation!";
  29. }
  30. function drop()
  31. {
  32.     echo "false";
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement