Displaying "Windows XP (NT 5.1)" instead of "
T
Status: New User - Welcome
Joined: 08 May 2004
Posts: 2
Reply Quote
How do I do that in the fully featured code...

Just want it to display:

Windows XP (NT 5.1) instead of the nt 5.1 which is now!
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
<added> Please download the latest version of the browser detection script, there is a bug in earlier versions unix detection that will cause problems with unix/search engine bots and might result in you losing search engine placement.

T: the main purpose of this script is to identify browsers/os's for internal purposes, css fixes and so on, which is why we use numbers as often as possible rather than letters, although with the windows os's that can't be done reliably because of ME, XP and so on, plus NT 3.5 would be hard to separate from Windows 3.1, etc.

To display something like Windows XP (NT 5.1), like we do on our browser detection page browser info thing is pretty easy.

Let's say you've already gotten the $os variable built, like this:

$os = browser_detection('os') . ' ' . browser_detection('os_number');

this gives you in this case $os == 'nt 5.1';

then you could just say:

if ( $os == 'nt 5.1' )
{
$os = 'Windows XP (NT 5.1)';
}
elseif ( $os == 'nt 5.0' )
{
$os = 'Windows 2000 (NT 5.0)';
}

then if you're just doing a page level display of os information, on the page you echo the $os:

<?php
echo $os;
?>

Personally, I generally prefer to build the whole echo string rather than echoing out individual variables, it's more efficient that way.

and so on. You could also use a switch construction if you wanted, doesn't matter as far as the output is concerned
That's pretty much how we do it, with a lot more variables for the output of course. If this answers your question, good, if it doesn't why don't you give a code sample and we'll help you figure it out.
Back to top
T
Status: New User - Welcome
Joined: 08 May 2004
Posts: 2
Reply Quote
Well...
My code look like this:
:: Code ::

<edited out extra code from browser detection script  that isn't relevant to question - jeffd>



And I include the separate file (browser.php) which the scipt I just pasted is located in, with this:

:: Code ::
<?PHP include("browser.php") ?>
<br>
<?php
echo ( browser_detection( 'browser' ) .'&nbsp;'.
browser_detection( 'number' ) .'<br>'. 
browser_detection( 'os' ) .'&nbsp;'. 
browser_detection( 'os_number' ) );
?>

<?php
if ( ( browser_detection( 'browser' ) == 'ie' ) &&
( browser_detection( 'number' ) >= 5 ) )
{
echo 'it is Internet Explorer ' .
browser_detection( 'number' );
// or anything else you want to happen of course
}
?>


So how do I display Windows XP (NT 5.1) with this script. Didn't understand what you did.

Thanks for the answer!
T
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
This is how I did it on the website:
:: Code ::

<?php

$os = '';
include('browser.inc');
$browser_info = browser_detection('full');

switch ($browser_info[5])
{
   case 'win':
      $os .= 'Windows ';
      break;
   case 'nt':
      $os .= 'Windows NT ';
      break;
   case 'lin':
      $os .= 'Linux ';
      break;
   case 'mac':
      $os .= 'MacIntosh ';
      break;
   case 'unix':
      $os .= 'Unix ';
      break;
   default:
      $os .= $browser_info[5];
}

if ( $browser_info[5] == 'nt'  )
{
   if ($browser_info[6] == 5)
   {
      $os .= '5.0 (Windows 2000)';
   }
   elseif ($browser_info[6] == 5.1)
   {
      $os .= '5.1 (Windows XP)';
   }
}
else
{
   $os .=  $browser_info[6];
}

echo $os;

?>


You are getting the entire browser information array this way, so you only have to call the browser.php script one time, that is packed with all the values that you will need.

Of course the version on the main browser detector page has a bunch more stuff on it, but this the basic script, there's other ways you could do it, I wouldn't change the main script though, it's setup to work without anything, do the custom output stuff using the data the script gives you.

By the way, version 4.5.0 just went up last night, that includes linux detection, sort of, but has a single large upgrade where it will now make a pretty good guess if it can't find the browser version in the hardcoded browser data array.
Back to top
deny
Status: Curious
Joined: 04 Jul 2008
Posts: 6
Reply Quote
Just found this very useful post and wonder of it should not be updated because of nt 5.2 (Windows XP x64 Edition or Windows Server 2003) and nt.6.0(Windows Vista or Windows Server 2008) and nt 6.1 (Windows 7).

I think that there are needed to add this code:

:: Code ::

   elseif ($browser_info[6] == 5.2)
            {
               $os .= '5.2 (Windows XP x64 Edition or Windows Server 2003)';
            }
               elseif ($browser_info[6] == 6.0)
            {
               $os .= '6.0 (Windows Vista or Windows Server 2008)';
            }      
               elseif ($browser_info[6] == 6.1)
            {
               $os .= '6.1 (Windows 7)';
            }   


behind line

:: Code ::

 elseif ($browser_info[6] == 5.1)
   {
      $os .= '5.1 (Windows XP)';
   }


Correct if i'm wrong. Thus new modified code that show WIndows XP 64-bit, Vista, Windows Server 2008 and Windows 7 (that should be released in 2009) is:
:: Code ::

<?php
         $os = '';
         $full = '';
         // change these two to match your include path/and file name you give the script
         include('browser.php');
         $browser_info = browser_detection('full');
         
         $browser_info[] = browser_detection('moz_version');

         switch ($browser_info[5])
         {
            case 'win':
               $os .= 'Windows ';
               break;
            case 'nt':
               $os .= 'Windows - NT ';
               break;
            case 'lin':
               $os .= 'Linux ';
               break;
            case 'mac':
               $os .= 'Mac ';
               break;
            case 'unix':
               $os .= 'Unix - Version: ';
               break;
            default:
               $os .= $browser_info[5];
         }

         if ( $browser_info[5] == 'nt' )
         {
            if ($browser_info[6] == 5)
            {
               $os .= '5.0 (Windows 2000)';
            }
            elseif ($browser_info[6] == 5.1)
            {
               $os .= '5.1 (Windows XP)';
            }
               elseif ($browser_info[6] == 5.2)
            {
               $os .= '5.2 (Windows XP x64 Edition or Windows Server 2003)';
            }
               elseif ($browser_info[6] == 6.0)
            {
               $os .= '6.0 (Windows Vista or Windows Server 2008)';
            }      
               elseif ($browser_info[6] == 6.1)
            {
               $os .= '6.1 (Windows 7)';
            }   
         }
         elseif ( ( $browser_info[5] == 'mac' ) &&  ( $browser_info[6] >= 10 ) )
         {
            $os .=  'OS X';
         }
         elseif ( $browser_info[5] == 'lin' )
         {
            $os .= ( $browser_info[6] != '' ) ? 'Distro: ' . ucfirst ($browser_info[6] ) : 'Smart Move!!!';
         }
         elseif ( $browser_info[6] == '' )
         {
            $os .=  ' (version unknown)';
         }
         else
         {
            $os .=  strtoupper( $browser_info[6] );
         }
         $full .= $os . '';
      
         echo $full . '';
         ?>



btw

Above are also outdated code for linux, Distro, Smart Move. It will be nice if author can modify his code to fit last changes with new OS.

Thanks
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
The scripts in question here were updated long ago for vista, nt 6.0, this thread is just a sample using the php browser detection script and the Your computer box script.

However, added the 6.1 detection to make it future compatible.

The 'smart move' thing you said I don't actually understand, you might want to look at the scripts in question, that is some default output if no specific linux or bsd distro version is detected. And it's still a fairly smart move to run Linux in general, so that doesn't require updating ;-)
Back to top
deny
Status: Curious
Joined: 04 Jul 2008
Posts: 6
Reply Quote
Thanks i see it now.
I would to ask why for $os .= '5.2 is not added Windows XP x64 Edition or for 6.0 Windows Server 2008?

Excuse me for smart move' thing. I have overlooked it.

btw


It seems that i couldn not find XHTML support: part of code?
Is there any special reason why is it excluded from "Your Computer Information" script?

Thanks
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
Windows XP x64 wasn't added because it was assumed that it was 5.1, updated that now.

The xhtml part is not in it because sometimes it's nice to keep some features unpublished, heh heh... but it's very easy:

:: Code ::
if ( $browser_info[1] != $browser_info[9] )
         {
            $full .= '<br />Main Version Number: ' . $browser_info[9];
         }
         $full .= '<br />XHTML support: ';
         $full .= ( stristr( $_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) ? 'Yes' : 'No';
         ....

Back to top
deny
Status: Curious
Joined: 04 Jul 2008
Posts: 6
Reply Quote
Great. Thanks for sharing :)
Back to top
Gandalf
Status: New User - Welcome
Joined: 17 Sep 2008
Posts: 1
Reply Quote
Where exacty would you put that code? I'm kindof new at this part of it, sorry.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours