diff --git a/inc/webadmin-itk.php b/inc/webadmin-itk.php index 680c653..0fcc14a 100644 --- a/inc/webadmin-itk.php +++ b/inc/webadmin-itk.php @@ -24,14 +24,11 @@ if (isset($_GET['enable']) ) { include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; - - # TODO: sanitize $_GET $servername = array ( 'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])), - 'servername' => $_GET['enable'] ); - $enable_cmd = 'web-add.sh enable-user-itk ' . $servername['servername'] . ' ' . $servername['domain']; + $enable_cmd = 'web-add.sh enable-user-itk ' . $servername['domain']; sudoexec($enable_cmd, $enable_cmd_output, $enable_cmd_return); @@ -42,22 +39,17 @@ if (isset($_GET['enable']) ) { include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; - -} -elseif (isset($_GET['disable']) ) { +} elseif (isset($_GET['disable']) ) { require_once EVOADMIN_BASE . '../evolibs/Form.php'; include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; - - # TODO: sanitize $_GET $servername = array ( 'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])), - 'servername' => $_GET['disable'] ); - $disable_cmd = 'web-add.sh disable-user-itk ' . $servername['servername'] . ' ' . $servername['domain']; + $disable_cmd = 'web-add.sh disable-user-itk ' . $servername['domain']; sudoexec($disable_cmd, $disable_cmd_output, $disable_cmd_return); @@ -68,12 +60,8 @@ elseif (isset($_GET['disable']) ) { include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; - -} -else { - +} else { $domain = $params[1]; - $data_list = array(); // TODO: adapt for cluster mode if ($conf['cluster']) { @@ -97,33 +85,17 @@ else { $alias_list = $bdd->list_serveralias($domain); } else { - - $cmd = 'web-add.sh list-servername ' . $domain; - - if(!is_superadmin()) { - $cmd = sprintf('%s %s', $cmd, $_SESSION['user']); - } - sudoexec($cmd, $data_output, $exec_return); - - # à revérifier (notamment gestion erreurs) - if ($exec_return == 0) { - foreach($data_output as $data_line) { - $cmd_itk = 'web-add.sh list-user-itk ' . $data_line . ' ' . $domain; + $cmd_itk = 'web-add.sh list-user-itk ' . $domain; sudoexec($cmd_itk, $data_output_itk, $exec_return_itk); - # on prend le premier résultat du tableau, ne fonctionne pas s'il y a plusieurs la même ligne ou des commentaires etc. - array_push($data_list, ['servername' => $data_line, 'user' => $data_output_itk[0]]); - unset($data_output_itk); # reset variable pour éviter conflits - } - } + $user_itk = $data_output_itk[0]; } include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; include_once EVOADMIN_BASE . '../tpl/webadmin-itk.tpl.php'; include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; - } ?> diff --git a/scripts/web-add.sh b/scripts/web-add.sh index 37d1948..5a560c8 100755 --- a/scripts/web-add.sh +++ b/scripts/web-add.sh @@ -1001,23 +1001,21 @@ op_checkoccurencename() { } op_listuseritk() { - if [ $# -eq 2 ]; then - domain=${1} - configfile="$VHOST_PATH/${2}.conf" + if [ $# -eq 1 ]; then + configfile="$VHOST_PATH/${1}.conf" - sed -n "/$domain/,/<\/VirtualHost>/p" "$configfile" | awk '/AssignUserID/ {print $2}' | uniq + awk '/AssignUserID/ {print $2}' "$configfile" | uniq else usage fi } op_enableuseritk() { - if [ $# -eq 2 ]; then - domain=${1} - configfile="$VHOST_PATH/${2}.conf" - group=$(sed -n "/$domain/,/<\/VirtualHost>/p" "$configfile" | awk '/AssignUserID/ {print $3}' | uniq) + if [ $# -eq 1 ]; then + configfile="$VHOST_PATH/${1}.conf" + group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq) - sed -i "/$domain/,/<\/VirtualHost>/ s/^ *AssignUserID $group/ AssignUserID www-$group/" "$configfile" --follow-symlinks + sed -i "s/^ *AssignUserID $group/ AssignUserID www-$group/" "$configfile" --follow-symlinks configtest_out=$(apache2ctl configtest) configtest_rc=$? @@ -1033,12 +1031,11 @@ op_enableuseritk() { } op_disableuseritk() { - if [ $# -eq 2 ]; then - domain=${1} - configfile="$VHOST_PATH"/"${2}".conf - group=$(sed -n "/$domain/,/<\/VirtualHost>/p" $configfile | awk '/AssignUserID/ {print $3}' | uniq) + if [ $# -eq 1 ]; then + configfile="$VHOST_PATH"/"${1}".conf + group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq) - sed -i "/$domain/,/<\/VirtualHost>/ s/^ *AssignUserID www-$group/ AssignUserID ${group}/" "$configfile" --follow-symlinks + sed -i "s/^ *AssignUserID www-$group/ AssignUserID ${group}/" "$configfile" --follow-symlinks configtest_out=$(apache2ctl configtest) configtest_rc=$? diff --git a/tpl/webadmin-itk.tpl.php b/tpl/webadmin-itk.tpl.php index 9554eea..e5ca180 100644 --- a/tpl/webadmin-itk.tpl.php +++ b/tpl/webadmin-itk.tpl.php @@ -17,12 +17,11 @@ 0) { ?> + if(!empty($user_itk)) { ?> - Action'; @@ -31,25 +30,23 @@ '; - printf('', - $data_list[$i]['servername']); - printf('', - $data_list[$i]['user']); - if (is_superadmin()) { - if (strpos($data_list[$i]['user'], 'www') !== false) { - $action = ['disable', 'Désactiver']; - } else { - $action = ['enable', 'Activer']; - } + print ''; + printf('', + $user_itk); + if (is_superadmin()) { - printf('', - $domain, $action[0], $data_list[$i]['servername']); - } - print ''; - } ?> + if (strpos($user_itk, 'www') !== false) { + $action = ['disable', 'Désactiver']; + } else { + $action = ['enable', 'Activer']; + } + + printf('', + $domain, $action[0]); + } + print ''; + ?>
Servername Utilisateur
%s%s
%s'.$action[1].'
'.$action[1].'