
09.01.2009, 16:19
|
|
Members of Antichat - Level 5
Регистрация: 09.05.2008
Сообщений: 304
Провел на форуме: 7875940
Репутация:
2362
|
|
Только как пример. Ниже кусок кода из своего старого скрипта:
PHP код:
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if(preg_match("!(Opera[\s\d\./]+)!msi", $agent, $math))
{
$agent = $math[1];
$mysqlAgent = "opera";
}
elseif(preg_match("!(Firefox[\s\d\./]+)!msi", $agent, $math))
{
$agent = $math[1];
$mysqlAgent = "firefox";
}
elseif (preg_match("!MSIE([\s\d\./]+)!msi", $agent, $math))
{
$agent = "Internet Explorer ".$math[1];
$mysqlAgent = "msie";
}
elseif (preg_match("!(Konqueror[\s\d\./]+)!msi", $agent, $math))
{
$agent = $math[1];
$mysqlAgent = "konqueror";
}
elseif (preg_match("!(Iceweasel[\s\d\./]+)!msi", $agent, $math))
{
$agent = $math[1];
$mysqlAgent = "iceweasel";
}
elseif (preg_match("!(Lynx[\s\d\./]+)!msi", $agent, $math))
{
$agent = $math[1];
$mysqlAgent = "lynx";
}
elseif (preg_match("!(Netscape[\s\d\./]+)!msi", $agent, $math))
{
$agent = $math[1];
$mysqlAgent = "netscape";
}
elseif (preg_match("!(Safari[\s\d\./]+)!msi", $agent, $math))
{
$agent = $math[1];
$mysqlAgent = "safari";
}
$location = "/";
switch($mysqlAgent)
{
case "opera": $location .= "opera/";break;
case "firefox": $location .= "firefox/";break;
case "msie": $location .= "msie/";break;
default: $location .= "msie/";break;
}
header('Location: '.$location);
?>
|
|
|