Uma Getting Started Guide - Implementation
(Page 4 of 7 )
Plugging Uma into your site is pretty easy, and it gets easier all the time. You need to have the following files in your PHP include path: Connection.class.php, DataObject.class.php, Utils.class.php, Uma.inc.php, config.php and authenticator.php. I suggest placing all of these files, other than the authenticator.php, outside of your web server's document root.
Connection.class.php - Handles all MySQL PHP function calls.
DataObject.class.php - Provides the common interface for database abstraction. Extends Connection.class.php.
Uma.inc.php - provides all the classes that Uma needs to do its job. All of the classes extend DataObject. You have to include this file for any page that you wish to protect with Uma, or any page that you wish to have access to Uma's objects or session data.
config.php - Provides all of the configuration options for Uma like database connection parameters, e-mail address for errors, text for error messages, etc. Dig around in here and become familiar with the configuration settings.
authenticator.php - Include this file in any page you wish to protect with a Uma login. If the user is not authenticated, this file loads the login page. This is where you set the $permissionLevel required to access the page and the $serviceId corresponding the 'id' column of the service associated with this page.
You will also need to have a login.php file that provides the login page. You can start by using the files I have included in the admin directory. Grab the login.php and the login.html.php and just modify the login.html.php file to give it your site's look and feel.
You should take notice of the file called mepath.php. I use this file to set the location of my Uma files. If you look at index.php in the admin directory, you will see what I am doing.
There is a line that looks like this:
ini_set('include_path', @current(file('mepath.php'))); |
This technique keeps me from having to hardcode the include_path in multiple files. Why not just edit the php.ini file? Often times I don't have access to modify the php.ini file. This is the best solution I have found so far to deal with the include path settings. I recommend using the mepath.php file, but you are free to set your include_path any way you chose.
Although these files aren't necessarily required, you should have a loginerr.php and error.php file in case something bad happens, the user has some place to land. You can do some reporting and logging in the loginerr.php file. When getting started, copy the files I have in the admin directory.
Next: Services >>
More Miscellaneous Articles
More By Codewalkers