简体   繁体   中英

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

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

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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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