Subversion Repositories ALCASAR

Rev

Rev 2316 | Rev 2325 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2316 Rev 2324
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: network.php 2316 2017-06-30 11:40:00Z tom.houdayer $
2
# $Id: network.php 2324 2017-07-10 10:18:59Z tom.houdayer $
3
 
3
 
4
// written by steweb57, Rexy & Tom HOUDAYER
4
// written by steweb57, Rexy & Tom HOUDAYER
5
 
5
 
6
/********************
6
/********************
7
*  READ CONF FILES  *
7
*  READ CONF FILES  *
Line 236... Line 236...
236
					if (file_exists($scpath))  unlink($scpath); 
236
					if (file_exists($scpath))  unlink($scpath); 
237
				}
237
				}
238
			}
238
			}
239
		}
239
		}
240
		break;
240
		break;
-
 
241
 
-
 
242
	case 'https_login':	// Set HTTPS login status
-
 
243
		if ($_POST['https_login'] === 'on') {
-
 
244
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
-
 
245
		} else {
-
 
246
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
-
 
247
		}
-
 
248
		header('Location: '.$_SERVER['PHP_SELF']);
-
 
249
		exit();
241
}
250
}
242
 
251
 
243
// Network changes
252
// Network changes
244
if ($choix === 'network_change') {
253
if ($choix === 'network_change') {
245
	$network_modification = false;
254
	$network_modification = false;
Line 615... Line 624...
615
</table>
624
</table>
616
<table width="100%" cellspacing="0" cellpadding="5" border="1">
625
<table width="100%" cellspacing="0" cellpadding="5" border="1">
617
	<tr><td colspan="2" valign="middle" align="left">
626
	<tr><td colspan="2" valign="middle" align="left">
618
	<center><h3><?= $l_dhcp_state ?> : <?= ${'l_DHCP_'.$conf['DHCP']} ?></h3></center>
627
	<center><h3><?= $l_dhcp_state ?> : <?= ${'l_DHCP_'.$conf['DHCP']} ?></h3></center>
619
	<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
628
	<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
620
		<select name="choix">";
629
		<select name="choix">
621
			<option value="DHCP_Off"<?= ((!strcmp($conf['DHCP'], 'off')) ? ' selected' : '') ?>><?= $l_DHCP_off ?></option>
630
			<option value="DHCP_Off"<?= ((!strcmp($conf['DHCP'], 'off')) ? ' selected' : '') ?>><?= $l_DHCP_off ?></option>
622
			<option value="DHCP_On"<?= ((!strcmp($conf['DHCP'], 'on')) ? ' selected' : '') ?>><?= $l_DHCP_on ?></option>
631
			<option value="DHCP_On"<?= ((!strcmp($conf['DHCP'], 'on')) ? ' selected' : '') ?>><?= $l_DHCP_on ?></option>
623
		</select>
632
		</select>
624
		<input type="submit" value="<?= $l_apply ?>">
633
		<input type="submit" value="<?= $l_apply ?>">
625
		<br><?= $l_DHCP_off_explain ?>
634
		<br><?= $l_DHCP_off_explain ?>
Line 698... Line 707...
698
	<tr><th><?= $l_import_cert ?></th></tr>
707
	<tr><th><?= $l_import_cert ?></th></tr>
699
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
708
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
700
</table>
709
</table>
701
<table width="100%" cellspacing="0" cellpadding="5" border="1">
710
<table width="100%" cellspacing="0" cellpadding="5" border="1">
702
	<tr>
711
	<tr>
703
		<td width="50%">
712
		<td width="50%" valign="top">
704
			<h3>Importer un certificat existant</h3>
-
 
705
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
713
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
706
				<?= $l_private_key;?> <input type="file" name="key"><br>
714
				<input type="hidden" name="choix" value="https_login">
707
				<?= $l_certificate;?> <input type="file" name="crt"><br>
715
				<span>Autoriser les utilisateurs à se connecter de manière non sécurisée :</span><br>
708
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
716
				<select name="https_login">
-
 
717
					<option value="on"<?=  (($conf['HTTPS_LOGIN'] === 'on')  ? ' selected' : '') ?>>Non</option>
709
				<input type="hidden" name="choix" value="import_cert">
718
					<option value="off"<?= (($conf['HTTPS_LOGIN'] === 'off') ? ' selected' : '') ?>>Oui</option>
-
 
719
				</select>
710
				<input type="submit" value="<?= $l_import ?>">
720
				<input type="submit" value="<?= $l_apply ?>"><br>
-
 
721
				<span>/!\ Les identifiants de connexion seront envoyés en clair.</span>
711
			</form>
722
			</form>
-
 
723
			<br>
-
 
724
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
-
 
725
				<input type="hidden" name="choix" value="default_cert">
-
 
726
				<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' : '' ?>>
-
 
727
			</form>
712
 
728
		</td>
-
 
729
		<td width="50%" valign="top">
713
			<?php
730
			<?php
714
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
731
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
715
 
732
 
716
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
733
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
717
			$domain               = $certificateInfos['subject']['CN'];
734
			$domain               = $certificateInfos['subject']['CN'];
718
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
735
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
719
			$CAdomain             = $certificateInfos['issuer']['CN'];
736
			$CAdomain             = $certificateInfos['issuer']['CN'];
720
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
737
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
721
			?>
738
			?>
722
 
-
 
723
			<br>
-
 
724
			<hr>
-
 
725
 
-
 
726
			<h3><?= $l_current_certificate ?></h3>
739
			<h3><?= $l_current_certificate ?></h3>
727
			Expiration Date : <?= $cert_expiration_date ?><br>
740
			Expiration Date : <?= $cert_expiration_date ?><br>
728
			Common name : <?= $domain ?><br>
741
			Common name : <?= $domain ?><br>
729
			Organization : <?= $organization ?><br/>
742
			Organization : <?= $organization ?><br/>
730
			<h4><?=  $l_validated ?></h4>
743
			<h4><?=  $l_validated ?></h4>
731
			Common name : <?= $CAdomain ?><br>
744
			Common name : <?= $CAdomain ?><br>
732
			Organization : <?= $CAorganization ?><br>
745
			Organization : <?= $CAorganization ?><br>
-
 
746
		</td>
733
 
747
	</tr>
734
			<br>
748
	<tr>
-
 
749
		<td width="50%" valign="top">
-
 
750
			<h3>Importer un certificat</h3>
735
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
751
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
-
 
752
				<?= $l_private_key;?> <input type="file" name="key"><br>
-
 
753
				<?= $l_certificate;?> <input type="file" name="crt"><br>
-
 
754
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
736
				<input type="hidden" name="choix" value="default_cert">
755
				<input type="hidden" name="choix" value="import_cert">
737
				<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' : '' ?>>
756
				<input type="submit" value="<?= $l_import ?>">
738
			</form>
757
			</form>
739
		</td>
758
		</td>
740
		<td width="50%" valign="top">
759
		<td width="50%" valign="top">
741
			<?php
760
			<?php
742
			// Get step
761
			// Get step
Line 749... Line 768...
749
			} else {
768
			} else {
750
				$step = 1;
769
				$step = 1;
751
			}
770
			}
752
			?>
771
			?>
753
			<h3>Intégration Let's Encrypt</h3>
772
			<h3>Intégration Let's Encrypt</h3>
754
			<?php if ($step === 1) : ?>
773
			<?php if ($step === 1): ?>
755
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
774
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
756
					<input type="hidden" name="choix" value="le_issueCert">
775
					<input type="hidden" name="choix" value="le_issueCert">
757
					Status : Inactif<br>
776
					Status : Inactif<br>
758
					Email : <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
777
					Email : <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
759
					Nom de domaine : <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
778
					Nom de domaine : <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>