From 308f06657c4fc6a1be7246ddfa6b349832f610cc Mon Sep 17 00:00:00 2001 From: NewEraCracker Date: Fri, 11 Mar 2016 12:01:45 +0000 Subject: The 'csr' code block is duplicated. This commit removes it --- src/usr/local/www/system_certmanager.php | 46 ++------------------------------ 1 file changed, 2 insertions(+), 44 deletions(-) (limited to 'src/usr/local') diff --git a/src/usr/local/www/system_certmanager.php b/src/usr/local/www/system_certmanager.php index e4db4e4..de607ff 100644 --- a/src/usr/local/www/system_certmanager.php +++ b/src/usr/local/www/system_certmanager.php @@ -589,49 +589,7 @@ if (file_exists("/etc/ca_countries")) { } if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)) { -$form = new Form; - -if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)) { - $form->setAction('system_certmanager.php?act=csr'); - - $section = new Form_Section('Complete Signing Request'); - - if (isset($id) && $a_cert[$id]) { - $form->addGlobal(new Form_Input( - 'id', - null, - 'hidden', - $id - )); - } - - $section->addInput(new Form_Input( - 'descr', - 'Descriptive name', - 'text', - $pconfig['descr'] - )); - - $section->addInput(new Form_Textarea( - 'csr', - 'Signing request data', - $pconfig['csr'] - ))->setReadonly()->setHelp('Copy the certificate signing data from here and '. - 'forward it to your certificate authority for signing.'); - - $section->addInput(new Form_Textarea( - 'cert', - 'Final certificate data', - $pconfig['cert'] - ))->setHelp('Paste the certificate received from your certificate authority here.'); - - $form->add($section); - print $form; - - include("foot.inc"); - exit; -} - +$form = new Form(); $form->setAction('system_certmanager.php?act=edit'); if (isset($userid) && $a_user) { @@ -939,7 +897,6 @@ foreach ($config['cert'] as $cert) { $existCerts[ $cert['refid'] ] = $cert['descr']; } - $section->addInput(new Form_Select( 'certref', 'Existing Certificates', @@ -952,6 +909,7 @@ print $form; } else if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)) { $form = new Form(false); + $form->setAction('system_certmanager.php?act=csr'); $section = new Form_Section("Complete Signing Request for " . $pconfig['descr']); -- cgit v1.1 From b35250d98eeeb99d15f4558219d28016c9720b7b Mon Sep 17 00:00:00 2001 From: NewEraCracker Date: Fri, 11 Mar 2016 12:02:31 +0000 Subject: Indent system_certmanager.php --- src/usr/local/www/system_certmanager.php | 572 +++++++++++++++---------------- 1 file changed, 286 insertions(+), 286 deletions(-) (limited to 'src/usr/local') diff --git a/src/usr/local/www/system_certmanager.php b/src/usr/local/www/system_certmanager.php index de607ff..bfad6a2 100644 --- a/src/usr/local/www/system_certmanager.php +++ b/src/usr/local/www/system_certmanager.php @@ -589,323 +589,323 @@ if (file_exists("/etc/ca_countries")) { } if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)) { -$form = new Form(); -$form->setAction('system_certmanager.php?act=edit'); + $form = new Form(); + $form->setAction('system_certmanager.php?act=edit'); -if (isset($userid) && $a_user) { - $form->addGlobal(new Form_Input( - 'userid', - null, - 'hidden', - $userid - )); -} + if (isset($userid) && $a_user) { + $form->addGlobal(new Form_Input( + 'userid', + null, + 'hidden', + $userid + )); + } -if (isset($id) && $a_cert[$id]) { - $form->addGlobal(new Form_Input( - 'id', - null, - 'hidden', - $id + if (isset($id) && $a_cert[$id]) { + $form->addGlobal(new Form_Input( + 'id', + null, + 'hidden', + $id + )); + } + + $section = new Form_Section('Add a New Certificate'); + + if (!isset($id)) { + $section->addInput(new Form_Select( + 'method', + 'Method', + $pconfig['method'], + $cert_methods + ))->toggles(); + } + + $section->addInput(new Form_Input( + 'descr', + 'Descriptive name', + 'text', + ($a_user && empty($pconfig['descr'])) ? $a_user[$userid]['name'] : $pconfig['descr'] + ))->addClass('toggle-existing'); + + $form->add($section); + $section = new Form_Section('Import Certificate'); + $section->addClass('toggle-import collapse'); + + $section->addInput(new Form_Textarea( + 'cert', + 'Certificate data', + $pconfig['cert'] + ))->setHelp('Paste a certificate in X.509 PEM format here.'); + + $section->addInput(new Form_Textarea( + 'key', + 'Private key data', + $pconfig['key'] + ))->setHelp('Paste a private key in X.509 PEM format here.'); + + $form->add($section); + $section = new Form_Section('Internal Certificate'); + $section->addClass('toggle-internal collapse'); + + if (!$internal_ca_count) { + $section->addInput(new Form_StaticText( + 'Certificate authority', + gettext('No internal Certificate Authorities have been defined. You must '). + ' '. gettext(" create") .''. + gettext(' an internal CA before creating an internal certificate.') + )); + } else { + $allCas = array(); + foreach ($a_ca as $ca) { + if (!$ca['prv']) { + continue; + } + + $allCas[ $ca['refid'] ] = $ca['descr']; + } + + $section->addInput(new Form_Select( + 'caref', + 'Certificate authority', + $pconfig['caref'], + $allCas + )); + } + + $section->addInput(new Form_Select( + 'keylen', + 'Key length', + $pconfig['keylen'], + array_combine($cert_keylens, $cert_keylens) )); -} -$section = new Form_Section('Add a New Certificate'); + $section->addInput(new Form_Select( + 'digest_alg', + 'Digest Algorithm', + $pconfig['digest_alg'], + array_combine($openssl_digest_algs, $openssl_digest_algs) + ))->setHelp('NOTE: It is recommended to use an algorithm stronger than '. + 'SHA1 when possible.'); -if (!isset($id)) { $section->addInput(new Form_Select( - 'method', - 'Method', - $pconfig['method'], - $cert_methods - ))->toggles(); -} + 'type', + 'Certificate Type', + $pconfig['type'], + $cert_types + ))->setHelp('Type of certificate to generate. Used for placing '. + 'restrictions on the usage of the generated certificate.'); -$section->addInput(new Form_Input( - 'descr', - 'Descriptive name', - 'text', - ($a_user && empty($pconfig['descr'])) ? $a_user[$userid]['name'] : $pconfig['descr'] -))->addClass('toggle-existing'); - -$form->add($section); -$section = new Form_Section('Import Certificate'); -$section->addClass('toggle-import collapse'); - -$section->addInput(new Form_Textarea( - 'cert', - 'Certificate data', - $pconfig['cert'] -))->setHelp('Paste a certificate in X.509 PEM format here.'); - -$section->addInput(new Form_Textarea( - 'key', - 'Private key data', - $pconfig['key'] -))->setHelp('Paste a private key in X.509 PEM format here.'); - -$form->add($section); -$section = new Form_Section('Internal Certificate'); -$section->addClass('toggle-internal collapse'); - -if (!$internal_ca_count) { - $section->addInput(new Form_StaticText( - 'Certificate authority', - gettext('No internal Certificate Authorities have been defined. You must '). - ' '. gettext(" create") .''. - gettext(' an internal CA before creating an internal certificate.') + $section->addInput(new Form_Input( + 'lifetime', + 'Lifetime (days)', + 'number', + $pconfig['lifetime'] + )); + + $section->addInput(new Form_Select( + 'dn_country', + 'Country Code', + $pconfig['dn_country'], + $dn_cc + )); + + $section->addInput(new Form_Input( + 'dn_state', + 'State or Province', + 'text', + $pconfig['dn_state'], + ['placeholder' => 'e.g. Texas'] )); -} else { - $allCas = array(); - foreach ($a_ca as $ca) { - if (!$ca['prv']) { - continue; - } - $allCas[ $ca['refid'] ] = $ca['descr']; + $section->addInput(new Form_Input( + 'dn_city', + 'City', + 'text', + $pconfig['dn_city'], + ['placeholder' => 'e.g. Austin'] + )); + + $section->addInput(new Form_Input( + 'dn_organization', + 'Organization', + 'text', + $pconfig['dn_organization'], + ['placeholder' => 'e.g. My Company Inc.'] + )); + + $section->addInput(new Form_Input( + 'dn_email', + 'Email Address', + 'text', + $pconfig['dn_email'], + ['placeholder' => 'e.g. admin@mycompany.com'] + )); + + $section->addInput(new Form_Input( + 'dn_commonname', + 'Common Name', + 'text', + $pconfig['dn_commonname'], + ['placeholder' => 'e.g. www.example.com'] + )); + + if (empty($pconfig['altnames']['item'])) { + $pconfig['altnames']['item'] = array( + array('type' => null, 'value' => null) + ); + } + + $counter = 0; + $numrows = count($pconfig['altnames']['item']) - 1; + + foreach ($pconfig['altnames']['item'] as $item) { + + $group = new Form_Group($counter == 0 ? 'Alternative Names':''); + + $group->add(new Form_Select( + 'altname_type' . $counter, + 'Type', + $item['type'], + array( + 'DNS' => gettext('FQDN or Hostname'), + 'IP' => gettext('IP address'), + 'URI' => gettext('URI'), + 'email' => gettext('email address'), + ) + ))->setHelp(($counter == $numrows) ? 'Type':null); + + $group->add(new Form_Input( + 'altname_value' . $counter, + null, + 'text', + $item['value'] + ))->setHelp(($counter == $numrows) ? 'Value':null); + + $group->add(new Form_Button( + 'deleterow' . $counter, + 'Delete', + null, + 'fa-trash' + ))->addClass('btn-warning'); + + $group->addClass('repeatable'); + + $section->add($group); + + $counter++; } + $section->addInput(new Form_Button( + 'addrow', + 'Add', + null, + 'fa-plus' + ))->addClass('btn-success'); + + $form->add($section); + $section = new Form_Section('External Signing Request'); + $section->addClass('toggle-external collapse'); + $section->addInput(new Form_Select( - 'caref', - 'Certificate authority', - $pconfig['caref'], - $allCas + 'csr_keylen', + 'Key length', + $pconfig['csr_keylen'], + array_combine($cert_keylens, $cert_keylens) )); -} -$section->addInput(new Form_Select( - 'keylen', - 'Key length', - $pconfig['keylen'], - array_combine($cert_keylens, $cert_keylens) -)); - -$section->addInput(new Form_Select( - 'digest_alg', - 'Digest Algorithm', - $pconfig['digest_alg'], - array_combine($openssl_digest_algs, $openssl_digest_algs) -))->setHelp('NOTE: It is recommended to use an algorithm stronger than '. - 'SHA1 when possible.'); - -$section->addInput(new Form_Select( - 'type', - 'Certificate Type', - $pconfig['type'], - $cert_types -))->setHelp('Type of certificate to generate. Used for placing '. - 'restrictions on the usage of the generated certificate.'); - -$section->addInput(new Form_Input( - 'lifetime', - 'Lifetime (days)', - 'number', - $pconfig['lifetime'] -)); - -$section->addInput(new Form_Select( - 'dn_country', - 'Country Code', - $pconfig['dn_country'], - $dn_cc -)); - -$section->addInput(new Form_Input( - 'dn_state', - 'State or Province', - 'text', - $pconfig['dn_state'], - ['placeholder' => 'e.g. Texas'] -)); - -$section->addInput(new Form_Input( - 'dn_city', - 'City', - 'text', - $pconfig['dn_city'], - ['placeholder' => 'e.g. Austin'] -)); - -$section->addInput(new Form_Input( - 'dn_organization', - 'Organization', - 'text', - $pconfig['dn_organization'], - ['placeholder' => 'e.g. My Company Inc.'] -)); - -$section->addInput(new Form_Input( - 'dn_email', - 'Email Address', - 'text', - $pconfig['dn_email'], - ['placeholder' => 'e.g. admin@mycompany.com'] -)); - -$section->addInput(new Form_Input( - 'dn_commonname', - 'Common Name', - 'text', - $pconfig['dn_commonname'], - ['placeholder' => 'e.g. www.example.com'] -)); - -if (empty($pconfig['altnames']['item'])) { - $pconfig['altnames']['item'] = array( - array('type' => null, 'value' => null) - ); -} + $section->addInput(new Form_Select( + 'csr_digest_alg', + 'Digest Algorithm', + $pconfig['csr_digest_alg'], + array_combine($openssl_digest_algs, $openssl_digest_algs) + ))->setHelp('NOTE: It is recommended to use an algorithm stronger than '. + 'SHA1 when possible'); -$counter = 0; -$numrows = count($pconfig['altnames']['item']) - 1; + $section->addInput(new Form_Select( + 'csr_dn_country', + 'Country Code', + $pconfig['csr_dn_country'], + $dn_cc + )); -foreach ($pconfig['altnames']['item'] as $item) { + $section->addInput(new Form_Input( + 'csr_dn_state', + 'State or Province', + 'text', + $pconfig['csr_dn_state'], + ['placeholder' => 'e.g. Texas'] + )); - $group = new Form_Group($counter == 0 ? 'Alternative Names':''); + $section->addInput(new Form_Input( + 'csr_dn_city', + 'City', + 'text', + $pconfig['csr_dn_city'], + ['placeholder' => 'e.g. Austin'] + )); - $group->add(new Form_Select( - 'altname_type' . $counter, - 'Type', - $item['type'], - array( - 'DNS' => gettext('FQDN or Hostname'), - 'IP' => gettext('IP address'), - 'URI' => gettext('URI'), - 'email' => gettext('email address'), - ) - ))->setHelp(($counter == $numrows) ? 'Type':null); + $section->addInput(new Form_Input( + 'csr_dn_organization', + 'Organization', + 'text', + $pconfig['csr_dn_organization'], + ['placeholder' => 'e.g. My Company Inc.'] + )); - $group->add(new Form_Input( - 'altname_value' . $counter, - null, + $section->addInput(new Form_Input( + 'csr_dn_email', + 'Email Address', 'text', - $item['value'] - ))->setHelp(($counter == $numrows) ? 'Value':null); + $pconfig['csr_dn_email'], + ['placeholder' => 'e.g. admin@mycompany.com'] + )); - $group->add(new Form_Button( - 'deleterow' . $counter, - 'Delete', - null, - 'fa-trash' - ))->addClass('btn-warning'); + $section->addInput(new Form_Input( + 'csr_dn_commonname', + 'Common Name', + 'text', + $pconfig['csr_dn_commonname'], + ['placeholder' => 'e.g. internal-ca'] + )); - $group->addClass('repeatable'); + $form->add($section); + $section = new Form_Section('Choose an Existing Certificate'); + $section->addClass('toggle-existing collapse'); - $section->add($group); + $existCerts = array(); - $counter++; -} + foreach ($config['cert'] as $cert) { + if (is_array($config['system']['user'][$userid]['cert'])) { // Could be MIA! + if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) { + continue; + } + } -$section->addInput(new Form_Button( - 'addrow', - 'Add', - null, - 'fa-plus' -))->addClass('btn-success'); - -$form->add($section); -$section = new Form_Section('External Signing Request'); -$section->addClass('toggle-external collapse'); - -$section->addInput(new Form_Select( - 'csr_keylen', - 'Key length', - $pconfig['csr_keylen'], - array_combine($cert_keylens, $cert_keylens) -)); - -$section->addInput(new Form_Select( - 'csr_digest_alg', - 'Digest Algorithm', - $pconfig['csr_digest_alg'], - array_combine($openssl_digest_algs, $openssl_digest_algs) -))->setHelp('NOTE: It is recommended to use an algorithm stronger than '. - 'SHA1 when possible'); - -$section->addInput(new Form_Select( - 'csr_dn_country', - 'Country Code', - $pconfig['csr_dn_country'], - $dn_cc -)); - -$section->addInput(new Form_Input( - 'csr_dn_state', - 'State or Province', - 'text', - $pconfig['csr_dn_state'], - ['placeholder' => 'e.g. Texas'] -)); - -$section->addInput(new Form_Input( - 'csr_dn_city', - 'City', - 'text', - $pconfig['csr_dn_city'], - ['placeholder' => 'e.g. Austin'] -)); - -$section->addInput(new Form_Input( - 'csr_dn_organization', - 'Organization', - 'text', - $pconfig['csr_dn_organization'], - ['placeholder' => 'e.g. My Company Inc.'] -)); - -$section->addInput(new Form_Input( - 'csr_dn_email', - 'Email Address', - 'text', - $pconfig['csr_dn_email'], - ['placeholder' => 'e.g. admin@mycompany.com'] -)); - -$section->addInput(new Form_Input( - 'csr_dn_commonname', - 'Common Name', - 'text', - $pconfig['csr_dn_commonname'], - ['placeholder' => 'e.g. internal-ca'] -)); - -$form->add($section); -$section = new Form_Section('Choose an Existing Certificate'); -$section->addClass('toggle-existing collapse'); - -$existCerts = array(); - -foreach ($config['cert'] as $cert) { - if (is_array($config['system']['user'][$userid]['cert'])) { // Could be MIA! - if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) { - continue; + $ca = lookup_ca($cert['caref']); + if ($ca) { + $cert['descr'] .= " (CA: {$ca['descr']})"; } - } - $ca = lookup_ca($cert['caref']); - if ($ca) { - $cert['descr'] .= " (CA: {$ca['descr']})"; - } + if (cert_in_use($cert['refid'])) { + $cert['descr'] .= " In Use"; + } + if (is_cert_revoked($cert)) { + $cert['descr'] .= " Revoked"; + } - if (cert_in_use($cert['refid'])) { - $cert['descr'] .= " In Use"; - } - if (is_cert_revoked($cert)) { - $cert['descr'] .= " Revoked"; + $existCerts[ $cert['refid'] ] = $cert['descr']; } - $existCerts[ $cert['refid'] ] = $cert['descr']; -} - -$section->addInput(new Form_Select( - 'certref', - 'Existing Certificates', - $pconfig['certref'], - $existCerts -)); + $section->addInput(new Form_Select( + 'certref', + 'Existing Certificates', + $pconfig['certref'], + $existCerts + )); -$form->add($section); -print $form; + $form->add($section); + print $form; } else if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)) { $form = new Form(false); -- cgit v1.1