From 9533121a53151657412723a131fbda3948172e6c Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Sun, 6 Mar 2011 15:03:51 +0000 Subject: [PATCH] =?UTF-8?q?Deux=20choses=20:=20=20-=20premier=20jet=20de?= =?UTF-8?q?=20"on=20degage=20le=20mass=20virtual=20hosting"=20=20-=20modif?= =?UTF-8?q?ication=20des=20types=20de=20domaine=20pour=20avoir=20des=20dom?= =?UTF-8?q?aines=20avanc=C3=A9=20=20-=20modification=20des=20types=20de=20?= =?UTF-8?q?domaines=20pour=20avoir=20des=20domaines=20visible=20"que"=20pa?= =?UTF-8?q?r=20les=20admins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bureau/admin/adm_domstype.php | 6 +++-- bureau/admin/adm_domstypedoedit.php | 2 +- bureau/admin/adm_domstypeedit.php | 19 +++++++++++--- bureau/admin/dom_edit.inc.php | 39 ++++++++++++++++++++++++++--- bureau/class/m_dom.php | 23 ++++++++++++++--- install/mysql.sql | 23 +++++++++-------- install/upgrades/1.0.sql | 33 +++++++++++------------- 7 files changed, 100 insertions(+), 45 deletions(-) diff --git a/bureau/admin/adm_domstype.php b/bureau/admin/adm_domstype.php index 0c82b151..7f47f25a 100644 --- a/bureau/admin/adm_domstype.php +++ b/bureau/admin/adm_domstype.php @@ -51,7 +51,7 @@ include_once("head.php");

-

+

@@ -63,6 +63,7 @@ include_once("head.php"); + domains_type_lst() as $d) { - + + diff --git a/bureau/admin/adm_domstypedoedit.php b/bureau/admin/adm_domstypedoedit.php index fde8914d..2eae6e7c 100644 --- a/bureau/admin/adm_domstypedoedit.php +++ b/bureau/admin/adm_domstypedoedit.php @@ -6,7 +6,7 @@ if (!$admin->enabled) { } -if ( ! $dom->domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns) ) { +if ( ! $dom->domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns, $advanced) ) { die($err->errstr()); } else { include("adm_domstype.php"); diff --git a/bureau/admin/adm_domstypeedit.php b/bureau/admin/adm_domstypeedit.php index 1e8927c8..1225cc57 100644 --- a/bureau/admin/adm_domstypeedit.php +++ b/bureau/admin/adm_domstypeedit.php @@ -41,9 +41,10 @@ $fields = array ( "target" => array ("request", "string", ""), "entry" => array ("request", "string", ""), "compatibility" => array ("request", "string", ""), - "enable" => array ("request", "boolean", ""), + "enable" => array ("request", "string", ""), "only_dns" => array ("request", "boolean", ""), "need_dns" => array ("request", "boolean", ""), + "advanced" => array ("request", "boolean", ""), ); getFields($fields); @@ -90,12 +91,18 @@ if ($error_edit) { - + - + @@ -104,11 +111,15 @@ if ($error_edit) { + + + +


/> + +
/>
/>
" /> - " onclick="document.location='adm_domstype.php'"/> + " onclick="document.location='adm_domstype.php'"/>
diff --git a/bureau/admin/dom_edit.inc.php b/bureau/admin/dom_edit.inc.php index fc5b28a6..8e9f287d 100644 --- a/bureau/admin/dom_edit.inc.php +++ b/bureau/admin/dom_edit.inc.php @@ -7,6 +7,7 @@ include_once("head.php"); # Take the values of the subdomain in arguments function sub_domains_edit($domain, $sub=false,$type=false,$value=false) { +global $admin, $oldid; $dom=new m_dom(); $dom->lock(); @@ -37,13 +38,27 @@ $dom->unlock(); . - domains_type_lst() as $dt) { - if (! $dt['enable']) continue; + domains_type_lst() as $dt) { + // If this type is disabled AND it's not the type in use here, continue + if ( $dt['enable'] == 'NONE' && strtoupper($type)!=strtoupper($dt['name'])) continue ; + // If this type is only for ADMIN and i'm not an admin, continue (oldid is to check if we are an admin who take user identity) + if (( $dt['enable'] == 'ADMIN') && (! $admin->enabled and ! intval($oldid))) continue; + if ( (! $r['dns'] ) and ($dt['need_dns']) ) continue; - //if ( strtoupper($type)!=strtoupper($dt['name']) ) continue; $targval=(strtoupper($type)==strtoupper($dt['name']))?$sd['dest']:''; + + if ($dt['advanced']) { + $lst_advanced[]=$dt['name']; + if ($first_advanced) { + $first_advanced=false; + echo "+ "; __("Show advanced options"); echo ""; + echo "- "; __("Hide advanced options"); echo ""; + } + } ?> - + /> @@ -94,6 +109,22 @@ $dom->unlock(); + + diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index 5f5057d8..34aafccd 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -102,7 +102,7 @@ class m_dom { function domains_type_lst() { global $db,$err,$cuid; $err->log("dom","domains_type_lst"); - $db->query("select * from domaines_type order by name;"); + $db->query("select * from domaines_type order by advanced, name;"); $this->domains_type_lst=false; while ($db->next_record()) { $this->domains_type_lst[] = $db->Record; @@ -110,6 +110,20 @@ class m_dom { return $this->domains_type_lst; } + function domains_type_enable_values() { + global $db,$err,$cuid; + $err->log("dom","domains_type_target_values"); + $db->query("desc domaines_type;"); + $r = array(); + while ($db->next_record()) { + if ($db->f('Field') == 'enable') { + $tab = explode(",", substr($db->f('Type'), 5, -1)); + foreach($tab as $t) { $r[]=substr($t,1,-1); } + } + } + return $r; + } + function domains_type_target_values($type=null) { global $db,$err,$cuid; $err->log("dom","domains_type_target_values"); @@ -167,7 +181,7 @@ class m_dom { return true; } - function domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns) { + function domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns,$advanced) { global $err,$cuid,$db; $id=intval($id); $name=mysql_real_escape_string($name); @@ -175,10 +189,11 @@ class m_dom { $target=mysql_real_escape_string($target); $entry=mysql_real_escape_string($entry); $compatibility=mysql_real_escape_string($compatibility); - $enable=intval($enable); + $enable=mysql_real_escape_string($enable); $only_dns=intval($only_dns); $need_dns=intval($need_dns); - $db->query("UPDATE domaines_type SET description='$description', target='$target', entry='$entry', compatibility='$compatibility', enable=$enable, need_dns=$need_dns, only_dns=$only_dns where name='$name';"); + $advanced=intval($advanced); + $db->query("UPDATE domaines_type SET description='$description', target='$target', entry='$entry', compatibility='$compatibility', enable='$enable', need_dns=$need_dns, only_dns=$only_dns, advanced='$advanced' where name='$name';"); return true; } diff --git a/install/mysql.sql b/install/mysql.sql index 17fbcff2..68dff8f8 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -487,22 +487,23 @@ CREATE TABLE IF NOT EXISTS `domaines_type` ( `target` enum ('NONE', 'URL', 'DIRECTORY', 'IP', 'IPV6', 'DOMAIN', 'TXT') NOT NULL DEFAULT 'NONE', -- Target type `entry` VARCHAR (255) DEFAULT '', -- BIND entry `compatibility` VARCHAR (255) DEFAULT '', -- Which type can be on the same subdomains - `enable` BOOLEAN DEFAULT TRUE, -- Show this options to the users ? + `enable` enum ('ALL', 'NONE', 'ADMIN') NOT NULL DEFAULT 'ALL', -- Show this option to who ? `only_dns` BOOLEAN DEFAULT FALSE, -- Update_domains modify just the dns, no web configuration `need_dns` BOOLEAN DEFAULT TRUE, -- The server need to be the DNS to allow this service + `advanced` BOOLEAN DEFAULT TRUE, -- It's an advanced option PRIMARY KEY ( `name` ) ) COMMENT = 'Type of domains allowed'; -INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns) values -('local','Locally managed', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false), -('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt', true, true), -('ip','IP redirection', 'IP', '%SUB% IN A %TARGET%','url,ip,ipv6,txt', false, true), -('webmail', 'Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false), -('ipv6','ipv6 address', 'IPV6', '%SUB% IN AAAA %TARGET%','ip,ipv6,webmail,txt',true, true), -('cname', 'cname entry', 'DOMAIN', '%SUB% CNAME %TARGET%', 'txt',true, true), -('txt', 'txt entry', 'TXT', '%SUB% IN TXT "%TARGET%"','local,url,ip,webmail,ipv6,cname,txt',true, true), -('mx', 'mx entry', 'IP', '%SUB% IN MX %TARGET%', 'local,url,ip,webmail,ipv6,cname,txt',true, false), -('panel', 'Panel redirection', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'local,url,ip,webmail,ipv6,cname,txt',true, false) +INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns, advanced) values +('vhost','Locally managed', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false), +('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt', true, true, false), +('ip','IP redirection', 'IP', '%SUB% IN A %TARGET%','url,ip,ipv6,txt', false, true, true), +('webmail', 'Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false), +('ipv6','IPv6 address', 'IPV6', '%SUB% IN AAAA %TARGET%','ip,ipv6,webmail,txt',true, true, true ), +('cname', 'cname entry', 'DOMAIN', '%SUB% CNAME %TARGET%', 'txt',true, true, true ), +('txt', 'txt entry', 'TXT', '%SUB% IN TXT "%TARGET%"','vhost,url,ip,webmail,ipv6,cname,txt',true, true, true), +('mx', 'mx entry', 'IP', '%SUB% IN MX %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt',true, false, true), +('panel', 'Panel redirection', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,ip,webmail,ipv6,cname,txt',true, false, false) ; diff --git a/install/upgrades/1.0.sql b/install/upgrades/1.0.sql index 7519fa7a..c754efd6 100644 --- a/install/upgrades/1.0.sql +++ b/install/upgrades/1.0.sql @@ -12,27 +12,26 @@ CREATE TABLE IF NOT EXISTS `domaines_type` ( `target` enum ('NONE', 'URL', 'DIRECTORY', 'IP', 'IPV6', 'DOMAIN', 'TXT') NOT NULL DEFAULT 'NONE', -- Target type `entry` VARCHAR (255) DEFAULT '', -- BIND entry `compatibility` VARCHAR (255) DEFAULT '', -- Which type can be on the same subdomains - `enable` BOOLEAN DEFAULT TRUE, -- Show this options to the users ? + `enable` enum ('ALL', 'NONE', 'ADMIN') NOT NULL DEFAULT 'ALL', -- Show this option to who ? `only_dns` BOOLEAN DEFAULT FALSE, -- Update_domains modify just the dns, no web configuration `need_dns` BOOLEAN DEFAULT TRUE, -- The server need to be the DNS to allow this service + `advanced` BOOLEAN DEFAULT TRUE, -- It's an advanced option PRIMARY KEY ( `name` ) ) COMMENT = 'Type of domains allowed'; -INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns) values -('massvhost','Locally managed with Mass Virtual Hosting technologie', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false), -('local','Locally managed', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false), -('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt', true, true), -('ip','IP redirection', 'IP', '%SUB% IN A %TARGET%','url,ip,ipv6,txt', false, true), -('webmail', 'Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false), -('ipv6','ipv6 address', 'IPV6', '%SUB% IN AAAA %TARGET%','ip,ipv6,webmail,txt',true, true), -('cname', 'cname entry', 'DOMAIN', '%SUB% CNAME %TARGET%', 'txt',true, true), -('txt', 'txt entry', 'TXT', '%SUB% IN TXT "%TARGET%"','local,url,ip,webmail,ipv6,cname,txt',true, true), -('mx', 'mx entry', 'IP', '%SUB% IN MX %TARGET%', 'local,url,ip,webmail,ipv6,cname,txt',true, false), -('panel', 'Panel redirection', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'local,url,ip,webmail,ipv6,cname,txt',true, false) +INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns, advanced) values +('vhost','Locally managed', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false), +('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt', true, true, false), +('ip','IP redirection', 'IP', '%SUB% IN A %TARGET%','url,ip,ipv6,txt', false, true, true), +('webmail', 'Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false), +('ipv6','IPv6 address', 'IPV6', '%SUB% IN AAAA %TARGET%','ip,ipv6,webmail,txt',true, true, true ), +('cname', 'cname entry', 'DOMAIN', '%SUB% CNAME %TARGET%', 'txt',true, true, true ), +('txt', 'txt entry', 'TXT', '%SUB% IN TXT "%TARGET%"','vhost,url,ip,webmail,ipv6,cname,txt',true, true, true), +('mx', 'mx entry', 'IP', '%SUB% IN MX %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt',true, false, true), +('panel', 'Panel redirection', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,ip,webmail,ipv6,cname,txt',true, false, false) ; -- Changing standby use --- 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_result varchar(255) not null default ''; alter table sub_domaines add column web_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE'; @@ -41,16 +40,12 @@ alter table sub_domaines add column enable enum ('ENABLED', 'ENABLE', 'DISABLED' drop table sub_domaines_standby; drop table domaines_standby; -update sub_domaines set type='MASSVHOST' where type='0'; +update sub_domaines set type='VHOST' where type='0'; -- We decide to drop massvhost. update sub_domaines set type='URL' where type='1'; update sub_domaines set type='IP' where type='2'; update sub_domaines set type='WEBMAIL' where type='3'; update sub_domaines set type='IPV6' where type='4'; update sub_domaines set type='CNAME' where type='5'; update sub_domaines set type='TXT' where type='6'; - --- If people want to stop using mass virtual hosting and use only virtual hosting : --- insert into sub_domaines (compte, domaine, sub, valeur, type,web_action) select compte, domaine, sub, valeur, 'local', 'UPDATE' --- from sub_domaines where lower(type)='massvhost'; --- update sub_domaines set web_action = 'DELETE' where lower(type)='massvhost'; +update sub_domaines set web_action='UPDATE';