zoukankan      html  css  js  c++  java
  • 编写自己的WifiDog认证服务器

    这次我使用的是php来编写auth_server服务器,因为这样比较简单。
    1.首先是login.php

    <?php  
    include './tool/MySQLHelper.php';  
    if (!empty($_GET["mac"])){  
        $result = selectMacByToken($_GET["mac"]);  
        if (!empty($result)){  
            header("location: http://192.168.1.1:2060/wifidog/auth?token=".$result);  
        }  
        else {  
            header("location: http://xxxxx/WelcomePage.php?mac=".$_GET["mac"]);  
        }  
    }  
    else {  
        header("location: http://xxxxx/WelcomePage.php?mac=".$_GET["mac"]);  
    }  
    ?>  

    2.ping.php

    <?php  
    echo "Pong";  
    ?>  

    这里没有做额外的处理,只是简单地向wifidog回应一个Pong。
    3.auth.php

    <?php  
    // 后门  
    if ($_GET["token"] == "123"){  
        echo "Auth: 1";  
        return;  
    }  
    
    if (!empty($_GET["token"]) && isset($_GET["token"])){  
        //获取$result的过程//  
        isValidate($result);  
        //**后续处理**//  
        return;  
    }  
    else if((!empty ($_GET["mac"])) && isset($_GET["mac"])){  
        //**获取result*//  
        $result = isSubscribeByMac($_GET["mac"]);  
        isValidate($result);  
        return;  
    }  
    else  
    {  
        echo "Auth: 0";  
    }  
    
    // 输出是否合法.  
    function isValidate($result){  
        if ($result == 1){  
            echo "Auth: 1";  
        }  
        else {  
            echo "Auth: 0";  
        }  
    }  
    ?>  

    这里根据一些参数来获取$result,从而决定是否允许认证。
    4.welcomePage.php以及Portal.html就不一一列举了。

    本文章由http://www.wifidog.pro/2015/06/08/wifidog%E8%AE%A4%E8%AF%81%E6%9C%8D%E5%8A%A1%E5%99%A8-4.html 整理编辑,转载请注明出处

  • 相关阅读:
    vs c++配置opencv(1)
    vs2013搭建团队版本控制 TFS、SVN
    robomongo
    Node log4js
    node.async.auto
    p2.js物理引擎学习
    pomelo
    Node.mongoose
    Node.Buffer
    Node安装及搭建简单HTTP服务器
  • 原文地址:https://www.cnblogs.com/wifidog/p/4562113.html
Copyright © 2011-2022 走看看