getUserAgent() 공개 메소드

public getUserAgent ( )
 /**
  * Checks for DoNotTrack headers and if found, sets `$exclude` to `true`.
  */
 public function checkHeaderInTracker(&$exclude)
 {
     if ($exclude) {
         Common::printDebug("Visit is already excluded, no need to check DoNotTrack support.");
         return;
     }
     if (!$this->isActive()) {
         Common::printDebug("DoNotTrack support is not enabled, skip check");
         return;
     }
     if (isset($_SERVER['HTTP_X_DO_NOT_TRACK']) && $_SERVER['HTTP_X_DO_NOT_TRACK'] === '1' || isset($_SERVER['HTTP_DNT']) && substr($_SERVER['HTTP_DNT'], 0, 1) === '1') {
         $request = new Request($_REQUEST);
         $ua = $request->getUserAgent();
         if (strpos($ua, 'MSIE') !== false || strpos($ua, 'Trident') !== false) {
             Common::printDebug("INTERNET EXPLORER enable DoNotTrack by default; so Piwik ignores DNT IE browsers...");
             return;
         }
         Common::printDebug("DoNotTrack header found!");
         $exclude = true;
         $trackingCookie = IgnoreCookie::getTrackingCookie();
         $trackingCookie->delete();
         // this is an optional supplement to the site's tracking status resource at:
         //     /.well-known/dnt
         // per Tracking Preference Expression (draft)
         header('Tk: 1');
     } else {
         Common::printDebug("DoNotTrack header not found");
     }
 }
예제 #2
0
 /**
  * @param Request $request
  */
 public function __construct(Request $request)
 {
     $this->spamFilter = new ReferrerSpamFilter();
     $this->request = $request;
     $this->idSite = $request->getIdSite();
     $userAgent = $request->getUserAgent();
     $this->userAgent = Common::unsanitizeInputValue($userAgent);
     $this->ip = $request->getIp();
 }
예제 #3
0
파일: BrowserName.php 프로젝트: piwik/piwik
 /**
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed
  */
 public function onNewVisit(Request $request, Visitor $visitor, $action)
 {
     $userAgent = $request->getUserAgent();
     $parser = $this->getUAParser($userAgent);
     $aBrowserInfo = $parser->getClient();
     if (!empty($aBrowserInfo['short_name'])) {
         return $aBrowserInfo['short_name'];
     }
     return 'UNK';
 }
예제 #4
0
파일: Os.php 프로젝트: piwik/piwik
 /**
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed
  */
 public function onNewVisit(Request $request, Visitor $visitor, $action)
 {
     $userAgent = $request->getUserAgent();
     $parser = $this->getUAParser($userAgent);
     if ($parser->isBot()) {
         $os = Settings::OS_BOT;
     } else {
         $os = $parser->getOS();
         $os = empty($os['short_name']) ? 'UNK' : $os['short_name'];
     }
     return $os;
 }
예제 #5
0
 /**
  * @param Request $request
  * @param bool|string $ip
  * @param bool|string $userAgent
  */
 public function __construct(Request $request, $ip = false, $userAgent = false)
 {
     if ($ip === false) {
         $ip = $request->getIp();
     }
     if ($userAgent === false) {
         $userAgent = $request->getUserAgent();
     }
     $this->request = $request;
     $this->idSite = $request->getIdSite();
     $this->userAgent = $userAgent;
     $this->ip = $ip;
 }
예제 #6
0
 /**
  * @param Request $request
  * @param bool|string $ip
  * @param bool|string $userAgent
  */
 public function __construct(Request $request, $ip = false, $userAgent = false)
 {
     $this->spamFilter = new ReferrerSpamFilter();
     if (false === $ip) {
         $ip = $request->getIp();
     }
     if (false === $userAgent) {
         $userAgent = $request->getUserAgent();
     }
     $this->request = $request;
     $this->idSite = $request->getIdSite();
     $this->userAgent = $userAgent;
     $this->ip = $ip;
 }
예제 #7
0
 /**
  * @return bool
  */
 public function isDoNotTrackFound()
 {
     if (!$this->isActive()) {
         Common::printDebug("DoNotTrack support is not enabled, skip check");
         return false;
     }
     if (!$this->isHeaderDntFound()) {
         Common::printDebug("DoNotTrack header not found");
         return false;
     }
     $request = new Request($_REQUEST);
     $userAgent = $request->getUserAgent();
     if ($this->isUserAgentWithDoNotTrackAlwaysEnabled($userAgent)) {
         Common::printDebug("INTERNET EXPLORER enable DoNotTrack by default; so Piwik ignores DNT IE browsers...");
         return false;
     }
     Common::printDebug("DoNotTrack header found!");
     return true;
 }
예제 #8
0
 /**
  * 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';
     list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $this->request->getPlugins();
     $resolution = $this->request->getParam('res');
     $userAgent = $this->request->getUserAgent();
     $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'];
     $browserLang = substr($this->request->getBrowserLanguage(), 0, 20);
     // limit the length of this string to match db
     $configurationHash = $this->getConfigHash($os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $this->getVisitorIp(), $browserLang);
     $this->userSettingsInformation = array('config_id' => $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_browser_lang' => $browserLang);
     return $this->userSettingsInformation;
 }
예제 #9
0
 public function getConfigId(Request $request, $ipAddress)
 {
     list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $request->getPlugins();
     $userAgent = $request->getUserAgent();
     $deviceDetector = DeviceDetectorFactory::getInstance($userAgent);
     $aBrowserInfo = $deviceDetector->getClient();
     if ($aBrowserInfo['type'] != 'browser') {
         // for now only track browsers
         unset($aBrowserInfo);
     }
     $browserName = !empty($aBrowserInfo['short_name']) ? $aBrowserInfo['short_name'] : 'UNK';
     $browserVersion = !empty($aBrowserInfo['version']) ? $aBrowserInfo['version'] : '';
     if ($deviceDetector->isBot()) {
         $os = self::OS_BOT;
     } else {
         $os = $deviceDetector->getOS();
         $os = empty($os['short_name']) ? 'UNK' : $os['short_name'];
     }
     $browserLang = substr($request->getBrowserLanguage(), 0, 20);
     // limit the length of this string to match db
     return $this->getConfigHash($request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ipAddress, $browserLang);
 }
 /**
  * Checks for DoNotTrack headers and if found, sets `$exclude` to `true`.
  */
 public function checkHeaderInTracker(&$exclude)
 {
     if (!$this->isActiveInTracker() || $exclude) {
         return;
     }
     if (isset($_SERVER['HTTP_X_DO_NOT_TRACK']) && $_SERVER['HTTP_X_DO_NOT_TRACK'] === '1' || isset($_SERVER['HTTP_DNT']) && substr($_SERVER['HTTP_DNT'], 0, 1) === '1') {
         $request = new Request($_REQUEST);
         $ua = $request->getUserAgent();
         if (strpos($ua, 'MSIE 10') !== false || strpos($ua, 'Trident/7') !== false) {
             Common::printDebug("INTERNET EXPLORER 10 and 11 enable DoNotTrack by default; so Piwik ignores DNT for all IE10 + IE11 browsers...");
             return;
         }
         $exclude = true;
         Common::printDebug("DoNotTrack found.");
         $trackingCookie = IgnoreCookie::getTrackingCookie();
         $trackingCookie->delete();
         // this is an optional supplement to the site's tracking status resource at:
         //     /.well-known/dnt
         // per Tracking Preference Expression (draft)
         header('Tk: 1');
     }
 }
예제 #11
0
파일: DeviceModel.php 프로젝트: piwik/piwik
 /**
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed
  */
 public function onNewVisit(Request $request, Visitor $visitor, $action)
 {
     $userAgent = $request->getUserAgent();
     $parser = $this->getUAParser($userAgent);
     return $parser->getModel();
 }
예제 #12
0
 public function parseMobileVisitData(&$visitorInfo, \Piwik\Tracker\Request $request)
 {
     $userAgent = $request->getUserAgent();
     $UAParser = new DeviceDetector($userAgent);
     $UAParser->setCache(new CacheFile('tracker', 86400));
     $UAParser->parse();
     $deviceInfo['config_browser_name'] = $UAParser->getBrowser("short_name");
     $deviceInfo['config_browser_version'] = $UAParser->getBrowser("version");
     $deviceInfo['config_os'] = $UAParser->getOs("short_name");
     $deviceInfo['config_os_version'] = $UAParser->getOs("version");
     $deviceInfo['config_device_type'] = $UAParser->getDevice();
     $deviceInfo['config_device_model'] = $UAParser->getModel();
     $deviceInfo['config_device_brand'] = $UAParser->getBrand();
     $visitorInfo = array_merge($visitorInfo, $deviceInfo);
     Common::printDebug("Device Detection:");
     Common::printDebug($deviceInfo);
 }
 public function parseMobileVisitData(&$visitorInfo, \Piwik\Tracker\Request $request)
 {
     $userAgent = $request->getUserAgent();
     $UAParser = new UserAgentParserEnhanced($userAgent);
     $UAParser->parse();
     $deviceInfo['config_browser_name'] = $UAParser->getBrowser("short_name");
     $deviceInfo['config_browser_version'] = $UAParser->getBrowser("version");
     $deviceInfo['config_os'] = $UAParser->getOs("short_name");
     $deviceInfo['config_os_version'] = $UAParser->getOs("version");
     $deviceInfo['config_device_type'] = $UAParser->getDevice();
     $deviceInfo['config_device_model'] = $UAParser->getModel();
     $deviceInfo['config_device_brand'] = $UAParser->getBrand();
     if (@Config::getInstance()->Debug['store_user_agent_in_visit']) {
         $deviceInfo['config_debug_ua'] = $userAgent;
     }
     $visitorInfo = array_merge($visitorInfo, $deviceInfo);
     Common::printDebug("Device Detection:");
     Common::printDebug($deviceInfo);
 }