Subversion Repositories ALCASAR

Rev

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

Rev 1748 Rev 1764
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
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
	fclose($ouvre);
181
	fclose($ouvre);
182
}
182
}
183
 
183
 
184
/************************
184
/************************
185
*	TO DO		*
185
*	TO DO		*
186
*************************/
186
*************************/
187
//modification de la conf réseau  --> V3.0
187
//modification de la conf réseau  --> V3.0
188
 
188
 
189
?>
189
?>
190
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
190
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
191
<html><!-- written by steweb57 & rexy -->
191
<html><!-- written by steweb57 & rexy -->
192
<head>
192
<head>
193
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
193
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
194
<title><?php echo $l_network_title; ?></title>
194
<title><?php echo $l_network_title; ?></title>
195
<link rel="stylesheet" href="/css/style.css" type="text/css">
195
<link rel="stylesheet" href="/css/style.css" type="text/css">
196
<script type="text/javascript">
196
<script type="text/javascript">
197
function MAC_Control(formulaire){
197
function MAC_Control(formulaire){
198
/*MAC control (upper case and '-' separator*/
198
/*MAC control (upper case and '-' separator*/
199
	var regex1 = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/; //vérification adresse mac
199
	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)){
200
	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, '-');
201
		document.forms[formulaire].add_mac.value=document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
202
		return true;
202
		return true;
203
	} else {
203
	} else {
204
		alert("Invalid MAC address");//non internationnalisé
204
		alert("Invalid MAC address");//non internationnalisé
205
		return false;
205
		return false;
206
	}
206
	}
207
}
207
}
208
</script>
208
</script>
209
</head>
209
</head>
210
<body>
210
<body>
211
<table width="100%" border="0" cellspacing="0" cellpadding="0">
211
<table width="100%" border="0" cellspacing="0" cellpadding="0">
212
	<tr><th><?php echo $l_network_title; ?></th></tr>
212
	<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>
213
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
214
</table>
214
</table>
215
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
215
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
216
	<tr><td valign="middle" align="left">
216
	<tr><td valign="middle" align="left">
217
	<fieldset>
217
	<fieldset>
218
	<legend><?php echo $l_internet_legend;
218
	<legend><?php echo $l_internet_legend;
219
 	if (InternetTest()){
219
 	if (InternetTest()){
220
		echo " <img src='/images/state_ok.gif'>";
220
		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");}
221
		$IP_PUB = exec ("wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1");}
222
	else 	{
222
	else 	{
223
		echo " <img src='/images/state_error.gif'>";
223
		echo " <img src='/images/state_error.gif'>";
224
		$IP_PUB = "-.-.-.-";}
224
		$IP_PUB = "-.-.-.-";}
225
	?></legend>
225
	?></legend>
226
	<table>
226
	<table>
227
		<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
227
		<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr>
228
		<tr><td><?php echo $l_ip_dns1." : </td><td>".$conf["DNS1"];?></td></tr>
228
		<tr><td><?php echo $l_ip_dns1." : </td><td>".$conf["DNS1"];?></td></tr>
229
		<tr><td><?php echo $l_ip_dns2." : </td><td>".$conf["DNS2"];?></td></tr>
229
		<tr><td><?php echo $l_ip_dns2." : </td><td>".$conf["DNS2"];?></td></tr>
230
	</table>
230
	</table>
231
	</fieldset>
231
	</fieldset>
232
	</td><td>
232
	</td><td>
233
	<fieldset>
233
	<fieldset>
234
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
234
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
235
	<table>
235
	<table>
236
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PUBLIC_IP"];?></td></tr>
236
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PUBLIC_IP"];?></td></tr>
237
		<tr><td><?php echo $l_ip_router." : </td><td>".$conf["GW"];?></td></tr>
237
		<tr><td><?php echo $l_ip_router." : </td><td>".$conf["GW"];?></td></tr>
238
	</table>
238
	</table>
239
	</fieldset>
239
	</fieldset>
240
	</td><td>
240
	</td><td>
241
	<fieldset>
241
	<fieldset>
242
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
242
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
243
	<table>
243
	<table>
244
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PRIVATE_IP"];?></td></tr>
244
		<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PRIVATE_IP"];?></td></tr>
245
	</table>
245
	</table>
246
	</fieldset>
246
	</fieldset>
247
	</td></tr>
247
	</td></tr>
248
</table>
248
</table>
249
<table width="100%" border="0" cellspacing="0" cellpadding="0">
249
<table width="100%" border="0" cellspacing="0" cellpadding="0">
250
	<tr><th><?php echo $l_dhcp_title;?></th></tr>
250
	<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>
251
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
252
</table>
252
</table>
253
<table width="100%" border=1 cellspacing=0 cellpadding=0>
253
<table width="100%" border=1 cellspacing=0 cellpadding=0>
254
<tr><td colspan="2" valign="middle" align="left">
254
<tr><td colspan="2" valign="middle" align="left">
255
<?
255
<?
256
$dhcp_state=trim($conf["DHCP"]);
256
$dhcp_state=trim($conf["DHCP"]);
257
echo "<CENTER><H3>$l_dhcp_state : ${"l_DHCP_".$dhcp_state}</H3></CENTER>";
257
echo "<CENTER><H3>$l_dhcp_state : ${"l_DHCP_".$dhcp_state}</H3></CENTER>";
258
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
258
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
259
echo "<select name='choix'>";
259
echo "<select name='choix'>";
260
echo "<option value=\"DHCP_Off\" ";if (!strcmp($dhcp_state,"off")) echo "selected";echo ">$l_DHCP_off";
260
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";
261
echo "<option value=\"DHCP_On\" ";if (!strcmp($dhcp_state,"on")) echo "selected";echo ">$l_DHCP_on";
262
echo "</select>";
262
echo "</select>";
263
echo "<input type=submit value='$l_apply'>";
263
echo "<input type=submit value='$l_apply'>";
264
echo "<br>$l_DHCP_off_explain";
264
echo "<br>$l_DHCP_off_explain";
265
echo "</FORM>";
265
echo "</FORM>";
266
echo "</td></tr>";
266
echo "</td></tr>";
267
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
267
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
268
else { echo "</TABLE>"; }
268
else { echo "</TABLE>"; }
269
$maxsize=100000;
269
$maxsize=100000;
270
?>
270
?>
271
 
271
 
272
<table width="100%" border="0" cellspacing="0" cellpadding="0">
272
<table width="100%" border="0" cellspacing="0" cellpadding="0">
273
	<tr><th><?php echo $l_import_cert;?></th></tr>
273
	<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>
274
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
275
</table>
275
</table>
276
<table width="100%" border="1" cellspacing="0" cellpadding="0">
276
<table width="100%" border="1" cellspacing="0" cellpadding="0">
277
	<tr><td>
277
	<tr><td>
278
	<form method="post" action="network.php" enctype="multipart/form-data">
278
	<form method="post" action="network.php" enctype="multipart/form-data">
279
	<?php echo $l_private_key;?><input type="file" name="key"><br>
279
	<?php echo $l_private_key;?><input type="file" name="key"><br>
280
	<?php echo $l_certificate;?><input type="file" name="crt"><br>
280
	<?php echo $l_certificate;?><input type="file" name="crt"><br>
281
	<?php echo $l_server_chain;?><input type="file" name="sc">
281
	<?php echo $l_server_chain;?><input type="file" name="sc">
282
	<input type="hidden" name="MAX_FILE_SIZE" value=<?php echo $maxsize;?>><br>
282
	<input type="hidden" name="MAX_FILE_SIZE" value=<?php echo $maxsize;?>><br>
283
	<input type="submit" <?php echo "value=\"".$l_import."\""?>>
283
	<input type="submit" <?php echo "value=\"".$l_import."\""?>>
284
	</form>
284
	</form>
285
<?php
285
<?php
286
$domain = exec("/bin/openssl x509 -noout -subject -in /etc/pki/tls/certs/alcasar.crt | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1");
286
$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");
287
$organization = exec("/bin/openssl x509 -noout -subject -in /etc/pki/tls/certs/alcasar.crt | sed -n '/^subject/s/^.*O=//p' | cut -d'/' -f 1");
288
$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");
-
 
290
$organization = exec("echo $cert_subject | sed -n '/^subject/s/^.*O=//p' | cut -d'/' -f 1");
288
$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
$CAdomain = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*CN=//p' | cut -d'/' -f 1");
289
$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
$CAorganization = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*O=//p' | cut -d'/' -f 1");
290
 
293
 
291
	echo "<br><br>\n";
294
	echo "<br>";
292
	echo "<h3>".$l_current_certificate."</h3>\n";
295
	echo "<h3>".$l_current_certificate."</h3>";
-
 
296
	echo "Expiration Date : ".$cert_expiration_date."<br>";
293
	echo "Common name : ".$domain."<br>\n";
297
	echo "Common name : ".$domain."<br>";
294
	echo "Organization : ".$organization."<br/>\n";
298
	echo "Organization : ".$organization."<br/>";
295
	echo "<h4>". $l_validated ."</h4>\n";
299
	echo "<h4>". $l_validated ."</h4>";
296
	echo "Common name : ".$CAdomain."<br>\n";
300
	echo "Common name : ".$CAdomain."<br>";
297
	echo "Organization : ".$CAorganization."<br>\n";
301
	echo "Organization : ".$CAorganization."<br>";
298
?>
302
?>
299
	</td><td>
303
	</td><td>
300
	<form method="post" action="network.php">
304
	<form method="post" action="network.php">
301
	<input type="hidden" name="default">
305
	<input type="hidden" name="default">
302
	<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";}?> >
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";}?>>
303
	</form>
307
	</form>
304
	</td>
308
	</td>
305
	</tr>
309
	</tr>
306
</table>
310
</table>
307
 
311
 
308
</body>
312
</body>
309
</html>
313
</html>
310
 
314
 
311
<?php
315
<?php
312
if(isset($_POST['default'])){
316
if(isset($_POST['default'])){
313
	echo "$l_default_cert";
317
	echo "$l_default_cert";
314
	exec("sudo alcasar-importcert.sh -d");
318
	exec("sudo alcasar-importcert.sh -d");
315
}
319
}
316
if(isset($_POST['MAX_FILE_SIZE'])){
320
if(isset($_POST['MAX_FILE_SIZE'])){
317
	echo "changement";
321
	echo "changement";
318
	$maxsize = 100000;
322
	$maxsize = 100000;
319
	if(isset($_FILES['key']) && isset($_FILES['crt']) && $_FILES['key']['error'] == 0 && $_FILES['crt']['error'] == 0){
323
	if(isset($_FILES['key']) && isset($_FILES['crt']) && $_FILES['key']['error'] == 0 && $_FILES['crt']['error'] == 0){
320
		$dest = "/tmp/";
324
		$dest = "/tmp/";
321
		if($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize)
325
		if($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize)
322
		{
326
		{
323
			if(pathinfo($_FILES['key']['name'])['extension'] == 'key' && pathinfo($_FILES['crt']['name'])['extension'] == 'crt')
327
			if(pathinfo($_FILES['key']['name'])['extension'] == 'key' && pathinfo($_FILES['crt']['name'])['extension'] == 'crt')
324
			{
328
			{
325
				$scpath = "";
329
				$scpath = "";
326
				if(isset($_FILES['sc']) && pathinfo($_FILES['sc']['name'])['extension'] == 'crt')
330
				if(isset($_FILES['sc']) && pathinfo($_FILES['sc']['name'])['extension'] == 'crt')
327
				{
331
				{
328
					$scpath = $dest."server-chain.crt";
332
					$scpath = $dest."server-chain.crt";
329
					move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
333
					move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
330
				}
334
				}
331
				$keypath = $dest."alcasar.key";
335
				$keypath = $dest."alcasar.key";
332
				$crtpath = $dest."alcasar.crt";
336
				$crtpath = $dest."alcasar.crt";
333
				move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
337
				move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
334
				move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
338
				move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
335
				exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
339
				exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
336
			}
340
			}
337
		}
341
		}
338
	}
342
	}
339
}
343
}
340
?>
344
?>
341
 
345