vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Mobile login conditional? (https://vborg.vbsupport.ru/showthread.php?t=281212)

Boofo 04-06-2012 05:59 PM

Mobile login conditional?
 
Is there a conditon for checking to see if a login is done via Mobile device?

SEOvB 04-06-2012 10:38 PM

You mean a template conditional? What do you want to use it for?

-Nick, SEOvB Developer

Boofo 04-06-2012 10:43 PM

Yes, a template conditional. I want to use it to not use the IP they are loggedin with if they are on a mobile.

SEOvB 04-06-2012 10:59 PM

AFAIK, there is no such conditional by default. The closest thing you could maybe access in a template is the useragent (e.g. Mozilla Firefox) with user.useragent, depending on which template you're dealing with, but that would be an awful mess of code.

If you just want to display different templates based on whether or not the user is on a mobile device, just edit the "Default Mobile Device" theme, editable from the Settings->Style & Language Settings AdminCP panel.

-Nick, SEOvB Developer

Boofo 04-06-2012 11:10 PM

How does vb know to display the mobile style if a mobile logs in?

Actually, what I need is the PHP conditional, not the template.

SEOvB 04-06-2012 11:29 PM

Hmmm... no idea. That feature is relatively new, and I haven't worked with it yet. It's probably PHP based, but that's not much help. If you're comfortable digging through code, you could check the code surrounding the init_start, global_start, and parse_template hooks.

Also, try asking over in the programming discussion forum. That would probably be a more appropriate forum for your question.

-Nick, SEOvB Developer

Boofo 04-07-2012 08:46 AM

Thanks for trying to help, anyway. ;)

croportal 04-07-2012 09:53 AM

Default Style for Old Mobile Browsers
Select the default mobile style for old mobile browsers. This style will be used if user is browsing your forum with an older mobile browser. Set to 'None' to use desktop browser style.

Default Style for Modern Mobile Browsers
Select the default mobile style for modern mobile browsers. This style will be used if user is browsing your forum with a modern mobile browser. Set to 'None' to use desktop browser style.

you have this option in admincp

Boofo 04-07-2012 10:16 AM

That still doesn't explain how they are selected on login.

Pandemikk 04-07-2012 01:11 PM

There was some merit in checking around init_start. ;)

Code:

// Test mobile browser
$mobile_browser = false;
$mobile_browser_advanced = false;
if ($vbulletin->options['mobilestyleid_advanced'] OR $vbulletin->options['mobilestyleid_basic'])
{
    if (stripos($_SERVER['HTTP_USER_AGENT'], 'windows') === false OR preg_match('/(Windows Phone OS)/i', strtolower($_SERVER['HTTP_USER_AGENT'])))
    {
        if (
            preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|Windows Phone OS)/i', strtolower($_SERVER['HTTP_USER_AGENT']))
            OR
            stripos($_SERVER['HTTP_ACCEPT'],'application/vnd.wap.xhtml+xml') !== false
            OR
            ((isset($_SERVER['HTTP_X_WAP_PROFILE']) OR isset($_SERVER['HTTP_PROFILE'])))
            OR
            stripos($_SERVER['ALL_HTTP'],'OperaMini') !== false
        )
        {
            $mobile_browser = true;
        }
        // This array is big and may be bigger later on. So we move it to a second if.
        else if (in_array(
                    strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4)),
                    array(
                    'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
                    'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
                    'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
                    'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
                    'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
                    'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
                    'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
                    'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
                    'wapr','webc','winw','winw','xda ','xda-')
                )
            )
        {
            $mobile_browser = true;
            if(strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4)) == 'oper' AND  preg_match('/(linux|mac)/i', $_SERVER['HTTP_USER_AGENT']))
            {
                $mobile_browser = false;
            }
        }
    }

    if (
        $mobile_browser
            AND
        preg_match('/(ipad|ipod|iphone|blackberry|android|pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine|Windows Phone OS)/i', strtolower($_SERVER['HTTP_USER_AGENT']))
    )
    {
        $mobile_browser_advanced = true;
    }
}



All times are GMT. The time now is 08:10 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.01133 seconds
  • Memory Usage 1,739KB
  • 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
  • (1)bbcode_code_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
  • (10)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