Sources for file plugins/auth/sql.php in version 2.0 Release Candidate 2



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.0rc2
 * CVS tag:     $Id: sql.php,v 1.15 2003/02/04 04:39:23 bok Exp $
 * Author:      Robert Amos <bok[at]ausmac.net>
 *              Andrew Wellington <proton[at]wiretapped.net>
 * Copyright:   2001,2002,2003 odynia.org.
*/

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);

        
// use specified juarez
        
if (!empty($params['table']))
            
$table $db->spec($params['table']);
        else
                
$table $db->spec ('auth');

            
// get any matching username
        
$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];
                if (!empty(
$details[$table->icon]))
                        
$groups['icon'] = $details[$table->icon];

        return 
$groups;
    }
}

?>


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