Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用于正确引导用户信息的脚本_Php_Apache - Fatal编程技术网

Php 用于正确引导用户信息的脚本

Php 用于正确引导用户信息的脚本,php,apache,Php,Apache,OS:Debian7 64位 我正在编写一个脚本,以引导用户正确地访问自己的username.info文件。 username.info文件位于“/home/username/”中 附加通过apache提供的文件。 该文件还通过apache-defaultsites配置文件中的用户名/密码——“有效用户”进行保护。 输入用户名/密码后,此脚本必须选择适当的username.info文件 目前,只有一个用户能够访问单个网页中的两个username.info文件。还列出了其他用户的.info文件:(

OS:Debian7 64位

我正在编写一个脚本,以引导用户正确地访问自己的username.info文件。 username.info文件位于“/home/username/”中 附加通过apache提供的文件。 该文件还通过apache-defaultsites配置文件中的用户名/密码——“有效用户”进行保护。 输入用户名/密码后,此脚本必须选择适当的username.info文件 目前,只有一个用户能够访问单个网页中的两个username.info文件。还列出了其他用户的.info文件:(

要在脚本中进行哪些更改,以便在输入用户名和密码时提供相应的usernmae.info文件

<htm>
<body>
<font face="arial">
<h2>User list</h2>
<?php
  error_reporting(E_ALL);

  $dir = '/etc/mainfile/users/';
  $files = scandir($dir);

  foreach($files as $index=>$file) {
    $data = explode(".", $file);
    if ($data[1] == 'info') {
        printUser($dir,$data[0]);
    }
  }

  function printUser($dir,$user) {
    echo "<h3>$user</h3>";
    $data = file($dir."$user.info");
    foreach($data as $index=>$line) {
      $line = makelink($line);
      echo $line;
    }
  }

  function makelink($input) {
    $parse = explode(' ', $input);
    $input = "";
    foreach ($parse as $token) {
      $br = "<br>";
      if (strpos($token, "://") > 0) {
        $input .= '<a href="' . $token . '">' . $token . '</a> ';
      } else if(substr($token, 1, 3) == '---') {
        $input .= "<hr>";
        $br = "";
      } else {
        $input .= $token." ";
      }
    }
    return trim($input.$br);
  }

  function getScriptVersion() {
    $data = file("/etc/mainfile/version.info");
    return $data[0];
  }
?>
</body>
</htm>

用户列表
  • 不要使用foreach。它显示所有文件

  • 添加$dir.=$username,如果它和pass是正确的

  • 检查文件_是否存在()


  • 我重新做了apache配置,经过大量测试,发现编辑apacherewritecond和规则更好。 完全删除了上面的文件,现在用户直接转到他的docs目录

    将以下内容添加到使用secret作为位置的虚拟主机:

    重新编写引擎打开
    重写cond%{LA-U:remote_user}^$
    重写规则^/secret(.*)/home/%{LA-U:remote_user}/secret$1
    AuthType摘要
    AuthName“秘密”
    AuthDigestDomain/var/www/secret
    AuthDigestProvider文件
    AuthUserFile/etc/apache2/htpasswd
    需要有效用户