创建使用shell的PHP,而不是新的HTTP认证证书 [英] Create new HTTP auth credentials using PHP instead of shell
本文介绍了创建使用shell的PHP,而不是新的HTTP认证证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道,它可能通过这个shell脚本添加新的HTTP认证凭据:
的htpasswd -c htpasswd的测试
是否有可能实现同一个PHP脚本?我知道我可以使用常规的PHP身份验证系统,但是这不是我要找的。 P>
解决方案
我已经创建了一个可能为你工作一个code片断:
< PHP
定义('HTPASSFILEPATH','的.htpasswd');
功能ADDUSER($ PUSER,$ pPass)
{
执行exec(htpasswd的-CBHTPASSFILEPATH$ {PUSER} $ {pPass}。);
}
?>
记住,在的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
这篇关于创建使用shell的PHP,而不是新的HTTP认证证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文