Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Service/DeveloperGarden/IpLocation/IpAddress.php
Go to the documentation of this file.
00001 <?php
00026 require_once 'Zend/Validate/Ip.php';
00027 
00036 class Zend_Service_DeveloperGarden_IpLocation_IpAddress
00037 {
00045     private $_version = 4;
00046 
00052     private $_versionSupported = array(
00053         4,
00054         //6, not supported yet
00055     );
00056 
00057     private $_address = null;
00058 
00067     public function __construct($ip, $version = 4)
00068     {
00069         $this->setIp($ip)
00070              ->setVersion($version);
00071     }
00072 
00080     public function setIp($ip)
00081     {
00082         $validator = new Zend_Validate_Ip();
00083 
00084         if (!$validator->isValid($ip)) {
00085             $message = $validator->getMessages();
00086             require_once 'Zend/Service/DeveloperGarden/Exception.php';
00087             throw new Zend_Service_DeveloperGarden_Exception($message['notIpAddress']);
00088         }
00089         $this->_address = $ip;
00090         return $this;
00091     }
00092 
00098     public function getIp()
00099     {
00100         return $this->_address;
00101     }
00102 
00110     public function setVersion($version)
00111     {
00112         if (!in_array($version, $this->_versionSupported)) {
00113             require_once 'Zend/Service/DeveloperGarden/Exception.php';
00114             throw new Zend_Service_DeveloperGarden_Exception('Ip Version ' . (int)$version . ' is not supported.');
00115         }
00116 
00117         $this->_version = $version;
00118         return $this;
00119     }
00120 
00126     public function getVersion()
00127     {
00128         return $this->_version;
00129     }
00130 }
 All Data Structures Namespaces Files Functions Variables Enumerations