如何使用exec()来更新、删除和编辑.htpasswd的用户名和密码?
exec()
对我来说是新的,我正在尝试学习如何使用它来编辑和更新访问者的用户名和密码,如果有教程网站或者有人可以教我如何使用它
exec()
is new to me and i am trying to learn on how to use it to edit and update usernames and passwords of visitors, if there is a tutorial website or someone can teach me on how to use it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不鼓励使用 htaccess/htpasswd 进行复杂的密码管理。相反,我建议您构建自己的密码管理/登录系统。但是,如果您仍然想使用 htpasswd,请按照以下说明操作:
首先,确保路径/当前目录中有 htpasswd.exe 文件。
然后,修改此行并将其添加到程序中需要的位置。
其中passwordFile是密码文件的名称
myUsername 是您要更改的用户名
myPassword 是新密码
如果您想使用动态输入,请确保先清理内容。否则,您可能会为恶意攻击者打开安全漏洞。
I discourage using htaccess/htpasswd for complex password management. Instead, I recommend you build your own password management/login system. However, if you still want to use htpasswd, follow these directions:
First, make sure that you have the htpasswd.exe file in the path/current directory.
Then, modify and add this line to your program where you need it.
where passwordFile is the name of the password file
myUsername is the username you want to change and
myPassword is the new password
If you want to use dynamic input, MAKE SURE you clean the content first. Otherwise, you could open up security holes to malicious attackers.
为什么使用
exec()
?使用 PHP 的普通文件 I/O 函数来读写文件要简单得多。Why are you using
exec()
? It'd be far simpler to use PHP's normal file I/O functions to read and write the file.