Subversion Repositories ALCASAR

Rev

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

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