Ajout de la possibilité d'avoir des CNAME, TXT dans les DNS.
Possibilitée d'avoir plusieurs entrée sur le même sous-domaine. ToDo : Merci aux experts Alternc de regarder si j'ai mit les modifications de base dans le bon fichier (install/upgrades/1.0.sql)
This commit is contained in:
parent
33cb13286b
commit
3343aa803a
|
@ -392,6 +392,7 @@ install/upgrades/0.9.5.sql -text
|
|||
install/upgrades/0.9.6.sql -text
|
||||
install/upgrades/0.9.7.sql -text
|
||||
install/upgrades/0.9.9.sql -text
|
||||
install/upgrades/1.0.sql -text
|
||||
install/upgrades/README -text
|
||||
man/alternc-admintools.8 -text
|
||||
man/alternc-admintools.fr.8 -text
|
||||
|
|
|
@ -37,6 +37,9 @@ $fields = array (
|
|||
"sub_local" => array ("request", "string", "/"),
|
||||
"sub_url" => array ("request", "string", "http://"),
|
||||
"sub_ip" => array ("request", "string", ""),
|
||||
"sub_ipv6" => array ("request", "string", ""),
|
||||
"sub_cname" => array ("request", "string", ""),
|
||||
"sub_txt" => array ("request", "string", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
|
@ -87,10 +90,10 @@ for($i=0;$i<$r["nsub"];$i++) {
|
|||
?>
|
||||
<tr class="lst<?php echo $col; ?>">
|
||||
<td class="center">
|
||||
<div class="ina"><a href="dom_subedit.php?domain=<?php echo urlencode($r["name"]) ?>&sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>"><img src="images/edit.png" alt="<?php __("Edit"); ?>" /><?php __("Edit"); ?></a></div>
|
||||
<div class="ina"><a href="dom_subedit.php?domain=<?php echo urlencode($r["name"]) ?>&sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>&type=<?php echo urlencode($r["sub"][$i]["type"]) ?>"><img src="images/edit.png" alt="<?php __("Edit"); ?>" /><?php __("Edit"); ?></a></div>
|
||||
|
||||
</td><td class="center">
|
||||
<div class="ina"><a href="dom_subdel.php?domain=<?php echo urlencode($r["name"]) ?>&sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>"><img src="images/delete.png" alt="<?php __("Delete"); ?>" /><?php __("Delete"); ?></a></div>
|
||||
<div class="ina"><a href="dom_subdel.php?domain=<?php echo urlencode($r["name"]) ?>&sub=<?php echo urlencode($r["sub"][$i]["name"]) ?>&type=<?php echo urlencode($r["sub"][$i]["type"]) ?>"><img src="images/delete.png" alt="<?php __("Delete"); ?>" /><?php __("Delete"); ?></a></div>
|
||||
</td>
|
||||
<td><a href="http://<?php ecif($r["sub"][$i]["name"],$r["sub"][$i]["name"]."."); echo $r["name"] ?>" target="_blank"><?php ecif($r["sub"][$i]["name"],$r["sub"][$i]["name"]."."); echo $r["name"] ?></a></td>
|
||||
<td><?php echo $r["sub"][$i]['type'] === '0' ? '<a href="bro_main.php?R='.urlencode($r["sub"][$i]["dest"]).'">'.htmlspecialchars($r["sub"][$i]["dest"]).'</a>' : htmlspecialchars($r["sub"][$i]["dest"]); ?> </td>
|
||||
|
@ -125,6 +128,11 @@ for($i=0;$i<$r["nsub"];$i++) {
|
|||
<label for="url" ><?php __("URL redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_url" id="sub_url" value="<?php ehe($sub_url); ?>" size="50" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="radio" id="webmail" class="inc" name="type" value="<?php echo $dom->type_webmail; ?>" <?php cbox($type==$dom->type_webmail); ?>/>
|
||||
<label for="webmail"><?php __("Webmail access"); ?></label></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<?php if ($r["dns"]) { // show only if dns is enabled ?>
|
||||
<tr>
|
||||
<td><input type="radio" id="ip" class="inc" name="type" value="<?php echo $dom->type_ip; ?>" <?php cbox($type==$dom->type_ip); ?> onclick="document.main.sub_ip.focus();" />
|
||||
|
@ -132,18 +140,27 @@ for($i=0;$i<$r["nsub"];$i++) {
|
|||
<td><input type="text" class="int" name="sub_ip" id="sub_ip" value="<?php ehe($sub_ip); ?>" size="16" /> <small><?php __("(enter an IPv4 address, for example 192.168.1.2)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input type="radio" id="ipv6" class="inc" name="type" value="<?php echo $dom->type_ipv6; ?>" <?php cbox($type==$dom->type_ipv6); ?> onclick="document.main.sub_ip.focus();" />
|
||||
<tr><td colspan=2 style="background-color: #CFE3F1;color: #007777;font-weight:bold;" >Advanced options</td></tr>
|
||||
<tr id="advopt1">
|
||||
<td><input type="radio" id="ipv6" class="inc" name="type" value="<?php echo $dom->type_ipv6; ?>" <?php cbox($type==$dom->type_ipv6); ?> onclick="document.main.sub_ipv6.focus();" />
|
||||
<label for="ipv6"><?php __("IPv6 redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_ipv6" id="sub_ipv6" value="<?php ehe($sub_ipv6); ?>" size="32" /> <small><?php __("(enter an IPv6 address, for example 2001:0910::)"); ?></small></td>
|
||||
<td><input type="text" class="int" name="sub_ipv6" id="sub_ipv6" value="<?php ehe($sub_ipv6); ?>" size="32" /> <small><?php __("(enter an IPv6 address, for example 2001:0910::0)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
<? } ?>
|
||||
<tr>
|
||||
<td><input type="radio" id="webmail" class="inc" name="type" value="<?php echo $dom->type_webmail; ?>" <?php cbox($type==$dom->type_webmail); ?>/>
|
||||
<label for="webmail"><?php __("Webmail access"); ?></label></td>
|
||||
<td> </td>
|
||||
<tr id="advopt2">
|
||||
<td><input type="radio" id="cname" class="inc" name="type" value="<?php echo $dom->type_cname; ?>" <?php cbox($type==$dom->type_cname); ?> onclick="document.main.sub_cname.focus();" />
|
||||
<label for="cname"><?php __("CNAME redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_cname" id="sub_cname" value="<?php ehe($sub_cname); ?>" size="32" /> <small><?php __("(enter a server address or a subdomain)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
<tr id="advopt3">
|
||||
<td><input type="radio" id="txt" class="inc" name="type" value="<?php echo $dom->type_txt; ?>" <?php cbox($type==$dom->type_txt); ?> onclick="document.main.sub_txt.focus();" />
|
||||
<label for="txt"><?php __("TXT information"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_txt" id="sub_txt" value="<?php ehe($sub_txt); ?>" size="32" /> <small><?php __("(enter a TXT informations for this domain)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<? } ?>
|
||||
<tr class="trbtn">
|
||||
<td colspan="2"><input type="submit" class="inb" name="add" value="<?php __("Add this subdomain"); ?>" /></td>
|
||||
</tr>
|
||||
|
|
|
@ -33,11 +33,12 @@ include_once("head.php");
|
|||
$fields = array (
|
||||
"domain" => array ("request", "string", ""),
|
||||
"sub" => array ("request", "string", ""),
|
||||
"type" => array ("request", "string", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
$dom->lock();
|
||||
if (!$r=$dom->get_sub_domain_all($domain,$sub)) {
|
||||
if (!$r=$dom->get_sub_domain_all($domain,$sub,$type)) {
|
||||
$error=$err->errstr();
|
||||
}
|
||||
$dom->unlock();
|
||||
|
@ -60,6 +61,7 @@ $dom->unlock();
|
|||
<p class="error">
|
||||
<input type="hidden" name="domain" value="<?php echo $domain ?>" />
|
||||
<input type="hidden" name="sub" value="<?php echo $sub ?>" />
|
||||
<input type="hidden" name="type" value="<?php echo $type ?>" />
|
||||
<?php __("WARNING : Confirm the deletion of the subdomain"); ?> : </p>
|
||||
<p><?php ecif($sub,$sub."."); echo $domain; ?></p>
|
||||
<blockquote>
|
||||
|
|
|
@ -33,12 +33,13 @@ include_once("head.php");
|
|||
$fields = array (
|
||||
"domain" => array ("request", "string", ""),
|
||||
"sub" => array ("request", "string", ""),
|
||||
"type" => array ("request", "string", ""),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
$dom->lock();
|
||||
|
||||
if (!$dom->del_sub_domain($domain,$sub)) {
|
||||
if (!$dom->del_sub_domain($domain,$sub,$type)) {
|
||||
$error=$err->errstr();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,13 @@ require_once("../class/config.php");
|
|||
$fields = array (
|
||||
"domain" => array ("request", "string", ""),
|
||||
"sub" => array ("request", "string", ""),
|
||||
"type_old" => array ("request", "integer",""),
|
||||
"type" => array ("request", "integer", $dom->type_local),
|
||||
"sub_local" => array ("request", "string", "/"),
|
||||
"sub_url" => array ("request", "string", "http://"),
|
||||
"sub_ip" => array ("request", "string", ""),
|
||||
"sub_txt" => array ("request", "string", ""),
|
||||
"sub_cname" => array ("request", "string", ""),
|
||||
"sub_ipv6" => array ("request", "string", ""),
|
||||
"action" => array ("request", "string", "add"),
|
||||
);
|
||||
|
@ -45,19 +48,25 @@ $dom->lock();
|
|||
|
||||
switch ($type) {
|
||||
case $dom->type_local:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_local);
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_local, $type_old);
|
||||
break;
|
||||
case $dom->type_url:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_url);
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_url, $type_old);
|
||||
break;
|
||||
case $dom->type_txt:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_txt, $type_old);
|
||||
break;
|
||||
case $dom->type_cname:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_cname, $type_old);
|
||||
break;
|
||||
case $dom->type_ip:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_ip);
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_ip, $type_old);
|
||||
break;
|
||||
case $dom->type_ipv6:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_ipv6);
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,$sub_ipv6, $type_old);
|
||||
break;
|
||||
case $dom->type_webmail:
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,"");
|
||||
$r=$dom->set_sub_domain($domain,$sub,$type,$action,"", $type_old);
|
||||
break;
|
||||
}
|
||||
$dom->unlock();
|
||||
|
|
|
@ -38,13 +38,15 @@ $fields = array (
|
|||
"sub_url" => array ("request", "string", "http://"),
|
||||
"sub_ip" => array ("request", "string", ""),
|
||||
"sub_ipv6" => array ("request", "string", ""),
|
||||
"sub_cname" => array ("request", "string", ""),
|
||||
"sub_txt" => array ("request", "string", ""),
|
||||
"action" => array ("request", "string", "add"),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
$dom->lock();
|
||||
if (!$noread) {
|
||||
if (!$r=$dom->get_sub_domain_all($domain,$sub)) {
|
||||
if (!$r=$dom->get_sub_domain_all($domain,$sub,$type)) {
|
||||
$error=$err->errstr();
|
||||
?>
|
||||
<h3><?php __("Editing subdomain"); ?> http://<?php ecif($sub,$sub."."); echo $domain; ?></h3>
|
||||
|
@ -63,6 +65,12 @@ switch ($type) {
|
|||
case $dom->type_url:
|
||||
$sub_url=$r["dest"];
|
||||
break;
|
||||
case $dom->type_cname:
|
||||
$sub_cname=$r["dest"];
|
||||
break;
|
||||
case $dom->type_txt:
|
||||
$sub_txt=$r["dest"];
|
||||
break;
|
||||
case $dom->type_ipv6:
|
||||
$sub_ipv6=$r["dest"];
|
||||
break;
|
||||
|
@ -93,6 +101,7 @@ $dom->unlock();
|
|||
<tr>
|
||||
<td> <input type="hidden" name="domain" value="<?php ehe($domain); ?>" />
|
||||
<input type="hidden" name="sub" value="<?php echo ehe($sub); ?>" />
|
||||
<input type="hidden" name="type_old" value="<?php echo ehe($type); ?>" />
|
||||
<input type="hidden" name="action" value="edit" />
|
||||
|
||||
<input type="radio" id="local" class="inc" name="type" value="<?php echo $dom->type_local; ?>" <?php cbox($r["type"]==$dom->type_local); ?> onclick="document.main.sub_local.focus();" />
|
||||
|
@ -117,17 +126,32 @@ $dom->unlock();
|
|||
<td><input type="text" class="int" name="sub_ip" id="sub_ip" value="<?php ehe($sub_ip); ?>" size="16" /> <small><?php __("(enter an IPv4 address, for example 192.168.1.2)"); ?></small></td>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><input type="radio" id="ipv6" class="inc" name="type" value="<?php echo $dom->type_ipv6; ?>" <?php cbox($type==$dom->type_ipv6); ?> onclick="document.main.sub_ipv6.focus();" />
|
||||
<label for="ipv6"><?php __("IPv6 redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_ipv6" id="sub_ipv6" value="<?php ehe($sub_ipv6); ?>" size="16" /> <small><?php __("(enter an IPv6 address, for example 2001:0910::0)"); ?></small></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="radio" id="webmail" class="inc" name="type" value="<?php echo $dom->type_webmail; ?>" <?php cbox($r["type"]==$dom->type_webmail); ?> />
|
||||
<label for="webmail"><?php __("Webmail access"); ?></label></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan=2 style="background-color: #CFE3F1;color: #007777;font-weight:bold;" >Advanced options</td></tr>
|
||||
<tr id="advopt1">
|
||||
<td><input type="radio" id="ipv6" class="inc" name="type" value="<?php echo $dom->type_ipv6; ?>" <?php cbox($type==$dom->type_ipv6); ?> onclick="document.main.sub_ipv6.focus();" />
|
||||
<label for="ipv6"><?php __("IPv6 redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_ipv6" id="sub_ipv6" value="<?php ehe($sub_ipv6); ?>" size="32" /> <small><?php __("(enter an IPv6 address, for example 2001:0910::0)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
<tr id="advopt2">
|
||||
<td><input type="radio" id="cname" class="inc" name="type" value="<?php echo $dom->type_cname; ?>" <?php cbox($type==$dom->type_cname); ?> onclick="document.main.sub_cname.focus();" />
|
||||
<label for="cname"><?php __("CNAME redirection"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_cname" id="sub_cname" value="<?php ehe($sub_cname); ?>" size="32" /> <small><?php __("(enter a server address or a subdomain)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
<tr id="advopt3">
|
||||
<td><input type="radio" id="txt" class="inc" name="type" value="<?php echo $dom->type_txt; ?>" <?php cbox($type==$dom->type_txt); ?> onclick="document.main.sub_txt.focus();" />
|
||||
<label for="txt"><?php __("TXT information"); ?></label></td>
|
||||
<td><input type="text" class="int" name="sub_txt" id="sub_txt" value="<?php ehe($sub_txt); ?>" size="32" /> <small><?php __("(enter a TXT informations for this domain)"); ?></small></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class="trbtn">
|
||||
<td colspan="2">
|
||||
<input type="submit" class="inb" name="submit" value="<?php __("Validate this change"); ?>" />
|
||||
|
|
|
@ -115,22 +115,25 @@ function checkurl($url) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Check that TXT domain is correct */
|
||||
function checksubtxt($txt) {
|
||||
return true;
|
||||
}
|
||||
/* Check that CNAME domain is correct */
|
||||
function checkcname($cname) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check that $ip is a correct 4 Dotted ip */
|
||||
function checkip($ip) {
|
||||
// return true or false whether the ip is correctly formatted
|
||||
if (!ereg("[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*",$ip)) return false;
|
||||
$l=explode(".",$ip);
|
||||
if ($l[0]>255 || $l[1]>255 || $l[2]>255 || $l[3]>255) return false;
|
||||
return true;
|
||||
return filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
}
|
||||
|
||||
/* Check that $ip is a correct ipv6 ip */
|
||||
function checkipv6($ip) {
|
||||
// return true or false whether the ip is correctly formatted
|
||||
$pattern =
|
||||
'/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/';
|
||||
|
||||
return preg_match( $pattern, $ip ) ? TRUE : FALSE;
|
||||
return filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
||||
}
|
||||
|
||||
/* Check a login mail */
|
||||
|
|
|
@ -71,6 +71,8 @@ class m_dom {
|
|||
var $type_ip = "2";
|
||||
var $type_webmail = "3";
|
||||
var $type_ipv6 = "4";
|
||||
var $type_cname = "5";
|
||||
var $type_txt = "6";
|
||||
|
||||
var $action_insert = "0";
|
||||
var $action_update= "1";
|
||||
|
@ -631,7 +633,7 @@ class m_dom {
|
|||
* $r["type"]= Type (0-n) de la redirection.
|
||||
* Retourne FALSE si une erreur s'est produite.
|
||||
*/
|
||||
function get_sub_domain_all($dom,$sub) {
|
||||
function get_sub_domain_all($dom,$sub, $type = "") {
|
||||
global $db,$err,$cuid;
|
||||
$err->log("dom","get_sub_domain_all",$dom."/".$sub);
|
||||
// Locked ?
|
||||
|
@ -644,7 +646,10 @@ class m_dom {
|
|||
$err->raise("dom",3+$t);
|
||||
return false;
|
||||
}
|
||||
$db->query("select * from sub_domaines where compte='$cuid' and domaine='$dom' and sub='$sub'");
|
||||
if ( ! empty($type)) {
|
||||
$type = " and type='".intval($type)."'";
|
||||
}
|
||||
$db->query("select * from sub_domaines where compte='$cuid' and domaine='$dom' and sub='$sub' $type");
|
||||
if ($db->num_rows()==0) {
|
||||
$err->raise("dom",14);
|
||||
return false;
|
||||
|
@ -675,7 +680,8 @@ class m_dom {
|
|||
* de $type (url, ip, dossier...)
|
||||
* @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
|
||||
*/
|
||||
function set_sub_domain($dom,$sub,$type,$action,$dest) {
|
||||
function set_sub_domain($dom,$sub,$type,$action,$dest, $type_old=null) {
|
||||
if (is_null($type_old)) $type_old=$type;
|
||||
global $db,$err,$cuid;
|
||||
$err->log("dom","set_sub_domain",$dom."/".$sub);
|
||||
// Locked ?
|
||||
|
@ -707,6 +713,18 @@ class m_dom {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if ($type==5) { // Cname
|
||||
if (!checkcname($dest)) {
|
||||
$err->raise("dom",19);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($type==6) { // TXT
|
||||
if (!checksubtxt($dest)) {
|
||||
$err->raise("dom",19);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($type==1) { // URL
|
||||
if (!checkurl($dest)) {
|
||||
$err->raise("dom",20);
|
||||
|
@ -728,32 +746,60 @@ class m_dom {
|
|||
$err->raise("dom",3+$t);
|
||||
return false;
|
||||
}
|
||||
if (!$r=$this->get_sub_domain_all($dom,$sub)) {
|
||||
// Le sous-domaine n'existe pas, on le crée seulement si $action vaut add
|
||||
|
||||
|
||||
// Si l'action demandé est une création
|
||||
if ($action=="add") {
|
||||
$do_create=false;
|
||||
// Tout d'abord on vérifie si il faut le créer
|
||||
$r=$this->get_sub_domain_all($dom,$sub);
|
||||
if ( !$r) { $do_create=true ;}; // If subdomains do not exist
|
||||
if ($r and (!in_array($type, Array(0,1,3))) ) { // Les types URL, LOCAL et WEBMAIL ne peuvent pas être en doublon
|
||||
foreach($r as $rr) { $rtype[] = $rr['type'];} // Tableau pour vérifier les compatibilitées de type
|
||||
if (
|
||||
( $type==$this->type_ipv6 and (in_array($this->type_cname, $rtype)) ) or
|
||||
( $type==$this->type_ipv4 and (in_array($this->type_cname, $rtype)) ) or
|
||||
( $type==$this->type_cname and (in_array($this->type_ipv4, $rtype)) ) or
|
||||
( $type==$this->type_cname and (in_array($this->type_ipv6, $rtype)) )
|
||||
) { $do_create=false; } else {$do_create=true ;}
|
||||
}
|
||||
if ($do_create) {
|
||||
// Tout est, je peux créer le sous-domaine
|
||||
$db->query("insert into sub_domaines (compte,domaine,sub,valeur,type) values ('$cuid','$dom','$sub','$dest',$type);");
|
||||
$db->query("delete from sub_domaines_standby where domaine='$dom' and sub='$sub';");
|
||||
$db->query("delete from sub_domaines_standby where domaine='$dom' and sub='$sub' and type=$type;");
|
||||
$db->query("insert into sub_domaines_standby (compte,domaine,sub,valeur,type,action) values ('$cuid','$dom','$sub','$dest','$type',0);"); // INSERT
|
||||
} else {
|
||||
$err->raise("dom",14);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ($action=="edit") {
|
||||
}elseif ($action=="edit") {
|
||||
// On vérifie que des modifications ont bien eu lieu :)
|
||||
if ($r["type"]==$type && $r["dest"]==$dest) {
|
||||
$err->raise("dom",15);
|
||||
return false;
|
||||
}
|
||||
// OK, des modifs ont été faites, on valide :
|
||||
$db->query("update sub_domaines set type='$type', valeur='$dest' where domaine='$dom' and sub='$sub'");
|
||||
$db->query("delete from sub_domaines_standby where domaine='$dom' and sub='$sub'");
|
||||
//$db->query("update sub_domaines set type='$type', valeur='$dest' where domaine='$dom' and sub='$sub' and type='".$r["type"]."'");
|
||||
//$db->query("delete from sub_domaines_standby where domaine='$dom' and sub='$sub' and type='".$r["type"]."'");
|
||||
//$db->query("insert into sub_domaines_standby (compte,domaine,sub,valeur,type,action) values ('$cuid','$dom','$sub','$dest','$type',1);"); // UPDATE
|
||||
/*
|
||||
$type contient la valeur QUE LON VEUT DONNER au sous domaine
|
||||
$type_old contient la valeur du subdomain QUE LON VEUX EDITER
|
||||
|
||||
die(" XXXX type = $type ---- type_old = $type_old XXXX ");
|
||||
*/
|
||||
if ($type != $type_old) {
|
||||
$this->del_sub_domain($dom,$sub,$type_old);
|
||||
$this->set_sub_domain($dom,$sub,$type,"add",$dest);
|
||||
} else {
|
||||
$db->query("update sub_domaines set type='$type', valeur='$dest' where domaine='$dom' and sub='$sub' and type='$type_old';");
|
||||
$db->query("delete from sub_domaines_standby where domaine='$dom' and sub='$sub' and type='$type_old';");
|
||||
$db->query("insert into sub_domaines_standby (compte,domaine,sub,valeur,type,action) values ('$cuid','$dom','$sub','$dest','$type',1);"); // UPDATE
|
||||
}
|
||||
} else {
|
||||
$err->raise("dom",16);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} // set_sub_domain
|
||||
|
||||
|
@ -766,7 +812,7 @@ class m_dom {
|
|||
* @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
|
||||
*
|
||||
*/
|
||||
function del_sub_domain($dom,$sub) {
|
||||
function del_sub_domain($dom,$sub,$type) {
|
||||
global $db,$err,$cuid;
|
||||
$err->log("dom","del_sub_domain",$dom."/".$sub);
|
||||
// Locked ?
|
||||
|
@ -779,14 +825,14 @@ class m_dom {
|
|||
$err->raise("dom",3+$t);
|
||||
return false;
|
||||
}
|
||||
if (!$r=$this->get_sub_domain_all($dom,$sub)) {
|
||||
if (!$r=$this->get_sub_domain_all($dom,$sub,$type)) {
|
||||
// Le sous-domaine n'existe pas, erreur
|
||||
$err->raise("dom",14);
|
||||
return false;
|
||||
} else {
|
||||
// OK, on valide :
|
||||
$db->query("delete from sub_domaines where domaine='$dom' and sub='$sub'");
|
||||
$db->query("delete from sub_domaines_standby where domaine='$dom' and sub='$sub'");
|
||||
$db->query("delete from sub_domaines where domaine='$dom' and sub='$sub' and type='$type'");
|
||||
$db->query("delete from sub_domaines_standby where domaine='$dom' and sub='$sub' type='$type");
|
||||
$db->query("insert into sub_domaines_standby (compte,domaine,sub,valeur,type,action) values ('$cuid','$dom','$sub','".$r["dest"]."','".$r["type"]."',2);"); // DELETE
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
-- Alter table to allow use of ipv6, cname and txt in dns record
|
||||
ALTER TABLE sub_domaines_standby DROP PRIMARY KEY;
|
||||
ALTER TABLE sub_domaines_standby ADD CONSTRAINT pk_SubDomainesStandby PRIMARY KEY (compte,domaine,sub,action,type);
|
||||
|
||||
-- Alter table to allow use of ipv6, cname and txt in dns record
|
||||
ALTER TABLE sub_domaines DROP PRIMARY KEY;
|
||||
ALTER TABLE sub_domaines ADD CONSTRAINT pk_SubDomaines PRIMARY KEY (compte,domaine,sub,type);
|
|
@ -105,13 +105,25 @@ change_host_ip() {
|
|||
if [ -z "$host" ]; then
|
||||
host="@"
|
||||
fi
|
||||
if [ "$host_type" = "$TYPE_IPV6" ]; then
|
||||
|
||||
case "$host_type" in
|
||||
"$TYPE_IPV6")
|
||||
a_line="$host IN AAAA $ip"
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*AAAA[[:space:]]*.*\$"
|
||||
else
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*AAAA[[:space:]]+.+\$"
|
||||
;;
|
||||
"$TYPE_CNAME")
|
||||
a_line="$host IN CNAME $ip"
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*CNAME[[:space:]]+.+\$"
|
||||
;;
|
||||
"$TYPE_TXT")
|
||||
a_line="$host IN TXT $ip"
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*TXT[[:space:]]+.+\$"
|
||||
;;
|
||||
*)
|
||||
a_line="$host IN A $ip"
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*A[[:space:]]*.*\$"
|
||||
fi
|
||||
pattern="^$host[[:space:]]*IN[[:space:]]*A[[:space:]]+.+\$"
|
||||
esac
|
||||
|
||||
if [ ! -f "$zone_file" ]; then
|
||||
echo "Should change $host.$domain, but can't find $zone_file."
|
||||
return 1
|
||||
|
@ -138,7 +150,7 @@ add_host() {
|
|||
local fqdn
|
||||
local vhost_directory
|
||||
|
||||
delete_host "$domain" "$host"
|
||||
delete_host "$domain" "$host" "$host_type"
|
||||
|
||||
if [ "$host" = "@" -o -z "$host" ]; then
|
||||
FQDN="$domain"
|
||||
|
@ -146,16 +158,28 @@ add_host() {
|
|||
FQDN="$host.$domain"
|
||||
fi
|
||||
|
||||
if [ "$host_type" = "$TYPE_IP" ]; then
|
||||
case "$host_type" in
|
||||
"$TYPE_IP")
|
||||
ip="$value"
|
||||
elif [ "$host_type" = "$TYPE_IPV6" ]; then
|
||||
;;
|
||||
"$TYPE_IPV6")
|
||||
ip="$value"
|
||||
else
|
||||
;;
|
||||
"$TYPE_CNAME")
|
||||
ip="$value"
|
||||
;;
|
||||
"$TYPE_TXT")
|
||||
ip="$value"
|
||||
;;
|
||||
"$TYPE_WEBMAIL")
|
||||
ip="$PUBLIC_IP"
|
||||
if [ "$host_type" != "$TYPE_WEBMAIL" ]; then
|
||||
add_to_php_override "$FQDN"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
ip="$PUBLIC_IP"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$host" = "@" -o -z "$host" ]; then
|
||||
change_host_ip "$domain" "$ip" || true
|
||||
fqdn="$domain"
|
||||
|
@ -203,10 +227,12 @@ add_host() {
|
|||
delete_host() {
|
||||
local domain="$1"
|
||||
local host="$2"
|
||||
local host_type="$3"
|
||||
local domain_letter=`print_domain_letter "$domain"`
|
||||
local fqdn
|
||||
local escaped_host
|
||||
local escaped_fqdn
|
||||
local pattern
|
||||
|
||||
if [ "$host" = "@" -o -z "$host" ]; then
|
||||
fqdn="$domain"
|
||||
|
@ -218,8 +244,22 @@ delete_host() {
|
|||
|
||||
if [ -f "$ZONES_DIR/$domain" ] ; then
|
||||
cp -a -f "$ZONES_DIR/$domain" "$ZONES_DIR/$domain.$$"
|
||||
sed -e "/^$escaped_host[[:space:]]*IN[[:space:]]*\(AAAA\|A\)[[:space:]]/d" \
|
||||
< "$ZONES_DIR/$domain" > "$ZONES_DIR/$domain.$$"
|
||||
|
||||
case "$host_type" in
|
||||
"$TYPE_IPV6")
|
||||
pattern="/^$escaped_host[[:space:]]*IN[[:space:]]*AAAA[[:space:]]/d"
|
||||
;;
|
||||
"$TYPE_CNAME")
|
||||
pattern="/^$escaped_host[[:space:]]*IN[[:space:]]*CNAME[[:space:]]/d"
|
||||
;;
|
||||
"$TYPE_TXT")
|
||||
pattern="/^$escaped_host[[:space:]]*IN[[:space:]]*TXT[[:space:]]/d"
|
||||
;;
|
||||
*)
|
||||
pattern="/^$escaped_host[[:space:]]*IN[[:space:]]*A[[:space:]]/d"
|
||||
esac
|
||||
|
||||
sed -e "$pattern" < "$ZONES_DIR/$domain" > "$ZONES_DIR/$domain.$$"
|
||||
mv "$ZONES_DIR/$domain.$$" "$ZONES_DIR/$domain"
|
||||
increment_serial "$domain"
|
||||
add_to_named_reload "$domain"
|
||||
|
|
|
@ -54,6 +54,8 @@ TYPE_URL=1
|
|||
TYPE_IP=2
|
||||
TYPE_WEBMAIL=3
|
||||
TYPE_IPV6=4
|
||||
TYPE_CNAME=5
|
||||
TYPE_TXT=6
|
||||
YES=1
|
||||
|
||||
if [ `id -u` -ne 0 ]; then
|
||||
|
@ -226,7 +228,7 @@ while read user domain host value type action; do
|
|||
;;
|
||||
|
||||
$ACTION_DELETE)
|
||||
delete_host "$domain" "$host"
|
||||
delete_host "$domain" "$host" "$type"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
|
Loading…
Reference in New Issue