Subversion Repositories ALCASAR

Rev

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

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