deviceTypes = $view->deviceModels = $view->deviceBrands = $view->osReport = $view->browserReport = "blank"; $view->deviceTypes = $this->getType(true); $view->deviceBrands = $this->getBrand(true); $view->deviceModels = $this->getModel(true); $view->osReport = $this->getOsFamilies(true); $view->browserReport = $this->getBrowserFamilies(true); return $view->render(); } public function getType() { return $this->renderReport(__FUNCTION__); } public function getBrand() { return $this->renderReport(__FUNCTION__); } public function getModel() { return $this->renderReport(__FUNCTION__); } public function getOsFamilies() { return $this->renderReport(__FUNCTION__); } public function getOsVersions() { return $this->renderReport(__FUNCTION__); } public function getBrowserFamilies() { return $this->renderReport(__FUNCTION__); } public function getBrowserVersions() { return $this->renderReport(__FUNCTION__); } /** * You may manually call this controller action to force re-processing of past user agents */ public function refreshParsedUserAgents() { Piwik::checkUserIsSuperUser(); $q = "SELECT idvisit, config_debug_ua FROM " . Common::prefixTable("log_visit"); $res = Db::fetchAll($q); $output = ''; foreach ($res as $rec) { $UAParser = new UserAgentParserEnhanced($rec['config_debug_ua']); $UAParser->parse(); $output .= "Processing idvisit = " . $rec['idvisit'] . "
"; $output .= "UserAgent string: " . $rec['config_debug_ua'] . "
Decoded values:"; $uaDetails = $this->getArray($UAParser); var_export($uaDetails); $output .= "
"; $this->updateVisit($rec['idvisit'], $uaDetails); unset($UAParser); } $output .= "Please remember to truncate your archives !"; return $output; } private function getArray(UserAgentParserEnhanced $UAParser) { $UADetails['config_browser_name'] = $UAParser->getBrowser("short_name"); $UADetails['config_browser_version'] = $UAParser->getBrowser("version"); $UADetails['config_os'] = $UAParser->getOs("short_name"); $UADetails['config_os_version'] = $UAParser->getOs("version"); $UADetails['config_device_type'] = $UAParser->getDevice(); $UADetails['config_device_model'] = $UAParser->getModel(); $UADetails['config_device_brand'] = $UAParser->getBrand(); return $UADetails; } private function updateVisit($idVisit, $uaDetails) { $q = "UPDATE " . Common::prefixTable("log_visit") . " SET " . "config_browser_name = '" . $uaDetails['config_browser_name'] . "' ," . "config_browser_version = '" . $uaDetails['config_browser_version'] . "' ," . "config_os = '" . $uaDetails['config_os'] . "' ," . "config_os_version = '" . $uaDetails['config_os_version'] . "' ," . "config_device_type = " . (isset($uaDetails['config_device_type']) ? "'" . $uaDetails['config_device_type'] . "'" : "NULL") . " ," . "config_device_model = " . (isset($uaDetails['config_device_model']) ? "'" . $uaDetails['config_device_model'] . "'" : "NULL") . " ," . "config_device_brand = " . (isset($uaDetails['config_device_brand']) ? "'" . $uaDetails['config_device_brand'] . "'" : "NULL") . " WHERE idvisit = " . $idVisit; Db::query($q); } }