5
Contributors
9
Replies
10
Views
5 Years
Discussion Span
Last Post by gacoekchip.pokher
0

How to get harddisk serial number and motherboard serial number using php?.

On your server perhaps with an exec call to some linux function (if you set priviliges correctly). On the client, not possible.

0

Get Harddisk Serial number from localhost

<?php

function GetVolumeLabel($drive) {
  // Try to grab the volume name
  if (preg_match('#Volume Serial Number is (.*)\n#i', shell_exec('dir '.$drive.':'), $m)) {
    $volname = ' ('.$m[1].')';
  } else {
    $volname = '';
  }
return $volname;
}

$serial =  str_replace("(","",str_replace(")","",GetVolumeLabel("c")));

echo $serial;

?>

Edited by gacoekchip.pokher

1

If the server is under linux you can use dmidecode for the motherboard serial:

sudo dmidecode --type 2 |grep -i serial

For the harddisk use hdparm:

sudo hdparm -I /dev/sda | grep -i serial

this will check for the serial of the master hd, for slaves you have to check for sdb, sdc... in any case, with both commands, you need to provide a password or you have to add the Apache user to the admin group which, for security reasons, it is never a great idea.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.