Subversion Repositories ALCASAR

Rev

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

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