revert multiple virtualhosts mgmt for ITK
This commit is contained in:
parent
7a32409abd
commit
c6935e2819
|
@ -24,14 +24,11 @@ if (isset($_GET['enable']) ) {
|
||||||
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
||||||
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
||||||
|
|
||||||
|
|
||||||
# TODO: sanitize $_GET
|
|
||||||
$servername = array (
|
$servername = array (
|
||||||
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])),
|
'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);
|
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';
|
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
||||||
|
|
||||||
|
} elseif (isset($_GET['disable']) ) {
|
||||||
}
|
|
||||||
elseif (isset($_GET['disable']) ) {
|
|
||||||
require_once EVOADMIN_BASE . '../evolibs/Form.php';
|
require_once EVOADMIN_BASE . '../evolibs/Form.php';
|
||||||
|
|
||||||
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
||||||
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
||||||
|
|
||||||
|
|
||||||
# TODO: sanitize $_GET
|
|
||||||
$servername = array (
|
$servername = array (
|
||||||
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])),
|
'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);
|
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';
|
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
||||||
|
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
$domain = $params[1];
|
$domain = $params[1];
|
||||||
$data_list = array();
|
|
||||||
|
|
||||||
// TODO: adapt for cluster mode
|
// TODO: adapt for cluster mode
|
||||||
if ($conf['cluster']) {
|
if ($conf['cluster']) {
|
||||||
|
@ -97,33 +85,17 @@ else {
|
||||||
$alias_list = $bdd->list_serveralias($domain);
|
$alias_list = $bdd->list_serveralias($domain);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$cmd_itk = 'web-add.sh list-user-itk ' . $domain;
|
||||||
$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;
|
|
||||||
|
|
||||||
sudoexec($cmd_itk, $data_output_itk, $exec_return_itk);
|
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.
|
$user_itk = $data_output_itk[0];
|
||||||
array_push($data_list, ['servername' => $data_line, 'user' => $data_output_itk[0]]);
|
|
||||||
unset($data_output_itk); # reset variable pour éviter conflits
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
||||||
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
||||||
include_once EVOADMIN_BASE . '../tpl/webadmin-itk.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/webadmin-itk.tpl.php';
|
||||||
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1001,23 +1001,21 @@ op_checkoccurencename() {
|
||||||
}
|
}
|
||||||
|
|
||||||
op_listuseritk() {
|
op_listuseritk() {
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
domain=${1}
|
configfile="$VHOST_PATH/${1}.conf"
|
||||||
configfile="$VHOST_PATH/${2}.conf"
|
|
||||||
|
|
||||||
sed -n "/$domain/,/<\/VirtualHost>/p" "$configfile" | awk '/AssignUserID/ {print $2}' | uniq
|
awk '/AssignUserID/ {print $2}' "$configfile" | uniq
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
op_enableuseritk() {
|
op_enableuseritk() {
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
domain=${1}
|
configfile="$VHOST_PATH/${1}.conf"
|
||||||
configfile="$VHOST_PATH/${2}.conf"
|
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
|
||||||
group=$(sed -n "/$domain/,/<\/VirtualHost>/p" "$configfile" | awk '/AssignUserID/ {print $3}' | 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_out=$(apache2ctl configtest)
|
||||||
configtest_rc=$?
|
configtest_rc=$?
|
||||||
|
@ -1033,12 +1031,11 @@ op_enableuseritk() {
|
||||||
}
|
}
|
||||||
|
|
||||||
op_disableuseritk() {
|
op_disableuseritk() {
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
domain=${1}
|
configfile="$VHOST_PATH"/"${1}".conf
|
||||||
configfile="$VHOST_PATH"/"${2}".conf
|
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
|
||||||
group=$(sed -n "/$domain/,/<\/VirtualHost>/p" $configfile | awk '/AssignUserID/ {print $3}' | 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_out=$(apache2ctl configtest)
|
||||||
configtest_rc=$?
|
configtest_rc=$?
|
||||||
|
|
|
@ -17,12 +17,11 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(count($data_list) > 0) { ?>
|
if(!empty($user_itk)) { ?>
|
||||||
|
|
||||||
<table id="tab-list">
|
<table id="tab-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Servername</th>
|
|
||||||
<th>Utilisateur</th>
|
<th>Utilisateur</th>
|
||||||
<?php if (is_superadmin()) {
|
<?php if (is_superadmin()) {
|
||||||
print '<th>Action</th>';
|
print '<th>Action</th>';
|
||||||
|
@ -31,25 +30,23 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
for ( $i=0; $i < count($data_list); ++$i ) {
|
|
||||||
print '<tr>';
|
|
||||||
printf('<td>%s</td>',
|
|
||||||
$data_list[$i]['servername']);
|
|
||||||
printf('<td>%s</td>',
|
|
||||||
$data_list[$i]['user']);
|
|
||||||
if (is_superadmin()) {
|
|
||||||
|
|
||||||
if (strpos($data_list[$i]['user'], 'www') !== false) {
|
print '<tr>';
|
||||||
$action = ['disable', 'Désactiver'];
|
printf('<td>%s</td>',
|
||||||
} else {
|
$user_itk);
|
||||||
$action = ['enable', 'Activer'];
|
if (is_superadmin()) {
|
||||||
}
|
|
||||||
|
|
||||||
printf('<td><a href="/webadmin/itk/%s?%s=%s">'.$action[1].'</a></td>',
|
if (strpos($user_itk, 'www') !== false) {
|
||||||
$domain, $action[0], $data_list[$i]['servername']);
|
$action = ['disable', 'Désactiver'];
|
||||||
}
|
} else {
|
||||||
print '</tr>';
|
$action = ['enable', 'Activer'];
|
||||||
} ?>
|
}
|
||||||
|
|
||||||
|
printf('<td><a href="/webadmin/itk/%s?%s">'.$action[1].'</a></td>',
|
||||||
|
$domain, $action[0]);
|
||||||
|
}
|
||||||
|
print '</tr>';
|
||||||
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in a new issue