We were working on a mobile version of our site.
Some programmers put up this code on our normal non-mobile page. The result was that our site started to perform very slowly and bug out.
I’m thinking that the new mobile page may have had some bad code that was creating the issues, but I wanted to know if the code snippit put on our existing pages was problematic.
Here is is:
<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
if ($iphone || $android || $palmpre || $ipod || $berry == true)
{
header('Location: http://m.site.com/index.php?id='.$HTTP_GET_VARS["id"]);
//OR
//echo "<script>window.location='http://mobile.site.com'</script>";
}
Someone from our hosting company suggested that the code maybe should have ‘===’ instead of ‘==’ at the end of the if statement.
Does the code look problematic?
Thanks as always.
First of all, I reccomend you to re-write:
Also, some other notes, your URL is bad because I see it, and I already know how to hack your site. Read about XSS.
Do not use
$HTTP_GET_VARS.Do not use
$_REQUESTUse
$_GETor$_POSTinstead.