GithubHelp home page GithubHelp logo

dmolsen / detector Goto Github PK

View Code? Open in Web Editor NEW
846.0 846.0 80.0 2.52 MB

Detector is a simple, PHP- and JavaScript-based browser- and feature-detection library that can adapt to new devices & browsers on its own without the need to pull from a central database of browser information.

Home Page: http://detector.dmolsen.com/

License: MIT License

PHP 95.47% Shell 1.25% Perl 2.14% JavaScript 1.15%

detector's People

Contributors

dmolsen 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

detector's Issues

"Please make sure families.json.default exists" error constantly...

I'm a little weirded out by this error, as I've used your api on my local machine and it works right out of the box.

My code is basic:

require_once($path."/includes/detector/lib/Detector/Detector.php");

And thats where it fails. Always gives the same error:

Please make sure families.json.default exists before trying to have Detector build the families.json file automagically.

Locally, same setup, works perfectly and I'm checking the UA information, but on my server, no go.
Constantly showing this error.
So I've got a couple of thoughts, one is its on a subdomain, maybe thats affecting the pathing somehow.

I've set all directories and files to 777 just to test, but no change.

I'm really running out of thoughts and options here.

Wondering if you could help.

Thanks

Marcus

Critical: WSOD in IE10 and IE11

Hello,

detector.dmolsen.com and our site using Detector results in a WSOD in IE10 and IE11, thus making this software unusable.

Anyone found a fix for this?

Thank you,
Chris

Problems Incorporating with WordPress

I know you can't support all possible platforms, but WordPress is a pretty popular PHP based platform, so perhaps you have some ideas.

I did find and try this plugin, which is just a simple wrapper to include, in addition to trying to manually include Detector.

Here is what I found:

Detector WordPress issues

Notes

  • Local Install
  • WordPress 3.5.1
  • All other plugins deactivated
  • Twenty Twelve Theme
  • Using ServerPress - DesktopServer
  • PHP version 5.3.1
  • set permissions to 777 on all files in Detector directory

1) Plugin - As - Is

  • http://wordpress.org/plugins/detector/
  • Last updated: 9/10/2012
  • Installed as is I get the following PHP warning:
    Warning: Invalid argument supplied for foreach() in /[path_to_wp_install]/wp-content/plugins/detector/lib/Detector/Detector.php on line 77
    Detector.php line 77:
    ```// populate some standard variables out of the config
    foreach ($config as $key => $value) {
    self::$$key = $value;
    }
- Below the warning, the rest fo the site appears to load normally

#### 2) Plugin - replacing entire /lib/Detector/ directory with current version from github
https://github.com/dmolsen/Detector/
- When I replace the /lib/Detector/ directory with the most current version I get a similar PHP warning
- `Warning: Invalid argument supplied for foreach() in /[path_to_wp_install]/wp-content/plugins/detector/lib/Detector/Detector.php on line 70`
- Detector.php line 70:
    ```// populate some standard variables out of the config
       foreach ($config as $key => $value) {
        self::$$key = $value;
       }
  • in addition, below the PHP warning I get a page full of raw code, and the rest of the site does not load.
  • screenshot http://d.pr/i/tRe7
  • It appears to break and print the raw code of Detector.php after line 380, which is within the buildTestPage() function.

3) Manually include latest version from github

https://github.com/dmolsen/Detector/

  • put /Detector directory inside the WordPress theme
  • include it in the theme's functions.php like so:
    • require_once('library/detector/lib/Detector/Detector.php');
  • Same results as #2 above.

File Creation Madness

I inherited a site using a version of this code. It's created >60K files on the server, making backups take forever.

I'm not 100% clear on how this code works - is it creating a file on the server for every session? Or just unique user agent strings?

Is there a way to stop the file creation madness?

Bandwidth detection ?

Hi,

I saw on http://detector.dmolsen.com/ a feature called "lowbandwidth" in the Misc category. I tried to load the site on mobile on 3G or on desktop with Charles Proxy set to 56k but the badge never became true.

How is this feature detected ? I found nothing neither here nor somewhere else.

Thanks.

Detector in Wordpress bugs out XMLRPC

I didn't have an issue incorporating Detector into my theme by literally dropping said directory into the theme directory then requiring it from functions. In terms of functionality it was a breeze.

What I discovered belatedly when having to connect to Wordpress to enable Jetpack was the following alert:

Error Details: The Jetpack server could not communicate with your site's XML-RPC URL. Please check to make sure http://www.example.com/ is working properly. It should show 'XML‑RPC server accepts POST requests only.' on a line by itself when viewed in a browser and should not have any blank links or extra output anywhere.

What happens when visiting /xmlrpc.php is just an endless loop. Commenting out Detector from functions.php let xmlrpc.php resolve correctly.

Sécurity Problem with User Agent Switcher

Hi,

I try Detector and it is a good job. Thanks.
But it is possible that you hate me soon :)

But I had a question during my tests : What happen if someone change his UA width à Switcher like "User Agent Switcher" for Firefox.

So, I tried to set my UA from IE8 in Firefox with "User Agent Switcher". Damned, IE8 UA is saved in user-agents folder with Firefox's features. Next I'll try to surf on my detector website with a real IE8 and the server serves pages optimised for Firefox. Grrrrrrrrrr

1/ It's a big problem because it is impossible to check the browser real UA and it is a risk to serve no wellformed pages

2/ It's possible width a script and a UA database to attack the website which use detector and to force him to save UAs with bad features

I search a solution : maybe

save 10 versions of features for each UA
and when 10 is reached, averaging features.

Sorry for my poor english from France.

Bye

Error relating to spyc-0.5 only on iOS

I've got Detector working fine on desktop but when I try to view my test page on iOS5.1.1 (using Safari or Chrome) I get

'failed to open stream: No such file or directory' for /lib/spyc-0.5/spyc.php in UAParser.php (line 27).

If I comment out that line, I get another error:

Please download the regexes.yaml file before using UAParser.php

Fatal error: require_once() Failed opening required /...spyc.php in /...UAParser.php on line 27

Hello,

We are getting the following error when installing and configuring Detector:

Warning: require_once(/.../spyc.php) [function.require-once]: failed to open stream: No such file or directory in /.../UAParser.php on line 27

Fatal error: require_once() [function.require]: Failed opening required '/.../spyc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /.../UAParser.php on line 27

We use PHP v5.4.

Thanks,
Chris

Incorrect spelling in families.json

In the JSON file the following is spelled incorrectly.

"mobile-advanced": { 
    "isMobile": true,
    "features": [ "csstranforms" ]
},

Should be csstransforms

Basic HTML implementation.

Hi,

I'm pretty sure that this is the dumbest question you'll get, but my PHP knowledge is very basic at most and I'm having a lot of trouble trying to use detector in a HTML page to conditionally load JS and CSS files for simple web apps (I'm a simple web app designer), some kind of fallback (similar to the ones that you can create with modernizr and yepnope.js) for smaller devices.

I know about the existence of detectizr (https://github.com/barisaydinoglu/Detectizr) but I consider your solution being more complete.

I've been looking for a more detailed tutorial on google but with no luck and I'll really appreciate if you could give me a couple of advices to begin with.

Thank you,
Rodrigo Hernando.

Problem with perrequest

Hi,
first of all, thank you so muck for your great job..
i m testing the perrequest including the features.js.php into my head, what i get it s just a print of all the js code requried (modernizr, dpi and screenattributes). what s wrong?

thank you in advance

Per-request tests not running/updating $ua?

I've been having issues getting the per-request tests to be saved to the session on every request. This seemed to work in 0.7.1 but seems to have stopped working as of 0.8.0. I'll have to test this to make sure.
This might be the case with my Drupal integration module, but I'm not sure if it's the module, the library or Drupal that's the root of the issues.

For example, the supplied screenattributes test doesn't change windowWidth or windowHeight variables regardless of browser size changes and how many times the browser is refreshed. I suspect that the cookie is not being updated or read on load or something along these lines, or that the session is not being refreshed in some other way.

Has anything relating to the cookie processing changed since 0.7.1?

Incorrect height value

Line 4 of screenattributes.js uses width instead of height when innerHeight is not defined.

Future of this project?

Hello,
Thank you for an awesome piece of software.

I see that there has not been any activity on this project for the last two years or so. What is the future of this project? Will it be further developed?

Thank you again,
Chris

OS and OS version separation

On Windows 7 I noticed the OS and OS version are not separate.

Using Detector 0.8.5

$ua->os = Windows 7
$ua->osVersion =
$ua->osFull = Windows 7

I have not checked if the same happened on other OS's

stats?

Do you have any stats on what properties are tested with Detector? It'd be helpful for a few projects that are currently underway..

cc @igrigorik

Notice: Undefined index: {my cookie}-pr

Notice: Undefined index: {my cookie}-pr in Detector::build() (line 119 of /Detector/Detector.php).

Replace {my cookie} with a cookie hash.

I'm running PHP 5.3.8.

Detecting JS support

What would be a good way to detect whether the browser runs javascript? I know of course the modernizr won't run at all if JS was disabled, but does the server side library have a function to let me know whether it received data from modernizr?

Blank page on IE Mobile 7.6 / Windows CE

Hello,

This is obviously not a high priority issue and you decide if it is worth investigating any further. We are testing the detector.dmolsen.com and our pages from a Pocket PC (IE Mobile 7.6 / Windows CE) and getting a blank page.

Could it be the Modernizr javascript that errors out in a blank page?

Thank you,
Chris

Opera 12.50 (desktop, alpha) doesn't render http://detector.dmolsen.com/

Opera 12.50 alpha (aka Opera Next http://www.opera.com/browser/next/) on desktop doesn't render http://detector.dmolsen.com/, whereas Opera 12.01 does. In Opera.Next, masking as Firefox makes it work. That's often indicative of UA detection at play.

Opera 12.50 simplifies the UA string (see http://my.opera.com/ODIN/blog/2012/08/03/a-hot-opera-12-50-summer-time-snapshot :)

Opera 12.50 will ship with a simplified UA string. Firstly, we have dropped the "U;" token, which signified that the browser provides crypto support that is stronger than what the "international" builds of Netscape offered circa 1995. The second change is removal of the language indicator. As an example, while the UA string for Opera 12.01 on Mac is currently
Opera/9.80 (Macintosh; Intel Mac OS X 10.8.0; U; en) Presto/2.10.289 Version/12.01

today's snapshot for Opera 12.50 on Mac shows
Opera/9.80 (Macintosh; Intel Mac OS X 10.8.0) Presto/2.12.363 Version/12.50

Both these changes correspond to similar changes in the IE, Firefox, Chrome and Safari browsers' UA strings."

Could this be the issue? (Or should I be looking in https://github.com/tobie/ua-parser)

(Later addition) just had a chat with Tobie on twitter and filing a bug against UA parser as he suggested.

Trying to get in touch regarding a security issue

Hey there!

I'd like to report a security issue but cannot find contact instructions on your repository.

If not a hassle, might you kindly add a SECURITY.md file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.

Thank you for your consideration, and I look forward to hearing from you!

(cc @huntr-helper)

[Security] XSS in _contactform.inc.php

Describe the bug
Reflected Cross-Site Scripting (XSS) may allow an attacker to execute JavaScript code in the context of the victim’s browser. This may lead to unauthorized actions being performed, unauthorized access to data, stealing of session information, denial of service, etc. An attacker needs to coerce a user into visiting a link with the XSS payload to be properly exploited against a victim.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the page with following parameter: http://[localhost]/Detector/web/templates/_contactform.inc.php?cid=%3C/textarea%3E%3Cscript%3Ealert(1);%3C/script%3E
  2. Boom!

Screenshots

  • Attack result
    캡처

Where the Issue Occurred
The code below displays the user-controlled parameter cid without sufficient sanitization:

I may have found a problem with the browser related to the user agent hash "<?=$_REQUEST['cid']?>." My notes are below:

Binary websocket support and IE10

I've created an add-on for ExpressionEngine that uses Detector and it works fine everywhere except for IE10 where you get a blank page because it fails at the Modernizr test stage with an unspecified error for:

Modernizr.addTest("websocketsbinary",!!window.WebSocket&&!!(new WebSocket("ws://.")).binaryType)

Looking through the issues for Modernizr, it seems this came up a while ago with a fix merged in a few months ago.

I'm wondering if it would be possible to update the custom build that Detector uses to include this fix? I know I could create my own custom build, but I'm not sure what customisations were made to achieve the build used with Detector.

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.