[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.



 Subscribe in a reader

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

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Nov 20th, 2007, 16:37
Highly Reputable Member

SuperMember
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
[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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 20th, 2007, 16:43
Highly Reputable Member

SuperMember
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
Re: Os Detection



Like this but html with my own custom messages
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Nov 20th, 2007, 16:45
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Os Detection

Look up user agents.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Nov 20th, 2007, 19:28
Highly Reputable Member
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Nov 21st, 2007, 06:16
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Os Detection

This is what you are looking for, The Perfect Solution!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Nov 21st, 2007, 06:20
Highly Reputable Member

SuperMember
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
Re: Os Detection

i don't have asp. Php html
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Nov 21st, 2007, 06:24
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Os Detection

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

Especially the $_SERVER['HTTP_USER_AGENT'] should be interesting.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Nov 21st, 2007, 11:25
welshstew's Avatar
Site Admin

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,689
Blog Entries: 14
Thanks: 3
Thanked 31 Times in 29 Posts
Re: Os Detection

You can try geekpedia or techpatterns solution

Stew
__________________
WelshStew Site Admin
If you think I've helped, click the "Thanks"
tierney rides tboard - uk site | xtreme wales - extreme clothing
WebForumz - facebook | LinkedIn
Last Blog Entry: Phorm approved for UK rollout (Sep 17th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Nov 21st, 2007, 17:13
Highly Reputable Member

SuperMember
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Nov 21st, 2007, 18:10
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Os Detection

Someone move this to PHP section?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Nov 23rd, 2007, 08:04
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Os Detection

How come it looks simple in php compare to asp?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Nov 23rd, 2007, 09:32
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
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 ;]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Nov 24th, 2007, 02:22
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Nov 24th, 2007, 08:36
Highly Reputable Member

SuperMember
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Nov 26th, 2007, 23:59
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: [SOLVED] Os Detection

I am not ready for Vista
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote