I just found a encrypt / decrypt php class...
Code:
<?php
class ENCRYPTION
{
var $KEY = "NEED_A_DECENT_KEY";
//Encrypt Function
function encrypt($string)
{
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->KEY,
$string, MCRYPT_MODE_ECB, $iv);
$encoded = base64_encode($passcrypt);
return $encoded;
}
//Decrypt Function
function decrypt($string)
{
$decoded = base64_decode($string);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->KEY,
$decoded, MCRYPT_MODE_ECB, $iv);
return trim($decrypted);
}
}
?>
This could be used to store the password in the "remember me" cookie so the com_connector can then de-crypt the value and use this?
EDIT....
These are the changes I am going to try (don't know if it will work yet, but its worth a shot.
USE THIS AT YOUR OWN RISK)...
com_connector - joomla.php changes...
Code:
<?php
/**
* Login validation function
*
* Username and encoded password is compare to db entries in the jos_users
* table. A successful validation updates the current session record with
* the users details.
*/
function login( $username=null,$passwd=null ) {
global $acl;
$encryption = new encryption;
$usercookie = mosGetParam( $_COOKIE, 'usercookie', '' );
$sessioncookie = mosGetParam( $_COOKIE, 'sessioncookie', '' );
// set clean password
if (!$usercookie)
{
$cleanpasswd=mosGetParam( $_POST, 'passwd', '' );
$remember = mosGetParam( $_POST, 'remember', '' );
}
else
{
$cleanpasswd=$encryption->decrypt($usercookie[md5($encryption->COOKIEKEY)]);
$remember = "yes";
}
// deal with null username or password
if (!$username || !$passwd) {
$username = mosGetParam( $_POST, 'username', '' );
$passwd = mosGetParam( $_POST, 'passwd', '' );
$passwd = md5( $passwd );
$bypost = 1;
}
/*echo "<script> alert(\"(Debug) username=".$username." passwd=".$passwd." cleanpasswd=".$cleanpasswd."\");</script>\n";*/
if (!$username || !$passwd) {
/*echo "<script> alert(\""._LOGIN_INCOMPLETE."\"); window.history.go(-1); </script>\n";*/
$this->logout();
exit();
} else {
$query = "SELECT *"
. "\n FROM #__users"
. "\n WHERE username = '$username'"
. "\n AND password = '$passwd'"
;
$this->_db->setQuery( $query );
$row = null;
if ($this->_db->loadObject( $row )) {
if ($row->block == 1) {
mosErrorAlert(_LOGIN_BLOCKED);
}
// fudge the group stuff
$grp = $acl->getAroGroup( $row->id );
$row->gid = 1;
if ($acl->is_group_child_of( $grp->name, 'Registered', 'ARO' ) ||
$acl->is_group_child_of( $grp->name, 'Public Backend', 'ARO' )) {
// fudge Authors, Editors, Publishers and Super Administrators into the Special Group
$row->gid = 2;
}
$row->usertype = $grp->name;
$session =& $this->_session;
$session->guest = 0;
$session->username = $username;
$session->userid = intval( $row->id );
$session->usertype = $row->usertype;
$session->gid = intval( $row->gid );
$session->update();
$currentDate = date("Y-m-d\TH:i:s");
$query = "UPDATE #__users"
. "\n SET lastvisitDate = '$currentDate'"
. "\n WHERE id = $session->userid"
;
$this->_db->setQuery($query);
if (!$this->_db->query()) {
die($this->_db->stderr(true));
}
if ($remember=="yes") {
$lifetime = time() + 365*24*60*60;
setcookie( "usercookie[username]", $username, $lifetime, "/" );
setcookie( "usercookie[password]", $passwd, $lifetime, "/" );
setcookie( "usercookie[".md5($encryption->COOKIEKEY)."]", $encryption->encrypt($cleanpasswd), $lifetime, "/" );
}
// COM_CONNECTOR by leonsio BEGIN
//echo("<br>BEGIN COM_CONNECTOR");
//if(!func_get_arg(0) && !func_get_arg(1))
//{
$query =" SELECT * "
."\n FROM #__connectors "
."\n WHERE published=1 ";
$this->_db->setQuery($query);
$data = $this->_db->loadObjectList();
$cookies=array();
foreach ( $data as $module )
{
// include module
require_once("./components/com_connector/modules/$module->module.class.php");
// module init
$params=new mosParameters($module->params);
$application=new $module->module($params, $module->id);
// try to login with module
if($application->login($username, $cleanpasswd))
{
// cookies
$cookies[$module->id]=$application->getcookies();
// session cookies
foreach( $cookies[$module->id] AS $name => $value)
{
//echo("<br>name=".$name." value[0]=".$value[0]);
setcookie($name, $value[0], $lifetime, $value[1]);
}
}
else
{
// unable to login with module, we now need to add or update the user record.
if($module->app_useradd)
{
if($application->userset($username, $cleanpasswd, $row->email))
{
// re-call the login function in this class
$this->login($username,$passwd);
break;
}
}
}
//}
//echo("<br>END COM_CONNECTOR");
// Cookies in die Datenbank speichern ( werden beim logout geloescht )
$query = "UPDATE #__users"
. "\n SET connector_cookies = '".serialize($cookies)."'"
. "\n WHERE id = $session->userid"
;
$this->_db->setQuery($query);
if (!$this->_db->query()) {
die($this->_db->stderr(true));
}
}
// COM_CONNECTOR by leonsio END
//mosCache::cleanCache('com_content');
mosCache::cleanCache();
} else {
// COM_CONNECTOR by leonsio BEGIN
//if(!func_get_arg(0) && !func_get_arg(1))
//{
$query =" SELECT * "
."\n FROM #__connectors "
."\n WHERE published=1 ";
$this->_db->setQuery($query);
$data = $this->_db->loadObjectList();
foreach ( $data as $module )
{
// Passendes Modul laden
require_once("./components/com_connector/modules/$module->module.class.php");
//Modul initalisieren
$params=new mosParameters($module->params);
$application=new $module->module($params, $module->id);
// Benutzer einlogen
if($application->login($username, $cleanpasswd) && $module->jos_useradd)
{
if($module->jos_useradd)
{
$useradded=false;
// Benutzerdaten hollen
if($application->userget($application->__userdata->userid))
{
$error=0;
$userdata=$application->__userdata;
// Registration..
$newuser = new mosUser( $this->_db );
$newuser->id = 0;
$newuser->usertype = '';
$newuser->gid = $acl->get_group_id( 'Registered', 'ARO' );
$newuser->email = $userdata->email;
$newuser->name = $userdata->name;
$newuser->username = $userdata->username;
if (!$newuser->check())
{
$error++;
}
$newuser->password = $passwd;
$newuser->registerDate = date('Y-m-d H:i:s', $userdata->joindate);
if (!$newuser->store(0,1))
{
$error++;
}
$newuser->checkin();
if($error != 0 )
$newuser->delete($newuser->id, 1);
else
{
$useradded=true;
break;
}
}
}
}
}
if(!$useradded)
{
if (isset($bypost)) {
mosErrorAlert(_LOGIN_INCORRECT);
} else {
$this->logout();
mosRedirect("index.php");
}
exit();
}
else
{
$this->login();
}
//}
// COM_CONNECTOR by leonsio END
}
}
}
/**
* User logout
*
* Reverts the current session record back to 'anonymous' parameters
*/
function logout() {
//mosCache::cleanCache('com_content');
mosCache::cleanCache();
$session =& $this->_session;
// COM_CONNECTOR by leonsio BEGIN
$userid=$session->userid;
$query =" SELECT * "
."\n FROM #__connectors "
."\n WHERE published=1 ";
$this->_db->setQuery($query);
$data = $this->_db->loadObjectList();
$cookies=array();
foreach ( $data as $module )
{
// Passendes Modul laden
require_once("./components/com_connector/modules/$module->module.class.php");
//Modul initialisieren
$params=new mosParameters($module->params);
$application=new $module->module($params, $module->id);
// Benutzer auslogen
$application->logout();
}
$query = "UPDATE #__users"
. "\n SET connector_cookies = ''"
. "\n WHERE id = $userid"
;
$this->_db->setQuery($query);
if (!$this->_db->query())
die($this->_db->stderr(true));
// COM_CONNECTOR by leonsio END
$session->guest = 1;
$session->username = '';
$session->userid = '';
$session->usertype = '';
$session->gid = 0;
$session->update();
// this is daggy??
$lifetime = time() - 1800;
$encryption = new encryption;
setcookie( "usercookie[username]", " ", $lifetime, "/" );
setcookie( "usercookie[password]", " ", $lifetime, "/" );
setcookie( "usercookie[".md5($encryption->COOKIEKEY)."]", " ", $lifetime, "/" );
setcookie( "usercookie", " ", $lifetime, "/" );
@session_destroy();
}
?>
class encryption - add this into the above file or in an include.
Code:
<?php
class encryption
{
var $KEY = "NEED_A_DECENT_KEY";
var $COOKIEKEY = "NEED_A_DECENT_KEY";
//Encrypt Function
function encrypt($string)
{
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->KEY,
$string, MCRYPT_MODE_ECB, $iv);
$encoded = base64_encode($passcrypt);
return $encoded;
}
//Decrypt Function
function decrypt($string)
{
$decoded = base64_decode($string);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->KEY,
$decoded, MCRYPT_MODE_ECB, $iv);
return trim($decrypted);
}
}
?>
Replace "NEED_A_DECENT_KEY" with something from here:
http://www.andrewscompanies.com/tools/wep.asp