Update domains, l'aventure continue
This commit is contained in:
parent
5e8125a697
commit
dacbd14cf9
|
@ -94,7 +94,7 @@ if ($r['dns_action']=='UPDATE') {?>
|
||||||
gestion des sous-domaines
|
gestion des sous-domaines
|
||||||
-->
|
-->
|
||||||
<table class="tlist">
|
<table class="tlist">
|
||||||
<tr><th colspan="2"><?php __("Actions"); ?></th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Place"); ?></th></tr>
|
<tr><th colspan="2"><?php __("Actions"); ?></th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Place"); ?></th><th><?php __("Enable")?></th><th><?php __("Pending");?></tr>
|
||||||
<?php
|
<?php
|
||||||
$col=1;
|
$col=1;
|
||||||
for($i=0;$i<$r["nsub"];$i++) {
|
for($i=0;$i<$r["nsub"];$i++) {
|
||||||
|
@ -110,6 +110,35 @@ for($i=0;$i<$r["nsub"];$i++) {
|
||||||
<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><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 __($r['sub'][$i]['type_desc']);?></td>
|
<td><?php __($r['sub'][$i]['type_desc']);?></td>
|
||||||
<td><?php echo $r["sub"][$i]['type'] === 'LOCAL' ? '<a href="bro_main.php?R='.urlencode($r["sub"][$i]["dest"]).'">'.htmlspecialchars($r["sub"][$i]["dest"]).'</a>' : htmlspecialchars($r["sub"][$i]["dest"]); ?> </td>
|
<td><?php echo $r["sub"][$i]['type'] === 'LOCAL' ? '<a href="bro_main.php?R='.urlencode($r["sub"][$i]["dest"]).'">'.htmlspecialchars($r["sub"][$i]["dest"]).'</a>' : htmlspecialchars($r["sub"][$i]["dest"]); ?> </td>
|
||||||
|
<td><?php
|
||||||
|
switch ($r['sub'][$i]['enable']) {
|
||||||
|
case 'ENABLED':
|
||||||
|
__("Enabled");
|
||||||
|
break;
|
||||||
|
case 'ENABLE':
|
||||||
|
__("Activation pending");
|
||||||
|
break;
|
||||||
|
case 'DISABLED':
|
||||||
|
__("Disabled");
|
||||||
|
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:
|
||||||
|
__("Up to date");
|
||||||
|
break;
|
||||||
|
}?></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -646,7 +646,7 @@ class m_dom {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
$r["nsub"]=$db->Record["cnt"];
|
$r["nsub"]=$db->Record["cnt"];
|
||||||
$db->free();
|
$db->free();
|
||||||
$db->query("select sd.*, dt.description as type_desc from sub_domaines sd, domaines_type dt where compte='$cuid' and domaine='$dom' and upper(dt.name)=upper(sd.type)");
|
$db->query("select sd.*, dt.description as type_desc, dt.only_dns from sub_domaines sd, domaines_type dt where compte='$cuid' and domaine='$dom' and upper(dt.name)=upper(sd.type)");
|
||||||
// Pas de webmail, on le cochera si on le trouve.
|
// Pas de webmail, on le cochera si on le trouve.
|
||||||
$this->webmail=0;
|
$this->webmail=0;
|
||||||
for($i=0;$i<$r["nsub"];$i++) {
|
for($i=0;$i<$r["nsub"];$i++) {
|
||||||
|
@ -655,7 +655,10 @@ class m_dom {
|
||||||
$r["sub"][$i]["name"]=$db->Record["sub"];
|
$r["sub"][$i]["name"]=$db->Record["sub"];
|
||||||
$r["sub"][$i]["dest"]=$db->Record["valeur"];
|
$r["sub"][$i]["dest"]=$db->Record["valeur"];
|
||||||
$r["sub"][$i]["type"]=$db->Record["type"];
|
$r["sub"][$i]["type"]=$db->Record["type"];
|
||||||
|
$r["sub"][$i]["enable"]=$db->Record["enable"];
|
||||||
$r["sub"][$i]["type_desc"]=$db->Record["type_desc"];
|
$r["sub"][$i]["type_desc"]=$db->Record["type_desc"];
|
||||||
|
$r["sub"][$i]["only_dns"]=$db->Record["only_dns"];
|
||||||
|
$r["sub"][$i]["web_action"]=$db->Record["web_action"];
|
||||||
/*
|
/*
|
||||||
if ($db->Record["type"]==3) { // Webmail
|
if ($db->Record["type"]==3) { // Webmail
|
||||||
$this->webmail=1;
|
$this->webmail=1;
|
||||||
|
@ -703,7 +706,7 @@ class m_dom {
|
||||||
$type = " and type=\"".mysql_real_escape_string($type)."\"";
|
$type = " and type=\"".mysql_real_escape_string($type)."\"";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
$db->query("select sd.*, dt.description as type_desc from sub_domaines sd, domaines_type dt where compte='$cuid' and domaine='$dom' and sub='$sub' and ( length('$type')=0 or type='$type') and (length('$value')=0 or '$value'=valeur) and upper(dt.name)=upper(sd.type);");
|
$db->query("select sd.*, dt.description as type_desc, dt.only_dns from sub_domaines sd, domaines_type dt where compte='$cuid' and domaine='$dom' and sub='$sub' and ( length('$type')=0 or type='$type') and (length('$value')=0 or '$value'=valeur) and upper(dt.name)=upper(sd.type);");
|
||||||
if ($db->num_rows()==0) {
|
if ($db->num_rows()==0) {
|
||||||
$err->raise("dom",14);
|
$err->raise("dom",14);
|
||||||
return false;
|
return false;
|
||||||
|
@ -712,8 +715,10 @@ class m_dom {
|
||||||
$r=array();
|
$r=array();
|
||||||
$r["name"]=$db->Record["sub"];
|
$r["name"]=$db->Record["sub"];
|
||||||
$r["dest"]=$db->Record["valeur"];
|
$r["dest"]=$db->Record["valeur"];
|
||||||
$r["type"]=$db->Record["type"];
|
$r["enable"]=$db->Record["enable"];
|
||||||
$r["type_desc"]=$db->Record["type_desc"];
|
$r["type_desc"]=$db->Record["type_desc"];
|
||||||
|
$r["only_dns"]=$db->Record["only_dns"];
|
||||||
|
$r["web_action"]=$db->Record["web_action"];
|
||||||
$db->free();
|
$db->free();
|
||||||
return $r;
|
return $r;
|
||||||
} // get_sub_domain_all
|
} // get_sub_domain_all
|
||||||
|
@ -737,6 +742,7 @@ class m_dom {
|
||||||
$err->raise("dom",21);
|
$err->raise("dom",21);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
break;
|
break;
|
||||||
case 'IP':
|
case 'IP':
|
||||||
if (checkip($value)) {return true;}
|
if (checkip($value)) {return true;}
|
||||||
|
@ -758,7 +764,7 @@ class m_dom {
|
||||||
} //check_type_value
|
} //check_type_value
|
||||||
|
|
||||||
|
|
||||||
function can_create_subdomain($dom,$sub,$type) {
|
function can_create_subdomain($dom,$sub,$type,$value_old='') {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("dom","can_create_subdomain",$dom."/".$sub);
|
$err->log("dom","can_create_subdomain",$dom."/".$sub);
|
||||||
|
|
||||||
|
@ -768,7 +774,8 @@ class m_dom {
|
||||||
$compatibility_lst = explode(",",$db->f('compatibility'));
|
$compatibility_lst = explode(",",$db->f('compatibility'));
|
||||||
|
|
||||||
# Get the list of type of subdomains already here who have the same name
|
# Get the list of type of subdomains already here who have the same name
|
||||||
$db->query("select distinct type from sub_domaines where sub='$sub' and domaine='$dom';");
|
$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom' and not (type='$type' and valeur='$value_old')");
|
||||||
|
#$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom';");
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
# And if there is a domain with a incompatible type, return false
|
# And if there is a domain with a incompatible type, return false
|
||||||
if (! in_array(strtoupper($db->f('type')),$compatibility_lst)) return false;
|
if (! in_array(strtoupper($db->f('type')),$compatibility_lst)) return false;
|
||||||
|
@ -828,7 +835,7 @@ class m_dom {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->can_create_subdomain($dom,$sub,$type)) {
|
if (! $this->can_create_subdomain($dom,$sub,$type,$value_old)) {
|
||||||
# TODO have a real error code
|
# TODO have a real error code
|
||||||
$err->raise("dom", 654);
|
$err->raise("dom", 654);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -34,8 +34,9 @@ INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibil
|
||||||
-- TODO modify mysql.sh to add this changes
|
-- TODO modify mysql.sh to add this changes
|
||||||
alter table domaines add column dns_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE';
|
alter table domaines add column dns_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE';
|
||||||
alter table domaines add column dns_result varchar(255) not null default '';
|
alter table domaines add column dns_result varchar(255) not null default '';
|
||||||
alter table sub_domaines add column web_action enum ('OK','UPDATE','ENABLE','DISABLE','DELETE') NOT NULL default 'UPDATE';
|
alter table sub_domaines add column web_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE';
|
||||||
alter table sub add column dns_result varchar(255) not null default '';
|
alter table sub_domaines add column dns_result varchar(255) not null default '';
|
||||||
|
alter table sub_domaines add column enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED';
|
||||||
drop table sub_domaines_standby;
|
drop table sub_domaines_standby;
|
||||||
drop table domaines_standby;
|
drop table domaines_standby;
|
||||||
|
|
||||||
|
|
|
@ -93,10 +93,9 @@ dns_regenerate() {
|
||||||
# Add the entry
|
# Add the entry
|
||||||
file=$(
|
file=$(
|
||||||
echo -e "$file"
|
echo -e "$file"
|
||||||
$MYSQL_DO "select distinct replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) as entry from sub_domaines sd,domaines_type dt where sd.type=dt.name and sd.domaine='$domain' order by entry ;"
|
$MYSQL_DO "select distinct replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) as entry from sub_domaines sd,domaines_type dt where sd.type=dt.name and sd.domaine='$domain' and sd.enable in ('ENABLE', 'ENABLED') order by entry ;"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Get some usefull vars
|
# Get some usefull vars
|
||||||
local mx=$( $MYSQL_DO "select mx from domaines where domaine='$domain' limit 1;")
|
local mx=$( $MYSQL_DO "select mx from domaines where domaine='$domain' limit 1;")
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ host_change_enable() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local FQDN=$2
|
local FQDN=$2
|
||||||
|
local TYPE=$3 # no use here, but one day, maybe... So here he is
|
||||||
local USER=$(get_account_by_domain $FQDN)
|
local USER=$(get_account_by_domain $FQDN)
|
||||||
local user_letter=`print_user_letter "$USER"`
|
local user_letter=`print_user_letter "$USER"`
|
||||||
local FENABLED="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
|
local FENABLED="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
|
||||||
|
|
|
@ -42,8 +42,8 @@ $MYSQL_DO "update sub_domaines sd, domaines d set sd.web_action = 'DELETE' where
|
||||||
|
|
||||||
# Sub_domaines we want to delete
|
# Sub_domaines we want to delete
|
||||||
# sub_domaines.web_action = delete
|
# sub_domaines.web_action = delete
|
||||||
for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where web_action ='DELETE';") ; do
|
for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.type) from sub_domaines sd where web_action ='DELETE';") ; do
|
||||||
host_delete $sub
|
host_delete $(echo $sub|tr '|µ' ' ')
|
||||||
# TODO Update the entry in the DB with the result and the action
|
# TODO Update the entry in the DB with the result and the action
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -51,26 +51,24 @@ done
|
||||||
# sub_domaines.web_action = update and sub_domains.only_dns = false
|
# sub_domaines.web_action = update and sub_domains.only_dns = false
|
||||||
params=$( $MYSQL_DO "
|
params=$( $MYSQL_DO "
|
||||||
select concat_ws('|µ',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), valeur)
|
select concat_ws('|µ',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), valeur)
|
||||||
from sub_domaines sd, domaines_type dt
|
from sub_domaines sd
|
||||||
where sd.web_action ='UPDATE'
|
where sd.web_action ='UPDATE'
|
||||||
and lower(sd.type) = lower(dt.name)
|
|
||||||
and dt.only_dns = false
|
|
||||||
;")
|
;")
|
||||||
for sub in $params;do
|
for sub in $params;do
|
||||||
host_create $(echo $sub|tr '|µ' ' ')
|
host_create $(echo $sub|tr '|µ' ' ')
|
||||||
# TODO Update the entry in the DB with the result and the action
|
$MYSQL_DO "update sub_domaines sd set web_action='OK',web_result='$?' where concat_ws('|µ',lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),valeur)='$sub'"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Domaine to enable
|
# Domaine to enable
|
||||||
for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='ENABLE' ;");do
|
for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='ENABLE' ;");do
|
||||||
host_enable $sub
|
host_enable $(echo $sub|tr '|µ' ' ')
|
||||||
# TODO Update the entry in the DB with the result and the action
|
$MYSQL_DO "update sub_domaines sd set enable='ENABLED' where concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Domains to disable
|
# Domains to disable
|
||||||
for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='DISABLE' ;");do
|
for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='DISABLE' ;");do
|
||||||
host_disable $sub
|
host_disable $(echo $sub|tr '|µ' ' ')
|
||||||
# TODO Update the entry in the DB with the result and the action
|
$MYSQL_DO "update sub_domaines sd set enable='DISABLED' where concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Domains we do not want to be the DNS serveur anymore :
|
# Domains we do not want to be the DNS serveur anymore :
|
||||||
|
|
Loading…
Reference in New Issue