[Web] Fix download link for dns zone file
parent
2077eb139e
commit
4a8edd5b88
|
@ -292,6 +292,7 @@ $data_field = array(
|
||||||
'TLSA' => 'data',
|
'TLSA' => 'data',
|
||||||
'TXT' => 'txt',
|
'TXT' => 'txt',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="table-responsive" id="dnstable">
|
<div class="table-responsive" id="dnstable">
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -419,39 +420,48 @@ foreach ($records as &$record) {
|
||||||
$record[3] = explode('<br />', $state);
|
$record[3] = explode('<br />', $state);
|
||||||
}
|
}
|
||||||
unset($record);
|
unset($record);
|
||||||
?>
|
|
||||||
</table>
|
$dns_data = sprintf("\$ORIGIN %s.\n", $domain);
|
||||||
<?php
|
|
||||||
$data = sprintf("\$ORIGIN %s.\n", $domain);
|
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
if ($domain == substr($record[0], -strlen($domain))) {
|
if ($domain == substr($record[0], -strlen($domain))) {
|
||||||
$label = substr($record[0], 0, -strlen($domain)-1);
|
$label = substr($record[0], 0, -strlen($domain)-1);
|
||||||
$val = $record[2];
|
$val = $record[2];
|
||||||
if (strlen($label) == 0)
|
if (strlen($label) == 0) {
|
||||||
$label = "@";
|
$label = "@";
|
||||||
|
}
|
||||||
$vals = array();
|
$vals = array();
|
||||||
if (strpos($val, "<a") !== FALSE) {
|
if (strpos($val, "<a") !== FALSE) {
|
||||||
if(is_array($record[3]) && count($record[3]) == 1 && $record[3][0] == state_optional)
|
if(is_array($record[3]) && count($record[3]) == 1 && $record[3][0] == state_optional) {
|
||||||
{
|
|
||||||
$record[3][0] = "**TODO**";
|
$record[3][0] = "**TODO**";
|
||||||
$label = ';' . $label;
|
$label = ';' . $label;
|
||||||
}
|
}
|
||||||
foreach ($record[3] as $val) {
|
foreach ($record[3] as $val) {
|
||||||
$val = str_replace(state_optional, '', $val);
|
$val = str_replace(state_optional, '', $val);
|
||||||
$val = str_replace(state_good, '', $val);
|
$val = str_replace(state_good, '', $val);
|
||||||
if (strlen($val) > 0)
|
if (strlen($val) > 0) {
|
||||||
$vals[] = sprintf("%s\tIN\t%s\t%s\n", $label, $record[1], $val);
|
$vals[] = sprintf("%s\tIN\t%s\t%s\n", $label, $record[1], $val);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$vals[] = sprintf("%s\tIN\t%s\t%s\n", $label, $record[1], $val);
|
$vals[] = sprintf("%s\tIN\t%s\t%s\n", $label, $record[1], $val);
|
||||||
}
|
}
|
||||||
foreach ($vals as $val) {
|
foreach ($vals as $val) {
|
||||||
$data .= str_replace($domain, $domain . '.', $val);
|
$dns_data .= str_replace($domain, $domain . '.', $val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '<a target="_blank" href="data:text/plain;base64,' . base64_encode($data) .'">Download</a>';
|
|
||||||
?>
|
?>
|
||||||
|
</table>
|
||||||
|
<a id='download-zonefile' data-zonefile="<?=base64_encode($dns_data);?>" download='<?=$_GET['domain'];?>.txt' type='text/csv'>Download</a>
|
||||||
|
<script>
|
||||||
|
var zonefile_dl_link = document.getElementById('download-zonefile');
|
||||||
|
var zonefile = atob(zonefile_dl_link.getAttribute('data-zonefile'));
|
||||||
|
var data = new Blob([zonefile]);
|
||||||
|
var download_zonefile_link = document.getElementById('download-zonefile');
|
||||||
|
download_zonefile_link.href = URL.createObjectURL(data);
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
<sup>1</sup> <?=$lang['diagnostics']['cname_from_a'];?><br />
|
<sup>1</sup> <?=$lang['diagnostics']['cname_from_a'];?><br />
|
||||||
|
|
Loading…
Reference in New Issue