[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc/class.auth_sql.inc.php, 1.15
From: |
nomail |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc/class.auth_sql.inc.php, 1.15 |
Date: |
Thu, 30 Dec 2004 07:47:30 +0100 |
Update of /phpgwapi/inc
Added Files:
Branch:
class.auth_sql.inc.php
date: 2004/12/30 06:47:30; author: skwashd; state: Exp; lines: +39 -30
Log Message:
new HEAD
=====================================================================
<?php
/**
* Authentication based on SQL table
* @author Dan Kuykendall <address@hidden>
* @author Joseph Engo <address@hidden>
* @copyright Copyright (C) 2000-2004 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General
Public License
* @package phpgwapi
* @subpackage accounts
* @version $Id: class.auth_sql.inc.php,v 1.15 2004/12/30 06:47:30
skwashd Exp $
*/
/**
* Authentication based on SQL table
*
* @package phpgwapi
* @subpackage accounts
*/
class auth
{
var $previous_login = -1;
var $xmlrpc_methods = array();
function auth()
{
$this->xmlrpc_methods[] = array(
'name' => 'change_password',
'decription' => 'Change the current users
password'
);
}
function authenticate($username, $passwd, $passwd_type)
{
$db = $GLOBALS['phpgw']->db;
if ($passwd_type == 'text')
{
$_passwd = md5($passwd);
}
if ($passwd_type == 'md5')
{
$_passwd = $passwd;
}
$db->query("SELECT * FROM phpgw_accounts WHERE
account_lid = '$username' AND "
. "account_pwd='" . $_passwd . "' AND
account_status ='A'",__LINE__,__FILE__);
$db->next_record();
if ($db->f('account_lid'))
{
$this->previous_login =
$db->f('account_lastlogin');
return True;
}
else
{
return False;
}
}
function change_password($old_passwd, $new_passwd, $account_id
= '')
{
// Don't allow passwords changes for other accounts
when using XML-RPC
if (! $account_id ||
$GLOBALS['phpgw_info']['flags']['currentapp'] == 'login')
{
$account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
$pwd_check = " and account_pwd='" .
md5($old_passwd) . "'";
}
$encrypted_passwd = md5($new_passwd);
$GLOBALS['phpgw']->db->query("update phpgw_accounts set
account_pwd='" . md5($new_passwd) . "',"
. "account_lastpwd_change='" . time() . "'
where account_id='" . $account_id . "'" . $pwd_check,__LINE__,__FILE__);
if ($GLOBALS['phpgw']->db->affected_rows())
{
$GLOBALS['phpgw']->session->appsession('password','phpgwapi',base64_encode($new_passwd));
return $encrypted_passwd;
}
else
{
return False;
}
}
function update_lastlogin($account_id, $ip)
{
$GLOBALS['phpgw']->db->query("update phpgw_accounts set
account_lastloginfrom='"
. "$ip', account_lastlogin='" . time()
. "' where
account_id='$account_id'",__LINE__,__FILE__);
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc/class.auth_sql.inc.php, 1.15,
nomail <=