Commit 30356cc7 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) more legacy code fixes

parent ba800ae6
...@@ -40,14 +40,14 @@ $openssl_digest_algs = array("sha1", "sha224", "sha256", "sha384", "sha512"); ...@@ -40,14 +40,14 @@ $openssl_digest_algs = array("sha1", "sha224", "sha256", "sha384", "sha512");
$pgtitle = array(gettext("System"), gettext("Certificate Authority Manager")); $pgtitle = array(gettext("System"), gettext("Certificate Authority Manager"));
if (is_numericint($_GET['id'])) { if (isset($_GET['id']) && is_numericint($_GET['id'])) {
$id = $_GET['id']; $id = $_GET['id'];
} }
if (isset($_POST['id']) && is_numericint($_POST['id'])) { if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id']; $id = $_POST['id'];
} }
if (!is_array($config['ca'])) { if (!isset($config['ca']) || !is_array($config['ca'])) {
$config['ca'] = array(); $config['ca'] = array();
} }
...@@ -59,14 +59,16 @@ if (!is_array($config['cert'])) { ...@@ -59,14 +59,16 @@ if (!is_array($config['cert'])) {
$a_cert =& $config['cert']; $a_cert =& $config['cert'];
if (!is_array($config['crl'])) { if (!isset($config['crl']) || !is_array($config['crl'])) {
$config['crl'] = array(); $config['crl'] = array();
} }
$a_crl =& $config['crl']; $a_crl =& $config['crl'];
$act = $_GET['act']; $act=null;
if ($_POST['act']) { if (isset($_GET['act'])) {
$act = $_GET['act'];
} elseif (isset($_POST['act'])) {
$act = $_POST['act']; $act = $_POST['act'];
} }
...@@ -99,7 +101,7 @@ if ($act == "del") { ...@@ -99,7 +101,7 @@ if ($act == "del") {
} }
if ($act == "edit") { if ($act == "edit") {
if (!$a_ca[$id]) { if (!isset($a_ca[$id])) {
redirectHeader("system_camanager.php"); redirectHeader("system_camanager.php");
exit; exit;
} }
...@@ -113,7 +115,11 @@ if ($act == "edit") { ...@@ -113,7 +115,11 @@ if ($act == "edit") {
} }
if ($act == "new") { if ($act == "new") {
$pconfig['method'] = $_GET['method']; if (isset($_GET['method'])) {
$pconfig['method'] = $_GET['method'];
} else {
$pconfig['method'] = null ;
}
$pconfig['keylen'] = "2048"; $pconfig['keylen'] = "2048";
$pconfig['digest_alg'] = "sha256"; $pconfig['digest_alg'] = "sha256";
$pconfig['lifetime'] = "365"; $pconfig['lifetime'] = "365";
...@@ -251,9 +257,13 @@ if ($_POST) { ...@@ -251,9 +257,13 @@ if ($_POST) {
$ca = $a_ca[$id]; $ca = $a_ca[$id];
} }
$ca['descr'] = $pconfig['descr']; if (isset($pconfig['descr'])) {
$ca['descr'] = $pconfig['descr'];
} else {
$ca['descr'] = null;
}
if ($_POST['edit'] == "edit") { if (isset($_POST['edit']) && $_POST['edit'] == "edit") {
$ca['descr'] = $pconfig['descr']; $ca['descr'] = $pconfig['descr'];
$ca['refid'] = $pconfig['refid']; $ca['refid'] = $pconfig['refid'];
$ca['serial'] = $pconfig['serial']; $ca['serial'] = $pconfig['serial'];
...@@ -305,12 +315,12 @@ if ($_POST) { ...@@ -305,12 +315,12 @@ if ($_POST) {
if (!$input_errors) { if (!$input_errors) {
write_config(); write_config();
unset($input_errors);
} }
// redirectHeader("system_camanager.php"); // redirectHeader("system_camanager.php");
} }
} }
include("head.inc"); include("head.inc");
$main_buttons = array( $main_buttons = array(
...@@ -373,7 +383,7 @@ function method_change() { ...@@ -373,7 +383,7 @@ function method_change() {
<div class="content-box tab-content table-responsive" style="overflow: auto;"> <div class="content-box tab-content table-responsive" style="overflow: auto;">
<?php if ($act == "new" || $act == "edit" || $act == gettext("Save") || $input_errors) : <?php if ($act == "new" || $act == "edit" || $act == gettext("Save") || isset($input_errors)) :
?> ?>
<form action="system_camanager.php" method="post" name="iform" id="iform" class="table table-striped"> <form action="system_camanager.php" method="post" name="iform" id="iform" class="table table-striped">
...@@ -390,7 +400,7 @@ endif; ?> ...@@ -390,7 +400,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/> <input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?php if (isset($pconfig['descr'])) echo htmlspecialchars($pconfig['descr']);?>"/>
</td> </td>
</tr> </tr>
...@@ -403,7 +413,7 @@ endif; ?> ...@@ -403,7 +413,7 @@ endif; ?>
<?php <?php
foreach ($ca_methods as $method => $desc) : foreach ($ca_methods as $method => $desc) :
$selected = ""; $selected = "";
if ($pconfig['method'] == $method) { if (isset($pconfig['method']) && $pconfig['method'] == $method) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }
?> ?>
...@@ -431,7 +441,7 @@ endif; ?> ...@@ -431,7 +441,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea> <textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?php if (isset($pconfig['cert'])) echo htmlspecialchars($pconfig['cert']);?></textarea>
<br /> <br />
<?=gettext("Paste a certificate in X.509 PEM format here.");?> <?=gettext("Paste a certificate in X.509 PEM format here.");?>
</td> </td>
...@@ -440,7 +450,7 @@ endif; ?> ...@@ -440,7 +450,7 @@ endif; ?>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate Private Key"); <td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate Private Key");
?><br /><?=gettext("(optional)");?></td> ?><br /><?=gettext("(optional)");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['key']);?></textarea> <textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?php if (isset($pconfig['key'])) echo htmlspecialchars($pconfig['key']);?></textarea>
<br /> <br />
<?=gettext("Paste the private key for the above certificate here. This is optional in most cases, but required if you need to generate a Certificate Revocation List (CRL).");?> <?=gettext("Paste the private key for the above certificate here. This is optional in most cases, but required if you need to generate a Certificate Revocation List (CRL).");?>
</td> </td>
...@@ -451,7 +461,7 @@ endif; ?> ...@@ -451,7 +461,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Serial for next certificate");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Serial for next certificate");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<input name="serial" type="text" class="formfld unknown" id="serial" size="20" value="<?=htmlspecialchars($pconfig['serial']);?>"/> <input name="serial" type="text" class="formfld unknown" id="serial" size="20" value="<?php if(isset($pconfig['serial'])) echo htmlspecialchars($pconfig['serial']);?>"/>
<br /><?=gettext("Enter a decimal number to be used as the serial number for the next certificate to be created using this CA.");?> <br /><?=gettext("Enter a decimal number to be used as the serial number for the next certificate to be created using this CA.");?>
</td> </td>
</tr> </tr>
...@@ -480,7 +490,7 @@ endif; ?> ...@@ -480,7 +490,7 @@ endif; ?>
continue; continue;
} }
$selected = ""; $selected = "";
if ($pconfig['caref'] == $ca['refid']) { if (isset($pconfig['caref']) && isset($ca['refid']) && $pconfig['caref'] == $ca['refid']) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }
?> ?>
...@@ -499,7 +509,7 @@ endif; ?> ...@@ -499,7 +509,7 @@ endif; ?>
<?php <?php
foreach ($ca_keylens as $len) : foreach ($ca_keylens as $len) :
$selected = ""; $selected = "";
if ($pconfig['keylen'] == $len) { if (isset($pconfig['keylen']) && $pconfig['keylen'] == $len) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }
?> ?>
...@@ -519,7 +529,7 @@ endif; ?> ...@@ -519,7 +529,7 @@ endif; ?>
<?php <?php
foreach ($openssl_digest_algs as $digest_alg) : foreach ($openssl_digest_algs as $digest_alg) :
$selected = ""; $selected = "";
if ($pconfig['digest_alg'] == $digest_alg) { if (isset($pconfig['digest_alg']) && $pconfig['digest_alg'] == $digest_alg) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }
?> ?>
...@@ -535,7 +545,7 @@ endif; ?> ...@@ -535,7 +545,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/> <input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?php if (isset($pconfig['lifetime'])) echo htmlspecialchars($pconfig['lifetime']);?>"/>
<?=gettext("days");?> <?=gettext("days");?>
</td> </td>
</tr> </tr>
...@@ -551,7 +561,7 @@ endif; ?> ...@@ -551,7 +561,7 @@ endif; ?>
$dn_cc = get_country_codes(); $dn_cc = get_country_codes();
foreach ($dn_cc as $cc => $cn) { foreach ($dn_cc as $cc => $cn) {
$selected = ''; $selected = '';
if ($pconfig['dn_country'] == $cc) { if (isset($pconfig['dn_country']) && $pconfig['dn_country'] == $cc) {
$selected = ' selected="selected"'; $selected = ' selected="selected"';
} }
print "<option value=\"$cc\"$selected>$cc ($cn)</option>"; print "<option value=\"$cc\"$selected>$cc ($cn)</option>";
...@@ -563,7 +573,7 @@ endif; ?> ...@@ -563,7 +573,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("State or Province");?> : &nbsp;</td> <td align="right"><?=gettext("State or Province");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>"/> <input name="dn_state" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['dn_state'])) echo htmlspecialchars($pconfig['dn_state']);?>"/>
&nbsp; &nbsp;
<em><?=gettext("ex:");?></em> <em><?=gettext("ex:");?></em>
&nbsp; &nbsp;
...@@ -573,7 +583,7 @@ endif; ?> ...@@ -573,7 +583,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("City");?> : &nbsp;</td> <td align="right"><?=gettext("City");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>"/> <input name="dn_city" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['dn_city'])) echo htmlspecialchars($pconfig['dn_city']);?>"/>
&nbsp; &nbsp;
<em><?=gettext("ex:");?></em> <em><?=gettext("ex:");?></em>
&nbsp; &nbsp;
...@@ -583,7 +593,7 @@ endif; ?> ...@@ -583,7 +593,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("Organization");?> : &nbsp;</td> <td align="right"><?=gettext("Organization");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>"/> <input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['dn_organization'])) echo htmlspecialchars($pconfig['dn_organization']);?>"/>
&nbsp; &nbsp;
<em><?=gettext("ex:");?></em> <em><?=gettext("ex:");?></em>
&nbsp; &nbsp;
...@@ -593,7 +603,7 @@ endif; ?> ...@@ -593,7 +603,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("Email Address");?> : &nbsp;</td> <td align="right"><?=gettext("Email Address");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/> <input name="dn_email" type="text" class="formfld unknown" size="25" value="<?php if (isset($pconfig['dn_email'])) echo htmlspecialchars($pconfig['dn_email']);?>"/>
&nbsp; &nbsp;
<em><?=gettext("ex:");?></em> <em><?=gettext("ex:");?></em>
&nbsp; &nbsp;
...@@ -603,7 +613,7 @@ endif; ?> ...@@ -603,7 +613,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("Common Name");?> : &nbsp;</td> <td align="right"><?=gettext("Common Name");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/> <input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?php if (isset($pconfig['dn_commonname'])) echo htmlspecialchars($pconfig['dn_commonname']);?>"/>
&nbsp; &nbsp;
<em><?=gettext("ex:");?></em> <em><?=gettext("ex:");?></em>
&nbsp; &nbsp;
...@@ -664,11 +674,23 @@ else : ...@@ -664,11 +674,23 @@ else :
$subj = htmlspecialchars($subj); $subj = htmlspecialchars($subj);
$issuer = htmlspecialchars($issuer); $issuer = htmlspecialchars($issuer);
$certcount = 0; $certcount = 0;
$issuer_ca = lookup_ca($ca['caref']); if (isset($ca['caref'])) {
if ($issuer_ca) { $issuer_ca = lookup_ca($ca['caref']);
$issuer_name = $issuer_ca['descr']; if ($issuer_ca) {
} $issuer_name = $issuer_ca['descr'];
}
foreach ($a_cert as $cert) {
if ($cert['caref'] == $ca['refid']) {
$certcount++;
}
}
foreach ($a_ca as $cert) {
if ($cert['caref'] == $ca['refid']) {
$certcount++;
}
}
}
// TODO : Need gray certificate icon // TODO : Need gray certificate icon
...@@ -680,16 +702,6 @@ else : ...@@ -680,16 +702,6 @@ else :
$caimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; $caimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
$internal = "NO"; $internal = "NO";
} }
foreach ($a_cert as $cert) {
if ($cert['caref'] == $ca['refid']) {
$certcount++;
}
}
foreach ($a_ca as $cert) {
if ($cert['caref'] == $ca['refid']) {
$certcount++;
}
}
?> ?>
<tr> <tr>
<td class="listlr"> <td class="listlr">
......
...@@ -84,8 +84,10 @@ foreach ($a_ca as $ca) { ...@@ -84,8 +84,10 @@ foreach ($a_ca as $ca) {
} }
} }
$act = $_GET['act']; $act = null;
if ($_POST['act']) { if (isset($_GET['act'])) {
$act = $_GET['act'];
} elseif (isset($_POST['act'])) {
$act = $_POST['act']; $act = $_POST['act'];
} }
...@@ -104,7 +106,11 @@ if ($act == "del") { ...@@ -104,7 +106,11 @@ if ($act == "del") {
} }
if ($act == "new") { if ($act == "new") {
$pconfig['method'] = $_GET['method']; if (isset($_GET['method'])) {
$pconfig['method'] = $_GET['method'];
} else {
$pconfig['method'] = null;
}
$pconfig['keylen'] = "2048"; $pconfig['keylen'] = "2048";
$pconfig['digest_alg'] = "sha256"; $pconfig['digest_alg'] = "sha256";
$pconfig['csr_keylen'] = "2048"; $pconfig['csr_keylen'] = "2048";
...@@ -425,7 +431,7 @@ if ($_POST) { ...@@ -425,7 +431,7 @@ if ($_POST) {
write_config(); write_config();
} }
if ($userid) { if (isset($userid)) {
post_redirect("system_usermanager.php", array('act' => 'edit', 'userid' => $userid)); post_redirect("system_usermanager.php", array('act' => 'edit', 'userid' => $userid));
exit; exit;
} }
...@@ -614,7 +620,7 @@ endif; ?> ...@@ -614,7 +620,7 @@ endif; ?>
<div class="content-box tab-content table-responsive"> <div class="content-box tab-content table-responsive">
<?php if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)) : <?php if ($act == "new" || ((isset($_POST['save']) && $_POST['save'] == gettext("Save")) && $input_errors)) :
?> ?>
<form action="system_certmanager.php" method="post" name="iform" id="iform" > <form action="system_certmanager.php" method="post" name="iform" id="iform" >
...@@ -644,13 +650,13 @@ endif; ?> ...@@ -644,13 +650,13 @@ endif; ?>
endif; ?> endif; ?>
<tr id="descriptivename"> <tr id="descriptivename">
<?php <?php
if ($a_user && empty($pconfig['descr'])) { if (isset($a_user) && empty($pconfig['descr'])) {
$pconfig['descr'] = $a_user[$userid]['name']; $pconfig['descr'] = $a_user[$userid]['name'];
} }
?> ?>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/> <input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?php if(isset($pconfig['descr'])) echo htmlspecialchars($pconfig['descr']);?>"/>
</td> </td>
</tr> </tr>
</table> </table>
...@@ -666,7 +672,7 @@ endif; ?> ...@@ -666,7 +672,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea> <textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?php if(isset($pconfig['cert'])) echo htmlspecialchars($pconfig['cert']);?></textarea>
<br /> <br />
<?=gettext("Paste a certificate in X.509 PEM format here.");?> <?=gettext("Paste a certificate in X.509 PEM format here.");?>
</td> </td>
...@@ -674,7 +680,7 @@ endif; ?> ...@@ -674,7 +680,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Private key data");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Private key data");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['key']);?></textarea> <textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?php if(isset($pconfig['key'])) echo htmlspecialchars($pconfig['key']);?></textarea>
<br /> <br />
<?=gettext("Paste a private key in X.509 PEM format here.");?> <?=gettext("Paste a private key in X.509 PEM format here.");?>
</td> </td>
...@@ -715,7 +721,7 @@ else : ...@@ -715,7 +721,7 @@ else :
continue; continue;
} }
$selected = ""; $selected = "";
if ($pconfig['caref'] == $ca['refid']) { if (isset($pconfig['caref']) && isset($ca['refid']) && $pconfig['caref'] == $ca['refid']) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }
?> ?>
...@@ -781,31 +787,31 @@ else : ...@@ -781,31 +787,31 @@ else :
<tr> <tr>
<td align="right"><?=gettext("Country Code");?> : &nbsp;</td> <td align="right"><?=gettext("Country Code");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_country" type="text" class="formfld unknown" maxlength="2" size="2" value="<?=htmlspecialchars($pconfig['dn_country']);?>"/> <input name="dn_country" type="text" class="formfld unknown" maxlength="2" size="2" value="<?php if (isset($pconfig['dn_country'])) echo htmlspecialchars($pconfig['dn_country']);?>"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="right"><?=gettext("State or Province");?> : &nbsp;</td> <td align="right"><?=gettext("State or Province");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>"/> <input name="dn_state" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['dn_state'])) echo htmlspecialchars($pconfig['dn_state']);?>"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="right"><?=gettext("City");?> : &nbsp;</td> <td align="right"><?=gettext("City");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>"/> <input name="dn_city" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['dn_city'])) echo htmlspecialchars($pconfig['dn_city']);?>"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="right"><?=gettext("Organization");?> : &nbsp;</td> <td align="right"><?=gettext("Organization");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>"/> <input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['dn_organization'])) echo htmlspecialchars($pconfig['dn_organization']);?>"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="right"><?=gettext("Email Address");?> : &nbsp;</td> <td align="right"><?=gettext("Email Address");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/> <input name="dn_email" type="text" class="formfld unknown" size="25" value="<?php if (isset($pconfig['dn_email'])) echo htmlspecialchars($pconfig['dn_email']);?>"/>
&nbsp; &nbsp;
<em>ex:</em> <em>ex:</em>
&nbsp; &nbsp;
...@@ -816,11 +822,11 @@ else : ...@@ -816,11 +822,11 @@ else :
<td align="right"><?=gettext("Common Name");?> : &nbsp;</td> <td align="right"><?=gettext("Common Name");?> : &nbsp;</td>
<td align="left"> <td align="left">
<?php <?php
if ($a_user && empty($pconfig['dn_commonname'])) { if (isset($a_user) && empty($pconfig['dn_commonname'])) {
$pconfig['dn_commonname'] = $a_user[$userid]['name']; $pconfig['dn_commonname'] = $a_user[$userid]['name'];
} }
?> ?>
<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/> <input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?php if (isset($pconfig['dn_commonname'])) htmlspecialchars($pconfig['dn_commonname']);?>"/>
&nbsp; &nbsp;
<em>ex:</em> <em>ex:</em>
&nbsp; &nbsp;
...@@ -840,7 +846,7 @@ else : ...@@ -840,7 +846,7 @@ else :
<tbody> <tbody>
<?php <?php
$counter = 0; $counter = 0;
if ($pconfig['altnames']['item']) : if (isset($pconfig['altnames']['item'])) :
foreach ($pconfig['altnames']['item'] as $item) : foreach ($pconfig['altnames']['item'] as $item) :
$type = $item['type']; $type = $item['type'];
$value = $item['value']; $value = $item['value'];
...@@ -950,7 +956,7 @@ endif; ?> ...@@ -950,7 +956,7 @@ endif; ?>
$dn_cc = get_country_codes(); $dn_cc = get_country_codes();
foreach ($dn_cc as $cc => $cn) { foreach ($dn_cc as $cc => $cn) {
$selected = ''; $selected = '';
if ($pconfig['csr_dn_country'] == $cc) { if (isset($pconfig['csr_dn_country']) && $pconfig['csr_dn_country'] == $cc) {
$selected = ' selected="selected"'; $selected = ' selected="selected"';
} }
print "<option value=\"$cc\"$selected>$cc ($cn)</option>"; print "<option value=\"$cc\"$selected>$cc ($cn)</option>";
...@@ -962,7 +968,7 @@ endif; ?> ...@@ -962,7 +968,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("State or Province");?> : &nbsp;</td> <td align="right"><?=gettext("State or Province");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="csr_dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_state']);?>" /> <input name="csr_dn_state" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['csr_dn_state'])) echo htmlspecialchars($pconfig['csr_dn_state']);?>" />
&nbsp; &nbsp;
<em>ex:</em> <em>ex:</em>
&nbsp; &nbsp;
...@@ -972,7 +978,7 @@ endif; ?> ...@@ -972,7 +978,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("City");?> : &nbsp;</td> <td align="right"><?=gettext("City");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="csr_dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_city']);?>" /> <input name="csr_dn_city" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['csr_dn_city'])) echo htmlspecialchars($pconfig['csr_dn_city']);?>" />
&nbsp; &nbsp;
<em>ex:</em> <em>ex:</em>
&nbsp; &nbsp;
...@@ -982,7 +988,7 @@ endif; ?> ...@@ -982,7 +988,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("Organization");?> : &nbsp;</td> <td align="right"><?=gettext("Organization");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="csr_dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_organization']);?>" /> <input name="csr_dn_organization" type="text" class="formfld unknown" size="40" value="<?php if (isset($pconfig['csr_dn_organization'])) echo htmlspecialchars($pconfig['csr_dn_organization']);?>" />
&nbsp; &nbsp;
<em>ex:</em> <em>ex:</em>
&nbsp; &nbsp;
...@@ -992,7 +998,7 @@ endif; ?> ...@@ -992,7 +998,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("Email Address");?> : &nbsp;</td> <td align="right"><?=gettext("Email Address");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="csr_dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_email']);?>"/> <input name="csr_dn_email" type="text" class="formfld unknown" size="25" value="<?php if (isset($pconfig['csr_dn_email'])) echo htmlspecialchars($pconfig['csr_dn_email']);?>"/>
&nbsp; &nbsp;
<em>ex:</em> <em>ex:</em>
&nbsp; &nbsp;
...@@ -1002,7 +1008,7 @@ endif; ?> ...@@ -1002,7 +1008,7 @@ endif; ?>
<tr> <tr>
<td align="right"><?=gettext("Common Name");?> : &nbsp;</td> <td align="right"><?=gettext("Common Name");?> : &nbsp;</td>
<td align="left"> <td align="left">
<input name="csr_dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_commonname']);?>"/> <input name="csr_dn_commonname" type="text" class="formfld unknown" size="25" value="<?php if(isset($pconfig['csr_dn_commonname'])) echo htmlspecialchars($pconfig['csr_dn_commonname']);?>"/>
&nbsp; &nbsp;
<em>ex:</em> <em>ex:</em>
&nbsp; &nbsp;
...@@ -1040,14 +1046,18 @@ endif;?> ...@@ -1040,14 +1046,18 @@ endif;?>
if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) { if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) {
continue; continue;
} }
$ca = lookup_ca($cert['caref']); if (isset($cert['caref'])) {
if ($ca) { $ca = lookup_ca($cert['caref']);
$caname = " (CA: {$ca['descr']})"; if ($ca) {
} $caname = " (CA: {$ca['descr']})";
if ($pconfig['certref'] == $cert['refid']) { }
} else {
$ca = null;
}
if (isset($pconfig['certref']) && isset($cert['refid']) && $pconfig['certref'] == $cert['refid']) {
$selected = " selected=\"selected\""; $selected = " selected=\"selected\"";
} }
if (cert_in_use($cert['refid'])) { if (isset($cert['refid']) && cert_in_use($cert['refid'])) {
$inuse = " *In Use"; $inuse = " *In Use";
} }
if (is_cert_revoked($cert)) { if (is_cert_revoked($cert)) {
...@@ -1081,7 +1091,7 @@ endif;?> ...@@ -1081,7 +1091,7 @@ endif;?>
</form> </form>
<?php <?php
elseif ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)) : elseif ($act == "csr" || ((isset($_POST['save']) && $_POST['save'] == gettext("Update")) && $input_errors)) :
?> ?>
<form action="system_certmanager.php" method="post" name="iform" id="iform"> <form action="system_certmanager.php" method="post" name="iform" id="iform">
...@@ -1170,15 +1180,16 @@ else : ...@@ -1170,15 +1180,16 @@ else :
$subj = htmlspecialchars($subj); $subj = htmlspecialchars($subj);
} }
if ($cert['csr']) { if (isset($cert['csr'])) {
$subj = htmlspecialchars(csr_get_subject($cert['csr'])); $subj = htmlspecialchars(csr_get_subject($cert['csr']));
$caname = "<em>" . gettext("external - signature pending") . "</em>"; $caname = "<em>" . gettext("external - signature pending") . "</em>";
} }
if (isset($cert['caref'])) {
$ca = lookup_ca($cert['caref']); $ca = lookup_ca($cert['caref']);
if ($ca) { if ($ca) {
$caname = $ca['descr']; $caname = $ca['descr'];
} }
}
// was: $certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; // was: $certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
...@@ -1284,7 +1295,7 @@ endif; ?> ...@@ -1284,7 +1295,7 @@ endif; ?>
<?php <?php
endif; ?> endif; ?>
<?php if ($cert['csr']) : <?php if (isset($cert['csr'])) :
?> ?>
<a href="system_certmanager.php?act=csr&amp;id=<?=$i; <a href="system_certmanager.php?act=csr&amp;id=<?=$i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment