Sources for file plugins/auth/sql.php in version 2.0 Beta 4



Click on a comment to hide it. Click here to show all comments.

/*
 * Project:     Onyx: PHP Application Backend
 * File:        plugins/auth/sql.php
 *              Authentication Plugin - Authenticate against SQL database
 *
 * Version:     2.0b4
 * CVS tag:     $Id: sql.php,v 1.9 2002/10/28 14:49:52 bok Exp $
 * Author:      Robert Amos <bok[at]ausmac.net>
 *              Andrew Wellington <proton[at]wiretapped.net>
 * Copyright:   2001,2002 Shiznatz Inc.
*/

class auth_sql_plugin {
    function 
login($username$password$params)
    {
               
// SQL Authentication
        
global $db;

            
// md5 hash the password so it matches the password in the database
            
$password md5($password);

            
// get any matching username
            
$table $db->spec ('auth');
        
$sql "SELECT * FROM $table->_title WHERE $table->username = '$username' AND $table->password =
'
$password'";

        
// run query
        
$db->select($table->_database);
        
$db->query($sql);
                
            
// if no matches, invalid login
        
if (!$db->num_rows()) 
            return 
false;

            
// get stuffs
        
$details $db->fetch_array (0);

            
// store groups into the array
            
$groups preg_split("/[,]/"$details[$table->groups]);
        if (!empty(
$details[$table->realname]))
            
$groups['loginname'] = $details[$table->realname];

        return 
$groups;
    }
}

class 
Auth_Table_Specs {

    
// juarez
    
var $_title "auth";
    var 
$_database "uls";
    var 
$username "username";
    var 
$password "password";
    var 
$groups "groups";
    var 
$realname "realname";

}

?>


Website is Copyright © Odynia.org 2000-2005 - Xnyo is released under a BSD license.