version() public method

Check the version of the given property in the User-Agent.
public version ( $propertyName, $type = self::VERSION_TYPE_STRING )
Esempio n. 1
0
 public static function cc($request, $user, $action)
 {
     $agent = new Agent();
     $platform = $agent->platform();
     $platform_v = $agent->version($platform);
     $browser = $agent->browser();
     $browser_v = $agent->version($browser);
     $device = $agent->device();
     switch ($action) {
         case 'login':
             $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '进行登录操作';
             break;
         case 'logout':
             $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '进行登出操作';
             break;
         case 'signup':
             $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '注册本网站';
             break;
         case 'user:confirm':
             $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '进行用户验证';
             break;
         case 'user:password_update':
             $mylog_content = date('Y-m-d H:i:s') . ' 修改了账号密码';
             break;
         default:
             $mylog_content = '';
             break;
     }
     return self::create(['mylog_cuid' => $user->user_id, 'mylog_action' => $action, 'mylog_content' => $mylog_content, 'mylog_ip' => ip2long($request->ip()), 'mylog_device' => $device, 'mylog_system' => $platform, 'mylog_system_v' => $platform_v, 'mylog_browser' => $browser, 'mylog_browser_v' => $browser_v]);
 }
Esempio n. 2
0
 public static function cc($request, $action, $option = [])
 {
     $agent = new Agent();
     $platform = $agent->platform();
     $platform_v = $agent->version($platform);
     $browser = $agent->browser();
     $browser_v = $agent->version($browser);
     $device = $agent->device();
     $charge_fee = 0;
     $charge_diamond = 0;
     $charge_datas = '';
     $charge_explanation = '';
     switch ($action) {
         case 'charge':
             $charge_fee = $option['fee'];
             $charge_diamond = $charge_fee * 1;
             $charge_explanation = '您于' . date('Y-m-d H:i:s') . '充值了 ¥' . $charge_fee . ' 获得了 ' . $charge_diamond . '颗勤云石';
             break;
         case 'consume:vip':
             $charge_diamond = -60;
             $charge_datas = $option['datas'];
             $charge_explanation = '您于' . date('Y-m-d H:i:s') . '消费了 ' . $charge_diamond . '颗勤云石,购买了VIP会员' . $charge_datas . '个月';
             break;
         case 'bequeath:signup':
             $charge_diamond = 18;
             $charge_explanation = '感谢您与' . date('Y-m-d H:i:s') . '注册本网站,系统自动赠送您' . $charge_diamond . '颗宝石';
             break;
         case 'bequeath:invited':
             $charge_diamond = 18;
             $charge_explanation = '感谢您分享了本网站的注册链接给好友,好友已经注册本网站,系统自动赠送您' . $charge_diamond . '颗宝石';
             break;
     }
     return self::create(['charge_cuid' => isset($option['userCreated']) ? $option['userCreated']->user_id : 0, 'charge_ruid' => $option['userRelated']->user_id, 'charge_action' => $action, 'charge_datas' => $charge_datas, 'charge_diamond' => $charge_diamond, 'charge_fee' => $charge_fee, 'charge_explanation' => $charge_explanation, 'charge_ip' => ip2long($request->ip()), 'charge_device' => $device, 'charge_system' => $platform, 'charge_system_v' => $platform_v, 'charge_browser' => $browser, 'charge_browser_v' => $browser_v]);
 }
Esempio n. 3
0
 /**
  * @medium
  * @dataProvider userAgentData
  */
 public function testUserAgents($userAgent, $isMobile, $isTablet, $version, $model, $vendor)
 {
     //make sure we're passed valid data
     if (!is_string($userAgent) || !is_bool($isMobile) || !is_bool($isTablet)) {
         $this->markTestIncomplete("The User-Agent {$userAgent} does not have sufficient information for testing.");
         return;
     }
     //setup
     $md = new Agent();
     $md->setUserAgent($userAgent);
     //is mobile?
     $this->assertEquals($md->isMobile(), $isMobile);
     //is tablet?
     $this->assertEquals($md->isTablet(), $isTablet);
     if (isset($version)) {
         foreach ($version as $condition => $assertion) {
             $this->assertEquals($assertion, $md->version($condition), 'FAILED UA (version("' . $condition . '")): ' . $userAgent);
         }
     }
     //version property tests
     if (isset($version)) {
         foreach ($version as $property => $stringVersion) {
             $v = $md->version($property);
             $this->assertSame($stringVersion, $v);
         }
     }
     //@todo: model test, not sure how exactly yet
     //@todo: vendor test. The below is theoretical, but fails 50% of the tests...
     /*if (isset($vendor)) {
           $method = "is$vendor";
           $this->assertTrue($md->{$method}(), "Expected Mobile_Detect::{$method}() to be true.");
       }*/
 }
Esempio n. 4
0
 /**
  * @param string $property
  * @return string|false
  */
 public function getVersion($property)
 {
     $property = (string) $property;
     $cache = CM_Cache_Local::getInstance();
     return $cache->get($cache->key(__METHOD__, $this->_headerList, $property), function () use($property) {
         return $this->_parser->version($property);
     });
 }
Esempio n. 5
0
 public function testVersions()
 {
     $agent = new Agent();
     foreach ($this->browserVersions as $version => $ua) {
         $agent->setUserAgent($ua);
         $browser = $agent->browser();
         $this->assertEquals($version, $agent->version($browser));
     }
     foreach ($this->operatingSystemVersions as $version => $ua) {
         $agent->setUserAgent($ua);
         $platform = $agent->platform();
         $this->assertEquals($version, $agent->version($platform));
     }
 }
Esempio n. 6
0
 public function postFSave(FSavePRequest $request, $user_email, $form_url)
 {
     $user = User::where('user_email', base64_decode($user_email))->where('user_active', '1')->firstOrFail();
     $form = $user->Form()->where('form_url', $form_url)->where('form_active', 1)->firstOrFail();
     if (!$form->canWrite()) {
         return redirect()->back()->with('msgError', '表单已经超过填写人数的最大限制了');
     }
     $agent = new Agent();
     $platform = $agent->platform();
     $platform_v = $agent->version($platform);
     $browser = $agent->browser();
     $browser_v = $agent->version($browser);
     $device = $agent->device();
     $result = Result::create(['result_ruid' => Auth::check() ? Auth::id() : 0, 'result_form_id' => $form->form_id, 'result_ip' => ip2long($request->ip()), 'result_device' => $device, 'result_system' => $platform, 'result_system_v' => $platform_v, 'result_browser' => $browser, 'result_browser_v' => $browser_v]);
     if ($result) {
         //插入数据
         $fields = $form->Field()->orderBy('field_sort', 'ASC')->get();
         $splitStr = ':$split$:';
         $user_id = Auth::check() ? Auth::id() : 0;
         foreach ($fields as $field) {
             $inputs = $request->input($field->field_attr_name);
             if (is_array($inputs)) {
                 if ($field->field_type == 'group:shop-thumbnail') {
                     $rows = [];
                     foreach ($inputs as $input) {
                         $rows[] = $input['goods_name'] . '(' . $input['goods_preice'] . '):' . $input['goods_num'];
                     }
                     $resultrow_attr_value = implode($splitStr, $rows);
                 } else {
                     $resultrow_attr_value = implode($splitStr, $inputs);
                 }
             } else {
                 $resultrow_attr_value = $inputs;
             }
             ResultRow::create(['resultrow_ruid' => $user_id, 'resultrow_result_id' => $result->result_id, 'resultrow_sort' => $field->field_sort, 'resultrow_type' => $field->field_type, 'resultrow_title' => $field->field_title, 'resultrow_tips' => $field->field_tips, 'resultrow_attr_name' => $field->field_attr_name, 'resultrow_attr_value' => $resultrow_attr_value]);
         }
         // 发送邮件提示
         if ($form->form_tips_email) {
             $email = Email::create(['email_cuid' => 0, 'email_ruid' => $user->user_id, 'email_block' => 'form_reply_tips', 'email_target' => $user->user_email, 'email_title' => '[ ' . WEBSITE_NAME . ' ]提示您:您的表单有了新的回复', 'email_datas' => $form->form_code, 'email_is_sent' => 0]);
             $this->dispatch(new SendReminderEmail($email));
         }
         $res = redirect('/u/' . $user_email . '/f-success')->with('msgSuccess', '您的表单已经成功提交,感谢您的参与。');
     } else {
         $res = redirect()->back()->with('msgError', MSG_FA);
     }
     return $res;
 }
Esempio n. 7
0
 public function store($inputs)
 {
     $contact = new $this->model();
     $contact->name = $inputs['name'];
     $contact->email = $inputs['email'];
     $contact->text = $inputs['message'];
     $contact->ip = \Request::ip();
     $agent = new Agent();
     $lang = $agent->languages();
     $lang = implode(",", $lang);
     $platform = $agent->platform();
     $version_p = $agent->version($platform);
     $device = $agent->device();
     $browser = $agent->browser();
     $version_b = $agent->version($browser);
     $contact->agent = $platform . $version_p . "|" . $device . "|" . $browser . $version_b . "|" . $lang;
     $contact->save();
 }
Esempio n. 8
0
 public function getUA()
 {
     // Initialize UA
     $agent = new Agent();
     $browser = $agent->browser();
     // Assemble data
     $data = ['browser' => $browser, 'browser_version' => $agent->version($browser), 'languages' => array($agent->languages()), 'device' => $agent->device(), 'platform' => $agent->platform(), 'is_mobile' => $agent->isMobile(), 'is_tablet' => $agent->isTablet(), 'is_desktop' => $agent->isDesktop(), 'is_robot' => $agent->isRobot(), 'robot_name' => $agent->robot()];
     return $data;
 }
Esempio n. 9
0
 public function insertUserInformation($ipAddress, $userAgentString, $sapiName, GeocoderResult $geocoderResult = null)
 {
     $userAgent = new UserAgent();
     $userAgent->setUserAgent($userAgentString);
     $browser = $userAgent->browser();
     $platform = $userAgent->platform();
     $data = ['ip_address' => $ipAddress, 'sapi_name' => substr($sapiName, 0, 32), 'user_agent' => substr($userAgentString, 0, 255), 'user_agent_browser' => substr($browser, 0, 32), 'user_agent_device' => substr($userAgent->device(), 0, 32), 'user_agent_browser_version' => substr($userAgent->version($browser), 0, 32), 'user_agent_platform_version' => substr($userAgent->version($platform), 0, 32), 'user_agent_platform' => substr($platform, 0, 32), 'user_agent_robot' => substr($userAgent->robot(), 0, 32)];
     if ($geocoderResult) {
         $region = $geocoderResult->getAdminLevels()->first();
         $data['geo_city'] = substr($geocoderResult->getLocality(), 0, 32);
         $data['geo_region'] = $region ? substr($region->getCode(), 0, 32) : null;
         $data['geo_country'] = substr($geocoderResult->getCountry(), 0, 32);
         $data['geo_country_code'] = substr($geocoderResult->getCountryCode(), 0, 6);
         $data['geo_latitude'] = substr($geocoderResult->getLatitude(), 0, 32);
         $data['geo_longitude'] = substr($geocoderResult->getLongitude(), 0, 32);
     }
     $this->getAdapter()->insert('dewdrop_activity_log_user_information', $data);
     return $this->getAdapter()->lastInsertId();
 }
Esempio n. 10
0
 public static function saveSession()
 {
     $session_id = uniqid();
     Session::put('session_id', $session_id);
     $agent = new Agent();
     $browser = $agent->browser();
     $version = $agent->version($browser);
     $platform = $agent->platform();
     $versionpla = $agent->version($platform);
     $device = $agent->device();
     $session = new SaveSession();
     $session->browser = $browser;
     $session->version = $version;
     $session->platform = $browser;
     $session->versionpla = $versionpla;
     $session->device = $device;
     //$session->ip 		 = $request->ip;
     $session->cookie = $session_id;
     $session->save();
 }
Esempio n. 11
0
 private function getBrowser()
 {
     $agent = new Agent();
     $browser = $agent->browser();
     $platform = $agent->platform();
     $data = array('name' => $browser, 'version' => $agent->version($browser), 'platform' => $platform, 'platformVersion' => $agent->version($platform), 'device' => $agent->device());
     return $data;
 }
 private function getBodyClass()
 {
     $agent = new Agent();
     $browser_css_classes = array();
     $unsupported = [];
     if ($mobile = $agent->isMobile()) {
         $browser_css_classes[] = 'device-mobile';
     }
     if ($tablet = $agent->isTablet()) {
         $browser_css_classes[] = 'device-tablet';
     }
     if ($iphone = $agent->is('iPhone')) {
         $browser_css_classes[] = 'device-iphone';
     }
     if ($ipad = $agent->is('iPad')) {
         $browser_css_classes[] = 'device-ipad';
     }
     $other_browser = $agent->browser();
     if ($agent->browser() == "Safari") {
         $other_browser = false;
         $browser_css_classes[] = 'browser-safari';
         if ($agent->version('Safari') < 5) {
             $unsupported['browser'] = 'Safari';
         }
     }
     if ($agent->browser() == "Chrome") {
         $other_browser = false;
         $browser_css_classes[] = 'browser-chrome';
         $browser_css_classes[] = 'browser-chrome-' . (int) $agent->version('Chrome');
         if ($agent->version('Chrome') < 30) {
             $unsupported['browser'] = 'Chrome';
         }
     }
     if ($agent->browser() == "Firefox") {
         $other_browser = false;
         $browser_css_classes[] = 'browser-firefox';
         $browser_css_classes[] = 'browser-firefox-' . (int) $agent->version('Firefox');
         if ($agent->version('Firefox') < 25) {
             $unsupported['browser'] = 'Firefox';
         }
     }
     if ($browser = $agent->browser() == "IE") {
         $version = $agent->version("IE");
         $version = str_replace('.0', '', $version);
         $other_browser = false;
         $browser_css_classes[] = 'browser-ie';
         $browser_css_classes[] = 'browser-ie-' . (int) $version;
         if ((int) $version < 10) {
             $browser_css_classes[] = 'browser-lt-ie10';
         }
         if ((int) $version < 9) {
             $unsupported['browser'] = 'Internet Explorer';
         }
         $browser_css_classes[] = 'browser-ie' . $version;
     }
     if ($other_browser) {
         $browser_css_classes[] = 'browser-' . strtolower($other_browser);
         $version = (int) $agent->version($other_browser);
         $browser_css_classes[] = 'browser-' . strtolower($other_browser) . '-' . $version;
     }
     if ($agent->is('Windows')) {
         $browser_css_classes[] = 'os-windows';
     }
     if ($agent->is('OS X')) {
         $browser_css_classes[] = 'os-mac';
     }
     if ($agent->isDesktop()) {
         $browser_css_classes[] = 'desktop';
     } else {
         //Don't display errors on non-desktop devices
         $unsupported = [];
     }
     $browser_css_classes = implode(' ', $browser_css_classes);
     return $browser_css_classes;
 }
 /**
  * @dataProvider versionDataProvider
  * @covers Agent::version
  */
 public function testVersionExtraction($userAgent, $property, $stringVersion, $floatVersion)
 {
     $md = new Agent(array('HTTP_USER_AGENT' => $userAgent));
     $prop = $md->version($property);
     $this->assertSame($stringVersion, $prop);
     $prop = $md->version($property, 'float');
     $this->assertSame($floatVersion, $prop);
     //assert that garbage data is always === false
     $prop = $md->version('garbage input is always garbage');
     $this->assertFalse($prop);
 }
Esempio n. 14
0
 public static function parse($userAgentString)
 {
     $browser = new UserAgentLib();
     $browser->setUserAgent($userAgentString);
     return array('os' => $browser->platform(), 'name' => $browser->browser(), 'version' => $browser->version($browser->browser()));
 }
Esempio n. 15
0
 /**
  * Check the version of the given property in the User-Agent.
  *
  * @inherit 
  * @static 
  */
 public static function version($propertyName, $type = 'text')
 {
     return \Jenssegers\Agent\Agent::version($propertyName, $type);
 }
Esempio n. 16
0
File: Base.php Progetto: joaogl/base
 public function RegisterVisit()
 {
     $agent = new Agent();
     $browser = $agent->browser();
     $version = $agent->version($browser);
     $platform = $agent->platform();
     $pversion = $agent->version($platform);
     $browserString = $browser . ' version ' . $version . ' | ' . $platform . ' version ' . $pversion;
     $visit = $this->getVisitsRepository()->create(['url' => Request::url(), 'ip' => Request::ip(), 'browser' => $browserString]);
 }
 /**
  * Set the user agent field
  *
  * @param string $value
  * @return string
  */
 public function setUserAgentAttribute($value)
 {
     $agent = new Agent();
     $agent->setUserAgent($value);
     $this->browser = $agent->browser();
     $this->browser_version = $agent->version($this->browser);
     $this->platform = $agent->platform();
     $this->platform_version = $agent->version($this->platform);
     $this->device = $agent->device() && !$agent->isDesktop() ? $agent->device() : '';
     $this->device_type = $agent->isMobile() ? 'mobile' : ($agent->isTablet() ? 'tablet' : ($agent->isDesktop() ? 'desktop' : ''));
     $this->attributes['user_agent'] = $value;
 }