From 09bb69348028ed72c355e1d6888b023b6f6f51ca Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Fri, 22 Jun 2018 16:31:23 +0200 Subject: [PATCH] [enh] adding HTTP/HTTPS/BOTH UI in the subdomain editor. --- bureau/admin/dom_edit.inc.php | 15 ++++++++++++--- bureau/admin/dom_subdoedit.php | 5 ++++- bureau/admin/styles/style.css | 29 +++++++++++++---------------- bureau/class/m_dom.php | 28 ++++++++++++++++++++++------ install/mysql.sql | 2 +- 5 files changed, 52 insertions(+), 27 deletions(-) diff --git a/bureau/admin/dom_edit.inc.php b/bureau/admin/dom_edit.inc.php index e69c4de2..bebf535f 100755 --- a/bureau/admin/dom_edit.inc.php +++ b/bureau/admin/dom_edit.inc.php @@ -50,7 +50,7 @@ $dom->unlock();
- +
+ unlock(); $lst_advanced[]=$dt['name']; if ($first_advanced) { $first_advanced=false; - echo ""; echo ""; echo ""; - echo ""; } } ?> @@ -126,6 +125,16 @@ $dom->unlock(); break; } // switch ?> + diff --git a/bureau/admin/dom_subdoedit.php b/bureau/admin/dom_subdoedit.php index a7e20395..8e027bcf 100644 --- a/bureau/admin/dom_subdoedit.php +++ b/bureau/admin/dom_subdoedit.php @@ -35,11 +35,14 @@ getFields($fields); // here we get a dynamic-named value $dynamicvar="t_$type"; +$httpsvar="https_$type"; $fields = array ( "$dynamicvar" => array ("post", "string", ""), + "$httpsvar" => array ("post", "string", ""), ); getFields($fields); $value=$$dynamicvar; +$https=$$httpsvar; // The dynamic value is now in $value $dom->lock(); @@ -52,7 +55,7 @@ if ( (!isset($isinvited) || !$isinvited) && $dt[strtolower($type)]["enable"] != } if (empty($sub_domain_id)) $sub_domain_id=null; -$r=$dom->set_sub_domain($domain,$sub,$type,$value, $sub_domain_id); +$r=$dom->set_sub_domain($domain, $sub, $type, $value, $sub_domain_id, $https); $dom->unlock(); diff --git a/bureau/admin/styles/style.css b/bureau/admin/styles/style.css index f0a0c0eb..832b0f38 100644 --- a/bureau/admin/styles/style.css +++ b/bureau/admin/styles/style.css @@ -205,21 +205,15 @@ div.ui-accordion-content > ul { margin-top: 0px !important; } -select { - border: 1px solid #999; - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; - font-size: 13px; - color: black; - background: white; - text-transform: lowercase; -} - -.inc, .inl { - border: 1px solid #999; +select, .inc, .inl { + border: 1px solid #ccc; + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 13px; color: black; background: white; + padding: 4px; } #inp1 { @@ -242,7 +236,7 @@ p > input#file + br + .inb, p > input#file + br + .inb + .inb { input.inb, input.ina{ color: black; white-space: nowrap; - border: 1px solid #999; + border: 1px solid black; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 14px; padding: 4px 10px 4px 0px; @@ -256,7 +250,7 @@ input.inb, input.ina{ } input.inb:hover, input.ina:hover { - border: 1px solid #999; + border: 1px solid black; text-decoration: none; background-color: #F0F0F0; } @@ -336,7 +330,7 @@ input.ui-state-hover { input.ina, input.inav, input.ina:hover, input.inav:hover { - border: 1px solid #999; + border: 1px solid black; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 14px; color: black; @@ -361,7 +355,7 @@ input.ina:hover, .ina a:hover, .inb a:hover { .ina a, a.ina, .inb a, a.inb,.inav a, a.inav { color: black; white-space: nowrap; - border: 1px solid #999; + border: 1px solid black; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 14px; padding: 4px 10px; @@ -416,7 +410,7 @@ span#newsubname { float: left; } .bff { - border: 1px solid #999; + border: 1px solid black; background-color: #F0F0F0; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 13px; @@ -1273,6 +1267,9 @@ input.cancel:active { border-top: 1px solid #ddd; } +.dom-edit-table td { + height: 2.4em; +} .dom a, a.dom, input.dom, .dom-menu .menu-title { background-image: url(../images/dom.png); background-repeat: no-repeat; diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index 862cba22..75820760 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -170,7 +170,7 @@ class m_dom { function domains_type_enable_values() { global $db, $msg, $cuid; - $msg->log("dom", "domains_type_target_values"); + $msg->log("dom", "domains_type_enable_values"); $db->query("desc domaines_type;"); $r = array(); while ($db->next_record()) { @@ -1256,11 +1256,26 @@ class m_dom { $r["type_desc"] = $db->Record["type_desc"]; $r["only_dns"] = $db->Record["only_dns"]; $r["web_action"] = $db->Record["web_action"]; + $r["https"] = $db->Record["https"]; $db->free(); return $r; } // get_sub_domain_all + function clean_https_value($type, $https) { + global $db; + $db->query("select has_https_option from domaines_type where name= ? ;", array($type)); + if (!$db->next_record()) { + return ""; + } + if ($db->Record["has_https_option"]) { + $https=strtolower($https); + if ($https!="http" && $https!="https" && $https!="both") { + return "both"; + } + return $https; + } else return ""; + } /** * @param integer $type * @param string $value @@ -1385,9 +1400,11 @@ class m_dom { * @param integer $type Type de sous-domaine (local, ip, url ...) * @param string $dest Destination du sous-domaine, dépend de la valeur * de $type (url, ip, dossier...) + * @param string $https the HTTPS behavior : HTTP(redirect https to http), + * HTTPS(redirect http to https) or BOTH (both hosted at the same place) * @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. */ - function set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id = 0) { + function set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id = 0, $https) { global $db, $msg, $cuid, $bro; $msg->log("dom", "set_sub_domain", $dom . "/" . $sub . "/" . $type . "/" . $dest); // Locked ? @@ -1399,7 +1416,6 @@ class m_dom { $sub = trim(trim($sub), "."); $dom = strtolower($dom); $sub = strtolower($sub); - // if (!(($sub == '*') || ($sub=="") || (preg_match('/([a-z0-9][\.\-a-z0-9]*)?[a-z0-9]/', $sub)))) { $fqdn = checkfqdn($sub); // Special cases : * (all subdomains at once) and '' empty subdomain are allowed. @@ -1409,10 +1425,10 @@ class m_dom { } if (!$this->check_type_value($type, $dest)) { - //plutot verifier si la chaine d'erreur est vide avant de raise sinon sa veut dire que l(erruer est deja remonté // error raised by check_type_value return false; } + $https=$this->clean_https_value($type, $https); // On a épuré $dir des problémes eventuels ... On est en DESSOUS du dossier de l'utilisateur. if (($t = checkfqdn($dom))) { @@ -1430,8 +1446,8 @@ class m_dom { } // Re-create the one we want - if (!$db->query("INSERT INTO sub_domaines (compte,domaine,sub,valeur,type,web_action) VALUES (?, ?, ?, ?, ?, 'UPDATE');", array( $cuid , $dom , $sub , $dest , $type ))) { - echo "query failed: " . $db->Error; + if (!$db->query("INSERT INTO sub_domaines (compte,domaine,sub,valeur,type,web_action,https) VALUES (?, ?, ?, ?, ?, 'UPDATE',?);", array( $cuid , $dom , $sub , $dest , $type, $https ))) { + $msg->raise("ERROR", "dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility")); return false; } diff --git a/install/mysql.sql b/install/mysql.sql index 7a614a09..5911ef70 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -224,7 +224,7 @@ CREATE TABLE IF NOT EXISTS sub_domaines ( enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED', `certificate_id` INT UNSIGNED NOT NULL DEFAULT '0', `provider` VARCHAR(16) NOT NULL DEFAULT '', - `https` VARCHAR(4) NOT NULL, -- SET(http,https,both) (also the suffix of the template name in /etc/alternc/templates/apache2/) + `https` VARCHAR(6) NOT NULL, -- SET(http,https,both) (also the suffix of the template name in /etc/alternc/templates/apache2/) PRIMARY KEY (id) -- ,FOREIGN KEY (type) REFERENCES (domaines_type) ) ENGINE=InnoDB;
@@ -64,6 +64,7 @@ $dom->unlock(); } ?> .
+ "; __("Show advanced options"); echo "
+ + + + +