Ejemplo n.º 1
0
$accts = list_whm_accts();
//get root account
$root_acc = get_cpanel_info(array('cpanel_user' => 'root'));
//update sqlite db used for cron job of backup
if (_get('do') == 'update_portable_db') {
    $db = new SQLite3('db/db');
    $hash = encrypt(serialize($accts));
    $r = $db->query("Update hashtext set hash='{$hash}'");
    add_message($r);
}
/**
 * add account
 *
 */
if (_post('task') == 'add_acc') {
    $cpanel = authorize_hwm();
    $acct = array('username' => _post('cp_username'), 'password' => _post('cp_password'), 'domain' => _post('cp_domain'), 'contactemail' => _post('cp_contactemail'));
    //create cpanel from whm
    $result = $cpanel->createacct($acct);
    if (isset($result->result) && isset($result->result[0]) && isset($result->result[0]->status) && $result->result[0]->status) {
        //check for exists acct
        $id = get_cpanel_info(array('cpanel_user' => $acct['username'], 'cpanel_host' => HW_WHM_IP));
        $_acc_id = isset($id['id']) ? $id['id'] : '';
        //add new acct to db
        update_cpacct(array('cpanel_user' => $acct['username'], 'cpanel_pass' => encrypt($acct['password']), 'cpanel_domain' => $acct['domain'], 'cpanel_host' => HW_WHM_IP, 'cpanel_email' => $acct['contactemail']), $_acc_id);
    }
    if (isset($result->result)) {
        add_message($result->result);
    } else {
        add_message('Failt !');
    }
Ejemplo n.º 2
0
/**
 *  set account pass
 * @param $data
 */
function setacctpass($data)
{
    $cpuser = _get('cpuser');
    $cppass = _post('pass');
    $cpanel = authorize_hwm();
    $res = $cpanel->setAcctPass($cpuser, $cppass);
    $result = json_decode($res);
    if (isset($result->passwd) && isset($result->passwd[0]->statusmsg) && strpos($result->passwd[0]->statusmsg, 'Password changed') !== false) {
        $row = get_cpanel_info(array('cpanel_user' => $cpuser, 'cpanel_host' => $cpanel->host));
        $cpid = isset($row['id']) ? $row['id'] : '';
        update_cpacct(array('cpanel_user' => $cpuser, 'cpanel_pass' => encrypt($cppass), 'cpanel_host' => $cpanel->host), $cpid);
    }
    //print result
    ajax_output($res);
    //send mail
    $body = HW_Twig_engine::twig_render('email/setacctpass.tpl', array('domain' => $data->domain, 'username' => $data->cpaneluser, 'email_domain' => $data->email_domain, 'cpanel_pass' => $cppass, 'cpanel_host' => $cpanel->host));
    send_mail1($data->email_domain, 'Hoangweb - thay đổi tài khoản cpanel', $body);
}