【发布时间】:2013-08-29 17:02:40
【问题描述】:
如果用户登录,我已经制作了以下脚本来显示目录中的文件:
<?php
session_start();
require_once("path/file.php");
if (!empty($_SESSION[username]))
{echo "You <b>$_SESSION[username]</b> are registered.";
$dirPath = dir('includes/path/');
$docArray = array();
while (($file = $dirPath->read()) !== false)
{
if ((substr($file, -3)=="pdf") || (substr($file, -3)=="doc"))
{
$docArray[ ] = trim($file);
}
}
$dirPath->close();
sort($docArray);
$c = count($docArray);
foreach($docArray as $filename)
{
echo "<div><a href=\"./includes/path/$filename\">Download '$filename'</a></div>";
echo "<br/>";
}
include('logout.php');
}
else
{echo "somethingsomething";
include('login.php');
}
?>
在成员表中有两列 MSV 和 LTP,可能的值为 0、1。此外,我还必须到目录 /path/LTP 和 /path/MSV。
我需要在脚本中添加一个内容,如果用户拥有 LTP 或/和 MSV 的权限,文件将相应地显示。
【问题讨论】:
-
您没有显示任何处理您的成员表的代码(我假设它是一个 MySQL 数据库),我假设
path/MSV/path/LTP部分将是$dirPath?请澄清。 -
是的,所有文件都存储在mysql数据库的成员表中。手动插入用户 username|password|company|LTP|MSV。
-
文件路径目前是/includes/published/ 这应该分成两个目录/includes/MSV和/includes/LTP/
标签: php mysql validation path directory