简体   繁体   English

使用php获取唯一的系统ID

[英]Get Unique System ID using php

I want client system's unique id for registering my app. 我需要客户端系统的唯一ID来注册我的应用。

My Method (or idea): 我的方法(或想法):

  1. I give a key ( key1 ) to my client when he purchase my application 客户购买我的应用程序时,我给他一个钥匙( key1

  2. After he installs my application on his local server, I want to verify that installation.so he want to submit a form 他在本地服务器上安装我的应用程序后,我想验证该安装。因此他想提交一个表格

  3. after receiving that information, I want to store that information and update his local database. 收到该信息后,我想存储该信息并更新他的本地数据库。

    1. my server database 'installations' table structure : name(empty) , email(empty) , address(empty) , key1 , key2 , unique_id(empty) , status(0) 我的服务器数据库“安装”表结构:name(空),email(空),address(空),key1,key2,unique_id(空),status(0)

      if key1 currect and status == 0 , his informations with unique_id save in installations table & status set to 1 & his local database will update with key1 and key2. if key1 currect and status == 0 ,则其具有unique_id的信息将保存在安装表中且状态设置为1,并且其本地数据库将使用key1和key2更新。

      if key1 currect and status == 1 (re-installing time), then his local machine unique_id and installations table unique_id will check. if key1 currect and status == 1 (重新安装时间),则将检查其本地计算机上的unique_id和安装表unique_id。 if equal, his local database will update with key1 and key2. 如果相等,则其本地数据库将使用key1和key2更新。

      if not currect , his local database will update with key1('key not valid') and key2('key not valid'). if not currect ,他的本地数据库将更新为key1('key not valid')和key2('key not valid')。

  4. if local database verification table values (key1 and key2) not 'key not valid' then application will work. 如果本地数据库验证表值(键1和键2)不是“键无效”,则应用程序将运行。

Client form: 客户表格:

<?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>

When client submit this form, i want save all informations with system unique id on my server and i will give him to a key. 当客户提交此表单时,我想将所有具有系统唯一ID的信息保存在我的服务器上,我将给他一个密钥。

please help me, how can i get client system's unique id? 请帮助我,我如何获得客户端系统的唯一ID? sorry for my bad english. 对不起,我的英语不好。 Thanks. 谢谢。

您可以将openssl_random_pseudo_bytesbin2hex用于安全的随机字符串。

echo bin2hex(openssl_random_pseudo_bytes(9));

Make use of uniqid function in PHP . 利用PHPuniqid函数。

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

Your code.. 您的代码..

<?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>

Use below 2 steps to generate unique data about visitor.. 使用下面的2个步骤来生成有关访问者的唯一数据。

  1. Use $_SERVER['REMOTE_ADDR'] will give you IP Address of user who is viewing this page. 使用$ _SERVER ['REMOTE_ADDR']将为您提供正在查看此页面的用户的IP地址。

  2. Use HTML5 Geolocation API to get location of User. 使用HTML5地理位置API获取用户的位置。

Generate a unique id based on above 2 datas 根据上述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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM