Source: lesson_19_c0_environment.php | Résultat |
<?php echo "Variables d'environnement non modifiables : <br/>"; echo "Contenu de HTTP_USER_AGENT : <br/>$_SERVER[HTTP_USER_AGENT]\n"; echo "<br/><br/>Navigateur : <br/>"; echo ckbrowser(); echo "<br/><br/>Système d'exploitation : <br/>"; echo ckos(); //---------------F O N C T I O N S---------------- function ckos() { $so = $_SERVER['HTTP_USER_AGENT']; $windowsxp = preg_match("/windows nt 5.1/i", $so); $windowsxp2 = preg_match("/windows xp/i", $so); $linux = preg_match("/linux/i", $so); $windowsme = preg_match("/win 9x 4.90/i", $so); $windowsme2 = preg_match("/windows me/i", $so); $windows2k = preg_match("/windows nt 5.0/i", $so); $windows2kb = preg_match("/windows 2000/i", $so); $windowsnt = preg_match("/windows nt 3.1/i", $so); $windowsnt2 = preg_match("/windows nt 3.5.0/i", $so); $windowsnt3 = preg_match("/windows nt 3.5.1/i", $so); $windowsnt4 = preg_match("/windows nt 4.0/i", $so); $windows98 = preg_match("/windows 98/i", $so); $windows95 = preg_match("/windows 95/i", $so);
if ($windowsxp == 1 or $windowsxp2 == 1) { $sys = "Windows XP"; } else if ($linux == 1) { $sys = "Linux"; } else if ($windowsme == 1 or $windowsme2 == 1) { $sys = "Windows ME"; } else if ($windows2k == 1 or $windows2kb == 1) { $sys = "Windows 2000"; } else if ($windowsnt == 1 or $windowsnt2 == 1 or $windowsnt3 == 1 or $windowsnt4 == 1) { $sys = "Windows NT"; } else if ($windows98 == 1 and $windowsme != 1) { $sys = "Windows 98"; } else if ($windows95 == 1) { $sys = "Windows 95"; } else { $sys = "Not identified"; }
return($sys);
}
//---------------------------------------------------- function ckbrowser() {
$b = $_SERVER['HTTP_USER_AGENT']; $ie40 = preg_match("/MSIE 4.0/i", $b); $ie50 = preg_match("/MSIE 5.0/i", $b); $ie55 = preg_match("/MSIE 5.5/i", $b); $ie60 = preg_match("/MSIE 6.0/i", $b); $opera = preg_match("/opera/i", $b);
if ($ie40 == 1) { $browser = "Internet Explorer 4.0"; } else if ($ie50 == 1) { $browser = "Internet Explorer 5.0"; } else if ($ie55 == 1) { $browser = "Internet Explorer 5.5"; } else if ($ie60 == 1) { $browser = "Internet Explorer 6.0"; } else if ($opera == 1) { $browser = "Opera"; } else { $browser = "Not identified"; }
return($browser);
} ?>
| Variables d'environnement non modifiables : Contenu de HTTP_USER_AGENT : Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Navigateur : Not identified
Système d'exploitation : Not identified
|