[fix] misc bugs in update_domaines.php,

This commit is contained in:
Benjamin Sonntag 2018-07-17 16:07:48 +02:00
parent 7445439654
commit dbfc59097b
5 changed files with 32 additions and 9 deletions

View File

@ -197,7 +197,6 @@ if (!$r["sub"][$i]["only_dns"]) {
__("HTTP and HTTPS"); __("HTTP and HTTPS");
break; break;
default: default:
__("Unknown");
break; break;
} }
} }

View File

@ -242,6 +242,26 @@ class DB_Sql {
return $data; return $data;
} }
/* pdo equivalent of fetch() */
function fetch($mode=PDO::FETCH_ASSOC) {
if (!$this->pdo_query) {
$this->halt("next_record called with no query pending.");
return FALSE;
}
$data = $this->pdo_query->fetch($mode);
$this->Errno = $this->pdo_query->errorCode();
$this->Error = $this->pdo_query->errorInfo();
if ($data == FALSE) {
if ($this->Auto_Free)
$this->free();
return FALSE;
}
return $data;
}
/** /**
* table locking * table locking
*/ */

View File

@ -105,7 +105,10 @@ class m_apache {
/** /**
* launched for each FQDN for which we want to delete a vhost template * launched for each FQDN for which we want to delete a vhost template
*/ */
function hook_updatedomains_web_del($subdom) { function hook_updatedomains_web_del($subdomid) {
$db->query("SELECT sd.*, dt.only_dns, dt.has_https_option, m.login FROM domaines_type dt, sub_domaines sd LEFT JOIN membres m ON m.uid=sd.compte WHERE dt.name=sd.type AND sd.web_action!='OK' AND id=?;",array($subdomid));
$db->next_record();
$subdom=$db->Record;
$confdir = $this->vhostroot."/".substr($subdom["compte"],-1)."/".$subdom["compte"]; $confdir = $this->vhostroot."/".substr($subdom["compte"],-1)."/".$subdom["compte"];
@unlink($confdir."/".$subdom["fqdn"].".conf"); @unlink($confdir."/".$subdom["fqdn"].".conf");
$this->shouldreload=true; $this->shouldreload=true;

View File

@ -128,7 +128,7 @@ class m_bind {
*/ */
function hook_updatedomains_dns_del($dominfo) { function hook_updatedomains_dns_del($dominfo) {
$domain = $dominfo["domaine"]; $domain = $dominfo["domaine"];
if (remove_line_from_file( if (del_line_from_file(
$this->NAMED_CONF, $this->NAMED_CONF,
trim(strtr( trim(strtr(
file_get_contents($this->NAMED_TEMPLATE), file_get_contents($this->NAMED_TEMPLATE),
@ -157,7 +157,7 @@ class m_bind {
global $msg; global $msg;
if ($this->shouldreload) { if ($this->shouldreload) {
$ret=0; $ret=0;
exec($this->rndc." reload 2>&1",$out,$ret); exec($this->RNDC." reload 2>&1",$out,$ret);
if ($ret!=0) { if ($ret!=0) {
$msg->raise("ERROR","bind","Error while reloading bind, error code is $ret\n".implode("\n",$out)); $msg->raise("ERROR","bind","Error while reloading bind, error code is $ret\n".implode("\n",$out));
} else { } else {
@ -166,7 +166,7 @@ class m_bind {
} }
if ($this->shouldreconfig) { if ($this->shouldreconfig) {
$ret=0; $ret=0;
exec($this->rndc." reload 2>&1",$out,$ret); exec($this->RNDC." reload 2>&1",$out,$ret);
if ($ret!=0) { if ($ret!=0) {
$msg->raise("ERROR","bind","Error while reconfiguring bind, error code is $ret\n".implode("\n",$out)); $msg->raise("ERROR","bind","Error while reconfiguring bind, error code is $ret\n".implode("\n",$out));
} else { } else {

View File

@ -1065,13 +1065,14 @@ class m_dom {
$db->query("SELECT sd.*, dt.description AS type_desc, dt.only_dns, dt.advanced, dt.has_https_option FROM sub_domaines sd LEFT JOIN domaines_type dt on UPPER(dt.name)=UPPER(sd.type) WHERE compte= ? AND domaine= ? ORDER BY dt.advanced,sd.sub,sd.type ;", array($cuid, $dom)); $db->query("SELECT sd.*, dt.description AS type_desc, dt.only_dns, dt.advanced, dt.has_https_option FROM sub_domaines sd LEFT JOIN domaines_type dt on UPPER(dt.name)=UPPER(sd.type) WHERE compte= ? AND domaine= ? ORDER BY dt.advanced,sd.sub,sd.type ;", array($cuid, $dom));
// Pas de webmail, on le cochera si on le trouve. // Pas de webmail, on le cochera si on le trouve.
$r["sub"] = array(); $r["sub"] = array();
$data = $db->fetchAll(); $i=0;
foreach($data as $i=>$record) { while ($record=$db->fetch()) {
$r["sub"][$i] = $record; $r["sub"][$i] = $record;
// FIXME : replace sub by name and dest by valeur in the code that exploits this function : // FIXME : replace sub by name and dest by valeur in the code that exploits this function :
$r["sub"][$i]["name"] = $record["sub"]; $r["sub"][$i]["name"] = $record["sub"];
$r["sub"][$i]["dest"] = $record["valeur"]; $r["sub"][$i]["dest"] = $record["valeur"];
$r["sub"][$i]["fqdn"] = ((!empty($r["sub"][$i]["name"])) ? $r["sub"][$i]["name"] . "." : "") . $r["name"]; $r["sub"][$i]["fqdn"] = ((!empty($r["sub"][$i]["name"])) ? $r["sub"][$i]["name"] . "." : "") . $r["name"];
$i++;
} }
$db->free(); $db->free();
return $r; return $r;
@ -1920,9 +1921,9 @@ class m_dom {
$hooks->invoke("hook_updatedomains_dns_pre"); $hooks->invoke("hook_updatedomains_dns_pre");
foreach($alldoms as $id=>$onedom) { foreach($alldoms as $id=>$onedom) {
if ($onedom["gesdns"]==0 || $onedom["dns_action"]=="DELETE") { if ($onedom["gesdns"]==0 || $onedom["dns_action"]=="DELETE") {
$ret = $hooks->invoke("hook_updatedomains_dns_del",array(array($onedom))); $ret = $hooks->invoke("hook_updatedomains_dns_del",array($onedom));
} else { } else {
$ret = $hooks->invoke("hook_updatedomains_dns_add",array(array($onedom))); $ret = $hooks->invoke("hook_updatedomains_dns_add",array($onedom));
} }
if ($onedom["dns_action"]=="DELETE") { if ($onedom["dns_action"]=="DELETE") {