Subversion Repositories ALCASAR

Rev

Rev 1959 | Rev 2013 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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