2021-01-22 21:58:46 +01:00
< ? php require " ../top.inc.php " ; ?>
2021-02-17 22:48:49 +01:00
< form method = " post " >
< label for = " action " > Action </ label >
< select name = " action " id = " action " >
< option value = " add " > Ajouter </ option >
< option value = " delete " > Retirer </ option >
</ select >
< br >
2021-02-18 22:40:16 +01:00
< input required = " " id = " subdomain " placeholder = " ns1 " name = " subdomain " type = " text " >
< select required = " " name = " suffix " id = " suffix " >
< option value = " " disabled = " " selected = " " >---</ option >
< ? php
$domains = regListUserDomains ( $_SESSION [ 'username' ]);
if ( $domains ) {
foreach ( $domains as $domain ) {
echo " <option value=' " . $domain . " '>. " . $domain . " </option> " ;
}
}
?>
</ select >
2021-02-17 22:48:49 +01:00
< br >
< label for = " ip " > IP </ label >< br >
< input required = " " pattern = " ^[a-f0-9:.]+ $ " id = " ip " name = " ip " minlength = " 7 " maxlength = " 39 " size = " 40 " type = " text " placeholder = " 2a0b:cbc0:1103:2::106f ou 45.13.104.169 " >
< br >
< input value = " Valider " type = " submit " >
</ form >
< ? php
2021-02-18 22:40:16 +01:00
if ( isset ( $_POST [ 'action' ]) AND isset ( $_POST [ 'subdomain' ]) AND isset ( $_POST [ 'suffix' ]) AND isset ( $_POST [ 'ip' ])) {
2021-02-17 22:48:49 +01:00
2021-02-18 22:40:16 +01:00
if ( $domains ) {
foreach ( $domains as $domain ) {
if ( $_POST [ 'suffix' ] == $domain ) goto ownedSuffix ;
}
exit ( " ERROR : You don't own this suffix " );
} else {
exit ( " ERROR : You don't own any domain " );
}
ownedSuffix :
$domain = $_POST [ 'subdomain' ] . " . " . $_POST [ 'suffix' ];
checkAbsoluteDomainFormat ( $domain );
2021-02-17 22:48:49 +01:00
checkIpFormat ( $_POST [ 'ip' ]);
if ( filter_var ( $_POST [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ))
$record = " A " ;
else if ( filter_var ( $_POST [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ))
$record = " AAAA " ;
else
exit ( " Unknown error about IP format " );
if ( $_POST [ 'action' ] == " delete " )
$action = " un " ;
else if ( $_POST [ 'action' ] == " add " )
$action = " " ;
else
exit ( " ERROR : Wrong value for action " );
2021-02-18 22:40:16 +01:00
// Remove anything before the first dot and the first dot itself
2021-02-19 13:23:26 +01:00
$suffix = regGetSuffix ( $_POST [ 'suffix' ]);
2021-02-18 22:40:16 +01:00
2021-02-17 22:48:49 +01:00
exec ( KNOTC_PATH . " zone-begin " . $suffix );
2021-02-18 22:40:16 +01:00
exec ( KNOTC_PATH . " zone- " . $action . " set " . $suffix . " " . $_POST [ 'subdomain' ] . " 86400 " . $record . " " . $_POST [ 'ip' ]);
2021-02-17 22:48:49 +01:00
exec ( KNOTC_PATH . " zone-commit " . $suffix );
echo " Glue record ajouté " ;
}
?>
2021-01-22 21:58:46 +01:00
< ? php require " ../bottom.inc.php " ; ?>