示例#1
0
/**
 * create wp user
 * @param $cp
 */
function create_wp_user($cp)
{
    $subdomain = _post('subdomain');
    $wp_user = _post('user');
    $wp_pass = _post('pass');
    $wp_email = _post('email');
    $role = _post('role');
    $login_path = _post('login_path', '/login');
    $fullname = urldecode(_post('fullname'));
    $update_svn_user = _post('update_svn_user');
    //check for exist user in db, wp user is unique for all cpanel domain
    /*$exist_u = hw_svn_get_user(array(
            'svn_user' => $wp_user
        ));
    
        if($exist_u && count($exist_u)) {
            echo "Sory, exists user {$wp_user}. Choose a other name.";
            exit();
        }*/
    //update wp tool on wp root
    $res = $cp->upload_wptool($cp->acc_id, $subdomain);
    ajax_output($res);
    //run this file
    $url = rtrim(_domain($cp->domain, $subdomain), '/') . '/' . HW_WP_TOOL_FILE . '?do=create_user&acc=' . $cp->acc_id;
    $data = array('user' => _post('user'), 'pass' => _post('pass'), 'email' => _post('email'), 'fullname' => $fullname, 'role' => $role, 'update_svn_user' => $update_svn_user);
    $res = curl_post($url, $data);
    $result = json_decode($res);
    ajax_output($res);
    //save to db option
    if (_post('savedb') && $result) {
        $myuser = array('svn_user' => $wp_user, 'svn_pass' => encrypt($wp_pass), 'svn_fullname' => $fullname, 'svn_email' => $wp_email, 'domain' => $cp->domain . (trim($subdomain, '/') ? '/' . trim($subdomain, '/') : ''));
        //add new or update user
        $_user = hw_svn_get_user(array('svn_user' => $wp_user));
        if ($_user && count($_user)) {
            //update exist user
            $res = hw_svn_adduser($myuser, $_user['id']);
        } else {
            $res = hw_svn_adduser($myuser);
        }
        //add new user
        #$res = hw_svn_update_user($myuser, array('svn_user' => $wp_user ));    //other way
        ajax_output($res ? "Add svn user [{$myuser['svn_user']}] successful !" : "Fail adding svn user to manager because exist !");
    }
    //send mail
    if (isset($result->email)) {
        //login path
        $login_url = rtrim(hw_valid_url($cp->domain), '/') . '/' . ltrim($login_path, '/');
        $body = HW_Twig_engine::twig_render('email/create_wp_user.tpl', array('domain' => $cp->domain, 'username' => $cp->cpaneluser, 'email_domain' => $cp->email_domain, 'user' => $result->user, 'pass' => $result->pass, 'email' => $result->email, 'login_url' => $login_url));
        send_mail1($result->email, 'Hoangweb.COM - tạo tài khoản đăng nhập Wordpress', $body);
    }
}
示例#2
0
$acc_id = '4';
//refer to hoangweb.vn
$acc = get_cpanel_acc($acc_id);
$host = isset($acc['cpanel_host']) ? $acc['cpanel_host'] : '';
$domain = isset($acc['cpanel_domain']) ? $acc['cpanel_domain'] : '';
$cpaneluser = isset($acc['cpanel_user']) ? $acc['cpanel_user'] : HW_WHM_ROOT_USER;
$cpaneluser_pass = isset($acc['cpanel_pass']) ? decrypt($acc['cpanel_pass']) : HW_WHM_ROOT_PASS;
$email_domain = isset($acc['cpanel_email']) ? $acc['cpanel_email'] : '*****@*****.**';
define('SVN_REPOSITORY_URL', 'http://svn.hoangweb.vn');
$task = _post('task');
//detect job
if (isset($_POST['submit'])) {
    if ($task == 'addsvn_user') {
        $user = array('svn_user' => _post('svn_user'), 'svn_pass' => encrypt(_post('svn_user_pass')), 'svn_fullname' => _post('svn_fullname'), 'svn_email' => _post('svn_user_email'));
        //add new or update user
        $res = hw_svn_adduser($user, _post('user'));
        add_message($res ? "Add svn user [{$user['svn_user']}] successful !" : "Add svn user failt !");
    }
}
//list accts
$accts = list_whm_accts();
//list dbs
//$list_dbs = get_acct_dbs();
//list all svn users
$users = hw_svn_list_users();
//get user to edit
if (_get('do') == 'edituser') {
    $user = hw_svn_get_user(array('svn_user' => _get('user')));
    if (!count($user)) {
        unset($user);
    }
示例#3
0
/**
 * update svn user in db
 * @param $cp
 */
function svn_update_user($cp)
{
    $user = _get('svn_user');
    if (is_numeric($user)) {
        $fields = array('svn_fullname', 'svn_user', 'svn_pass', 'svn_email');
        $userdata = array();
        foreach ($fields as $f) {
            if (_post($f)) {
                $userdata[$f] = _post($f);
            }
        }
        if (count($userdata)) {
            hw_svn_adduser($userdata, $user);
        }
    }
}