Skip to content

Commit

Permalink
updated context menu for private key functions, and updated context m…
Browse files Browse the repository at this point in the history
…enu to take into account <font> tag in status area, of show_summary
  • Loading branch information
cuediin committed Aug 12, 2016
1 parent 48c602f commit 1a97d4d
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 67 deletions.
5 changes: 3 additions & 2 deletions include/functions_cert.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function download_cert($this_cert,$cer_ext) {
// =================== CONVERT CERT PKCS12 =====================================================================================
// ==================================================================================================================

function convert_cert_pkcs12_form(){
function convert_cert_pkcs12_form($my_values=array('cert_name'=>'::zz::')){
$config=$_SESSION['config'];
?>
<p>
Expand Down Expand Up @@ -120,7 +120,8 @@ function convert_cert_pkcs12_form(){
if (is_file($config['key_path'].$file) ) {
$name = base64_decode(substr($file, 0,strrpos($file,'.')));
$ext = substr($file, strrpos($file,'.'));
print "<option value=\"$name$ext\">$name$ext</option>\n";
if ( $my_values['cert_name'] == "$name$ext") $this_selected=" selected=\"selected\""; else $this_selected="";
print "<option value=\"$name$ext\"$this_selected>$name$ext</option>\n";
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions include/functions_csr.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// =================== CREATE CSR =====================================================================================
// ==================================================================================================================

function createCSR_form(){
function createCSR_form(){
$config=$_SESSION['config'];
$my_x509_parse = openssl_x509_parse(file_get_contents($config['cacert']));
?>
Expand Down Expand Up @@ -55,7 +55,7 @@ function create_csr($my_cert_dn,$my_keysize,$my_passphrase,$my_device_type) {
}
$my_csrfile=substr($my_csrfile,0,strrpos($my_csrfile,':'));
$filename=base64_encode($my_csrfile);
print "CSR Filename:" . $my_csrfile;
print "CSR Filename : " . $my_csrfile."<BR>";
if ($my_device_type=='ca_cert') {
$client_keyFile = $config['cakey'];
$client_reqFile = $config['req_path'].$filename.".pem";
Expand Down Expand Up @@ -116,7 +116,7 @@ function create_csr($my_cert_dn,$my_keysize,$my_passphrase,$my_device_type) {
// =================== DOWNLOAD CSR =====================================================================================
// ==================================================================================================================

function download_csr_form(){
function download_csr_form(){
$config=$_SESSION['config'];
?>
<p>
Expand Down Expand Up @@ -195,7 +195,7 @@ function download_csr($this_cert,$cer_ext) {
// ==================================================================================================================


function import_CSR_form(){
function import_CSR_form(){
$config=$_SESSION['config'];
?>
<p>
Expand Down Expand Up @@ -244,7 +244,7 @@ function import_csr($my_csr) {



function upload_CSR_form(){
function upload_CSR_form(){
$config=$_SESSION['config'];
?>
<p>
Expand Down Expand Up @@ -325,7 +325,7 @@ function upload_csr($uploaded_file) {
// ==================================================================================================================


function view_csr_details_form(){
function view_csr_details_form(){
$config=$_SESSION['config'];
?>

Expand Down Expand Up @@ -417,7 +417,7 @@ function view_csr($my_csrfile) {
// ==================================================================================================================


function sign_csr_form($my_values=array('csr_name'=>'::zz::')){
function sign_csr_form($my_values=array('csr_name'=>'::zz::')){
$config=$_SESSION['config'];
?>
<p>
Expand Down
7 changes: 4 additions & 3 deletions include/functions_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function check_key_passphrase_form($my_values=array('key_name'=>'::zz::')){
$dh = opendir($config['key_path']) or die('Unable to open ' . $config['key_path']);
while (($file = readdir($dh)) !== false) {
if ( ($file !== ".htaccess") && is_file($config['key_path'].$file) ) {
if ( $my_values['key_name'] == "$name$ext") $this_selected=" selected=\"selected\""; else $this_selected="";
$name = base64_decode(substr($file, 0,strrpos($file,'.')));
$ext = substr($file, strrpos($file,'.'));
if ( $my_values['key_name'] == "$name$ext") $this_selected=" selected=\"selected\""; else $this_selected="";
print "<option value=\"$name$ext\"".$this_selected.">$name$ext</option>\n";
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ function get_public_ssh_key($this_key_name,$my_passPhrase) {
// =================== GET PRIVATE KEY =====================================================================================
// ==================================================================================================================

function get_mod_private_form(){
function get_mod_private_form($my_values=array('key_name'=>'::zz::')){
$config=$_SESSION['config'];
?>
<p>
Expand Down Expand Up @@ -170,7 +170,8 @@ function get_mod_private_form(){
if ( ($file !== ".htaccess") && is_file($config['key_path'].$file) ) {
$name = base64_decode(substr($file, 0,strrpos($file,'.')));
$ext = substr($file, strrpos($file,'.'));
print "<option value=\"$name$ext\">$name$ext</option>\n";
if ( $my_values['key_name'] == "$name$ext") $this_selected=" selected=\"selected\""; else $this_selected="";
print "<option value=\"$name$ext\"$this_selected>$name$ext</option>\n";
}
}
?>
Expand Down
23 changes: 16 additions & 7 deletions include/functions_layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ function display_menu() {
border: '2px solid #000',
},
onShowMenu: function(e, menu) {
if ( ($(e.target).parent().data('has_csr') == 'TRUE') || ($(e.target).parent().data('has_cert') == 'TRUE') || ($(e.target).parent().data('has_pkcs12') == 'TRUE') ) $('#no_actions', menu).remove();
if ($(e.target).parent().data('has_csr') == 'FALSE') $('#view_csr, #download_csr, #sign_csr', menu).remove();
if ($(e.target).parent().data('has_cert') == 'FALSE') $('#view_cert, #download_cert, #revoke_cert', menu).remove();
if ($(e.target).parent().data('has_pkcs12') == 'FALSE') $('#download_pkcs12', menu).remove();
var this_target = $(e.target).parent();
if (this_target.context.toString().indexOf('Font') !== -1) {this_target = this_target.parent();}
if ( (this_target.data('has_csr') == 'TRUE') || (this_target.data('has_cert') == 'TRUE') || (this_target.data('has_pkcs12') == 'TRUE') || (this_target.data('has_pkey') == 'TRUE') ) $('#no_actions', menu).remove();
if (this_target.data('has_csr') == 'FALSE') $('#view_csr, #download_csr, #sign_csr', menu).remove();
if (this_target.data('has_cert') == 'FALSE') $('#view_cert, #download_cert, #revoke_cert', menu).remove();
if (this_target.data('has_pkcs12') == 'FALSE') $('#download_pkcs12', menu).remove();
if ( (this_target.data('has_pkcs12') == 'TRUE') || (this_target.data('has_cert') == 'FALSE') ) $('#convert_pkcs12', menu).remove();
if (this_target.data('has_pkey') == 'FALSE') $('#check_pkey_passphrase, #download_pkey', menu).remove();
return menu;
},
bindings: {
Expand All @@ -78,9 +82,14 @@ function display_menu() {
'revoke_cert': function(t) {
$.post( 'index.php',{menuoption:'revoke_cert_form',cert_serial:$(t).data('serial_no'),cert_id:t.id,print_content_only:'TRUE'},function(data){var win = window.open('','Revoke Certificate','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=50,left=50,width=800,height=600');win.document.write(data);});
},
'check_key_passphrase': function(t) {
var url = '/phpca/index.php?menuoption=check_key_passphrase_form&key_name=' + t.id + '.pem';
window.location = url;
'check_pkey_passphrase': function(t) {
$.post( 'index.php',{menuoption:'check_key_passphrase_form',key_name:t.id+'.pem',print_content_only:'TRUE'},function(data){var win = window.open('','Check Key Passphrase','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=50,left=50,width=800,height=600');win.document.write(data);});
},
'download_pkey': function(t) {
$.post( 'index.php',{menuoption:'get_mod_private_form',key_name:t.id+'.pem',print_content_only:'TRUE'},function(data){var win = window.open('','Check Key Passphrase','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=50,left=50,width=800,height=600');win.document.write(data);});
},
'convert_pkcs12': function(t) {
$.post( 'index.php',{menuoption:'convert_cert_pkcs12_form',cert_name:t.id+'.pem',print_content_only:'TRUE'},function(data){var win = window.open('','Convert Certificate to PKCS12','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=50,left=50,width=800,height=600');win.document.write(data);});
}
}
});
Expand Down
72 changes: 38 additions & 34 deletions include/functions_show_summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ function show_summary() {
$my_grey_title="rgb(170,170,170)";
$my_grey_body="rgb(215,215,215)";
/*
$my_ascii_yes="&#9745";
$my_ascii_no="&#9746";
$my_ascii_yes="&#9745;";
$my_ascii_no="&#9746;";
*/
$my_ascii_yes="&#10004";
$my_ascii_no="&#10060";
$my_ascii_yes="&#10004;";
$my_ascii_no="&#10060;";
print "<div class='contextMenu' id='all_menu'>
<ul>
<li id='no_actions'>No Actions Available</li>
Expand All @@ -114,7 +114,10 @@ function show_summary() {
<li id='view_cert'>View Certificate details</li>
<li id='download_cert'>Download Cert</li>
<li id='revoke_cert'>Revoke Cert</li>
<li id='convert_pkcs12'>Create PKCS12 from Certificate</li>
<li id='download_pkcs12'>Download PKCS12</li>
<li id='check_pkey_passphrase'>Check Private Key Passphrase</li>
<li id='download_pkey'>Download Private Key</li>
</ul>
</div>\n";
print "<TABLE width=100% border=1>\n";
Expand All @@ -131,50 +134,50 @@ function show_summary() {
foreach ($status_array as $filename=>$this_array) {
$table_array=array();
if ($this_array['status']=="R") {
$table_array['status']['background']=$my_grey_body."\n";
$table_array['status']['font_colour']="red\n";
$table_array['status']['text']="Revoked\n";
$table_array['status']['background']=$my_grey_body;
$table_array['status']['font_colour']="red";
$table_array['status']['text']="Revoked";
$table_array['status']['menu']="is_revoked";
$table_array['status']['menu_id']=$this_array['unique'];
$table_array['status']['font_weight']="bold";
}
elseif ($this_array['status']=="E") {
$table_array['status']['background']=$my_grey_body."\n";
$table_array['status']['font_colour']="orange\n";
$table_array['status']['text']="Expired\n";
$table_array['status']['background']=$my_grey_body;
$table_array['status']['font_colour']="orange";
$table_array['status']['text']="Expired";
$table_array['status']['menu']="is_expired";
$table_array['status']['menu_id']=$this_array['unique'];
$table_array['status']['font_weight']="bold";
}
elseif ($this_array['status']=="V") {
$table_array['status']['background']=$my_grey_body."\n";
$table_array['status']['font_colour']="green\n";
$table_array['status']['text']="Valid\n";
$table_array['status']['background']=$my_grey_body;
$table_array['status']['font_colour']="green";
$table_array['status']['text']="Valid";
$table_array['status']['menu']="is_valid";
$table_array['status']['menu_id']=$this_array['unique'];
$table_array['status']['font_weight']="bold";
}
else {
$table_array['status']['background']=$my_grey_body."\n";
$table_array['status']['font_colour']="black\n";
$table_array['status']['text']="Unknown\n";
$table_array['status']['background']=$my_grey_body;
$table_array['status']['font_colour']="black";
$table_array['status']['text']="Unknown";
$table_array['status']['menu']="is_unknown";
$table_array['status']['menu_id']=$this_array['unique'];
$table_array['status']['font_weight']="normal";
}

if ($this_array['has_csr']==TRUE) {
$table_array['csr']['background']=$my_grey_body."\n";
$table_array['csr']['font_colour']="green\n";
$table_array['csr']['background']=$my_grey_body;
$table_array['csr']['font_colour']="green";
$table_array['csr']['text']=$my_ascii_yes;
$table_array['csr']['menu']="has_csr";
$table_array['csr']['menu_id']=$this_array['unique'];
$this_array['has_csr_string']="TRUE";
$table_array['csr']['font_weight']="bold";
}
else {
$table_array['csr']['background']=$my_grey_body."\n";
$table_array['csr']['font_colour']="red\n";
$table_array['csr']['background']=$my_grey_body;
$table_array['csr']['font_colour']="red";
$table_array['csr']['text']=$my_ascii_no;
$table_array['csr']['menu']="has_not_csr";
$table_array['csr']['menu_id']=$this_array['unique'];
Expand All @@ -183,17 +186,17 @@ function show_summary() {
}

if ($this_array['has_cert']==TRUE) {
$table_array['cert']['background']=$my_grey_body."\n";
$table_array['cert']['font_colour']="green\n";
$table_array['cert']['background']=$my_grey_body;
$table_array['cert']['font_colour']="green";
$table_array['cert']['text']=$my_ascii_yes;
$table_array['cert']['menu']="has_cert";
$table_array['cert']['menu_id']=$this_array['unique'];
$this_array['has_cert_string']="TRUE";
$table_array['cert']['font_weight']="bold";
}
else {
$table_array['cert']['background']=$my_grey_body."\n";
$table_array['cert']['font_colour']="red\n";
$table_array['cert']['background']=$my_grey_body;
$table_array['cert']['font_colour']="red";
$table_array['cert']['text']=$my_ascii_no;
$table_array['cert']['menu']="has_not_cert";
$table_array['cert']['menu_id']=$this_array['unique'];
Expand All @@ -202,17 +205,17 @@ function show_summary() {
}

if ($this_array['has_pkcs12']==TRUE) {
$table_array['pkcs12']['background']=$my_grey_body."\n";
$table_array['pkcs12']['font_colour']="green\n";
$table_array['pkcs12']['background']=$my_grey_body;
$table_array['pkcs12']['font_colour']="green";
$table_array['pkcs12']['text']=$my_ascii_yes;
$table_array['pkcs12']['menu']="has_pkcs12";
$table_array['pkcs12']['menu_id']=$this_array['unique'];
$this_array['has_pkcs12_string']="TRUE";
$table_array['pkcs12']['font_weight']="bold";
}
else {
$table_array['pkcs12']['background']=$my_grey_body."\n";
$table_array['pkcs12']['font_colour']="red\n";
$table_array['pkcs12']['background']=$my_grey_body;
$table_array['pkcs12']['font_colour']="red";
$table_array['pkcs12']['text']=$my_ascii_no;
$table_array['pkcs12']['menu']="has_not_pkcs12";
$table_array['pkcs12']['menu_id']=$this_array['unique'];
Expand All @@ -221,17 +224,17 @@ function show_summary() {
}

if ($this_array['has_pkey']==TRUE) {
$table_array['pkey']['background']=$my_grey_body."\n";
$table_array['pkey']['font_colour']="green\n";
$table_array['pkey']['background']=$my_grey_body;
$table_array['pkey']['font_colour']="green";
$table_array['pkey']['text']=$my_ascii_yes;
$table_array['pkey']['menu']="has_pkey";
$table_array['pkey']['menu_id']=$this_array['unique'];
$this_array['has_pkey_string']="TRUE";
$table_array['pkey']['font_weight']="bold";
}
else {
$table_array['pkey']['background']=$my_grey_body."\n";
$table_array['pkey']['font_colour']="red\n";
$table_array['pkey']['background']=$my_grey_body;
$table_array['pkey']['font_colour']="red";
$table_array['pkey']['text']=$my_ascii_no;
$table_array['pkey']['menu']="has_not_pkey";
$table_array['pkey']['menu_id']=$this_array['unique'];
Expand All @@ -240,7 +243,7 @@ function show_summary() {
}
$this_menu = "::::::".$table_array['status']['menu'].":::".$table_array['csr']['menu'].":::".$table_array['cert']['menu'].":::".$table_array['pkcs12']['menu'].":::".$table_array['pkey']['menu'].":::";

print "<TR class=\"all_menu_class\" id=\"".$this_array['unique']."\"";
print "<TR class=\"all_menu_class\" id=\"".$this_array['unique']."\"\n";
print " data-serial_no=\"".$this_array['dn']['serial_number']."\"";
print " data-has_csr=\"".$this_array['has_csr_string']."\"";
print " data-has_cert=\"".$this_array['has_cert_string']."\"";
Expand All @@ -255,7 +258,8 @@ function show_summary() {
print "<TD>".$this_array['dn']['st']."</TD>\n";
print "<TD>".$this_array['dn']['c']."</TD>\n";
foreach ($table_array as $this_cell=>$this_cell_array) {
print '<TD width=20px align=center style="font-weight:'.$this_cell_array['font_weight'].';background-color:'.$this_cell_array['background'].';"><font color='.$this_cell_array['font_colour'].'>'.$this_cell_array['text'].'</font></TD>';
print '<TD width=20px align=center style="font-weight:'.$this_cell_array['font_weight'].';background-color:'.$this_cell_array['background'].';"><font color='.$this_cell_array['font_colour'].'>'.$this_cell_array['text'].'</font></TD>';

print "\n";
}
print "</TR>\n\n";
Expand Down
Loading

0 comments on commit 1a97d4d

Please sign in to comment.