vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Adding Template Conditionals to vB. (https://vborg.vbsupport.ru/showthread.php?t=77965)

Revan 03-13-2005 11:44 AM

The first error I detect is that you have a parse error on this line:
PHP Code:

        if ((strpos($useragent'linux') !== false) AND (strpos($useragent'x11') !== false) AND (strpos($useragent'i686') !== false)) 

You had 1 parenthesis too many at the end there ;)
I'll keep testing this function, then race ya to get it working first ;)

And here is the complete working function. For obvious reasons, I have not been able to test linux, mac or webtv, you might want to get someone using those os'es (is webtv an OS though? :confused: )
PHP Code:

// #################### Start is os ##########################
// os detection script
function is_os($os)
{
    
$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';
        
// I left this code in because I have no idea why you put it there... :P
        /*
        preg_match('#webtv/([0-9\.]+)#', $useragent, $regs);
        $found_os = $regs[1];
        */
    
}

    
// sanitize the incoming os name
    
$os strtolower($os);
    if (
substr($os03) == 'is_')
    {
        
$os substr($os3);
    }
    
    if (
$os === $found_os)
    {
        return 
true;
    }
    else
    {
        return 
false;
    }
}
// #################### End is os ########################## 


Marco van Herwaarden 03-13-2005 01:24 PM

Looks better to me :D

neocorteqz 03-13-2005 04:55 PM

Quote:

Originally Posted by Revan
The first error I detect is that you have a parse error on this line:
PHP Code:

        if ((strpos($useragent'linux') !== false) AND (strpos($useragent'x11') !== false) AND (strpos($useragent'i686') !== false)) 

You had 1 parenthesis too many at the end there ;)
I'll keep testing this function, then race ya to get it working first ;)

And here is the complete working function. For obvious reasons, I have not been able to test linux, mac or webtv, you might want to get someone using those os'es (is webtv an OS though? :confused: )
PHP Code:

// #################### Start is os ##########################
// os detection script
function is_os($os)
{
    
$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';
        
// I left this code in because I have no idea why you put it there... :P
        /*
        preg_match('#webtv/([0-9\.]+)#', $useragent, $regs);
        $found_os = $regs[1];
        */
    
}

    
// sanitize the incoming os name
    
$os strtolower($os);
    if (
substr($os03) == 'is_')
    {
        
$os substr($os3);
    }
    
    if (
$os === $found_os)
    {
        return 
true;
    }
    else
    {
        return 
false;
    }
}
// #################### End is os ########################## 



Thanks. and Here's how to test.

Firefox's useragent switcher plugin.

Seeing as this is based on useragent string, you can change it to anything other than windows to test it. :)

and webtv isn't an os, But i wanted it included for the Remote posibility that someone may actually be using it. Doubtful, but you never know.


Thanks again everyone.

Edit:
@ Revan

Did you want to release this? i was planning on releasing this after i finished it.

If you don't I'll of course release with you credited as a main contributer along with anyone else that contributed in this thread. :)

Revan 03-13-2005 06:46 PM

You need it more than I - you haven't even gotten your coder title yet ;)
Besides it was your idea, we merely helped you :)
Credits will do fine. *waves hand* Credits will do fine. [/Qui-Gon Jinn]

Ye of course, I never thought of the user agent switcher plugin. I got the bugger installed too :p

Hm I just took a look at your first post, and it appears like you tried to submit multiple arguments to the function - do you want/need it to do this?

neocorteqz 03-13-2005 07:54 PM

Quote:

Originally Posted by Revan
You need it more than I - you haven't even gotten your coder title yet ;)
Besides it was your idea, we merely helped you :)
Credits will do fine. *waves hand* Credits will do fine. [/Qui-Gon Jinn]

Ye of course, I never thought of the user agent switcher plugin. I got the bugger installed too :p

Hm I just took a look at your first post, and it appears like you tried to submit multiple arguments to the function - do you want/need it to do this?

Lol, even if I had one by some freakish chance, I'm far from "Coder", i still have a lot to learn. :)

release as soon as I post it. :D :)

T3MEDIA 03-13-2005 09:12 PM

thats hot. listen to the list maybe you should have a condition to see what contry the user is from.

THEN>>>>>>> oh ho ho ho your phases could instantly change... like google does.

do that... and users will worship you as a god with big brests and azz.


All times are GMT. The time now is 12:28 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01905 seconds
  • Memory Usage 1,770KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete