Alternc  3.2
Alternc logiel libre pour l'h├ębergement
 All Data Structures Namespaces Files Functions Variables Pages
dom_edit.php
Go to the documentation of this file.
1 <?php
2 /*
3  $Id: dom_edit.php,v 1.8 2006/02/17 18:20:08 olivier 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: Edit a domain parameters
28  ----------------------------------------------------------------------
29 */
30 require_once("../class/config.php");
31 include_once("head.php");
32 
33 $fields = array (
34  "domain" => array ("request", "string", (empty($domain)?"":$domain) ),
35  "sub" => array ("request", "string", (empty($sub)?"":$sub) ),
36 );
38 
39 $dom->lock();
40 if (!$r=$dom->get_domain_all($domain)) {
41  $error=$err->errstr();
42  echo "<p class=\"alert alert-danger\">$error</p>";
43  include('foot.php');
44  die();
45 }
46 if (isset($error) && $error ) {
47  echo "<p class=\"alert alert-danger\">$error</p>";
48 }
49 $dom->unlock();
50 
51 ?>
52 <script type="text/javascript">
53 function dnson() {
54  alert('This function seems unused. If you see this message, please let us know.');
55  // Active les composants DNS :
56  if (document.forms["fdns"].mx.disabled!=null)
57  document.forms["fdns"].mx.disabled=false;
58  if (document.forms["fdns"].emailon.disabled!=null)
59  document.forms["fdns"].emailon.disabled=true;
60  if (document.forms["fdns"].emailoff.disabled!=null)
61  document.forms["fdns"].emailoff.disabled=true;
62 }
63 function dnsoff() {
64  alert('This function seems unused. If you see this message, please let us know.');
65  // Active les composants DNS :
66  if (document.forms["fdns"].mx.disabled!=null)
67  document.forms["fdns"].mx.disabled=true;
68  if (document.forms["fdns"].emailon.disabled!=null)
69  document.forms["fdns"].emailon.disabled=false;
70  if (document.forms["fdns"].emailoff.disabled!=null)
71  document.forms["fdns"].emailoff.disabled=false;
72 }
73 
74 function destruction_alert() {
75  // On ne se pose pas de question si le DNS est deja sur NON
76  if (<?php echo (int)$r["dns"]; ?>!=1) {
77  return true;
78  }
79  if (document.forms["fdns"].email[1].checked) {
80  if ( confirm("<?php __("Are you sure you want to do this? This will DELETE ALL the mailboxes, messages and aliases on this domain ?"); ?>") ) {
81  return true;
82  } else {
83  return false;
84  }
85  } else {
86  return true;
87  }
88 }
89 </script>
90 
91 <h3><img src="images/dom.png" alt="" />&nbsp;<?php printf(_("Manage %s"),$domain); ?></h3>
92 
93 <?php
94 
95 if ($r['dns_action']=='UPDATE') {?>
96  <p class="alert alert-info"><?php __("This domain have some DNS change pending. Please wait."); ?></p>
97 <?php
98 } elseif ($r['dns_action']=='DELETE') {?>
99  <p class="alert alert-warning"><?php printf(_("You requested deletion of domain %s."), $domain);?></p>
100 <?php
101 /*
102  // Link hidden as long as the del_domain_cancel function is not complete
103  <a href="dom_dodel.php?domain=<?php echo urlencode($domain);?>&del_cancel=true"><?php __("Clic here to cancel deletion");?></a>
104 */
105 ?>
106  <?php
107  include_once("foot.php");
108  die();
109 }
110 
111 if (! empty($r['dns_result']) && $r['dns_result'] != '0') {
112  echo '<p class="alert alert-warning">'; __($r['dns_result']); echo '</p>';
113 }
114 
115 ?>
116 
117 
118 <div id="tabsdom">
119 
120 <ul>
121  <li class="edit"><a href="#tabsdom-editsub"><?php __("Edit subdomains");?></a></li>
122  <li class="add"><a href="#tabsdom-addsub"><?php __("Add subdomains");?></a></li>
123  <li class="settings"><a href="#tabsdom-params"><?php __("Settings");?></a></li>
124 <?php if ( $r["dns"] ) { ?>
125  <li class="view"><a href="#tabsdom-view" onClick="update_dns_content();"><?php __("View");?></a></li>
126 <?php } //if gesdns ?>
127  <li class="delete"><a href="#tabsdom-delete"><?php __("Delete");?></a></li>
128 </ul>
129 
130 
131 <div id="tabsdom-editsub">
132 <h3><?php printf(_("Editing subdomains of %s"),$domain); ?></h3>
133 <?php
134 $dt=$dom->domains_type_lst();
135 
136 $problems = $dom->get_problems($domain);
137 if ( ! empty($problems) ) {
138  echo '<p class="alert alert-danger">';
139  foreach ($problems as $p) echo $p."</br>";
140  echo "</p>";
141 }
142 
143 ?>
144 <table class="tlist" id="dom_edit_table">
145 <thead>
146 <tr><th colspan="2"> </th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Status")?></th><th></th></tr>
147 </thead>
148 <?php
149 for($i=0;$i<$r["nsub"];$i++) {
150 
151 $disabled_class=in_array(strtoupper($r['sub'][$i]['enable']),array('DISABLED','DISABLE') )?'sub-disabled':'';
152 
153 ?>
154  <tr class="lst" data-fqdn="<?php echo $r["sub"][$i]["fqdn"]; ?>">
155  <?php if ( $r['sub'][$i]['web_action'] =='DELETE') { echo "<td colspan='2' />"; } else { ?>
156  <td class="center">
157  <?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
158  <?php if ( isset($problems[$r["sub"][$i]["fqdn"]])) { // if this subdomain have problem, can't modify it, only delete it
159  __("Forbidden");
160  } else { ?>
161  <div class="ina edit"><a href="dom_subedit.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><?php __("Edit"); ?></a></div><?php
162  } // isset problems
163  } ?>
164 
165 
166  </td><td class="center">
167  <?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
168  <div class="ina delete"><a href="dom_subdel.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><?php __("Delete"); ?></a></div>
169 <?php } ?>
170  </td>
171  <?php } // end IF ==DELETE ?>
172  <td><div class="retour-auto <?php echo $disabled_class; ?>"><a href="http://<?php echo $r["sub"][$i]["fqdn"] ?>" target="_blank"><?php echo $r["sub"][$i]["fqdn"]; ?></a></div></td>
173  <td><div class="retour-auto <?php echo $disabled_class; ?>"><?php if ($r['sub'][$i]['type_desc']) { __($r['sub'][$i]['type_desc']); } else { echo __("ERROR, please check your server setup"); } ?>
174  <?php
175  //if ($r["sub"][$i]['type'] === 'VHOST') {
176  if ( @$dt[$r["sub"][$i]['type']]['target'] === 'DIRECTORY') {
177  $iidir=$r["sub"][$i]["dest"];
178  if ($iidir=='') $iidir='/';
179  echo '<br /><a href="bro_main.php?R='.urlencode($iidir).'">'.htmlspecialchars($iidir).'</a>';
180  if ( ! file_exists($bro->convertabsolute($iidir,0))) { echo " <span class=\"alerte\">"._("Directory not found")."</span>"; }
181 } else {
182  if ($r["sub"][$i]['type']) echo "<br />".htmlspecialchars($r["sub"][$i]["dest"]);
183 }
184 ?></div></td>
185  <td><?php
186  if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) {
187  if ( $r['sub'][$i]['web_action'] !='DELETE') {
188  switch ($r['sub'][$i]['enable']) {
189  case 'ENABLED':
190  __("Enabled");
191  echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=disable'>";__("Disable");echo "</a>";
192  break;
193  case 'ENABLE':
194  __("Activation pending");
195  break;
196  case 'DISABLED':
197  __("Disabled");
198  echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=enable'>";__("Enable");echo "</a>";
199  break;
200  case 'DISABLE':
201  __("Desactivation pending");
202  break;
203  }
204  }
205  }?></td>
206  <td><?php
207  switch ($r['sub'][$i]['web_action']) {
208  case 'UPDATE':
209  __("Update pending");
210  break;
211  case 'DELETE':
212  __("Deletion pending");
213  break;
214  case 'OK':
215  default:
216  break;
217  }?></td>
218 
219  </tr>
220 <?php } ?>
221 </table>
222 <?php
223 // Add a class on the sub_domains who have a problem
224 foreach ($problems as $pr => $lm) { // $problems can be empty but can't be null/false
225  echo "<script type='text/javascript'>$(\"tr[data-fqdn='".$pr."']\").addClass('alert-danger-tr');</script>\n";
226 }
227 ?>
228 </div>
229 
230 
231 <div id="tabsdom-addsub">
232 <h3><?php printf(_("Add a subdomains to %s"),$domain); ?></h3>
233 <?php
234 $isedit=false;
235 require_once('dom_edit.inc.php');
236 sub_domains_edit($domain);
237 ?>
238 <br />
239 <?php $mem->show_help("edit_domain"); ?>
240 <!-- *****************************************
241  modification des parametres dns
242  -->
243 <?php
244 if (!$r['noerase']) {
245 ?>
246 
247 </div>
248 <div id="tabsdom-params">
249 <h3><?php __("DNS &amp; Email parameters"); ?></h3>
250 <form action="dom_editdns.php?domain=<?php echo urlencode($r["name"]) ?>" method="post" id="fdns" name="fdns" onSubmit="return destruction_alert();">
251 
252 <table class="tlist2">
253 <tr>
254  <td><?php __("Manage the DNS on the server ?"); ?></td>
255  <td>
256  <input type="radio" id="yesdns" class="inc" name="dns" value="1"<?php cbox($r["dns"]); ?> />&nbsp;<label for="yesdns"><?php __("Yes"); ?></label>
257  </td><td><input type="radio" id="nodns" class="inc" name="dns" value="0"<?php cbox(!$r["dns"]); ?> />&nbsp;<label for="nodns"><?php __("No"); ?></label>
258  </td>
259 </tr>
260 </table>
261 
262 <?php if ($r["dns"]) { ?>
263 <table class="tlist2">
264 <tr>
265  <td><?php __("Define TTL for the zone records"); ?>&nbsp;: </td>
266  <td>
267  <input type="text" id="ttldns" class="inc" name="ttl" size="6" value="<?php echo ($r["zonettl"]); ?>" /> <?php __("seconds"); ?> <small><i><?php __("Warning: a low TTL can be problematic. It is recommended not to use a lower TTL than 3600 seconds."); ?></i></small>
268  </td>
269 </tr>
270 </table>
271 <?php } ?>
272 
273 <table class="tlist2">
274 <tr>
275  <td>
276  <?php __("Manage the Emails Addresses of this domain on the server?"); ?>
277  </td>
278  <td>
279  <input type="radio" id="yesemail" class="inc" name="email" value="1"<?php cbox($r["mail"]); ?> />&nbsp;<label for="yesemail"><?php __("Yes"); ?></label>
280  </td><td><input type="radio" id="noemail" class="inc" name="email" value="0"<?php cbox(!$r["mail"]); ?> />&nbsp;<label for="noemail"><?php __("No"); ?></label>
281  </td>
282 </tr>
283 </table>
284 <p class="alert alert-warning"> <?php __("Warning: If you set this to 'no', all your email accounts and aliases on this domain will be immediately deleted."); ?></p>
285 <input type="submit" class="inb ok" name="submit" value="<?php __("Submit the changes"); ?>" />
286  </form>
287 
288 </div>
289 
290 <?php if ( $r["dns"] ) { ?>
291 <div id="tabsdom-view">
292 <p>
293 <?php __("Here is the actual DNS zone running on the AlternC server. If you just made some changes, you have to wait for it."); ?>
294 </p>
295 
296 <pre><span class="petit" id="divdumpdns">
297 <a target="_blank" href="dom_dnsdump.php?domain=<?php echo urlencode($domain) ?>"><?php __("Click here to view the dump");?></a>
298 </span>
299 </pre>
300 <a href="javascript:force_update_dns_content();"><?php __("Refresh");?></a>
301 
302 </div>
303 <?php } // if dns ?>
304 
305 <div id="tabsdom-delete">
306  <h3><?php __("Domain removal"); ?></h3>
307  <?php printf(_("If you want to destroy the domain %s, click on the button below. Warning: this also deletes all FTP accounts, email, mailing lists associated with the domain and subdomains."),$domain); ?><br />
308  <form action="dom_dodel.php?domain=<?php echo urlencode($domain) ?>" method="post">
309  <p>
310  <input type="submit" class="inb delete" name="detruire" value="<?php printf(_("Delete %s from this server"),$domain); ?>" />
311  </p>
312  </form>
313 </div> <!-- tabsdom-delete -->
314 </div> <!-- tabsdom -->
315 <?php } // noerase ?>
316 <script type="text/javascript">
317 //document.forms['main'].sub.focus(); // not with tabs
318 
319 $(function() {
320  $("#tabsdom").tabs();
321 });
322 
325  if ( get_dns_content == 1 ) {
326  get_dns_content = 0;
327 
328  $.ajax({
329  url: "dom_dnsdump.php?domain=<?php echo urlencode($domain)?>",
330  }).done(function( html ) {
331  $("#divdumpdns").html(html);
332  });
333  }
334 }
335 
337  get_dns_content = 1;
338  $("#divdumpdns").html('In progress...');
340 }
341 
342 $(document).ready(function()
343  {
344  $("#dom_edit_table").tablesorter();
345  }
346 );
347 
348 </script>
349 <?php include_once("foot.php"); ?>