Coder Social home page Coder Social logo

php-browser-detector's Introduction

Users

Build Status StyleCI Scrutinizer Code Quality Code Coverage Code Climate Latest Stable Version Total Downloads License SensioLabsInsight Join the chat at https://gitter.im/sinergi/users

Users provide cross-framework user and group management, authentication and 2-step authentication, password reset and email verification.

Table Of Content

  1. Requirements
  2. Installation
  3. License

Requirements

This library uses PHP 7+.

Installation

It is recommended that you install the Users library through composer. To do so, run the Composer command to install the latest stable version of Users library.

composer require sinergi/users

License

Users is licensed under The MIT License (MIT).

php-browser-detector's People

Contributors

adlenton avatar asdfklgash avatar blackbass1988 avatar cbulock avatar coreywynsma avatar gabrielbull avatar gitter-badger avatar igusev avatar janhohner avatar jonasschumacher avatar martin-song-ck avatar maxcoe avatar pavarnos avatar svenluijten avatar tigrazone avatar vinkla avatar yigit-serin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-browser-detector's Issues

Get rid of "Mozilla"

Since Mozilla/5.0 is used everywhere, many "unknown" browsers are simply being detected as Mozilla. There has never been a "mozilla browser", so this is false at any rate.

Based on this NetScape UA history: http://www.zytrax.com/tech/web/netscape-history.html, we can summise the following rules:

  • Anything with Mozilla/5.0 or higher, which does NOT also contain "Netscape", "Netscape6", "Navigator" or "NS8", is not NetScape.

  • Anything lower than Mozilla/5.0, which also contains the word "compatible" or "like", which does NOT also contain "Netscape", "Netscape6", "Navigator" or "NS8", is not Netscape.

  • Anything which contains the exact version "Mozilla/4.0" is not netscape.

  • Anything lower than Mozilla/5.0, except the exact version "Mozilla/4.0" or UAs containing the words "compatible" or "like", probably are genuinely NetScape

Browser\Browser::isMobile() doesn't work.

Hi,
I recently started using this library with Composer (https://packagist.org/packages/gavroche/browser) on my website. Here is what I tried:

if (Browser\Browser::isMobile() === "true") {
    header("Location: /mobile/");
    die();
}

This had no effect on redirecting mobile browsers to "/mobile" and did not cause any errors. Also, there was no output or errors when I tried this:

echo Browser\Browser::isMobile();

Am I doing something wrong or is this an issue? Thanks in advance for any help.

Note: I switched to this library from browscap (http://tempdownloads.browserscap.com/) which isn't updated very often. Should I switch back?

This cache store does not support tagging

We are getting issues as we use a cache driver that does not support a file or database cache driver.

BadMethodCallException · This cache store does not support tagging.
.....
$userActivity->uniqid = request()->token;
}
$location = geoip()->getLocation();
$browser = new \Sinergi\BrowserDetector\Browser();
$userActivity->updated_at = date('Y-m-d H:i:s');
.....

Perhaps a good idea to add a note to the README on this? We will look into Redis or Memcached.

$browser->getBrowser() does not work

Instead $browser->isBrowser(Browser\Browser::Firefox) should be used. I think the docs should be updated accordingly (maybe for other functions too). Great work by the way.

Chrome OS detected as OS X

Mozilla/5.0 (X11; CrOS x86_64 7520.62.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36

is detected as
Chrome 47 OS X
because OSDetector::checkOSX() is seeing the "OS x" of "CrOS x86_64"

(thanks for the useful package btw)

add_windows_version_8_1

Hey Gabriel,

I found there are some usage to detect windows version 8.1, which is mapped to 6.3 in the user-agent. Is it ok to add this into OsDetector? Thanks.

Best,
Martin

Get Os Name on Ubuntu return Unknown

I'm encountering an error with the Os class and getName function wich return unknown on my env

my setup env:

NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
php version : 8.0.3
composer: 2.1.11

Allow user agent injection in Device class

I assumed, but found out that the Device class doesn't support injection of an alternative user agent string, like the Os and Browser classes do. Could this be fixed?

Class 'Sinergi\BrowserDetector\Browser' not found

Hey,

This is just what iv been looking for, how ever im having an issue installing/running it as i get the error:

Class 'Sinergi\BrowserDetector\Browser' not found

I installed it via Compser whilst in the public_html folder via SSH. During the install the end part of the install outputted this:

symfony/polyfill-mbstring suggests installing ext-mbstring (For best performance)
symfony/console suggests installing symfony/process ()
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
guzzle/guzzle suggests installing guzzlehttp/guzzle (Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated.)
satooshi/php-coveralls suggests installing symfony/http-kernel (Allows Symfony integration)
sebastian/global-state suggests installing ext-uopz ()
phpunit/phpunit-mock-objects suggests installing ext-soap (
)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.1)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Writing lock file
Generating autoload files

As you can see it says somthing about guzzle, so has it been installed or not? Any help would be great please, i have root access to the server.

Thank you!

Opera detected as Chrome

Hello,

installed Opera 21 on Mac OS X. It is detected as Chrome.

User Agent String:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.132 Safari/537.36 OPR/21.0.1432.67

greets
Darius

Detecting IE in Compatibility Mode

Wondering if BrowserDetector::checkBrowserInternetExplorer() would benefit from a mechanism to detect IE's true version when in compatibility mode. I believe if the user agent string contains the combination of strings below, the true version at hand can determined. Of course, it's not a simple as just returning the actual version, as IE11 in compatibility mode renders pages more akin to 7, for instance, but some mechanism by which to determine both the actual version and compatibility mode would be quite useful. Thank you for all the hard work on what is really a very nice package!

MSIE 7.0 && Trident/7.0 is IE11 in compatibility mode
MSIE 7.0 && Trident/6.0 is IE10 in compatibility mode
MSIE 7.0 && Trident/5.0 is IE9 in compatibility mode
MSIE 7.0 && Trident/4.0 is IE8 in compatibility mode

Can't detect Windows Phone

Detects Windows Phone like chrome OS and in checkWindowsPhone missed $os->setIsMobile(true);
user-agent example: "Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; Microsoft; Lumia 640 LTE) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Mobile Safari/537.36 Edge/14.14393"

Unexpected usage of "USE" :-(

Hi guys

I installed using composer
require ($home_dir . "/browser_detect/vendor/autoload.php");
use Sinergi\BrowserDetector\Os;
I get an error on the 2nd line above: Parse error: syntax error, unexpected 'use' (T_USE)
$home_dir is well set and the autoload.php exists there (points to the autoload_real.php in the composer directory under "vendor"

What's wrong?

Thanks in advance

Should not throw Exception, when could not detect browser

I found problem that, if this script can't find some information about browser, it throw Exception. Instead, it should return information, that it found and false or null, if something not found, but not Exception. To test this, I used this chrome plugin: https://chrome.google.com/webstore/detail/random-hide-user-agent/einpaelgookohagofgnnkcfjbkkgepnp. Set User Agent to "Chrome" and this script will return:
Undefined offset: 1 in ../vendor/gabrielbull/browser/src/Browser/BrowserDetector.php:280

Please add Xiaomi Mi Browser

The UA string for Mi Browser:
"Mozilla/5.0 (Linux; U; Android 9; pt-br; Redmi Note 8 Build/PKQ1.190616.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/11.4.3-g"

New Edge(Chromium) detected as Chrome

New UA string in Edge:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.66 Safari/537.36 Edg/80.0.361.40"
Do you plan to detect such case as Edge?

Always "Unknown" browser

Copy one file "Browser.php" and used it as a readme.
But always get "Unknwon" browser.

What am I doing wrong?

iPad/Tablet Detection

It would be very handy to have the capability to determine tablets, specifically in my case iPad's. I'm happy to get involved in implementing this if you think it's of any value? I'm just not quite sure where it fit's in as this library is browser and OS specific and obviously this is a device specific feature.

SamsungBrowser

The stock browser used by new Samsung Androids is significantly different compared to both Chrome and old android stock browsers. One important difference for instance, is that Samsung Browser does not support browser notifications (among other important differences.) I think it would be good if the library would not show this browser as Chrome.

Firefox on iOs is detected as Safari

When checking for firefox the first criteria to is the absence of 'safari' in the user agent string.

but on iOS 'safari' appears (@see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox)

Instead of 'Firefox/version' 'FxiOS/version' is used.

Hence firefox on iOS is identified as Safari with version:unkown.

IN:

Sinergi\BrowserDetector\BrowserDetector

public static function checkBrowserFirefox()
    {
        if (stripos(self::$userAgentString, 'safari') === false) {
            if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", self::$userAgentString, $matches)) {
                if (isset($matches[1])) {
                    self::$browser->setVersion($matches[1]);
                }
                self::$browser->setName(Browser::FIREFOX);

                return true;
            } elseif (preg_match('/Firefox$/i', self::$userAgentString, $matches)) {
                self::$browser->setVersion('');
                self::$browser->setName(Browser::FIREFOX);

                return true;
            }
        }

        return false;
    }

Undefined offset

While running a lot of UA through this parser, i got this error.

Sadly i dont have more data, if you need i need to investigate it deeper.

Notice: Undefined offset: 1 in C:\Data\wap\htdocs\GitHub\UserAgentParserComparis
on\vendor\sinergi\browser-detector\src\BrowserDetector.php on line 299

Call Stack:
    0.0000     118696   1. {main}() C:\Data\wap\htdocs\GitHub\UserAgentParserCom
parison\bin\db\initResults.php:0
  107.6978   32710160   2. UserAgentParser\Provider\SinergiBrowserDetector->pars
e() C:\Data\wap\htdocs\GitHub\UserAgentParserComparison\bin\db\initResults.php:7
1
  107.6978   32710696   3. UserAgentParser\Provider\SinergiBrowserDetector->hasR
esult() C:\Data\wap\htdocs\GitHub\UserAgentParserComparison\vendor\thadafinser\u
ser-agent-parser\src\Provider\SinergiBrowserDetector.php:174
  107.6978   32710696   4. Sinergi\BrowserDetector\Browser->getName() C:\Data\wa
p\htdocs\GitHub\UserAgentParserComparison\vendor\thadafinser\user-agent-parser\s
rc\Provider\SinergiBrowserDetector.php:97
  107.6978   32710696   5. Sinergi\BrowserDetector\BrowserDetector::detect() C:\
Data\wap\htdocs\GitHub\UserAgentParserComparison\vendor\sinergi\browser-detector
\src\Browser.php:112
  107.6988   32710824   6. Sinergi\BrowserDetector\BrowserDetector::checkBrowser
Chrome() C:\Data\wap\htdocs\GitHub\UserAgentParserComparison\vendor\sinergi\brow
ser-detector\src\BrowserDetector.php:94

Detect Facebook and Twitter browsers

Since websites more often are opened in webviews in both the Facebook and Twitter applications on numerous different types of devices it would be nice to detect if the user currently are using the Facebook application etc. I know we can detect Facebook with FBAN. Not sure about Twitter though. Any ideas?

Wrong version on Chrome >100

Hi, library returns wrong version on newest Chrome. I guess, that it takes two digits from the version number, instead of full number.

Add StyleCI Support

What about adding https://styleci.io/ support? Then we will get syntax checks on all commits and PRs made to this repository.

This is the guide to add StyleCI support:

  1. Sign up at https://styleci.io/

  2. Go to the repositories page https://styleci.io/account#repos

  3. Enable this repository.

  4. Press Show Analysis and then Settings.

  5. Add the following settings:

    enabled:
      - unalign_double_arrow
    
    disabled:
      - psr0
      - align_double_arrow
      - phpdoc_align
  6. Press Save Configuration.

  7. Press Analyze Now.

This has to be done by the owner of the repository.

Detect Iridium browser

Can you add detection for Iridum browser? https://iridiumbrowser.de/

Example of browser useragent
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Iridium/58.0 Safari/537.36 Chrome/58.0.3029.81

Can't include class through PHP

It seems it's impossible to include this class with the require function within PHP, without getting a error message! How can I include the function to my website?! Please, tell us others how to do this, in your guide!

Tie Android Browser version to Android OS version

Firstly, I propose that Browser::NAVIGATOR be changed to Browser::ANDROID - the official name of the app is "Android Browser", Navigator doesn't appear.

The detection of the Version/4.0 string is supposed to be correct, but the fact is that /every/ version of the Android Browser reports as Version/4.0.

Since the Android Browser is a core part of the Android OS, I propose that the OS version be used.

Some info to back up my proposal:

Mozilla/5.0 (Linux; U; Android 4.2.2; de-de; SM-T110 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

Here the Android browser is using WebKit

Mozilla/5.0 (Linux; Android 4.4.4; SM-G360H Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36

Here the Android browser is using Blink

The layout engine was upgraded to Blink with the release of Android 4.4, which makes it almost an entirely new browser, but yet both are reported as Version/4.0.

Drop PHP 5.3 Support?

What about dropping PHP 5.3 support? Even 5.4 will stop getting security updates this september (2015). I would even argue for just having 5.5.9 (Symfony 3 and Laravel 5.1 uses this version).

Change namespace

I'd like to change the namespace from Sinergi\BrowserDetector to BrowserDetector

Wkhtmltopdf detection

Hello,

I don't now if it's possible, but I need a browser detector for detect wkhtmltopdf.
For information wkhtmltopdf is a software for print a web page into a PDF.

Thanks

New static API

It would be easier to have a static API to use. Something like this:

use BrowserDetector\BrowserDetector;

$browser = BrowserDetector::getBrowser();
$os = BrowserDetector::getOs();
$device = BrowserDetector::getDevice();
$language = BrowserDetector::getLanguage();
$scriptedAgent = BrowserDetector::getScriptedAgent();

BrowserDetector::isScriptedAgent();
BrowserDetector::isChromeFrame();
BrowserDetector::isWebkit();
BrowserDetector::isFacebookWebView();
BrowserDetector::isTwitterWebView();
BrowserDetector::isCompatibilityMode();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.