Author Topic: Change Password for QmailAdmin / roundcube0.2stable  (Read 4357 times)

Offline ikaris

  • Newbie
  • *
  • Posts: 2
Change Password for QmailAdmin / roundcube0.2stable
« on: February 09, 2009, 09:17:23 PM »
Base on:
 http://wheaties.us/blog/2008/12/21/change-password-roundcube/

alter function ( roundcube/program/steps/settings/password.inc ):


function rcube_save_password($current_password,$new_password)
{
        global 
$OUTPUT$RCMAIL;

        
$emailuser=$_SESSION['username'];

        
//$db = rcmail::get_instance()->get_dbh();

        // YOU MUST CHANGE THIS QUERY LINE TO MATCH YOUR DATABASE SETTINGS !!!!!
        //$passwordquery = "UPDATE database.table SET password_field =ENCRYPT('".$new_password."') WHERE user_name = '".$emailuser."';";   

        //$db->query($passwordquery);

        //console("email: $emailuser");
        //console("current password: $current_password");
        //console("New password: $new_password");

        //set POST variables
        
$url 'http://localhost/qmailadmin/index.cgi/passwd/';

        
$fields = array(
                
'address'=>urlencode($emailuser),
                
'oldpass'=>urlencode($current_password),
                
'newpass1'=>urlencode($new_password),
                
'newpass2'=>urlencode($new_password),
                );

        
//url-ify the data for the POST
        
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
        
rtrim($fields_string,'&');

        
//open connection
        
$ch curl_init();

        
//set the url, number of POST vars, POST data
        
curl_setopt($chCURLOPT_URL,$url);
        
curl_setopt($chCURLOPT_POST,count($fields));
        
curl_setopt($chCURLOPT_POSTFIELDS,$fields_string);
        
curl_setopt($chCURLOPT_POST,1);
        
curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
        
curl_setopt($chCURLOPT_HEADER,0);  // DO NOT RETURN HTTP HEADERS
        
curl_setopt($chCURLOPT_RETURNTRANSFER,1);  // RETURN THE CONTENTS OF THE CALL

        //execute post
        //console("Curl: $url$fields_string");
        
$result curl_exec($ch);

        
ob_start();
        
header("Content-Type: text/html");
        
$Temp_Output ltrim(rtrim(trim(strip_tags(trim(preg_replace "/\s\s+/" " " html_entity_decode($result)))),"\n\t\r\h\v\0 ")), "%20");
        
$Temp_Output ereg_replace (' +'' 'trim($Temp_Output));
        
$Temp_Output ereg_replace("[\r\t\n]","",$Temp_Output);

        
/* The \b in the pattern indicates a word boundary, so only the distinct
         * word "web" is matched, and not a word partial like "webbing" or "cobweb" */
        
if (preg_match("/\bsuccessfully\b/i"$Temp_Output)) {

                
//console ("Temp_Out : $Temp_Output");

                
$_SESSION['password'] = encrypt_password($new_password);

                
$OUTPUT->show_message('successfullysaved''confirmation');
        } else {
                
//console ("Temp_Out : $Temp_Output");
                
$error_msgexplode(':',$Temp_Output);
                
//console ("Error msg : $error_msg[0]");
                
$OUTPUT->show_message("$error_msg[0]"'error');
                
//$OUTPUT->show_message('errorsaving', 'error');
        
}

        
//console ("Temp_Out : $Temp_Output");
        
$Final_Out=ob_get_clean();
        
//console ("Final_Out : $Final_Out");

        //close connection
        
curl_close($ch);
}



Offline ikaris

  • Newbie
  • *
  • Posts: 2
Change Password for QmailAdmin / roundcube0.2stable
« Reply #1 on: February 09, 2009, 09:23:09 PM »