/** * @return string Two letters language code, eg. "fr" */ public static function getLanguageCodeForCurrentUser() { $languageCode = self::getLanguageFromPreferences(); if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) { $languageCode = Piwik_Common::extractLanguageCodeFromBrowserLanguage(Piwik_Common::getBrowserLanguage(), Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages()); } if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) { $languageCode = 'en'; } return $languageCode; }
function recordGoals($visitorInformation, $action) { $location_country = isset($visitorInformation['location_country']) ? $visitorInformation['location_country'] : Piwik_Common::getCountry(Piwik_Common::getBrowserLanguage(), $enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess']); $location_continent = isset($visitorInformation['location_continent']) ? $visitorInformation['location_continent'] : Piwik_Common::getContinent($location_country); $goal = array('idvisit' => $visitorInformation['idvisit'], 'idsite' => $visitorInformation['idsite'], 'visitor_idcookie' => $visitorInformation['visitor_idcookie'], 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']), 'visit_server_date' => $visitorInformation['visit_server_date'], 'location_country' => $location_country, 'location_continent' => $location_continent, 'visitor_returning' => $this->cookie->get(Piwik_Tracker::COOKIE_INDEX_VISITOR_RETURNING)); $referer_idvisit = $this->cookie->get(Piwik_Tracker::COOKIE_INDEX_REFERER_ID_VISIT); if ($referer_idvisit !== false) { $goal += array('referer_idvisit' => $referer_idvisit, 'referer_visit_server_date' => date("Y-m-d", $this->cookie->get(Piwik_Tracker::COOKIE_INDEX_REFERER_TIMESTAMP)), 'referer_type' => htmlspecialchars_decode($this->cookie->get(Piwik_Tracker::COOKIE_INDEX_REFERER_TYPE)), 'referer_name' => htmlspecialchars_decode($this->cookie->get(Piwik_Tracker::COOKIE_INDEX_REFERER_NAME)), 'referer_keyword' => htmlspecialchars_decode($this->cookie->get(Piwik_Tracker::COOKIE_INDEX_REFERER_KEYWORD))); } foreach ($this->convertedGoals as $convertedGoal) { printDebug("- Goal " . $convertedGoal['idgoal'] . " matched. Recording..."); $newGoal = $goal; $newGoal['idgoal'] = $convertedGoal['idgoal']; $newGoal['url'] = $convertedGoal['url']; $newGoal['revenue'] = $convertedGoal['revenue']; if (!is_null($action)) { $newGoal['idaction'] = $action->getIdAction(); $newGoal['idlink_va'] = $action->getIdLinkVisitAction(); } printDebug($newGoal); $fields = implode(", ", array_keys($newGoal)); $bindFields = substr(str_repeat("?,", count($newGoal)), 0, -1); try { Piwik_Tracker::getDatabase()->query("INSERT INTO " . Piwik_Common::prefixTable('log_conversion') . "\t({$fields}) \n\t\t\t\t\tVALUES ({$bindFields}) ", array_values($newGoal)); } catch (Exception $e) { if (strpos($e->getMessage(), '1062') !== false) { // integrity violation when same visit converts to the same goal twice printDebug("--> Goal already recorded for this (idvisit, idgoal)"); } else { throw $e; } } //$idlog_goal = Piwik_Tracker::getDatabase()->lastInsertId(); } }
/** * Data driven tests of getBrowserLanguage */ public function test_getBrowserLanguage() { $a1 = array(array("en-gb", "en-gb"), array("en-us,en;q=0.5", "en-us,en"), array("en-us,chrome://global/locale/intl.properties", "en-us"), array("en,en-securid", "en"), array("en-securid,en", "en"), array("en-us,en-securid,en", "en-us,en"), array("en-us,x-en-securid", "en-us,x-en-securid"), array("en-us,en-x-securid", "en-us,en-x-securid"), array("en-us, en", "en-us,en"), array("en-ca, en-us ,en", "en-ca,en-us,en"), array(" ( comment ) en-us (another comment) ", "en-us"), array(" ( \\( start ) en-us ( \\) end ) ", "en-us"), array(" ( \\) en-ca, \\( ) en-us ( \\) ,en ) ", "en-us")); foreach ($a1 as $testdata) { $res = Piwik_Common::getBrowserLanguage($testdata[0]); $this->assertEqual($testdata[1], $res); } }
/** * Gets the UserSettings information and returns them in an array of name => value * * @return array */ protected function getUserSettingsInformation() { // we already called this method before, simply returns the result if (is_array($this->userSettingsInformation)) { return $this->userSettingsInformation; } require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php'; $plugin_Flash = Piwik_Common::getRequestVar('fla', 0, 'int', $this->request); $plugin_Java = Piwik_Common::getRequestVar('java', 0, 'int', $this->request); $plugin_Director = Piwik_Common::getRequestVar('dir', 0, 'int', $this->request); $plugin_Quicktime = Piwik_Common::getRequestVar('qt', 0, 'int', $this->request); $plugin_RealPlayer = Piwik_Common::getRequestVar('realp', 0, 'int', $this->request); $plugin_PDF = Piwik_Common::getRequestVar('pdf', 0, 'int', $this->request); $plugin_WindowsMedia = Piwik_Common::getRequestVar('wma', 0, 'int', $this->request); $plugin_Gears = Piwik_Common::getRequestVar('gears', 0, 'int', $this->request); $plugin_Silverlight = Piwik_Common::getRequestVar('ag', 0, 'int', $this->request); $plugin_Cookie = Piwik_Common::getRequestVar('cookie', 0, 'int', $this->request); $userAgent = Piwik_Common::sanitizeInputValues(@$_SERVER['HTTP_USER_AGENT']); $aBrowserInfo = UserAgentParser::getBrowser($userAgent); $browserName = $aBrowserInfo !== false && $aBrowserInfo['id'] !== false ? $aBrowserInfo['id'] : 'UNK'; $browserVersion = $aBrowserInfo !== false && $aBrowserInfo['version'] !== false ? $aBrowserInfo['version'] : ''; $os = UserAgentParser::getOperatingSystem($userAgent); $os = $os === false ? 'UNK' : $os['id']; $resolution = Piwik_Common::getRequestVar('res', 'unknown', 'string', $this->request); $ip = Piwik_Common::getIp(); $browserLang = Piwik_Common::getBrowserLanguage(); $configurationHash = $this->getConfigHash($os, $browserName, $browserVersion, $resolution, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang); $this->userSettingsInformation = array('config_md5config' => $configurationHash, 'config_os' => $os, 'config_browser_name' => $browserName, 'config_browser_version' => $browserVersion, 'config_resolution' => $resolution, 'config_pdf' => $plugin_PDF, 'config_flash' => $plugin_Flash, 'config_java' => $plugin_Java, 'config_director' => $plugin_Director, 'config_quicktime' => $plugin_Quicktime, 'config_realplayer' => $plugin_RealPlayer, 'config_windowsmedia' => $plugin_WindowsMedia, 'config_gears' => $plugin_Gears, 'config_silverlight' => $plugin_Silverlight, 'config_cookie' => $plugin_Cookie, 'location_ip' => $ip, 'location_browser_lang' => $browserLang); return $this->userSettingsInformation; }
/** * Echo's a pretty formatted location using a specific LocationProvider. * * Input: * The 'id' query parameter must be set to the ID of the LocationProvider to use. * * Output: * The pretty formatted location that was obtained. Will be HTML. */ public function getLocationUsingProvider() { $providerId = Piwik_Common::getRequestVar('id'); $provider = $provider = Piwik_UserCountry_LocationProvider::getProviderById($providerId); if ($provider === false) { throw new Exception("Invalid provider ID: '{$providerId}'."); } $location = $provider->getLocation(array('ip' => Piwik_IP::getIpFromHeader(), 'lang' => Piwik_Common::getBrowserLanguage(), 'disable_fallbacks' => true)); $location = Piwik_UserCountry_LocationProvider::prettyFormatLocation($location, $newline = '<br/>', $includeExtra = true); echo $location; }
/** * Gets the UserSettings information and returns them in an array of name => value * * @return array */ protected function getUserSettingsInformation() { // we already called this method before, simply returns the result if (is_array($this->userSettingsInformation)) { return $this->userSettingsInformation; } require_once "UserAgentParser/UserAgentParser.php"; $plugin_Flash = Piwik_Common::getRequestVar('fla', 0, 'int', $this->request); $plugin_Director = Piwik_Common::getRequestVar('dir', 0, 'int', $this->request); $plugin_RealPlayer = Piwik_Common::getRequestVar('realp', 0, 'int', $this->request); $plugin_Pdf = Piwik_Common::getRequestVar('pdf', 0, 'int', $this->request); $plugin_WindowsMedia = Piwik_Common::getRequestVar('wma', 0, 'int', $this->request); $plugin_Cookie = Piwik_Common::getRequestVar('cookie', 0, 'int', $this->request); $userAgent = Piwik_Common::sanitizeInputValues(@$_SERVER['HTTP_USER_AGENT']); $aBrowserInfo = UserAgentParser::getBrowser($userAgent); # the !==false does not match the NULL and we have NOT NULL in the colums, so change to !empty. $browserName = !empty($aBrowserInfo) && !empty($aBrowserInfo['id']) ? $aBrowserInfo['id'] : 'UNK'; $browserVersion = !empty($aBrowserInfo) && !empty($aBrowserInfo['version']) ? $aBrowserInfo['version'] : ''; $os = UserAgentParser::getOperatingSystem($userAgent); $os = $os === false ? 'UNK' : $os['id']; $resolution = Piwik_Common::getRequestVar('res', 'unknown', 'string', $this->request); $ip = Piwik_Common::getIp(); $browserLang = Piwik_Common::getBrowserLanguage(); $configurationHash = $this->getConfigHash($os, $browserName, $browserVersion, $resolution, $plugin_Flash, $plugin_Director, $plugin_RealPlayer, $plugin_Pdf, $plugin_WindowsMedia, $plugin_Cookie, $ip, $browserLang); $this->userSettingsInformation = array('config_md5config' => $configurationHash, 'config_os' => $os, 'config_browser_name' => $browserName, 'config_browser_version' => $browserVersion, 'config_resolution' => $resolution, 'config_pdf' => $plugin_Pdf, 'config_flash' => $plugin_Flash, 'config_director' => $plugin_Director, 'config_realplayer' => $plugin_RealPlayer, 'config_windowsmedia' => $plugin_WindowsMedia, 'config_cookie' => $plugin_Cookie, 'location_ip' => $ip, 'location_browser_lang' => $browserLang); return $this->userSettingsInformation; }
function recordGoals($idSite, $visitorInformation, $visitCustomVariables, $action, $referrerTimestamp, $referrerUrl, $referrerCampaignName, $referrerCampaignKeyword) { $location_country = isset($visitorInformation['location_country']) ? $visitorInformation['location_country'] : Piwik_Common::getCountry(Piwik_Common::getBrowserLanguage(), $enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess'], $visitorInformation['location_ip']); $location_continent = isset($visitorInformation['location_continent']) ? $visitorInformation['location_continent'] : Piwik_Common::getContinent($location_country); $goal = array('idvisit' => $visitorInformation['idvisit'], 'idsite' => $idSite, 'idvisitor' => $visitorInformation['idvisitor'], 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']), 'location_country' => $location_country, 'location_continent' => $location_continent, 'visitor_returning' => $visitorInformation['visitor_returning'], 'visitor_days_since_first' => $visitorInformation['visitor_days_since_first'], 'visitor_count_visits' => $visitorInformation['visitor_count_visits']); // Attributing the correct Referrer to this conversion. // Priority order is as follows: // 1) Campaign name/kwd parsed in the JS // 2) Referrer URL stored in the _ref cookie // 3) If no info from the cookie, attribute to the current visit referrer // 3) Default values: current referrer $type = $visitorInformation['referer_type']; $name = $visitorInformation['referer_name']; $keyword = $visitorInformation['referer_keyword']; $time = $visitorInformation['visit_first_action_time']; // 1) Campaigns from 1st party cookie if (!empty($referrerCampaignName)) { $type = Piwik_Common::REFERER_TYPE_CAMPAIGN; $name = $referrerCampaignName; $keyword = $referrerCampaignKeyword; $time = $referrerTimestamp; } elseif (!empty($referrerUrl)) { $referrer = new Piwik_Tracker_Visit_Referer(); $referrer = $referrer->getRefererInformation($referrerUrl, $currentUrl = '', $idSite); // if the parsed referer is interesting enough, ie. website or search engine if (in_array($referrer['referer_type'], array(Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, Piwik_Common::REFERER_TYPE_WEBSITE))) { $type = $referrer['referer_type']; $name = $referrer['referer_name']; $keyword = $referrer['referer_keyword']; $time = $referrerTimestamp; } } $goal += array('referer_type' => $type, 'referer_name' => $name, 'referer_keyword' => $keyword, 'referer_visit_server_date' => date("Y-m-d", $time)); $goal += $visitCustomVariables; foreach ($this->convertedGoals as $convertedGoal) { printDebug("- Goal " . $convertedGoal['idgoal'] . " matched. Recording..."); $newGoal = $goal; $newGoal['idgoal'] = $convertedGoal['idgoal']; $newGoal['url'] = $convertedGoal['url']; $newGoal['revenue'] = $convertedGoal['revenue']; if (!is_null($action)) { $newGoal['idaction_url'] = $action->getIdActionUrl(); $newGoal['idlink_va'] = $action->getIdLinkVisitAction(); } // If multiple Goal conversions per visit, set a cache buster $newGoal['buster'] = $convertedGoal['allow_multiple'] == 0 ? '0' : $visitorInformation['visit_last_action_time']; $newGoalDebug = $newGoal; $newGoalDebug['idvisitor'] = bin2hex($newGoalDebug['idvisitor']); printDebug($newGoalDebug); $fields = implode(", ", array_keys($newGoal)); $bindFields = substr(str_repeat("?,", count($newGoal)), 0, -1); $sql = "INSERT IGNORE INTO " . Piwik_Common::prefixTable('log_conversion') . "\t\n\t\t\t\t\t({$fields}) VALUES ({$bindFields}) "; $bind = array_values($newGoal); Piwik_Tracker::getDatabase()->query($sql, $bind); } }
/** * Records one or several goals matched in this request. */ public function recordGoals($idSite, $visitorInformation, $visitCustomVariables, $action, $referrerTimestamp, $referrerUrl, $referrerCampaignName, $referrerCampaignKeyword) { $location_country = isset($visitorInformation['location_country']) ? $visitorInformation['location_country'] : Piwik_Common::getCountry(Piwik_Common::getBrowserLanguage(), $enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess'], $visitorInformation['location_ip']); $location_continent = isset($visitorInformation['location_continent']) ? $visitorInformation['location_continent'] : Piwik_Common::getContinent($location_country); $goal = array('idvisit' => $visitorInformation['idvisit'], 'idsite' => $idSite, 'idvisitor' => $visitorInformation['idvisitor'], 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']), 'location_country' => $location_country, 'location_continent' => $location_continent, 'visitor_returning' => $visitorInformation['visitor_returning'], 'visitor_days_since_first' => $visitorInformation['visitor_days_since_first'], 'visitor_days_since_order' => $visitorInformation['visitor_days_since_order'], 'visitor_count_visits' => $visitorInformation['visitor_count_visits']); // Copy Custom Variables from Visit row to the Goal conversion for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { if (isset($visitorInformation['custom_var_k' . $i]) && strlen($visitorInformation['custom_var_k' . $i])) { $goal['custom_var_k' . $i] = $visitorInformation['custom_var_k' . $i]; } if (isset($visitorInformation['custom_var_v' . $i]) && strlen($visitorInformation['custom_var_v' . $i])) { $goal['custom_var_v' . $i] = $visitorInformation['custom_var_v' . $i]; } } // Otherwise, set the Custom Variables found in the cookie sent with this request $goal += $visitCustomVariables; // Attributing the correct Referrer to this conversion. // Priority order is as follows: // 0) In some cases, the campaign is not passed from the JS so we look it up from the current visit // 1) Campaign name/kwd parsed in the JS // 2) Referrer URL stored in the _ref cookie // 3) If no info from the cookie, attribute to the current visit referrer // 3) Default values: current referrer $type = $visitorInformation['referer_type']; $name = $visitorInformation['referer_name']; $keyword = $visitorInformation['referer_keyword']; $time = $visitorInformation['visit_first_action_time']; // 0) In some (unknown!?) cases the campaign is not found in the attribution cookie, but the URL ref was found. // In this case we look up if the current visit is credited to a campaign and will credit this campaign rather than the URL ref (since campaigns have higher priority) if (empty($refererCampaignName) && $type == Piwik_Common::REFERER_TYPE_CAMPAIGN && !empty($name)) { // Use default values per above } elseif (!empty($referrerCampaignName)) { $type = Piwik_Common::REFERER_TYPE_CAMPAIGN; $name = $referrerCampaignName; $keyword = $referrerCampaignKeyword; $time = $referrerTimestamp; } elseif (!empty($referrerUrl)) { $referrer = new Piwik_Tracker_Visit_Referer(); $referrer = $referrer->getRefererInformation($referrerUrl, $currentUrl = '', $idSite); // if the parsed referer is interesting enough, ie. website or search engine if (in_array($referrer['referer_type'], array(Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, Piwik_Common::REFERER_TYPE_WEBSITE))) { $type = $referrer['referer_type']; $name = $referrer['referer_name']; $keyword = $referrer['referer_keyword']; $time = $referrerTimestamp; } } $goal += array('referer_type' => $type, 'referer_name' => $name, 'referer_keyword' => $keyword, 'referer_visit_server_date' => date("Y-m-d", $time)); // some goals are converted, so must be ecommerce Order or Cart Update if ($this->requestIsEcommerce) { $this->recordEcommerceGoal($goal, $visitorInformation); } else { $this->recordStandardGoals($goal, $action, $visitorInformation); } }
/** * Returns the language the visitor is viewing. * * @return string browser language code, eg. "en-gb,en;q=0.5" */ protected function getBrowserLanguage() { return Piwik_Common::getRequestVar('lang', Piwik_Common::getBrowserLanguage(), 'string', $this->request); }
/** * Returns an array mapping provider IDs w/ information about the provider, * for each location provider. * * The following information is provided for each provider: * 'id' - The provider's unique string ID. * 'title' - The provider's title. * 'description' - A description of how the location provider works. * 'status' - Either self::NOT_INSTALLED, self::INSTALLED or self::BROKEN. * 'statusMessage' - If the status is self::BROKEN, then the message describes why. * 'location' - A pretty formatted location of the current IP address * (Piwik_IP::getIpFromHeader()). * * An example result: * array( * 'geoip_php' => array('id' => 'geoip_php', * 'title' => '...', * 'desc' => '...', * 'status' => Piwik_UserCountry_LocationProvider_GeoIp::BROKEN, * 'statusMessage' => '...', * 'location' => '...') * 'geoip_serverbased' => array(...) * ) * * @param string $newline What to separate lines with in the pretty locations. * @param bool $includeExtra Whether to include ISP/Org info in formatted location. * @return array */ public static function getAllProviderInfo($newline = "\n", $includeExtra = false) { $allInfo = array(); foreach (self::getAllProviders() as $provider) { $info = $provider->getInfo(); $status = self::INSTALLED; $location = false; $statusMessage = false; $availableOrMessage = $provider->isAvailable(); if ($availableOrMessage !== true) { $status = self::NOT_INSTALLED; if (is_string($availableOrMessage)) { $statusMessage = $availableOrMessage; } } else { $workingOrError = $provider->isWorking(); if ($workingOrError === true) { $locInfo = array('ip' => Piwik_IP::getIpFromHeader(), 'lang' => Piwik_Common::getBrowserLanguage(), 'disable_fallbacks' => true); $location = $provider->getLocation($locInfo); $location = self::prettyFormatLocation($location, $newline, $includeExtra); } else { $status = self::BROKEN; $statusMessage = $workingOrError; } } $info['status'] = $status; $info['statusMessage'] = $statusMessage; $info['location'] = $location; $allInfo[$info['order']] = $info; } ksort($allInfo); $result = array(); foreach ($allInfo as $info) { $result[$info['id']] = $info; } return $result; }
/** * Records one or several goals matched in this request. */ public function recordGoals($idSite, $visitorInformation, $visitCustomVariables, $action, $referrerTimestamp, $referrerUrl, $referrerCampaignName, $referrerCampaignKeyword) { $location_country = isset($visitorInformation['location_country']) ? $visitorInformation['location_country'] : Piwik_Common::getCountry( Piwik_Common::getBrowserLanguage(), $enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess'], $visitorInformation['location_ip'] ); $location_continent = isset($visitorInformation['location_continent']) ? $visitorInformation['location_continent'] : Piwik_Common::getContinent($location_country); $goal = array( 'idvisit' => $visitorInformation['idvisit'], 'idsite' => $idSite, 'idvisitor' => $visitorInformation['idvisitor'], 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']), 'location_country' => $location_country, 'location_continent'=> $location_continent, 'visitor_returning' => $visitorInformation['visitor_returning'], 'visitor_days_since_first' => $visitorInformation['visitor_days_since_first'], 'visitor_days_since_order' => $visitorInformation['visitor_days_since_order'], 'visitor_count_visits' => $visitorInformation['visitor_count_visits'], ); // Attributing the correct Referrer to this conversion. // Priority order is as follows: // 1) Campaign name/kwd parsed in the JS // 2) Referrer URL stored in the _ref cookie // 3) If no info from the cookie, attribute to the current visit referrer // 3) Default values: current referrer $type = $visitorInformation['referer_type']; $name = $visitorInformation['referer_name']; $keyword = $visitorInformation['referer_keyword']; $time = $visitorInformation['visit_first_action_time']; // 1) Campaigns from 1st party cookie if(!empty($referrerCampaignName)) { $type = Piwik_Common::REFERER_TYPE_CAMPAIGN; $name = $referrerCampaignName; $keyword = $referrerCampaignKeyword; $time = $referrerTimestamp; } // 2) Referrer URL parsing elseif(!empty($referrerUrl)) { $referrer = new Piwik_Tracker_Visit_Referer(); $referrer = $referrer->getRefererInformation($referrerUrl, $currentUrl = '', $idSite); // if the parsed referer is interesting enough, ie. website or search engine if(in_array($referrer['referer_type'], array(Piwik_Common::REFERER_TYPE_SEARCH_ENGINE, Piwik_Common::REFERER_TYPE_WEBSITE))) { $type = $referrer['referer_type']; $name = $referrer['referer_name']; $keyword = $referrer['referer_keyword']; $time = $referrerTimestamp; } } $goal += array( 'referer_type' => $type, 'referer_name' => $name, 'referer_keyword' => $keyword, // this field is currently unused 'referer_visit_server_date' => date("Y-m-d", $time), ); $goal += $visitCustomVariables; // some goals are converted, so must be ecommerce Order or Cart Update if($this->requestIsEcommerce) { $this->recordEcommerceGoal($goal, $visitorInformation); } else { $this->recordStandardGoals($goal, $action, $visitorInformation); } }
/** * @dataProvider getBrowserLanguageData * @group Core * @group Common * @group getBrowserLanguage */ public function testGetBrowserLanguage($useragent, $browserLanguage) { $res = Piwik_Common::getBrowserLanguage($useragent); $this->assertEquals($browserLanguage, $res); }