简体   繁体   English

如何使用exec()更新,删除和编辑.htpasswd的用户名和密码?

[英]how to use exec() to update, delete and edit username and password of .htpasswd?

exec()是我的新手,如果有教程网站或有人可以教我如何使用它,我正在尝试学习如何使用它来编辑和更新访问者的用户名和密码。

I discourage using htaccess/htpasswd for complex password management. 我不鼓励使用htaccess / htpasswd进行复杂的密码管理。 Instead, I recommend you build your own password management/login system. 相反,我建议您构建自己的密码管理/登录系统。 However, if you still want to use htpasswd, follow these directions: 但是,如果您仍然想使用htpasswd,请按照以下说明进行操作:

First, make sure that you have the htpasswd.exe file in the path/current directory. 首先,请确保您在路径/当前目录中有htpasswd.exe文件。

Then, modify and add this line to your program where you need it. 然后,修改此行并将其添加到您需要的程序中。

exec('htpasswd.exe -b passwordFile myUserame myPassword');

where passwordFile is the name of the password file 其中passwordFile是密码文件的名称
myUsername is the username you want to change and myUsername是您要更改的用户名,
myPassword is the new password myPassword是新密码

If you want to use dynamic input, MAKE SURE you clean the content first. 如果要使用动态输入,请确保先清除内容。 Otherwise, you could open up security holes to malicious attackers. 否则,您可能会向恶意攻击者开放安全漏洞。

Why are you using exec() ? 为什么使用exec() It'd be far simpler to use PHP's normal file I/O functions to read and write the file. 使用PHP的常规文件I / O函数读取和写入文件要简单得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM