Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
condition_user_agent.inc
1 <?php
17 require_once SQ_CORE_PACKAGE_PATH.'/system/conditions/condition/condition.inc';
18 
33 {
34 
35 
42  function __construct($assetid=0)
43  {
44  parent::__construct($assetid);
45 
46  }//end constructor
47 
48 
58  public static function evaluate(Asset $asset, Array $condition_data)
59  {
60  if (!isset($condition_data['user_agent'])) {
61  return FALSE;
62  }
63  if (!isset($_SERVER['HTTP_USER_AGENT'])) {
64  return FALSE;
65  }
66 
67  // escape any '/' that are thrown oru way
68  $condition_data['user_agent'] = str_replace('/', '\/', $condition_data['user_agent']);
69  $matches = preg_match('/'.$condition_data['user_agent'].'/i', $_SERVER['HTTP_USER_AGENT']);
70  return ($matches > 0);
71 
72  }//end evaluate()
73 
74 
75 }//end class
76 ?>