Alternc  latest
Alternc logiel libre pour l'hébergement
dom_edit.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Change a DOMAIN settings
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 include_once("head.php");
28 
29 $fields = array (
30  "domain" => array ("request", "string", (empty($domain)?"":$domain) ),
31  "sub" => array ("request", "string", (empty($sub)?"":$sub) ),
32 );
33 getFields($fields);
34 
35 $dom->lock();
36 if (!$r=$dom->get_domain_all($domain)) {
37  $dom->unlock();
38  echo $msg->msg_html_all();
39  include('foot.php');
40  die();
41 }
42 $dom->unlock();
43 
44 if (isset($_GET["msg"])) {
45  $msg->raise("INFO","dom",$_GET["msg"]);
46 }
47 ?>
48 <h3><i class="fas fa-globe-africa"></i> <?php printf(_("Manage %s"),$domain); ?></h3>
49 <?php
50 echo $msg->msg_html_all();
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  // enable / disable html components:
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  // enable / disable html components:
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  // We don't ask question if DNS is already NO
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 <?php
92 
93 if ($r['dns_action']=='UPDATE') {?>
94  <p class="alert alert-info"><?php __("This domain have some DNS change pending. Please wait."); ?></p>
95 <?php
96 } elseif ($r['dns_action']=='DELETE') {?>
97  <p class="alert alert-warning"><?php printf(_("You requested deletion of domain %s."), $domain);?></p>
98 <?php
99 /*
100  // Link hidden as long as the del_domain_cancel function is not complete
101  <a href="dom_dodel.php?domain=<?php echo urlencode($domain);?>&del_cancel=true"><?php __("Click here to cancel deletion");?></a>
102 */
103 ?>
104  <?php
105  include_once("foot.php");
106  die();
107 }
108 
109 if (! empty($r['dns_result']) && $r['dns_result'] != '0') {
110  if ($r['dns_result'] == 1) $r['dns_result'] =_("DNS zone is locked, changes will be ignored");
111  echo '<p class="alert alert-warning">'; __($r['dns_result']); echo '</p>';
112 }
113 
114 ?>
115 
116 
117 <div id="tabsdom">
118 
119 <ul>
120  <li class="edit"><a href="#tabsdom-editsub"><?php __("Edit subdomains");?></a></li>
121  <li class="add"><a href="#tabsdom-addsub"><?php __("Add subdomains");?></a></li>
122  <li class="settings"><a href="#tabsdom-params"><?php __("Settings");?></a></li>
123 <?php if ( $r["dns"] ) { ?>
124  <li class="view"><a href="#tabsdom-view" onClick="update_dns_content();"><?php __("View");?></a></li>
125 <?php } //if gesdns ?>
126  <li class="delete"><a href="#tabsdom-delete"><?php __("Delete");?></a></li>
127 </ul>
128 
129 
130 <div id="tabsdom-editsub">
131 <h3><?php __("Main subdomains"); ?></h3>
132 <?php
133 $dt=$dom->domains_type_lst();
134 
135 $problems = $dom->get_problems($domain);
136 if ( ! empty($problems) ) {
137  echo '<p class="alert alert-danger">';
138  foreach ($problems as $p) echo $p."</br>";
139  echo "</p>";
140 }
141 
142 ?>
143 <table class="tlist" id="dom_edit_table">
144 <thead>
145  <tr><th colspan="2"> </th><th><?php __("Subdomain"); ?></th><th><?php __("HTTPS"); ?></th><th><?php __("Type");?></th><th><?php __("Status")?></th><th></th></tr>
146 </thead>
147 <?php
148 $hasadvanced=false;
149 // this loop expect the table to be sorted with advanced entries AFTER normal ones :
150 for($i=0;$i<$r["nsub"];$i++) {
151 if ($r["sub"][$i]["advanced"] && !$hasadvanced) {
152  $hasadvanced=true;
153 ?>
154 </table>
155 <h3 style="padding: 40px 0 0 0"><?php __("Advanced subdomains"); ?></h3>
156 <p class="alert alert-warning"><?php __("The following entries are advanced ones, edit them at your own risks."); ?></p>
157 <table class="tlist" id="dom_edit_table">
158 <thead>
159  <tr><th colspan="2"> </th><th><?php __("Subdomain"); ?></th><th><?php __("HTTPS"); ?></th><th><?php __("Type");?></th><th><?php __("Status")?></th><th></th></tr>
160 </thead>
161 <?php
162 
163 }
164 
165 $disabled_class=in_array(strtoupper($r['sub'][$i]['enable']),array('DISABLED','DISABLE') )?'sub-disabled':'';
166 ?>
167  <tr class="lst" data-fqdn="<?php echo $r["sub"][$i]["fqdn"]; ?>">
168  <?php if ( $r['sub'][$i]['web_action'] =='DELETE') { echo "<td colspan='2' />"; } else { ?>
169  <td class="center">
170  <?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
171  <?php if ( isset($problems[$r["sub"][$i]["fqdn"]])) { // if this subdomain have problem, can't modify it, only delete it
172  __("Forbidden");
173  } else { ?>
174  <div class="ina edit"><a href="dom_subedit.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><?php __("Edit"); ?></a></div><?php
175  } // isset problems
176  } ?>
177 
178 
179  </td><td class="center">
180  <?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
181  <div class="ina delete"><a href="dom_subdel.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><?php __("Delete"); ?></a></div>
182 <?php } ?>
183  </td>
184  <?php } // end IF ==DELETE ?>
185  <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>
186 <td>
187 <?php
188 if (!$r["sub"][$i]["only_dns"]) {
189  switch ($r["sub"][$i]["https"]) {
190  case "http":
191  __("HTTP only");
192  break;
193  case "https":
194  __("HTTPS only");
195  break;
196  case "both":
197  __("HTTP and HTTPS");
198  break;
199  default:
200  if ($r['sub'][$i]['has_https_option']) {
201  __("Unknown");
202  }
203  else {
204  __('Not applicable');
205  }
206  break;
207  }
208 }
209 ?>
210 </td>
211 <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"); } ?>
212  <?php
213  //if ($r["sub"][$i]['type'] === 'VHOST') {
214  if ( @$dt[$r["sub"][$i]['type']]['target'] === 'DIRECTORY') {
215  $iidir=$r["sub"][$i]["dest"];
216  if ($iidir=='') $iidir='/';
217  echo '<br /><a href="bro_main.php?R='.urlencode($iidir).'">'.htmlspecialchars($iidir).'</a>';
218  if ( ! file_exists($bro->convertabsolute($iidir,0))) { echo " <span class=\"alerte\">"._("Directory not found")."</span>"; }
219 } else {
220  if ($r["sub"][$i]['type']) echo "<br />".htmlspecialchars($r["sub"][$i]["dest"]);
221 }
222 ?></div></td>
223  <td><?php
224  if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) {
225  if ( $r['sub'][$i]['web_action'] !='DELETE') {
226  switch ($r['sub'][$i]['enable']) {
227  case 'ENABLED':
228  __("Enabled");
229  echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=disable'>";__("Disable");echo "</a>";
230  break;
231  case 'ENABLE':
232  __("Activation pending");
233  break;
234  case 'DISABLED':
235  __("Disabled");
236  echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=enable'>";__("Enable");echo "</a>";
237  break;
238  case 'DISABLE':
239  __("Desactivation pending");
240  break;
241  }
242  }
243  }?></td>
244  <td><?php
245  switch ($r['sub'][$i]['web_action']) {
246  case 'UPDATE':
247  __("Update pending");
248  break;
249  case 'DELETE':
250  __("Deletion pending");
251  break;
252  case 'OK':
253  default:
254  break;
255  }?></td>
256 
257  </tr>
258 <?php } ?>
259 </table>
260 <?php
261 // Add a class on the sub_domains who have a problem
262 foreach ($problems as $pr => $lm) { // $problems can be empty but can't be null/false
263  echo "<script type='text/javascript'>$(\"tr[data-fqdn='".$pr."']\").addClass('alert-danger-tr');</script>\n";
264 }
265 ?>
266 
267 <p>&nbsp;</p>
268 <hr />
269 <p>
270  <a class="inb ssl" href="dom_sslpref.php?domain=<?php ehe($domain); ?>"><?php __("HTTPS Preferences for this domain");?></a>
271 </p>
272 
273 
274 </div> <!-- tabsdom-editsub -->
275 
276 
277 <div id="tabsdom-addsub">
278 <h3><?php printf(_("Add a subdomain to %s"),$domain); ?></h3>
279 <?php
280 $isedit=false;
281 require_once('dom_edit.inc.php');
282 sub_domains_edit($domain);
283 ?>
284 <br />
285 <?php $mem->show_help("edit_domain"); ?>
286 <!-- DNS SETTINGS -->
287 
288 </div>
289  <?php
290 if (!$r['noerase']) {
291 ?>
292 
293 <div id="tabsdom-params">
294 <h3><?php __("DNS &amp; Email parameters"); ?></h3>
295 <form action="dom_editdns.php?domain=<?php echo urlencode($r["name"]) ?>" method="post" id="fdns" name="fdns" onSubmit="return destruction_alert();">
296  <?php csrf_get(); ?>
297 <table class="tlist2">
298 <tr>
299  <td><?php __("Manage the DNS on the server ?"); ?></td>
300  <td>
301  <input type="radio" id="yesdns" class="inc" name="dns" value="1"<?php cbox($r["dns"]); ?> />&nbsp;<label for="yesdns"><?php __("Yes"); ?></label>
302  </td><td><input type="radio" id="nodns" class="inc" name="dns" value="0"<?php cbox(!$r["dns"]); ?> />&nbsp;<label for="nodns"><?php __("No"); ?></label>
303  </td>
304 </tr>
305 </table>
306 
307 <?php if ($r["dns"]) { ?>
308 <table class="tlist2">
309 <tr>
310  <td><?php __("Define TTL for the zone records"); ?>&nbsp;: </td>
311  <td>
312  <input type="text" id="ttldns" class="inc" name="ttl" size="6" value="<?php ehe($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>
313  </td>
314 </tr>
315 </table>
316 <?php } ?>
317 
318 <table class="tlist2">
319 <tr>
320  <td>
321  <?php __("Manage the Emails Addresses of this domain on the server?"); ?>
322  </td>
323  <td>
324  <input type="radio" id="yesemail" class="inc" name="email" value="1"<?php cbox($r["mail"]); ?> />&nbsp;<label for="yesemail"><?php __("Yes"); ?></label>
325  </td><td><input type="radio" id="noemail" class="inc" name="email" value="0"<?php cbox(!$r["mail"]); ?> />&nbsp;<label for="noemail"><?php __("No"); ?></label>
326  </td>
327 </tr>
328 </table>
329 <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>
330 <input type="submit" class="inb ok" name="submit" value="<?php __("Submit the changes"); ?>" />
331  </form>
332 
333 </div>
334  <?php } else { ?>
335 <div id="tabsdom-params">
336  <p class="alert alert-info"><?php __("This domain is locked, only a server administrator can unlock it."); ?></p>
337 </div>
338  <?php } ?>
339 
340 <?php if ( $r["dns"] ) { ?>
341 <div id="tabsdom-view">
342 <p>
343 <?php __("Here is the actual DNS zone running on the AlternC server. If you just made some changes, you have to wait for it."); ?>
344 </p>
345 
346 <div>
347 <pre><span class="petit" id="divdumpdns">
348 <a target="_blank" href="dom_dnsdump.php?domain=<?php echo urlencode($domain) ?>"><?php __("Click here to view the dump");?></a>
349 </span>
350 </pre>
351 </div>
352 
353 <p>&nbsp;</p>
354 <p><a class="inb" href="javascript:force_update_dns_content();"><?php __("Refresh");?></a></p>
355 
356 </div>
357 <?php } // if dns ?>
358  <?php
359 if (!$r['noerase']) {
360 ?>
361 
362 <div id="tabsdom-delete">
363  <h3><?php __("Domain removal"); ?></h3>
364  <?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 />
365  <form action="dom_dodel.php?domain=<?php echo urlencode($domain) ?>" method="post">
366  <?php csrf_get(); ?>
367  <p>
368  <input type="submit" class="inb delete" name="detruire" value="<?php printf(_("Delete %s from this server"),$domain); ?>" />
369  </p>
370  </form>
371 </div> <!-- tabsdom-delete -->
372 <?php } else { // noerase
373  ?>
374 <div id="tabsdom-delete">
375  <p class="alert alert-info"><?php __("This domain is locked, only a server administrator can unlock it."); ?></p>
376 </div>
377  <?php
378 } ?>
379 
380 <div id="tabsdom-ssl">
381 <div id="sslpref">
382  </div>
383 </div> <!-- tabsdom-ssl -->
384 
385 </div> <!-- tabsdom -->
386 <script type="text/javascript">
387 
388 $(function() {
389  $("#tabsdom").tabs();
390 });
391 
392 get_dns_content = 1;
393 function update_dns_content(){
394  if ( get_dns_content == 1 ) {
395  get_dns_content = 0;
396 
397  $.ajax({
398  url: "dom_dnsdump.php?domain=<?php echo urlencode($domain)?>",
399  }).done(function( html ) {
400  $("#divdumpdns").html(html);
401  });
402  }
403 }
404 
406  $.ajax({
407  url: "dom_ssl.inc.php?domain=<?php echo urlencode($domain)?>",
408  }).done(function( html ) {
409  $("#sslpref").html(html);
410  });
411 }
412 
414  get_dns_content = 1;
415  $("#divdumpdns").html('In progress...');
416  update_dns_content();
417 }
418 
419 $(document).ready(function()
420  {
421  $("#dom_edit_table").tablesorter();
422  }
423 );
424 
425 </script>
426 <?php include_once("foot.php"); ?>
$dt
Definition: dom_edit.php:133
$problems
Definition: dom_edit.php:135
$isedit
Definition: dom_edit.php:280
$fields
Change a DOMAIN settings.
Definition: dom_edit.php:29
update_ssl_content()
Definition: dom_edit.php:405
force_update_dns_content()
Definition: dom_edit.php:413