Skip to content

Commit

Permalink
*8015* Added regex to parse plugin log files, add url to track issue …
Browse files Browse the repository at this point in the history
…views
  • Loading branch information
beghelli committed Apr 25, 2013
1 parent 9abd569 commit 96e7123
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions plugins/generic/usageStats/UsageStatsLoader.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,21 @@ private function _isLogEntryValid($entry, $lineNumber) {
private function _getDataFromLogEntry($entry) {
$plugin = $this->_plugin; /* @var $plugin Plugin */
if (!$plugin->getSetting(0, 'createLogFiles')) {
// User defined regex to parse external log files.
$parseRegex = $plugin->getSetting(0, 'accessLogFileParseRegex');
} else {
// Regex to parse this plugin's log access files.
$parseRegex = '/^(\S+) \S+ \S+ "(.*?)" (\S+)/';
}

if (!$parseRegex) $parseRegex = '/^(\S+) \S+ \S+ \[(.*?)\] "(\S+).*?" \d+ \d+ "(.*?)" "(.*?)"/';
// The default regex will parse only apache log files in combined format.
if (!$parseRegex) $parseRegex = '/^(\S+) \S+ \S+ \[(.*?)\] "\S+.*?" \d+ \d+ "(.*?)"/';

$returner = array();
if (preg_match($parseRegex, $entry, $m)) {
$returner['ip'] = $m[1];
$returner['date'] = strtotime($m[2]);
$returner['method'] = $m[3];
$returner['referer'] = $m[4];
$returner['browser'] = $m[5];
$returner['referer'] = $m[3];
}

return $returner;
Expand All @@ -180,14 +183,16 @@ private function _getDataFromLogEntry($entry) {
*/
private function _getExpectedReferer() {
return array(ASSOC_TYPE_ARTICLE => array(
'/article/view/',
'/article/viewArticle/',
'/article/viewDownloadInterstitial/',
'/article/download/',
'/article/view/',
'/article/viewArticle/',
'/article/viewDownloadInterstitial/',
'/article/download/'),
ASSOC_TYPE_ISSUE => array(
'issue/view'
)
));
'issue/view/',
'issue/viewFile/',
'issue/viewDownloadInterstitial/',
'issue/download/')
);
}

/**
Expand Down Expand Up @@ -219,8 +224,7 @@ private function _getAssocFromReferer($referer) {
if ($refererCheck) {
// Get the assoc id inside the passed referer.
$explodedString = explode($workingReferer, $referer);
$explodedString = explode('/', $explodedString[1]);
$assocId = $explodedString[0];
$assocId = $explodedString[1];

if (!is_numeric($assocId)) {
$assocId = false;
Expand Down

0 comments on commit 96e7123

Please sign in to comment.