步骤

  • 编辑文件/_h5ai/public/index.php,在底部增加:
function auth ()
{
        $valid_passwords = array ("账号" => "密码");
        $valid_users = array_keys($valid_passwords);

        $user = $_SERVER['PHP_AUTH_USER'];
        $pass = $_SERVER['PHP_AUTH_PW'];

        $validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);

        if (!$validated) {
          header('WWW-Authenticate: Basic realm="My Realm"');
          header('HTTP/1.0 401 Unauthorized');
          die ("Not authorized");
        }
}
  • 在头部 <?php 的下一行,增加
auth();

其他

  • 将上文的$valid_passwords = array ("账号" => "密码");改为$valid_passwords = array ("账号" => "密码","账号" => "密码","账号" => "密码","账号" => "密码","账号" => "密码","账号" => "密码",);,则实现多用户,但是看见的目录是一模一样的。。。(没有数据隔离)

  • 其他一些经验,来自Hostloc 斜阳晚暮。