setUserAgent() public method

Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
public setUserAgent ( string $agent_string )
$agent_string string The value for the User Agent
Example #1
0
 /**
  * Определение браузера
  * @return string браузер и версия браузера
  */
 public static function getUserAgent($userAgent = null)
 {
     $browser = new Browser();
     if ($userAgent) {
         $browser->setUserAgent($userAgent);
     }
     $brow = $browser->getBrowser();
     $version = implode('.', array_slice(explode('.', $browser->getVersion()), 0, 2));
     return $version == 'unknown' ? $brow : $brow . ' ' . $version;
 }
Example #2
0
             // check if IP exists
             if (empty($r['ip'])) {
                 continue;
             }
             break;
         default:
             break;
     }
     $displayDate = $GROUPED;
     $browsingTime = $GROUPED;
     $interactionTime = $GROUPED;
     $numClicks = $GROUPED;
     $numNotes = $GROUPED;
 } else {
     $browser = new Browser();
     $browser->setUserAgent($r['user_agent']);
     // display a start on first time visitors
     $ftu = $r['ftu'] ? ' class="ftu"' : null;
     $abbrDate = date('Y/m/d', strtotime($r['sess_date']));
     // use pretty date?
     $displayDate = $usePrettyDate ? '<abbr title="' . prettyDate::getStringResolved($r['sess_date']) . '">' . $abbrDate . '</abbr>' : $abbrDate;
     $browsingTime = $r['sess_time'];
     //$locationId = mask_client(md5($r['ip']));
     $lang = $browser->getLanguage();
     if ($lang != $browser::LANGUAGE_UNKNOWN) {
         $locationId = '<img src="styles/blank.gif" class="flag flag-' . $lang . '" alt="' . $lang . '" title="' . $lang . '" />';
     } else {
         $locationId = "?";
     }
     $displayId = 'id=' . $r['id'];
     $pageId = $r['cache_id'];
Example #3
0
 public function agentStatistics()
 {
     $result = array();
     $model = Statistics::model()->findAll();
     foreach ($model as $data) {
         $agent = $data->terminal;
         $browser = new Browser();
         $browser->setUserAgent($agent);
         $browserinfo = str_replace(array(' ', '.'), array('_', '-'), $browser->getBrowser());
         $version = str_replace(array(' ', '.'), array('_', '-'), $browser->getVersion());
         $platform = str_replace(array(' ', '.'), array('_', '-'), $browser->getPlatform());
         //			$aolversion = str_replace(array(' ','.'), array('_','-'),$browser->getAolVersion());
         $result['Agent'][$browserinfo][$version] += 1;
         $result['Platform'][$platform] += 1;
     }
     return $result;
 }
Example #4
0
 public static function detectPlatform($userAgent)
 {
     Yii::import('app.addons.Browser');
     $platform = new Browser();
     $platform->setUserAgent($userAgent);
     return $platform->getPlatform();
 }