Sources for file plugins/auth/sql.php in version 2.0
Click on a comment to hide it. Click here to show all comments.
<?php
/*
* Project: Onyx: PHP Application Backend
* File: plugins/auth/sql.php
* Authentication Plugin - Authenticate against SQL database
*
* Version: 2.0
* CVS tag: $Id: sql.php,v 1.20 2003/05/31 08:29:35 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 data into the array
$details['groups'] = explode(',', $details['groups']);
// remove any references to the password field
unset($details['password']);
return $details;
}
}
?>
