PHP输入密码并列出目录文件生成超链接代码

chen'mo
2017-12-23 / 0 评论 / 2,181 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于1970年01月01日,已超过19839天没有更新,若内容或图片失效,请留言反馈。

一个可以加密文件夹,并且可以展示文件夹内文件的php代码:


<?php 
$password = "123456"; // 这里是密码 
$p = ""; 
if(isset($_COOKIE["isview"]) and $_COOKIE["isview"] == $password){ 
$isview = true; 
}else{ 
if(isset($_POST["pwd"])){ 
if($_POST["pwd"] == $password){ 
setcookie("isview",$_POST["pwd"],time()+3600*3); 
$isview = true; 
}else{ 
$p = (empty($_POST["pwd"])) ? "需要密码才能查看,请输入密码。" : "密码不正确,请重新输入。"; 
} 
}else{ 
$isview = false; 
$p = "请输入密码查看,获取密码可联系我。"; 
} 
} 
if($isview){ ?> 
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title>加密内容</title>
<meta name="Keywords" content="加密内容" />
<meta name="Description" content="加密内容" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div id="post">
<pre id="neirong">
<?php   
$dir = "./";   

// Open a known directory, and proceed to read its contents   
if (is_dir($dir)) {   
   if ($dh = opendir($dir)) {   

       while (($file = readdir($dh)) !== false) {   
       if ($file!="." && $file!="..") {   
       echo "<a href=./".$file.">".$file."</a><br>";   
       }   
       }   
       closedir($dh);   
   }   
}   
?>
</pre>
</div>
</body></html>
<?php }else{ ?> 

<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title>输入密码</title>
<meta name="Keywords" content="输入密码" />
<meta name="Description" content="输入密码" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div id="post">
<img src="key.png">
<form action="?yes" method="post" style="margin:0px;">输入查看密码 
<input type="password" name="pwd" /> <input type="submit" value="查看" /> 
</form> 
<?php echo $p; ?> 
</div> 
<?php 
} ?> 
</body> 
</html>

来源:https://diannaobos.com/post/567.html

0
分享腾讯云抢一元学生服务器JS脚本
« 上一篇 12-23
使用手机DLNA功能将内容投屏到电脑
下一篇 » 12-23

评论 (0)

插入图片