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
https://forums.phpfreaks.com/topic/84233-solved-php-auth-package/
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

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...

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?

you'll find something like an uncommented "include_path" directive

 

 

include_path=".;..."

 

just put a semi-colin at the end before the quotes and add your path there

 

 

include_path=".;...;/home/fearandf/php"

 

something like the above and it should work

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.