/** * Inicia a análise de tráfego. */ private function iniciarAnaliseTrafego() { if ($this->_configuracao->get($this->_servidor . '.piwik_id')) { require_once implode(DIRECTORY_SEPARATOR, [__DIR__, '..', '..', '..', '..', 'library', 'PiwikTracker.php']); $piwikTracker = new \PiwikTracker($this->_configuracao->get($this->_servidor . '.piwik_id'), $this->_configuracao->get($this->_servidor . '.piwik_url')); if ($this->_configuracao->get($this->_servidor . '.piwik_token_auth')) { $piwikTracker->setTokenAuth($this->_configuracao->get($this->_servidor . '.piwik_token_auth')); } if (isset($_SERVER['HTTP_REFERER'])) { $piwikTracker->setReferrer($_SERVER['HTTP_REFERER']); } // detecta o endereço da internet do cliente if (isset($_SERVER['HTTP_CLIENT_IP'])) { $piwikTracker->setIp($_SERVER['HTTP_CLIENT_IP']); } else { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $piwikTracker->setIp($_SERVER['HTTP_X_FORWARDED_FOR']); } else { if (isset($_SERVER['HTTP_X_FORWARDED'])) { $piwikTracker->setIp($_SERVER['HTTP_X_FORWARDED']); } else { if (isset($_SERVER['HTTP_FORWARDED_FOR'])) { $piwikTracker->setIp($_SERVER['HTTP_FORWARDED_FOR']); } else { if (isset($_SERVER['HTTP_FORWARDED'])) { $piwikTracker->setIp($_SERVER['HTTP_FORWARDED']); } else { if (isset($_SERVER['REMOTE_ADDR'])) { $piwikTracker->setIp($_SERVER['REMOTE_ADDR']); } else { $piwikTracker->setIp('DESCONHECIDO'); } } } } } } $piwikTracker->setUserAgent($_SERVER['HTTP_USER_AGENT']); if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $idioma = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $piwikTracker->setBrowserLanguage($idioma[0]); unset($idioma); } if ($this->postExists('localTime')) { $piwikTracker->setLocalTime($this->post('localTime')); } if ($this->postExists('screenWidth') && $this->postExists('screenHeight')) { $piwikTracker->setResolution($this->post('screenWidth'), $this->post('screenHeight')); } if ($this->postExists('position')) { $posicao = $this->post('position'); $piwikTracker->setLongitude($posicao['longitude']); $piwikTracker->setLatitude($posicao['latitude']); unset($posicao); } } else { $piwikTracker = null; } return $piwikTracker; }