Project

General

Profile

« Previous | Next » 

Revision 78863416

Added by Phil Davis over 9 years ago

Code style System Certificates

View differences:

src/usr/local/www/system_certmanager.php
248 248

  
249 249
if ($_POST) {
250 250
	// This is just the blank altername name that is added for display purposes. We don't want to validate/save it
251
	if($_POST['altname_value0'] == "") {
251
	if ($_POST['altname_value0'] == "") {
252 252
		unset($_POST['altname_type0']);
253 253
		unset($_POST['altname_value0']);
254 254
	}
......
317 317
				if (!substr_compare('altname_type', $key, 0, 12)) {
318 318
					$entry = substr($key, 12);
319 319
					$field = 'type';
320
				}
321
				elseif (!substr_compare('altname_value', $key, 0, 13)) {
320
				} elseif (!substr_compare('altname_value', $key, 0, 13)) {
322 321
					$entry = substr($key, 13);
323 322
					$field = 'value';
324 323
				}
......
507 506
		/* input validation */
508 507
		$reqdfields = explode(" ", "descr cert");
509 508
		$reqdfieldsn = array(
510
		gettext("Descriptive name"),
511
		gettext("Final Certificate data"));
509
			gettext("Descriptive name"),
510
			gettext("Final Certificate data"));
512 511

  
513 512
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
514 513

  
......
562 561

  
563 562
include("head.inc");
564 563

  
565
if ($input_errors)
564
if ($input_errors) {
566 565
	print_input_errors($input_errors);
566
}
567 567

  
568
if ($savemsg)
568
if ($savemsg) {
569 569
	print_info_box($savemsg, 'success');
570
}
570 571

  
571 572
$tab_array = array();
572 573
$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
......
576 577

  
577 578
// Load valid country codes
578 579
$dn_cc = array();
579
if (file_exists("/etc/ca_countries")){
580
if (file_exists("/etc/ca_countries")) {
580 581
	$dn_cc_file=file("/etc/ca_countries");
581
	foreach($dn_cc_file as $line) {
582
	foreach ($dn_cc_file as $line) {
582 583
		if (preg_match('/^(\S*)\s(.*)$/', $line, $matches)) {
583 584
			$dn_cc[$matches[1]] = $matches[1];
584 585
		}
......
588 589
if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)) {
589 590
$form = new Form;
590 591

  
591
if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors))
592
{
592
if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)) {
593 593
	$form->setAction('system_certmanager.php?act=csr');
594 594

  
595 595
	$section = new Form_Section('Complete Signing Request');
596 596

  
597
	if (isset($id) && $a_cert[$id])
598
	{
597
	if (isset($id) && $a_cert[$id]) {
599 598
		$form->addGlobal(new Form_Input(
600 599
			'id',
601 600
			null,
......
621 620
	$section->addInput(new Form_Textarea(
622 621
		'cert',
623 622
		'Final certificate data',
624
		$pconfig["cert"]
623
		$pconfig['cert']
625 624
	))->setHelp('Paste the certificate received from your certificate authority here.');
626 625

  
627 626
	$form->add($section);
......
633 632

  
634 633
$form->setAction('system_certmanager.php?act=edit');
635 634

  
636
if (isset($userid) && $a_user)
637
{
635
if (isset($userid) && $a_user) {
638 636
	$form->addGlobal(new Form_Input(
639 637
		'userid',
640 638
		null,
......
643 641
	));
644 642
}
645 643

  
646
if (isset($id) && $a_cert[$id])
647
{
644
if (isset($id) && $a_cert[$id]) {
648 645
	$form->addGlobal(new Form_Input(
649 646
		'id',
650 647
		null,
......
655 652

  
656 653
$section = new Form_Section('Add a new certificate');
657 654

  
658
if (!isset($id))
659
{
655
if (!isset($id)) {
660 656
	$section->addInput(new Form_Select(
661 657
		'method',
662 658
		'Method',
......
692 688
$section = new Form_Section('Internal Certificate');
693 689
$section->addClass('toggle-internal collapse');
694 690

  
695
if (!$internal_ca_count)
696
{
691
if (!$internal_ca_count) {
697 692
	$section->addInput(new Form_StaticText(
698 693
		'Certificate authority',
699 694
		gettext('No internal Certificate Authorities have been defined. You must ').
700 695
		'<a href="system_camanager.php?act=new&amp;method=internal"> '. gettext(" create") .'</a>'.
701 696
		gettext(' an internal CA before creating an internal certificate.')
702 697
	));
703
}
704
else
705
{
698
} else {
706 699
	$allCas = array();
707
	foreach ($a_ca as $ca)
708
	{
709
		if (!$ca['prv'])
710
				continue;
700
	foreach ($a_ca as $ca) {
701
		if (!$ca['prv']) {
702
			continue;
703
		}
711 704

  
712 705
		$allCas[ $ca['refid'] ] = $ca['descr'];
713 706
	}
......
797 790
	['placeholder' => 'e.g. www.example.com']
798 791
));
799 792

  
800
if (empty($pconfig['altnames']['item']))
801
{
793
if (empty($pconfig['altnames']['item'])) {
802 794
	$pconfig['altnames']['item'] = array(
803 795
		array('type' => null, 'value' => null)
804 796
	);
......
920 912
$existCerts = array();
921 913

  
922 914
foreach ($config['cert'] as $cert)	{
923
	if(is_array($config['system']['user'][$userid]['cert'])) { // Could be MIA!
924
		if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert']))
915
	if (is_array($config['system']['user'][$userid]['cert'])) { // Could be MIA!
916
		if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) {
925 917
			continue;
918
		}
926 919
	}
927 920

  
928 921
	$ca = lookup_ca($cert['caref']);
929
	if ($ca)
922
	if ($ca) {
930 923
		$cert['descr'] .= " (CA: {$ca['descr']})";
924
	}
931 925

  
932
	if (cert_in_use($cert['refid']))
926
	if (cert_in_use($cert['refid'])) {
933 927
		$cert['descr'] .= " <i>In Use</i>";
934
	if (is_cert_revoked($cert))
928
	}
929
	if (is_cert_revoked($cert)) {
935 930
		$cert['descr'] .= " <b>Revoked</b>";
931
	}
936 932

  
937 933
	$existCerts[ $cert['refid'] ] = $cert['descr'];
938 934
}
......
1011 1007
	</thead>
1012 1008
	<tbody>
1013 1009
<?php
1014
foreach($a_cert as $i => $cert):
1010
foreach ($a_cert as $i => $cert):
1015 1011
	$name = htmlspecialchars($cert['descr']);
1016 1012

  
1017 1013
	if ($cert['crt']) {
......
1020 1016
		$purpose = cert_get_purpose($cert['crt']);
1021 1017
		list($startdate, $enddate) = cert_get_dates($cert['crt']);
1022 1018

  
1023
		if ($subj==$issuer)
1019
		if ($subj == $issuer) {
1024 1020
			$caname = '<i>'. gettext("self-signed") .'</i>';
1025
		else
1021
		} else {
1026 1022
			$caname = '<i>'. gettext("external").'</i>';
1023
		}
1027 1024

  
1028 1025
		$subj = htmlspecialchars($subj);
1029 1026
	}
......
1034 1031
	}
1035 1032

  
1036 1033
	$ca = lookup_ca($cert['caref']);
1037
	if ($ca)
1034
	if ($ca) {
1038 1035
		$caname = $ca['descr'];
1036
	}
1039 1037
?>
1040 1038
		<tr>
1041 1039
			<td>
......
1050 1048
			<td><?=$caname?></td>
1051 1049
			<td>
1052 1050
				<?=$subj?>
1053
				<?php if (! $cert['csr']): ?>
1051
				<?php if (!$cert['csr']): ?>
1054 1052
				<br />
1055 1053
				<small>
1056 1054
					<?=gettext("Valid From")?>: <b><?=$startdate ?></b><br /><?=gettext("Valid Until")?>: <b><?=$enddate ?></b>
......
1115 1113
?>
1116 1114
<script type="text/javascript">
1117 1115
//<![CDATA[
1118
events.push(function(){
1116
events.push(function() {
1119 1117

  
1120 1118
<?php if ($internal_ca_count): ?>
1121 1119
	function internalca_change() {

Also available in: Unified diff