[TYPO3-core] RFC correction: Feature #1585: Logfile by Request URI + configuration of Empty Referer handling + logline hook
Martin Kutschker
martin.t.kutschker at n0spam.blackbox.net
Sat Nov 10 17:10:11 CET 2007
Ralf Hettinger schrieb:
>
> Solution:
> (1) Introduce the option [requesturi] to config.stat_apache_pagenames
I think of more interest is TYPO3_SITE_SCRIPT, which does not include
any path parts before the actual TYPO3 root.
But both variables include the query part, which currently is not
available for TYPO3 logging. I would like to see the query part removed
(or an option to do so).
> (2) Though this is not an exact solution (which I think is not possible due to
> missing env var), it could be made configurable how to log hits with an empty
> referer (since Apache's direct address hits will be seen as empty referer by
> TYPO3). Introducing the property stat_apache_NoRefererIsDirectAddress=[boolean]
> for this reason (see attached .txt)
AFAICS Apache uses for ALL empty fields in the log the -. So I suggest a
"config.stat_apache_emptyValue = -" setting affecting both referer and
user agent.
> (3) On behalf of Thomas Oppelt: Add a LogLine hook to tslib_fe->statistics():
> TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['createLogLine'][]->createLogLine(&$LogLine,$this)
Wrong name. The name should start with the method's name (not the
exiting hook in the method.) My suggestion: sys_stat-PreLogClass (odd
but in sync with the old one). And I don't think we need references for
passing strings.
Masi
>
> Comments:
> Previous version used ambiguous wording for a suggested TS property
> (stat_apache_NoRefererIsDirectAccess), which is changed hereby to
> stat_apache_NoRefererIsDirectAddress to better reflect its function.
>
>
> Ralf Hettinger
>
>
> ------------------------------------------------------------------------
>
> Index: typo3/sysext/cms/tslib/class.tslib_fe.php
> ===================================================================
> --- typo3/sysext/cms/tslib/class.tslib_fe.php (Revision 2682)
> +++ typo3/sysext/cms/tslib/class.tslib_fe.php (Arbeitskopie)
> @@ -1945,6 +1945,7 @@
> $pageName = str_replace('[uid]',$this->page['uid'],$pageName);
> $pageName = str_replace('[alias]',$this->page['alias'],$pageName);
> $pageName = str_replace('[type]',$this->type,$pageName);
> + $pageName = str_replace('[requesturi]',t3lib_div::getIndpEnv('REQUEST_URI'),$pageName);
> $temp = $this->config['rootLine'];
> array_pop($temp);
> if ($this->config['config']['stat_apache_noRoot']) {
> @@ -3254,9 +3255,19 @@
> if (@is_file($this->config['stat_vars']['logFile'])) {
> $LogLine = ((t3lib_div::getIndpEnv('REMOTE_HOST') && !$this->config['config']['stat_apache_noHost']) ? t3lib_div::getIndpEnv('REMOTE_HOST') : t3lib_div::getIndpEnv('REMOTE_ADDR')).' - - '.Date('[d/M/Y:H:i:s +0000]',$GLOBALS['EXEC_TIME']).' "GET '.$this->config['stat_vars']['pageName'].' HTTP/1.1" 200 '.strlen($this->content);
> if (!$this->config['config']['stat_apache_notExtended']) {
> - $LogLine.= ' "'.t3lib_div::getIndpEnv('HTTP_REFERER').'" "'.t3lib_div::getIndpEnv('HTTP_USER_AGENT').'"';
> + if ($this->config['config']['stat_apache_NoRefererIsDirectAddress']) {
> + $LogLine.= ' "'.((t3lib_div::getIndpEnv('HTTP_REFERER'))?t3lib_div::getIndpEnv('HTTP_REFERER'):'-').'" "'.t3lib_div::getIndpEnv('HTTP_USER_AGENT').'"';
> + } else {
> + $LogLine.= ' "'.t3lib_div::getIndpEnv('HTTP_REFERER').'" "'.t3lib_div::getIndpEnv('HTTP_USER_AGENT').'"';
> + }
> }
> -
> + // Hook for processing LogLine
> + if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['createLogLine'])) {
> + foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['createLogLine'] as $_classRef) {
> + $_procObj = &t3lib_div::getUserObj($_classRef);
> + $_procObj->createLogLine(&$LogLine,$this);
> + }
> + }
> $GLOBALS['TT']->push('Write to log file (fputs)');
> $logfilehandle = fopen($this->config['stat_vars']['logFile'], 'a');
> fputs($logfilehandle, $LogLine.chr(10));
>
>
> ------------------------------------------------------------------------
>
> Ralf Hettinger, 2007-11-10 <bug>1585</bug>: statistics and realurl + statistics and handling of empty referer hits
> <pre>
> TSref [tsref:config/->CONFIG]
>
>
> (1) Add option to description of stat_apache_pagenames
>
> [requesturi] = The requested URI (server environment variable). Quite useful if you use realurl or any other rewrite extension.
>
>
>
> (2) Add new property after stat_apache_noRoot
>
> Property:
> stat_apache_NoRefererIsDirectAddress
>
> Data type:
> boolean
>
> Description:
> Configures logging of hits with an empty referer. If not set (default), they will be logged as hits with an empty referer. If set, these hits will be logged as if they were direct address hits (i.e. hits by using a browser's bookmark or hits by visitors who type the URL directly into their browser's address line).
>
> Possible additional description:
> Apache itself is able to log the difference between empty referers and direct address hits. But since there is no environment variable for this, TYPO3 cannot track direct address hits and will by default log them as hits with an empty referer. Which is not unlikely to be the "wronger" interpretation of those hits.
> </pre>
More information about the TYPO3-team-core
mailing list