The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
A function like is_broswer, but for Operating System Ident.
I was wondering if anyone could find a small amount of time to do this.
We have the built in function of is_browser, to select specific browsers, I was wondering if someone could code something similar for a browser conditional. I use a plugin for grabbing game server info, called q3px, and it currently does not support Linux. So i'd like to have something that can exclude Operating systems that are not compatible with what I may install to add to the already existing scripts. Thanks for anyone that can take the time to do this. |
#2
|
|||
|
|||
Hi
Something like this... Code:
<? // usage $out = this_system (); // good systems! (example) $good = array ( 'windows', 'mac' ); // test it! if ( ! in_array ( $out, $good ) ) { echo 'Sorry this service does not support your system type'; exit (); } // keep processing script, system OK! echo 'You are using ' . $out . ' for your OS!'; function this_system () { $ua = $_SERVER['HTTP_USER_AGENT']; $sta = stristr ( $ua, 'x11' ); $stb = stristr ( $ua, 'linux' ); $stc = stristr ( $ua, 'sunos' ); $std = stristr ( $ua, 'os/2' ); $ste = stristr ( $ua, 'mac' ); $stf = stristr ( $ua, 'ppc' ); $stg = stristr ( $ua, '32bit' ); $sth = stristr ( $ua, 'winnt' ); $sti = stristr ( $ua, 'win95' ); $stj = stristr ( $ua, 'win32' ); $stk = stristr ( $ua, 'windows' ); if ( $stk !== false ) { $system = 'windows'; } else if ( $stj !== false ) { $system = 'windows'; } else if ( $sti !== false ) { $system = 'windows'; } else if ( $sth !== false ) { $system = 'windows'; } else if ( $stg !== false ) { $system = 'windows'; } else { if ( $stf !== false ) { $system = 'mac'; } else if ( $ste !== false ) { $system = 'mac'; } else { if ( $std !== false ) { $system = 'os2'; } else { if ( $stc !== false ) { $system = 'unix'; } else if ( $stb !== false ) { $system = 'linux'; } else if ( $sta !== false ) { $system = 'unix'; } else { $system = 'unknown'; } } } } return ( $system ); } ?> |
#3
|
||||
|
||||
I was thinking of something based off of the existing code for is_browser
PHP Code:
But the code you posted works fine. Just i need to integrate it into vB for a conditional i can use anywhere. like HTML Code:
<if condition="!is_os('win,mac')> You must be using Windows or Mac to view the q3px plugin. <else /> <code here> </if> Edit: will this work? PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|