Subversion Repositories ALCASAR

Rev

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

Rev 2013 Rev 2016
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
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name");
9
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name");
10
$conf_files=array(CONF_FILE,ETHERS_FILE);
10
$conf_files=array(CONF_FILE,ETHERS_FILE);
11
$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 = '/^(([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])$/';
12
$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
$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]))$/';
13
$network_modification=0;
13
$network_modification=0;
14
foreach ($conf_files as $file){
14
foreach ($conf_files as $file){
15
if (!file_exists($file)){
15
if (!file_exists($file)){
16
	exit("Requested file ".$file." isn't present");}
16
	exit("Requested file ".$file." isn't present");}
17
if (!is_readable($file)){
17
if (!is_readable($file)){
18
	exit("Can't read the file ".$file);}
18
	exit("Can't read the file ".$file);}
19
}
19
}
20
# Choice of language
20
# Choice of language
21
$Language = 'en';
21
$Language = 'en';
22
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
22
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
23
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
23
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
24
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
24
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
25
if($Language == 'fr'){
25
if($Language == 'fr'){
26
	$l_network_title	= "Configuration réseau";
26
	$l_network_title	= "Configuration réseau";
27
	$l_extif_legend		= " (Interface connectée à Internet)";
27
	$l_extif_legend		= " (Interface connectée à Internet)";
28
	$l_intif_legend		= " (Réseau de consultation)";
28
	$l_intif_legend		= " (Réseau de consultation)";
29
	$l_internet_legend	= "INTERNET";
29
	$l_internet_legend	= "INTERNET";
30
	$l_ip_mask		= "Masque";
30
	$l_ip_mask		= "Masque";
31
	$l_ip_router		= "Passerelle";
31
	$l_ip_router		= "Passerelle";
32
	$l_ip_public		= "Adresse IP publique";
32
	$l_ip_public		= "Adresse IP publique";
33
	$l_ip_dns1		= "DNS1";
33
	$l_ip_dns1		= "DNS1";
34
	$l_ip_dns2		= "DNS2";
34
	$l_ip_dns2		= "DNS2";
35
	$l_dhcp_title		= "Service DHCP";
35
	$l_dhcp_title		= "Service DHCP";
36
	$l_dhcp_state		= "Mode actuel";
36
	$l_dhcp_state		= "Mode actuel";
37
	$l_DHCP_on		= "actif";
37
	$l_DHCP_on		= "actif";
38
	$l_DHCP_off		= "inactif";
38
	$l_DHCP_off		= "inactif";
39
	$l_chilliNTP_on		= "actif";
-
 
40
	$l_chilliNTP_off	= "inactif";
-
 
41
	$l_chilliNTP_explain	= "Activer l'option NTP dans les requêtes DHCP de coova-chilli ?<br> si oui, vous devez spécifier l'addresse IP du serveur NTP dans le fichier '/usr/local/etc/alcasar.conf' et changer la valeur de CHILLI_NTP_IP par l'ip de votre serveur NTP. Ensuite rendez le NTP 'actif' et appliquez.";
-
 
42
	$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).";
43
	$l_DHCP_explain		= "Activer le DHCP";
-
 
44
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques";
40
	$l_static_dhcp_title	= "Réservation d'adresses IP statiques";
45
	$l_mac_address		= "Adresse MAC";
41
	$l_mac_address		= "Adresse MAC";
46
	$l_ip_address		= "Adresse IP";
42
	$l_ip_address		= "Adresse IP";
47
	$l_host_name		= "Nom d'hôte";
43
	$l_host_name		= "Nom d'hôte";
48
	$l_del			= "Supprimer de la liste";
44
	$l_del			= "Supprimer de la liste";
49
	$l_add_to_list		= "Ajouter";
45
	$l_add_to_list		= "Ajouter";
50
	$l_apply		= "Appliquer les changements";
46
	$l_apply		= "Appliquer les changements";
51
	$l_local_dns		= "Résolution local de nom";
47
	$l_local_dns		= "Résolution local de nom";
52
	$l_import_cert		= "Import de certificat";
48
	$l_import_cert		= "Import de certificat";
53
	$l_private_key		= "Clé privée (.key) :";
49
	$l_private_key		= "Clé privée (.key) :";
54
	$l_certificate		= "Certificat (.crt) :";
50
	$l_certificate		= "Certificat (.crt) :";
55
	$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) :";
56
	$l_default_cert		= "Revenir au certificat d'origine";
52
	$l_default_cert		= "Revenir au certificat d'origine";
57
	$l_import		= "Importer";
53
	$l_import		= "Importer";
58
	$l_current_certificate  = "Certificat actuel";
54
	$l_current_certificate  = "Certificat actuel";
59
	$l_validated		= "Validé par :";
55
	$l_validated		= "Validé par :";
60
 
56
 
61
} else {
57
} else {
62
	$l_network_title	= "Network configuration";
58
	$l_network_title	= "Network configuration";
63
	$l_extif_legend		= " (Internet connected interface)";
59
	$l_extif_legend		= " (Internet connected interface)";
64
	$l_intif_legend		= " (Private network)";
60
	$l_intif_legend		= " (Private network)";
65
	$l_internet_legend	= "INTERNET";
61
	$l_internet_legend	= "INTERNET";
66
	$l_ip_mask		= "Mask";
62
	$l_ip_mask		= "Mask";
67
	$l_ip_router		= "Gateway";
63
	$l_ip_router		= "Gateway";
68
	$l_ip_public		= "Public IP address";
64
	$l_ip_public		= "Public IP address";
69
	$l_ip_dns1		= "DNS1";
65
	$l_ip_dns1		= "DNS1";
70
	$l_ip_dns2		= "DNS2";
66
	$l_ip_dns2		= "DNS2";
71
	$l_dhcp_title		= "DHCP service";
67
	$l_dhcp_title		= "DHCP service";
72
	$l_dhcp_state		= "Current mode";
68
	$l_dhcp_state		= "Current mode";
73
	$l_DHCP_on		= "enabled";
69
	$l_DHCP_on		= "enabled";
74
	$l_DHCP_off		= "disabled";
70
	$l_DHCP_off		= "disabled";
75
	$l_DHCP_off_explain	= "! Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
71
	$l_DHCP_off_explain	= "! Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)";
76
	$l_DHCP_explain		= "Enable DHCP";
-
 
77
	$l_chilliNTP_on		= "enabled";
-
 
78
	$l_chilliNTP_off	= "disabled";
-
 
79
	$l_chilliNTP_explain	= "Would you like to enable NTP option in DHCP request of coova-chilli?<br> You have to specify IP address of NTP server in this file '/usr/local/etc/alcasar.conf' and change the value of CHILLI_NTP_IP by @IP of NTP server. Then select 'enabled' and 'Apply change'.";
-
 
80
	$l_static_dhcp_title	= "Static IP addresses reservation";
72
	$l_static_dhcp_title	= "Static IP addresses reservation";
81
	$l_mac_address		= "MAC Address";
73
	$l_mac_address		= "MAC Address";
82
	$l_ip_address		= "IP Address";
74
	$l_ip_address		= "IP Address";
83
	$l_host_name		= "Host name";
75
	$l_host_name		= "Host name";
84
	$l_del			= "Delete from list";
76
	$l_del			= "Delete from list";
85
	$l_add_to_list		= "Add";
77
	$l_add_to_list		= "Add";
86
	$l_apply		= "Apply changes";
78
	$l_apply		= "Apply changes";
87
	$l_local_dns		= "Local name resolution";
79
	$l_local_dns		= "Local name resolution";
88
	$l_import_cert		= "Certificate import";
80
	$l_import_cert		= "Certificate import";
89
	$l_private_key		= "Private key (.key) :";
81
	$l_private_key		= "Private key (.key) :";
90
	$l_certificate		= "Certificate (.crt) :";
82
	$l_certificate		= "Certificate (.crt) :";
91
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
83
	$l_server_chain		= "Server-chain (if necessary : .crt) :";
92
	$l_default_cert		= "Back to default certificate";
84
	$l_default_cert		= "Back to default certificate";
93
	$l_import		= "Import";
85
	$l_import		= "Import";
94
	$l_current_certificate  = "Current certificate";
86
	$l_current_certificate  = "Current certificate";
95
	$l_validated		= "Validated by :";
87
	$l_validated		= "Validated by :";
96
 
88
 
97
}
89
}
98
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
90
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
99
switch ($choix)
91
switch ($choix)
100
{
92
{
101
case 'chilliNTP_On' :
-
 
102
	exec ("sudo /usr/local/bin/alcasar-chilli_ntp.sh -on");
-
 
103
	break;
-
 
104
case 'chilliNTP_Off' :
-
 
105
	exec ("sudo /usr/local/bin/alcasar-chilli_ntp.sh -off");
-
 
106
	break;
-
 
107
case 'DHCP_On' :
93
case 'DHCP_On' :
108
	exec ("sudo /usr/local/bin/alcasar-dhcp.sh -on");
94
	exec ("sudo /usr/local/bin/alcasar-dhcp.sh -on");
109
	break;
95
	break;
110
case 'DHCP_Off' :
96
case 'DHCP_Off' :
111
	exec ("sudo /usr/local/bin/alcasar-dhcp.sh -off");
97
	exec ("sudo /usr/local/bin/alcasar-dhcp.sh -off");
112
	break;
98
	break;
113
case 'new_mac' :
99
case 'new_mac' :
114
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
100
	if ((trim($_POST['add_mac']) != "") and (trim($_POST['add_ip']) != ""))
115
		{
101
		{
116
		$tab=file(ETHERS_FILE);
102
		$tab=file(ETHERS_FILE);
117
		if ($tab)  # the file isn't empty
103
		if ($tab)  # the file isn't empty
118
			{
104
			{
119
			$insert="True";
105
			$insert="True";
120
			foreach ($tab as $line)  # verify that MAC or IP address doesn't exist
106
			foreach ($tab as $line)  # verify that MAC or IP address doesn't exist
121
				{
107
				{
122
				$field=explode(" ", $line);
108
				$field=explode(" ", $line);
123
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
109
				$mac_addr=trim($field[0]);$ip_addr=trim($field[1]);
124
				if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0)
110
				if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0)
125
					{
111
					{
126
					$insert="False";
112
					$insert="False";
127
					break;
113
					break;
128
					}
114
					}
129
				if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
115
				if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
130
					{
116
					{
131
					$insert="False";
117
					$insert="False";
132
					break;
118
					break;
133
					}
119
					}
134
				}
120
				}
135
			if ($insert == "True")
121
			if ($insert == "True")
136
				{
122
				{
137
				$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
123
				$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n";
138
				$pointeur=fopen(ETHERS_FILE,"a");
124
				$pointeur=fopen(ETHERS_FILE,"a");
139
				fwrite ($pointeur, $line);
125
				fwrite ($pointeur, $line);
140
				fclose ($pointeur);
126
				fclose ($pointeur);
141
				exec ("sudo /usr/bin/systemctl reload chilli");
127
				exec ("sudo /usr/bin/systemctl reload chilli");
142
				}
128
				}
143
			}
129
			}
144
		}
130
		}
145
	break;
131
	break;
146
case 'del_mac' :
132
case 'del_mac' :
147
	foreach ($_POST as $key => $value)
133
	foreach ($_POST as $key => $value)
148
		{
134
		{
149
		if ($value == 'on')
135
		if ($value == 'on')
150
			{
136
			{
151
			$ether_file=ETHERS_FILE;
137
			$ether_file=ETHERS_FILE;
152
			exec("/bin/sed -i \"/^$key/d\" $ether_file"); 
138
			exec("/bin/sed -i \"/^$key/d\" $ether_file"); 
153
			exec ("sudo /usr/bin/systemctl reload chilli");
139
			exec ("sudo /usr/bin/systemctl reload chilli");
154
			}
140
			}
155
		}
141
		}
156
	break;
142
	break;
157
case 'new_host' :
143
case 'new_host' :
158
	if ((trim($_POST['add_host']) != "") and (trim($_POST['add_ip']) != ""))
144
	if ((trim($_POST['add_host']) != "") and (trim($_POST['add_ip']) != ""))
159
		{
145
		{
160
		$tab=file(DNS_LOCAL_FILE);
146
		$tab=file(DNS_LOCAL_FILE);
161
		$insert="True";
147
		$insert="True";
162
		if ($tab)  # the file isn't empty
148
		if ($tab)  # the file isn't empty
163
			{
149
			{
164
			foreach ($tab as $line)  # verify that host or IP address doesn't exist
150
			foreach ($tab as $line)  # verify that host or IP address doesn't exist
165
				{
151
				{
166
				if (preg_match ('/^address/', $line))
152
				if (preg_match ('/^address/', $line))
167
					{
153
					{
168
					$field=explode("/", $line);
154
					$field=explode("/", $line);
169
					$host_name=trim($field[1]);$ip_addr=trim($field[2]);
155
					$host_name=trim($field[1]);$ip_addr=trim($field[2]);
170
					if (strcasecmp(trim($_POST['add_host']),trim($host_name)) == 0)
156
					if (strcasecmp(trim($_POST['add_host']),trim($host_name)) == 0)
171
						{
157
						{
172
						$insert="False";
158
						$insert="False";
173
						break;
159
						break;
174
						}
160
						}
175
					if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
161
					if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0)
176
						{
162
						{
177
						$insert="False";
163
						$insert="False";
178
						break;
164
						break;
179
						}
165
						}
180
					}
166
					}
181
				}
167
				}
182
			if ($insert == "True")
168
			if ($insert == "True")
183
				{
169
				{
184
				$line1 = "address=/".trim($_POST['add_host'])."/".trim($_POST['add_ip'])."\n";
170
				$line1 = "address=/".trim($_POST['add_host'])."/".trim($_POST['add_ip'])."\n";
185
				$explode_ip=explode('.',trim($_POST['add_ip']));
171
				$explode_ip=explode('.',trim($_POST['add_ip']));
186
				$reverse_ip=implode('.',array_reverse($explode_ip));
172
				$reverse_ip=implode('.',array_reverse($explode_ip));
187
				$line2 = "ptr-record=".$reverse_ip.".in-addr.arpa,".trim($_POST['add_host'])."\n";
173
				$line2 = "ptr-record=".$reverse_ip.".in-addr.arpa,".trim($_POST['add_host'])."\n";
188
				$pointeur=fopen(DNS_LOCAL_FILE,"a");
174
				$pointeur=fopen(DNS_LOCAL_FILE,"a");
189
				fwrite ($pointeur, $line1);
175
				fwrite ($pointeur, $line1);
190
				fwrite ($pointeur, $line2);
176
				fwrite ($pointeur, $line2);
191
				fclose ($pointeur);
177
				fclose ($pointeur);
192
				exec ("sudo /usr/bin/systemctl restart dnsmasq");
178
				exec ("sudo /usr/bin/systemctl restart dnsmasq");
193
				exec ("sudo /usr/bin/systemctl restart dnsmasq-blacklist");
179
				exec ("sudo /usr/bin/systemctl restart dnsmasq-blacklist");
194
				exec ("sudo /usr/bin/systemctl restart dnsmasq-whitelist");
180
				exec ("sudo /usr/bin/systemctl restart dnsmasq-whitelist");
195
				}
181
				}
196
			}
182
			}
197
		}
183
		}
198
	break;
184
	break;
199
case 'del_host' :
185
case 'del_host' :
200
	foreach ($_POST as $key => $value)
186
	foreach ($_POST as $key => $value)
201
		{
187
		{
202
		if ($value == 'on')
188
		if ($value == 'on')
203
			{
189
			{
204
			$dns_local_file=DNS_LOCAL_FILE;
190
			$dns_local_file=DNS_LOCAL_FILE;
205
			exec("/bin/sed -i \"/$key/d\" $dns_local_file"); 
191
			exec("/bin/sed -i \"/$key/d\" $dns_local_file"); 
206
			exec ("sudo /usr/bin/systemctl restart dnsmasq");
192
			exec ("sudo /usr/bin/systemctl restart dnsmasq");
207
			exec ("sudo /usr/bin/systemctl restart dnsmasq-blacklist");
193
			exec ("sudo /usr/bin/systemctl restart dnsmasq-blacklist");
208
			exec ("sudo /usr/bin/systemctl restart dnsmasq-whitelist");
194
			exec ("sudo /usr/bin/systemctl restart dnsmasq-whitelist");
209
			}
195
			}
210
		}
196
		}
211
	break;
197
	break;
212
}
198
}
213
 
199
 
214
// Fonction de test de connectivité internet
200
// Fonction de test de connectivité internet
215
function internetTest(){
201
function internetTest(){
216
	$host = "www.google.fr"; # Google Test
202
	$host = "www.google.fr"; # Google Test
217
	$port = "80";
203
	$port = "80";
218
	//var $num;	//not used
204
	//var $num;	//not used
219
	//var $error;	//not used
205
	//var $error;	//not used
220
 
206
 
221
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
207
	if (! $sock = @fsockopen($host, $port, $num, $error, 5)) {
222
		return false;
208
		return false;
223
	} else {
209
	} else {
224
		fclose($sock);
210
		fclose($sock);
225
		return true;
211
		return true;
226
	}
212
	}
227
}
213
}
228
/***********************************
214
/***********************************
229
* 	Update ALCASAR_CONF_FILE   *
215
* 	Update ALCASAR_CONF_FILE   *
230
***********************************/
216
***********************************/
231
/*******************************************
217
/*******************************************
232
*	Read ALCASAR_CONF_FILE Before     *
218
*	Read ALCASAR_CONF_FILE Before     *
233
********************************************/
219
********************************************/
234
$ouvre=fopen(CONF_FILE,"r");
220
$ouvre=fopen(CONF_FILE,"r");
235
if ($ouvre){
221
if ($ouvre){
236
	while (!feof ($ouvre))
222
	while (!feof ($ouvre))
237
	{
223
	{
238
		$tampon = fgets($ouvre, 4096);
224
		$tampon = fgets($ouvre, 4096);
239
		if (strpos($tampon,"=")!==false){
225
		if (strpos($tampon,"=")!==false){
240
			$tmp = explode("=",$tampon);
226
			$tmp = explode("=",$tampon);
241
			$conf[$tmp[0]] = $tmp[1];
227
			$conf[$tmp[0]] = $tmp[1];
242
		}
228
		}
243
	}
229
	}
244
	fclose($ouvre);
230
	fclose($ouvre);
245
}
231
}
246
	
232
	
247
if(isset($_POST['dns1']) && preg_match($reg_ip,$_POST['dns1']))
233
if(isset($_POST['dns1']) && preg_match($reg_ip,$_POST['dns1']))
248
{
234
{
249
	file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'],'DNS1='.$_POST['dns1']."\n",file_get_contents(CONF_FILE)));
235
	file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'],'DNS1='.$_POST['dns1']."\n",file_get_contents(CONF_FILE)));
250
	$network_modification=1;
236
	$network_modification=1;
251
}
237
}
252
if(isset($_POST['dns2']) && preg_match($reg_ip,$_POST['dns2']))
238
if(isset($_POST['dns2']) && preg_match($reg_ip,$_POST['dns2']))
253
{
239
{
254
	file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'],'DNS2='.$_POST['dns2']."\n",file_get_contents(CONF_FILE)));
240
	file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'],'DNS2='.$_POST['dns2']."\n",file_get_contents(CONF_FILE)));
255
	$network_modification=1;
241
	$network_modification=1;
256
}
242
}
257
 
243
 
258
if(isset($_POST['ip_public']) && preg_match($reg_ip_cidr,$_POST['ip_public']))
244
if(isset($_POST['ip_public']) && preg_match($reg_ip_cidr,$_POST['ip_public']))
259
{
245
{
260
	file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'],'PUBLIC_IP='.$_POST['ip_public']."\n",file_get_contents(CONF_FILE)));
246
	file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'],'PUBLIC_IP='.$_POST['ip_public']."\n",file_get_contents(CONF_FILE)));
261
	$network_modification=1;
247
	$network_modification=1;
262
}
248
}
263
 
249
 
264
if(isset($_POST['ip_gw']) && preg_match($reg_ip,$_POST['ip_gw']))
250
if(isset($_POST['ip_gw']) && preg_match($reg_ip,$_POST['ip_gw']))
265
{
251
{
266
	file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'],'GW='.$_POST['ip_gw']."\n",file_get_contents(CONF_FILE)));
252
	file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'],'GW='.$_POST['ip_gw']."\n",file_get_contents(CONF_FILE)));
267
	$network_modification=1;
253
	$network_modification=1;
268
}
254
}
269
 
255
 
270
if(isset($_POST['ip_private']) && preg_match($reg_ip_cidr,$_POST['ip_private']))
256
if(isset($_POST['ip_private']) && preg_match($reg_ip_cidr,$_POST['ip_private']))
271
{
257
{
272
	file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'],'PRIVATE_IP='.$_POST['ip_private']."\n",file_get_contents(CONF_FILE)));
258
	file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'],'PRIVATE_IP='.$_POST['ip_private']."\n",file_get_contents(CONF_FILE)));
273
	$network_modification=1;
259
	$network_modification=1;
274
}
260
}
275
if($network_modification)
261
if($network_modification)
276
{
262
{
277
	exec("sudo /usr/local/bin/alcasar-conf.sh -apply");
263
	exec("sudo /usr/local/bin/alcasar-conf.sh -apply");
278
}
264
}
279
 
265
 
280
/*******************************************
266
/*******************************************
281
*	Read ALCASAR_CONF_FILE Updated     *
267
*	Read ALCASAR_CONF_FILE Updated     *
282
********************************************/
268
********************************************/
283
$ouvre=fopen(CONF_FILE,"r");
269
$ouvre=fopen(CONF_FILE,"r");
284
if ($ouvre){
270
if ($ouvre){
285
	while (!feof ($ouvre))
271
	while (!feof ($ouvre))
286
	{
272
	{
287
		$tampon = fgets($ouvre, 4096);
273
		$tampon = fgets($ouvre, 4096);
288
		if (strpos($tampon,"=")!==false){
274
		if (strpos($tampon,"=")!==false){
289
			$tmp = explode("=",$tampon);
275
			$tmp = explode("=",$tampon);
290
			$conf[$tmp[0]] = $tmp[1];
276
			$conf[$tmp[0]] = $tmp[1];
291
		}
277
		}
292
	}
278
	}
293
	fclose($ouvre);
279
	fclose($ouvre);
294
}
280
}
295
?>
281
?>
296
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
282
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
297
<html><!-- written by steweb57 & rexy -->
283
<html><!-- written by steweb57 & rexy -->
298
<head>
284
<head>
299
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
285
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
300
<title><?php echo $l_network_title; ?></title>
286
<title><?php echo $l_network_title; ?></title>
301
<link rel="stylesheet" href="/css/style.css" type="text/css">
287
<link rel="stylesheet" href="/css/style.css" type="text/css">
302
<script type="text/javascript">
288
<script type="text/javascript">
303
function MAC_Control(formulaire){
289
function MAC_Control(formulaire){
304
/*MAC control (upper case and '-' separator*/
290
/*MAC control (upper case and '-' separator*/
305
	var regex1 = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/; //vérification adresse mac
291
	var regex1 = /^([0-9a-fA-F]{2}(-|:)){5}[0-9a-fA-F]{2}$/; //vérification adresse mac
306
	if (regex1.test(document.forms[formulaire].add_mac.value)){
292
	if (regex1.test(document.forms[formulaire].add_mac.value)){
307
		document.forms[formulaire].add_mac.value=document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
293
		document.forms[formulaire].add_mac.value=document.forms[formulaire].add_mac.value.toUpperCase().replace(/:/g, '-');
308
		return true;
294
		return true;
309
	} else {
295
	} else {
310
		alert("Invalid MAC address");//non internationnalisé
296
		alert("Invalid MAC address");//non internationnalisé
311
		return false;
297
		return false;
312
	}
298
	}
313
}
299
}
314
</script>
300
</script>
315
</head>
301
</head>
316
<body>
302
<body>
317
<table width="100%" border="0" cellspacing="0" cellpadding="0">
303
<table width="100%" border="0" cellspacing="0" cellpadding="0">
318
	<tr><th><?php echo $l_network_title; ?></th></tr>
304
	<tr><th><?php echo $l_network_title; ?></th></tr>
319
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
305
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
320
</table>
306
</table>
321
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
307
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
322
	<tr><td valign="middle" align="left">
308
	<tr><td valign="middle" align="left">
323
	<fieldset>
309
	<fieldset>
324
	<legend><?php echo $l_internet_legend;
310
	<legend><?php echo $l_internet_legend;
325
 	if (InternetTest()){
311
 	if (InternetTest()){
326
		echo " <img src='/images/state_ok.gif'>";
312
		echo " <img src='/images/state_ok.gif'>";
327
		$IP_PUB = exec ("wget http://ipecho.net/plain -O - -o /dev/null");}
313
		$IP_PUB = exec ("wget http://ipecho.net/plain -O - -o /dev/null");}
328
	else 	{
314
	else 	{
329
		echo " <img src='/images/state_error.gif'>";
315
		echo " <img src='/images/state_error.gif'>";
330
		$IP_PUB = "-.-.-.-";}
316
		$IP_PUB = "-.-.-.-";}
331
	?></legend>
317
	?></legend>
332
	<table>
318
	<table>
333
		<tr><td><?php echo $l_ip_public." : ".$IP_PUB;?></td></tr>
319
		<tr><td><?php echo $l_ip_public." : ".$IP_PUB;?></td></tr>
334
		<?php
320
		<?php
335
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
321
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
336
		echo "<tr><td>".$l_ip_dns1." <input style='width:120px' type='text' name='dns1' value=".$conf["DNS1"]."/></td></tr>";
322
		echo "<tr><td>".$l_ip_dns1." <input style='width:120px' type='text' name='dns1' value=".$conf["DNS1"]."/></td></tr>";
337
		echo "<tr><td>".$l_ip_dns2." <input style='width:120px' type='text' name='dns2' value=".$conf["DNS2"]."/></td></tr>";
323
		echo "<tr><td>".$l_ip_dns2." <input style='width:120px' type='text' name='dns2' value=".$conf["DNS2"]."/></td></tr>";
338
		?>
324
		?>
339
	</table>
325
	</table>
340
	</fieldset>
326
	</fieldset>
341
	</td><td>
327
	</td><td>
342
	<fieldset>
328
	<fieldset>
343
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
329
	<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend>
344
	<table>
330
	<table>
345
		<?php
331
		<?php
346
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
332
		echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
347
		echo "<tr><td>".$l_ip_address." <input style='width:150px' type='text' name='ip_public' value=".$conf['PUBLIC_IP']."/></td></tr>";
333
		echo "<tr><td>".$l_ip_address." <input style='width:150px' type='text' name='ip_public' value=".$conf['PUBLIC_IP']."/></td></tr>";
348
		echo "<tr><td>".$l_ip_router." <input style='width:120px' type='text' name='ip_gw' value=".$conf['GW']."/></td></tr>";
334
		echo "<tr><td>".$l_ip_router." <input style='width:120px' type='text' name='ip_gw' value=".$conf['GW']."/></td></tr>";
349
		?>
335
		?>
350
	</table>
336
	</table>
351
	</fieldset>
337
	</fieldset>
352
	</td><td>
338
	</td><td>
353
	<fieldset>
339
	<fieldset>
354
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
340
	<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend>
355
	<table>
341
	<table>
356
	<?php
342
	<?php
357
	echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
343
	echo "<form action=".$_SERVER['PHP_SELF']." method='post'>";
358
	echo "<tr><td>".$l_ip_address."</td><td> <input style='width:150px' type='text' name='ip_private' value=".$conf['PRIVATE_IP']." /></td></tr>";
344
	echo "<tr><td>".$l_ip_address."</td><td> <input style='width:150px' type='text' name='ip_private' value=".$conf['PRIVATE_IP']." /></td></tr>";
359
	?>
345
	?>
360
	</table>
346
	</table>
361
	</fieldset>
347
	</fieldset>
362
	</td></tr>
348
	</td></tr>
363
	<?php 
349
	<?php 
364
	echo "<td><input type='submit' value='$l_apply' ></td>"; 	
350
	echo "<td><input type='submit' value='$l_apply' ></td>"; 	
365
	echo "</form>";
351
	echo "</form>";
366
	?>
352
	?>
367
</table>
353
</table>
368
<table width="100%" border="0" cellspacing="0" cellpadding="0">
354
<table width="100%" border="0" cellspacing="0" cellpadding="0">
369
	<tr><th><?php echo $l_dhcp_title;?></th></tr>
355
	<tr><th><?php echo $l_dhcp_title;?></th></tr>
370
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
356
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
371
</table>
357
</table>
372
<table width="100%" border=1 cellspacing=0 cellpadding=0>
358
<table width="100%" border=1 cellspacing=0 cellpadding=0>
373
<tr><td colspan="2" valign="middle" align="left">
359
<tr><td colspan="2" valign="middle" align="left">
374
<?
360
<?
375
$dhcp_state=trim($conf["DHCP"]);
361
$dhcp_state=trim($conf["DHCP"]);
376
echo "<CENTER><H3>$l_dhcp_state : ${"l_DHCP_".$dhcp_state}</H3></CENTER>";
362
echo "<CENTER><H3>$l_dhcp_state : ${"l_DHCP_".$dhcp_state}</H3></CENTER>";
377
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
363
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
378
echo "<br><b>$l_DHCP_explain : </b><br>";
-
 
379
echo "<select name='choix'>";
364
echo "<select name='choix'>";
380
echo "<option value=\"DHCP_Off\" ";if (!strcmp($dhcp_state,"off")) echo "selected";echo ">$l_DHCP_off";
365
echo "<option value=\"DHCP_Off\" ";if (!strcmp($dhcp_state,"off")) echo "selected";echo ">$l_DHCP_off";
381
echo "<option value=\"DHCP_On\" ";if (!strcmp($dhcp_state,"on")) echo "selected";echo ">$l_DHCP_on";
366
echo "<option value=\"DHCP_On\" ";if (!strcmp($dhcp_state,"on")) echo "selected";echo ">$l_DHCP_on";
382
echo "</select>";
367
echo "</select>";
-
 
368
echo "<input type=submit value='$l_apply'>";
-
 
369
echo "<br>$l_DHCP_off_explain";
383
 
370
 
384
echo "<br>$l_DHCP_off_explain<br>";
-
 
385
 
-
 
386
//DHCP option NTP (as known as 'option 42') with coovachilli
-
 
387
if (!strcmp($dhcp_state,"on"))
-
 
388
{
-
 
389
$chilliNTP_state=trim($conf["CHILLI_NTP_ENABLED"]);
-
 
390
echo "<br><b>$l_chilliNTP_explain : </b><br>";
-
 
391
echo "<select name='chilliNTP_choix'>";
-
 
392
echo "<option value=\"chilliNTP_Off\" ";if (!strcmp($chilliNTP_state,"off")) echo "selected";echo ">$l_chilliNTP_off";
-
 
393
echo "<option value=\"chilliNTP_On\" ";if (!strcmp($chilliNTP_state,"on")) echo "selected";echo ">$l_chilliNTP_on";
-
 
394
echo "</select>";
-
 
395
}
-
 
396
 
-
 
397
echo "<br><br><input type=submit value='$l_apply'>";
-
 
398
echo "</FORM>";
371
echo "</FORM>";
399
echo "</td></tr>";
372
echo "</td></tr>";
400
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
373
if (strncmp($conf["DHCP"],"on",2) == 0) { require ('network2.php');}
401
else { echo "</TABLE>"; }
374
else { echo "</TABLE>"; }
402
$maxsize=100000;
375
$maxsize=100000;
403
?>
376
?>
404
 
377
 
405
<table width="100%" border="0" cellspacing="0" cellpadding="0">
378
<table width="100%" border="0" cellspacing="0" cellpadding="0">
406
	<tr><th><?php echo $l_local_dns;?></th></tr>
379
	<tr><th><?php echo $l_local_dns;?></th></tr>
407
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
380
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
408
</table>
381
</table>
409
<table width="100%" border="1" cellspacing="0" cellpadding="0">
382
<table width="100%" border="1" cellspacing="0" cellpadding="0">
410
<tr><td colspan=2 align="center">
383
<tr><td colspan=2 align="center">
411
<?
384
<?
412
echo "<FORM action='network.php' method='POST'>";
385
echo "<FORM action='network.php' method='POST'>";
413
echo "<table cellspacing=2 cellpadding=3 border=1>";
386
echo "<table cellspacing=2 cellpadding=3 border=1>";
414
echo "<tr><th>$l_host_name<th>$l_ip_address<th>$l_del</tr>";
387
echo "<tr><th>$l_host_name<th>$l_ip_address<th>$l_del</tr>";
415
// Read the "dns_local" file
388
// Read the "dns_local" file
416
$line_exist=False;
389
$line_exist=False;
417
$tab=file(DNS_LOCAL_FILE);
390
$tab=file(DNS_LOCAL_FILE);
418
if ($tab)  # not empty
391
if ($tab)  # not empty
419
	{
392
	{
420
	foreach ($tab as $line)
393
	foreach ($tab as $line)
421
		{
394
		{
422
			if (preg_match ('/^address/', $line))
395
			if (preg_match ('/^address/', $line))
423
			{
396
			{
424
				$line_exist=True;
397
				$line_exist=True;
425
				$field=explode("/", $line);
398
				$field=explode("/", $line);
426
				$host_name=$field[1];
399
				$host_name=$field[1];
427
				$ip_addr=$field[2];
400
				$ip_addr=$field[2];
428
				echo "<tr><td>$host_name";
401
				echo "<tr><td>$host_name";
429
				echo "<td>$ip_addr";
402
				echo "<td>$ip_addr";
430
				echo "<td><input type='checkbox' name='$host_name'>";
403
				echo "<td><input type='checkbox' name='$host_name'>";
431
				echo "</tr>";
404
				echo "</tr>";
432
			}
405
			}
433
		}
406
		}
434
	}
407
	}
435
echo "</table>";
408
echo "</table>";
436
if ($line_exist)
409
if ($line_exist)
437
	{
410
	{
438
	echo "<input type='hidden' name='choix' value='del_host'>";
411
	echo "<input type='hidden' name='choix' value='del_host'>";
439
	echo "<input type='submit' value='$l_apply'>";
412
	echo "<input type='submit' value='$l_apply'>";
440
	}	
413
	}	
441
echo "</form></td><td valign='middle' align='center'>";
414
echo "</form></td><td valign='middle' align='center'>";
442
echo "<FORM name='new_host' action='network.php' method='POST'>";
415
echo "<FORM name='new_host' action='network.php' method='POST'>";
443
echo "<table cellspacing=2 cellpadding=3 border=1>";
416
echo "<table cellspacing=2 cellpadding=3 border=1>";
444
echo "<tr><th>$l_host_name<th>$l_ip_address";
417
echo "<tr><th>$l_host_name<th>$l_ip_address";
445
?>
418
?>
446
<td></td></tr>
419
<td></td></tr>
447
<tr><td>exemple : my_nas</td><td>exemple : 192.168.182.10</td><td></td></tr>
420
<tr><td>exemple : my_nas</td><td>exemple : 192.168.182.10</td><td></td></tr>
448
<tr><td><input type='text' name='add_host' size='17'></td>
421
<tr><td><input type='text' name='add_host' size='17'></td>
449
<td><input type='text' name='add_ip' size='10'><input type='hidden' name='choix' value='new_host'></td>
422
<td><input type='text' name='add_ip' size='10'><input type='hidden' name='choix' value='new_host'></td>
450
<td><? echo "<input type=submit class=button value=\"$l_add_to_list\">"?></td>
423
<td><? echo "<input type=submit class=button value=\"$l_add_to_list\">"?></td>
451
</tr></table>
424
</tr></table>
452
</form>
425
</form>
453
</td></tr>
426
</td></tr>
454
</table>
427
</table>
455
<table width="100%" border="0" cellspacing="0" cellpadding="0">
428
<table width="100%" border="0" cellspacing="0" cellpadding="0">
456
	<tr><th><?php echo $l_import_cert;?></th></tr>
429
	<tr><th><?php echo $l_import_cert;?></th></tr>
457
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
430
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
458
</table>
431
</table>
459
<table width="100%" border="1" cellspacing="0" cellpadding="0">
432
<table width="100%" border="1" cellspacing="0" cellpadding="0">
460
	<tr><td>
433
	<tr><td>
461
	<form method="post" action="network.php" enctype="multipart/form-data">
434
	<form method="post" action="network.php" enctype="multipart/form-data">
462
	<?php echo $l_private_key;?><input type="file" name="key"><br>
435
	<?php echo $l_private_key;?><input type="file" name="key"><br>
463
	<?php echo $l_certificate;?><input type="file" name="crt"><br>
436
	<?php echo $l_certificate;?><input type="file" name="crt"><br>
464
	<?php echo $l_server_chain;?><input type="file" name="sc">
437
	<?php echo $l_server_chain;?><input type="file" name="sc">
465
	<input type="hidden" name="MAX_FILE_SIZE" value=<?php echo $maxsize;?>><br>
438
	<input type="hidden" name="MAX_FILE_SIZE" value=<?php echo $maxsize;?>><br>
466
	<input type="submit" <?php echo "value=\"".$l_import."\""?>>
439
	<input type="submit" <?php echo "value=\"".$l_import."\""?>>
467
	</form>
440
	</form>
468
<?php
441
<?php
469
$cert_subject = exec("/bin/openssl x509 -noout -subject -in /etc/pki/tls/certs/alcasar.crt");
442
$cert_subject = exec("/bin/openssl x509 -noout -subject -in /etc/pki/tls/certs/alcasar.crt");
470
$cert_issuer = exec("/bin/openssl x509 -noout -issuer -in /etc/pki/tls/certs/alcasar.crt");
443
$cert_issuer = exec("/bin/openssl x509 -noout -issuer -in /etc/pki/tls/certs/alcasar.crt");
471
$cert_expiration_date = exec("/bin/openssl x509 -noout -dates -in /etc/pki/tls/certs/alcasar.crt|grep After|cut -d\"=\" -f2");
444
$cert_expiration_date = exec("/bin/openssl x509 -noout -dates -in /etc/pki/tls/certs/alcasar.crt|grep After|cut -d\"=\" -f2");
472
$domain = exec("echo $cert_subject | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1");
445
$domain = exec("echo $cert_subject | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1");
473
$organization = exec("echo $cert_subject | sed -n '/^subject/s/^.*O=//p' | cut -d'/' -f 1");
446
$organization = exec("echo $cert_subject | sed -n '/^subject/s/^.*O=//p' | cut -d'/' -f 1");
474
$CAdomain = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*CN=//p' | cut -d'/' -f 1");
447
$CAdomain = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*CN=//p' | cut -d'/' -f 1");
475
$CAorganization = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*O=//p' | cut -d'/' -f 1");
448
$CAorganization = exec("echo $cert_issuer | sed -n '/^issuer/s/^.*O=//p' | cut -d'/' -f 1");
476
 
449
 
477
	echo "<br>";
450
	echo "<br>";
478
	echo "<h3>".$l_current_certificate."</h3>";
451
	echo "<h3>".$l_current_certificate."</h3>";
479
	echo "Expiration Date : ".$cert_expiration_date."<br>";
452
	echo "Expiration Date : ".$cert_expiration_date."<br>";
480
	echo "Common name : ".$domain."<br>";
453
	echo "Common name : ".$domain."<br>";
481
	echo "Organization : ".$organization."<br/>";
454
	echo "Organization : ".$organization."<br/>";
482
	echo "<h4>". $l_validated ."</h4>";
455
	echo "<h4>". $l_validated ."</h4>";
483
	echo "Common name : ".$CAdomain."<br>";
456
	echo "Common name : ".$CAdomain."<br>";
484
	echo "Organization : ".$CAorganization."<br>";
457
	echo "Organization : ".$CAorganization."<br>";
485
?>
458
?>
486
	</td><td>
459
	</td><td>
487
	<form method="post" action="network.php">
460
	<form method="post" action="network.php">
488
	<input type="hidden" name="default">
461
	<input type="hidden" name="default">
489
	<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";}?>>
462
	<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";}?>>
490
	</form>
463
	</form>
491
	</td>
464
	</td>
492
	</tr>
465
	</tr>
493
</table>
466
</table>
494
</body>
467
</body>
495
</html>
468
</html>
496
 
469
 
497
<?php
470
<?php
498
if(isset($_POST['default'])){
471
if(isset($_POST['default'])){
499
	echo "$l_default_cert";
472
	echo "$l_default_cert";
500
	exec("sudo alcasar-importcert.sh -d");
473
	exec("sudo alcasar-importcert.sh -d");
501
}
474
}
502
if(isset($_POST['MAX_FILE_SIZE'])){
475
if(isset($_POST['MAX_FILE_SIZE'])){
503
	echo "changement";
476
	echo "changement";
504
	$maxsize = 100000;
477
	$maxsize = 100000;
505
	if(isset($_FILES['key']) && isset($_FILES['crt']) && $_FILES['key']['error'] == 0 && $_FILES['crt']['error'] == 0){
478
	if(isset($_FILES['key']) && isset($_FILES['crt']) && $_FILES['key']['error'] == 0 && $_FILES['crt']['error'] == 0){
506
		$dest = "/tmp/";
479
		$dest = "/tmp/";
507
		if($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize)
480
		if($_FILES['key']['size'] <= $maxsize && $_FILES['crt']['size'] <= $maxsize)
508
		{
481
		{
509
			if(pathinfo($_FILES['key']['name'])['extension'] == 'key' && pathinfo($_FILES['crt']['name'])['extension'] == 'crt')
482
			if(pathinfo($_FILES['key']['name'])['extension'] == 'key' && pathinfo($_FILES['crt']['name'])['extension'] == 'crt')
510
			{
483
			{
511
				$scpath = "";
484
				$scpath = "";
512
				if(isset($_FILES['sc']) && pathinfo($_FILES['sc']['name'])['extension'] == 'crt')
485
				if(isset($_FILES['sc']) && pathinfo($_FILES['sc']['name'])['extension'] == 'crt')
513
				{
486
				{
514
					$scpath = $dest."server-chain.crt";
487
					$scpath = $dest."server-chain.crt";
515
					move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
488
					move_uploaded_file($_FILES['sc']['tmp_name'], $scpath);
516
				}
489
				}
517
				$keypath = $dest."alcasar.key";
490
				$keypath = $dest."alcasar.key";
518
				$crtpath = $dest."alcasar.crt";
491
				$crtpath = $dest."alcasar.crt";
519
				move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
492
				move_uploaded_file($_FILES['key']['tmp_name'], $keypath);
520
				move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
493
				move_uploaded_file($_FILES['crt']['tmp_name'], $crtpath);
521
				exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
494
				exec("sudo alcasar-importcert.sh -i $crtpath -k $keypath -c $scpath");
522
			}
495
			}
523
		}
496
		}
524
	}
497
	}
525
}
498
}
526
?>
499
?>
527
 
500
 
528
 
501