使用 php 获取唯一的系统 ID


Get Unique System ID using php

我需要客户端系统的唯一 ID 来注册我的应用程序。

我的方法(或想法):

  1. 当客户购买我的应用程序时,我给他一个密钥(key1

  2. 在他将我的应用程序安装到他的本地服务器上后,我想验证他是否 installation.so 要提交表单

  3. 收到该信息
  4. 后,我想存储该信息并更新他的本地数据库。

    1. 我的服务器数据库"安装"表结构 : 名称

      (空) , 电子邮件(空) , 地址(空) , 键 1 , 键 2 , unique_id(空) , 状态(0)

      if key1 currect and status == 0,他的信息unique_id保存在安装表中和状态设置为1,他的本地数据库将使用key1和key2更新。

      if key1 currect and status == 1(重新安装时间),则他的本地计算机unique_id和安装表unique_id将检查。 如果相等,他的本地数据库将使用 key1 和 key2 进行更新。

      if not currect,他的本地数据库将使用key1('key not valid')和key2('key not valid')进行更新。

  5. 如果本地数据库验证表值(密钥 1 和密钥 2)不是"密钥无效",则应用程序将正常工作。

客户表格:

<?php
$unique_id = "i want unique system id here";
?>
<form action="http://www.example.com/verifiy.php" method="post">
    <p>
        <label>Name</label>
        <input type="text" name="name" />
    </p>
    <p>
        <label>Email</label>
        <input type="text" name="email" />
    </p>
    <p>
        <label>Phone</label>
        <input type="text" name="phone" />
    </p>
    <p>
        <label>Activation key</label>
        <input type="text" name="name" />
    </p>
    <p class="hidden">
        <input type="text" name="unique_id" value="<?php echo $unique_id; ?>" />
    </p>
    <input type="submit" />
</form>

当客户提交此表格时,我想在我的服务器上保存带有系统唯一ID的所有信息,我会给他一个密钥。

请帮助我,如何获取客户端系统的唯一ID? 对不起,我的英语不好。谢谢。

您可以使用 openssl_random_pseudo_bytes 和 bin2hex 作为安全的随机字符串。

echo bin2hex(openssl_random_pseudo_bytes(9));

PHP中使用uniqid函数。

<?php
/* A uniqid, like: 4b3403665fea6 */
printf("uniqid(): %s'r'n", uniqid());

你的代码..

<?php
$unique_id = uniqid(); // I have added it here.
?>
<form action="http://www.example.com/verifiy.php" method="post">
    <p>
        <label>Name</label>
        <input type="text" name="name" />
    </p>
    <p>
        <label>Email</label>
        <input type="text" name="email" />
    </p>
    <p>
        <label>Phone</label>
        <input type="text" name="phone" />
    </p>
    <p class="hidden">
        <input type="text" name="unique_id" value="<?php echo $unique_id; ?>" />
    </p>
    <input type="submit" />
</form>

使用以下 2 个步骤生成有关访问者的唯一数据。

  1. 使用 $_SERVER['REMOTE_ADDR'] 将为您提供正在查看此页面的用户的 IP 地址。

  2. 使用 HTML5 地理位置 API 获取用户的位置。

根据以上 2 个数据生成唯一 ID

<script>
   var x=document.getElementById("demo");
   function getLocation()
   {
     if (navigator.geolocation)
       {
         navigator.geolocation.getCurrentPosition(showPosition);
       }
     else{x.innerHTML="Geolocation is not supported by this browser.";}
   }
  function showPosition(position)
  {
   //Get latitude & longitude from position
   x.innerHTML="Latitude: " + position.coords.latitude + 
   "<br>Longitude: " + position.coords.longitude; 
   }
  </script>