first commit
This commit is contained in:
79
core/LogReader/Item/Abstract.php
Normal file
79
core/LogReader/Item/Abstract.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
abstract class LogReader_Item_Abstract {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_timestamp;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_message;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_isNew;
|
||||
|
||||
/**
|
||||
* Unique id to distinct errors
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId() {
|
||||
return md5($this->getMessage());
|
||||
}
|
||||
|
||||
public function getTimestamp() {
|
||||
return $this->_timestamp;
|
||||
}
|
||||
|
||||
public function getType() {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return $this->_message;
|
||||
}
|
||||
|
||||
public function setTimestamp($timestamp) {
|
||||
$this->_timestamp = $timestamp;
|
||||
}
|
||||
|
||||
public function setType($type) {
|
||||
$this->_type = $type;
|
||||
}
|
||||
|
||||
public function setMessage($message) {
|
||||
$this->_message = $message;
|
||||
}
|
||||
|
||||
public function getIsNew() {
|
||||
return $this->_isNew;
|
||||
}
|
||||
|
||||
public function setIsNew($isNew) {
|
||||
$this->_isNew = $isNew;
|
||||
}
|
||||
|
||||
public function populate($data) {
|
||||
foreach ($data as $prop => $value) {
|
||||
if (property_exists($this, $prop)) {
|
||||
$this->$prop = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
63
core/LogReader/Item/ApachePhp.php
Normal file
63
core/LogReader/Item/ApachePhp.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
require_once 'LogReader/Item/Abstract.php';
|
||||
|
||||
class LogReader_Item_ApachePhp extends LogReader_Item_Abstract {
|
||||
|
||||
protected $_clientIp;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_stackTrace = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_referer = '';
|
||||
|
||||
|
||||
public function getReferer() {
|
||||
return $this->_referer;
|
||||
}
|
||||
|
||||
public function setReferer($referer) {
|
||||
$this->_referer = $referer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $line
|
||||
*/
|
||||
public function appendStackTrace($line) {
|
||||
$this->_stackTrace[] = $line;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStackTrace() {
|
||||
return $this->_stackTrace;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $clientIp
|
||||
*/
|
||||
public function setClientIp($clientIp) {
|
||||
$this->_clientIp = $clientIp;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClientIp() {
|
||||
return $this->_clientIp;
|
||||
}
|
||||
|
||||
}
|
||||
57
core/LogReader/Item/Nginx.php
Normal file
57
core/LogReader/Item/Nginx.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require_once '../core/LogReader/Item/Abstract.php';
|
||||
|
||||
class LogReader_Item_Nginx extends LogReader_Item_Abstract {
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_referrer = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_request = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_host = '';
|
||||
|
||||
|
||||
public function getRequest() {
|
||||
return $this->_request;
|
||||
}
|
||||
|
||||
public function getHost() {
|
||||
return $this->_host;
|
||||
}
|
||||
|
||||
public function setRequest($request) {
|
||||
$this->_request = $request;
|
||||
}
|
||||
|
||||
public function setHost($host) {
|
||||
$this->_host = $host;
|
||||
}
|
||||
|
||||
|
||||
public function getReferrer() {
|
||||
return $this->_referrer;
|
||||
}
|
||||
|
||||
public function setReferrer($referer) {
|
||||
$this->_referrer = $referer;
|
||||
}
|
||||
|
||||
public function getRequestUrl() {
|
||||
$request = preg_replace('/^GET (.+) HTTP.+/', '$1', $this->getRequest());
|
||||
$url = 'http://' . $this->getHost() . $request;
|
||||
return $url;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user