Example #1
0
 protected function _write($event)
 {
     $ip = Zend_Controller_Action_HelperBroker::getStaticHelper('Currentip');
     $event['ip'] = $ip->getCurrentIp();
     $event['created_by'] = Zend_Auth::getInstance()->getIdentity()->id;
     parent::_write($event);
 }
Example #2
0
 protected function _write($event)
 {
     $ip = Zend_Controller_Action_HelperBroker::getStaticHelper('Currentip');
     $event['ip_client'] = $ip->getCurrentIp();
     $event['ip_host'] = $_SERVER['SERVER_ADDR'];
     $event['created_by'] = Zend_Auth::getInstance()->getIdentity()->id;
     $event['id_branch'] = Zend_Auth::getInstance()->getIdentity()->id_branch;
     $event['request_headers'] = Zend_Json::encode(getallheaders());
     $event['url'] = 'http' . (empty($_SERVER['HTTPS']) ? '' : 's') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     $event['request_parameters'] = Zend_Json::encode($_REQUEST);
     $event['request_hash'] = $this->getRequestHash();
     parent::_write($event);
 }
Example #3
0
 /**
  * Write a message to the log.
  *
  * @param  array  $event  event data
  * @return void
  * @throws Zend_Log_Exception
  */
 protected function _write($event)
 {
     $config = Zend_Registry::get('config');
     $isLogMsg = (bool) $config['logging']['log']['enable'];
     $isLogStat = (bool) $config['logging']['statistics']['enable'];
     $isLogEx = (bool) $config['logging']['exeption']['enable'];
     // Проверим возможность логирования
     if ($this->_table == 'log_msg' && !$isLogMsg) {
         return;
     } elseif ($this->_table == 'log_stat' && !$isLogStat) {
         return;
     } elseif ($this->_table == 'log_error' && !$isLogEx) {
         return;
     }
     // Удалим лишние записи
     if ($this->_max_rows && $this->_max_rows !== -1) {
         $select = $this->_db->select();
         $select->from($this->_table, 'count(*)');
         $count_rows = (int) $this->_db->fetchOne($select);
         if ($count_rows >= $this->_max_rows) {
             // Получим массив ids для удаления строк в таблице
             $limit = $count_rows - $this->_max_rows;
             $limit++;
             $select = $this->_db->select();
             $select->from($this->_table, 'id');
             $select->limit($limit, 0);
             $row_ids = $this->_db->fetchCol($select);
             // Удалим строки из таблицы
             foreach ($row_ids as $id) {
                 $this->_db->delete($this->_table, 'id=' . $id);
             }
         }
     }
     // Запишем событие в лог
     parent::_write($event);
 }