1

I was searching this question for a while, and i wanted to know if this is possible. I also saw other questions like this topic and i assume that you can't get the real ip.

But how about the computer's name, or something that is unique and is coming from each computer of the person, that is logging in my log in page.

For example i want to set maximum users 3 in my programm. If i could take the cpu name or something else i would be able to write code in order to know from which computer they are logging in and i also could set the 3 maximum users. Feel free to suggest other ideas in order to achieve that.

I have also tried this code which returns something like unique id from the disk of the pc..

function UniqueMachineID($salt = "") {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {

    $temp = sys_get_temp_dir().DIRECTORY_SEPARATOR."diskpartscript.txt";
    if(!file_exists($temp) && !is_file($temp)) file_put_contents($temp, "select disk 0\ndetail disk");
    $output = shell_exec("diskpart /s ".$temp);
    $lines = explode("\n",$output);
    $result = array_filter($lines,function($line) {
        return stripos($line,"ID:")!==false;
    });


    if(count($result)>0) {
        $result = array_shift(array_values($result));
        $result = explode(":",$result);
        $result = trim(end($result));
    } else $result = $output;
} else {
    $result = shell_exec("blkid -o value -s UUID");
    if(stripos($result,"blkid")!==false) {
        $result = $_SERVER['HTTP_HOST'];
    }
}
return md5($salt.md5($result));
}


echo UniqueMachineID(); 
Markos
  • 190
  • 12
  • Your code above will give you infos of your server, since PHP runs on the server, not on the client. There is no way to get any information of the machine of the client (besides what you get in $_SERVER, etc.) in PHP. – lukas.j Feb 05 '22 at 12:17

0 Answers0