View Full Version : [TXT] & [HTL]Adding OS specific Template conditonal.
neocorteqz
03-12-2005, 10:00 PM
I had this idea because when I was in Linux and was viewing a site using the Q3px (http://q3px.khimtech.com/) Plugin. It would annoy me everytime because it would constantly ask for the plugin. Or it would show a Install this plugin Box.
What this will do is allow you to insert plugins that will work for only Specific Operating systems, while blocking out the unsupported operating systems.
Alot of the credit goes to Revan For providing the fixed code and for pointing me to the corrent file to edit to add this function.
And Credit also goes to MarcoH64 for his assistance.
Thanks guys. :)
Intructions are in the txt file, or if you have the Hack Tracking Log (https://vborg.vbsupport.ru/showthread.php?t=60735) installed, download the htl file. :)
neocorteqz
03-13-2005, 08:11 PM
No Screenshot.
The example of how to use this is in the txt file. But here it is again.
<if condition="is_os('XXX')">
Insert Code Here
</if>
Where XXX can equal the following.
windows
linux
mac
and webtv
Yes I know webTv isn't an OS, but I included it for the remote chance someone out there actually uses it. :D
Revan
03-13-2005, 08:32 PM
Cort, you never told me if you wanted a version that could check against multiple os'es as well, so:
if anyone needs a version that can check multiple os'es at a time (IE something like <if condition="is_os('XXX', 'YYY', 'ZZZ')">
Insert Code Here
</if> for various reasons, like plugins/code working on several os'es), the code would be this:
// #################### Start is os ##########################
// os detection script
function is_os()
{
$os = func_get_args();
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
// detect windows
if ((strpos($useragent, 'winnt') !== false) OR (strpos($useragent, 'win32') !== false) OR (strpos($useragent, 'windows') !== false))
{
$found_os = 'windows';
}
// detect macintosh
if (strpos($useragent, 'mac') !== false)
{
$found_os = 'mac';
}
// detect linux
if ((strpos($useragent, 'linux') !== false) OR (strpos($useragent, 'x11') !== false) OR (strpos($useragent, 'i686') !== false))
{
$found_os = 'linux';
}
// detect web tv
if (strpos($useragent, 'webtv') !== false)
{
$found_os = 'webtv';
}
// sanitize the incoming os names
foreach ($os as $ops)
{
$opsys[] = strtolower($ops);
}
if (in_array($found_os, $opsys))
{
return true;
}
else
{
return false;
}
}
// #################### End is os ##########################
The difference is that if you want your code to be executed on both f.ex. linux and windows, you would have to use <if condition="is_os('windows') OR is_os('linux')">
Insert Code Here
</if>
:)
//peace
neocorteqz
03-13-2005, 08:55 PM
Thanks!
HTL and TXT Updated.
Marco van Herwaarden
03-14-2005, 03:26 AM
Maybe my eyes are still closed (yee i need more coffee) but i don't se any files attached.
PS Don't think i need any credits, all the work is done by Revan.
neocorteqz
03-14-2005, 06:36 AM
Maybe my eyes are still closed (yee i need more coffee) but i don't se any files attached.
PS Don't think i need any credits, all the work is done by Revan.
Doh.. I forgot to click upload before i closed the window. :D :o
Files are uploaded.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.