Browser Coding Option

Started on the old forum in June 2007 · view the original in the archive · old links redirect here

19 replies · 1,318 views · started 19 years ago · 1 min read

5 participants
Guest #1

i am looking for a script that find the browser that a user is using then select a view to it. Whether its wml or html. any help

phoenix90 Developer · 113 posts #2

For wich of the following, Lavalair/RW/Funmobile??

amylee Principal · 1,092 posts #3

all the same

Guest #4

all the same

it doesn/t matter.... for any script i just want the code.

amylee Principal · 1,092 posts #5

im a bit confused to what your asking for

Guest #6

ok let see if i can explain much clearer. There is a code that fine the browser a user using whether it can view in wml only or html.... for instants if i were to view a site but my browser can't view in html it would automatically view in wml....you can fine site live prodigits, twilightwap, mobile.itsmy.com and much more coded in that way.... its a multilingual interface, supporting both XHTML and WML outputs. The new lavalair script is also coded in that way.

chatabox Senior · 361 posts #8
<?php

//Configuration
global $userBrowser;

// Your wapsite
//enter the link you want user to be redirected in case of WML browser
$wmllink = "http://wap.yahoo.com/";

// Your website
//enter the link you want user to be redirected in case of PC browser
$htmllink = "http://www.google.com";

//There is no need to edit any information from this point on
//however in case if you want to contribute please do so
//please be sure to let me know about the changes
//Detect the browser
$userBrowser = $_SERVER['HTTP_USER_AGENT'];

//Remove the below // qutoes.
//It helps to check if there is any error when editing
//If everything is all right it will display the browser information
//please remember to put // back after testing or no redirection will occur
//echo $userBrowser;

//Check for Mozilla
if(stristr($userBrowser, 'Mozilla'))
{
  $ub="PC";
}
//Check for Mozilla
elseif(stristr($userBrowser, 'gecko'))
{
  $ub="PC";
}
//Check for opera
elseif(stristr($userBrowser, 'opera'))
{
  $ub="PC";
}
//Check for omniweb
elseif(stristr($userBrowser, 'omniweb'))
{
  $ub="PC";
}
//Check for msie
elseif(stristr($userBrowser, 'msie'))
{
  $ub="PC";
}
//Check for konqueror
elseif(stristr($userBrowser, 'konqueror'))
{
  $ub="PC";
}
//Check for safari
elseif(stristr($userBrowser, 'safari'))
{
  $ub="PC";
}
//Check for netpositive
elseif(stristr($userBrowser, 'netpositive'))
{
  $ub="PC";
}
//Check for lynx
elseif(stristr($userBrowser, 'lynx'))
{
  $ub="PC";
}
//Check for elinks
elseif(stristr($userBrowser, 'elinks'))
{
  $ub="PC";
}
//Check for Mozilla
elseif(stristr($userBrowser, 'Mozilla'))
{
  $ub="PC";
}
//Check for links
elseif(stristr($userBrowser, 'links'))
{
  $ub="PC";
}
//Check for w3m
elseif(stristr($userBrowser, 'w3m'))
{
  $ub="PC";
}
//Check for webtv
elseif(stristr($userBrowser, 'webtv'))
{
  $ub="PC";
}
//Check for amaya
elseif(stristr($userBrowser, 'amaya'))
{
  $ub="PC";
}
//Check for dillo
elseif(stristr($userBrowser, 'dillo'))
{
  $ub="PC";
}
//Check for ibrowse
elseif(stristr($userBrowser, 'ibrowse'))
{
  $ub="PC";
}
//Check for icab
elseif(stristr($userBrowser, 'icab'))
{
  $ub="PC";
}
//Check for crazy browser
elseif(stristr($userBrowser, 'crazy browser'))
{
  $ub="PC";
}
//Check for IE
elseif(stristr($userBrowser, 'internet explorer'))
{
  $ub="PC";
}
//If it's not any of the above browsers
//Then it gotta be a WML or very unpopular browser
else
{
  $ub="WML";
  }
//Code for redirecting based upon the results
if($ub == "PC") {
    header("Location: ".$htmllink);
    exit;
    }
    else
    {
    header("Location: ".$wmllink);
    exit;
    }
    
?>
GumSlone Administrator Principal · 1,690 posts #9
if (strpos(strtolower($_SERVER["HTTP_ACCEPT"]), "text/vnd.wap.wml") !== false) $wml_device = true;
else $wml_device = false;
if (strpos(strtolower($_SERVER["HTTP_ACCEPT"]), "text/html") !== false) $html_device = true;
else $html_device = false;

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Guest #10

Thanks guys i'll try these coding

Guest #11

i am not getting through with the code you give me Gumslone can you please give me an example index.php file using this code. or any user that can do so.

GumSlone Administrator Principal · 1,690 posts #13
if (strpos(strtolower($_SERVER["HTTP_ACCEPT"]), "text/vnd.wap.wml") !== false) $wml_device = true;
else $wml_device = false;
if (strpos(strtolower($_SERVER["HTTP_ACCEPT"]), "text/html") !== false) $html_device = true;
else $html_device = false;

if($wml_device&&!$html_device)
{
echo "Your browser supports only wml";
}
else if($wml_device&&$html_device)
{
echo "Your browser supports wml+html";
}
else echo "Probably you are using pc browser";

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Guest #16

the code is also in 2wap.net, bestTop.mobi,prodigits.co.uk, twilightwap.com,lavalair.net i am not sure if its in funmobile.ws, the code they are using is a multilingual interface, supporting both XHTML and WML outputs,

amylee Principal · 1,092 posts #17

what? you mean the option where a user can view the site in different languages? for example

http://lavalair.net/index.php?ln=af&op=

in afrikaan

http://lavalair.net/index.php?ln=sp&op=

in leet text

http://lavalair.net/index.php?ln=ar&op=

and in arabic

ot the option where a non wml browser trying to access a html page gets directed to a wml page?

Guest #18

Yes thats the code am looking for where a non wml browser trying to access a html page gets direted to the wml version page

what? you mean the option where a user can view the site in different languages? for example

http://lavalair.net/index.php?ln=af&op=

in afrikaan

http://lavalair.net/index.php?ln=sp&op=

in leet text

http://lavalair.net/index.php?ln=ar&op=

and in arabic

ot the option where a non wml browser trying to access a html page gets directed to a wml page?

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close