Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
0
/**
 * 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;
    }
}
Ejemplo n.º 4
0
/**
 * laravel-directadmin
 *
 * Laravel bundle to access the DirectAdmin API
 *
 * @author Chris Schalenborgh <*****@*****.**>
 * @version 0.1
 * @package laravel-directadmin
 * @link http://www.directadmin.com/api.html
 * @license BSD License
 */
// configure autoloader
Autoloader::map(array('HTTPSocket' => Bundle::path('directadmin') . 'lib' . DS . 'DirectAdmin.php'));
// Register a mailer in the IoC container
IoC::singleton('DirectAdmin', function () {
    // instantiate new directadmin
    $sock = new HTTPSocket();
    // load settings
    $config = Config::get('directadmin::settings', array());
    // set host/port
    if (!empty($config['host']) && !empty($config['port'])) {
        $sock->connect($config['host'], $config['port']);
    }
    // set login/password
    if (!empty($config['login']) && !empty($config['password'])) {
        $sock->set_login($config['login'], $config['password']);
    }
    // Return the instance.
    return $sock;
});
Ejemplo n.º 5
0
<?php

echo '<pre>';
include '../Source/DA/Emails.php';
// Optional, you can pass these as arguments of the class constructor too
$socket = new HTTPSocket();
$socket->connect('topdomain.nl', 2222);
$socket->set_login('user', 'pass');
DA_Api::$DEFAULT_SOCKET = $socket;
DA_Api::$DEFAULT_DOMAIN = 'domain.nl';
// new DA_Emails instance
$emails = new DA_Emails();
// displays the users
print_r($emails->fetch());
// creates a new user, should return true
var_dump($emails->create('testing', 'test_pass', 20));
// fetches the data, quota and usage, of one user
print_r($emails->fetchUserQuota('testing'));
// sets a new password and quota
var_dump($emails->modify('testing', 'new_test_pass', 30));
// fetches all data, including quotas and usage
print_r($emails->fetchQuotas());
// deletes the test user, should be true
var_dump($emails->delete('testing'));
Ejemplo n.º 6
0
<?php

echo '<pre>';
include_once '../Source/HTTPSocket.php';
$sock = new HTTPSocket();
$sock->connect('domain.nl', 2222);
$sock->set_login('DirectAdminUsername', 'DirectAdminPassword');
include_once '../Source/DA/Emails.php';
$emails = new DA_Emails($sock, 'domain.com');
try {
    // Fetch a list of users (before the @ sign) or pop emails
    print_r($emails->fetch());
    // Fetch a list of users and their usage and quota
    print_r($emails->fetchQuotas());
    // Fetch the quota and usage for a single user
    print_r($emails->fetchUserQuota('username'));
    // Create a user email => username - password - quota (MiB)
    var_dump($emails->create('username', 'pass', 50));
    // Modify a user email => username - password - quota (MiB)
    var_dump($emails->modify('username'));
    // Delete a user email
    var_dump($emails->delete('username'));
} catch (DA_Exception $e) {
    echo $e->getMessage();
}
include_once '../Source/DA/Forwarders.php';
$fwd = new DA_Forwarders($sock);
$fwd->setDomain('refox.nl');
try {
    // Fetch a list of users and their forward emails
    print_r($fwd->fetch());