Subversion Repositories ALCASAR

Rev

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

Rev 2713 Rev 2717
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: network.php 2713 2019-03-10 23:35:02Z tom.houdayer $
2
# $Id: network.php 2717 2019-03-11 21:23:17Z 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 54... Line 54...
54
	$l_dhcp_title		= "Service DHCP";
54
	$l_dhcp_title		= "Service DHCP";
55
	$l_dhcp_state		= "Mode actuel";
55
	$l_dhcp_state		= "Mode actuel";
56
	$l_DHCP_on		= "actif";
56
	$l_DHCP_on		= "actif";
57
	$l_DHCP_off		= "inactif";
57
	$l_DHCP_off		= "inactif";
58
	$l_DHCP_off_explain	= "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
58
	$l_DHCP_off_explain	= "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
59
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques";
59
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques (DHCP)";
60
	$l_dhcp_relay		= "Relais DHCP";
-
 
61
	$l_dhcp_relay_local_ip	= "Adresse IP locale";
-
 
62
	$l_dhcp_relay_ip	= "Adresse IP DHCP";
-
 
63
	$l_dhcp_relay_port	= "Port DHCP";
-
 
64
	$l_mac_address		= "Adresse MAC";
60
	$l_mac_address		= "Adresse MAC";
65
	$l_ip_address		= "Adresse IP";
61
	$l_ip_address		= "Adresse IP";
66
	$l_host_name		= "Nom d'hôte";
62
	$l_host_name		= "Nom d'hôte";
67
	$l_del			= "Supprimer de la liste";
63
	$l_del			= "Supprimer de la liste";
68
	$l_add_to_list		= "Ajouter";
64
	$l_add_to_list		= "Ajouter";
69
	$l_apply		= "Appliquer les changements";
65
	$l_apply		= "Appliquer les changements";
70
	$l_dns_title		= "Service DNS";
-
 
71
	$l_local_dns		= "Résolution local de nom";
66
	$l_local_dns		= "Résolution local de nom (DNS)";
72
	$l_dns_internal		= "Serveur DNS interne";
-
 
73
	$l_import_cert		= "Import de certificat";
67
	$l_import_cert		= "Import de certificat";
74
	$l_private_key		= "Clé privée (.key) :";
68
	$l_private_key		= "Clé privée (.key) :";
75
	$l_certificate		= "Certificat (.crt) :";
69
	$l_certificate		= "Certificat (.crt) :";
76
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
70
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
77
	$l_default_cert		= "Revenir au certificat d'origine";
71
	$l_default_cert		= "Revenir au certificat d'origine";
Line 114... Line 108...
114
	$l_dhcp_title		= "DHCP service";
108
	$l_dhcp_title		= "DHCP service";
115
	$l_dhcp_state		= "Current mode";
109
	$l_dhcp_state		= "Current mode";
116
	$l_DHCP_on		= "enabled";
110
	$l_DHCP_on		= "enabled";
117
	$l_DHCP_off		= "disabled";
111
	$l_DHCP_off		= "disabled";
118
	$l_DHCP_off_explain	= "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
112
	$l_DHCP_off_explain	= "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
119
	$l_static_dhcp_title	= "Static IP addresses reservation";
113
	$l_static_dhcp_title	= "Static IP addresses reservation (DHCP)";
120
	$l_dhcp_relay		= "DHCP relay";
-
 
121
	$l_dhcp_relay_local_ip	= "Locale IP address";
-
 
122
	$l_dhcp_relay_ip	= "DHCP IP address";
-
 
123
	$l_dhcp_relay_port	= "DHCP port";
-
 
124
	$l_mac_address		= "MAC address";
114
	$l_mac_address		= "MAC address";
125
	$l_ip_address		= "IP address";
115
	$l_ip_address		= "IP address";
126
	$l_port			= "Port";
116
	$l_port			= "Port";
127
	$l_host_name		= "Host name";
117
	$l_host_name		= "Host name";
128
	$l_del			= "Delete from list";
118
	$l_del			= "Delete from list";
129
	$l_add_to_list		= "Add";
119
	$l_add_to_list		= "Add";
130
	$l_apply		= "Apply changes";
120
	$l_apply		= "Apply changes";
131
	$l_dns_title		= "DNS service";
-
 
132
	$l_local_dns		= "Local name resolution";
121
	$l_local_dns		= "Local name resolution (DNS";
133
	$l_dns_internal		= "DNS internal";
-
 
134
	$l_import_cert		= "Certificate import";
122
	$l_import_cert		= "Certificate import";
135
	$l_private_key		= "Private key (.key) :";
123
	$l_private_key		= "Private key (.key) :";
136
	$l_certificate		= "Certificate (.crt) :";
124
	$l_certificate		= "Certificate (.crt) :";
137
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
125
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
138
	$l_default_cert		= "Back to default certificate";
126
	$l_default_cert		= "Back to default certificate";
Line 229... Line 217...
229
			}
217
			}
230
		}
218
		}
231
		header('Location: '.$_SERVER['PHP_SELF']);
219
		header('Location: '.$_SERVER['PHP_SELF']);
232
		exit();
220
		exit();
233
 
221
 
234
	case 'dhcp_relay':	// DHCP relay
-
 
235
		// TODO : check DHCP relay before apply?
-
 
236
		file_put_contents(CONF_FILE, str_replace('EXT_DHCP_IP='.$conf['EXT_DHCP_IP'],         'EXT_DHCP_IP='.trim($_POST['dhcp_relay_ext_ip']),   file_get_contents(CONF_FILE)));
-
 
237
		file_put_contents(CONF_FILE, str_replace('RELAY_DHCP_IP='.$conf['RELAY_DHCP_IP'],     'RELAY_DHCP_IP='.trim($_POST['dhcp_relay_ip']),     file_get_contents(CONF_FILE)));
-
 
238
		file_put_contents(CONF_FILE, str_replace('RELAY_DHCP_PORT='.$conf['RELAY_DHCP_PORT'], 'RELAY_DHCP_PORT='.trim($_POST['dhcp_relay_port']), file_get_contents(CONF_FILE)));
-
 
239
		header('Location: '.$_SERVER['PHP_SELF']);
-
 
240
		exit();
-
 
241
 
-
 
242
	case 'new_host':
222
	case 'new_host':
243
		$add_host = trim($_POST['add_host']);
223
		$add_host = trim($_POST['add_host']);
244
		$add_ip   = trim($_POST['add_ip']);
224
		$add_ip   = trim($_POST['add_ip']);
245
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
225
		if (((!empty($add_host)) && (preg_match($reg_host, $add_host))) && ((!empty($add_ip)) && (preg_match($reg_ip, $add_ip)))) {
246
			$tab = file(DNS_LOCAL_FILE);
226
			$tab = file(DNS_LOCAL_FILE);
Line 273... Line 253...
273
			}
253
			}
274
		}
254
		}
275
		header('Location: '.$_SERVER['PHP_SELF']);
255
		header('Location: '.$_SERVER['PHP_SELF']);
276
		exit();
256
		exit();
277
 
257
 
278
	case 'dns_internal':	// Internal DNS
-
 
279
		// TODO : check @IP / domain before apply? (can break DNS server and shut down the Internet!)
-
 
280
		file_put_contents(CONF_FILE, str_replace('INT_DNS_IP='.$conf['INT_DNS_IP'],         'INT_DNS_IP='.trim($_POST['dns_internal_ip']),         file_get_contents(CONF_FILE)));
-
 
281
		file_put_contents(CONF_FILE, str_replace('INT_DNS_DOMAIN='.$conf['INT_DNS_DOMAIN'], 'INT_DNS_DOMAIN='.trim($_POST['dns_internal_domain']), file_get_contents(CONF_FILE)));
-
 
282
		if ($_POST['dns_internal_active'] === 'on') {
-
 
283
			exec('sudo /usr/local/bin/alcasar-dns-local.sh --on');
-
 
284
		} else {
-
 
285
			exec('sudo /usr/local/bin/alcasar-dns-local.sh --off');
-
 
286
		}
-
 
287
		header('Location: '.$_SERVER['PHP_SELF']);
-
 
288
		exit();
-
 
289
 
-
 
290
	case 'default_cert':	// Restore default certificate
258
	case 'default_cert':	// Restore default certificate
291
		exec('sudo alcasar-importcert.sh -d');
259
		exec('sudo alcasar-importcert.sh -d');
292
		break;
260
		break;
293
 
261
 
294
	case 'import_cert':	// Import certificate
262
	case 'import_cert':	// Import certificate
Line 700... Line 668...
700
		</div>
668
		</div>
701
	</div>
669
	</div>
702
	<br>
670
	<br>
703
 
671
 
704
<table width="100%" cellspacing="0" cellpadding="0" border="0">
672
<table width="100%" cellspacing="0" cellpadding="0" border="0">
705
	<tr><th><?= $l_dhcp_title?></th></tr>
673
	<tr><th><?= $l_static_dhcp_title?></th></tr>
706
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
674
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
707
</table>
675
</table>
708
<table width="100%" cellspacing="0" cellpadding="5" border="1">
676
<table width="100%" cellspacing="0" cellpadding="5" border="1">
709
	<tr><td colspan="2" valign="middle" align="left">
-
 
710
	<center><h3><?= $l_dhcp_state ?> : <?= ${'l_DHCP_'.$conf['DHCP']} ?></h3></center>
-
 
711
	<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
-
 
712
		<select name="choix">
-
 
713
			<option value="DHCP_Off"<?= ((!strcmp($conf['DHCP'], 'off')) ? ' selected' : '') ?>><?= $l_DHCP_off ?></option>
-
 
714
			<option value="DHCP_On"<?= ((!strcmp($conf['DHCP'], 'on')) ? ' selected' : '') ?>><?= $l_DHCP_on ?></option>
-
 
715
		</select>
-
 
716
		<input type="submit" value="<?= $l_apply ?>">
-
 
717
		<br><?= $l_DHCP_off_explain ?>
-
 
718
	</form>
-
 
719
	</td></tr>
-
 
720
 
-
 
721
<?php if ($conf['DHCP'] === 'on'): ?>
-
 
722
	<tr><td colspan="2" align="center"><?= $l_static_dhcp_title ?></td></tr>
-
 
723
	<tr><td width="50%" align="center" valign="middle">
677
	<tr><td width="50%" align="center" valign="middle">
724
		<form action="network.php" method="POST">
678
		<form action="network.php" method="POST">
725
		<table cellspacing="2" cellpadding="3" border="1">
679
		<table cellspacing="2" cellpadding="3" border="1">
726
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
680
		<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr>
727
		<?php
681
		<?php
Line 773... Line 727...
773
					<input type="submit" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
727
					<input type="submit" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');">
774
				</td>
728
				</td>
775
			</tr></table>
729
			</tr></table>
776
		</form>
730
		</form>
777
	</td></tr>
731
	</td></tr>
778
<?php else: ?>
-
 
779
	<tr><td colspan="2" align="center"><?= $l_dhcp_relay ?></td></tr>
-
 
780
	<tr>
-
 
781
		<td colspan="2" align="center">
-
 
782
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
-
 
783
			<table cellspacing="2" cellpadding="3" border="1">
-
 
784
			<tr>
-
 
785
				<th><label for="dhcp_relay_ip"><?= $l_dhcp_relay_local_ip ?></label></th><td><input type="text" name="dhcp_relay_ip" id="dhcp_relay_ip" value="<?= $conf['RELAY_DHCP_IP'] ?>" size="32"></td>
-
 
786
			</tr>
-
 
787
			<tr>
-
 
788
				<th><label for="dhcp_relay_ext_ip"><?= $l_dhcp_relay_ip ?></label></th><td><input type="text" name="dhcp_relay_ext_ip" id="dhcp_relay_ext_ip" value="<?= $conf['EXT_DHCP_IP'] ?>" size="32"></td>
-
 
789
			</tr>
-
 
790
			<tr>
-
 
791
				<th><label for="dhcp_relay_port"><?= $l_dhcp_relay_port ?></label></th><td><input type="text" name="dhcp_relay_port" id="dhcp_relay_port" value="<?= $conf['RELAY_DHCP_PORT'] ?>" size="32"></td>
-
 
792
			</tr>
-
 
793
			</table>
-
 
794
			<input type="hidden" name="choix" value="dhcp_relay">
-
 
795
			<input type="submit" value="<?= $l_apply ?>">
-
 
796
			</form>
-
 
797
		</td>
-
 
798
	</tr>
-
 
799
<?php endif; ?>
-
 
800
</table>
732
</table>
801
<br>
733
<br>
802
 
734
 
803
<table width="100%" cellspacing="0" cellpadding="0" border="0">
735
<table width="100%" cellspacing="0" cellpadding="0" border="0">
804
	<tr><th><?= $l_dns_title ?></th></tr>
736
	<tr><th><?= $l_local_dns ?></th></tr>
805
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
737
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
806
</table>
738
</table>
807
<table width="100%" cellspacing="0" cellpadding="5" border="1">
739
<table width="100%" cellspacing="0" cellpadding="5" border="1">
808
	<tr><td colspan="2" align="center"><?= $l_local_dns ?></td></tr>
-
 
809
	<tr>
740
	<tr>
810
		<td width="50%" align="center">
741
		<td width="50%" align="center">
811
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
742
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
812
			<table cellspacing="2" cellpadding="3" border="1">
743
			<table cellspacing="2" cellpadding="3" border="1">
813
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
744
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
Line 860... Line 791...
860
			</tr>
791
			</tr>
861
			</table>
792
			</table>
862
			</form>
793
			</form>
863
		</td>
794
		</td>
864
	</tr>
795
	</tr>
865
	<tr><td colspan="2" align="center"><?= $l_dns_internal ?></td></tr>
-
 
866
	<tr>
-
 
867
		<td colspan="2" align="center">
-
 
868
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
-
 
869
			<table cellspacing="2" cellpadding="3" border="1">
-
 
870
			<tr>
-
 
871
				<th><?= $l_enabled ?></th>
-
 
872
				<td>
-
 
873
					<select name="dns_internal_active">
-
 
874
						<option value="on"<?=  (($conf['INT_DNS_ACTIVE'] === 'on')  ? ' selected' : '') ?>><?= $l_yes ?></option>
-
 
875
						<option value="off"<?= (($conf['INT_DNS_ACTIVE'] === 'off') ? ' selected' : '') ?>><?= $l_no ?></option>
-
 
876
					</select>
-
 
877
				</td>
-
 
878
			</tr>
-
 
879
			<tr>
-
 
880
				<th><?= $l_ip_address ?></th><td><input type="text" name="dns_internal_ip" value="<?= $conf['INT_DNS_IP'] ?>" size="32"></td>
-
 
881
			</tr>
-
 
882
			<tr>
-
 
883
				<th><?= $l_host_name ?></th><td><input type="text" name="dns_internal_domain" value="<?= $conf['INT_DNS_DOMAIN'] ?>" size="32"></td>
-
 
884
			</tr>
-
 
885
			</table>
-
 
886
			<input type="hidden" name="choix" value="dns_internal">
-
 
887
			<input type="submit" value="<?= $l_apply ?>">
-
 
888
			</form>
-
 
889
		</td>
-
 
890
	</tr>
-
 
891
</table>
796
</table>
892
<br>
797
<br>
893
 
798
 
894
<table width="100%" cellspacing="0" cellpadding="0" border="0">
799
<table width="100%" cellspacing="0" cellpadding="0" border="0">
895
	<tr><th><?= $l_ssl_title ?></th></tr>
800
	<tr><th><?= $l_ssl_title ?></th></tr>