mirror of
https://github.com/moparisthebest/user_sql
synced 2024-11-21 16:55:02 -05:00
Added "Joomla" encryption type (thanks Frédéric France)
Added sort order and minimal caching (thanks Ed W)
This commit is contained in:
parent
ea2f18b22b
commit
a767fe07a7
@ -24,7 +24,7 @@
|
||||
<p><label for="sql_column_username"><?php echo $l->t('Username Column');?></label><input type="text" id="sql_column_username" name="sql_column_username" value="<?php echo $_['sql_column_username']; ?>" /></p>
|
||||
<p><label for="sql_column_password"><?php echo $l->t('Password Column');?></label><input type="text" id="sql_column_password" name="sql_column_password" value="<?php echo $_['sql_column_password']; ?>" /></p>
|
||||
<p><label for="crypt_type"><?php echo $l->t('Encryption Type');?></label>
|
||||
<?php $crypt_types = array('md5' => 'MD5', 'md5crypt' => 'MD5 Crypt', 'cleartext' => 'Cleartext', 'mysql_encrypt' => 'mySQL ENCRYPT()', 'system' => 'System (crypt)', 'mysql_password' => 'mySQL PASSWORD()');?>
|
||||
<?php $crypt_types = array('md5' => 'MD5', 'md5crypt' => 'MD5 Crypt', 'cleartext' => 'Cleartext', 'mysql_encrypt' => 'mySQL ENCRYPT()', 'system' => 'System (crypt)', 'mysql_password' => 'mySQL PASSWORD()', 'joomla' => 'Joomla MD5 Encryption');?>
|
||||
<select id="crypt_type" name="crypt_type">
|
||||
<?php
|
||||
foreach ($crypt_types as $driver => $name):
|
||||
|
27
user_sql.php
27
user_sql.php
@ -3,9 +3,13 @@
|
||||
/**
|
||||
* ownCloud - user_sql
|
||||
*
|
||||
* @author Andreas Böhler
|
||||
* @author Andreas Böhler and contributors
|
||||
* @copyright 2012/2013 Andreas Böhler <andreas (at) aboehler (dot) at>
|
||||
*
|
||||
* credits go to Ed W for several SQL injection fixes and caching support
|
||||
* credits go to Frédéric France for providing Joomla support
|
||||
* credits go to
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
@ -200,7 +204,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
|
||||
|
||||
public function getUsers($search = '', $limit = null, $offset = null)
|
||||
{
|
||||
OC_Log::write('OC_USER_SQL', "Entering getUsers() with Search: $search", OC_Log::DEBUG);
|
||||
OC_Log::write('OC_USER_SQL', "Entering getUsers() with Search: $search, Limit: $limit, Offset: $offset", OC_Log::DEBUG);
|
||||
$users = array();
|
||||
if(!$this->db_conn)
|
||||
{
|
||||
@ -217,6 +221,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
|
||||
$query .= " WHERE";
|
||||
$query .= " $this->sql_column_active = 1";
|
||||
}
|
||||
$query .= " ORDER BY $this->sql_column_username";
|
||||
if($limit != null)
|
||||
{
|
||||
$limit = intval($limit);
|
||||
@ -264,6 +269,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
|
||||
|
||||
public function userExists($uid)
|
||||
{
|
||||
static $cached_exists;
|
||||
OC_Log::write('OC_USER_SQL', "Entering userExists() for UID: $uid", OC_Log::DEBUG);
|
||||
if(!$this->db_conn)
|
||||
{
|
||||
@ -276,6 +282,10 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
|
||||
}
|
||||
$uid = strtolower($uid);
|
||||
|
||||
if ($uid === $cached_exists) {
|
||||
OC_Log::write('OC_USER_SQL', "User exists (using cache), return true", OC_Log::DEBUG);
|
||||
return true;
|
||||
}
|
||||
$query = "SELECT $this->sql_column_username FROM $this->sql_table WHERE $this->sql_column_username = :uid";
|
||||
if($this->sql_column_active != '')
|
||||
$query .= " AND $this->sql_column_active = 1";
|
||||
@ -299,6 +309,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
|
||||
else
|
||||
{
|
||||
OC_Log::write('OC_USER_SQL', "User exists, return true", OC_Log::DEBUG);
|
||||
$cached_exists = $uid;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -396,6 +407,18 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface {
|
||||
$password = $row[0];
|
||||
}
|
||||
|
||||
// The following is by Frédéric France
|
||||
elseif($this->crypt_type == 'joomla')
|
||||
{
|
||||
$split_salt = preg_split ('/:/', $pw_db);
|
||||
if(isset($split_salt[1]))
|
||||
{
|
||||
$salt = $split_salt[1];
|
||||
}
|
||||
$password = ($salt) ? md5($pw.$salt) : md5($pw);
|
||||
$password.= ':'.$salt;
|
||||
}
|
||||
|
||||
else {
|
||||
OC_Log::write('OC_USER_SQL', "unknown/invalid crypt_type settings: $this->crypt_type", OC_Log::ERROR);
|
||||
die ('unknown/invalid Encryption type setting: ' . $this->crypt_type);
|
||||
|
Loading…
Reference in New Issue
Block a user