[SOLVED] Os Detection

This is a discussion on "[SOLVED] Os Detection" within the PHP Forum section. This forum, and the thread "[SOLVED] Os Detection are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 20th, 2007, 16:37
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 675
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
[SOLVED] Os Detection

Is there any code html or php. That would tell the use what os there running. Eg

You are not Running a Windows pc
You are on Vista Ulimate - basic - ect
You are on Xp
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote

  #2 (permalink)  
Old Nov 20th, 2007, 16:43
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 675
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: Os Detection



Like this but html with my own custom messages
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote
  #3 (permalink)  
Old Nov 20th, 2007, 16:45
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Os Detection

Look up user agents.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #4 (permalink)  
Old Nov 20th, 2007, 19:28
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: Os Detection

Quote:
Originally Posted by alexgeek View Post
Look up user agents.
In other words...php

http://php.about.com/od/learnphp/p/http_user_agent.htm
Reply With Quote
  #5 (permalink)  
Old Nov 20th, 2007, 20:06
New Member
Join Date: Nov 2007
Location: North Carolina
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Os Detection

Hi Simon,

You could try something like this in JavaScrict:

Code: Select all
 
<script type="text/javascript"> 
 var bname=navigator.appName;
 var host=addr.getHostName();
 var ip=addr.getHostAddress();
 var os="unknown";
 
 if (navigator.appVersion.indexOf("Win")!=-1) os="Windows";
 if (navigator.appVersion.indexOf("Mac")!=-1) os="Mac";
 if (navigator.appVersion.indexOf("X11")!=-1) os="UNIX";
 if (navigator.appVersion.indexOf("Linux")!=-1) os="Linux";
 
 document.write('Your IP is ' + ip + '! Your ISP is ' + host + '.')
 document.write('<br />')
 document.write('You are running ' + os + 'and using ' + browser + '!')
</script>
but be aware of the fact that alot of people can spoof their user agent info and some firewalls will not send this info.
Reply With Quote
  #6 (permalink)  
Old Nov 21st, 2007, 06:16
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: Os Detection

This is what you are looking for, The Perfect Solution!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #7 (permalink)  
Old Nov 21st, 2007, 06:20
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 675
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: Os Detection

i don't have asp. Php html
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote
  #8 (permalink)  
Old Nov 21st, 2007, 06:24
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Os Detection

Check this out: http://de2.php.net/manual/en/reserved.variables.php

Especially the $_SERVER['HTTP_USER_AGENT'] should be interesting.
Reply With Quote
  #9 (permalink)  
Old Nov 21st, 2007, 11:25
welshstew's Avatar
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,388
Blog Entries: 13
Thanks: 1
Thanked 17 Times in 15 Posts
Re: Os Detection

You can try geekpedia or techpatterns solution

Stew
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)
Reply With Quote
  #10 (permalink)  
Old Nov 21st, 2007, 17:13
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 675
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: Os Detection

PHP: Select all

<?php  $OSList = array
   
      (
   
              
// Match user agent string with operating systems
   
              
'Windows 3.11' => 'Win16',
   
              
'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)',
   
              
'Windows 98' => '(Windows 98)|(Win98)',
  
              
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
   
              
'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
   
              
'Windows Server 2003' => '(Windows NT 5.2)',
  
              
'Windows Vista Great' => '(Windows NT 6.0)',
  
              
'Windows 7' => '(Windows NT 7.0)',
  
              
'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
  
              
'Windows ME' => 'Windows ME',
  
              
'Open BSD' => 'OpenBSD',
  
              
'Sun OS' => 'SunOS',
 
              
'Linux' => '(Linux)|(X11)',

              
'Mac OS' => '(Mac_PowerPC)|(Macintosh)',
 
              
'QNX' => 'QNX',
 
              
'BeOS' => 'BeOS',

              
'OS/2' => 'OS/2',

              
'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)'

      
);
 
       

      
// Loop through the array of user agents and matching operating systems

      
foreach($OSList as $CurrOS=>$Match)

      {

              
// Find a match

              
if (eregi($Match$_SERVER['HTTP_USER_AGENT']))
 
              {

                      
// We found the correct match
 
                      
break;

              }
 
      }
 
      
// You are using Windows Vista
 
      
echo "You are using ".$CurrOS?>
Thanks rep for you thats work i am looking for
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote
  #11 (permalink)  
Old Nov 21st, 2007, 18:10
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Os Detection

Someone move this to PHP section?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #12 (permalink)  
Old Nov 23rd, 2007, 08:04
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: Os Detection

How come it looks simple in php compare to asp?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #13 (permalink)  
Old Nov 23rd, 2007, 09:32
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Os Detection

Quote:
Originally Posted by monie View Post
How come it looks simple in php compare to asp?
cus PHP has nothing to do with microsoft
Reply With Quote
  #14 (permalink)  
Old Nov 23rd, 2007, 12:16
Junior Member
Join Date: Oct 2007
Location: Israel
Age: 21
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Os Detection

its the same...
the only difference from the function i've uploaded is that this function is using array.
you can do it too...

the truth is that i don't know what better except that arrays looking nicer ;]
Reply With Quote
  #15 (permalink)  
Old Nov 24th, 2007, 02:22
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: [SOLVED] Os Detection

The asp INSTR function will do just fine for now
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #16 (permalink)  
Old Nov 24th, 2007, 08:36
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 675
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: [SOLVED] Os Detection

i am going to add it to vistahelpers.co.uk

So i can tell people to get vista
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote
  #17 (permalink)  
Old Nov 26th, 2007, 23:59
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: [SOLVED] Os Detection

I am not ready for Vista
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Event Chain detection StanLevin JavaScript Forum 4 Jan 18th, 2008 18:33
Browser detection IE mac jillcary JavaScript Forum 1 Aug 1st, 2007 11:28
javascript detection yvettesio JavaScript Forum 2 Feb 12th, 2007 23:58
Object Detection RobinDeanDotCom JavaScript Forum 4 Sep 11th, 2006 18:30
ie mac detection jimz JavaScript Forum 2 Jul 27th, 2006 22:07


All times are GMT. The time now is 02:16.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43