Subversion Repositories ALCASAR

Rev

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

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