$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); } } //get all repositories saved from local $repositories = hw_svn_get_repositories(); ?> <html> <head> <title>Subversion</title> <?php include 'template/head.php';
/** * list all wp users * @param $cp */ function list_wp_user($cp) { $subdomain = _post('subdomain'); $res = $cp->upload_wptool(0, $subdomain); #ajax_output($res); //run this file $url = rtrim(_domain($cp->domain, $subdomain), '/') . '/' . HW_WP_TOOL_FILE . '?do=list_users&acc=' . $cp->acc_id; $res = curl_post($url, array('subdomain' => $subdomain)); ajax_output($res); function hw_output_table_data_cb($name, $value) { if ($name == 'svn_pass') { return decrypt($value); } return $value; } //compare to `svn_wp_users` table. echo '<h2>All WP Users on localhost</h2>'; $svn_users = hw_svn_list_users($cp->domain); hw_output_table_data($svn_users, array('id' => 'ID', 'svn_fullname' => "Fullname", 'svn_user' => 'User', 'svn_pass' => 'Pass', 'svn_email' => 'Email', 'domain' => 'Domain'), 'hw_output_table_data_cb'); }
/** * update all svn users from `svn_wp_users` table * @param $cp */ function svn_update_users($cp) { $cmd = _post('cmd'); //get command file $ssh_batch = _post('ssh_batch'); ### modify svn-update-users-passwd.txt ==>we don't use #$cmd="chmod 755 /home/svn-update-users-passwd.sh;cd /home;source ./svn-update-users-passwd.sh"; #file_put_contents(WHM_CPANEL_SHELL_APP."/x_ssh/commands/svn-update-users-passwd.txt", $cmd); //get users data from local (so if on server not match data with `svn_wp_users` table you shou;d import to server.) $htpasswd = ''; $svn_users = hw_svn_list_users('hoangweb.vn'); foreach ($svn_users as $u) { $svn_user = $u['svn_user']; $svn_depass = decrypt($u['svn_pass']); $htpasswd .= "/usr/local/apache/bin/htpasswd -bc ./{$svn_user}.svn.htpasswd {$svn_user} \"{$svn_depass}\";"; } //create .sh file $update_svn_users_passwd = "echo 'Update all svn users pass !';\r\nsudo -u {$cp->cpaneluser} -H sh -c 'cd ~;pwd;mkdir svn_users;cd svn_users;{$htpasswd}'\r\nread -n1 -r -p \"Press any key to continue...\" key"; file_put_contents(WHM_CPANEL_SHELL_APP . "/x_ssh/commands/svn-update-users-passwd.txt", $update_svn_users_passwd); //update all svn users pass $cp->run_command_as_root($ssh_batch, $cmd); }