PHP 生成 .htpasswd 文件的用户名和密码
p.htpasswd 主要是 apache 使用的基于文件的用户名和密码的存储/p
.htpasswd 主要是 apache 使用的基于文件的用户名和密码的存储
<?php
// - - - - - - - - - - - - - - - - - - -
// Author: Christopher Hair
// Website: www.chrishair.co.uk
// - - - - - - - - - - - - - - - - - - -
if (isset($_POST['submit'])){
$error = '';
$username = trim(stripslashes($_POST['username']));
$password = trim(stripslashes($_POST['password']));
if ($username == '' || preg_match('/\s/m', $username)) {
$error .= "<p><strong>Invalid Username.</strong></p>\n";
}
if ($password == '' || preg_match('/\s/m', $password)) {
$error .= "<p><strong>Invalid Password.</strong></p>\n";
}
if ($error == '') {
echo "<p>Success</p>\n";
echo "<h1>" . htmlspecialchars($username) . ":" . crypt($password) . "</h1>\n";
} else {
echo $error;
}
}
?>
- 上一篇:PHP获取文件平内的文件数
- 下一篇:Magento 的文件和数据库维护脚本
精彩图集
精彩文章






