doupian9490 2015-09-12 07:50
浏览 108

使用两个设备限制访问

I have php website.

How I limit the user to login the website only with 2 devices.

So if the user try to login with other these 2 devices they can't!

  • 写回答

1条回答 默认 最新

  • duanba8070 2015-09-12 09:16
    关注

    Store the IP addresses of those devices in db and at the time of login check if the user is accessing from that registered devices or not. You can get client's IP using this code in PHP. the code is :

    $ip = $_SERVER['HTTP_CLIENT_IP'];
    

    follow these steps : 1. Create a page to register the devices. 2. Access that page from the devices you want to give the pass. 3. Register the IP addresses of those devices and store it into the db. 4. And lastly from the main site at the time of login check if that device IP is in the list or not.

    And of-course hide that page to register or simply delete that page for security purpose.

    in the same network ip will be conflicting. in that case you can use system MAC address to resolve the conflict . the code to find the MAC address in php is ..

    <?php
    ob_start();
    //Get the ipconfig details using system command
    system('ipconfig /all');
    
    // Capture the output into a variable
    $mycom=ob_get_contents();
    // Clean (erase) the output buffer
    ob_clean();
    
    $findme = "Physical";
    //Search the "Physical" | Find the position of Physical text
    $pmac = strpos($mycom, $findme);
    
    // Get Physical Address
    $mac=substr($mycom,($pmac+36),17);
    //Display Mac Address
    echo $mac;
     ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c