Return to the EJW Associates home page About EJW | NEWS | Services | Who We help | Contact | Lightbox | Site Map | Home

HttpAuthPlus / Documentation

Authentication | Administration | Methods

Administration With HttpAuthPlus

HttpAuthPlus can also be used for managing access to protected pages. It provides methods for adding, editing, and removing users from both flat-file & database authentication schemes.

There are a couple of things to keep in mind:

  1. All usernames and email addresses must be unique
  2. When using a flat-file scheme usernames, passwords & emails must not contain the '|' character as this is used as the field delimeter.

Adding Users:
Adding users is pretty simple, just make sure the user your adding has a unique username & email.

Adding users to a flat-file:

$login = new HttpAuthPlus; // Creates a new instance of the HttpAuthPlus object
$login->setAuthType('file'); // Sets the Authentication scheme to file instead of the default database scheme
$login->setAuthFile('/home/userdir/passwordfile'); // Sets the full path to the password file to add the user to
$login->AddUser('username', 'password', 'user@whatever.com');
// Adds the user to the password file

Adding users to a database:

$login = new HttpAuthPlus; // Creates a new instance of the HttpAuthPlus object
$login->setAuthEncrypt('crypt'); // Sets the Authentication Encryption to 'crypt' instead of the default 'plain-text'
$login->setAuthRealm('HttpAuthPlus'); // Sets the text tp use for the Authentication Realm
$login->setDbType('mysql'); // sets the type of database to use
$login->setDbHost('localhost'); // the hostname or IP of the database server
$login->setDbUser('username'); // the username for connecting to the server
$login->setDbPass('password'); // the password for connecting to the server
$login->setDbName('databasename'); // the name of the database to use
$login->setUsernameField('username_field'); // the name of the field that contains the username
$login->setPasswordField('password_field'); // the name of the field that contains the password
$login->setEmailField('email_field'); // the name of the field that contains the email address
$login->setDbInitStr(); // builds the DSN string; must be called after initializing the database variables
$login->setTableName('tablename'); // the name of the table that stores usernames,passwords,emails
$login->AddUser('username', 'password', 'user@whatever.com'); // adds the user to the database

Refer to Method Documentation for further details and options for administrative functions.

Editing Users:
HttpAuthPlus has the ability to change every aspect of a user record, including the username. In order to do this, the username and/or email an existing user is changing to must not already exist. In order to change a user's username and/or email, the original username and email along with the new username and email must be passed to the EditUser() method.

Editing a user record in a flat-file:

$login = new HttpAuthPlus; // Creates a new instance of the HttpAuthPlus object
$login->setAuthType('file'); // Sets the Authentication scheme to file instead of the default database scheme
$login->setAuthEncrypt('crypt'); // Sets the Authentication Encryption to 'crypt' instead of the default 'plain-text'
$login->setAuthFile('/home/userdir/passwords'); // Sets the full path to the password file to add the user to
$login->EditUser('currentusername', 'newusername', 'password', 'currentemail', 'newemail'); // carries out the actual updating of the user record

Editing a user record in a database:

$login = new HttpAuthPlus; // Creates a new instance of the HttpAuthPlus object
$login->setAuthEncrypt('crypt'); // Sets the Authentication Encryption to 'crypt' instead of the default 'plain-text'
$login->setAuthRealm('HttpAuthPlus'); // Sets the text tp use for the Authentication Realm
$login->setDbType('mysql'); // sets the type of database to use
$login->setDbHost('localhost'); // the hostname or IP of the database server
$login->setDbUser('username'); // the username for connecting to the server
$login->setDbPass('password'); // the password for connecting to the server
$login->setDbName('databasename'); // the name of the database to use
$login->setUsernameField('username_field'); // the name of the field that contains the username
$login->setPasswordField('password_field'); // the name of the field that contains the password
$login->setEmailField('email_field'); // the name of the field that contains the email address
$login->setDbInitStr(); // builds the DSN string; must be called after initializing the database variables
$login->setTableName('tablename'); // the name of the table that stores usernames,passwords,emails

$login->EditUser('currentusername', 'newusername', 'password', 'currentemail', 'newemail'); // carries out the actual updating of the user record

Refer to Method Documentation for further details and options for administrative functions.

Removing Users:
Using HttpAuthPlus to remove a user is simple, create a new instance of the HttpAuthPlus obejct, set some parameters, and call the RmUser() method with a username as the argument.

Removing a user from a flat-file:

$login = new HttpAuthPlus; // Creates a new instance of the HttpAuthPlus object
$login->setAuthType('file'); // Sets the Authentication scheme to file instead of the default database scheme
$login->setAuthEncrypt('crypt'); // Sets the Authentication Encryption to 'crypt' instead of the default 'plain-text'
$login->setAuthFile('/home/userdir/passwords'); // Sets the full path to the password file to add the user to
$login->RmUser('username'); // carries out the actual removal of the user

Removing a user from a database:

$login = new HttpAuthPlus; // Creates a new instance of the HttpAuthPlus object
$login->setAuthEncrypt('crypt'); // Sets the Authentication Encryption to 'crypt' instead of the default 'plain-text'
$login->setAuthRealm('HttpAuthPlus'); // Sets the text tp use for the Authentication Realm
$login->setDbType('mysql'); // sets the type of database to use
$login->setDbHost('localhost'); // the hostname or IP of the database server
$login->setDbUser('username'); // the username for connecting to the server
$login->setDbPass('password'); // the password for connecting to the server
$login->setDbName('databasename'); // the name of the database to use
$login->setUsernameField('username_field'); // the name of the field that contains the username
$login->setPasswordField('password_field'); // the name of the field that contains the password
$login->setEmailField('email_field'); // the name of the field that contains the email address
$login->setDbInitStr(); // builds the DSN string; must be called after initializing the database variables
$login->setTableName('tablename'); // the name of the table that stores usernames,passwords,emails

$login->RmUser('username'); // carries out the actual removal of the user

Refer to Method Documentation for further details and options for administrative functions.

Authentication | Administration | Methods

Today's media is different than yesterday's, and will change tomorrow.

Following a template is not enough. Contact EJW Associates in the Atlanta, GA area for an Internet presence developed around a solid strategy… and designed to click with business-to-business markets. Current, knowledgeable Internet programs that are an integral part of a marketing plan are essential if you are to win market share today. Your brand and your profitability are on the line. Trust a trade marketing professional to develop your company’s direct marketing, web site, search marketing (SEM, SEO), email promotions, interactive banner ads, Pay per click (keyword) advertising campaigns, sales support brochure programs.