コード例 #1
0
 public function save($curpass, $passwd)
 {
     $rcmail = rcmail::get_instance();
     $Socket = new HTTPSocket();
     $da_user = $_SESSION['username'];
     $da_curpass = $curpass;
     $da_newpass = $passwd;
     $da_host = $rcmail->config->get('password_directadmin_host');
     $da_port = $rcmail->config->get('password_directadmin_port');
     if (strpos($da_user, '@') === false) {
         return array('code' => PASSWORD_ERROR, 'message' => 'Change the SYSTEM user password through control panel!');
     }
     $da_host = str_replace('%h', $_SESSION['imap_host'], $da_host);
     $da_host = str_replace('%d', $rcmail->user->get_username('domain'), $da_host);
     $Socket->connect($da_host, $da_port);
     $Socket->set_method('POST');
     $Socket->query('/CMD_CHANGE_EMAIL_PASSWORD', array('email' => $da_user, 'oldpassword' => $da_curpass, 'password1' => $da_newpass, 'password2' => $da_newpass, 'api' => '1'));
     $response = $Socket->fetch_parsed_body();
     //DEBUG
     //rcube::console("Password Plugin: [USER: $da_user] [HOST: $da_host] - Response: [SOCKET: ".$Socket->result_status_code."] [DA ERROR: ".strip_tags($response['error'])."] [TEXT: ".$response[text]."]");
     if ($Socket->result_status_code != 200) {
         return array('code' => PASSWORD_CONNECT_ERROR, 'message' => $Socket->error[0]);
     } elseif ($response['error'] == 1) {
         return array('code' => PASSWORD_ERROR, 'message' => strip_tags($response['text']));
     } else {
         return PASSWORD_SUCCESS;
     }
 }
コード例 #2
0
 public static function createDB($client_id)
 {
     $cfg = erConfigClassLhConfig::getInstance();
     $sock = new HTTPSocket();
     $sock->connect('ssl://' . $cfg->getSetting('site', 'direct_admin_ip'), $cfg->getSetting('site', 'direct_admin_port'));
     $sock->set_login($cfg->getSetting('site', 'direct_admin_user'), $cfg->getSetting('site', 'direct_admin_pass'));
     $sock->set_method('POST');
     $sock->query('/CMD_API_DATABASES', array('action' => 'create', 'name' => "client{$client_id}", 'userlist' => $cfg->getSetting('site', 'direct_admin_dbuser'), 'passwd' => $cfg->getSetting('site', 'direct_admin_dbpass'), 'passwd2' => $cfg->getSetting('site', 'direct_admin_dbpass')));
     return $sock->fetch_body();
 }
コード例 #3
0
ファイル: directadmin.php プロジェクト: bahrmichael/eyeos
/**
 * DirectAdmin Password Driver
 *
 * Driver to change passwords via DirectAdmin Control Panel
 *
 * @version 1.0
 * @author Victor Benincasa <*****@*****.**>
 *
 */
function password_save($curpass, $passwd)
{
    $rcmail = rcmail::get_instance();
    $Socket = new HTTPSocket();
    $da_user = $_SESSION['username'];
    $da_curpass = $curpass;
    $da_newpass = $passwd;
    $da_host = $rcmail->config->get('password_directadmin_host');
    $da_port = $rcmail->config->get('password_directadmin_port');
    $Socket->connect($da_host, $da_port);
    $Socket->set_method('POST');
    $Socket->query('/CMD_CHANGE_EMAIL_PASSWORD', array('email' => $da_user, 'oldpassword' => $da_curpass, 'password1' => $da_newpass, 'password2' => $da_newpass, 'api' => '1'));
    $response = $Socket->fetch_parsed_body();
    //console("DA error response: $response[text] [$da_user]");
    if ($Socket->result_status_code != 200) {
        return PASSWORD_CONNECT_ERROR;
    } elseif ($response['error'] == 1) {
        //Error description: $response[text]
        return PASSWORD_ERROR;
    } else {
        return PASSWORD_SUCCESS;
    }
}