75 $enabled = $_POST['state'] == 'active'; |
79 $enabled = $_POST['state'] == 'active'; |
76 $any_client = isset($_POST['any_client']); |
80 $any_client = isset($_POST['any_client']); |
77 $notes = $_POST['notes']; |
81 $notes = $_POST['notes']; |
78 $result = yms_chown_yubikey($_POST['claim_otp'], $client_id, $enabled, $any_client, $notes); |
82 $result = yms_chown_yubikey($_POST['claim_otp'], $client_id, $enabled, $any_client, $notes); |
79 yms_send_response('yms_msg_addkey_success', $result); |
83 yms_send_response('yms_msg_addkey_success', $result); |
|
84 } |
|
85 else if ( $paths->getParam(0) == 'DeleteKey' && $paths->getParam(2) == 'Confirm' ) |
|
86 { |
|
87 csrf_request_confirm(); |
|
88 $id = intval($paths->getParam(1)); |
|
89 $result = yms_delete_key($id); |
|
90 yms_send_response('yms_msg_delete_success', $result); |
|
91 } |
|
92 |
|
93 if ( isset($_GET['toggle']) && isset($_GET['state']) ) |
|
94 { |
|
95 $id = intval($_GET['toggle']); |
|
96 if ( $_GET['state'] === 'active' ) |
|
97 $expr = 'flags | ' . YMS_ENABLED; |
|
98 else |
|
99 $expr = 'flags & ~' . YMS_ENABLED; |
|
100 |
|
101 $q = $db->sql_query('UPDATE ' . table_prefix . "yms_yubikeys SET flags = $expr WHERE id = $id AND client_id = {$session->user_id};"); |
|
102 if ( !$q ) |
|
103 $db->die_json(); |
80 } |
104 } |
81 |
105 |
82 // Preload JS libraries we need for Yubikey |
106 // Preload JS libraries we need for Yubikey |
83 $template->preload_js(array('jquery', 'jquery-ui', 'l10n', 'flyin', 'messagebox', 'fadefilter')); |
107 $template->preload_js(array('jquery', 'jquery-ui', 'l10n', 'flyin', 'messagebox', 'fadefilter')); |
84 // Load CSS |
108 // Load CSS |
106 </a> |
130 </a> |
107 </div> |
131 </div> |
108 <?php |
132 <?php |
109 |
133 |
110 // Pull all Yubikeys |
134 // Pull all Yubikeys |
111 $q = $db->sql_query('SELECT id, public_id, session_count, create_time, access_time, flags, notes FROM ' . table_prefix . "yms_yubikeys WHERE client_id = {$session->user_id};"); |
135 $q = $db->sql_query('SELECT id, public_id, session_count, create_time, access_time, flags, notes FROM ' . table_prefix . "yms_yubikeys WHERE client_id = {$session->user_id} ORDER BY id ASC;"); |
112 if ( !$q ) |
136 if ( !$q ) |
113 $db->_die(); |
137 $db->_die(); |
114 |
138 |
115 if ( $db->numrows() < 1 ) |
139 if ( $db->numrows() < 1 ) |
116 { |
140 { |
626 <?php |
650 <?php |
627 |
651 |
628 $output->footer(); |
652 $output->footer(); |
629 } |
653 } |
630 |
654 |
|
655 function page_Special_YMS_DeleteKey() |
|
656 { |
|
657 global $db, $session, $paths, $template, $plugins; // Common objects |
|
658 global $lang, $output; |
|
659 |
|
660 $output->add_after_header('<div class="breadcrumbs"> |
|
661 <a href="' . makeUrlNS('Special', 'YMS') . '">' . $lang->get('yms_specialpage_yms') . '</a> » |
|
662 ' . $lang->get('yms_btn_delete_key') . ' |
|
663 </div>'); |
|
664 |
|
665 $id = intval($paths->getParam(1)); |
|
666 if ( !$id ) |
|
667 die(); |
|
668 |
|
669 if ( $paths->getParam(2) == 'Confirm' ) |
|
670 { |
|
671 // go back, Jack! |
|
672 return true; |
|
673 } |
|
674 |
|
675 $delete_url = makeUrlNS('Special', "YMS/DeleteKey/$id/Confirm", "cstok={$session->csrf_token}", true); |
|
676 |
|
677 $output->header(); |
|
678 |
|
679 ?> |
|
680 <form action="<?php echo $delete_url; ?>" method="post"> |
|
681 <div style="text-align: center;"> |
|
682 <h3><?php echo $lang->get('yms_msg_delete_confirm'); ?></h3> |
|
683 <input type="hidden" name="placeholder" value="placeholder" /> |
|
684 <p> |
|
685 <a href="<?php echo $delete_url; ?>" onclick="return yms_ajax_submit(this);" class="abutton abutton_red icon" style="background-image: url(<?php echo scriptPath; ?>/plugins/yms/icons/key_delete.png);"> |
|
686 <?php echo $lang->get('yms_btn_delete_key'); ?> |
|
687 </a> |
|
688 </p> |
|
689 </div> |
|
690 </form> |
|
691 <?php |
|
692 |
|
693 $output->footer(); |
|
694 } |
|
695 |
631 function page_Special_YMS_AjaxToggleState() |
696 function page_Special_YMS_AjaxToggleState() |
632 { |
697 { |
633 global $db, $session, $paths, $template, $plugins; // Common objects |
698 global $db, $session, $paths, $template, $plugins; // Common objects |
634 |
699 |
635 $id = intval($_POST['id']); |
700 $id = intval($_POST['id']); |
822 |
887 |
823 function yms_state_indicator($flags, $id) |
888 function yms_state_indicator($flags, $id) |
824 { |
889 { |
825 global $lang; |
890 global $lang; |
826 return $flags & YMS_ENABLED ? |
891 return $flags & YMS_ENABLED ? |
827 '<span onclick="yms_toggle_state(this, ' . $id . ');" class="yms-enabled">' . $lang->get('yms_state_active') . '</span>' : |
892 '<a href="' . makeUrlNS('Special', 'YMS', "toggle=$id&state=inactive", true) . '" onclick="yms_toggle_state(this, ' . $id . '); return false;" class="yms-enabled">' . $lang->get('yms_state_active') . '</a>' : |
828 '<span onclick="yms_toggle_state(this, ' . $id . ');" class="yms-disabled">' . $lang->get('yms_state_inactive') . '</span>'; |
893 '<a href="' . makeUrlNS('Special', 'YMS', "toggle=$id&state=active", true) . '" onclick="yms_toggle_state(this, ' . $id . '); return false;" class="yms-disabled">' . $lang->get('yms_state_inactive') . '</a>'; |
829 } |
894 } |
830 |
895 |
831 function yms_notes_cell($notes, $id) |
896 function yms_notes_cell($notes, $id) |
832 { |
897 { |
833 global $lang; |
898 global $lang; |
861 // Show AES secret |
926 // Show AES secret |
862 ?> |
927 ?> |
863 <a href="<?php echo makeUrlNS('Special', "YMS/ShowAESKey/{$row['id']}"); ?>" title="<?php echo $lang->get('yms_btn_show_aes'); ?>" onclick="yms_showpage('ShowAESKey/<?php echo $row['id']; ?>'); return false;"> |
928 <a href="<?php echo makeUrlNS('Special', "YMS/ShowAESKey/{$row['id']}"); ?>" title="<?php echo $lang->get('yms_btn_show_aes'); ?>" onclick="yms_showpage('ShowAESKey/<?php echo $row['id']; ?>'); return false;"> |
864 <img alt="<?php echo $lang->get('yms_btn_show_aes'); ?>" src="<?php echo scriptPath; ?>/plugins/yms/icons/key_go.png" /> |
929 <img alt="<?php echo $lang->get('yms_btn_show_aes'); ?>" src="<?php echo scriptPath; ?>/plugins/yms/icons/key_go.png" /> |
865 </a> |
930 </a> |
|
931 <a href="<?php echo makeUrlNS('Special', "YMS/DeleteKey/{$row['id']}"); ?>" title="<?php echo $lang->get('yms_btn_delete_key'); ?>" onclick="yms_showpage('DeleteKey/<?php echo $row['id']; ?>'); return false;"> |
|
932 <img alt="<?php echo $lang->get('yms_btn_delete_key'); ?>" src="<?php echo scriptPath; ?>/plugins/yms/icons/key_delete.png" /> |
|
933 </a> |
866 <?php |
934 <?php |
867 } |
935 } |