Subversion Repositories ALCASAR

Rev

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

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