From 7e017eb2c702d2d3fda61d454be6626a6718644b Mon Sep 17 00:00:00 2001 From: Steven Mondji-Lerider Date: Thu, 30 Aug 2012 15:51:41 +0000 Subject: [PATCH] Ajout page de gestion des sous domaines par defaults --- .gitattributes | 1 + bureau/admin/adm_doms_def_type.php | 81 ++++++++++++++++++++++++++++++ bureau/admin/adm_panel.php | 7 +-- bureau/class/m_dom.php | 49 ++++++++++++++++++ 4 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 bureau/admin/adm_doms_def_type.php diff --git a/.gitattributes b/.gitattributes index 2447c8c2..69174870 100644 --- a/.gitattributes +++ b/.gitattributes @@ -61,6 +61,7 @@ bureau/admin/adm_dodel.php -text bureau/admin/adm_doedit.php -text bureau/admin/adm_domlock.php -text bureau/admin/adm_doms.php -text +bureau/admin/adm_doms_def_type.php -text bureau/admin/adm_domstype.php -text bureau/admin/adm_domstypedoedit.php -text bureau/admin/adm_domstypeedit.php -text diff --git a/bureau/admin/adm_doms_def_type.php b/bureau/admin/adm_doms_def_type.php new file mode 100644 index 00000000..17bd4486 --- /dev/null +++ b/bureau/admin/adm_doms_def_type.php @@ -0,0 +1,81 @@ +enabled) { + __("This page is restricted to authorized staff"); + exit(); + } + + include_once("head.php"); + + ?> +

+
+

+ +
+ $error

"; + } + + +$fields = array ( + "domup" => array ("post", "array", ""), +); +getFields($fields); + +if (!empty($domup)) { + if (!$dom->update_default_subdomains($domup) ) { + $error=_("There was an error during the record."); + } else { + $error=_("Save done."); + } +} + +$tab=$dom->lst_default_subdomains(); +?> +
+ + +"; + } +?> + + + + + + + + + + + + + +
 
+ + ' >' > + />
+

" />

+
+ diff --git a/bureau/admin/adm_panel.php b/bureau/admin/adm_panel.php index cfa7ac96..07ed7a4d 100644 --- a/bureau/admin/adm_panel.php +++ b/bureau/admin/adm_panel.php @@ -64,9 +64,10 @@ if (isset($error) && $error) {
  • -
  • -
  • -
  • +
  • +
  • +
  • +
  • diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index 317c0c9d..6ede7489 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -416,6 +416,55 @@ class m_dom { return "/www/".$this->domshort($domain); } + + function lst_default_subdomains(){ + global $db,$err; + $c=array(); + $db->query("select * from default_subdomains;"); + + while($db->next_record()) { + $c[]=array('id'=>$db->f('id'), + 'sub'=>$db->f('sub'), + 'domain_type'=>$db->f('domain_type'), + 'domain_type_parameter'=>$db->f('domain_type_parameter'), + 'concerned'=>$db->f('concerned'), + 'enabled'=>$db->f('enabled') + ) ; + } + + return $c; + } + + + function update_default_subdomains($arr) { + $ok=true; + foreach ($arr as $a) { + if (! isset($a['id'])) $a['id']=null; + if(!empty($a['sub']) || !empty($a['domain_type_parameter'])){ + + if (! isset($a['enabled'])) $a['enabled']=0; + printvar($a); + if (! $this->update_one_default($a['domain_type'],$a['sub'], $a['domain_type_parameter'], $a['concerned'], $a['enabled'],$a['id']) ) { + $ok=false; + } + } + } + return $ok; + } + + function update_one_default($domain_type,$sub,$domain_type_parameter,$concerned,$enabled,$id=null){ + global $db,$err; + + if($id==null) + $db->query("INSERT INTO default_subdomains values ('','".$sub."','".$domain_type."','".$domain_type_parameter."','".$concerned."','".$enabled."');"); + else + $db->query("UPDATE default_subdomains set sub='".$sub."', domain_type='".$domain_type."',domain_type_parameter='".$domain_type_parameter."',concerned='".$concerned."',enabled='".$enabled."' where id=".$id.";"); + return true; + //update + + + } + /* ----------------------------------------------------------------- */ /** * Retourne les entrées DNS du domaine $domain issues du WHOIS.