Coder Social home page Coder Social logo

uap-php's People

Contributors

antonioribeiro avatar ausi avatar binaryoverload avatar carver avatar commenthol avatar dmolsen avatar dsazup avatar gitter-badger avatar gwendolenlynch avatar ironholds avatar janpio avatar justblackbird avatar krinkle avatar leocolomb avatar lstrojny avatar mondrake avatar nyholm avatar oligriffiths avatar onkarjanwa avatar secondtruth avatar synchro avatar tobie avatar yoannchabert 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

uap-php's Issues

Composer bin not working

This package registers ua-parser.php as bin file, and the file mode is executable. However when actually making use of this (composer global require ua-parser/uap-pphp), invoking it doesn't work because there is no hashbang.

Either add a shebang (and maybe rename the file to without a .php extension), or remove it from the bin list in composer.json.

Right now the only way to invoke it is by doing something like php which uaparser.php ua-parser:parse 'string'.

Minimum PHP version

Hello,
Great plugin!
What is the minimum PHP version required to run this plugin?
Thanks,

Performance improvement when placing most common browser/os/device on top of the regexes list

There would be noticeably faster parsing when the browsers and operating systems which have the most market share are placed on top of the regexes list. Due to looping through the list, the more chances we have a match the sooner we break the loop and return the result.

This issue also applies to other languages and, thus, is not limited to PHP only. Perhaps this is not the right place to create this issue, but you can move it to the proper repository.

IE Edge identified as Chrome

Folling user agent:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240

is incorrectly identified as Chrome. Should be identified as Edge.

VS Code does not find "parse"-functions

While using your project - which is very cool, thank you :) - I am facing a small issue:

$parser = \UAParser\Parser::create();
$result = $parser->parse($useragent_string);

When I am using this two lines, Visual Studio Code is complaining about the function "parse" as AbstractParser does not have any function "parse". Because function "create" returns this kind of object, VS Code is correct at this point I guess.

Image of the issue hint:

image

The list of regexes is outdated

The last update of resources was done almost 1 year. uap-core has seen a bunch of activity in the meantime. It would be great to bring them in the composer package.

Unknown modifier 'T'

Here is my PHP code based off of the sample usage code:

require_once($CFG->dirroot.'/vendor/autoload.php');
$ua = $_SERVER['HTTP_USER_AGENT'];
$parser = UAParser\Parser::create();
$result = $parser->parse($ua);

But I'm getting the following error message. Has anyone seen the same message before or know what the issue could be?

Warning: preg_match(): Unknown modifier 'T' in /vagrant/moodle/vendor/ua-parser/uap-php/src/AbstractParser.php on line 83
Call Stack
#   Time    Memory  Function    Location
1   0.0000  236840  {main}( )   ../index.php:0
2   0.1604  11097280    create_help_message( )  ../index.php:147
3   0.1635  12078336    UAParser\Parser->parse( )   ../help_lib.php:349
4   0.1653  12097032    UAParser\DeviceParser->parseDevice( )   ../Parser.php:51
5   0.1654  12099768    UAParser\AbstractParser->tryMatch( )    ../DeviceParser.php:26
6   0.1656  12158752    preg_match ( )  ../AbstractParser.php:83

"Mi 4i" is not correctly detected as xiaomi

Chrome Beta on Xiaomi Mi 4i has the following user agent string:

Mozilla/5.0 (Linux; Android 5.0.2; Mi 4i Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.36 Mobile Safari/537.36

Installing the default version with composer (require ua-parser/uap-php) identifies device brand as Generic_Android, where it should be XiaoMi

Editing https://github.com/ua-parser/uap-php/blob/master/resources/regexes.php#L4451 , changing it to 'regex' => '; *((Mi|MI|HM|MI-ONE|Redmi)[ -](NOTE |Note )?[^;/]*) Build/', (adding Mi) makes it detect the brand correctly

Compatibility mode detection?

Some of our users are running IE11 in "compatibility mode". It would be nice to be able to detect this. UAParser just shows them as running IE7.

Patch Minor Version Is Always Ignored

Consider these two user agent strings.

1 - Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36 OPR/33.0.1990.115

2 - Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36

As you can see in browsers versions there is a 4th number marking "patch minor".
This 4th number is more and more common in modern devices and I think you should add support for it.

Changing regex (for Opera string )from this:

'regex' => '(?:Chrome).*(OPR)/(\d+).(\d+).(\d+)'

to this:

'regex' => '(?:Chrome).*(OPR)/(\d+).(\d+).(\d+)(?:.(\d+))?'

did not help.

I think you should add some code support for this.

Thank you.

Differentiating from WebView mobile chrome and real Mobile Chrome

Is there anyway for uap-php to tell the difference between WebView in an Android App and the Chrome Mobile browser. https://developer.chrome.com/multidevice/user-agent

Looks like if it has a Version/x.x then it is webview ie..

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

Vs a real chrome ua like this one:

Mozilla/5.0 (Linux; Android 4.4.4; SAMSUNG-SM-G900A Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36

PHP 8.0 compatibility

Are there any plans for adding compatibilty with PHP 8.0?

Would you like me to create a pull request for this?

Symfony 3 conflict

ua-parser/uap-php can't be installed in a Symfony 3 project because it uses some components from Symfony 2, without explicit support to version 3.

Your requirements could not be resolved to an installable set of packages.
ua-parser/uap-php v3.4.0 requires symfony/finder ~2 -> satisfiable by symfony/finder[2.0.4, 2.0.5, ...]

[...]

    - don't install symfony/finder v2.7.7|don't install symfony/symfony v3.0.0
    - don't install symfony/finder v2.8.0|don't install symfony/symfony v3.0.0
    - Installation request for symfony/symfony 3.0.* -> satisfiable by symfony/symfony[v3.0.0].
    - Installation request for ua-parser/uap-php ~3.4 -> satisfiable by ua-parser/uap-php[v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4].

The same conflict would happen with the other components (yaml, filesystem and console).

Did device->family change?

We use this package in another package, and I would have sworn that $client->device->family would return Tablet for an iPad or Mobile for an iPhone, but now we get iPhone for an 'iPhone

From what we remember, $client->device->family had 3 buckets...

  1. Mobile
    2 Other
  2. Tablet

Did something change in a newer version or did we just have it wrong to begin with?

Thanks.

Doesn't recognize SRWare Iron

I know this is a fairly obscure choice, but I've got all my clients into SRWare Iron (Portable). It's being recognized as Chrome. The two most recent versions (51.x and 52.x, the current one) have changed how their ua string is formatted.

Here's my current one:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2750.0 Iron Safari/537.36

There is no longer a slash and a version number after "Iron" in the string.

I'm not sure where to post this concern, so I'm starting here. Long time happy user, first time troubleshooter. Thanks for any advice and for the fabulous tool.

Convert to json file is not implemented

Hi,

The option to convert from yaml to json is not implemented as stated. Actually it does read the yaml file and writes to a PHP file named 'resources.php'.

Also it will be nice to have option to specify the destination file.

Cheers,
Jai

regexp.php file should be shipped with composer package

At the moment there is no regexp.php file in the composer package thus it does not work right out of the box. If someone uses a package that depends on ua-parser/ua-parser he must know too much about package's internals.

I suggest to add regexp.php to the composer's package.

Transition from tobie's ua-parser

Am I the only one that struggle to install ua-parser with composer:

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing ua-parser/uap-php (dev-master 1ff0c92)
    Cloning 1ff0c92eca7958d3977480cf5c1a15b31b7ca909

  [ErrorException]                                                                                                                            
  file_put_contents(/Volumes/Default/server/sy_admin/api/composer/vendor/bin/uaparser.php): failed to open stream: No such file or directory  

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [packages1] ... [packagesN]

I used tobie/ua-parser in the past and I am trying to upgrade.

PHP 7.1 support

Hi!

Does uap-php support PHP 7.1. I noticed there's no such version in travis config. I also tried to run unit tests and 3 of them failed:

genote:vena gene$ phpunit --verbose vendor/ua-parser/uap-php/
PHPUnit 5.7.5 by Sebastian Bergmann and contributors.

Runtime: PHP 7.1.1
Configuration: /Users/gene/Work/ssp/phpunit.xml

.EEE...................S 24 / 24 (100%)

Time: 1.03 seconds, Memory: 26.00MB

There were 3 errors:

  1. UAParser\ParserTest::testDeviceParsing
    ArgumentCountError: Too few arguments to function UAParser\ParserTest::testDeviceParsing(), 0 passed and exactly 9 expected

/Users/gene/Work/ssp/vendor/ua-parser/uap-php/tests/ParserTest.php:79

  1. UAParser\ParserTest::testOperatingSystemParsing
    ArgumentCountError: Too few arguments to function UAParser\ParserTest::testOperatingSystemParsing(), 0 passed and exactly 7 expected

/Users/gene/Work/ssp/vendor/ua-parser/uap-php/tests/ParserTest.php:89

  1. UAParser\ParserTest::testUserAgentParsing
    ArgumentCountError: Too few arguments to function UAParser\ParserTest::testUserAgentParsing(), 0 passed and exactly 6 expected

/Users/gene/Work/ssp/vendor/ua-parser/uap-php/tests/ParserTest.php:101

--

There was 1 skipped test:

  1. UAParser\Util\Logfile\ApacheCommonLogFormatReaderTest::testReadingFile
    Try with your own log file

/Users/gene/Work/ssp/vendor/ua-parser/uap-php/tests/Util/Logfile/AbstractReaderTest.php:55

ERRORS!
Tests: 24, Assertions: 46, Errors: 3, Skipped: 1.

Non-Composer Install

How can this be used without Composer? Composer Installation isn't possible on my server

Make symfony not a required dependency

Hi

Why is symfony a required dependency? This should really be a "suggests" than a require, as the docs say you can use this stand alone without the CLI.

Can this be removed please?

Thanks

'Other' is not returned anymore after updating

Hi,

We went from "ua-parser/uap-php": "^3.8, < 3.9" to: "ua-parser/uap-php": "^3.9",

With version 3.8 i had this check in our code

$parser = Parser::create();              
$result = $parser->parse($request->headers->get('User-Agent'));

return 1 == $request->request->get('mobile-view') || 'Other' !== $result->device->family;

With this version i could check for 'Other' in order to check if the user is working on a desktop or mobile

When i update to 3.9 the $result->device->family returns 'MAC' instead of other (in my case i am working on a mac)

That means that for every operating system it will return something else.

Is there something else i can check in order to check if the user is on mobile or on desktop?

Create tag

I would like to be able to use this package with composer and lock down a version. Currently I am unable to do so. It appears as though the original repo is registered in packagist, it just needs to be updated for this new repo.

Thanks

preg_match Warnings After PHP Ugrade

We recently upgraded our version of PHP from 7.0 to 7.3, and are now receiving many warnings, some of which are pasted below.
You can see the documented changes in the migration notes.

Also note the jump in PCRE versions on the PCRE Installation page.

We also upgraded this library, going from 3.9.1 to 3.9.14 (the latest as of the creation of this issue). Due to the inherent PCRE upgrade in PHP itself, my guess is that is irrelevant, but just thought it should be mentioned anyway.

PHP Warning:  preg_match(): Unknown modifier '/' in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Unknown modifier '/' in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): No ending delimiter ';' found in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Unknown modifier '/' in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Unknown modifier '/' in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): No ending delimiter ';' found in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Unknown modifier '/' in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Delimiter must not be alphanumeric or backslash in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Delimiter must not be alphanumeric or backslash in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Delimiter must not be alphanumeric or backslash in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Unknown modifier '?' in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Delimiter must not be alphanumeric or backslash in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Delimiter must not be alphanumeric or backslash in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28
PHP Warning:  preg_match(): Unknown modifier 'M' in /var/www/vendor/ua-parser/uap-php/src/AbstractParser.php on line 28

Added typehint to Parser breaks Symfony compiled class

After a recent update I get this error:
Compile Error: Declaration of Parser_9383176::parse($userAgent, array $jsParseBits = Array) must be compatible with UAParser\Parser::parse(string $userAgent, array $jsParseBits = Array): UAParser\Result\Client

Versioning question

Hey there!

My question is that the package versioned by semver or a simple stepping?

I wouldn't open an issue for a question like this :D But the release 3.9.8 introduced a breaking change as a patch version and caused issues with users on PHP 7.1 and below.

This was on purpose and I wrongfully assumed semantic versioning or this slipped through the release process? :D

Anyways, thanks for the answer in advance and keep up the good work!

Installation without composer

Dears,

I can't use the composer tool on my website.

Is there another way to install ua-parser ?

Thanks in advance.

Slight issue

Just having a small issue with the 'cache', it is conflicting with my framework cache system. Perhaps a new 'nameing' scheme could be helpful.

Using Chrome on mac os comes out as 'Other'

We've just found out this issue. At the moment if you use Chrome on mac os x the device recorded by the ua-parser comes out as Other with no branch or model.

This is happening on v3.4.5.

vendor/autoload.php

i'm sorry for stupid question

where i can copy source "autoload.php" ?
i can't find it on source..

or someone can create a doc for installing manual without composer?

Microsoft Edge detecting as Chrome .

Hi,
Sorry to open similar issue again but I updated my system to windows 10, and Now on edge browser,
print $result->ua->family; outputs as Chrome instead of Edge.

This is the output I am getting on your example.

========================================
Edge:
========================================

ua-parser-php Test

ua-parser-php is the PHP library for the ua-parser project. Please use this page to test your browser. ua-parser-php was developed to help support my Detector project.
  ua->family: Chrome
  ua->major: 42
  ua->minor: 0
  ua->patch: 2311
  ua->toString: Chrome 42.0.2311
  ua->toVersionString: 42.0.2311
  os->family: Windows
  os->major: 
  os->minor: 
  os->patch: 
  os->patch_minor: 
  os->toString: Windows
  os->toVersionString: 
  device->family: Other
  toFullString: Chrome 42.0.2311/Windows
  uaOriginal: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240

As a temp fix on my website, I am searching for "Edge" using regex in $result->originalUserAgent;
But It would be nice to get Family as Edge.

Update :
I re downloaded from composer specifically for 3.4.3 It is still detecting Edge as chrome.
I even checked http://uaparser.dmolsen.com/. Chrome.

What are libraries for

Connect as much shit in order to determine the user's browser? Are you serious?! Optimize develop.

device is not detected

Thanks for this repository.
When I use it on my pc, device returned as 'Other' instead of PC. Is it the intended behavior?

Composer package

The current repository does not exist on packagist.org. At the tobie/ua-parser package contains files for other languages which are useless for a PHP application.

I believe ua-parser/ua-parser package from this repository should be published.

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.