簡體   English   中英

使用php獲取唯一的系統ID

[英]Get Unique System ID using php

我需要客戶端系統的唯一ID來注冊我的應用。

我的方法(或想法):

  1. 客戶購買我的應用程序時,我給他一個鑰匙( key1

  2. 他在本地服務器上安裝我的應用程序后,我想驗證該安裝。因此他想提交一個表格

  3. 收到該信息后,我想存儲該信息並更新他的本地數據庫。

    1. 我的服務器數據庫“安裝”表結構:name(空),email(空),address(空),key1,key2,unique_id(空),status(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')。

  4. 如果本地數據庫驗證表值(鍵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_bytesbin2hex用於安全的隨機字符串。

echo bin2hex(openssl_random_pseudo_bytes(9));

利用PHPuniqid函數。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM