oxserverchecker.php

Go to the documentation of this file.
00001 <?php
00002 
00011 class oxServerChecker
00012 {
00013 
00017     const NODE_VALIDITY_TIME = 43200;
00018 
00024     private $_iCurrentTime = 0;
00025 
00029     public function __construct()
00030     {
00031         $this->_iCurrentTime = oxRegistry::get("oxUtilsDate")->getTime();
00032     }
00033 
00041     public function check(oxApplicationServer $oServer)
00042     {
00043         $blResult = false;
00044 
00045         if ($this->_isValid($oServer) && $this->_isServerTimeValid($oServer->getTimestamp())) {
00046             $blResult = true;
00047         }
00048 
00049         return $blResult;
00050     }
00051 
00059     private function _isValid($oServer)
00060     {
00061         return ($oServer->getTimestamp() - $this->_getCurrentTime() + self::NODE_VALIDITY_TIME) > 0;
00062     }
00063 
00071     private function _isServerTimeValid($iServerTimeInPast)
00072     {
00073         return ($this->_getCurrentTime() - $iServerTimeInPast) >= 0;
00074     }
00075 
00081     private function _getCurrentTime()
00082     {
00083         return $this->_iCurrentTime;
00084     }
00085 }