diff -u8pN rcmail/patch_ab_rc.txt new_rcmail/patch_ab_rc.txt
--- rcmail/patch_ab_rc.txt 2006-05-23 19:02:46.000000000 +0200
+++ new_rcmail/patch_ab_rc.txt 2006-06-06 18:36:50.000000000 +0200
@@ -10,17 +10,17 @@ diff -ruN -x .svn -x config -x program r
+session_start();
+if ($_GET['do'] == 'login'){
+$_POST['_action'] = 'login';
+}
+//eof rcmail_module
define('RCMAIL_VERSION', '0.1-20060505');
// define global vars
-@@ -116,7 +121,27 @@
+@@ -116,7 +121,26 @@
// init necessary objects for GUI
load_gui();
+//bof rcmail_module
+if ($_GET['do'] == 'login'){
+include_once('../rcmail.module');
+ global $DB, $CACHE_KEYS;
@@ -29,17 +29,16 @@ diff -ruN -x .svn -x config -x program r
+ WHERE sessions.sid = '".session_id()."'" .
+ "and sessions.uid=users.uid" .
+ "");
+ $IDENTITY_RECORD = $DB->fetch_assoc();
+ $sdb=unserialize($IDENTITY_RECORD[data]);
+ //print_r ($sdb);
+
+$_POST['_user'] = $sdb[rcmail_username];
-+//$_POST['_pass'] = _decrypt($sdb[rcmail_password]);
-+$_POST['_pass'] = $sdb[rcmail_password];
++$_POST['_pass'] = _decrypt($sdb[rcmail_password]);
+$_POST['_action'] = 'login';
+$_POST['_host'] = $sdb[rcmail_server];
+}
+//eof rcmail_module
// check DB connections and exit on failure
if ($err_str = $DB->is_error())
diff -u8pN rcmail/rcmail.module new_rcmail/rcmail.module
--- rcmail/rcmail.module 2006-05-23 19:02:46.000000000 +0200
+++ new_rcmail/rcmail.module 2006-06-06 17:59:34.000000000 +0200
@@ -42,17 +42,17 @@ $form["rcmail_iframe_width"] = array(
$form["rcmail_iframe_height"] = array(
'#type' => 'textfield',
'#title' => t("iframe height"),
'#default_value' => variable_get("rcmail_iframe_height", "550"),
'#size' => 10,
'#maxlength' => 15,
'#description' => t("Enter width of the iframe. Optimum is 550px"),
);
- drupal_get_form('rcmail',$form);
+ return $form;
}
function rcmail_perm() {
return array('use rcmail', 'adminster rcmail');
}
/**
* hook_menu() implementation
@@ -65,17 +65,17 @@ function rcmail_perm() {
* Grab the settings of the imap account for each user
*/
function rcmail_user($type, &$edit, &$user, $category = NULL) {
switch ($type) {
case 'form':
if ($category == 'account' && user_access('use rcmail')) {
//$user_status = $edit['rcmail_status'] != NULL ? $edit['rcmail_status'] : ($user->rcmail_status != NULL ? $user->rcmail_status : variable_get('rcmail_default_state', 0));
- $dec=$edit['rcmail_password'];
+ $dec=_decrypt($edit['rcmail_password']);
$form['rcmail_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Roundcubemail Settings for your IMAP account'),
'#collapsible' => TRUE,
'#weight' => 4);
$form['rcmail_settings']['rcmail_username'] = array(
@@ -105,20 +105,17 @@ $form['rcmail_settings']['rcmail_passwor
'#description' => t('Enter the servername of your IMAP account.'),
);
return $form;
} //eof if
case 'update':
- global $form_values;
- $dec=$form_values['rcmail_password'];
- //$enc='foo'._encrypt($dec);
- return $edit['rcmail_password'] = $dec;
+ $edit['rcmail_password'] = _encrypt($edit['rcmail_password']);
} //eof switch $type
}
/**
* hook_menu() implementation
*/
function rcmail_menu() {
$items[] = array(
@@ -131,30 +128,33 @@ function rcmail_menu() {
}
/**
* callback to return the iframe with roundcube inside
*/
function rcmail_page(){
global $user;
- $content='';
+ $height = variable_get("rcmail_iframe_height", "550");
+ $width = variable_get("rcmail_iframe_width", "850");
+ $content='';
print theme('page', $content);
}
/**
* decrypt the password of imap account stored in drupals users settings
* callback from roundcubemail/index.php
* @param $enc
* an encrypted string
* @return
* return the decrypted string
*/
function _decrypt($enc) {
$key='zugbz766fhgfv';
+ $enc = base64_decode($enc);
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$dec = mcrypt_decrypt(MCRYPT_XTEA, $key, $enc, MCRYPT_MODE_ECB, $iv);
return $dec;
}
/**
* encrypt the password grabed from the user settings
@@ -164,16 +164,17 @@ function _decrypt($enc) {
* @return
* return the encrypted string
*/
function _encrypt($dec) {
$key='zugbz766fhgfv';
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$enc = mcrypt_encrypt(MCRYPT_XTEA, $key, $dec, MCRYPT_MODE_ECB, $iv);
- return $key;
+ $enc = base64_encode($enc);
+ return $enc;
}
function _testfunc(){
echo "foo";
}
-?>
\ Pas de fin de ligne à la fin du fichier.
+?>