PhpSnip.com

User Stats

WAP and WEB TV redirect

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.

Info

 Download  View Source (print view)
 Rating : 4.7  Views : 481

Source Code ( 57 lines )

<?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>

Search

Subscribe

  Rss Feeds

Sponsors

Advertise