Ajout d'une alerte lors de certains cas problematiques sur la conf apache

This commit is contained in:
Alan Garcia 2014-03-06 18:03:21 +00:00
parent 1ca07f8139
commit 4dd3a2c915
2 changed files with 40 additions and 5 deletions

View File

@ -130,12 +130,22 @@ if (! empty($r['dns_result']) && $r['dns_result'] != '0') {
<div id="tabsdom-editsub">
<h3><?php printf(_("Editing subdomains of %s"),$domain); ?></h3>
<?php
$dt=$dom->domains_type_lst();
$problems = $dom->get_problems($domain);
if ( ! empty($problems) ) {
echo '<p class="alert alert-danger">';
foreach ($problems as $p) echo $p."</br>";
echo "</p>";
}
?>
<table class="tlist" id="dom_edit_table">
<thead>
<tr><th colspan="2"> </th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Status")?></th><th></th></tr>
</thead>
<?php
$dt=$dom->domains_type_lst();
for($i=0;$i<$r["nsub"];$i++) {
$disabled_class=in_array(strtoupper($r['sub'][$i]['enable']),array('DISABLED','DISABLE') )?'sub-disabled':'';
@ -155,9 +165,7 @@ $disabled_class=in_array(strtoupper($r['sub'][$i]['enable']),array('DISABLED','D
<?php } ?>
</td>
<?php } // end IF ==DELETE ?>
<td><div class="retour-auto <?php echo $disabled_class; ?>"><a href="http://<?php ecif($r["sub"][$i]["name"],$r["sub"][$i]["name"]."."); echo $r["name"] ?>" target="_blank"><?php
echo ecif($r["sub"][$i]["name"] , $r["sub"][$i]["name"]."." , "" , 0) . $r["name"];
?></a></div></td>
<td><div class="retour-auto <?php echo $disabled_class; ?>"><a href="http://<?php echo $r["sub"][$i]["fqdn"] ?>" target="_blank"><?php echo $r["sub"][$i]["fqdn"]; ?></a></div></td>
<td><div class="retour-auto <?php echo $disabled_class; ?>"><?php if ($r['sub'][$i]['type_desc']) { __($r['sub'][$i]['type_desc']); } else { echo __("ERROR, please check your server setup"); } ?>
<?php
//if ($r["sub"][$i]['type'] === 'VHOST') {

View File

@ -1119,6 +1119,7 @@ class m_dom {
$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"];
$r["sub"][$i]["fqdn"]= ((!empty($r["sub"][$i]["name"]))?$r["sub"][$i]["name"].".": "").$r["name"] ;
}
$db->free();
return $r;
@ -1481,7 +1482,7 @@ class m_dom {
}
$db->query("UPDATE domaines SET gesdns='$dns', gesmx='$gesmx', zonettl='$ttl' WHERE domaine='$dom'");
$db->query("UPDATE domaines set dns_action='UPDATE' where domaine='$dom';");
$dom->set_dns_action($dom, 'UPDATE');
return true;
} // edit_domain
@ -2052,6 +2053,32 @@ function generate_apacheconf($p = null) {
);
}
// List if there is problems in the domains.
// Problems can appear when editing domains type properties
function get_problems($domain) {
$this->lock();
$da = $this->get_domain_all($domain);
$this->unlock();
$errors = array();
// Check if there is more than 1 apache conf
// by subdomain
$tmp = array();
foreach ( $da['sub'] as $sub ) {
if ( ! $sub['only_dns'] ) {
if (!isset($tmp[$sub['fqdn']])) {
$tmp[$sub['fqdn']] = 0;
}
$tmp[$sub['fqdn']]++;
if ($tmp[$sub['fqdn']] >= 2 ) {
$errors[$sub['fqdn']]=sprintf(_("Problem on %s: there is more than 1 web configuration going to be generated for this sub-domain."), $sub['fqdn']);
}
}
}
// TODO: add a full compatibility check.
return $errors;
}
function default_domain_type() {
// This function is only used to allow translation of default domain types: