Jump to content

[SOLVED] PHP Auth Package


bryantms

Recommended Posts

I'm having trouble getting the Auth package to work.  I'm trying to set it up, but I get this error:

 

Fatal error: Class 'Auth' not found in /home/fearandf/php/Auth/HTTP.php on line 54

 

I've tried searching for quite a while now, but have found nothing to solve this.

 

The login.php file I'm trying to create is here:

 

<?php
// Example of Auth_HTTP the also returns additional information about the user
require_once('config.php');
require_once('db_login.php');
require_once('/home/fearandf/php/Auth/HTTP.php');
// We use the same connection string as the pear DB functions
$AuthOptions = array(
'dsn'=>"mysql://$db_username:$db_password@$db_host/$db_database",
'table'=>"users", // your table name
'usernamecol'=>"username", // the table username column
'passwordcol'=>"password", // the table password column
'cryptType'=>"md5", // password encryption type in your db
'db_fields'=>"*" // enabling fetch for other db columns
);

$authenticate = new Auth_HTTP("MDB2", $AuthOptions);
// set the realm name
$authenticate->setRealm('Member Area');
// authentication failed error message
$authenticate->setCancelText('<h2>Access Denied</h2>');
// request authentication
$authenticate->start( );
// compare username and password to stored values

if ($authenticate->getAuth( )) {
session_start( );
$smarty->assign('blog_title',$blog_title);
$smarty->display('header.tpl');
//setup session variable
$_SESSION['username'] = $authenticate->username;
$_SESSION['first_name'] = $authenticate->getAuthData('first_name');
$_SESSION['last_name'] = $authenticate->getAuthData('last_name');
$_SESSION['user_id'] = $authenticate->getAuthData('user_id');
echo "Login successful. Great to see you ";
echo $authenticate->getAuthData('first_name');
echo " ";
echo $authenticate->getAuthData('last_name').".<br />";
$smarty->display('footer.tpl');
}
?>

 

Couple things to make it clearer what I'm doing:

  • Using MDB2
  • Using Smarty Template Engine
  • Trying to create a very basic page using Auth
  • Using Auth_HTTP extension right now, but don't really want to

 

Has anyone had any experience with Auth to be able to help me out?

Link to comment
Share on other sites

I edited HTTP.php a bit earlier to get it to find a .php file it was missing.  But that line is as follows:

 

class Auth_HTTP extends Auth
{

 

And then there are a bunch of variables being set.  The problem is that I don't know how to fix this error. 

Link to comment
Share on other sites

I think what you were saying is that Auth.php needs to be included as well as it is being extended:

 

require_once('/relative/path/to/Auth.php');

 

But I've tried that in all its forms and I'm still getting the same error:

 

Fatal error: Class 'Auth' not found in /home/fearandf/php/Auth/HTTP.php on line 54

Link to comment
Share on other sites

I've just installed it using PEAR installer (pear install Auth & pear install Auth_HTTP) and I'm getting the same error message.  I need to edit line 24 to direct it to the correct Auth.php file but then it still says it can't find Class Auth.

 

I'm starting to think this is something to do with the setup.  Might this be server related since it's a shared host and many of the file paths are all relative to a folder within the root?  Does that throw off many of PEAR's packages?  I'm guessing at this point...

Link to comment
Share on other sites

After browsing around for a couple of hours, I think I finally figured it out.  You were right...the pear directory was not included in PHP.

 

I just included this little baby:

 

ini_set('include_path', "/home/fearandf/php");

 

For which the relative path is the location that pear is installed.  Now I just need to figure out how to add the to my .ini file (of which I just found) so that this code doesn't need to be placed on every page using Pear (all of 'em).

 

Any hints on what to put in the ini file and where?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.