“SimpleAuth” Documentation by “Arnaud Lemercier” v4.0


“SimpleAuth” : Very Simple Secure Login System

Created: 10/04/2011
By: Arnaud Lemercier
Email: arnaud@wixiweb.fr
Follow me on Twitter

Thank you for purchasing my script. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here. Thanks so much!


Table of Contents

  1. Installation
  2. Your First Secure Page
  3. Add User
  4. Logout
  5. Get the username
  6. Restricted access to some users
  7. Configuration
  8. Additional user informations
  9. Load a theme
  10. Change flat theme colors

A) Installation - top

Installation is very simple, just copy the file simpleauth.php at the root of your website.

B) Your First Secure Page - top

With SimpleAuth, you can secure any web page. To do this you must:

  1. Use the ".php" extension for each secure page. (You can rename. "html" to ".php")
  2. Add the following line to the top of each page :
<?php ${(require_once('SimpleAuth.php'))}->protectme(); ?>

Warning, there should be no line breaks or no space before the code

To help you, look at this example:

Before :

After :


C) Add User - top

To configure users, you must open the file SimpleAuth.php

Then, simply edit the list of current users using the same logic

Trying to create a new login "administrator"with a new password and delete the demo accounts

You can now try connecting to your secure page


D) Logout - top

You can add a link to disconnect the user

For this is very simple, just make a link to the current page with the action "logout"

<a href="?simple_auth_action=logout">Logout</a>

If you want, you can redirect the user after logout

Redirect to the current folder (relative):

<?php
${(require_once('SimpleAuth.php'))}->protectme(array(
    'logoutPage' => './'
));
?>

Redirect to the root (absolute) :

<?php
${(require_once('SimpleAuth.php'))}->protectme(array(
    'logoutPage' => '/'
));
?>

Redirect to a specifique page (absolute) :

<?php
${(require_once('SimpleAuth.php'))}->protectme(array(
    'logoutPage' => '/client/news/'
));
?>

Redirect to an external page (absolute) :

<?php
${(require_once('SimpleAuth.php'))}->protectme(array(
    'logoutPage' => 'http://www.wixiweb.fr'
));
?>

You can also edit SimpleAuth.php to configure redirection for All pages :

// Allowed Users List
    'allowedUsers' => NULL,
    // The page will be displayed after logout
    'logoutPage' => 'http://www.wixiweb.fr'
    

E) Get the username - top

If you are in a secure page, you can display the user login

You can place this line to the place you want it to display the login of the user logged :

<?php echo $simpleAuthInstance->getLogin(); ?>

F) Restricted access to some users - top

You can allow access to a page to certain users only. Use the "allowedUsers" option

<?php
${(require_once('SimpleAuth.php'))}->protectme(array(
    'allowedUsers' => array('admin', 'client1')
));
?>

You can allow access to a page to certain groups of users only. Use the "allowedGroups" option

<?php
${(require_once('SimpleAuth.php'))}->protectme(array(
    'allowedGroups' => array('editor', 'administrator')
));
?>

G) Configuration - top

// Locale for translation
'locale' => 'EN',
// Allow user to change locale
'localeSwitcher' => true,

H) additional user informations - top

You can add custom information about your users.
For example, you can add 3 new fieds (phone, email, skype) for 2 users (login@domain.com and admin)
You can retrieve information with the following code :


            Phone : <?php echo $simpleAuthInstance->getMetas("phone");?>
            Email : <?php echo $simpleAuthInstance->getMetas("email");?>
        

I) Load a theme - top

Open "SimpleAuth.php" and edit the theme property


J) Change flat theme colors - top

Open "Themes/flat/flat.php and active another color css file

Uncomment the row of the color you want to activate

Arnaud Lemercier

Go To Table of Contents