AlternC/bureau/admin/dom_edit.php

549 lines
21 KiB
PHP
Executable File

<?php
/*
----------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
*/
/**
* Change a DOMAIN settings
*
* @copyright AlternC-Team 2000-2017 https://alternc.com/
*/
require_once("../class/config.php");
include_once("head.php");
$fields = array (
"domain" => array ("request", "string", (empty($domain)?"":$domain) ),
"sub" => array ("request", "string", (empty($sub)?"":$sub) ),
);
getFields($fields);
$dom->lock();
if (!$r=$dom->get_domain_all($domain)) {
$dom->unlock();
echo $msg->msg_html_all();
include('foot.php');
die();
}
$dom->unlock();
if (isset($_GET["msg"])) {
$msg->raise("INFO","dom",$_GET["msg"]);
}
?>
<h3><i class="fas fa-globe-africa"></i> <?php printf(_("Manage %s"),$domain); ?></h3>
<?php
echo $msg->msg_html_all();
?>
<script type="text/javascript">
function dnson() {
alert('This function seems unused. If you see this message, please let us know.');
// enable / disable html components:
if (document.forms["fdns"].mx.disabled!=null)
document.forms["fdns"].mx.disabled=false;
if (document.forms["fdns"].emailon.disabled!=null)
document.forms["fdns"].emailon.disabled=true;
if (document.forms["fdns"].emailoff.disabled!=null)
document.forms["fdns"].emailoff.disabled=true;
}
function dnsoff() {
alert('This function seems unused. If you see this message, please let us know.');
// enable / disable html components:
if (document.forms["fdns"].mx.disabled!=null)
document.forms["fdns"].mx.disabled=true;
if (document.forms["fdns"].emailon.disabled!=null)
document.forms["fdns"].emailon.disabled=false;
if (document.forms["fdns"].emailoff.disabled!=null)
document.forms["fdns"].emailoff.disabled=false;
}
function destruction_alert() {
// We don't ask question if DNS is already NO
if (<?php echo (int)$r["dns"]; ?>!=1) {
return true;
}
if (document.forms["fdns"].email[1].checked) {
if ( confirm("<?php __("Are you sure you want to do this? This will DELETE ALL the mailboxes, messages and aliases on this domain ?"); ?>") ) {
return true;
} else {
return false;
}
} else {
return true;
}
}
</script>
<?php
if ($r['dns_action']=='UPDATE') {?>
<p class="alert alert-info"><?php __("This domain have some DNS change pending. Please wait."); ?></p>
<?php
} elseif ($r['dns_action']=='DELETE') {?>
<p class="alert alert-warning"><?php printf(_("You requested deletion of domain %s."), $domain);?></p>
<?php
/*
// Link hidden as long as the del_domain_cancel function is not complete
<a href="dom_dodel.php?domain=<?php echo urlencode($domain);?>&del_cancel=true"><?php __("Clic here to cancel deletion");?></a>
*/
?>
<?php
include_once("foot.php");
die();
}
if (! empty($r['dns_result']) && $r['dns_result'] != '0') {
if ($r['dns_result'] == 1) $r['dns_result'] =_("DNS zone is locked, changes will be ignored");
echo '<p class="alert alert-warning">'; __($r['dns_result']); echo '</p>';
}
?>
<div id="tabsdom">
<ul>
<li class="edit"><a href="#tabsdom-editsub"><?php __("Edit subdomains");?></a></li>
<li class="add"><a href="#tabsdom-addsub"><?php __("Add subdomains");?></a></li>
<li class="settings"><a href="#tabsdom-params"><?php __("Settings");?></a></li>
<?php if ( $r["dns"] ) { ?>
<li class="view"><a href="#tabsdom-view" onClick="update_dns_content();"><?php __("View");?></a></li>
<?php } //if gesdns ?>
<?php if ($r['dnssec']): ?>
<li class="dnssec"><a href="#tabsdom-dnssec"><?php __('DnsSec');?></a></li>
<?php endif; ?>
<li class="delete"><a href="#tabsdom-delete"><?php __("Delete");?></a></li>
</ul>
<div id="tabsdom-editsub">
<h3><?php __("Main subdomains"); ?></h3>
<?php
$dt=$dom->domains_type_lst();
$problems = $dom->get_problems($domain);
if ( ! empty($problems) ) {
echo '<p class="alert alert-danger">';
foreach ($problems as $p) echo $p."</br>";
echo "</p>";
}
?>
<table class="tlist" id="dom_edit_table">
<thead>
<tr><th colspan="2"> </th><th><?php __("Subdomain"); ?></th><th><?php __("HTTPS"); ?></th><th><?php __("Type");?></th><th><?php __("Status")?></th><th></th></tr>
</thead>
<?php
$hasadvanced=false;
// this loop expect the table to be sorted with advanced entries AFTER normal ones :
for($i=0;$i<$r["nsub"];$i++) {
if ($r["sub"][$i]["advanced"] && !$hasadvanced) {
$hasadvanced=true;
?>
</table>
<h3 style="padding: 40px 0 0 0"><?php __("Advanced subdomains"); ?></h3>
<p class="alert alert-warning"><?php __("The following entries are advanced ones, edit them at your own risks."); ?></p>
<table class="tlist" id="dom_edit_table">
<thead>
<tr><th colspan="2"> </th><th><?php __("Subdomain"); ?></th><th><?php __("HTTPS"); ?></th><th><?php __("Type");?></th><th><?php __("Status")?></th><th></th></tr>
</thead>
<?php
}
$disabled_class=in_array(strtoupper($r['sub'][$i]['enable']),array('DISABLED','DISABLE') )?'sub-disabled':'';
?>
<tr class="lst" data-fqdn="<?php echo $r["sub"][$i]["fqdn"]; ?>">
<?php if ( $r['sub'][$i]['web_action'] =='DELETE') { echo "<td colspan='2' />"; } else { ?>
<td class="center">
<?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
<?php if ( isset($problems[$r["sub"][$i]["fqdn"]])) { // if this subdomain have problem, can't modify it, only delete it
__("Forbidden");
} else { ?>
<div class="ina edit"><a href="dom_subedit.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><?php __("Edit"); ?></a></div><?php
} // isset problems
} ?>
</td><td class="center">
<?php if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) { ?>
<div class="ina delete"><a href="dom_subdel.php?sub_domain_id=<?php echo urlencode($r["sub"][$i]["id"]) ?>"><?php __("Delete"); ?></a></div>
<?php } ?>
</td>
<?php } // end IF ==DELETE ?>
<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>
<td>
<?php
if (!$r["sub"][$i]["only_dns"]) {
switch ($r["sub"][$i]["https"]) {
case "http":
__("HTTP only");
break;
case "https":
__("HTTPS only");
break;
case "both":
__("HTTP and HTTPS");
break;
default:
break;
}
}
?>
</td>
<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"); } ?>
<?php
//if ($r["sub"][$i]['type'] === 'VHOST') {
if ( @$dt[$r["sub"][$i]['type']]['target'] === 'DIRECTORY') {
$iidir=$r["sub"][$i]["dest"];
if ($iidir=='') $iidir='/';
echo '<br /><a href="bro_main.php?R='.urlencode($iidir).'">'.htmlspecialchars($iidir).'</a>';
if ( ! file_exists($bro->convertabsolute($iidir,0))) { echo " <span class=\"alerte\">"._("Directory not found")."</span>"; }
} else {
if ($r["sub"][$i]['type']) echo "<br />".htmlspecialchars($r["sub"][$i]["dest"]);
}
?></div></td>
<td><?php
if (!(!$isinvited && $dt[strtolower($r["sub"][$i]["type"])]["enable"] != "ALL" )) {
if ( $r['sub'][$i]['web_action'] !='DELETE') {
switch ($r['sub'][$i]['enable']) {
case 'ENABLED':
__("Enabled");
echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=disable'>";__("Disable");echo "</a>";
break;
case 'ENABLE':
__("Activation pending");
break;
case 'DISABLED':
__("Disabled");
echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=enable'>";__("Enable");echo "</a>";
break;
case 'DISABLE':
__("Desactivation pending");
break;
}
}
}?></td>
<td><?php
switch ($r['sub'][$i]['web_action']) {
case 'UPDATE':
__("Update pending");
break;
case 'DELETE':
__("Deletion pending");
break;
case 'OK':
default:
break;
}?></td>
</tr>
<?php } ?>
</table>
<?php
// Add a class on the sub_domains who have a problem
foreach ($problems as $pr => $lm) { // $problems can be empty but can't be null/false
echo "<script type='text/javascript'>$(\"tr[data-fqdn='".$pr."']\").addClass('alert-danger-tr');</script>\n";
}
?>
<p>&nbsp;</p>
<hr />
<p>
<a class="inb ssl" href="dom_sslpref.php?domain=<?php ehe($domain); ?>"><?php __("HTTPS Preferences for this domain");?></a>
</p>
</div> <!-- tabsdom-editsub -->
<div id="tabsdom-addsub">
<h3><?php printf(_("Add a subdomain to %s"),$domain); ?></h3>
<?php
$isedit=false;
require_once('dom_edit.inc.php');
sub_domains_edit($domain);
?>
<br />
<?php $mem->show_help("edit_domain"); ?>
<!-- DNS SETTINGS -->
</div>
<?php
if (!$r['noerase']) {
?>
<div id="tabsdom-params">
<h3><?php __("DNS &amp; Email parameters"); ?></h3>
<form action="dom_editdns.php?domain=<?php echo urlencode($r["name"]) ?>" method="post" id="fdns" name="fdns" onSubmit="return destruction_alert();">
<?php csrf_get(); ?>
<table class="tlist2">
<tr>
<td><?php __("Manage the DNS on the server ?"); ?></td>
<td>
<input type="radio" id="yesdns" class="inc" name="dns" value="1"<?php cbox($r["dns"]); ?> />&nbsp;<label for="yesdns"><?php __("Yes"); ?></label>
</td><td><input type="radio" id="nodns" class="inc" name="dns" value="0"<?php cbox(!$r["dns"]); ?> />&nbsp;<label for="nodns"><?php __("No"); ?></label>
</td>
</tr>
</table>
<?php if ($r["dns"]) { ?>
<table class="tlist2">
<tr>
<td><?php __("Define TTL for the zone records"); ?>&nbsp;: </td>
<td>
<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>
</td>
</tr>
</table>
<?php } ?>
<table class="tlist2">
<tr>
<td>
<?php __("Manage the Emails Addresses of this domain on the server?"); ?>
</td>
<td>
<input type="radio" id="yesemail" class="inc" name="email" value="1"<?php cbox($r["mail"]); ?> />&nbsp;<label for="yesemail"><?php __("Yes"); ?></label>
</td><td><input type="radio" id="noemail" class="inc" name="email" value="0"<?php cbox(!$r["mail"]); ?> />&nbsp;<label for="noemail"><?php __("No"); ?></label>
</td>
</tr>
</table>
<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>
<div class="dnssec-configuration">
<span><?php __("Enable DnsSec for this domain?"); ?></span>
<span><input type="checkbox" name="dnssec" value="1" <?php if($r['dnssec']) { echo "checked"; } ?>/></span>
<div>
<p class="alert alert-warning"><?php __("If configuring DnsSec for the first time, ensure that your registrar can configure DS records for your domain. If enabling DnsSec on a subdomain, DS records will need to be added to the parent domain instead.");?>
<br><br>
<?php __("If disabling DnsSec make sure to remove DS records recorded with your registrar or in the parent domain.");?>
<br><br>
<?php __("Initial KSK/ZSK configuration is determined by the AlternC settings. Once enabled, keys may be managed in the \"DnsSec\" tab");?>
<br><br>
<?php $dnssec_defaults = system_bind::default_dnssec_configuration(); ?>
<?php __("Key-siging keys will be {$dnssec_defaults['ksk']['algorithm']} of length {$dnssec_defaults['ksk']['keysize']}. Zone-signing keys will be {$dnssec_defaults['zsk']['algorithm']} of length {$dnssec_defaults['zsk']['keysize']}."); ?>
</p>
</div>
</div>
<?php if ($admin->enabled || intval($oldid)): ?>
<div class="ignore-dns-checks">
<span><?php __('Ignore whois check?'); ?></span>
<span><input type="checkbox" name="force" value="1"/></span>
</div>
<?php endif; ?>
<input type="submit" class="inb ok" name="submit" value="<?php __("Submit the changes"); ?>" />
</form>
</div>
<?php } else { ?>
<div id="tabsdom-params">
<p class="alert alert-info"><?php __("This domain is locked, only a server administrator can unlock it."); ?></p>
</div>
<?php } ?>
<?php if ( $r["dns"] ) { ?>
<div id="tabsdom-view">
<p>
<?php __("Here is the actual DNS zone running on the AlternC server. If you just made some changes, you have to wait for it."); ?>
</p>
<div>
<pre><span class="petit" id="divdumpdns">
<a target="_blank" href="dom_dnsdump.php?domain=<?php echo urlencode($domain) ?>"><?php __("Click here to view the dump");?></a>
</span>
</pre>
</div>
<p>&nbsp;</p>
<p><a class="inb" href="javascript:force_update_dns_content();"><?php __("Refresh");?></a></p>
</div>
<?php } // if dns ?>
<?php if ($r['dnssec']): ?>
<div id="tabsdom-dnssec">
<div>
<h3><?php __('DS Entries'); ?></h3>
<p><?php __('Here are the current DS entries for your zone. To finish activating DNSSEC on your domain, they must be uploaded to your registrar, or added as DS entries on the parent zone file.');?></p>
<pre><?php echo system_bind::dnssec_ds_entries(); ?></pre>
</div>
<div>
<h3><?php __('Existing DnsSec Keys'); ?></h3>
<form action="dom_editdnsseckeys.php" id="fdnsseckeys" name="fdsnsseckeys" method="post">
<!-- First pass: don't enforce workflow, just give options -->
<input type="hidden" name="domain" value="<?php echo urlencode($r['name']); ?>"/>
<?php $keys = system_bind::list_keys($r['name']); ?>
<?php if (!empty($keys)): ?>
<table>
<?php $attr_list = array('Created', 'Publish', 'Activate',
'Revoke', 'Inactive', 'Delete'); ?>
<tr>
<th><?php __('Key'); ?></th>
<?php foreach ($attr_list as $attr): ?>
<th><?php __($attr); ?></th>
<?php endforeach; ?>
</tr>
<?php foreach ($keys as $key): ?>
<?php $key_data = system_bind::get_key_metadata($key); ?>
<?php $key_base = basename($key); ?>
<td><?php print($key_base); ?></td>
<?php foreach ($attr_list as $attr): ?>
<td>
<!-- @TODO: Is there a nice datetime edit element? -->
<input type="datetime-local"
name="key[<?php echo $key_base; ?>][<?php echo $attr; ?>]"
value="<?php echo strftime("%Y-%m-%dT%H:%M", $key_data[$attr]); ?>"
/>
</td>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
<button type="submit" class="inb" value="<?php __('Submit'); ?>"/>
<?php else: ?>
<p><?php __('No keys found for the domain'); ?></p>
<?php endif; ?>
</form>
</div>
<div>
<h3><?php __('Key generation settings for your domain'); ?></h3>
<?php $key_conf = $dom->get_dnssec_key_generation_parametrs; $valid_conf = system_bind::$dns_key_limits; ?>
<form action="dom_editdnssec.php" method="post" id="fdnssec" name="fdnssec">
<?php csrf_get(); ?>
<input type="hidden" name="domain" value="<?php echo urlencode($r['name']); ?>"/>
<?php $keys = array(
'ksk' => array(
'title' => _('Key-Signing Key Paramaters'),
'validation_type' => 'KSK/ZSK'),
'zsk' => array(
'title' => _('Zone-Signing Key Parameters'),
'validation_type' => 'KSK/ZSK')
); ?>
<?php foreach ($keys as $key_type => $attrs): ?>
<h4><?php echo $attrs['key_title']; ?></h4>
<label>
<?php __('Algorithm'); ?>
<select name="<?php echo $key_type; ?>_algorithm">
<?php foreach($valid_conf[$attrs['validation_type']] as $algo => $v): ?>
<?php $selected = ($algo == $key_config[$key_type]['algorithm']); ?>
<option
value="<?php echo $algo; ?>"
<?php echo $selected ? "selected" : "";?>
>
<?php echo $algo; ?>
</option>
<?php endforeach; ?>
</select>
</label>
<label>
<?php __('Key Size'); ?>
<select name=<?php echo $key_type; ?>_keysize">
<?php // @TODO Change key sizes available when algorithm selected changes ?>
<?php foreach(array(512, 1024, 2048) as $keysize): ?>
<?php $selected = ($keysize == $key_config[$key_type]['keysize']); ?>
<option
value="<?php echo $keysize; ?>"
<?php echo $selected ? "selected" : ""; ?>
>
<?php echo $keysize; ?>
</option>
<?php endforeach; ?>
</select>
</label>
<?php endforeach; ?>
<label><?php __('Force key re-generation'); ?>
<input type="checkbox" name="regen-keys">
</label>
<p class="alert alert-warning">
<?php __('When creating new keys you must manually managed key-rollover.'); ?>
<?php __('All keys are added to the zone.'); ?>
</p>
<button type="submit" class="inb" value="<?php __('Submit'); ?>"/>
<!-- @TODO: Implement form submission handling for KSK/ZSK algo change + key regen -->
</form>
</div>
</div>
<?php endif; ?>
<?php
if (!$r['noerase']) {
?>
<div id="tabsdom-delete">
<h3><?php __("Domain removal"); ?></h3>
<?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 />
<form action="dom_dodel.php?domain=<?php echo urlencode($domain) ?>" method="post">
<?php csrf_get(); ?>
<p>
<input type="submit" class="inb delete" name="detruire" value="<?php printf(_("Delete %s from this server"),$domain); ?>" />
</p>
</form>
</div> <!-- tabsdom-delete -->
<?php } else { // noerase
?>
<div id="tabsdom-delete">
<p class="alert alert-info"><?php __("This domain is locked, only a server administrator can unlock it."); ?></p>
</div>
<?php
} ?>
<div id="tabsdom-ssl">
<div id="sslpref">
</div>
</div> <!-- tabsdom-ssl -->
</div> <!-- tabsdom -->
<script type="text/javascript">
$(function() {
$("#tabsdom").tabs();
});
get_dns_content = 1;
function update_dns_content(){
if ( get_dns_content == 1 ) {
get_dns_content = 0;
$.ajax({
url: "dom_dnsdump.php?domain=<?php echo urlencode($domain)?>",
}).done(function( html ) {
$("#divdumpdns").html(html);
});
}
}
function update_ssl_content(){
$.ajax({
url: "dom_ssl.inc.php?domain=<?php echo urlencode($domain)?>",
}).done(function( html ) {
$("#sslpref").html(html);
});
}
function force_update_dns_content(){
get_dns_content = 1;
$("#divdumpdns").html('In progress...');
update_dns_content();
}
$(document).ready(function()
{
$("#dom_edit_table").tablesorter();
}
);
</script>
<?php include_once("foot.php"); ?>