/**
  * nagios monitoring for tine 2.0 logins during the last 5 mins
  * 
  * @return number
  * 
  * @todo allow to configure timeslot
  */
 public function monitoringLoginNumber()
 {
     $message = 'LOGINS';
     $result = 0;
     try {
         $filter = new Tinebase_Model_AccessLogFilter(array(array('field' => 'li', 'operator' => 'after', 'value' => Tinebase_DateTime::now()->subMinute(5))));
         $accesslogs = Tinebase_AccessLog::getInstance()->search($filter, NULL, FALSE, TRUE);
         $valueString = ' | count=' . count($accesslogs) . ';;;;';
         $message .= ' OK' . $valueString;
     } catch (Exception $e) {
         $message .= ' FAIL: ' . $e->getMessage();
         $result = 2;
     }
     echo $message . "\n";
     return $result;
 }
 /**
  * update access log entry if needed
  * 
  * @param Tinebase_Model_FullUser $user
  * @param Tinebase_Model_AccessLog $accessLog
  */
 protected function _updateAccessLog(Tinebase_Model_FullUser $user, Tinebase_Model_AccessLog $accessLog)
 {
     if (!$accessLog->getId()) {
         $user->setLoginTime($accessLog->ip);
         if ($this->_writeAccessLog) {
             $accessLog->setId(Tinebase_Record_Abstract::generateUID());
             $accessLog = Tinebase_AccessLog::getInstance()->create($accessLog);
         }
     }
     Tinebase_Core::set(Tinebase_Core::USERACCESSLOG, $accessLog);
 }
 /**
  * add access log entry
  * 
  * @param Tinebase_Model_FullUser $_user
  * @param String $_clienttype
  */
 protected function _addAccessLog($_user, $_clienttype)
 {
     Tinebase_AccessLog::getInstance()->create(new Tinebase_Model_AccessLog(array('sessionid' => 'test_session_id', 'login_name' => $_user->accountLoginName, 'ip' => '127.0.0.1', 'li' => Tinebase_DateTime::now()->get(Tinebase_Record_Abstract::ISO8601LONG), 'result' => Zend_Auth_Result::SUCCESS, 'account_id' => $_user->getId(), 'clienttype' => $_clienttype)));
 }
 /**
  * set session id for current request in accesslog
  *
  * @param Tinebase_Model_AccessLog $accessLog
  */
 public function setSessionId(Tinebase_Model_AccessLog $accessLog)
 {
     if (in_array($accessLog->clienttype, array(Tinebase_Server_WebDAV::REQUEST_TYPE, ActiveSync_Server_Http::REQUEST_TYPE))) {
         try {
             $previousAccessLog = Tinebase_AccessLog::getInstance()->getPreviousAccessLog($accessLog);
             $accessLog->sessionid = $previousAccessLog->sessionid;
         } catch (Tinebase_Exception_NotFound $tenf) {
             // ignore
         }
     }
     if (empty($accessLog->sessionid)) {
         $accessLog->sessionid = Tinebase_Core::getSessionId();
     } else {
         Tinebase_Core::set(Tinebase_Core::SESSIONID, $accessLog->sessionid);
     }
 }
 /**
  * delete access log entries
  *
  * @param   array $_ids list of logIds to delete
  */
 public function delete($_ids)
 {
     $this->checkRight('MANAGE_ACCESS_LOG');
     Tinebase_AccessLog::getInstance()->delete($_ids);
 }
Beispiel #6
0
 /**
  * destroy session
  *
  * @return void
  */
 public function logout($_ipAddress)
 {
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $currentAccount = Tinebase_Core::getUser();
         if (is_object($currentAccount)) {
             Tinebase_AccessLog::getInstance()->setLogout(session_id(), $_ipAddress);
         }
     }
     Zend_Session::destroy();
 }
 /**
  * set up tests
  */
 protected function setUp()
 {
     parent::setUp();
     $this->_uit = Tinebase_AccessLog::getInstance();
 }