| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
require_once("../class/config.php"); |
|---|
| 31 |
|
|---|
| 32 |
include("head.php"); |
|---|
| 33 |
?> |
|---|
| 34 |
</head> |
|---|
| 35 |
<body> |
|---|
| 36 |
<?php |
|---|
| 37 |
$uid = $_GET['uid']; |
|---|
| 38 |
if (!$uid) { |
|---|
| 39 |
__("Missing uid"); |
|---|
| 40 |
echo "</body></html>"; |
|---|
| 41 |
exit(); |
|---|
| 42 |
} |
|---|
| 43 |
if (!$admin->enabled || !$admin->checkcreator($uid)) { |
|---|
| 44 |
__("This page is restricted to authorized staff"); |
|---|
| 45 |
echo "</body></html>"; |
|---|
| 46 |
exit(); |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
if (!$r=$admin->get($uid)) { |
|---|
| 50 |
__("User does not exist"); |
|---|
| 51 |
echo "</body></html>"; |
|---|
| 52 |
exit(); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
if (! ($confirmed = ($_GET['submit'] == _("Confirm")) ) ) { |
|---|
| 56 |
print '<h2>' . _('WARNING: experimental feature, use at your own risk') . '</h2>'; |
|---|
| 57 |
__("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."); |
|---|
| 58 |
|
|---|
| 59 |
?> |
|---|
| 60 |
<form action="<?=$PHP_SELF?>" method="GET"> |
|---|
| 61 |
<input type="hidden" name="uid" value="<?=$uid?>" /> |
|---|
| 62 |
<? __("Redirection URL:") ?> <input type="text" name="redirect" value="http://example.com/" /> |
|---|
| 63 |
<input type="submit" name="submit" value="<?=_("Confirm")?>" /> |
|---|
| 64 |
</form><?php |
|---|
| 65 |
|
|---|
| 66 |
print "<h3>" . _("Domains of user: ") . $r["login"] . "</h3>"; |
|---|
| 67 |
} else { |
|---|
| 68 |
if (!$_GET['redirect']) { |
|---|
| 69 |
__("Missing redirect url."); |
|---|
| 70 |
exit(); |
|---|
| 71 |
} else { |
|---|
| 72 |
$redirect = $_GET['redirect']; |
|---|
| 73 |
} |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
$backup = ""; |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
global $cuid; |
|---|
| 82 |
$old_cuid = $cuid; |
|---|
| 83 |
$cuid = $uid; |
|---|
| 84 |
$domains = $dom->enum_domains(); |
|---|
| 85 |
|
|---|
| 86 |
if ($confirmed) { |
|---|
| 87 |
print "<pre>"; |
|---|
| 88 |
printf(_("-- Redirecting all domains and subdomains of the user %s to %s\n"), $r['login'], $redirect); |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
reset($domains); |
|---|
| 92 |
|
|---|
| 93 |
foreach ($domains as $key => $domain) { |
|---|
| 94 |
if (!$confirmed) print '<h4>' . $domain . '</h4><ul>'; |
|---|
| 95 |
$dom->lock(); |
|---|
| 96 |
if (!$r=$dom->get_domain_all($domain)) { |
|---|
| 97 |
$error=$err->errstr(); |
|---|
| 98 |
} |
|---|
| 99 |
$dom->unlock(); |
|---|
| 100 |
|
|---|
| 101 |
foreach ($r['sub'] as $k => $sub) { |
|---|
| 102 |
|
|---|
| 103 |
$type = $sub['type']; |
|---|
| 104 |
$dest = $sub['dest']; |
|---|
| 105 |
$sub = $sub['name']; |
|---|
| 106 |
|
|---|
| 107 |
if ($type == $dom->type_local) { |
|---|
| 108 |
if (!$confirmed) { |
|---|
| 109 |
print "<li>"; |
|---|
| 110 |
if ($sub) { |
|---|
| 111 |
print $sub . '.'; |
|---|
| 112 |
} |
|---|
| 113 |
print "$domain -> $dest</li>"; |
|---|
| 114 |
} else { |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
$backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest' WHERE `domaine`='$domain' AND sub='$sub';\n"; |
|---|
| 118 |
$backup .= "DELETE FROM `sub_domaines_standby` WHERE domaine='$domain' and sub='$sub';\n"; |
|---|
| 119 |
$backup .= "INSERT INTO sub_domaines_standby (compte,domaine,sub,valeur,type,action) values ('$cuid','$domain','$sub','$dest','$type',1);\n"; |
|---|
| 120 |
|
|---|
| 121 |
# 2.2 change the subdomain to redirect to http://spam.koumbit.org/ |
|---|
| 122 |
$dom->lock(); |
|---|
| 123 |
if (!$dom->set_sub_domain($domain, $sub, $dom->type_url, "edit", $redirect)) { |
|---|
| 124 |
print "-- error in $sub.$domain: " . $err->errstr() . "\n"; |
|---|
| 125 |
} |
|---|
| 126 |
$dom->unlock(); |
|---|
| 127 |
} |
|---|
| 128 |
} |
|---|
| 129 |
} |
|---|
| 130 |
if (!$confirmed) print '</ul>'; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
if ($confirmed) { |
|---|
| 135 |
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"; |
|---|
| 136 |
print $backup; |
|---|
| 137 |
print "</pre>"; |
|---|
| 138 |
} |
|---|
| 139 |
$cuid = $old_cuid; |
|---|
| 140 |
|
|---|
| 141 |
?> |
|---|
| 142 |
</body> |
|---|
| 143 |
</html> |
|---|
| 144 |
|
|---|
| 145 |
|
|---|