Zend - The PHP Company




HTTP

Add Code


WAP and WEB TV redirect  

Type: application
Added by: navex
Entered: 19/08/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 10451
This top lines inserted in index.php preserves the same URL to WAP, WEB TV or traditional browsers users. Example: Instead of http://nave.net/wap , http://nave.net/webtv and http://nave.net ,all users goes to http://nave.net with any browser and be redirected to correct patch.


<?php

##This top lines inserted in index.php preserves the same URL
#to WAP, WEB TV or traditional browsers users.
#Example:
#Instead of http://nave.net/wap , http://nave.net/webtv and http://nave.net ,
#all users goes to http://nave.net with any browser... until another new 
#technology appears... If this happens, few changes in this code maybe solve.

#This code is a hard modification of another that I copied from somebody and 
#stored months ago. Sorry but I cannot give the correct credit for now.


#Tell me if works fine. Improves are welcome.
#php@nave.net - Omar Ballabio

#Functional example in http://nave.net/lab/useragent.php

    
$status=     "HTML" ;
       
$ext=        substr($REQUEST_URI,-3,3);
       
$agent=     strtolower(trim($HTTP_USER_AGENT));
       
$browser=      substr($agent,0,4);
    
$tviwer=    substr(stristr($agent tv),0,2);
    
$wapviwer=    substr(stristr($agent wap),0,3);

   if(    
$ext==        "wml"   ||
          
$wapviwer==    "wap"     ||
          
$browser==    "noki"     ||
          
$browser==    "eric"     ||
          
$browser==    "r380"     ||
          
$browser==    "up.b"     ||
          
$browser==    "winw"     ||
          
$browser==    "wapa"
##For redirect WAP users to "yourWAPfile.wml"
##Replace ("../wap/index.wml") to ("yourWAPfile.wml").
        
{$status"WAP" ;
         
header("Content-type: text/vnd.wap.wml");
                include 
"../wap/index.wml";}
else

    
    if(    
$tviwer== "tv")
##For redirect WEB TV users to "yourWEBTVfile.htm"
##Replace ($status= "TV") to (include "yourWEBTVfile.htm").
        
{$status"TV" ;}
else
##For redirect HTML users to "yourHTMLfile.htm"
##Replace ($status= "HTML") to (include "yourHTMLfile.htm").
        
{$status"HTML" ;}

?>

<P>
HTTP_USER_AGENT:     <?PHP echo $HTTP_USER_AGENT ?>
<br>
STATUS:             <?PHP echo $status ?>
<p>


Usage Example


See the example


Rate This Script





Search



This Category All Categories