2021-01-22 20:58:46 +00:00
< ? php require " ../top.inc.php " ; ?>
< p >
Ici vous pouvez ajouter ou enlever des adresses IP dans une zone déjà enregistrée sur le serveur ns1 . atope . art
< br > Le format IPv4 ( A ) ou IPv6 ( AAAA ) sera détecté automatiquement .
< br > Si vous souhaitez utiliser un service d ' hébergement hypertexte de Niver , voici les adresses à renseigner :
< br > IPv4 : 45.13 . 104.169
< br > IPv6 : 2 a0b : cbc0 : 1103 : 2 :: 106 f
</ p >
< 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 >
< label for = " zone " > Zone </ label >< br >
< select required = " " name = " zone " id = " zone " >
< option value = " " disabled = " " selected = " " >---</ option >
< ? php
$db = new PDO ( 'sqlite:' . $dbPath );
$username [ 0 ] = $_SESSION [ 'username' ];
var_dump ( $username );
$req = $db -> prepare ( 'SELECT zone FROM zones WHERE username = ?' );
$req -> execute ( $username );
$domain = $req -> fetch ()[ 'zone' ];
while ( $domain != NULL ) {
echo " <option value=' " . $domain . " '> " . $domain . " </option> " ;
$domain = $req -> fetch ()[ 'zone' ];
}
?>
</ select >
< br >
< label for = " domain " > Domaine </ label >< br >
2021-02-12 14:32:48 +00:00
< input required = " " id = " domain " name = " domain " type = " text " placeholder = " www.domaine. " >< br >
2021-01-22 20:58:46 +00:00
< label for = " ttl " >< abbr title = " Time To Live " > TTL </ abbr ></ label >< br >
< input id = " ttl " list = " ttls " name = " ttl " size = " 10 " type = " number " min = " 600 " max = " 604800 " value = " 3600 " placeholder = " 3600 " >< br >
< datalist id = " ttls " >
< option value = " 900 " >
< option value = " 3600 " >
< option value = " 10800 " >
< option value = " 86400 " >
< option value = " 604800 " >
</ datalist >
< label for = " ip " > IP </ label >< br >
2021-02-12 14:32:48 +00:00
< 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 >
2021-01-22 20:58:46 +00:00
< input value = " Valider " type = " submit " >
</ form >
< ? php
2021-02-12 14:32:48 +00:00
if ( isset ( $_POST [ 'domain' ]) AND isset ( $_POST [ 'ip' ]) AND isset ( $_POST [ 'zone' ]) AND isset ( $_POST [ 'action' ])) {
2021-01-22 20:58:46 +00:00
if ( ! filter_var ( $_POST [ 'ip' ], FILTER_VALIDATE_IP )) {
echo " Erreur : l'adresse IP n'est pas valide " ;
} else if ( ! filter_var ( $_POST [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_NO_PRIV_RANGE )) {
echo " Erreur : l'adresse IP est dans une plage privée " ;
} else if ( ! filter_var ( $_POST [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_NO_RES_RANGE )) {
echo " Erreur : l'adresse IP est dans une plage réservée " ;
} else {
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 ( " Erreur inconnue sur le format de l'IP " );
}
if ( $_POST [ 'action' ] == " delete " ) {
$action = " un " ;
} else if ( $_POST [ 'action' ] == " add " ) {
$action = " " ;
} else {
exit ( " Erreur : valeur invalide pour action " );
}
exec ( " knotc zone-begin " . $_POST [ 'zone' ]);
2021-02-08 11:57:32 +00:00
exec ( " knotc zone- " . $action . " set " . $_POST [ 'zone' ] . " " . $_POST [ 'domain' ] . " 900 IN " . $record . " " . $_POST [ 'ip' ]);
2021-01-22 20:58:46 +00:00
exec ( " knotc zone-commit " . $_POST [ 'zone' ]);
echo " Opération effectuée " ;
}
}
?>
< ? php require " ../bottom.inc.php " ; ?>