Subversion Repositories ALCASAR

Rev

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

Rev 3300 Rev 3301
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: network.php 3300 2025-09-23 16:11:12Z rexy $
2
# $Id: network.php 3301 2025-10-04 08:12:56Z rexy $
3
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
3
// written by steweb57, Rexy, Tom HOUDAYER & Pierre RIVAULT
4
 
4
 
5
/********************
5
/********************
6
*  READ CONF FILES  *
6
*  READ CONF FILES  *
7
*********************/
7
*********************/
Line 76... Line 76...
76
	$l_empty		= "Vide";
76
	$l_empty		= "Vide";
77
	$l_yes			= "Oui";
77
	$l_yes			= "Oui";
78
	$l_no			= "Non";
78
	$l_no			= "Non";
79
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
79
	$l_ssl_title		= "Chiffrer les flux d'authentification entre les utilisateurs et ALCASAR";
80
	$l_ssh_title		= "SSH";
80
	$l_ssh_title		= "SSH";
81
	$l_ssh_port			= "Port";
81
	$l_ssh_port		= "Port";
82
	$l_ssh_from			= "IP autorisée";
82
	$l_ssh_from		= "IP autorisée";
83
	$l_ssh_wan_activate	= "Activer SSH côté WAN";
83
	$l_ssh_wan_activate	= "Activer SSH côté WAN";
84
	$l_ssh_lan_activate	= "Activer SSH côté LAN";
84
	$l_ssh_lan_activate	= "Activer SSH côté LAN";
85
	$l_all_ip			= "Pour autoriser toutes les @IP sources: 0.0.0.0";
85
	$l_all_ip		= "Pour autoriser toutes les @IP sources: 0.0.0.0";
86
	$l_interlan_title	= "Autoriser l'accès au réseau situé entre ALCASAR et le routeur d'accès à Internet";
86
	$l_interlan_title	= "Autoriser l'accès au réseau situé entre ALCASAR et le routeur d'accès à Internet";
87
	$l_cert_expiration	= "Date d'expiration :";
87
	$l_cert_expiration	= "Date d'expiration :";
88
	$l_cert_commonname	= "Nom commun :";
88
	$l_cert_commonname	= "Nom commun :";
89
	$l_cert_organization	= "Organisation :";
89
	$l_cert_organization	= "Organisation :";
90
	$l_upload_certificate	= "Importer un certificat officiel";
90
	$l_upload_certificate	= "Importer un certificat officiel";
Line 103... Line 103...
103
	$l_cancel		= "Annuler";
103
	$l_cancel		= "Annuler";
104
	$l_le_api		= "API :";
104
	$l_le_api		= "API :";
105
	$l_le_auto_renewal_warning	= "Alerte de renouvellement à partir du :";
105
	$l_le_auto_renewal_warning	= "Alerte de renouvellement à partir du :";
106
	$l_renewal_request	= "Demande de renouvellement";
106
	$l_renewal_request	= "Demande de renouvellement";
107
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
107
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
108
	$l_gw_weight    = "Poids";
108
	$l_gw_weight		= "Poids";
109
	$l_error        = "Erreur";
109
	$l_error		= "Erreur";
110
	$l_error_bad_mac = "Adresse MAC invalide";
110
	$l_error_bad_mac	= "Adresse MAC invalide";
111
	$l_error_bad_ip = "Adresse IP invalide";
111
	$l_error_bad_ip		= "Adresse IP invalide";
112
	$l_error_bad_ip_CIDR = "Adresse IP au format CIDR invalide";
112
	$l_error_bad_ip_CIDR	= "Adresse IP au format CIDR invalide";
113
	$l_error_bad_ip_port = "Adresse IP + port invalide";
113
	$l_error_bad_ip_port	= "Adresse IP + port invalide";
114
	$l_error_weight = "Poids invalide";
114
	$l_error_weight		= "Poids invalide";
-
 
115
	$l_error_bad_domain	= "Nom de domaine invalide";
115
    $l_change_successful = "Changement effectué avec succès";
116
	$l_change_successful	= "Changement effectué avec succès";
116
 
-
 
117
} else if ($Language === 'es') {
117
} else if ($Language === 'es') {
118
	$l_network_title	= "Configuración de Red";
118
	$l_network_title	= "Configuración de Red";
119
	$l_internet_legend	= "INTERNET";
119
	$l_internet_legend	= "INTERNET";
120
	$l_ip_mask		= "Máscara";
120
	$l_ip_mask		= "Máscara";
121
	$l_ip_router		= "Router";
121
	$l_ip_router		= "Router";
Line 146... Line 146...
146
	$l_empty		= "Vacío";
146
	$l_empty		= "Vacío";
147
	$l_yes			= "Si";
147
	$l_yes			= "Si";
148
	$l_no			= "No";
148
	$l_no			= "No";
149
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
149
	$l_ssl_title		= "La autenticación de cifrado fluye entre usuarios y ALCASAR";
150
	$l_ssh_title		= "SSH";
150
	$l_ssh_title		= "SSH";
151
	$l_ssh_port			= "Puerto";
151
	$l_ssh_port		= "Puerto";
152
	$l_ssh_from			= "IP autorizada";
152
	$l_ssh_from		= "IP autorizada";
153
	$l_ssh_wan_activate	= "Activar SSH en el lado WAN";
153
	$l_ssh_wan_activate	= "Activar SSH en el lado WAN";
154
	$l_ssh_lan_activate	= "Activar SSH en el lado LAN";
154
	$l_ssh_lan_activate	= "Activar SSH en el lado LAN";
155
	$l_all_ip			= "Para permitir todas las @IP de origen : 0.0.0.0";
155
	$l_all_ip		= "Para permitir todas las @IP de origen : 0.0.0.0";
156
	$l_interlan_title = "Permitir el acceso a la red entre ALCASAR y el router de acceso a Internet";
156
	$l_interlan_title	= "Permitir el acceso a la red entre ALCASAR y el router de acceso a Internet";
157
	$l_cert_expiration	= "Fecha de vencimiento:";
157
	$l_cert_expiration	= "Fecha de vencimiento:";
158
	$l_cert_commonname	= "Common name:";
158
	$l_cert_commonname	= "Common name:";
159
	$l_cert_organization	= "Organización:";
159
	$l_cert_organization	= "Organización:";
160
	$l_upload_certificate	= "Importar un certificado";
160
	$l_upload_certificate	= "Importar un certificado";
161
	$l_le_integration	= "Integración con Let's Encrypt";
161
	$l_le_integration	= "Integración con Let's Encrypt";
Line 173... Line 173...
173
	$l_cancel		= "Cancelar";
173
	$l_cancel		= "Cancelar";
174
	$l_le_api		= "API:";
174
	$l_le_api		= "API:";
175
	$l_le_auto_renewal_warning	= "Aviso de renovación a partir de:";
175
	$l_le_auto_renewal_warning	= "Aviso de renovación a partir de:";
176
	$l_renewal_request	= "Solicitud de renovación";
176
	$l_renewal_request	= "Solicitud de renovación";
177
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
177
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
178
    $l_gw_weight	= "Peso";
178
	$l_gw_weight		= "Peso";
179
    $l_error		= "Error";
179
	$l_error		= "Error";
180
	$l_error_bad_mac = "Dirección MAC no válida";
180
	$l_error_bad_mac	= "Dirección MAC no válida";
181
    $l_error_bad_ip	= "Dirección IP inválida";
181
	$l_error_bad_ip		= "Dirección IP inválida";
182
    $l_error_bad_ip_CIDR	= "Dirección IP no válida en formato CIDR";
182
	$l_error_bad_ip_CIDR	= "Dirección IP no válida en formato CIDR";
183
    $l_error_bad_ip_port	= "Dirección IP + puerto no válidos";
183
	$l_error_bad_ip_port	= "Dirección IP + puerto no válidos";
184
    $l_error_weight	= "Peso no válido";
184
	$l_error_weight		= "Peso no válido";
-
 
185
	$l_error_bad_domain	= "Nombre de dominio no válido";
185
    $l_change_successful	= "Cambio completado con éxito";
186
	$l_change_successful	= "Cambio completado con éxito";
186
} else {
187
} else {
187
	$l_network_title	= "Network configuration";
188
	$l_network_title	= "Network configuration";
188
	$l_internet_legend	= "INTERNET";
189
	$l_internet_legend	= "INTERNET";
189
	$l_ip_mask		= "Mask";
190
	$l_ip_mask		= "Mask";
190
	$l_ip_router		= "Router";
191
	$l_ip_router		= "Router";
Line 215... Line 216...
215
	$l_empty		= "Empty";
216
	$l_empty		= "Empty";
216
	$l_yes			= "Yes";
217
	$l_yes			= "Yes";
217
	$l_no			= "No";
218
	$l_no			= "No";
218
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
219
	$l_ssl_title		= "Cipher authentication flows between users and ALCASAR";
219
	$l_ssh_title		= "SSH";
220
	$l_ssh_title		= "SSH";
220
	$l_ssh_port			= "Port";
221
	$l_ssh_port		= "Port";
221
	$l_ssh_from			= "Authorized IP";
222
	$l_ssh_from		= "Authorized IP";
222
	$l_ssh_wan_activate	= "Activate SSH on WAN side";
223
	$l_ssh_wan_activate	= "Activate SSH on WAN side";
223
	$l_ssh_lan_activate	= "Activate SSH on LAN side";
224
	$l_ssh_lan_activate	= "Activate SSH on LAN side";
224
	$l_all_ip			= "To allow all source IP addresses: 0.0.0.0";
225
	$l_all_ip		= "To allow all source IP addresses: 0.0.0.0";
225
	$l_interlan_title = "Authorize access to the network located between ALCASAR and Internet broadband router";
226
	$l_interlan_title	= "Authorize access to the network located between ALCASAR and Internet broadband router";
226
	$l_cert_expiration	= "Expiration date:";
227
	$l_cert_expiration	= "Expiration date:";
227
	$l_cert_commonname	= "Common name:";
228
	$l_cert_commonname	= "Common name:";
228
	$l_cert_organization	= "Organization:";
229
	$l_cert_organization	= "Organization:";
229
	$l_upload_certificate	= "Import an officlal certificate";
230
	$l_upload_certificate	= "Import an officlal certificate";
230
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
231
	$l_le_integration	= "Integrate a Let's Encrypt certificate";
Line 242... Line 243...
242
	$l_cancel		= "Cancel";
243
	$l_cancel		= "Cancel";
243
	$l_le_api		= "API:";
244
	$l_le_api		= "API:";
244
	$l_le_auto_renewal_warning	= "Renewal Alert starting on:";
245
	$l_le_auto_renewal_warning	= "Renewal Alert starting on:";
245
	$l_renewal_request	= "Renewal request";
246
	$l_renewal_request	= "Renewal request";
246
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
247
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
247
    $l_gw_weight = "Weight";
248
	$l_gw_weight		= "Weight";
248
    $l_error        = "Error";
249
	$l_error		= "Error";
249
	$l_error_bad_mac = "Invalid mac address";
250
	$l_error_bad_mac	= "Invalid mac address";
250
    $l_error_bad_ip = "Invalid IP address";
251
	$l_error_bad_ip		= "Invalid IP address";
251
    $l_error_bad_ip_CIDR = "Invalid IP address in CIDR format";
252
	$l_error_bad_ip_CIDR	= "Invalid IP address in CIDR format";
252
    $l_error_bad_ip_port = "Invalid IP address + port";
253
	$l_error_bad_ip_port	= "Invalid IP address + port";
253
    $l_error_weight = "Invalid weight";
254
	$l_error_weight		= "Invalid weight";
-
 
255
	$l_error_bad_domain	= "Invalid domain name";
254
    $l_change_successful = "Network updated successfully";
256
	$l_change_successful	= "Network updated successfully";
255
}
257
}
256
 
258
 
257
$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])$/';
259
$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])$/';
258
$reg_ip_cidr = '/^(([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])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
260
$reg_ip_cidr = '/^(([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])(\/([0-9]|[1-2][0-9]|3[0-2]))$/';
259
$reg_ip_port = '/^(([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])(\:([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))$/';
261
$reg_ip_port = '/^(([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])(\:([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))$/';
260
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
262
$reg_mac     = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/';
261
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
263
$reg_host    = '/^[a-zA-Z0-9-_]+$/';
262
$reg_weight  = '/^[0-9]*$/';
264
$reg_weight  = '/^[0-9]*$/';
-
 
265
$reg_domain  = '/^[a-zA-Z0-9-]+\.[a-zA-Z]{2,11}(?:\.[a-zA-Z]{2,})?$/';
263
$ext_conf_error = false;
266
$ext_conf_error = false;
264
 
267
 
265
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
268
$choix = (isset($_POST['choix'])) ? $_POST['choix'] : '';
266
switch ($choix) {
269
switch ($choix) {
267
	case 'DHCP_On':
270
	case 'DHCP_On':
Line 724... Line 727...
724
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
727
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
725
	<script src="/js/jquery.min.js"></script>
728
	<script src="/js/jquery.min.js"></script>
726
	<script src="/js/jquery.connections.js"></script>
729
	<script src="/js/jquery.connections.js"></script>
727
	<script type="text/javascript">
730
	<script type="text/javascript">
728
	function MAC_Control(formulaire){
731
	function MAC_Control(formulaire){
729
		// MAC control syntax (hexadecimal upper case and '- or :' separator) + rewrite ":" in "-"
732
		// MAC syntax control (hexadecimal upper case and '- or :' separator) + rewrite ":" in "-"
730
		var regex_mac = <?= $reg_mac ?>;
733
		var regex_mac = <?= $reg_mac ?>;
731
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
734
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
732
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
735
			document.forms[formulaire].add_mac.value = document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
733
			return true;
736
			return true;
734
		} else {
737
		} else {
735
			alert('<?= $l_error_bad_mac ?>');
738
			alert('<?= $l_error_bad_mac ?>');
736
			return false;
739
			return false;
737
		}
740
		}
738
	}
741
	}
739
	function IP_Control(formulaire){
742
	function IP_Control(formulaire){
740
		// IP control (decimal & dot separator)
743
		// IP syntax control (decimal & dot separator)
741
		var regex_ip = <?= $reg_ip ?>;
744
		var regex_ip = <?= $reg_ip ?>;
742
		if (regex_ip.test(document.forms[formulaire].add_ip.value)){
745
		if (regex_ip.test(document.forms[formulaire].add_ip.value)){
743
			return true;
746
			return true;
744
		} else {
747
		} else {
745
			alert('<?= $l_error_bad_ip ?>');
748
			alert('<?= $l_error_bad_ip ?>');
746
			return false;
749
			return false;
747
		}
750
		}
748
	}
751
	}
-
 
752
	function Domain_Control(formulaire){
-
 
753
		// domain name syntax control
-
 
754
		var regex_domain = <?= $reg_domain ?>;
-
 
755
		if (regex_domain.test(document.forms[formulaire].domainname.value)){
-
 
756
			return true;
-
 
757
		} else {
-
 
758
			alert('<?= $l_error_bad_domain ?>');
-
 
759
			return false;
-
 
760
		}
-
 
761
	}
749
	</script>
762
	</script>
750
	<style>
763
	<style>
751
		.network-configurator {
764
		.network-configurator {
752
			width: 100%;
765
			width: 100%;
753
		}
766
		}
Line 1340... Line 1353...
1340
				$step = 1;
1353
				$step = 1;
1341
			}
1354
			}
1342
			?>
1355
			?>
1343
			<h3><?= $l_le_integration ?></h3>
1356
			<h3><?= $l_le_integration ?></h3>
1344
			<?php if ($step === 1): ?>
1357
			<?php if ($step === 1): ?>
1345
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1358
				<form name="new_LE"  method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" onSubmit="document.getElementById('ldoverlay').style.display='block';">
1346
					<input type="hidden" name="choix" value="le_issueCert">
1359
					<input type="hidden" name="choix" value="le_issueCert">
1347
					<?= $l_le_status ?> <?= $l_disabled ?><br>
1360
					<?= $l_le_status ?> <?= $l_disabled ?><br>
1348
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
1361
					<?= $l_le_email ?> <input type="text" name="email" placeholder="adresse@email.com"<?= ((!empty($LE_conf['email'])) ? ' value="'.$LE_conf['email'].'"' : '') ?>><br>
1349
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
1362
					<?= $l_le_domain_name ?> <input type="text" name="domainname" placeholder="alcasar.domain.tld" required><br>
1350
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" name="issue" value="<?= $l_send ?>"><br>
1363
					<input type="submit" onClick="return (Domain_Control('new_LE'))" class="button" name="issue" value="<?= $l_send ?>"><br>
1351
				</form>
1364
				</form>
1352
			<?php elseif ($step === 2): ?>
1365
			<?php elseif ($step === 2): ?>
1353
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1366
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1354
					<input type="hidden" name="choix" value="le_renewCert">
1367
					<input type="hidden" name="choix" value="le_renewCert">
1355
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>
1368
					<?= $l_le_status ?> <?= $l_pending_validation ?><br>