root/alternc/trunk/bureau/admin/adm_deactivate.php

Revision 1897, 4.6 kB (checked in by benjamin, 1 year ago)

correct html tags on adm_deactivate

Line 
1 <?php
2 /*
3  $Id: adm_tld.php,v 1.4 2004/11/29 17:27:04 anonymous Exp $
4  ----------------------------------------------------------------------
5  AlternC - Web Hosting System
6  Copyright (C) 2002 by the AlternC Development Team.
7  http://alternc.org/
8  ----------------------------------------------------------------------
9  Based on:
10  Valentin Lacambre's web hosting softwares: http://altern.org/
11  ----------------------------------------------------------------------
12  LICENSE
13
14  This program is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License (GPL)
16  as published by the Free Software Foundation; either version 2
17  of the License, or (at your option) any later version.
18
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  GNU General Public License for more details.
23
24  To read the license please visit http://www.gnu.org/copyleft/gpl.html
25  ----------------------------------------------------------------------
26  Original Author of file: Benjamin Sonntag
27  Purpose of file: Manage allowed TLD on the server
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 # 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
77 $backup = "";
78
79 # 1. list the domains of the user
80 # 1.1 list the domains
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 # 1.2 foreach domain, list the subdomains
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   # 2. for each subdomain
101   foreach ($r['sub'] as $k => $sub) {
102     # shortcuts
103     $type = $sub['type'];
104     $dest = $sub['dest'];
105     $sub = $sub['name'];
106     # if it's a real website
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         # 2.1 keep a copy of where it was, in an SQL request
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"; // UPDATE
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 # 3. wrap up (?)
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
Note: See TracBrowser for help on using the browser.