Click here to Skip to main content
15,886,026 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
Questionbest way to determine mobile device Pin
Jassim Rahma19-Dec-11 0:24
Jassim Rahma19-Dec-11 0:24 
AnswerRe: best way to determine mobile device Pin
User 171649219-Dec-11 0:57
professionalUser 171649219-Dec-11 0:57 
AnswerRe: best way to determine mobile device Pin
Mohibur Rashid19-Dec-11 18:00
professionalMohibur Rashid19-Dec-11 18:00 
GeneralRe: best way to determine mobile device Pin
Jassim Rahma19-Dec-11 21:43
Jassim Rahma19-Dec-11 21:43 
GeneralRe: best way to determine mobile device Pin
Gerben Jongerius19-Dec-11 22:30
Gerben Jongerius19-Dec-11 22:30 
GeneralRe: best way to determine mobile device Pin
Jassim Rahma20-Dec-11 1:19
Jassim Rahma20-Dec-11 1:19 
GeneralRe: best way to determine mobile device Pin
Gerben Jongerius20-Dec-11 1:40
Gerben Jongerius20-Dec-11 1:40 
GeneralRe: best way to determine mobile device Pin
Jassim Rahma20-Dec-11 2:07
Jassim Rahma20-Dec-11 2:07 
I am now getting this error:
Parse error: syntax error, unexpected T_VARIABLE in /home/jassimrahma/JassimRahma.com/detection.php on line 4


this is what I put in my index.php 1st line:

C#
<?php
    include_once('detection.php');
    if (detect_mobile()) {
    header('Location: http://m.jassimrahma.com');
    }
?>


and detection.php is here:

VB
<?php
    function detect_mobile()
    {
        $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : '';

        $mobile_browser = '0';

        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);

        if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', $agent))
            $mobile_browser++;

        if((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') !== false))
            $mobile_browser++;

        if(isset($_SERVER['HTTP_X_WAP_PROFILE']))
            $mobile_browser++;

        if(isset($_SERVER['HTTP_PROFILE']))
            $mobile_browser++;

        $mobile_ua = substr($agent,0,4);
        $mobile_agents = 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','xda','xda-'
                            );

        if(in_array($mobile_ua, $mobile_agents))
            $mobile_browser++;

        if(strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false)
            $mobile_browser++;

        // Pre-final check to reset everything if the user is on Windows
        if(strpos($agent, 'windows') !== false)
            $mobile_browser=0;

        // But WP7 is also Windows, with a slightly different characteristic
        if(strpos($agent, 'windows phone') !== false)
            $mobile_browser++;

        if($mobile_browser>0)
            return true;
        else
            return false;
    }
?>

GeneralRe: best way to determine mobile device Pin
Jassim Rahma20-Dec-11 3:21
Jassim Rahma20-Dec-11 3:21 
AnswerRe: best way to determine mobile device Pin
Mohibur Rashid19-Dec-11 22:47
professionalMohibur Rashid19-Dec-11 22:47 
QuestionLinux Back Track 5 Pin
HARISHCHOWDHARY18-Dec-11 20:40
HARISHCHOWDHARY18-Dec-11 20:40 
AnswerRe: Linux Back Track 5 PinPopular
Richard MacCutchan18-Dec-11 23:36
mveRichard MacCutchan18-Dec-11 23:36 
QuestionHow to configure email system in xampp server Pin
VickyVicki16-Dec-11 1:41
VickyVicki16-Dec-11 1:41 
AnswerRe: How to configure email system in xampp server Pin
Aniruddha Loya19-Dec-11 8:29
Aniruddha Loya19-Dec-11 8:29 
GeneralRe: How to configure email system in xampp server Pin
VickyVicki24-Dec-11 0:02
VickyVicki24-Dec-11 0:02 
GeneralRe: How to configure email system in xampp server Pin
Aniruddha Loya24-Dec-11 7:48
Aniruddha Loya24-Dec-11 7:48 
QuestionEditor for php Pin
VickyVicki15-Dec-11 6:17
VickyVicki15-Dec-11 6:17 
AnswerRe: Editor for php Pin
User 171649215-Dec-11 6:50
professionalUser 171649215-Dec-11 6:50 
GeneralRe: Editor for php Pin
VickyVicki16-Dec-11 1:38
VickyVicki16-Dec-11 1:38 
GeneralRe: Editor for php Pin
User 171649216-Dec-11 4:00
professionalUser 171649216-Dec-11 4:00 
GeneralRe: Editor for php Pin
VickyVicki17-Dec-11 19:25
VickyVicki17-Dec-11 19:25 
AnswerRe: Editor for php Pin
sephirot4721-Dec-11 20:26
sephirot4721-Dec-11 20:26 
QuestionReading Mails using PHP Pin
anudivya13-Dec-11 23:11
anudivya13-Dec-11 23:11 
AnswerRe: Reading Mails using PHP Pin
Kevin Schaefer3-Jan-12 12:19
Kevin Schaefer3-Jan-12 12:19 
Questioncreating webmail script using php Pin
anudivya12-Dec-11 21:29
anudivya12-Dec-11 21:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.