Zum Inhalt springen

AWStats realurl

Erstellt am 18. Februar 2005 · 19 Antworten · letzte Antwort am 13. Juni 2012

Tags: RealURL, Frage

adventuremaker ·

Um das Thema nochmal aufzuwärmen:

Gibt's da mittlerweile eine elegantere Lösung für? Kann man das mit einer Extensions lösen?

Der Tipp von Roger ist zwar klasse und funktioniert auch, ist aber sicher nicht der optimalste Weg. Besonders im Hinblick auf die Updatefähigkeit von TYPO3...

semidark ·

Hallo Roger,

ich habe wie von adventuremaker schon abgesprochen die Anpassungen in eine Extension gepackt. Diese möchte ich nach Fertigstellung natürlich auch veröffentlichen. Soweit funktioniert eigentlich auch alles ganz gut. Nur werden bei mir jetzt aus irgendwelchen gründen die Startseite nicht mehr in das Log geschrieben.

Jemand ne idee warum?

Hier der Quellcode der Extension bei dem in der Zeile 124 die hier bereits besprochene Erweiterung entählt. Den rest habe ich noch nicht bearbeitet.

<?php

class ux_tslib_fe extends tslib_fe {
	/**
	 * Checks if config-array exists already but if not, gets it
	 * Addition by Nico Thomaier @line 123: add realurl generated pagename to array
	 * @return	void
	 */
	function getConfigArray()	{
		$setStatPageName = false;

		if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing)	{	// If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
				$GLOBALS['TT']->push('Parse template','');

				// Force parsing, if set?:
			$this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;

				// Start parsing the TS template. Might return cached version.
			$this->tmpl->start($this->rootLine);
				$GLOBALS['TT']->pull();

			if ($this->tmpl->loaded)	{
				$GLOBALS['TT']->push('Setting the config-array','');
			//	t3lib_div::print_array($this->tmpl->setup);
				$this->sPre = $this->tmpl->setup['types.'][$this->type];	// toplevel - objArrayName
				$this->pSetup = $this->tmpl->setup[$this->sPre.'.'];

				if (!is_array($this->pSetup))	{
					$this->printError('The page is not configured! [type= '.$this->type.']['.$this->sPre.']');
					exit;
				} else {
					$this->config['config']=Array();

						// Filling the config-array.
					if (is_array($this->tmpl->setup['config.']))	{
						$this->config['config'] = $this->tmpl->setup['config.'];
					}
					if (is_array($this->pSetup['config.']))	{
						reset($this->pSetup['config.']);
						while(list($theK,$theV)=each($this->pSetup['config.']))	{
							$this->config['config'][$theK] = $theV;
						}
					}
						// if .simulateStaticDocuments was not present, the default value will rule.
					if (!isset($this->config['config']['simulateStaticDocuments']))	{
						$this->config['config']['simulateStaticDocuments'] = trim($this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']);
					}
					if ($this->config['config']['simulateStaticDocuments']) {
							// Set replacement char only if it is needed
						$this->setSimulReplacementChar();
					}

						// Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
					if (!isset($this->config['config']['removeDefaultJS']) && t3lib_div::compat_version('4.0'))	{
						$this->config['config']['removeDefaultJS'] = 'external';
					}
					if (!isset($this->config['config']['inlineStyle2TempFile']) && t3lib_div::compat_version('4.0'))	{
						$this->config['config']['inlineStyle2TempFile'] = 1;
					}

							// Processing for the config_array:
					$this->config['rootLine'] = $this->tmpl->rootLine;
					$this->config['mainScript'] = trim($this->config['config']['mainScript']) ? trim($this->config['config']['mainScript']) : 'index.php';

						// STAT:
					$theLogFile = $this->TYPO3_CONF_VARS['FE']['logfile_dir'].strftime($this->config['config']['stat_apache_logfile']);
						// Add PATH_site left to $theLogFile if the path is not absolute yet
					if (!t3lib_div::isAbsPath($theLogFile)) $theLogFile = PATH_site.$theLogFile;

					if ($this->config['config']['stat_apache'] && $this->config['config']['stat_apache_logfile'] && !strstr($this->config['config']['stat_apache_logfile'],'/'))	{
						if (t3lib_div::isAllowedAbsPath($theLogFile))	{
							if (!@is_file($theLogFile))	{
								touch($theLogFile);	// Try to create the logfile
								t3lib_div::fixPermissions($theLogFile);
							}

							if (@is_file($theLogFile) && @is_writable($theLogFile))	{
								$this->config['stat_vars']['logFile'] = $theLogFile;
								$setStatPageName = true;	// Set page name later on
							} else {
								$GLOBALS['TT']->setTSlogMessage('Could not set logfile path. Check filepath and permissions.',3);
							}
						}
					}

					$this->config['FEData'] = $this->tmpl->setup['FEData'];
					$this->config['FEData.'] = $this->tmpl->setup['FEData.'];
				}
				$GLOBALS['TT']->pull();
			} else {
				$this->printError('No template found!');
				exit;
			}
		}

			// Initialize charset settings etc.
		$this->initLLvars();

			// We want nice names, so we need to handle the charset
		if ($setStatPageName)	{
				// Make life easier and accept variants for utf-8
			if (preg_match('/utf-?8/i', $this->config['config']['stat_apache_niceTitle']))	{
				$this->config['config']['stat_apache_niceTitle'] = 'utf-8';
			}
			if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8')	{
				$shortTitle = $this->csConvObj->utf8_encode($this->page['title'],$this->renderCharset);
			} elseif ($this->config['config']['stat_apache_niceTitle'])	{
				$shortTitle = $this->csConvObj->specCharsToASCII($this->renderCharset,$this->page['title']);
			} else {
				$shortTitle = $this->page['title'];
			}
			$len = t3lib_div::intInRange($this->config['config']['stat_apache_pageLen'],1,100,30);
			if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8')	{
				$shortTitle = rawurlencode($this->csConvObj->substr('utf-8',$shortTitle,0,$len));
			} else {
				$shortTitle = substr(preg_replace('/[^.[:alnum:]_-]/','_',$shortTitle),0,$len);
			}
			$pageName = $this->config['config']['stat_apache_pagenames'] ? $this->config['config']['stat_apache_pagenames'] : '[path][title]--[uid].html';
			$pageName = str_replace('[title]', $shortTitle ,$pageName);
			$pageName = str_replace('[uid]',$this->page['uid'],$pageName);
			$pageName = str_replace('[alias]',$this->page['alias'],$pageName);
			$pageName = str_replace('[type]',$this->type,$pageName);
			// REALURL EXTENSION - Start      
      $pageName = str_replace('[realurl]',$_SERVER['REDIRECT_URL'],$pageName);
			// REALURL EXTENSION - END
			
			$temp = $this->config['rootLine'];
			array_pop($temp);
			if ($this->config['config']['stat_apache_noRoot'])	{
				array_shift($temp);
			}
			$len = t3lib_div::intInRange($this->config['config']['stat_titleLen'],1,100,20);
			if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8')	{
				$path = '';
				$c = count($temp);
				for ($i=0; $i<$c; $i++)	{
					if ($temp[$i]['uid'])	{
						$p = $this->csConvObj->crop('utf-8',$this->csConvObj->utf8_encode($temp[$i]['title'],$this->renderCharset),$len,"\xE2\x80\xA6");	// U+2026; HORIZONTAL ELLIPSIS
						$path .= '/' . rawurlencode($p);
					}
				}
			} elseif ($this->config['config']['stat_apache_niceTitle'])	{
				$path = $this->csConvObj->specCharsToASCII($this->renderCharset,$this->sys_page->getPathFromRootline($temp,$len));
			} else {
				$path = $this->sys_page->getPathFromRootline($temp,$len);
			}
			if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8')	{
				$this->config['stat_vars']['pageName'] = str_replace('[path]', $path.'/', $pageName);
			} else {
				$this->config['stat_vars']['pageName'] = str_replace('[path]', preg_replace('/[^.[:alnum:]\/_-]/','_',$path.'/'), $pageName);
			}
		}

			// No cache
		if ($this->config['config']['no_cache'])	{ $this->set_no_cache(); }		// Set $this->no_cache true if the config.no_cache value is set!

			// Check PATH_INFO url
		if ($this->absRefPrefix_force && strcmp($this->config['config']['simulateStaticDocuments'],'PATH_INFO'))	{
			$redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php?id='.$this->id.'&type='.$this->type;
			if ($this->config['config']['simulateStaticDocuments_dontRedirectPathInfoError'])	{
				$this->printError('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!<br /><br /><a href="'.htmlspecialchars($redirectUrl).'">Click here to get to the right page.</a>','Error: PATH_INFO not configured');
			} else {
				header('Location: '.t3lib_div::locationHeaderUrl($redirectUrl));
			}
			exit;
//			$this->set_no_cache();	// Set no_cache if PATH_INFO is NOT used as simulateStaticDoc. and if absRefPrefix_force shows that such an URL has been passed along.
		}
	}
}
?>

Wäre super wenn jemand ne idee hätte. Hab mir den Code schon genau angesehen bin aber bis jetzt noch nicht auf den BUG gestoßen

Gruß Semidark

adventuremaker ·

Hallo Roger,

vielen Dank schonmal für deine Mühe!
Vielleicht solltest du anstatt $_SERVER['REDIRECT_URL'] lieber t3lib_div::getIndpEnv('TYPO3_REQUEST_URL') verwenden.

Habs aber noch nicht getestet.

semidark ·

Hallo adventuremaker,

ich heiße doch nicht roger 😉

Naja egal. Auf jedenfall hat dein Post mich auf den richtigen weg gebracht so das ich die Extension "cr_awstat_realurl" fertig stellen konnte und diese gerade ins TER gespielt habe. Sollte wohl morgen zum Dowload bereit stehen.

http://typo3.org/extensions/repository/view/cr_awstat_realurl/0.1.1/

Den Quellcode habe ich noch stark verkürzt so das er - hoffentlich - auch mit allen Typo3 Versionen funktioniert. In 3.8.1 und 4.1 hat die extension einwandfrei funktioniert.

<?php

class ux_tslib_fe extends tslib_fe {
	/**
	 * Checks if config-array exists already but if not, gets it
	 * to array
	 * @return	void
	 */
	function getConfigArray()	{
    parent::getConfigArray();
    if ($this->config['stat_vars']['pageName']=='[realurl]') {
      $this->config['stat_vars']['pageName'] = '/'.t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT');
    }
	}
}
?>

Gruß Semidark

adventuremaker ·

So, ich habe die Extension eben mal installiert (und direkt noch die TYPO3-Version auf 4.1.1 aktualisiert).
Scheint alles zu funktionieren!

Gute Arbeit und vielen Dank nochmal!

paukul ·

sorry fürs ausgraben... aber was genau muss ich denn amchen dass
die cr_awstat_realurl mir das gewünschte ergebniss bringt?

hab cc_awstats 1.10.0 und cr_awstat_realurl 0.1.1 installiert,
logfiles geleert, awstats cache gelöscht und bisschen auf meiner
Seite rumgeklickt. Wenn ich nun im Backend Modul die Logfiles auswerte
dann lande ich trotzdem noch solche links hier angezeigt:

/xyz.../Basic_Services/Schnittstellenthematik--40.html

der eintrag dazu in den Logfiles sieht so aus:

212.6.247.21 - - [01/Aug/2007:11:34:24 +0000] "GET /xyz.../Basic_Services/Schnittstellenthematik--40.html HTTP/1.1" 200 10353 "http://xyz/de/basic-services/"

habe einfach nur awstats isntalliert, logging enabled, cc_awstat_realurl installiert, logfile ausgewählt.

irgendwas vergessen? irgend ein Parameter? evtl im typoscript setup?

paukul ·

sehs gerade,

config.stat_apache_pagenames = [realurl]

muss ins setup. Wäre evtl gut das in die Doku rein zu nehmen?!
(oder zumindest extension beschreibung die man im repos sieht)

ansonsten danke für die extension 🙂

semidark ·

Hallo paukul,

sehr schon das du es hinbekommen hast.

ich hatte in die Description vom TER geschrieben
Usage: config.stat_apache_pagenames = [realurl]

Nur wurde aus irgendwelchen Gründen das = verschluckt.

Da ich kein OpenOffice benutze, habe ich immer leichte
Probleme Dokumentationen für das TER zu erstellen.

Wenn ich mal zeit habe werde ich das Thema angehen.

Gruß Semidark