Localhost (and other domain) exclusion

I searched the forum and found this unresolved post 301 Moved Permanently

I wanted to exclude localhost from showing up under Visitor->Visitor Log in the Action column so a website’s stats wouldn’t get messed up when I doing maintenance .

I added the following at the start of the handle() function in Piwik 1.7.1
core/Tracker/Visit.php. line 130


$pos = strpos($this->request['url'], "://localhost" );
		if ($pos > 0)
		{
			return;
		}

this works fine and will exclude localhost if it is running on http, https, or a different port. For some reason adding 127.0.0.1 to the list of excluded ips did not work.

My question is “Is there a better way to do this and how do I take the beacon into account (e.g. JavaScript disabled)”?

I tried to get this to work with multiple websites using something like this but it breaks all tracking. It would only work for someone with a small number of sites that needed to be excluded and had just a handful of websites to track anyways. It doesn’t work but is a start for someone that want’s something quick and dirty.


$excludedDomains = $array(
				"://localhost",
				"dev.domain.com" );
		$domainIsExcluded = false;				
		for ($i = 0; $i < count($excludedDomains ); $i++)
		{
			$pos = strpos($this->request['url'], $excludedDomains [$i]);
			if ($pos > 0)
			{
				$domainIsExcluded = true;
			}
		}
		if ($domainIsExcluded == true)
		{		
			return;
		}

in the meantime I suppose this would work


$pos = strpos($this->request['url'], "://localhost" );
		if ($pos > 0)
		{
			return;
		}
$pos = strpos($this->request['url'], "dev.domain.com" );
		if ($pos > 0)
		{
			return;
		}

:frowning: