Page 1 of 1
how to check PC system of a visitor?
Posted: Mon Sep 19, 2005 10:51 am
by aaaphp000000
i need to do following process:
IF system is Windows, display a C++ COM control
ELSE
IF JRE is installed on the system, display a APPLET
ELSE
display error message
are there php functios which can help me to check and implement above process?
thanks
Posted: Mon Sep 19, 2005 11:04 am
by feyd
Windows detection, yes, JRE nope.
the user agent string will contain what OS the browser is running (most often) ... the data is unreliable however.
Posted: Mon Sep 19, 2005 11:06 am
by Jenk
The first part is quite easy
Code: Select all
<?php
if (strpos(PHP_OS, "WIN") !== false) {
/* enter code for displaying COM panel */
}
?>
The second part I would guess you'll need a JavaScript function to make the check, as I doubt the User Agent (browser) broadcasts that kind of information to the server (remember, PHP is server side and entirely depends upon the information the User Agent sends to the server)

Posted: Mon Sep 19, 2005 11:09 am
by feyd
Jenk, your code would detect if the server is a Windows machine... not the client

Posted: Mon Sep 19, 2005 12:01 pm
by jayshields
yeah and using double negatives is bad programming technique imo.
Posted: Mon Sep 19, 2005 5:15 pm
by Jenk
Dammit, I quickly copied and pasted from one of my own classes not thinking about it.
And using double negatives is NOT bad practice when challenging such criteria. Read up on PHP.net.
Fixed code:
Code: Select all
<?php
if (stripos('Win', $_SERVER['HTTP_USERAGENT']) !== false) {
/* do com bits */
}
?>