[enh] finishing the HTTPS preference code

This commit is contained in:
Benjamin Sonntag 2018-06-23 11:03:57 +02:00
parent 2ed4cbad21
commit 73376121e5
3 changed files with 17 additions and 16 deletions

View File

@ -41,6 +41,9 @@ if (!$r=$dom->get_domain_all($domain)) {
} }
$dom->unlock(); $dom->unlock();
if (isset($_GET["msg"])) {
$msg->raise("INFO","dom",$_GET["msg"]);
}
?> ?>
<h3><i class="fas fa-globe-africa"></i> <?php printf(_("Manage %s"),$domain); ?></h3> <h3><i class="fas fa-globe-africa"></i> <?php printf(_("Manage %s"),$domain); ?></h3>
<?php <?php

View File

@ -24,7 +24,6 @@
*/ */
require_once("../class/config.php"); require_once("../class/config.php");
require_once("head.php");
$fields = array ( $fields = array (
"domain" => array ("request", "string", (empty($domain)?"":$domain) ), "domain" => array ("request", "string", (empty($domain)?"":$domain) ),
@ -34,6 +33,7 @@ getFields($fields);
$dom->lock(); $dom->lock();
if (!$r=$dom->get_domain_all($domain)) { if (!$r=$dom->get_domain_all($domain)) {
$dom->unlock(); $dom->unlock();
require_once("head.php");
echo $msg->msg_html_all(); echo $msg->msg_html_all();
include('foot.php'); include('foot.php');
die(); die();
@ -54,13 +54,15 @@ if (count($_POST)) {
} }
$dom->unlock(); $dom->unlock();
if ($haserror) { if ($haserror) {
require_once("head.php");
echo $msg->msg_html_all(); echo $msg->msg_html_all();
} else { } else {
header("Location: dom_edit.php?domain=".eue($domain,false)); header("Location: dom_edit.php?domain=".eue($domain,false)."&msg=".eue(_("Your HTTPS preferences have been set"),false));
exit();
} }
} // post ? } // post ?
require_once("head.php");
?> ?>
<h3><i class="fas fa-globe-africa"></i> <?php printf(_("Manage %s HTTPS preferences"),ehe($domain,false)); ?></h3> <h3><i class="fas fa-globe-africa"></i> <?php printf(_("Manage %s HTTPS preferences"),ehe($domain,false)); ?></h3>
@ -72,7 +74,7 @@ if (count($_POST)) {
<?php __("please note that you only see a provider if you have a valid certificate for this domain"); ?> <?php __("please note that you only see a provider if you have a valid certificate for this domain"); ?>
</p> </p>
<form action="dom_ssl.inc.php" method="post" name="main" id="main"> <form action="dom_sslpref.php" method="post" name="main" id="main">
<input type="hidden" name="domain" value="<?php ehe($domain); ?>" /> <input type="hidden" name="domain" value="<?php ehe($domain); ?>" />
<?php csrf_get(); ?> <?php csrf_get(); ?>
<table class="tlist" id="dom_edit_ssl"> <table class="tlist" id="dom_edit_ssl">
@ -94,9 +96,11 @@ for($i=0;$i<$r["nsub"];$i++) {
echo "<option value=\"\">"._("-- no HTTPS certificate provider preference --")."</option>"; echo "<option value=\"\">"._("-- no HTTPS certificate provider preference --")."</option>";
$providers=array(); $providers=array();
foreach($certs as $cert) { foreach($certs as $cert) {
if ($cert["provider"] && !isset($providers[$cert["provider"]])) { if ($cert["provider"] && $cert["provider"]!="snakeoil" && !isset($providers[$cert["provider"]])) {
$providers[$cert["provider"]]=1; $providers[$cert["provider"]]=1;
echo "<option value=\"".$cert["provider"]."\">"._("Provider:")." ".$cert["provider"]."</option>"; echo "<option value=\"".$cert["provider"]."\"";
selected($r["sub"][$i]["provider"]==$cert["provider"]);
echo ">"._("Provider:")." ".$cert["provider"]."</option>";
} }
} }
echo "</select>"; echo "</select>";

View File

@ -1203,16 +1203,10 @@ class m_dom {
$r["sub"] = array(); $r["sub"] = array();
$data = $db->fetchAll(); $data = $db->fetchAll();
foreach($data as $i=>$record) { foreach($data as $i=>$record) {
$r["sub"][$i] = array(); $r["sub"][$i] = $record;
$r["sub"][$i]["id"] = $record["id"]; // 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]["name"] = $record["sub"];
$r["sub"][$i]["dest"] = $record["valeur"]; $r["sub"][$i]["dest"] = $record["valeur"];
$r["sub"][$i]["type"] = $record["type"];
$r["sub"][$i]["enable"] = $record["enable"];
$r["sub"][$i]["type_desc"] = $record["type_desc"];
$r["sub"][$i]["only_dns"] = $record["only_dns"];
$r["sub"][$i]["web_action"] = $record["web_action"];
$r["sub"][$i]["advanced"] = $record["advanced"];
$r["sub"][$i]["fqdn"] = ((!empty($r["sub"][$i]["name"])) ? $r["sub"][$i]["name"] . "." : "") . $r["name"]; $r["sub"][$i]["fqdn"] = ((!empty($r["sub"][$i]["name"])) ? $r["sub"][$i]["name"] . "." : "") . $r["name"];
} }
$db->free(); $db->free();
@ -1395,9 +1389,9 @@ class m_dom {
* @param string the provider (if not empty, will be checked against an existing certificate for this subdomain) * @param string the provider (if not empty, will be checked against an existing certificate for this subdomain)
* @return boolean true if the preference has been set * @return boolean true if the preference has been set
*/ */
function set_sub_domain_ssl_provider($sub_domain_id,$provider) { function set_subdomain_ssl_provider($sub_domain_id,$provider) {
global $db, $msg, $cuid, $ssl; global $db, $msg, $cuid, $ssl;
$msg->log("dom", "set_sub_domain_ssl_provider", $sub_domain_id." / ".$provider) $msg->log("dom", "set_sub_domain_ssl_provider", $sub_domain_id." / ".$provider);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!")); $msg->raise("ERROR", "dom", _("--- Program error --- No lock on the domains!"));