Regexp pour déterminer le type de navigateur
Bonjour à tous !
Voilà j'ai était obligé de passer en PHP5 pour mettre du xml à jour avec du php en utilisant le DOM.
Mais depuis j'ai un problème avec un script PHP servant à rediriger le visiteur selon s'il utilise un "Smartphone" ou un ordinateur (le script ne redirige plus lorsque l'on y va avec un ordi :cry:).
Voilà le script utilisé (qui fonctionne très bien en PHP4 !) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <?php
if(checkmobile())
header('Location:http://www.eternal-graphic.com/mobile/m_detect_lang.php');
function checkmobile()
{
if (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE']))
return true;
if (isset ($_SERVER['HTTP_ACCEPT']))
{
$accept = strtolower($_SERVER['HTTP_ACCEPT']);
if (strpos($accept, 'wap') !== false)
return true;
}
if (isset ($_SERVER['HTTP_USER_AGENT']))
{
if (strpos ($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false)
return true;
if (strpos ($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false)
return true;
if (preg_match('#Android|BlackBerry|Cellphone|iPhone|iPod|hiptop|HTC|MIDP-2\.|MMEF20|MOT-V|NetFront|Newt|Nintendo Wii|Nintendo DS|Nitro|Nokia|Opera Mobi|Palm|PlayStation Portable|PSP|portalmmm|SonyEricsson|Symbian|UP.Browser|UP.Link|webOS|Windows CE|WinWAP|YahooSeeker/M1A1-R2D2|LGE VX|Maemo|phone)#', $_SERVER['HTTP_USER_AGENT']))
return true;
}
header('Location: http://www.eternal-graphic.com/computer ... _lang.php');
}
?> |
Voilà le msg sur la page : 8O
Citation:
Warning: preg_match() [function.preg-match]: Compilation failed: unmatched parentheses at offset 280 in /homepages/39/d299682238/htdocs/eternal-graphic/index.php on line 26
Warning: Cannot modify header information - headers already sent by (output started at /homepages/39/d299682238/htdocs/eternal-graphic/index.php:26) in /homepages/39/d299682238/htdocs/eternal-graphic/index.php on line 30
...pour voir de vous même : http://www.eternal-graphic.com
Un grand merci d'avance à ceux qui pourront m'aider !
...