[enh] adding HTTP/HTTPS/BOTH UI in the subdomain editor.
This commit is contained in:
parent
6ba6a40d05
commit
09bb693480
|
@ -50,7 +50,7 @@ $dom->unlock();
|
||||||
|
|
||||||
<form action="dom_subdoedit.php" method="post" name="main" id="main">
|
<form action="dom_subdoedit.php" method="post" name="main" id="main">
|
||||||
<?php csrf_get(); ?>
|
<?php csrf_get(); ?>
|
||||||
<table border="0">
|
<table class="dom-edit-table">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="domain" value="<?php ehe($domain) ?>" />
|
<input type="hidden" name="domain" value="<?php ehe($domain) ?>" />
|
||||||
|
@ -64,6 +64,7 @@ $dom->unlock();
|
||||||
}
|
}
|
||||||
?></td><td>
|
?></td><td>
|
||||||
<input type="text" class="int" name="sub" style="text-align:right" value="<?php ehe($sub); ?>" size="22" id="sub" /><span class="int" id="newsubname">.<?php ehe($domain); ?></span></td>
|
<input type="text" class="int" name="sub" style="text-align:right" value="<?php ehe($sub); ?>" size="22" id="sub" /><span class="int" id="newsubname">.<?php ehe($domain); ?></span></td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
$first_advanced=true;
|
$first_advanced=true;
|
||||||
|
@ -81,10 +82,8 @@ $dom->unlock();
|
||||||
$lst_advanced[]=$dt['name'];
|
$lst_advanced[]=$dt['name'];
|
||||||
if ($first_advanced) {
|
if ($first_advanced) {
|
||||||
$first_advanced=false;
|
$first_advanced=false;
|
||||||
echo "<tr><td colspan=\"2\" class=\"advdom\"></td></tr>";
|
|
||||||
echo "<tr id='domtype_show' onClick=\"domtype_advanced_show();\"><td colspan='2'><a href=\"javascript:domtype_advanced_show();\"><b>+ "; __("Show advanced options"); echo "</b></a></td></tr>";
|
echo "<tr id='domtype_show' onClick=\"domtype_advanced_show();\"><td colspan='2'><a href=\"javascript:domtype_advanced_show();\"><b>+ "; __("Show advanced options"); echo "</b></a></td></tr>";
|
||||||
echo "<tr id='domtype_hide' onClick=\"domtype_advanced_hide();\" style='display:none'><td colspan='2'><a href=\"javascript:domtype_advanced_hide();\"><b>- "; __("Hide advanced options"); echo "</b></a></td></tr>";
|
echo "<tr id='domtype_hide' onClick=\"domtype_advanced_hide();\" style='display:none'><td colspan='2'><a href=\"javascript:domtype_advanced_hide();\"><b>- "; __("Hide advanced options"); echo "</b></a></td></tr>";
|
||||||
echo "<tr><td colspan=\"2\" class=\"advdom\"></td></tr>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -126,6 +125,16 @@ $dom->unlock();
|
||||||
break;
|
break;
|
||||||
} // switch ?>
|
} // switch ?>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php if ($dt['has_https_option']) { ?>
|
||||||
|
|
||||||
|
<select class="inl" name="https_<?php ehe($dt['name']); ?>" id="https_<?php ehe($dt['name']); ?>">
|
||||||
|
<option value="http"<?php selected((strtoupper($type)==strtoupper($dt['name']) && $sd["https"]=="http") || false); ?>><?php __("HTTP Only (redirect HTTPS to HTTP)"); ?></option>
|
||||||
|
<option value="https"<?php selected((strtoupper($type)==strtoupper($dt['name']) && $sd["https"]=="http") || true); ?>><?php __("HTTPS Only (redirect HTTP to HTTPS)"); ?></option>
|
||||||
|
<option value="both"<?php selected((strtoupper($type)==strtoupper($dt['name']) && $sd["https"]=="http") || false); ?>><?php __("Both HTTP and HTTPS hosted at the same place"); ?></option>
|
||||||
|
</select>
|
||||||
|
<?php } ?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } // foreach ?>
|
<?php } // foreach ?>
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,14 @@ getFields($fields);
|
||||||
|
|
||||||
// here we get a dynamic-named value
|
// here we get a dynamic-named value
|
||||||
$dynamicvar="t_$type";
|
$dynamicvar="t_$type";
|
||||||
|
$httpsvar="https_$type";
|
||||||
$fields = array (
|
$fields = array (
|
||||||
"$dynamicvar" => array ("post", "string", ""),
|
"$dynamicvar" => array ("post", "string", ""),
|
||||||
|
"$httpsvar" => array ("post", "string", ""),
|
||||||
);
|
);
|
||||||
getFields($fields);
|
getFields($fields);
|
||||||
$value=$$dynamicvar;
|
$value=$$dynamicvar;
|
||||||
|
$https=$$httpsvar;
|
||||||
// The dynamic value is now in $value
|
// The dynamic value is now in $value
|
||||||
|
|
||||||
$dom->lock();
|
$dom->lock();
|
||||||
|
@ -52,7 +55,7 @@ if ( (!isset($isinvited) || !$isinvited) && $dt[strtolower($type)]["enable"] !=
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($sub_domain_id)) $sub_domain_id=null;
|
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();
|
$dom->unlock();
|
||||||
|
|
||||||
|
|
|
@ -205,21 +205,15 @@ div.ui-accordion-content > ul {
|
||||||
margin-top: 0px !important;
|
margin-top: 0px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select, .inc, .inl {
|
||||||
border: 1px solid #999;
|
border: 1px solid #ccc;
|
||||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
border-top-left-radius: 0px;
|
||||||
font-size: 13px;
|
border-bottom-left-radius: 0px;
|
||||||
color: black;
|
|
||||||
background: white;
|
|
||||||
text-transform: lowercase;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inc, .inl {
|
|
||||||
border: 1px solid #999;
|
|
||||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: black;
|
color: black;
|
||||||
background: white;
|
background: white;
|
||||||
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#inp1 {
|
#inp1 {
|
||||||
|
@ -242,7 +236,7 @@ p > input#file + br + .inb, p > input#file + br + .inb + .inb {
|
||||||
input.inb, input.ina{
|
input.inb, input.ina{
|
||||||
color: black;
|
color: black;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
border: 1px solid #999;
|
border: 1px solid black;
|
||||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 4px 10px 4px 0px;
|
padding: 4px 10px 4px 0px;
|
||||||
|
@ -256,7 +250,7 @@ input.inb, input.ina{
|
||||||
}
|
}
|
||||||
|
|
||||||
input.inb:hover, input.ina:hover {
|
input.inb:hover, input.ina:hover {
|
||||||
border: 1px solid #999;
|
border: 1px solid black;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background-color: #F0F0F0;
|
background-color: #F0F0F0;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +330,7 @@ input.ui-state-hover {
|
||||||
|
|
||||||
input.ina, input.inav,
|
input.ina, input.inav,
|
||||||
input.ina:hover, input.inav:hover {
|
input.ina:hover, input.inav:hover {
|
||||||
border: 1px solid #999;
|
border: 1px solid black;
|
||||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: black;
|
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 {
|
.ina a, a.ina, .inb a, a.inb,.inav a, a.inav {
|
||||||
color: black;
|
color: black;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
border: 1px solid #999;
|
border: 1px solid black;
|
||||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
|
@ -416,7 +410,7 @@ span#newsubname {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
.bff {
|
.bff {
|
||||||
border: 1px solid #999;
|
border: 1px solid black;
|
||||||
background-color: #F0F0F0;
|
background-color: #F0F0F0;
|
||||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
@ -1273,6 +1267,9 @@ input.cancel:active {
|
||||||
border-top: 1px solid #ddd;
|
border-top: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dom-edit-table td {
|
||||||
|
height: 2.4em;
|
||||||
|
}
|
||||||
.dom a, a.dom, input.dom, .dom-menu .menu-title {
|
.dom a, a.dom, input.dom, .dom-menu .menu-title {
|
||||||
background-image: url(../images/dom.png);
|
background-image: url(../images/dom.png);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
|
@ -170,7 +170,7 @@ class m_dom {
|
||||||
|
|
||||||
function domains_type_enable_values() {
|
function domains_type_enable_values() {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$msg->log("dom", "domains_type_target_values");
|
$msg->log("dom", "domains_type_enable_values");
|
||||||
$db->query("desc domaines_type;");
|
$db->query("desc domaines_type;");
|
||||||
$r = array();
|
$r = array();
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
|
@ -1256,11 +1256,26 @@ class m_dom {
|
||||||
$r["type_desc"] = $db->Record["type_desc"];
|
$r["type_desc"] = $db->Record["type_desc"];
|
||||||
$r["only_dns"] = $db->Record["only_dns"];
|
$r["only_dns"] = $db->Record["only_dns"];
|
||||||
$r["web_action"] = $db->Record["web_action"];
|
$r["web_action"] = $db->Record["web_action"];
|
||||||
|
$r["https"] = $db->Record["https"];
|
||||||
$db->free();
|
$db->free();
|
||||||
return $r;
|
return $r;
|
||||||
} // get_sub_domain_all
|
} // 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 integer $type
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
@ -1385,9 +1400,11 @@ class m_dom {
|
||||||
* @param integer $type Type de sous-domaine (local, ip, url ...)
|
* @param integer $type Type de sous-domaine (local, ip, url ...)
|
||||||
* @param string $dest Destination du sous-domaine, dépend de la valeur
|
* @param string $dest Destination du sous-domaine, dépend de la valeur
|
||||||
* de $type (url, ip, dossier...)
|
* 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.
|
* @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;
|
global $db, $msg, $cuid, $bro;
|
||||||
$msg->log("dom", "set_sub_domain", $dom . "/" . $sub . "/" . $type . "/" . $dest);
|
$msg->log("dom", "set_sub_domain", $dom . "/" . $sub . "/" . $type . "/" . $dest);
|
||||||
// Locked ?
|
// Locked ?
|
||||||
|
@ -1399,7 +1416,6 @@ class m_dom {
|
||||||
$sub = trim(trim($sub), ".");
|
$sub = trim(trim($sub), ".");
|
||||||
$dom = strtolower($dom);
|
$dom = strtolower($dom);
|
||||||
$sub = strtolower($sub);
|
$sub = strtolower($sub);
|
||||||
|
|
||||||
// if (!(($sub == '*') || ($sub=="") || (preg_match('/([a-z0-9][\.\-a-z0-9]*)?[a-z0-9]/', $sub)))) {
|
// if (!(($sub == '*') || ($sub=="") || (preg_match('/([a-z0-9][\.\-a-z0-9]*)?[a-z0-9]/', $sub)))) {
|
||||||
$fqdn = checkfqdn($sub);
|
$fqdn = checkfqdn($sub);
|
||||||
// Special cases : * (all subdomains at once) and '' empty subdomain are allowed.
|
// 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)) {
|
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
|
// error raised by check_type_value
|
||||||
return false;
|
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.
|
// On a épuré $dir des problémes eventuels ... On est en DESSOUS du dossier de l'utilisateur.
|
||||||
if (($t = checkfqdn($dom))) {
|
if (($t = checkfqdn($dom))) {
|
||||||
|
@ -1430,8 +1446,8 @@ class m_dom {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-create the one we want
|
// 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 ))) {
|
if (!$db->query("INSERT INTO sub_domaines (compte,domaine,sub,valeur,type,web_action,https) VALUES (?, ?, ?, ?, ?, 'UPDATE',?);", array( $cuid , $dom , $sub , $dest , $type, $https ))) {
|
||||||
echo "query failed: " . $db->Error;
|
$msg->raise("ERROR", "dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ CREATE TABLE IF NOT EXISTS sub_domaines (
|
||||||
enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED',
|
enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED',
|
||||||
`certificate_id` INT UNSIGNED NOT NULL DEFAULT '0',
|
`certificate_id` INT UNSIGNED NOT NULL DEFAULT '0',
|
||||||
`provider` VARCHAR(16) NOT NULL DEFAULT '',
|
`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)
|
PRIMARY KEY (id)
|
||||||
-- ,FOREIGN KEY (type) REFERENCES (domaines_type)
|
-- ,FOREIGN KEY (type) REFERENCES (domaines_type)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
Loading…
Reference in New Issue