Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Session / Validator / HttpUserAgent.php
blobe64d8b673eb156afee5877f9040528fb677e4c71
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Session\Validator;
12 class HttpUserAgent implements ValidatorInterface
14 /**
15 * Internal data
17 * @var string
19 protected $data;
21 /**
22 * Constructor
23 * get the current user agent and store it in the session as 'valid data'
25 * @param string|null $data
27 public function __construct($data = null)
29 if (empty($data)) {
30 $data = isset($_SERVER['HTTP_USER_AGENT'])
31 ? $_SERVER['HTTP_USER_AGENT']
32 : null;
34 $this->data = $data;
37 /**
38 * isValid() - this method will determine if the current user agent matches the
39 * user agent we stored when we initialized this variable.
41 * @return bool
43 public function isValid()
45 $userAgent = isset($_SERVER['HTTP_USER_AGENT'])
46 ? $_SERVER['HTTP_USER_AGENT']
47 : null;
49 return ($userAgent === $this->getData());
52 /**
53 * Retrieve token for validating call
55 * @return string
57 public function getData()
59 return $this->data;
62 /**
63 * Return validator name
65 * @return string
67 public function getName()
69 return __CLASS__;