1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Convert PHP to ASP (small code)

Discussion in 'PHP' started by roice, Jul 4, 2010.

  1. #1
    Hello all,
    I need help with convertion PHP code to ASP -

    
    <?PHP
    $user_browser = strtolower($_SERVER["HTTP_USER_AGENT"]);
    echo "user_browser: $user_browser<br />";
    
        function check_for_mobile($user_browser){
    
            $mobile_browsers = array( 
    			'android',
                            'avantGo',
                            'blackBerry',
                         );
    
    
    
            foreach ($mobile_browsers as $browser) {
                if (strstr($user_browser, $browser)) {
                    return true;
                }
            }
            return false;
    
        }
    
    
    
    if(check_for_mobile($user_browser)){
    
    	///looks like a mobile ...
    
    }
    
    else {
    	echo "Regolar browser";
    }
    
    ?>
    PHP:
    Thanks in advance,
    Roi
     
    roice, Jul 4, 2010 IP
  2. Kaimi

    Kaimi Peon

    Messages:
    60
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <%
    dim ua 
    ua = Request.ServerVariables("HTTP_USER_AGENT")
    response.write("user_browser: " & ua & "<br />")
    
    function check_for_mobile(ua)
    	dim browsers
    	browsers = Array("android", "avantGo", "blackBerry")
    	for each item in browsers
    		if InStr(ua, item) > 0 then
    			check_for_mobile = 1
    			exit function
    		end if
    	next
    	
    	check_for_mobile = 0
    end function
    
    
    if check_for_mobile(ua) then
    	response.write("Mobile browser")
    else
    	response.write("Normal browser")
    end if
    
    %>
    
    Code (markup):
     
    Kaimi, Jul 4, 2010 IP
  3. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you very much
    I truly appreciate your help
     
    roice, Jul 4, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you're not sanitizing the user agent?
     
    krsix, Jul 4, 2010 IP