Subversion Repositories ALCASAR

Rev

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

Rev 2708 Rev 2709
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: network.php 2708 2019-03-05 23:17:43Z tom.houdayer $
2
# $Id: network.php 2709 2019-03-05 23:20:31Z 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 65... Line 65...
65
	$l_ip_address		= "Adresse IP";
65
	$l_ip_address		= "Adresse IP";
66
	$l_host_name		= "Nom d'hôte";
66
	$l_host_name		= "Nom d'hôte";
67
	$l_del			= "Supprimer de la liste";
67
	$l_del			= "Supprimer de la liste";
68
	$l_add_to_list		= "Ajouter";
68
	$l_add_to_list		= "Ajouter";
69
	$l_apply		= "Appliquer les changements";
69
	$l_apply		= "Appliquer les changements";
-
 
70
	$l_dns_title		= "Service DNS";
70
	$l_local_dns		= "Résolution local de nom";
71
	$l_local_dns		= "Résolution local de nom";
-
 
72
	$l_dns_internal		= "Serveur DNS interne";
71
	$l_import_cert		= "Import de certificat";
73
	$l_import_cert		= "Import de certificat";
72
	$l_private_key		= "Clé privée (.key) :";
74
	$l_private_key		= "Clé privée (.key) :";
73
	$l_certificate		= "Certificat (.crt) :";
75
	$l_certificate		= "Certificat (.crt) :";
74
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
76
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
75
	$l_default_cert		= "Revenir au certificat d'origine";
77
	$l_default_cert		= "Revenir au certificat d'origine";
Line 124... Line 126...
124
	$l_port			= "Port";
126
	$l_port			= "Port";
125
	$l_host_name		= "Host name";
127
	$l_host_name		= "Host name";
126
	$l_del			= "Delete from list";
128
	$l_del			= "Delete from list";
127
	$l_add_to_list		= "Add";
129
	$l_add_to_list		= "Add";
128
	$l_apply		= "Apply changes";
130
	$l_apply		= "Apply changes";
-
 
131
	$l_dns_title		= "DNS service";
129
	$l_local_dns		= "Local name resolution";
132
	$l_local_dns		= "Local name resolution";
-
 
133
	$l_dns_internal		= "DNS internal";
130
	$l_import_cert		= "Certificate import";
134
	$l_import_cert		= "Certificate import";
131
	$l_private_key		= "Private key (.key) :";
135
	$l_private_key		= "Private key (.key) :";
132
	$l_certificate		= "Certificate (.crt) :";
136
	$l_certificate		= "Certificate (.crt) :";
133
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
137
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
134
	$l_default_cert		= "Back to default certificate";
138
	$l_default_cert		= "Back to default certificate";
Line 269... Line 273...
269
			}
273
			}
270
		}
274
		}
271
		header('Location: '.$_SERVER['PHP_SELF']);
275
		header('Location: '.$_SERVER['PHP_SELF']);
272
		exit();
276
		exit();
273
 
277
 
-
 
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
 
274
	case 'default_cert':	// Restore default certificate
290
	case 'default_cert':	// Restore default certificate
275
		exec('sudo alcasar-importcert.sh -d');
291
		exec('sudo alcasar-importcert.sh -d');
276
		break;
292
		break;
277
 
293
 
278
	case 'import_cert':	// Import certificate
294
	case 'import_cert':	// Import certificate
Line 783... Line 799...
783
<?php endif; ?>
799
<?php endif; ?>
784
</table>
800
</table>
785
<br>
801
<br>
786
 
802
 
787
<table width="100%" cellspacing="0" cellpadding="0" border="0">
803
<table width="100%" cellspacing="0" cellpadding="0" border="0">
-
 
804
	<tr><th><?= $l_dns_title ?></th></tr>
-
 
805
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
-
 
806
</table>
-
 
807
<table width="100%" cellspacing="0" cellpadding="5" border="1">
-
 
808
	<tr><td colspan="2" align="center"><?= $l_local_dns ?></td></tr>
-
 
809
	<tr>
-
 
810
		<td width="50%" align="center">
-
 
811
			<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
-
 
812
			<table cellspacing="2" cellpadding="3" border="1">
-
 
813
			<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr>
-
 
814
			<?php
-
 
815
			// Read the "dns_local" file
-
 
816
			$line_exist = false;
-
 
817
			$tab = file(DNS_LOCAL_FILE);
-
 
818
			if ($tab) { // not empty
-
 
819
				foreach ($tab as $line) {
-
 
820
					if (preg_match ('/^\d+/', $line)) { # begin with one or several digit
-
 
821
						$line_exist = true;
-
 
822
						$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab)
-
 
823
						$ip_addr   = $field[0];
-
 
824
						$host_name = $field[1];
-
 
825
						echo "<tr><td>$ip_addr</td>";
-
 
826
						echo "<td>$host_name</td>";
-
 
827
						if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) {
-
 
828
							echo "<td>";}
-
 
829
						else {
-
 
830
							echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">";
-
 
831
						}
-
 
832
						echo "</td></tr>";
-
 
833
					}
-
 
834
				}
-
 
835
			}
-
 
836
			if (!$line_exist) {
-
 
837
				echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>';
-
 
838
			}
-
 
839
			?>
-
 
840
			</table>
-
 
841
			<?php if ($line_exist): ?>
-
 
842
				<input type="hidden" name="choix" value="del_host">
-
 
843
				<input type="submit" value="<?= $l_apply ?>">
-
 
844
			<?php endif; ?>
-
 
845
			</form>
-
 
846
		</td>
-
 
847
		<td width="50%" valign="middle" align="center">
-
 
848
			<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST">
-
 
849
			<table cellspacing="2" cellpadding="3" border="1">
-
 
850
			<tr>
-
 
851
				<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td>
-
 
852
			</tr>
-
 
853
			<tr>
-
 
854
				<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td>
-
 
855
			</tr>
-
 
856
			<tr>
-
 
857
				<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td>
-
 
858
				<td><input type="text" name="add_host" size="17"></td>
-
 
859
				<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td>
-
 
860
			</tr>
-
 
861
			</table>
-
 
862
			</form>
-
 
863
		</td>
-
 
864
	</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>
-
 
892
<br>
-
 
893
 
-
 
894
<table width="100%" cellspacing="0" cellpadding="0" border="0">
788
	<tr><th><?= $l_ssl_title ?></th></tr>
895
	<tr><th><?= $l_ssl_title ?></th></tr>
789
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
896
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
790
</table>
897
</table>
791
<table width="100%" cellspacing="0" cellpadding="5" border="1">
898
<table width="100%" cellspacing="0" cellpadding="5" border="1">
792
	<tr><td valign="middle" align="left">
899
	<tr><td valign="middle" align="left">