Background Image
Web
Development
Tools
Tool...
49 Projects
Web Development Project
Web
Development
Project
Product: Secure Login System
Product Large Image

Details:

Last update:2010-09-27 16:16:30
Download:http://www.webdevproject.com/zips/SLS.zip
License:GNU Free Documentation License, Version 1.3
Version:v1.00
Price:Free!

Description:

A safe and easy-to-use login system. Various layouts are available, and is easy to implement in your code. It is possible to manage the users that are allowed to login by using our PHP functions. See the reference section for more information.

Table of content
Installation guide
Reference

Installation guide



Part one: SLS installation and setup

  • Download the SLS using one of the links below:
    http://www.webdevproject.com/zips/sls.zip

  • Unzip the content of sls.zip into a new directory, for example named 'SLS'. An example of the URL is http://www.example.com/SLS/ and an example for the URI is '/home/domains/example.com/public_html/SLS'. Make sure the following files in the 'core' folder are permission 666: SLS-Config.ini, SLS-Data.db, SLS-Crypt.php and SLS-Core.inc.php

  • Change the password which stands in the file SLS-Crypt.php located in the 'core' folder of the SLS-folder into your a new password.

  • Until here everything should have worked.

  • Open SLS-Setup.php (go to your browser and open http://www.example.com/SLS/core/SLS-Setup.php, and enter your password. Press 'Decode Variables' and then adjust the values of the form into your own. When done, click the 'Save changes' submit button on the bottom.

  • If you get the 'can't open stream, permission denied', you need to go back to step 2 and change the file permissions.

  • Open the file 'example.php' in your browser, which should be located in your 'SLS' folder. An default user is already added by setup when you are using the SLS file as database (user: 'Admin', password: 'secret'). Try to log in with the previous data when you are using the SLS file, or when you are using MySQL as database with the data located in the corresponding table. If you can succesfully log in, the installation is complete.

  • If nothing happens when your press enter after entering your details, it means you entered the wrong path (URL) in SLS-Setup.php .

  • Remove SLS-Setup.php from the 'core' folder


Part two: using this code

  • Place the following HTML in the <head> section, adjust the href attribute to your own value (there alot of different styles, see the reference for more information):
    Code Snippet (Syntax highlighted) - Toggle Wrap

    <link rel="stylesheet" href="http://www.example.com/SLS/style/SLS-Style-Matrix.css" type="text/css" />


  • Place the following HTML right after the <body>, adjust the src attribute to your own value:
    Code Snippet (Syntax highlighted) - Toggle Wrap

    <script type="text/javascript" src="core/SLS-JS-Core.js"></script>


  • You can enable the user to open the SLS login window by calling the JavaScript function PerformLogin() and you can enable the user to log out by using the JavaScript function PerformLogout(). In the 'SLS' folder, a file is located named 'example.php', read it, learn it, use it. See the reference for more information (section 'SLS Examples')

  • If you chose to use the SLS File as database, you can use the SLS functions to add, edit and remove users, see the reference for more details on the functions. If you chose MySQL as database, you need to use MySQL's functions to add, edit and remove users.

  • You can include the functions and session variables by adding the following PHP code at the top of your page:
    Code Snippet (Syntax highlighted) - Toggle Wrap

    <?php
    session_start(); /* SLS automatically starts the session, if one has not yet been started, so you can neglect this line in your own code. */
    /*
    * Including the SLS Core Functions, you only need to include
    * this if you want to communicate with the SLS Database:
    */
    include('core/SLS-Core.inc.php');
    ?>




Reference



SLS Examples:

This is how you check whether the user is logged in:

Code Snippet (Syntax highlighted) - Toggle Wrap

<?php
// Make sure you change the path into your own:
include('core/SLS-Core.inc.php');
if ($_SESSION['SLS_USER']['LOGIN'] == 1) {
echo "You are logged in as".$_SESSION['SLS_USER']['USER'];
} else {
echo "You are not logged in.";
}
?>


The following code enables the user to open the login window:
Code Snippet (Syntax highlighted) - Toggle Wrap

<a href='' onclick='ShowLoginPopup(); return false;'>Click here to log in</a>

The following code enables the user to log off:
Code Snippet (Syntax highlighted) - Toggle Wrap

<a href='' onclick='PerformLogout(); return false;'>Click here to log out</a>


SLS Styles:

There are alot of styles, they are all located in the 'style' folder:

  • SLS-Style-BlueLight.css

  • SLS-Style-BlueWave.css

  • SLS-Style-GreenWave.css

  • SLS-Style-Island.css

  • SLS-Style-Matrix.css

  • SLS-Style-RedFire.css

  • SLS-Style-Tree.css


You can implement them the following, you only need to change the file (so instead of Matrix, you write RedFire etc.):

Code Snippet (Syntax highlighted) - Toggle Wrap

<link rel="stylesheet" href="http://www.example.com/SLS/style/SLS-Style-Matrix.css" type="text/css" />


SLS Session Variables:

If the SLS-Core.inc.php is included, all the below session variables are available.

  • $_SESSION['SLS_USER'], Array example:
    Code Snippet (Syntax highlighted) - Toggle Wrap

    Array
    (
    [LOGIN] => 1 /* 0 = not logged in, 1 = logged in */
    [USER] => Admin
    [DETAIL] => Array
    (
    [var1] => value1 /* Array key = column name, array value = column value */
    [var2] => value2
    [var3] => value3
    )

    )


  • $_SESSION['SLS_CONFIG'], Array example:
    Code Snippet (Syntax highlighted) - Toggle Wrap

    Array
    (
    [REPORT_FAIL] => 0 /* 0 = no errors are echoed, 1 = errors enabled */
    [DATABASE] => MYSQL /* MYSQL or FILE */
    [DB_NAME] => database1
    [DB_USER] => root
    [DB_PASSWORD] =>
    [DB_HOST] => localhost
    [DB_TABLE] => users
    [DB_COL_USER] => user
    [DB_COL_PASS] => password
    [DB_PASS_ENC] => sha1,md5,sha1,md5 /* Encryption method, from left to right */
    )


SLS Functions:

  • Prototype: sls_get_users ( void )

    Description: reads the database content and convert it into an array (including the details)

    Return value: Array of all users, example:
    Code Snippet (Syntax highlighted) - Toggle Wrap

    Array
    (
    [0] => Array
    (
    [user] => Admin
    [password] => 8e2ad3b8e7ee8cdf34d66b120fae70625ab1a4ae
    [detail] => Array
    (
    [var1] => value1
    [var2] => value2
    [var3] => value3
    )

    )

    [1] => Array
    (
    [user] => user1
    [password] => 8993a29f9c95f200f9dfe02dc03a7372373590be
    [detail] => Array
    (
    [var4] => value4
    [var1] => value2
    )

    )

    )


  • Prototype: sls_count_users ( void )

    Description: counts all users

    Return value: number of users


  • Prototype: sls_get_user ( string $user )

    Parameters:
    user - the name of the user, which should be unique

    Description: retrieves the users from the database and returns the array that matches the user column

    Return value: array of all values, example:
    Code Snippet (Syntax highlighted) - Toggle Wrap

    Array
    (
    [user] => Admin
    [password] => 8e2ad3b8e7ee8cdf34d66b120fae70625ab1a4ae
    [detail] => Array
    (
    [var1] => value1
    [var2] => value2
    [var3] => value3
    )

    )


  • Prototype: sls_add_user ( string $user , string $password , string $details )

    Parameters:
    user - the name of the new user, which should be unique
    password - the password of the new user, unencoded
    details - string of values, format: "var1=value1,var2=value2,var3=value3"

    Description: adding a user to the database with the given parameters

    Return value: if the user is succesfully added the return value is true, if not false


  • Prototype: sls_edit_user ( string $user , string $password , string $details )

    Parameters:
    user - the name of the new user, which should be unique
    password - the password of the new user, unencoded
    details - string of values, format: "var1=value1,var2=value2,var3=value3"

    Description: editing the user in the database with the given parameters

    Return value: if the user is succesfully edited the return value is true, if not false


  • Prototype: sls_del_user ( string $user )

    Parameters:
    user - the name of the user, which should be unique

    Description: deleting the user from the database

    Return value: if the user is succesfully removed the return value is true, if not false

Latest news
New project: Math Quiz
2010-11-09 18:07:48
Read more...

New project: Custom Messagebox
2010-11-06 19:10:50
Read more...

New project: Visitor Counter
2010-11-01 21:39:04
Read more...

New project: Image Editor
2010-11-01 21:37:27
Read more...

New project: Image Generator
2010-11-01 21:33:05
Read more...

Projects Contact © 2010 WDP - All rights reserved Terms and Conditions Log in