Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2812 → Rev 2813

/web/acc/admin/network.php
66,9 → 66,9
$l_local_dns = "Résolution local de nom (DNS)";
$l_import_cert = "Import de certificat";
$l_private_key = "Clé privée (.key) :";
$l_certificate = "Certificat (.crt) :";
$l_server_chain = "Chaîne de certification (si nécéssaire : .crt) :";
$l_default_cert = "Revenir au certificat d'origine";
$l_certificate = "Certificat (.crt ou .cer) :";
$l_server_chain = "Chaîne de certification (.crt, .cer ou .pem) :";
$l_default_cert = "Revenir au certificat d'origine :";
$l_import = "Importer";
$l_current_certificate = "Certificat actuel";
$l_validated = "Validé par :";
79,8 → 79,8
$l_cert_expiration = "Date d'expiration :";
$l_cert_commonname = "Nom commun :";
$l_cert_organization = "Organisation :";
$l_upload_certificate = "Importer un certificat";
$l_le_integration = "Intégration Let's Encrypt";
$l_upload_certificate = "Importer un certificat officiel";
$l_le_integration = "Intégrer un certificat Let's Encrypt";
$l_le_status = "Status :";
$l_disabled = "Inactif";
$l_pending_validation = "En attente de validation";
97,6 → 97,7
$l_le_next_renewal = "Prochain renouvellement :";
$l_renew = "Renouveller";
$l_renew_force = "Renouveller (forcer)";
$l_previous_LE_cert = "Revenir au certificat Let's Encrypt :";
} else { // English
$l_network_title = "Network configuration";
$l_internet_legend = "INTERNET";
121,9 → 122,9
$l_local_dns = "Local name resolution (DNS";
$l_import_cert = "Certificate import";
$l_private_key = "Private key (.key) :";
$l_certificate = "Certificate (.crt) :";
$l_server_chain = "Server-chain (if necessary : .crt) :";
$l_default_cert = "Back to default certificate";
$l_certificate = "Certificate (.crt or .cer) :";
$l_server_chain = "Server-chain (.crt, .cer or .pem) :";
$l_default_cert = "Back to default certificate :";
$l_import = "Import";
$l_current_certificate = "Current certificate";
$l_validated = "Validated by :";
134,8 → 135,8
$l_cert_expiration = "Expiration date:";
$l_cert_commonname = "Common name:";
$l_cert_organization = "Organization:";
$l_upload_certificate = "Importer un certificat";
$l_le_integration = "Let's Encrypt integration";
$l_upload_certificate = "Import an officlal certificate";
$l_le_integration = "Integrate a Let's Encrypt certificate";
$l_le_status = "Status:";
$l_disabled = "Disabled";
$l_pending_validation = "Pending validation";
152,6 → 153,7
$l_le_next_renewal = "Next renewal:";
$l_renew = "Renew";
$l_renew_force = "Renew (force)";
$l_previous_LE_cert = "Back to the Let's Encrypt certificate :";
}
 
$reg_ip = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
255,10 → 257,12
header('Location: '.$_SERVER['PHP_SELF']);
exit();
 
case 'default_cert': // Restore default certificate
case 'set_default_cert':
exec('sudo alcasar-importcert.sh -d');
break;
 
case 'set_last_LE_cert':
exec('sudo alcasar-letsencrypt.sh --install-cert');
break;
case 'import_cert': // Import certificate
$maxsize = 100000;
if (isset($_FILES['key']) && isset($_FILES['crt']) && ($_FILES['key']['error'] == 0) && ($_FILES['crt']['error'] == 0)) {
266,8 → 270,8
if (pathinfo($_FILES['key']['name'])['extension'] == 'key' && ((pathinfo($_FILES['crt']['name'])['extension'] == 'crt') || (pathinfo($_FILES['crt']['name'])['extension'] == 'cer'))) {
$dest = '/tmp/';
$scpath = '';
if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer'))) {
$scpath = $dest.'server-chain.crt';
if (isset($_FILES['sc']) && ((pathinfo($_FILES['sc']['name'])['extension'] == 'crt') || (pathinfo($_FILES['sc']['name'])['extension'] == 'cer') || (pathinfo($_FILES['sc']['name']['extension'] == 'pem')))){
$scpath = $dest.'server-chain.pem';
move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
}
$keypath = $dest.'alcasar.key';
340,12 → 344,9
// Let's Encrypt actions
if ($choix === 'le_issueCert') {
// TODO: check ndd & mail format
 
$email = $_POST['email'];
$domainName = $_POST['domainname'];
 
exec('sudo /usr/local/bin/alcasar-letsencrypt.sh --issue --email '.escapeshellarg($email).' --domain '.escapeshellarg($domainName), $output, $exitCode);
 
$cmdResponse = implode("<br>\n", $output);
}
if ($choix === 'le_renewCert') {
361,7 → 362,6
}
}
 
 
// Read Let's Encrypt configuration file
$file_conf_LE = fopen(LETS_ENCRYPT_FILE, 'r');
if (!$file_conf_LE) {
376,7 → 376,6
}
fclose($file_conf_LE);
 
 
// Fonction de test de connectivité internet
function internetTest() {
$host = 'www.google.fr'; # Google Test
400,7 → 399,6
$internet_publicIP = '-.-.-.-';
}
 
 
// Network interfaces
$interfacesIgnored = ['lo', 'tun[0-9]*', $conf['EXTIF'], $conf['INTIF']];
exec("ip -o link show | awk -F': ' '{print $2}' | sed '/^" . implode('\\|', $interfacesIgnored) . "$/d'", $interfacesAvailable);
421,7 → 419,7
];
 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
443,77 → 441,77
}
</script>
<style>
.network-configurator {
width: 100%;
}
.network-configurator > * {
display: inline-block;
vertical-align: top;
text-align: center;
}
.network-configurator > .internet, .network-configurator > .alcasar {
width: 20%;
}
.network-configurator > .externals, .network-configurator > .internals {
width: 30%;
}
.network-configurator .actions {
position: absolute;
background-color: #ddd;
padding: 0 2px;
}
.network-configurator .actions a {
text-decoration: none;
}
.network-configurator .actions a:hover {
font-weight: bold;
}
.network-configurator > .alcasar .actions-externals {
bottom: 0;
left: 0;
border-radius: 0 5px;
}
.network-configurator > .alcasar .actions-internals {
bottom: 0;
right: 0;
border-radius: 5px 0;
}
.network-configurator .actions-network {
top: 0;
right: 0;
border-radius: 0 5px;
}
.network-configurator .network-box {
display: inline-block;
min-height: 100px;
margin: 5px;
padding: 3px;
text-align: left;
background-color: #f7f3ef;
position: relative;
border-radius: 5px;
border: 2px solid grey;
}
.network-configurator .network-connector {
display: inline-block;
position: absolute;
top: 50%;
margin-top: -5px;
margin-left: -5px;
width: 10px;
height: 10px;
border-radius: 5px;
background-color: black;
}
.network-configurator .network-connector[data-connector-direction="left"] {
border-radius: 5px 0px 0px 5px;
}
.network-configurator .network-connector[data-connector-direction="right"] {
border-radius: 0px 5px 5px 0px;
}
.network-configurator div[data-network-type] {
position: relative;
}
.network-configurator {
width: 100%;
}
.network-configurator > * {
display: inline-block;
vertical-align: top;
text-align: center;
}
.network-configurator > .internet, .network-configurator > .alcasar {
width: 20%;
}
.network-configurator > .externals, .network-configurator > .internals {
width: 30%;
}
.network-configurator .actions {
position: absolute;
background-color: #ddd;
padding: 0 2px;
}
.network-configurator .actions a {
text-decoration: none;
}
.network-configurator .actions a:hover {
font-weight: bold;
}
.network-configurator > .alcasar .actions-externals {
bottom: 0;
left: 0;
border-radius: 0 5px;
}
.network-configurator > .alcasar .actions-internals {
bottom: 0;
right: 0;
border-radius: 5px 0;
}
.network-configurator .actions-network {
top: 0;
right: 0;
border-radius: 0 5px;
}
.network-configurator .network-box {
display: inline-block;
min-height: 100px;
margin: 5px;
padding: 3px;
text-align: left;
background-color: #f7f3ef;
position: relative;
border-radius: 5px;
border: 2px solid grey;
}
.network-configurator .network-connector {
display: inline-block;
position: absolute;
top: 50%;
margin-top: -5px;
margin-left: -5px;
width: 10px;
height: 10px;
border-radius: 5px;
background-color: black;
}
.network-configurator .network-connector[data-connector-direction="left"] {
border-radius: 5px 0px 0px 5px;
}
.network-configurator .network-connector[data-connector-direction="right"] {
border-radius: 0px 5px 5px 0px;
}
.network-configurator div[data-network-type] {
position: relative;
}
</style>
<script>
$(document).ready(function () {
602,76 → 600,74
</script>
</head>
<body>
<div class="panel">
<div class="panel-header"><?= $l_network_title ?></div>
<div class="panel-body">
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
<div class="network-configurator">
<div class="internet">
<div data-network-type="internet">
<div class="panel">
<div class="panel-header"><?= $l_network_title ?></div>
<div class="panel-row">
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
<div class="network-configurator">
<div class="internet">
<div data-network-type="internet">
<div class="network-box">
<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
</div>
<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
</div>
</div><div class="externals">
<?php foreach ($externalNetworks as $index => $network): ?>
<div data-network-type="external">
<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
<div class="network-box">
<?= $l_internet_legend ?> <img src="/images/state_<?= (($internet_connected) ? 'ok' : 'error') ?>.gif"><br>
<?= $l_ip_public ?> : <?= $internet_publicIP ?><br>
<label for="dns1"><?= $l_ip_dns1 ?></label> : <input style="width:120px" type="text" id="dns1" name="dns1" value="<?= $conf['DNS1'] ?>" /><br>
<label for="dns2"><?= $l_ip_dns2 ?></label> : <input style="width:120px" type="text" id="dns2" name="dns2" value="<?= $conf['DNS2'] ?>" />
<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
<label for="ext_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="ext_interface[<?= $index ?>]" id="ext_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
<label for="ext_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
<label for="ext_gateway_<?= $index ?>"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
</div>
<div class="network-connector" data-connector-network="internet" data-connector-direction="right"></div>
<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
</div>
</div><div class="externals">
<?php foreach ($externalNetworks as $index => $network): ?>
<div data-network-type="external">
<div class="network-connector" data-connector-network="internet" data-connector-direction="left"></div>
<div class="network-box">
<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
<label for="ext_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="ext_interface[<?= $index ?>]" id="ext_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
<label for="ext_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_public" id="ext_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
<label for="ext_gateway_<?= $index ?>"><?= $l_ip_router ?></label> <input style="width:120px" type="text" name="ip_gw" id="ext_gateway_<?= $index ?>" value="<?= $network->gateway ?>" />
</div>
<div class="network-connector" data-connector-network="external" data-connector-direction="right"></div>
</div>
<? endforeach; ?>
</div><div class="alcasar">
<div data-network-type="alcasar">
<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
<? endforeach; ?>
</div><div class="alcasar">
<div data-network-type="alcasar">
<div class="network-connector" data-connector-network="external" data-connector-direction="left"></div>
<div class="network-box">
<!-- <div class="actions actions-externals">
<div><a href="#" class="add-external-network" title="Ajouter un réseau externe">+</a></div>
</div> -->
<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
<!-- <div class="actions actions-internals">
<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
<div><a href="#" class="add-internal-wifi-network">++</a></div>
</div> -->
</div>
<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
</div>
</div><div class="internals">
<?php foreach ($internalNetworks as $network): ?>
<div data-network-type="internal">
<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
<div class="network-box">
<!-- <div class="actions actions-externals">
<div><a href="#" class="add-external-network" title="Ajouter un réseau externe">+</a></div>
</div> -->
<div class="alcasar-logo"><img src="/images/logo-alcasar.png" style="width: 100px;height: 100px;"></div>
<!-- <div class="actions actions-internals">
<div><a href="#" class="add-internal-network" title="Ajouter un réseau interne">+</a></div>
<div><a href="#" class="add-internal-wifi-network">++</a></div>
</div> -->
<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
<label for="int_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="int_interface[<?= $index ?>]" id="int_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
<label for="int_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
</div>
<div class="network-connector" data-connector-network="internal" data-connector-direction="right"></div>
</div>
</div><div class="internals">
<?php foreach ($internalNetworks as $network): ?>
<div data-network-type="internal">
<div class="network-connector" data-connector-network="internal" data-connector-direction="left"></div>
<div class="network-box">
<!-- <div class="actions actions-network"><a href="#" class="remove-network" title="Supprimer ce réseau">-</a></div> -->
<label for="int_interface_<?= $index ?>"><?= 'Interface' ?></label> <select name="int_interface[<?= $index ?>]" id="int_interface_<?= $index ?>" disabled><option value="<?= $network->interface ?>"><?= $network->interface ?></option></select><br>
<label for="int_ip_<?= $index ?>"><?= $l_ip_address ?></label> <input style="width:150px" type="text" name="ip_private" id="int_ip_<?= $index ?>" value="<?= $network->ip ?>" /><br>
</div>
</div>
<? endforeach; ?>
</div>
<? endforeach; ?>
</div>
<hr>
<div style="text-align: center; margin: 5px">
<input type="hidden" name="choix" value="network_change">
<input type="submit" value="<?= $l_apply ?>">
</div>
</form>
</div>
</div>
<hr>
<div style="text-align: center; margin: 5px">
<input type="hidden" name="choix" value="network_change">
<input type="submit" value="<?= $l_apply ?>">
</div>
</form>
</div>
<br>
 
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr><th><?= $l_static_dhcp_title?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>
</div>
<br>
<div class="panel">
<div class="panel-header"><?= $l_static_dhcp_title ?></div>
</div>
<table width="100%" cellspacing="0" cellpadding="5" border="1">
<tr><td width="50%" align="center" valign="middle">
<form action="network.php" method="POST">
730,11 → 726,9
</td></tr>
</table>
<br>
 
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr><th><?= $l_local_dns ?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>
<div class="panel">
<div class="panel-header"><?= $l_local_dns ?></div>
</div>
<table width="100%" cellspacing="0" cellpadding="5" border="1">
<tr>
<td width="50%" align="center">
794,13 → 788,9
</tr>
</table>
<br>
 
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr><th><?= $l_ssl_title ?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>
<table width="100%" cellspacing="0" cellpadding="5" border="1">
<tr><td valign="middle" align="left">
<div class="panel">
<div class="panel-header"><?= $l_ssl_title ?></div>
<div class="panel-row">
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
<input type="hidden" name="choix" value="https_login">
<select name="https_login">
809,21 → 799,15
</select>
<input type="submit" value="<?= $l_apply ?>"><br>
</form>
<br>
</td></tr>
</table>
</div>
</div>
<br>
 
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr><th><?= $l_import_cert ?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</table>
<table width="100%" cellspacing="0" cellpadding="5" border="1">
<tr>
<td width="50%" valign="top">
<div class="panel">
<div class="panel-header"><?= $l_import_cert ?></div>
<div class="panel-row">
<div class="panel-cell">
<?php
$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
 
$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
$domain = $certificateInfos['subject']['CN'];
$organization = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
831,22 → 815,28
$CAorganization = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
?>
<h3><?= $l_current_certificate ?></h3>
<?= $l_cert_expiration ?> <?= $cert_expiration_date ?><br>
<?= $l_cert_commonname ?> <?= $domain ?><br>
<?= $l_cert_organization ?> <?= $organization ?><br/>
<h4><?= $l_validated ?></h4>
<?= $l_cert_commonname ?> <?= $CAdomain ?><br>
<?= $l_cert_organization ?> <?= $CAorganization ?><br>
</td>
<td width="50%" valign="center">
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
<input type="hidden" name="choix" value="default_cert">
<input type="submit" value="<?= $l_default_cert ?>" <?= (!file_exists('/etc/pki/tls/certs/alcasar.crt.old') || !file_exists('/etc/pki/tls/private/alcasar.key.old')) ? ' disabled' : '' ?>>
</form>
</td>
</tr>
<tr>
<td width="50%" valign="top">
<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
</div>
<div class="panel-cell">
<?
if (file_exists('/etc/pki/tls/certs/alcasar.crt.old') && file_exists('/etc/pki/tls/private/alcasar.key.old')){ // An old default certificate exist ?
echo "<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_default_cert\">\n";
echo "\t\t\t\t<input type=\"submit\" value=\"$l_default_cert\"> (alcasar.localdomain)<br>\n";
echo "\t\t\t</form>\n";}
if (!empty($LE_conf['domainRequest']) && ($domain != $LE_conf['domainRequest'])) { // A Let's encrypt certificate exist & it's not the active one ?
echo "\t\t\t<form method=\"post\" action=\"".htmlspecialchars($_SERVER['PHP_SELF'])."\">\n";
echo "\t\t\t\t<input type=\"hidden\" name=\"choix\" value=\"set_last_LE_cert\">\n";
echo "\t\t\t\t<input type=\"submit\" value=\"".$l_previous_LE_cert."\"> (".$LE_conf['domainRequest'].")\n";
echo "\t\t\t</form>\n";}
?>
</div>
</div>
<div class="panel-row">
<div class="panel-cell">
<h3><?= $l_upload_certificate ?></h3>
<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
<?= $l_private_key;?> <input type="file" name="key"><br>
855,8 → 845,8
<input type="hidden" name="choix" value="import_cert">
<input type="submit" value="<?= $l_import ?>">
</form>
</td>
<td width="50%" valign="top">
</div>
<div class="panel-cell">
<?php
// Get step
if (empty($LE_conf['domainRequest'])) {
905,8 → 895,8
<?php if (isset($cmdResponse)): ?>
<p><?= $cmdResponse ?></p>
<?php endif; ?>
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>