Jump to content

HDD Recognition on web app


Guest TostiXXX

Recommended Posts

Guest TostiXXX

I'm building a webapp that needs te recognize the harddisk in the clients computer, and I need to look if the harddisk exist in the database and if not I need to add it. The last part is not hard at all. I already found a solution for this problem, but I was wondering if there is a better example. The solution I'm using makes use of jscript and php and of course html but it will only work within internet explorer.This is what I thought of.My jscript to determine the serial number of the hdd:

 function DetermineSerialNumberHDD() {  var browser=navigator.appName;  if(browser=="Microsoft Internet Explorer")   {    var locator = new ActiveXObject ("WbemScripting.SWbemLocator");    var strServer = "";    var service = locator.ConnectServer(strServer);    var properties = service.ExecQuery("SELECT * FROM Win32_LogicalDisk");    var e = new Enumerator (properties);    for (;!e.atEnd();e.moveNext ())    {      var p = e.item ();      var description = p.Description;      if(description == "Local Fixed Disk")     {     var serial = p.VolumeSerialNumber;  return(serial);   }    }  }  else    alert("Use Internet Exploder");}

This is the file that sends the jscript variable to a php file:

<html>  <head>    <title> HDD Recognition </title>  </head>  <body>	<script src="DetermineSerialNumberHdd.js"></script>	<form name="invicibleform" action="inputphpvar.php" method="post">   <input type="text" name="jscript2phpvar" value="">   <input type="submit" name="submitjscript2phpvar" value="submit">	</form>	<script LANGUAGE="javascript">      var j2php = DetermineSerialNumberHDD();      document.invicibleform.jscript2phpvar.value = j2php;    </SCRIPT>  </body></html>

This is the file that gets the form variable and should send to the database.

 <html>  <head>  </head>  <body>    <?php      $jscriptvar = $_POST[jscript2phpvar];	?>	<h1> "<?php echo $jscriptvar; ?>" </h1>		<?php	// Check variable if exists in db    	// If not exists upload variable in dbase	?>  </body></html>

I know there are other ways to send jscript variables to php variables but I don't know how yet, maybe you guys know a good way to go.I'll explain my solution, first I use the DetermineCoords() function that uses the WMI class, which can do stuff with local drives, so I check for hdd's and then I check the serial and return the serial number.I then pass the serial number in the form and the form sends it to the php which then can be uploaded to the database.My question is, is there a better way to pass jscript variables to php variables, and is there a better way to identify local harddrives. because this method works only in internet explorer.

Link to comment
Share on other sites

right as I read that I thought "he'll need an ActiveX thing" which is what you have... other browsers don't generally let servers that deep into a user's computer, so I don't know of another way to do that. Does Flash have that kind of capabilties? If not flash, maybe you could build a plug-in for firefox... that's the only way I can think of.And for Opera users... Jonas? Any ideas?Also, obviously this will only work for Windows computers (IE) but a FF plug-in will need to work with other OSs as well.

Link to comment
Share on other sites

right as I read that I thought "he'll need an ActiveX thing" which is what you have... other browsers don't generally let servers that deep into a user's computer, so I don't know of another way to do that. Does Flash have that kind of capabilties? If not flash, maybe you could build a plug-in for firefox... that's the only way I can think of.And for Opera users... Jonas? Any ideas?Also, obviously this will only work for Windows computers (IE) but a FF plug-in will need to work with other OSs as well.

Flash has no server side abilities...I don't know about it's client side abilities. Flash relies on a server side language to be the middle man between flash and the database, I imagine it would be the case when accessing computer files/folders, etc.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...