Subversion Repositories ALCASAR

Rev

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

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