Systeme d'exploitation
jeremyguyot
Messages postés
77
Statut
Membre
-
jeremyguyot Messages postés 77 Statut Membre -
jeremyguyot Messages postés 77 Statut Membre -
Bonjour,
Je recherche un script qui va me permétre d'afficher quel os utilise un visiteur exemple:
votre systeme d'exploitation est: "Linux"
ou s'il utilise windows:
votre systeme d'exploitation est: "Windows 98"
votre systeme d'exploitation est: "Windows 2000"
votre systeme d'exploitation est: "Windows xp"
votre systeme d'exploitation est: "Windows Vista"
votre systeme d'exploitation est: "Windows 7"
votre systeme d'exploitation est: "Mac"
votre systeme d'exploitation est: "Linux"
Je recherche un script qui va me permétre d'afficher quel os utilise un visiteur exemple:
votre systeme d'exploitation est: "Linux"
ou s'il utilise windows:
votre systeme d'exploitation est: "Windows 98"
votre systeme d'exploitation est: "Windows 2000"
votre systeme d'exploitation est: "Windows xp"
votre systeme d'exploitation est: "Windows Vista"
votre systeme d'exploitation est: "Windows 7"
votre systeme d'exploitation est: "Mac"
votre systeme d'exploitation est: "Linux"
A voir également:
- Systeme d'exploitation
- Restauration systeme windows 10 - Guide
- Vérificateur des fichiers système - Guide
- Comment connaitre son système d'exploitation - Guide
- Vous avez besoin d'une autorisation de la part de système pour modifier ce dossier - Guide
- Systeme binaire - Guide
9 réponses
Tu peux le savoir en utilisant la variable $_SERVER['HTTP_USER_AGENT'] en PHP.
Exemple de résultat:
A toi ensuite de combiner ça avec un script qui te permettra de décomposer ce résultat et d'en extraire les données en utilisant preg_match par exemple.
Exemple de résultat:
Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.17) Gecko/2010010604 Ubuntu/9.04 (jaunty) Firefox/3.0.17
A toi ensuite de combiner ça avec un script qui te permettra de décomposer ce résultat et d'en extraire les données en utilisant preg_match par exemple.
<?php
// This script sets OSName variable as follows:
// "Windows" for all versions of Windows
// "MacOS" for all versions of Macintosh OS
// "Linux" for all versions of Linux
// "UNIX" for all other UNIX flavors
// "Unknown OS" indicates failure to detect the OS
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);
?>
merci avion !
il faut le placer dans body ?
// This script sets OSName variable as follows:
// "Windows" for all versions of Windows
// "MacOS" for all versions of Macintosh OS
// "Linux" for all versions of Linux
// "UNIX" for all other UNIX flavors
// "Unknown OS" indicates failure to detect the OS
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);
?>
merci avion !
il faut le placer dans body ?
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
C'est du Javascript, pas du PHP.
<script type="text/javascript">
// <![CDATA[
var OSName = "Unknown OS";
if(navigator.appVersion.indexOf("Win") != -1) OSName = "Windows";
if(navigator.appVersion.indexOf("Mac") != -1) OSName = "MacOS";
if(navigator.appVersion.indexOf("X11") != -1) OSName = "UNIX";
if(navigator.appVersion.indexOf("Linux") != -1) OSName = "Linux";
document.write('Your OS: ' + OSName);
// ]]>
</script>À mettre la où tu veux voir le texte s'afficher.
c'est bon j'ai trouver ;)
Le code:
<script language="JavaScript">
<!--
// This script sets OSName variable as follows:
// "Windows" for all versions of Windows
// "MacOS" for all versions of Macintosh OS
// "Linux" for all versions of Linux
// "UNIX" for all other UNIX flavors
// "Unknown OS" indicates failure to detect the OS
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);
//-->
</script>
Merci avion
Le code:
<script language="JavaScript">
<!--
// This script sets OSName variable as follows:
// "Windows" for all versions of Windows
// "MacOS" for all versions of Macintosh OS
// "Linux" for all versions of Linux
// "UNIX" for all other UNIX flavors
// "Unknown OS" indicates failure to detect the OS
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);
//-->
</script>
Merci avion
Pour finir quand même l'idée que j'avais lancé, voici un vieux code que j'utilisais pendant un temps:
C'est le même principe que ce que j'ai expliqué précédemment.
if (ereg("Win", getenv("HTTP_USER_AGENT")))
$os = "Windows";
elseif ((ereg("Mac", getenv("HTTP_USER_AGENT"))) || (ereg("PPC", getenv("HTTP_USER_AGENT"))))
$os = "Mac";
elseif (ereg("Linux", getenv("HTTP_USER_AGENT")))
$os = "Linux";
elseif (ereg("FreeBSD", getenv("HTTP_USER_AGENT")))
$os = "FreeBSD";
elseif (ereg("SunOS", getenv("HTTP_USER_AGENT")))
$os = "SunOS";
elseif (ereg("IRIX", getenv("HTTP_USER_AGENT")))
$os = "IRIX";
elseif (ereg("BeOS", getenv("HTTP_USER_AGENT")))
$os = "BeOS";
elseif (ereg("OS/2", getenv("HTTP_USER_AGENT")))
$os = "OS/2";
elseif (ereg("AIX", getenv("HTTP_USER_AGENT")))
$os = "AIX";
else
$os = "Autre";
echo $os;
C'est le même principe que ce que j'ai expliqué précédemment.
;) sinon si c'est pas tro demander j'aimerait faire fonctionner maintenant un lien dans la détéction
if (navigator.appVersion.indexOf("Win")!=-1) OSName="<a target="_blanck"href="liendunsite"title=letitre">Windows </a> ";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);
//-->
</script>
et la couleur ne fonctionnent pas aussi quand je veut la changer ;)
Merci beaucoup
if (navigator.appVersion.indexOf("Win")!=-1) OSName="<a target="_blanck"href="liendunsite"title=letitre">Windows </a> ";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
document.write('Your OS: '+OSName);
//-->
</script>
et la couleur ne fonctionnent pas aussi quand je veut la changer ;)
Merci beaucoup