Subversion Repositories ALCASAR

Rev

Rev 1764 | Rev 1827 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1764 Rev 1822
1
<?php
1
<?php
2
/* written by steweb57 & Rexy */
2
/* written by steweb57 & Rexy */
3
 
3
 
4
/********************
4
/********************
5
* READ CONF FILES   *
5
* READ CONF FILES   *
6
*********************/
6
*********************/
7
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
7
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
8
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
8
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
9
$conf_files=array(CONF_FILE,ETHERS_FILE);
9
$conf_files=array(CONF_FILE,ETHERS_FILE);
-
 
10
$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])$/';
-
 
11
$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]))$/';
-
 
12
$network_modification=0;
10
foreach ($conf_files as $file){
13
foreach ($conf_files as $file){
11
if (!file_exists($file)){
14
if (!file_exists($file)){
12
	exit("Requested file ".$file." isn't present");}
15
	exit("Requested file ".$file." isn't present");}
13
if (!is_readable($file)){
16
if (!is_readable($file)){
14
	exit("Can't read the file ".$file);}
17
	exit("Can't read the file ".$file);}
15
}
18
}
16
 
19
 
-
 
20
 
17
# Choice of language
21
# Choice of language
18
$Language = 'en';
22
$Language = 'en';
19
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
23
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
20
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
24
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
21
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
25
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
22
if($Language == 'fr'){
26
if($Language == 'fr'){
23
	$l_network_title	= "Configuration réseau";
27
	$l_network_title	= "Configuration réseau";
24
	$l_extif_legend		= " (Interface connectée à Internet)";
28
	$l_extif_legend		= " (Interface connectée à Internet)";
25
	$l_intif_legend		= " (Réseau de consultation)";
29
	$l_intif_legend		= " (Réseau de consultation)";
26
	$l_internet_legend	= "INTERNET";
30
	$l_internet_legend	= "INTERNET";
27
	$l_ip_adr		= "Adresse IP";
31
	$l_ip_adr		= "Adresse IP";
28
	$l_ip_mask		= "Masque";
32
	$l_ip_mask		= "Masque";
29
	$l_ip_router		= "Passerelle";
33
	$l_ip_router		= "Passerelle";
30
	$l_ip_public		= "Adresse IP publique";
34
	$l_ip_public		= "Adresse IP publique";
31
	$l_ip_dns1		= "DNS1";
35
	$l_ip_dns1		= "DNS1";
32
	$l_ip_dns2		= "DNS2";
36
	$l_ip_dns2		= "DNS2";
33
	$l_dhcp_title		= "Service DHCP";
37
	$l_dhcp_title		= "Service DHCP";
34
	$l_dhcp_state		= "Mode actuel";
38
	$l_dhcp_state		= "Mode actuel";
35
	$l_DHCP_on		= "actif";
39
	$l_DHCP_on		= "actif";
36
	$l_DHCP_off		= "inactif";
40
	$l_DHCP_off		= "inactif";
37
	$l_DHCP_off_explain	= "! Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
41
	$l_DHCP_off_explain	= "! Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation).";
38
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques";
42
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques";
39
	$l_mac_address		= "Adresse MAC";
43
	$l_mac_address		= "Adresse MAC";
40
	$l_ip_address		= "Adresse IP";
44
	$l_ip_address		= "Adresse IP";
41
	$l_mac_del		= "Supprimer de la liste";
45
	$l_mac_del		= "Supprimer de la liste";
42
	$l_add_to_list		= "Ajouter";
46
	$l_add_to_list		= "Ajouter";
43
	$l_apply		= "Appliquer les changements";
47
	$l_apply		= "Appliquer les changements";
44
	$l_import_cert		= "Import de certificat";
48
	$l_import_cert		= "Import de certificat";
45
	$l_private_key		= "Clé privée (.key) :";
49
	$l_private_key		= "Clé privée (.key) :";
46
	$l_certificate		= "Certificat (.crt) :";
50
	$l_certificate		= "Certificat (.crt) :";
47
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
51
	$l_server_chain		= "Chaîne de certification (si nécéssaire : .crt) :";
48
	$l_default_cert		= "Revenir au certificat d'origine";
52
	$l_default_cert		= "Revenir au certificat d'origine";
49
	$l_import		= "Importer";
53
	$l_import		= "Importer";
50
	$l_current_certificate  = "Certificat actuel";
54
	$l_current_certificate  = "Certificat actuel";
51
	$l_validated		= "Validé par :";
55
	$l_validated		= "Validé par :";
52
 
56
 
53
} else {
57
} else {
54
	$l_network_title	= "Network configuration";
58
	$l_network_title	= "Network configuration";
55
	$l_extif_legend		= " (Internet connected interface)";
59
	$l_extif_legend		= " (Internet connected interface)";
56
	$l_intif_legend		= " (Private network)";
60
	$l_intif_legend		= " (Private network)";
57
	$l_internet_legend	= "INTERNET";
61
	$l_internet_legend	= "INTERNET";
58
	$l_ip_adr		= "IP Address";
62
	$l_ip_adr		= "IP Address";
59
	$l_ip_mask		= "Mask";
63
	$l_ip_mask		= "Mask";
60
	$l_ip_router		= "Gateway";
64
	$l_ip_router		= "Gateway";
61
	$l_ip_public		= "Public IP address";
65
	$l_ip_public		= "Public IP address";
62
	$l_ip_dns1		= "DNS1";
66
	$l_ip_dns1		= "DNS1";
63
	$l_ip_dns2		= "DNS2";
67
	$l_ip_dns2		= "DNS2";
64
	$l_dhcp_title		= "DHCP service";
68
	$l_dhcp_title		= "DHCP service";
65
	$l_dhcp_state		= "Current mode";
69
	$l_dhcp_state		= "Current mode";
66
	$l_DHCP_on		= "enabled";
70
	$l_DHCP_on		= "enabled";
67
	$l_DHCP_off		= "disabled";
71
	$l_DHCP_off		= "disabled";
68
	$l_DHCP_off_explain	= "! Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
72
	$l_DHCP_off_explain	= "! Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
69
	$l_static_dhcp_title	= "Static IP addresses reservation";
73
	$l_static_dhcp_title	= "Static IP addresses reservation";
70
	$l_mac_address		= "MAC Address";
74
	$l_mac_address		= "MAC Address";
71
	$l_ip_address		= "IP Address";
75
	$l_ip_address		= "IP Address";
72
	$l_mac_del		= "Delete from list";
76
	$l_mac_del		= "Delete from list";
73
	$l_add_to_list		= "Add";
77
	$l_add_to_list		= "Add";
74
	$l_apply		= "Apply changes";
78
	$l_apply		= "Apply changes";
75
	$l_import_cert		= "Certificate import";
79
	$l_import_cert		= "Certificate import";
76
	$l_private_key		= "Private key (.key) :";
80
	$l_private_key		= "Private key (.key) :";
77
	$l_certificate		= "Certificate (.crt) :";
81
	$l_certificate		= "Certificate (.crt) :";
78
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
82
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
79
	$l_default_cert		= "Back to default certificate";
83
	$l_default_cert		= "Back to default certificate";
80
	$l_import		= "Import";
84
	$l_import		= "Import";
81
	$l_current_certificate  = "Current certificate";
85
	$l_current_certificate  = "Current certificate";
82
	$l_validated		= "Validated by :";
86
	$l_validated		= "Validated by :";
83
 
87
 
84
}
88
}
85
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
89
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
86
switch ($choix)
90
switch ($choix)
87
{
91
{
88
case 'DHCP_On' :
92
case 'DHCP_On' :
89
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -on");
93
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -on");
90
	break;
94
	break;
91
case 'DHCP_Off' :
95
case 'DHCP_Off' :
92
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -off");
96
	exec ("sudo /usr/local/sbin/alcasar-dhcp.sh -off");
93
	break;
97
	break;
94
case 'new_mac' :
98
case 'new_mac' :
95
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
99
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
96
		{
100
		{
97
		$tab=file(ETHERS_FILE);
101
		$tab=file(ETHERS_FILE);
98
		$insert="True";
102
		$insert="True";
99
		if ($tab)  # the file isn't empty
103
		if ($tab)  # the file isn't empty
100
			{
104
			{
101
			foreach ($tab as $line)  # verify that MAC or IP addresses doesn't exist
105
			foreach ($tab as $line)  # verify that MAC or IP addresses doesn't exist
102
				{
106
				{
103
				$field=explode(" ", $line);
107
				$field=explode(" ", $line);
104
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
108
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
105
				if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0)
109
				if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0)
106
					{
110
					{
107
					$insert="False";
111
					$insert="False";
108
					break;
112
					break;
109
					}
113
					}
110
				if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
114
				if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
111
					{
115
					{
112
					$insert="False";
116
					$insert="False";
113
					break;
117
					break;
114
					}
118
					}
115
				}
119
				}
116
			}
120
			}
117
		if ($insert == "True")
121
		if ($insert == "True")
118
			{
122
			{
119
			$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
123
			$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
120
			$pointeur=fopen(ETHERS_FILE,"a");
124
			$pointeur=fopen(ETHERS_FILE,"a");
121
			fwrite ($pointeur, $line);
125
			fwrite ($pointeur, $line);
122
			fclose ($pointeur);
126
			fclose ($pointeur);
123
			exec ("sudo /usr/bin/systemctl reload chilli");
127
			exec ("sudo /usr/bin/systemctl reload chilli");
124
			}
128
			}
125
		}
129
		}
126
	break;
130
	break;
127
case 'del_mac' :
131
case 'del_mac' :
128
	$tab=file(ETHERS_FILE);
132
	$tab=file(ETHERS_FILE);
129
	if ($tab)
133
	if ($tab)
130
		{
134
		{
131
		$pointeur=fopen(ETHERS_FILE,"w+");
135
		$pointeur=fopen(ETHERS_FILE,"w+");
132
		foreach ($tab as $line)
136
		foreach ($tab as $line)
133
			{
137
			{
134
			$field=explode(" ", $line);
138
			$field=explode(" ", $line);
135
			$mac_addr=trim($field[0]);
139
			$mac_addr=trim($field[0]);
136
			$remove_line = False;
140
			$remove_line = False;
137
			foreach ($_POST as $key => $value)
141
			foreach ($_POST as $key => $value)
138
				{
142
				{
139
				if ($mac_addr == $key)
143
				if ($mac_addr == $key)
140
			       		{
144
			       		{
141
					$remove_line = True;
145
					$remove_line = True;
142
					break;
146
					break;
143
					}
147
					}
144
				}
148
				}
145
			if (! $remove_line) {fwrite($pointeur,$line);}
149
			if (! $remove_line) {fwrite($pointeur,$line);}
146
			}
150
			}
147
		fclose($pointeur);
151
		fclose($pointeur);
148
		exec ("sudo /usr/bin/systemctl reload chilli");
152
		exec ("sudo /usr/bin/systemctl reload chilli");
149
		}
153
		}
150
	break;
154
	break;
151
}
155
}
152
 
156
 
153
// Fonction de test de connectivité internet
157
// Fonction de test de connectivité internet
154
function internetTest(){
158
function internetTest(){
155
	$host = "www.google.fr"; # Google Test
159
	$host = "www.google.fr"; # Google Test
156
	$port = "80";
160
	$port = "80";
157
	//var $num;	//not used
161
	//var $num;	//not used
158
	//var $error;	//not used
162
	//var $error;	//not used
159
 
163
 
160
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
164
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
161
		return false;
165
		return false;
162
	} else {
166
	} else {
163
		fclose($sock);
167
		fclose($sock);
164
		return true;
168
		return true;
165
	}
169
	}
166
}
170
}
167
 
-
 
168
/***********************************
171
/***********************************
169
*	Read ALCASAR_CONF_FILE     *
172
* 	Update ALCASAR_CONF_FILE   *
170
************************************/
173
***********************************/
-
 
174
 
-
 
175
/*******************************************
-
 
176
*	Read ALCASAR_CONF_FILE Before     *
-
 
177
********************************************/
-
 
178
$ouvre=fopen(CONF_FILE,"r");
-
 
179
if ($ouvre){
-
 
180
	while (!feof ($ouvre))
-
 
181
	{
-
 
182
		$tampon = fgets($ouvre, 4096);
-
 
183
		if (strpos($tampon,"=")!==false){
-
 
184
			$tmp = explode("=",$tampon);
-
 
185
			$conf[$tmp[0]] = $tmp[1];
-
 
186
		}
-
 
187
	}
-
 
188
	fclose($ouvre);
-
 
189
}
-
 
190
	
-
 
191
		
-
 
192
if(isset($_POST['dns1']) && preg_match($reg_ip,$_POST['dns1']))
-
 
193
{
-
 
194
	file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'],'DNS1='.$_POST['dns1']."\n",file_get_contents(CONF_FILE)));
-
 
195
	$network_modification=1;
-
 
196
}
-
 
197
if(isset($_POST['dns2']) && preg_match($reg_ip,$_POST['dns2']))
-
 
198
{
-
 
199
	file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'],'DNS2='.$_POST['dns2']."\n",file_get_contents(CONF_FILE)));
-
 
200
	$network_modification=1;
-
 
201
}
-
 
202
 
-
 
203
if(isset($_POST['ip_public']) && preg_match($reg_ip_cidr,$_POST['ip_public']))
-
 
204
{
-
 
205
	file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'],'PUBLIC_IP='.$_POST['ip_public']."\n",file_get_contents(CONF_FILE)));
-
 
206
	$network_modification=1;
-
 
207
}
-
 
208
 
-
 
209
if(isset($_POST['ip_gw']) && preg_match($reg_ip,$_POST['ip_gw']))
-
 
210
{
-
 
211
	file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'],'GW='.$_POST['ip_gw']."\n",file_get_contents(CONF_FILE)));
-
 
212
	$network_modification=1;
-
 
213
}
-
 
214
 
-
 
215
if(isset($_POST['ip_private']) && preg_match($reg_ip_cidr,$_POST['ip_private']))
-
 
216
{
-
 
217
	file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'],'PRIVATE_IP='.$_POST['ip_private']."\n",file_get_contents(CONF_FILE)));
-
 
218
	$network_modification=1;
-
 
219
}
-
 
220
if($network_modification)
-
 
221
{
-
 
222
	exec("sudo /usr/local/bin/alcasar-conf.sh -apply");
-
 
223
	
-
 
224
}
-
 
225
 
-
 
226
 
-
 
227
 
-
 
228
 
-
 
229
/*******************************************
-
 
230
*	Read ALCASAR_CONF_FILE Updated     *
-
 
231
********************************************/
171
$ouvre=fopen(CONF_FILE,"r");
232
$ouvre=fopen(CONF_FILE,"r");
172
if ($ouvre){
233
if ($ouvre){
173
	while (!feof ($ouvre))
234
	while (!feof ($ouvre))
174
	{
235
	{
175
		$tampon = fgets($ouvre, 4096);
236
		$tampon = fgets($ouvre, 4096);
176
		if (strpos($tampon,"=")!==false){
237
		if (strpos($tampon,"=")!==false){
177
			$tmp = explode("=",$tampon);
238
			$tmp = explode("=",$tampon);
178
			$conf[$tmp[0]] = $tmp[1];
239
			$conf[$tmp[0]] = $tmp[1];
179
		}
240
		}
180
	}
241
	}
181
	fclose($ouvre);
242
	fclose($ouvre);
182
}
243
}
183
 
244
 
184
/************************
245
/************************
185
*	TO DO		*
246
*	TO DO		*
186
*************************/
247
*************************/
187
//modification de la conf réseau  --> V3.0
248
//modification de la conf réseau  --> V3.0
188
 
249
 
189
?>
250
?>
190
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
251
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
191
<html><!-- written by steweb57 & rexy -->
252
<html><!-- written by steweb57 & rexy -->
192
<head>
253
<head>
193
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
254
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
194
<title><?php echo $l_network_title; ?></title>
255
<title><?php echo $l_network_title; ?></title>
195
<link rel="stylesheet" href="/css/style.css" type="text/css">
256
<link rel="stylesheet" href="/css/style.css" type="text/css">
196
<script type="text/javascript">
257
<script type="text/javascript">
197
function MAC_Control(formulaire){
258
function MAC_Control(formulaire){
198
/*MAC control (upper case and '-' separator*/
259
/*MAC control (upper case and '-' separator*/
199
	var regex1 = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/; //vérification adresse mac
260
	var regex1 = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/; //vérification adresse mac
200
	if (regex1.test(document.forms[formulaire].add_mac.value)){
261
	if (regex1.test(document.forms[formulaire].add_mac.value)){
201
		document.forms[formulaire].add_mac.value=document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
262
		document.forms[formulaire].add_mac.value=document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
202
		return true;
263
		return true;
203
	} else {
264
	} else {
204
		alert("Invalid MAC address");//non internationnalisé
265
		alert("Invalid MAC address");//non internationnalisé
205
		return false;
266
		return false;
206
	}
267
	}
207
}
268
}
208
</script>
269
</script>
209
</head>
270
</head>
-
 
271
 
-
 
272
 
210
<body>
273
<body>
211
<table width="100%" border="0" cellspacing="0" cellpadding="0">
274
<table width="100%" border="0" cellspacing="0" cellpadding="0">
212
	<tr><th><?php echo $l_network_title; ?></th></tr>
275
	<tr><th><?php echo $l_network_title; ?></th></tr>
213
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
276
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
214
</table>
277
</table>
215
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
278
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
216
	<tr><td valign="middle" align="left">
279
	<tr><td valign="middle" align="left">
217
	<fieldset>
280
	<fieldset>
218
	<legend><?php echo $l_internet_legend;
281
	<legend><?php echo $l_internet_legend;
219
 	if (InternetTest()){
282
 	if (InternetTest()){
220
		echo " <img src='/images/state_ok.gif'>";
283
		echo " <img src='/images/state_ok.gif'>";
221
		$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");}
284
		$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");}
222
	else 	{
285
	else 	{
223
		echo " <img src='/images/state_error.gif'>";
286
		echo " <img src='/images/state_error.gif'>";
224
		$IP_PUB = "-.-.-.-";}
287
		$IP_PUB = "-.-.-.-";}
225
	?></legend>
288
	?></legend>
226
	<table>
289
	<table>
227
		<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
290
		<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
-
 
291
		<?php
-
 
292
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
228
		<tr><td><?php echo $l_ip_dns1." : </td><td>".$conf["DNS1"];?></td></tr>
293
		echo "<tr><td>".$l_ip_dns1." <input style='width:120px' type='text' name='dns1' value=".$conf["DNS1"]."/></td></tr>";
229
		<tr><td><?php echo $l_ip_dns2." : </td><td>".$conf["DNS2"];?></td></tr>
294
		echo "<tr><td>".$l_ip_dns2." <input style='width:120px' type='text' name='dns2' value=".$conf["DNS2"]."/></td></tr>";
-
 
295
		?>
230
	</table>
296
	</table>
231
	</fieldset>
297
	</fieldset>
232
	</td><td>
298
	</td><td>
233
	<fieldset>
299
	<fieldset>
234
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
300
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
235
	<table>
301
	<table>
-
 
302
		<?php
-
 
303
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
236
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PUBLIC_IP"];?></td></tr>
304
		echo "<tr><td>".$l_ip_adr." <input style='width:150px' type='text' name='ip_public' value=".$conf['PUBLIC_IP']."/></td></tr>";
237
		<tr><td><?php echo $l_ip_router." : </td><td>".$conf["GW"];?></td></tr>
305
		echo "<tr><td>".$l_ip_router." <input style='width:120px' type='text' name='ip_gw' value=".$conf['GW']."/></td></tr>";
-
 
306
		?>
238
	</table>
307
	</table>
239
	</fieldset>
308
	</fieldset>
240
	</td><td>
309
	</td><td>
241
	<fieldset>
310
	<fieldset>
242
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
311
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
243
	<table>
312
	<table>
-
 
313
	<?php
-
 
314
	echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
244
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PRIVATE_IP"];?></td></tr>
315
	echo "<tr><td>".$l_ip_adr."</td><td> <input style='width:150px' type='text' name='ip_private' value=".$conf['PRIVATE_IP']." /></td></tr>";
-
 
316
	?>
245
	</table>
317
	</table>
246
	</fieldset>
318
	</fieldset>
247
	</td></tr>
319
	</td></tr>
-
 
320
	<?php 
-
 
321
	echo "<td><input type='submit' value='$l_apply' disabled></td>"; 	
-
 
322
	echo "</form>";
-
 
323
	?>
248
</table>
324
</table>
-
 
325
 
249
<table width="100%" border="0" cellspacing="0" cellpadding="0">
326
<table width="100%" border="0" cellspacing="0" cellpadding="0">
250
	<tr><th><?php echo $l_dhcp_title;?></th></tr>
327
	<tr><th><?php echo $l_dhcp_title;?></th></tr>
251
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
328
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
252
</table>
329
</table>
253
<table width="100%" border=1 cellspacing=0 cellpadding=0>
330
<table width="100%" border=1 cellspacing=0 cellpadding=0>
254
<tr><td colspan="2" valign="middle" align="left">
331
<tr><td colspan="2" valign="middle" align="left">
255
<?
332
<?
256
$dhcp_state=trim($conf["DHCP"]);
333
$dhcp_state=trim($conf["DHCP"]);
257
echo "<CENTER><H3>$l_dhcp_state : ${"l_DHCP_".$dhcp_state}</H3></CENTER>";
334
echo "<CENTER><H3>$l_dhcp_state : ${"l_DHCP_".$dhcp_state}</H3></CENTER>";
258
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
335
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
259
echo "<select name='choix'>";
336
echo "<select name='choix'>";
260
echo "<option value=\"DHCP_Off\" ";if (!strcmp($dhcp_state,"off")) echo "selected";echo ">$l_DHCP_off";
337
echo "<option value=\"DHCP_Off\" ";if (!strcmp($dhcp_state,"off")) echo "selected";echo ">$l_DHCP_off";
261
echo "<option value=\"DHCP_On\" ";if (!strcmp($dhcp_state,"on")) echo "selected";echo ">$l_DHCP_on";
338
echo "<option value=\"DHCP_On\" ";if (!strcmp($dhcp_state,"on")) echo "selected";echo ">$l_DHCP_on";
262
echo "</select>";
339
echo "</select>";
263
echo "<input type=submit value='$l_apply'>";
340
echo "<input type=submit value='$l_apply'>";
264
echo "<br>$l_DHCP_off_explain";
341
echo "<br>$l_DHCP_off_explain";
265
echo "</FORM>";
342
echo "</FORM>";
266
echo "</td></tr>";
343
echo "</td></tr>";
267
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
344
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
268
else { echo "</TABLE>"; }
345
else { echo "</TABLE>"; }
269
$maxsize=100000;
346
$maxsize=100000;
270
?>
347
?>
271
 
348
 
272
<table width="100%" border="0" cellspacing="0" cellpadding="0">
349
<table width="100%" border="0" cellspacing="0" cellpadding="0">
273
	<tr><th><?php echo $l_import_cert;?></th></tr>
350
	<tr><th><?php echo $l_import_cert;?></th></tr>
274
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
351
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
275
</table>
352
</table>
276
<table width="100%" border="1" cellspacing="0" cellpadding="0">
353
<table width="100%" border="1" cellspacing="0" cellpadding="0">
277
	<tr><td>
354
	<tr><td>
278
	<form method="post" action="network.php" enctype="multipart/form-data">
355
	<form method="post" action="network.php" enctype="multipart/form-data">
279
	<?php echo $l_private_key;?><input type="file" name="key"><br>
356
	<?php echo $l_private_key;?><input type="file" name="key"><br>
280
	<?php echo $l_certificate;?><input type="file" name="crt"><br>
357
	<?php echo $l_certificate;?><input type="file" name="crt"><br>
281
	<?php echo $l_server_chain;?><input type="file" name="sc">
358
	<?php echo $l_server_chain;?><input type="file" name="sc">
282
	<input type="hidden" name="MAX_FILE_SIZE" value=<?php echo $maxsize;?>><br>
359
	<input type="hidden" name="MAX_FILE_SIZE" value=<?php echo $maxsize;?>><br>
283
	<input type="submit" <?php echo "value=\"".$l_import."\""?>>
360
	<input type="submit" <?php echo "value=\"".$l_import."\""?>>
284
	</form>
361
	</form>
285
<?php
362
<?php
286
$cert_subject = exec("/bin/openssl x509 -noout -subject -in /etc/pki/tls/certs/alcasar.crt");
363
$cert_subject = exec("/bin/openssl x509 -noout -subject -in /etc/pki/tls/certs/alcasar.crt");
287
$cert_issuer = exec("/bin/openssl x509 -noout -issuer -in /etc/pki/tls/certs/alcasar.crt");
364
$cert_issuer = exec("/bin/openssl x509 -noout -issuer -in /etc/pki/tls/certs/alcasar.crt");
288
$cert_expiration_date = exec("/bin/openssl x509 -noout -dates -in /etc/pki/tls/certs/alcasar.crt|grep After|cut -d\"=\" -f2");
365
$cert_expiration_date = exec("/bin/openssl x509 -noout -dates -in /etc/pki/tls/certs/alcasar.crt|grep After|cut -d\"=\" -f2");
289
$domain = exec("echo $cert_subject | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1");
366
$domain = exec("echo $cert_subject | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1");
290
$organization = exec("echo $cert_subject | sed -n '/^subject/s/^.*O=//p' | cut -d'/' -f 1");
367
$organization = exec("echo $cert_subject | sed -n '/^subject/s/^.*O=//p' | cut -d'/' -f 1");
291
$CAdomain = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*CN=//p' | cut -d'/' -f 1");
368
$CAdomain = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*CN=//p' | cut -d'/' -f 1");
292
$CAorganization = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*O=//p' | cut -d'/' -f 1");
369
$CAorganization = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*O=//p' | cut -d'/' -f 1");
293
 
370
 
294
	echo "<br>";
371
	echo "<br>";
295
	echo "<h3>".$l_current_certificate."</h3>";
372
	echo "<h3>".$l_current_certificate."</h3>";
296
	echo "Expiration Date : ".$cert_expiration_date."<br>";
373
	echo "Expiration Date : ".$cert_expiration_date."<br>";
297
	echo "Common name : ".$domain."<br>";
374
	echo "Common name : ".$domain."<br>";
298
	echo "Organization : ".$organization."<br/>";
375
	echo "Organization : ".$organization."<br/>";
299
	echo "<h4>". $l_validated ."</h4>";
376
	echo "<h4>". $l_validated ."</h4>";
300
	echo "Common name : ".$CAdomain."<br>";
377
	echo "Common name : ".$CAdomain."<br>";
301
	echo "Organization : ".$CAorganization."<br>";
378
	echo "Organization : ".$CAorganization."<br>";
302
?>
379
?>
303
	</td><td>
380
	</td><td>
304
	<form method="post" action="network.php">
381
	<form method="post" action="network.php">
305
	<input type="hidden" name="default">
382
	<input type="hidden" name="default">
306
	<input type="submit" <?php echo "value=\"".$l_default_cert."\""; if(!file_exists("/etc/pki/tls/certs/alcasar.crt.old") || !file_exists("/etc/pki/tls/private/alcasar.key.old")){ echo " disabled";}?>>
383
	<input type="submit" <?php echo "value=\"".$l_default_cert."\""; if(!file_exists("/etc/pki/tls/certs/alcasar.crt.old") || !file_exists("/etc/pki/tls/private/alcasar.key.old")){ echo " disabled";}?>>
307
	</form>
384
	</form>
308
	</td>
385
	</td>
309
	</tr>
386
	</tr>
310
</table>
387
</table>
311
 
388
 
312
</body>
389
</body>
313
</html>
390
</html>
314
 
391
 
315
<?php
392
<?php
316
if(isset($_POST['default'])){
393
if(isset($_POST['default'])){
317
	echo "$l_default_cert";
394
	echo "$l_default_cert";
318
	exec("sudo alcasar-importcert.sh -d");
395
	exec("sudo alcasar-importcert.sh -d");
319
}
396
}
320
if(isset($_POST['MAX_FILE_SIZE'])){
397
if(isset($_POST['MAX_FILE_SIZE'])){
321
	echo "changement";
398
	echo "changement";
322
	$maxsize = 100000;
399
	$maxsize = 100000;
323
	if(isset($_FILES['key']) && isset($_FILES['crt']) && $_FILES['key']['error'] == 0 && $_FILES['crt']['error'] == 0){
400
	if(isset($_FILES['key']) && isset($_FILES['crt']) && $_FILES['key']['error'] == 0 && $_FILES['crt']['error'] == 0){
324
		$dest = "/tmp/";
401
		$dest = "/tmp/";
325
		if($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize)
402
		if($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize)
326
		{
403
		{
327
			if(pathinfo($_FILES['key']['name'])['extension'] == 'key' && pathinfo($_FILES['crt']['name'])['extension'] == 'crt')
404
			if(pathinfo($_FILES['key']['name'])['extension'] == 'key' && pathinfo($_FILES['crt']['name'])['extension'] == 'crt')
328
			{
405
			{
329
				$scpath = "";
406
				$scpath = "";
330
				if(isset($_FILES['sc']) && pathinfo($_FILES['sc']['name'])['extension'] == 'crt')
407
				if(isset($_FILES['sc']) && pathinfo($_FILES['sc']['name'])['extension'] == 'crt')
331
				{
408
				{
332
					$scpath = $dest."server-chain.crt";
409
					$scpath = $dest."server-chain.crt";
333
					move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
410
					move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
334
				}
411
				}
335
				$keypath = $dest."alcasar.key";
412
				$keypath = $dest."alcasar.key";
336
				$crtpath = $dest."alcasar.crt";
413
				$crtpath = $dest."alcasar.crt";
337
				move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
414
				move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
338
				move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
415
				move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
339
				exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
416
				exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
340
			}
417
			}
341
		}
418
		}
342
	}
419
	}
343
}
420
}
344
?>
421
?>
345
 
422