由网友(对我而言.)分享简介:我知道,它可能通过这个shell脚本添加新的HTTP认证凭据:的htpasswd -c htpasswd的测试是否有可能实现同一个PHP脚本?我知道我可以使用常规的PHP身份验证系统,但是这不是我要找的。解决方案 您可以使用的系统或 EXEC 添加用户我已经创建了一个可能为你工作一个code片断:< PHP定...![不懂珠宝需要识别鉴定证书真伪,鉴定机构参差不齐,买错亏大了](https://p.xsw88.cn/allimgs/daicuo/20230902/297.png)
我知道,它可能通过这个shell脚本添加新的HTTP认证凭据:
的htpasswd -c htpasswd的测试
是否有可能实现同一个PHP脚本?我知道我可以使用常规的PHP身份验证系统,但是这不是我要找的。 解决方案
您可以使用的系统或 EXEC 添加用户
我已经创建了一个可能为你工作一个code片断:
< PHP
定义('HTPASSFILEPATH','的.htpasswd');
功能ADDUSER($ PUSER,$ pPass)
{
执行exec(htpasswd的-CBHTPASSFILEPATH$ {PUSER} $ {pPass}。);
}
?>
![不懂珠宝需要识别鉴定证书真伪,鉴定机构参差不齐,买错亏大了](https://p.xsw88.cn/allimgs/daicuo/20230902/297.png)
记住,在的htpasswd
工具应该在你的 PATH
I know that it's possible to add new HTTP auth credentials through this shell script:
htpasswd -c .htpasswd testing
Is it possible to achieve the same with a PHP script? I know I could use a regular PHP auth system, but that's not what I'm looking for.
解决方案You can execute this command with system or exec to add your users.
I've created a code snippet that might work for you:
<?php
define('HTPASSFILEPATH', '.htpasswd');
function addUser($pUser, $pPass)
{
exec("htpasswd -cb " . HTPASSFILEPATH . " ${pUser} ${pPass}");
}
?>
And remember, the htpasswd
tool should be in your PATH
相关推荐
最新文章