Subversion Repositories ALCASAR

Rev

Rev 3287 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3287 Rev 3288
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: network.php 3287 2025-05-24 17:44:18Z rexy $
2
# $Id: network.php 3288 2025-05-25 17:03:29Z 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 106... Line 106...
106
	$l_renew		= "Renouveller";
106
	$l_renew		= "Renouveller";
107
	$l_renew_force		= "Renouveller (forcer)";
107
	$l_renew_force		= "Renouveller (forcer)";
108
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
108
	$l_previous_LE_cert	= "Revenir au certificat Let's Encrypt :";
109
	$l_gw_weight    = "Poids";
109
	$l_gw_weight    = "Poids";
110
	$l_error        = "Erreur";
110
	$l_error        = "Erreur";
-
 
111
	$l_error_bad_mac = "Adresse MAC invalide";
111
	$l_error_bad_ip = "Ceci n'est pas une adresse IP valide";
112
	$l_error_bad_ip = "Adresse IP invalide";
112
	$l_error_bad_ip_CIDR = "Ceci n'est pas une adresse CIDR valide";
113
	$l_error_bad_ip_CIDR = "Adresse IP au format CIDR invalide";
113
	$l_error_bad_ip_port = "Ceci n'est pas une adresse IP + port valide";
114
	$l_error_bad_ip_port = "Adresse IP + port invalide";
114
	$l_error_weight = "Ceci n'est pas un poids valide";
115
	$l_error_weight = "Poids invalide";
115
    $l_change_successful = "Changement effectué avec succès";
116
    $l_change_successful = "Changement effectué avec succès";
116
 
117
 
117
} else if ($Language === 'es') {
118
} else if ($Language === 'es') {
118
	$l_network_title	= "Configuración de Red";
119
	$l_network_title	= "Configuración de Red";
119
	$l_internet_legend	= "INTERNET";
120
	$l_internet_legend	= "INTERNET";
Line 176... Line 177...
176
	$l_renew		= "Renovar";
177
	$l_renew		= "Renovar";
177
	$l_renew_force		= "Renovar (forzado)";
178
	$l_renew_force		= "Renovar (forzado)";
178
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
179
	$l_previous_LE_cert	= "Volver al certificado de Let's Encrypt :";
179
    $l_gw_weight	= "Peso";
180
    $l_gw_weight	= "Peso";
180
    $l_error		= "Error";
181
    $l_error		= "Error";
-
 
182
	$l_error_bad_mac = "Dirección MAC no válida";
181
    $l_error_bad_ip	= "Esta no es una dirección IP válida";
183
    $l_error_bad_ip	= "Dirección IP inválida";
182
    $l_error_bad_ip_CIDR	= "Esta no es una dirección CIDR válida";
184
    $l_error_bad_ip_CIDR	= "Dirección IP no válida en formato CIDR";
183
    $l_error_bad_ip_port	= "Esto no es una dirección IP + puerto válidos";
185
    $l_error_bad_ip_port	= "Dirección IP + puerto no válidos";
184
    $l_error_weight	= "Esto no es un peso válido";
186
    $l_error_weight	= "Peso no válido";
185
    $l_change_successful	= "Cambio completado con éxito";
187
    $l_change_successful	= "Cambio completado con éxito";
186
} else {
188
} else {
187
	$l_network_title	= "Network configuration";
189
	$l_network_title	= "Network configuration";
188
	$l_internet_legend	= "INTERNET";
190
	$l_internet_legend	= "INTERNET";
189
	$l_ip_mask		= "Mask";
191
	$l_ip_mask		= "Mask";
Line 245... Line 247...
245
	$l_renew		= "Renew";
247
	$l_renew		= "Renew";
246
	$l_renew_force		= "Renew (force)";
248
	$l_renew_force		= "Renew (force)";
247
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
249
	$l_previous_LE_cert	= "Back to the Let's Encrypt certificate :";
248
    $l_gw_weight = "Weight";
250
    $l_gw_weight = "Weight";
249
    $l_error        = "Error";
251
    $l_error        = "Error";
-
 
252
	$l_error_bad_mac = "Invalid mac address";
250
    $l_error_bad_ip = "This is not a valid IP";
253
    $l_error_bad_ip = "Invalid IP address";
251
    $l_error_bad_ip_CIDR = "This is not a valid CIDR IP";
254
    $l_error_bad_ip_CIDR = "Invalid IP address in CIDR format";
252
    $l_error_bad_ip_port = "This is not a valid IP + port";
255
    $l_error_bad_ip_port = "Invalid IP address + port";
253
    $l_error_weight = "This is not a valid weight";
256
    $l_error_weight = "Invalid weight";
254
    $l_change_successful = "Network updated successfully";
257
    $l_change_successful = "Network updated successfully";
255
}
258
}
256
 
259
 
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])$/';
260
$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]))$/';
261
$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]))$/';
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 (hexadecimal upper case and '- or :' separator)
732
		// MAC control syntax (hexadecimal upper case and '- or :' separator) + rewrite ":" in "-"
730
		//var regex_mac = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/;
-
 
731
		var regex_mac = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
733
		var regex_mac = <?= $reg_mac ?>;
732
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
734
		if (regex_mac.test(document.forms[formulaire].add_mac.value)){
733
			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, '-');
734
			return true;
736
			return true;
735
		} else {
737
		} else {
-
 
738
			alert('<?= $l_error_bad_mac ?>');
-
 
739
			return false;
-
 
740
		}
-
 
741
	}
-
 
742
	function IP_Control(formulaire){
-
 
743
		// IP control (decimal & dot separator)
-
 
744
		var regex_ip = <?= $reg_ip ?>;
-
 
745
		if (regex_ip.test(document.forms[formulaire].add_ip.value)){
-
 
746
			return true;
-
 
747
		} else {
736
			alert('Invalid MAC address');
748
			alert('<?= $l_error_bad_ip ?>');
737
			return false;
749
			return false;
738
		}
750
		}
739
	}
751
	}
740
	</script>
752
	</script>
741
	<style>
753
	<style>
Line 1082... Line 1094...
1082
<div class="panel">
1094
<div class="panel">
1083
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
1095
	<div class="panel-header"><?= $l_static_dhcp_title ?></div>
1084
</div>
1096
</div>
1085
<table width="100%" cellspacing="0" cellpadding="5" border="1">
1097
<table width="100%" cellspacing="0" cellpadding="5" border="1">
1086
	<tr><td width="50%" align="center" valign="middle">
1098
	<tr><td width="50%" align="center" valign="middle">
1087
		<form action="network.php" method="POST">
1099
		<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1088
		<table cellspacing="2" cellpadding="3" border="1">
1100
		<table cellspacing="2" cellpadding="3" border="1">
1089
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
1101
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
1090
		<?php
1102
		<?php
1091
		// Read the "ether" file
1103
		// Read the "ether" file
1092
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
1104
		exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output);
Line 1122... Line 1134...
1122
			<input type="hidden" name="choix" value="del_mac">
1134
			<input type="hidden" name="choix" value="del_mac">
1123
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1135
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1124
		<?php endif; ?>
1136
		<?php endif; ?>
1125
		</form>
1137
		</form>
1126
	</td><td width="50%" valign="middle" align="center">
1138
	</td><td width="50%" valign="middle" align="center">
1127
		<form name="new_mac" action="network.php" method="POST">
1139
		<form name="new_mac" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST" onSubmit="document.getElementById('ldoverlay').style.display='block';">
1128
			<table cellspacing="2" cellpadding="3" border="1">
1140
			<table cellspacing="2" cellpadding="3" border="1">
1129
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><td></td></tr>
1141
				<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><td></td></tr>
1130
				<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr>
1142
				<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr>
1131
				<tr><td><input type="text" name="add_mac" size="17"></td>
1143
				<tr><td><input type="text" name="add_mac" size="17"></td>
1132
				<td><input type="text" name="add_ip" size="10"></td>
1144
				<td><input type="text" name="add_ip" size="10"></td>
1133
				<td><input type="text" name="info" size="10"></td>
1145
				<td><input type="text" name="info" size="10"></td>
1134
				<td>
1146
				<td>
1135
					<input type="hidden" name="choix" value="new_mac">
1147
					<input type="hidden" name="choix" value="new_mac">
1136
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
1148
					<input type="submit" onClick="return (MAC_Control('new_mac') && IP_Control('new_mac'))" class="button" value="<?= $l_add_to_list ?>">
1137
				</td>
1149
				</td>
1138
			</tr></table>
1150
			</tr></table>
1139
		</form>
1151
		</form>
1140
	</td></tr>
1152
	</td></tr>
1141
</table>
1153
</table>
Line 1176... Line 1188...
1176
			}
1188
			}
1177
			?>
1189
			?>
1178
			</table>
1190
			</table>
1179
			<?php if ($line_exist): ?>
1191
			<?php if ($line_exist): ?>
1180
				<input type="hidden" name="choix" value="del_host">
1192
				<input type="hidden" name="choix" value="del_host">
1181
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>">
1193
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_apply ?>">
1182
			<?php endif; ?>
1194
			<?php endif; ?>
1183
			</form>
1195
			</form>
1184
		</td>
1196
		</td>
1185
		<td width="50%" valign="middle" align="center">
1197
		<td width="50%" valign="middle" align="center">
1186
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
1198
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST" onSubmit="document.getElementById('ldoverlay').style.display='block';">
1187
			<table cellspacing="2" cellpadding="3" border="1">
1199
			<table cellspacing="2" cellpadding="3" border="1">
1188
			<tr>
1200
			<tr>
1189
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
1201
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
1190
			</tr>
1202
			</tr>
1191
			<tr>
1203
			<tr>
1192
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
1204
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
1193
			</tr>
1205
			</tr>
1194
			<tr>
1206
			<tr>
1195
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
1207
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
1196
				<td><input type="text" name="add_host" size="17"></td>
1208
				<td><input type="text" name="add_host" size="17"></td>
1197
				<td><input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_add_to_list ?>"></td>
1209
				<td><input type="submit" onClick="return (IP_Control('new_host'))" class="button" value="<?= $l_add_to_list ?>"></td>
1198
			</tr>
1210
			</tr>
1199
			</table>
1211
			</table>
1200
			</form>
1212
			</form>
1201
		</td>
1213
		</td>
1202
	</tr>
1214
	</tr>
Line 1206... Line 1218...
1206
	<div class="panel-header"><?= $l_ssl_title ?></div>
1218
	<div class="panel-header"><?= $l_ssl_title ?></div>
1207
	<div class="panel-row">
1219
	<div class="panel-row">
1208
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1220
		<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1209
			<input type="hidden" name="choix" value="https_login">
1221
			<input type="hidden" name="choix" value="https_login">
1210
			<input type="checkbox" name="https_login" id="https_login" <?= ($conf['HTTPS_LOGIN'] === 'on')? "checked": "" ?>><b><?= $l_ssl_title ?></b><br>
1222
			<input type="checkbox" name="https_login" id="https_login" <?= ($conf['HTTPS_LOGIN'] === 'on')? "checked": "" ?>><b><?= $l_ssl_title ?></b><br>
1211
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1223
			<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_apply ?>"><br>
1212
		</form>
1224
		</form>
1213
	</div>
1225
	</div>
1214
</div>
1226
</div>
1215
<br>
1227
<br>
1216
<div class="panel">
1228
<div class="panel">
Line 1228... Line 1240...
1228
	<div class="panel-header"><?= $l_ssh_title ?></div>
1240
	<div class="panel-header"><?= $l_ssh_title ?></div>
1229
	<table width="100%" cellspacing="0" cellpadding="5" border="1">
1241
	<table width="100%" cellspacing="0" cellpadding="5" border="1">
1230
	<tr>
1242
	<tr>
1231
		<td width="50%" align="center">
1243
		<td width="50%" align="center">
1232
			<div class="panel-row">
1244
			<div class="panel-row">
1233
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1245
				<form name="ssh_lan" method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1234
					<input type="hidden" name="choix" value="enable_lan_ssh">
1246
					<input type="hidden" name="choix" value="enable_lan_ssh">
1235
					<input type="checkbox" name="sshlan" id="sshlan" <?= $conf['SSH_LAN'] !== '0' ? "checked": "" ?> onchange="document.getElementById('sshtablelan').style.display = this.checked ? 'block' : 'none';"> <b><?= $l_ssh_lan_activate ?></b><br><br>
1247
					<input type="checkbox" name="sshlan" id="sshlan" <?= $conf['SSH_LAN'] !== '0' ? "checked": "" ?> onchange="document.getElementById('sshtablelan').style.display = this.checked ? 'block' : 'none';"> <b><?= $l_ssh_lan_activate ?></b><br><br>
1236
					<div id="sshtablelan" style="display:<?= $conf['SSH_LAN'] !== '0'? "block": "none" ?>">
1248
					<div id="sshtablelan" style="display:<?= $conf['SSH_LAN'] !== '0'? "block": "none" ?>">
1237
					<table cellspacing="2" cellpadding="3" border="1">
1249
					<table cellspacing="2" cellpadding="3" border="1">
1238
						<tr>
1250
						<tr>
Line 1243... Line 1255...
1243
							<td><input style="width:120px" type="text" id="ssh_from" name="ssh_from" value="<?= explode('/',$conf['SSH_ADMIN_FROM'])[0] ?>" /></td>		
1255
							<td><input style="width:120px" type="text" id="ssh_from" name="ssh_from" value="<?= explode('/',$conf['SSH_ADMIN_FROM'])[0] ?>" /></td>		
1244
						</tr>
1256
						</tr>
1245
					</table>
1257
					</table>
1246
					<p><?= $l_all_ip ?></p>
1258
					<p><?= $l_all_ip ?></p>
1247
				</div>
1259
				</div>
1248
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1260
					<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_apply ?>"><br>
1249
				</form>
1261
				</form>
1250
			</div>
1262
			</div>
1251
		</td>
1263
		</td>
1252
		<td width="50%" align="center">
1264
		<td width="50%" align="center">
1253
			<div class="panel-row">
1265
			<div class="panel-row">
1254
				<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1266
				<form name="ssh_wan" method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
1255
				<input type="hidden" name="choix" value="enable_wan_ssh">
1267
				<input type="hidden" name="choix" value="enable_wan_ssh">
1256
				<input type="checkbox" name="togglessh" id="togglessh" <?= $conf['SSH_WAN'] !== '0'? "checked": "" ?> onchange="document.getElementById('sshtablewan').style.display = this.checked ? 'block' : 'none';"> <b><?= $l_ssh_wan_activate ?></b><br><br>
1268
				<input type="checkbox" name="togglessh" id="togglessh" <?= $conf['SSH_WAN'] !== '0'? "checked": "" ?> onchange="document.getElementById('sshtablewan').style.display = this.checked ? 'block' : 'none';"> <b><?= $l_ssh_wan_activate ?></b><br><br>
1257
				<div id="sshtablewan" style="display:<?= $conf['SSH_WAN'] !== '0'? "block": "none" ?>">
1269
				<div id="sshtablewan" style="display:<?= $conf['SSH_WAN'] !== '0'? "block": "none" ?>">
1258
					<table cellspacing="2" cellpadding="3" border="1">
1270
					<table cellspacing="2" cellpadding="3" border="1">
1259
						<tr>
1271
						<tr>
Line 1264... Line 1276...
1264
							<td><input style="width:120px" type="text" id="ssh_from" name="ssh_from" value="<?= explode('/',$conf['SSH_ADMIN_FROM'])[1] ?>" /></td>		
1276
							<td><input style="width:120px" type="text" id="ssh_from" name="ssh_from" value="<?= explode('/',$conf['SSH_ADMIN_FROM'])[1] ?>" /></td>		
1265
						</tr>
1277
						</tr>
1266
					</table>
1278
					</table>
1267
					<p><?= $l_all_ip ?></p>
1279
					<p><?= $l_all_ip ?></p>
1268
				</div>
1280
				</div>
1269
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_apply ?>"><br>
1281
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_apply ?>"><br>
1270
				</form>
1282
				</form>
1271
			</div>
1283
			</div>
1272
		</td>
1284
		</td>
1273
	</tr>
1285
	</tr>
1274
	</table>
1286
	</table>
Line 1313... Line 1325...
1313
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
1325
			<form method="post" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
1314
				<?= $l_private_key;?> <input type="file" name="key"><br>
1326
				<?= $l_private_key;?> <input type="file" name="key"><br>
1315
				<?= $l_certificate;?> <input type="file" name="crt"><br>
1327
				<?= $l_certificate;?> <input type="file" name="crt"><br>
1316
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
1328
				<?= $l_server_chain;?> <input type="file" name="sc"><br>
1317
				<input type="hidden" name="choix" value="import_cert">
1329
				<input type="hidden" name="choix" value="import_cert">
1318
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" value="<?= $l_import ?>">
1330
				<input type="submit" onClick="document.getElementById('ldoverlay').style.display='block';" class="button" value="<?= $l_import ?>">
1319
			</form>
1331
			</form>
1320
		</div>
1332
		</div>
1321
		<div class="panel-cell">
1333
		<div class="panel-cell">
1322
			<?php
1334
			<?php
1323
			// Get step
1335
			// Get step