News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

OS & Browser Detection (version 1.5 is out) [20. 09. 2010.]

Started by Branko., December 06, 2008, 05:23:42 AM

Previous topic - Next topic

cieplutki

seriously BlackBerry OS and Win Phone ...
who confirms linux mint  ???




.

French

Quote from: cieplutkiwho confirms linux mint  ???

Code (adding this) Select
 
      elseif(preg_match('/linux/si', $user_agent))
        {
      $client_data['system'] = " (Linux Mint)";
      $client_data['system_icon'] = "mint";
        }

Code (instead of) Select
elseif(preg_match('/mint/si', $user_agent))
        {
$client_data['system'] = " (Linux Mint)";
$client_data['system_icon'] = "mint";
        }



When i analysis on client SW type (browser, webcrawler, anonymizer etc.), and which OS is used (using User agent info)

We get this information

That's because Linux Mint is based on Ubuntu,That,s why I did it this way to get the Linux Mint ico.

cieplutki

Hi,

on my os_browser_detection.php no code you write

    // Linux
    if(preg_match('/linux/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Linux";
      $client_data['system_icon'] = "linux";
      if(preg_match('/mdv/si', $user_agent) || preg_match('/mandriva/si', $user_agent))
        {
        $client_data['system'] .= " (Mandriva";
        $client_data['system_icon'] = "mandriva";
        // Try to detect version
        if(preg_match('/mdv([0-9.]*)/si', $user_agent, $tmp_array))
          {
          $client_data['system'] .= ($tmp_array[1] ? " ".$tmp_array[1].")" : ")");
          }
        else
  {
          $client_data['system'] .= ")";
  }
        }




.

lukaszuk1995

#443
This is a line which the useragent which uses IE 11.
    // Catchall for other Mozilla compatible browsers
    if(preg_match('/mozilla/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Mozilla " . $txt['OS_Browser_Compatible'];
      $client_data['browser_icon'] = 'mozilla';
      }
     

This is IE 11 useragent :
Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko
How to modify it to Internet Explorer 11 ?
It must be something like this :if(preg_match('/mozilla.*rv:[11.0\.]+.*gecko\/[0-9]+.* Trident/7.0\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])

Sandmansa

That detection method doesn't work.  Good try though lukaszuk.  You gave me an idea though and it does seem to work for me.

What I did is changed this:

    // Catchall for other Mozilla compatible browsers
    if(preg_match('/mozilla/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Mozilla " . $txt['OS_Browser_Compatible'];
      $client_data['browser_icon'] = 'mozilla';
      }
     


To this:

    // Catchall for other Mozilla compatible browsers
    if(preg_match('/mozilla/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "MS Internet Explorer 11 " . ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'msie';
      }



It's just a temporary work around until someone comes up with something better.

Arantor

Considering that every single browser out there - even most of the spam bots - states itself as Mozilla compatible (and thus begins with 'Mozilla'), that's really not going to work that well.
Holder of controversial views, all of which my own.


Sandmansa

I am aware of that Arantor.  Is there anything you can do to help find a workable detection method?

Arantor

The entire mod needs a rewrite, and I don't really have the time to do that right now.
Holder of controversial views, all of which my own.


Sandmansa

Please don't take what I am about to say as insulting or anything like that, because it is not intended to be.

I understand that your time is very limited.  That goes without saying.  And a lot of mods around here could use some attention from one degree or another, not just this one.  So we (the community) are trying to work with what is still available to us.

Arantor

Right, which is why I added what I did have to hand that was useful: detecting MSIE 11 based on 'Mozilla' in the user agent is terrible. At least test for Trident in the user agent instead... every version of MSIE, even the ones that clearly mark themselves as MSIE should be indicating themselves with the word Trident (which is the internal HTML renderer, in the same way Chrome uses Webkit and later, Blink)

Though a mod that works by inefficient regexes needs more than patchwork... it really does need rewriting from scratch. Maybe one day I'll find the time... :/
Holder of controversial views, all of which my own.


Sandmansa

#450
Thanks for the tip Arantor.  That actually works.


    // MSIE 11
    if(preg_match('/Trident\/7.0/', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "MS Internet Explorer 11.0" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'msie';
      }



Funny though, /Trident/7.0 didn't work.  ???

Arantor

In regex, the first character is a container, you use that to mark out the entire string. Since you're using / for all the container characters, you have to escape it inside the string, e.g. /Trident\/7.0/ (since the si part is outside the regex and tells PHP how to treat the rest of the regex, in this case, i means case insensitive and the s means to treat . a slightly different way to normal... but . has a ton of special meaning of its own anyway so you should generally escape that too)
Holder of controversial views, all of which my own.


Sandmansa

Thanks again for your help.  That worked out great.  I updated my last post.

cieplutki

Quote from: Sandmansa on January 05, 2014, 10:41:34 PM
Thanks for the tip Arantor.  That actually works.


    // MSIE 11
    if(preg_match('/Trident\/7.0/', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "MS Internet Explorer 11 " . ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'msie';
      }



Funny though, /Trident/7.0 didn't work.  ???

It's works Thanks,

We have a similar problem with the new version of the opera who fix that  ???




.

French

Quote from: cieplutkion my os_browser_detection.php no code you write
It's my own editing  ;).......Modification have never been upgrade or rewritten

cieplutki

#455
Ok,
collected all updates  ;D




.

Arantor

I'm sorry, I had to remove your attachment. We cannot allow you to re-package modified mods unless the author explicitly allows it. Documenting changes is fine but creating a composite work is not legal.
Holder of controversial views, all of which my own.



lukaszuk1995

It works for me, thanks. I have error:
Fatal error: Call to undefined function sys_template() in /usr/home/pcvortal/domains/betaportal.ct8.pl/public_html/Sources/Load.php(2170) : eval()'d code on line 306
Can anyone help me ?

Branko.

Quote from: Arantor Beeblebrox the First on January 06, 2014, 12:59:01 PM
I'm sorry, I had to remove your attachment. We cannot allow you to re-package modified mods unless the author explicitly allows it. Documenting changes is fine but creating a composite work is not legal.

Actualy the problem with the copyright has been solved a long time ago. I have approval for any modifications made by Miloš Ranđelović aka X3mE. All necessary data are stored in my personal email archive. If you have enough free time to continue working on this modification, then everything is fine.  :)
Strong people don't put others down, they lift them up.
A clever person solves a problem. A wise person avoids it.

Advertisement: