Problem with image tracker url

I a trying to track down not only visitors but bots as well (google,bing, facebook scraper etc.).
After some tests I noticed that some bots parse the image tracker url like this


<img src="http://domain.com/clients/metrics-analytics/piwik.php?idsite=1&rec=1"

instead of


<img src="http://domain.com/clients/metrics-analytics/piwik.php?idsite=1&rec=1"

That confuses piwik somehow…
The debugger returns this when I try to visit the image url :


Debug enabled - Input parameters: <br/>array ( 'rec' => '1', 'amp;idsite' => '1', )
Loading plugins: { Provider,Goals,BotTracker }
Current datetime: 2012-03-14 15:15:32

Invalid idSite

Backtrace:

#0 /home/content/90/8889490/html/clients/metrics-analytics/core/Tracker.php(110): Piwik_Tracker_Visit->setRequest(Array)
#1 /home/content/90/8889490/html/clients/metrics-analytics/piwik.php(83): Piwik_Tracker->main()
#2 {main}

I suppose you convert the given url to an array using explode(’&’… or something similar.
A solution to this would be to replace all the “&” strings to “&” using the str_replace() function but I have no idea what file to mess with.

Can you help me out with this please?

see function getRequestVar() in Common.php

Thanks, I’ll check it out!

Until now I was checking the url structure in main() (core/Tracker.php) and redirecting if necessary :confused:


		$pageURL = 'http';
		if (isset($_SERVER["HTTPS"])){
			if ($_SERVER["HTTPS"] == "on" ) { $pageURL .= "s"; }
		}
		$pageURL .= "://";
		if ($_SERVER["SERVER_PORT"] != "80" ) {
			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
		} else {
			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		}
			 
		$pos = strpos($pageURL,'&');
		
		if ($pos !== false){ 
			$pageURL = str_replace('&','&',$pageURL);
			header('Location: '.$pageURL);
			exit;
		}

Don’t know if it was the right thing to do but it did the trick.