From dbfc59097b67141ade490d938d8ee1ed8bb96c1a Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Tue, 17 Jul 2018 16:07:48 +0200 Subject: [PATCH] [fix] misc bugs in update_domaines.php, --- bureau/admin/dom_edit.php | 1 - bureau/class/db_mysql.php | 20 ++++++++++++++++++++ bureau/class/m_apache.php | 5 ++++- bureau/class/m_bind.php | 6 +++--- bureau/class/m_dom.php | 9 +++++---- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/bureau/admin/dom_edit.php b/bureau/admin/dom_edit.php index 88d4c629..6986eb6b 100755 --- a/bureau/admin/dom_edit.php +++ b/bureau/admin/dom_edit.php @@ -197,7 +197,6 @@ if (!$r["sub"][$i]["only_dns"]) { __("HTTP and HTTPS"); break; default: - __("Unknown"); break; } } diff --git a/bureau/class/db_mysql.php b/bureau/class/db_mysql.php index 8e5a3c36..9ec79968 100644 --- a/bureau/class/db_mysql.php +++ b/bureau/class/db_mysql.php @@ -242,6 +242,26 @@ class DB_Sql { 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 */ diff --git a/bureau/class/m_apache.php b/bureau/class/m_apache.php index e497e8e1..1c26bd4d 100644 --- a/bureau/class/m_apache.php +++ b/bureau/class/m_apache.php @@ -105,7 +105,10 @@ class m_apache { /** * 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"]; @unlink($confdir."/".$subdom["fqdn"].".conf"); $this->shouldreload=true; diff --git a/bureau/class/m_bind.php b/bureau/class/m_bind.php index e85b42ad..5610e236 100644 --- a/bureau/class/m_bind.php +++ b/bureau/class/m_bind.php @@ -128,7 +128,7 @@ class m_bind { */ function hook_updatedomains_dns_del($dominfo) { $domain = $dominfo["domaine"]; - if (remove_line_from_file( + if (del_line_from_file( $this->NAMED_CONF, trim(strtr( file_get_contents($this->NAMED_TEMPLATE), @@ -157,7 +157,7 @@ class m_bind { global $msg; if ($this->shouldreload) { $ret=0; - exec($this->rndc." reload 2>&1",$out,$ret); + exec($this->RNDC." reload 2>&1",$out,$ret); if ($ret!=0) { $msg->raise("ERROR","bind","Error while reloading bind, error code is $ret\n".implode("\n",$out)); } else { @@ -166,7 +166,7 @@ class m_bind { } if ($this->shouldreconfig) { $ret=0; - exec($this->rndc." reload 2>&1",$out,$ret); + exec($this->RNDC." reload 2>&1",$out,$ret); if ($ret!=0) { $msg->raise("ERROR","bind","Error while reconfiguring bind, error code is $ret\n".implode("\n",$out)); } else { diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index 77b8bf64..029fe1c7 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -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)); // Pas de webmail, on le cochera si on le trouve. $r["sub"] = array(); - $data = $db->fetchAll(); - foreach($data as $i=>$record) { + $i=0; + while ($record=$db->fetch()) { $r["sub"][$i] = $record; // 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]["dest"] = $record["valeur"]; $r["sub"][$i]["fqdn"] = ((!empty($r["sub"][$i]["name"])) ? $r["sub"][$i]["name"] . "." : "") . $r["name"]; + $i++; } $db->free(); return $r; @@ -1920,9 +1921,9 @@ class m_dom { $hooks->invoke("hook_updatedomains_dns_pre"); foreach($alldoms as $id=>$onedom) { 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 { - $ret = $hooks->invoke("hook_updatedomains_dns_add",array(array($onedom))); + $ret = $hooks->invoke("hook_updatedomains_dns_add",array($onedom)); } if ($onedom["dns_action"]=="DELETE") {