Pages: 1 [2]   Go Down
Send this topic | Print
Author Topic: Using a Normal Site and a Mobile Site  (Read 1121 times)
robleyd
Official 110mb Guru
********
Online Online

Posts: 5700

Ask before you PM


« Reply #20 on: September 19, 2008, 10:46:27 AM »

Pasting exactly that into my development server here and calling it from another page didn't throw an error. Perhaps that is not exactly what you have on your site?
Logged

I once had a hard drive clunk-clicking
Strange noises, weird sounds and tick-ticking
I thought I would wait
And procrastinate...
But now all my data is missing
--------------
dd, a dump, a data dump
read a line from standard in
$USER, the name I call my self
make - a long long time to run
.so a library that is shared
.ko it's not the same as .so
tee, a redirect with in and out
and brings us back to dd d d d
codewhite
Advanced Authority Member
*****
Online Online

Posts: 1340


Violent Patient


WWW
« Reply #21 on: September 19, 2008, 10:50:43 AM »

Pasting exactly that into my development server here and calling it from another page didn't throw an error. Perhaps that is not exactly what you have on your site?

Thank you, I'm glad I'm not the only one who's got it running with no problems here.
Logged


I am a signature virus, copy me to your signature to spread me <Generation 0>
Increase Generation number each time I'm copied.
Codewhite Designs Cigar Journal On sale now.
michaellindahl
Member
*
Offline Offline

Posts: 17


WWW
« Reply #22 on: September 19, 2008, 11:06:54 AM »

Pasting exactly that into my development server here and calling it from another page didn't throw an error. Perhaps that is not exactly what you have on your site?

Thank you, I'm glad I'm not the only one who's got it running with no problems here.

I am using TextWrangler on a Mac, and have no upgrades on my account...
Logged
robleyd
Official 110mb Guru
********
Online Online

Posts: 5700

Ask before you PM


« Reply #23 on: September 19, 2008, 11:18:00 AM »

The point I am making is that the code you showed works for me, but the code you have on your website doesn't work. Therefore, there is a difference.
Logged

I once had a hard drive clunk-clicking
Strange noises, weird sounds and tick-ticking
I thought I would wait
And procrastinate...
But now all my data is missing
--------------
dd, a dump, a data dump
read a line from standard in
$USER, the name I call my self
make - a long long time to run
.so a library that is shared
.ko it's not the same as .so
tee, a redirect with in and out
and brings us back to dd d d d
Myles Grey
Full-Time Programmer
Super Authority member
******
Offline Offline

Posts: 1863


Programmer's Delight Release - 90%


WWW
« Reply #24 on: September 19, 2008, 11:24:45 AM »

Well as far as I'm aware that line isn't all that important anyway, so try this:

Code:
<?php
function ismobile(){
  
// check if the user agent gives away any tell tale signs it's a mobile browser
  
if(eregi('up.browser|up.link|windows ce|iemobile|mini|mmp|symbian|midp|wap|phone|pocket|mobile|pda|psp|N70|S60|S40|S80|S90',$_SERVER['HTTP_USER_AGENT'])){
    return
true;
  }
  
// check the http accept header to see if wap.wml or wap.xhtml support is claimed
  
if(stristr($_SERVER['HTTP_ACCEPT'],'text/vnd.wap.wml')||stristr($_SERVER['HTTP_ACCEPT'],'application/vnd.wap.xhtml+xml')){
    return
true;
  }
  
// check if there are any tell tales signs it's a mobile device from the _server headers
  
if(isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])||isset($_SERVER['X-OperaMini-Features'])||isset($_SERVER['UA-pixels'])){
    return
true;
  }
  
// build an array with the first four characters from the most common mobile user agents
  
$a = array(
                    
'acs-'=>'acs-',
                    
'alav'=>'alav',
                    
'alca'=>'alca',
                    
'amoi'=>'amoi',
                    
'audi'=>'audi',
                    
'aste'=>'aste',
                    
'avan'=>'avan',
                    
'benq'=>'benq',
                    
'bird'=>'bird',
                    
'blac'=>'blac',
                    
'blaz'=>'blaz',
                    
'brew'=>'brew',
                    
'cell'=>'cell',
                    
'cldc'=>'cldc',
                    
'cmd-'=>'cmd-',
                    
'dang'=>'dang',
                    
'doco'=>'doco',
                    
'eric'=>'eric',
                    
'hipt'=>'hipt',
                    
'inno'=>'inno',
                    
'ipaq'=>'ipaq',
                    
'java'=>'java',
                    
'jigs'=>'jigs',
                    
'kddi'=>'kddi',
                    
'keji'=>'keji',
                    
'leno'=>'leno',
                    
'lg-c'=>'lg-c',
                    
'lg-d'=>'lg-d',
                    
'lg-g'=>'lg-g',
                    
'lge-'=>'lge-',
                    
'maui'=>'maui',
                    
'maxo'=>'maxo',
                    
'midp'=>'midp',
                    
'mits'=>'mits',
                    
'mmef'=>'mmef',
                    
'mobi'=>'mobi',
                    
'mot-'=>'mot-',
                    
'moto'=>'moto',
                    
'mwbp'=>'mwbp',
                    
'nec-'=>'nec-',
                    
'newt'=>'newt',
                    
'noki'=>'noki',
                    
'opwv'=>'opwv',
                    
'palm'=>'palm',
                    
'pana'=>'pana',
                    
'pant'=>'pant',
                    
'pdxg'=>'pdxg',
                    
'phil'=>'phil',
                    
'play'=>'play',
                    
'pluc'=>'pluc',
                    
'port'=>'port',
                    
'prox'=>'prox',
                    
'qtek'=>'qtek',
                    
'qwap'=>'qwap',
                    
'sage'=>'sage',
                    
'sams'=>'sams',
                    
'sany'=>'sany',
                    
'sch-'=>'sch-',
                    
'sec-'=>'sec-',
                    
'send'=>'send',
                    
'seri'=>'seri',
                    
'sgh-'=>'sgh-',
                    
'shar'=>'shar',
                    
'sie-'=>'sie-',
                    
'siem'=>'siem',
                    
'smal'=>'smal',
                    
'smar'=>'smar',
                    
'sony'=>'sony',
                    
'sph-'=>'sph-',
                    
'symb'=>'symb',
                    
't-mo'=>'t-mo',
                    
'teli'=>'teli',
                    
'tim-'=>'tim-',
                    
'tosh'=>'tosh',
                    
'treo'=>'treo',
                    
'tsm-'=>'tsm-',
                    
'upg1'=>'upg1',
                    
'upsi'=>'upsi',
                    
'vk-v'=>'vk-v',
                    
'voda'=>'voda',
                    
'wap-'=>'wap-',
                    
'wapa'=>'wapa',
                    
'wapi'=>'wapi',
                    
'wapp'=>'wapp',
                    
'wapr'=>'wapr',
                    
'webc'=>'webc',
                    
'winw'=>'winw',
                    
'winw'=>'winw',
                    
'xda-'=>'xda-'
                  
);
  
// check if the first four characters of the current user agent are set as a key in the array
  
if(isset($a[substr($_SERVER['HTTP_USER_AGENT'],0,4)])){
    return
true;
  }
}
?>

Logged

IE has the best Quirks
Almost every site you see runs on Quirks, not standards




Remember to mark your topic as [resolved]
codewhite
Advanced Authority Member
*****
Online Online

Posts: 1340


Violent Patient


WWW
« Reply #25 on: September 19, 2008, 11:36:02 AM »

The point I am making is that the code you showed works for me, but the code you have on your website doesn't work. Therefore, there is a difference.

(S)He had me take a look at the code on the server, I couldn't see anything wrong, but I uploaded a copy of the working code from my test server and it's working now.  So this should be considered resolved until (s)he tests the code with either a mobile browser or a user-agent faker.
Logged


I am a signature virus, copy me to your signature to spread me <Generation 0>
Increase Generation number each time I'm copied.
Codewhite Designs Cigar Journal On sale now.
michaellindahl
Member
*
Offline Offline

Posts: 17


WWW
« Reply #26 on: September 19, 2008, 11:45:54 AM »

The point I am making is that the code you showed works for me, but the code you have on your website doesn't work. Therefore, there is a difference.

He had me take a look at the code on the server, I couldn't see anything wrong, but I uploaded a copy of the working code from my test server and it's working now.  So this should be considered resolved until he tests the code with either a mobile browser or a user-agent faker.

I'm a he(michael, and pic of me on website) but I think that the app that I use to make the php file doesn't like php files, and i have faked the user agent to be an iphone, and it doesn't work I can't really tell why because it switches to fast


Okay I say this topic is over because I give up.  I cannot make php files that will work but for future reference if you can make php files that work, this solution stated in the post above work...
« Last Edit: September 19, 2008, 11:50:23 AM by michaellindahl » Logged
aed
Oh My Goddess
Hyper-Active Member
***
Offline Offline

Posts: 130


-------------------


WWW
« Reply #27 on: September 19, 2008, 03:06:43 PM »

You should change this code on your page

Quote
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
require_once "ismobile.php";
if (ismobile() == true) {
header("location: http://michaellindahl.com/m/");
 exit;
}
?>

to this

Quote
<?php
ob_start();
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
require_once "ismobile.php";
if (ismobile() == true) {
header("location: http://michaellindahl.com/m/");
 exit;
}
?>

what i added is the ob_Start() since header(); will not work if you already sent a data to the browser that is the

Code:
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

in your code it is also better if you write it this way if you dont want to add the ob_Start() in your code

Quote
<?php
require_once "ismobile.php";
if (ismobile() == true)
{
 header("location: http://michaellindahl.com/m/");
 exit;
}
?>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

make sure also that there are no whitespaces before the first character of your script...
« Last Edit: September 19, 2008, 03:08:55 PM by aed » Logged
M0ZZA
A Man In A Trance...
Loyal 110MB Member
*******
Online Online

Posts: 2551


So yeah, I would like to be a moderator.


WWW
« Reply #28 on: September 19, 2008, 07:28:23 PM »

I have a feeling that the program you are using is not the right program for writing PHP files, it is probably adding certain things you do not want, when you save the file
Logged

michaellindahl
Member
*
Offline Offline

Posts: 17


WWW
« Reply #29 on: September 19, 2008, 09:46:57 PM »

I have a feeling that the program you are using is not the right program for writing PHP files, it is probably adding certain things you do not want, when you save the file

Yea my program, TextWrangler on the Mac, works fine with HTML but when I changed it to .php it might have an issue with that...
Logged
Pages: 1 [2]   Go Up
Send this topic | Print
Jump to: