Subversion Repositories ALCASAR

Rev

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

Rev 3030 Rev 3040
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: network.php 3030 2022-07-04 22:29:44Z rexy $
2
# $Id: network.php 3040 2022-07-17 22:31:53Z rexy $
3
 
3
 
4
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
4
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
5
 
5
 
6
/********************
6
/********************
7
*  READ CONF FILES  *
7
*  READ CONF FILES  *
Line 76... Line 76...
76
	$l_validated		= "Validé par :";
76
	$l_validated		= "Validé par :";
77
	$l_empty		= "Vide";
77
	$l_empty		= "Vide";
78
	$l_yes			= "Oui";
78
	$l_yes			= "Oui";
79
	$l_no			= "Non";
79
	$l_no			= "Non";
80
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
80
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
-
 
81
	$l_ssh_title		= "SSH";
-
 
82
	$l_ssh_port			= "Port";
81
	$l_cert_from	= "Date d'émission";
83
	$l_ssh_activate		= "Activer SSH";
82
	$l_cert_expiration	= "Date d'expiration :";
84
	$l_cert_expiration	= "Date d'expiration :";
83
	$l_cert_commonname	= "Nom commun :";
85
	$l_cert_commonname	= "Nom commun :";
84
	$l_cert_organization	= "Organisation :";
86
	$l_cert_organization	= "Organisation :";
85
	$l_upload_certificate	= "Importer un certificat officiel";
87
	$l_upload_certificate	= "Importer un certificat officiel";
86
	$l_le_renewal	= "Renouveler le certificat Let's Encrypt";
-
 
87
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
88
	$l_le_integration	= "Intégrer un certificat Let's Encrypt";
88
	$l_le_status		= "Status :";
89
	$l_le_status		= "Status :";
89
	$l_disabled		= "Inactif";
90
	$l_disabled		= "Inactif";
90
	$l_pending_validation	= "En attente de validation";
91
	$l_pending_validation	= "En attente de validation";
91
	$l_enabled		= "Actif";
92
	$l_enabled		= "Actif";
Line 141... Line 142...
141
	$l_validated		= "Validado por :";
142
	$l_validated		= "Validado por :";
142
	$l_empty		= "Vacío";
143
	$l_empty		= "Vacío";
143
	$l_yes			= "Si";
144
	$l_yes			= "Si";
144
	$l_no			= "No";
145
	$l_no			= "No";
145
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
146
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
-
 
147
	$l_ssh_title		= "SSH";
-
 
148
	$l_ssh_port			= "Puerto";
146
	$l_cert_from	= "Fecha de emisión";
149
	$l_ssh_activate		= "Activar SSH";
147
	$l_cert_expiration	= "Fecha de vencimiento:";
150
	$l_cert_expiration	= "Fecha de vencimiento:";
148
	$l_cert_commonname	= "Common name:";
151
	$l_cert_commonname	= "Common name:";
149
	$l_cert_organization	= "Organización:";
152
	$l_cert_organization	= "Organización:";
150
	$l_upload_certificate	= "Importar un certificado";
153
	$l_upload_certificate	= "Importar un certificado";
151
	$l_le_integration	= "Integración con Let's Encrypt";
154
	$l_le_integration	= "Integración con Let's Encrypt";
152
	$l_le_renewal	= "Renovación del certificado Let's Encrypt";
-
 
153
	$l_le_status		= "Estado:";
155
	$l_le_status		= "Estado:";
154
	$l_disabled		= "Desactivado";
156
	$l_disabled		= "Desactivado";
155
	$l_pending_validation	= "Validación pendiente";
157
	$l_pending_validation	= "Validación pendiente";
156
	$l_enabled		= "Activado";
158
	$l_enabled		= "Activado";
157
	$l_le_email		= "Email:";
159
	$l_le_email		= "Email:";
Line 205... Line 207...
205
	$l_validated		= "Validated by :";
207
	$l_validated		= "Validated by :";
206
	$l_empty		= "Empty";
208
	$l_empty		= "Empty";
207
	$l_yes			= "Yes";
209
	$l_yes			= "Yes";
208
	$l_no			= "No";
210
	$l_no			= "No";
209
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
211
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
-
 
212
	$l_ssh_title		= "SSH";
-
 
213
	$l_ssh_port			= "Port";
210
	$l_cert_from	= "Date of issue";
214
	$l_ssh_activate		= "Activate SSH";
211
	$l_cert_expiration	= "Expiration date:";
215
	$l_cert_expiration	= "Expiration date:";
212
	$l_cert_commonname	= "Common name:";
216
	$l_cert_commonname	= "Common name:";
213
	$l_cert_organization	= "Organization:";
217
	$l_cert_organization	= "Organization:";
214
	$l_upload_certificate	= "Import an officlal certificate";
218
	$l_upload_certificate	= "Import an officlal certificate";
215
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
219
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
216
	$l_le_renewal	= "Renewing the Let's Encrypt certificate";
-
 
217
	$l_le_status		= "Status:";
220
	$l_le_status		= "Status:";
218
	$l_disabled		= "Disabled";
221
	$l_disabled		= "Disabled";
219
	$l_pending_validation	= "Pending validation";
222
	$l_pending_validation	= "Pending validation";
220
	$l_enabled		= "Enabled";
223
	$l_enabled		= "Enabled";
221
	$l_le_email		= "Email:";
224
	$l_le_email		= "Email:";
Line 368... Line 371...
368
					if (file_exists($scpath))  unlink($scpath);
371
					if (file_exists($scpath))  unlink($scpath);
369
				}
372
				}
370
			}
373
			}
371
		}
374
		}
372
		break;
375
		break;
-
 
376
	case 'enable_wan_ssh': // Activate SSH on WAN
-
 
377
		if (isset($_POST['togglessh'])) {
-
 
378
			exec('sudo /usr/local/bin/alcasar-ssh.sh --on -p'.escapeshellarg($_POST["ssh_port"]));
-
 
379
		} else{
-
 
380
			exec('sudo /usr/local/bin/alcasar-ssh.sh --off');
-
 
381
		}
-
 
382
		header('Location: '.$_SERVER['PHP_SELF']);
-
 
383
		exit();
373
	case 'https_login':	// Set HTTPS login status
384
	case 'https_login':	// Set HTTPS login status
374
		if ($_POST['https_login'] === 'on') {
385
		if ($_POST['https_login'] === 'on') {
375
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
386
			exec('sudo /usr/local/bin/alcasar-https.sh --on');
376
		} else {
387
		} else {
377
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
388
			exec('sudo /usr/local/bin/alcasar-https.sh --off');
Line 1165... Line 1176...
1165
		</form>
1176
		</form>
1166
	</div>
1177
	</div>
1167
</div>
1178
</div>
1168
<br>
1179
<br>
1169
<div class="panel">
1180
<div class="panel">
-
 
1181
	<div class="panel-header"><?= $l_ssh_title ?></div>
-
 
1182
	<div class="panel-row">
-
 
1183
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
-
 
1184
		<input type="hidden" name="choix" value="enable_wan_ssh">
-
 
1185
		<input type="checkbox" name="togglessh" id="togglessh" <?= is_numeric($conf['SSH_WAN'])? "checked": "" ?> onchange="document.getElementById('sshtable').style.display = this.checked ? 'block' : 'none';"> <b>Activer SSH <!-- TODO : Mettre traduction --></b><br>
-
 
1186
		<div id="sshtable" style="display:<?= is_numeric($conf['SSH_WAN'])? "block": "none" ?>">
-
 
1187
			<label for="ssh_port"><?= $l_ssh_port ?></label> : <input style="width:120px" type="text" id="ssh_port" name="ssh_port" value="<?= is_numeric($conf['SSH_WAN']) ? $conf['SSH_WAN']:22 ?>" /><br>
-
 
1188
		</div>
-
 
1189
		<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
-
 
1190
		</form>
-
 
1191
	</div>
-
 
1192
</div>
-
 
1193
<br>
-
 
1194
<div class="panel">
1170
	<div class="panel-header"><?= $l_import_cert ?></div>
1195
	<div class="panel-header"><?= $l_import_cert ?></div>
1171
	<div class="panel-row">
1196
	<div class="panel-row">
1172
		<div class="panel-cell">
1197
		<div class="panel-cell">
1173
			<?php
1198
			<?php
1174
			$certificateInfos     = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
1199
			$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
1175
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
1200
			$cert_expiration_date = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
1176
			$cert_from_date       = date('d-m-Y H:i:s', $certificateInfos['validFrom_time_t']);
-
 
1177
			$domain               = $certificateInfos['subject']['CN'];
1201
			$domain               = $certificateInfos['subject']['CN'];
1178
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
1202
			$organization         = (isset($certificateInfos['subject']['O'])) ? $certificateInfos['subject']['O'] : '';
1179
			$CAdomain             = $certificateInfos['issuer']['CN'];
1203
			$CAdomain             = $certificateInfos['issuer']['CN'];
1180
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
1204
			$CAorganization       = (isset($certificateInfos['issuer']['O'])) ? $certificateInfos['issuer']['O'] : '';
1181
			?>
1205
			?>
1182
			<h3><?= $l_current_certificate ?></h3>
1206
			<h3><?= $l_current_certificate ?></h3>
1183
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
1207
			<b><?= $l_cert_commonname ?></b> <?= $domain ?><br>
1184
			<b><?= $l_cert_from ?></b> <?= $cert_from_date ?><br>
-
 
1185
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
1208
			<b><?= $l_cert_expiration ?></b> <?= $cert_expiration_date ?><br>
1186
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
1209
			<b><?= $l_cert_organization ?></b> <?= $organization ?><br>
1187
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
1210
			<b><?= $l_validated ?></b> <?= $CAdomain ?> (<?= $CAorganization ?>)<br>
1188
		</div>
1211
		</div>
1189
		<div class="panel-cell">
1212
		<div class="panel-cell">
Line 1222... Line 1245...
1222
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
1245
			} else if (($domain === $LE_conf['domainRequest']) && (empty($LE_conf['challenge']))) {
1223
				$step = 3;
1246
				$step = 3;
1224
			} else {
1247
			} else {
1225
				$step = 1;
1248
				$step = 1;
1226
			}
1249
			}
1227
			if ($step === 2) {
-
 
1228
				echo "<h3>$l_le_renewal</h3>";
-
 
1229
			} else { echo "<h3>$l_le_integration</h3>";}
-
 
1230
			?>
1250
			?>
-
 
1251
			<h3><?= $l_le_integration ?></h3>
1231
			<?php if ($step === 1): ?>
1252
			<?php if ($step === 1): ?>
1232
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1253
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1233
					<input type="hidden" name="choix" value="le_issueCert">
1254
					<input type="hidden" name="choix" value="le_issueCert">
1234
					<?= $l_le_status ?> <?= $l_disabled ?><br>
1255
					<?= $l_le_status ?> <?= $l_disabled ?><br>
1235
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
1256
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
Line 1239... Line 1260...
1239
			<?php elseif ($step === 2): ?>
1260
			<?php elseif ($step === 2): ?>
1240
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1261
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1241
					<input type="hidden" name="choix" value="le_renewCert">
1262
					<input type="hidden" name="choix" value="le_renewCert">
1242
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
1263
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
1243
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
1264
					<?= $l_le_domain_name ?> <?= $LE_conf['domainRequest'] ?><br>
-
 
1265
					<?= $l_le_ask_on ?> <?= date('d-m-Y H:i:s', $LE_conf['dateIssueRequest']) ?><br>
1244
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
1266
					<?= $l_le_dns_entry_txt ?> "<?= '_acme-challenge.'.$LE_conf['domainRequest'] ?>"<br>
1245
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
1267
					<?= $l_le_challenge ?> "<?= $LE_conf['challenge'] ?>"<br>
1246
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="cancel" value="<?= $l_cancel ?>"><br>
1268
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="recheck" value="<?= $l_recheck ?>"> <input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="cancel" value="<?= $l_cancel ?>"><br>
1247
				</form>
1269
				</form>
1248
			<?php elseif ($step === 3): ?>
1270
			<?php elseif ($step === 3): ?>