Auth_HTTP认证的问题,请指教谢谢!
安装pear,安装目录为C:\Program Files\PHP\PEAR
拷贝了一个书上的例子运行,但运行时出现如下致命错误:
Fatal error: Class 'Auth' not found in C:\Program Files\PHP\PEAR\Auth\HTTP.php
on line 54
但我看了一下HTTP.php中require_once "Auth/Auth.php";
并且
C:\Program Files\PHP\PEAR\Auth\Auth.php中也有Auth.php的定义了.
请问是什么原因?
通过phpinfo()函数,include_path设置如下:
include_path .;C:\Program Files\PHP\pear
尝试修改HTTP.php中的require为require_once "Auth.php";无效.
<?php
require_once("Auth/HTTP.php");
// Designate authentication credentials, table name,
// username and password columns, password encryption type,
// and query parameters for retrieving other fields
$dblogin = array (
'dsn' => "mysql://corpweb:secret@localhost/corporate",
'table' => "userauth",
'usernamecol' => "username",
'passwordcol' => "pswd",
'cryptType' => "md5",
'db_fields' => "*"
);
// Instantiate Auth_HTTP
$auth = new Auth_HTTP("DB", $dblogin) or die("blah");
// Begin the authentication process
$auth->start();
// Message to provide in case of authentication failure
$auth->setCancelText('Authentication credentials not accepted!');
// Check for credentials. If not available, prompt for them
if($auth->getAuth())
{
echo "Welcome, $auth->commonname<br />";
}
?>