Alternc  3.2
Alternc logiel libre pour l'h├ębergement
 All Data Structures Namespaces Files Functions Variables Pages
adm_deactivate.php
Go to the documentation of this file.
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_once("head.php");
33 
34 if (!$admin->enabled) {
35  __("This page is restricted to authorized staff");
36  exit;
37 }
38 $fields = array (
39  "uid" => array ("request", "integer", ""),
40  "submit" => array ("post", "string", ""),
41  "redirect" => array ("post", "string", ""),
42 );
44 
45 if (!$uid) {
46  __("Account not found");
47  include_once("foot.php");
48  exit();
49 }
50 
51 if (!$admin->checkcreator($uid)) {
52  __("This page is restricted to authorized staff");
53  include_once("foot.php");
54  exit();
55 }
56 
57 if (!$r=$admin->get($uid)) {
58  __("User does not exist");
59  include_once("foot.php");
60  exit();
61 }
62 
63 $confirmed = ($submit == _("Confirm"))?true:false;
64 
65 
66 if (! ($confirmed ) ) {
67  print '<h2>' . _('WARNING: experimental feature, use at your own risk') . '</h2>';
68  __("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.");
69 
70  ?>
71  <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
72  <input type="hidden" name="uid" value="<?php echo $uid?>" />
73  <?php __("Redirection URL:") ?> <input type="text" name="redirect" class="int" value="http://example.com/" />
74  <input type="submit" name="submit" class="inb" value="<?php __("Confirm")?>" />
75  <input type="button" class="inb" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location='adm_list.php'"/>
76  </form><?php
77 
78  print "<h3>" . _("Domains of user: ") . $r["login"] . "</h3>";
79 } else {
80  if (empty($redirect)) {
81  __("Missing redirect url.");
82  include_once("foot.php");
83  exit();
84  }
85 }
86 
87 # 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
88 $backup = "";
89 
90 # 1. list the domains of the user
91 # 1.1 list the domains
92 global $cuid;
94 $cuid = $uid;
95 $domains = $dom->enum_domains();
96 
97 if ($confirmed) {
98  print "<pre>";
99  printf(_("-- Redirecting all domains and subdomains of the user %s to %s\n"), $r['login'], $redirect);
100 }
101 
102 reset($domains);
103 # 1.2 foreach domain, list the subdomains
104 foreach ($domains as $key => $domain) {
105  if (!$confirmed) print '<h4>' . $domain . '</h4><ul>';
106  $dom->lock();
107  if (!$r=$dom->get_domain_all($domain)) {
108  $error=$err->errstr();
109  }
110  $dom->unlock();
111  # 2. for each subdomain
112  if (is_array($r['sub'])) {
113  foreach ($r['sub'] as $k => $sub) {
114 # shortcuts
115  $type = $sub['type'];
116  $dest = $sub['dest'];
117  $sub = $sub['name'];
118 # if it's a real website
119  if ($type == $dom->type_local) {
120  if (!$confirmed) {
121  print "<li>";
122  if ($sub) {
123  print $sub . '.';
124  }
125  print "$domain -> $dest</li>";
126  } else {
127 
128 # 2.1 keep a copy of where it was, in an SQL request
129  $backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE `domaine`='$domain' AND sub='$sub';\n";
130 
131 # 2.2 change the subdomain to redirect to http://spam.koumbit.org/
132  $dom->lock();
133  if (!$dom->set_sub_domain($domain, $sub, $dom->type_url, "edit", $redirect)) {
134  print "-- error in $sub.$domain: " . $err->errstr() . "\n";
135  }
136  $dom->unlock();
137  }
138  }
139  }
140  }
141  if (!$confirmed) print '</ul>';
142 }
143 
144 # 3. wrap up (?)
145 if ($confirmed) {
146  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";
147  print $backup;
148  print "</pre>";
149 }
150 $cuid = $old_cuid;
151 
152 include_once("foot.php");
153 
154 ?>
155