enabled) {
$msg->raise("ERROR", "admin", _("This page is restricted to authorized staff"));
echo $msg->msg_html_all();
exit;
}
$fields = array (
"uid" => array ("request", "integer", ""),
"submit" => array ("post", "string", ""),
"redirect" => array ("post", "string", ""),
);
getFields($fields);
if (!$uid) {
$msg->raise("ERROR", "admin", _("Account not found"));
echo $msg->msg_html_all();
include_once("foot.php");
exit();
}
if (!$admin->checkcreator($uid)) {
$msg->raise("ERROR", "admin", _("This page is restricted to authorized staff"));
echo $msg->msg_html_all();
include_once("foot.php");
exit();
}
if (!$r=$admin->get($uid)) {
$msg->raise("ERROR", "admin", _("User does not exist"));
echo $msg->msg_html_all();
include_once("foot.php");
exit();
}
$confirmed = ($submit == _("Confirm"))?true:false;
if (! ($confirmed ) ) {
print '
' . _('WARNING: experimental feature, use at your own risk') . '
';
__("The following domains will be deactivated and redirected to the URL entered in the following box. A backup of the domain configuration will be displayed as a serie of SQL request that you can run to restore the current configuration if you want. Click confirm if you are sure you want to deactivate all this user's domains.");
?>
" . _("Domains of user: ") . $r["login"] . "";
} else {
if (empty($redirect)) {
$msg->raise("ERROR", "admin", _("Missing redirect url."));
echo $msg->msg_html_all();
include_once("foot.php");
exit();
}
}
// this string will contain an SQL request that will be printed at the end of the process and that can be used to reload the old domain configuration
$backup = "";
# 1. list the domains of the user
# 1.1 list the domains
global $cuid;
$old_cuid = $cuid;
$cuid = $uid;
$domains = $dom->enum_domains();
if ($confirmed) {
print "";
printf(_("-- Redirecting all domains and subdomains of the user %s to %s\n"), $r['login'], $redirect);
}
reset($domains);
# 1.2 foreach domain, list the subdomains
foreach ($domains as $key => $domain) {
if (!$confirmed) print '' . $domain . '
';
$dom->lock();
$r=$dom->get_domain_all($domain);
$dom->unlock();
# 2. for each subdomain
if (is_array($r['sub'])) {
foreach ($r['sub'] as $k => $sub) {
# shortcuts
$type = $sub['type'];
$dest = $sub['dest'];
$sub = $sub['name'];
# if it's a real website
if ($type == $dom->type_local) {
if (!$confirmed) {
print "- ";
if ($sub) {
print $sub . '.';
}
print "$domain -> $dest
";
} else {
# 2.1 keep a copy of where it was, in an SQL request
$backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE `domaine`='$domain' AND sub='$sub';\n";
# 2.2 change the subdomain to redirect to http://spam.koumbit.org/
$dom->lock();
if (!$dom->set_sub_domain($domain, $sub, $dom->type_url, "edit", $redirect)) {
print "-- error in $sub.$domain: ";
echo $msg->msg_html("ERROR");
}
$dom->unlock();
}
}
}
}
if (!$confirmed) print '
';
}
# 3. wrap up (?)
if ($confirmed) {
print "-- The following is a serie of SQL request you can run, as root, to revert the user's domains to their previous state.\n";
print $backup;
print "";
}
$cuid = $old_cuid;
include_once("foot.php");
?>