3 $plugins->attachHook('acp_general_users', 'yubikey_admin_cp_ui();'); |
3 $plugins->attachHook('acp_general_users', 'yubikey_admin_cp_ui();'); |
4 $plugins->attachHook('acp_general_save', 'yubikey_admin_cp_save();'); |
4 $plugins->attachHook('acp_general_save', 'yubikey_admin_cp_save();'); |
5 |
5 |
6 function yubikey_admin_cp_ui() |
6 function yubikey_admin_cp_ui() |
7 { |
7 { |
8 global $lang; |
8 global $lang; |
9 ?> |
9 ?> |
10 <tr> |
10 <tr> |
11 <th colspan="2" class="subhead"> |
11 <th colspan="2" class="subhead"> |
12 <?php echo $lang->get('yubiacp_th'); ?> |
12 <?php echo $lang->get('yubiacp_th'); ?> |
13 </th> |
13 </th> |
14 </tr> |
14 </tr> |
15 |
15 |
16 <tr> |
16 <tr> |
17 <td class="row1"> |
17 <td class="row1"> |
18 <?php echo $lang->get('yubiacp_field_enable_title'); ?> |
18 <?php echo $lang->get('yubiacp_field_enable_title'); ?> |
19 </td> |
19 </td> |
20 <td class="row1"> |
20 <td class="row1"> |
21 <label> |
21 <label> |
22 <input type="checkbox" name="yubikey_enable" <?php if ( getConfig('yubikey_enable', '1') == '1' ) echo 'checked="checked" '; ?>/> |
22 <input type="checkbox" name="yubikey_enable" <?php if ( getConfig('yubikey_enable', '1') == '1' ) echo 'checked="checked" '; ?>/> |
23 <?php echo $lang->get('yubiacp_field_enable'); ?> |
23 <?php echo $lang->get('yubiacp_field_enable'); ?> |
24 </label> |
24 </label> |
25 </td> |
25 </td> |
26 </tr> |
26 </tr> |
27 |
27 |
28 <tr> |
28 <tr> |
29 <td class="row2"> |
29 <td class="row2"> |
30 <?php echo $lang->get('yubiacp_field_api_key'); ?> |
30 <?php echo $lang->get('yubiacp_field_api_key'); ?> |
31 </td> |
31 </td> |
32 <td class="row2"> |
32 <td class="row2"> |
33 <input type="text" name="yubikey_api_key" value="<?php echo htmlspecialchars(getConfig('yubikey_api_key', '')); ?>" size="30" /> |
33 <input type="text" name="yubikey_api_key" value="<?php echo htmlspecialchars(getConfig('yubikey_api_key', '')); ?>" size="30" /> |
34 </td> |
34 </td> |
35 </tr> |
35 </tr> |
36 |
36 |
37 <tr> |
37 <tr> |
38 <td class="row1"> |
38 <td class="row1"> |
39 <?php echo $lang->get('yubiacp_field_api_key_id'); ?> |
39 <?php echo $lang->get('yubiacp_field_api_key_id'); ?> |
40 </td> |
40 </td> |
41 <td class="row1"> |
41 <td class="row1"> |
42 <input type="text" name="yubikey_api_key_id" value="<?php echo strval(intval(getConfig('yubikey_api_key_id', ''))); ?>" size="5" /> |
42 <input type="text" name="yubikey_api_key_id" value="<?php echo strval(intval(getConfig('yubikey_api_key_id', ''))); ?>" size="5" /> |
43 </td> |
43 </td> |
44 </tr> |
44 </tr> |
45 |
45 |
46 <tr> |
46 <tr> |
47 <td class="row2"> |
47 <td class="row2"> |
48 <?php echo $lang->get('yubiacp_field_auth_server'); ?> |
48 <?php echo $lang->get('yubiacp_field_auth_server'); ?> |
49 </td> |
49 </td> |
50 <td class="row2"> |
50 <td class="row2"> |
51 <input type="text" name="yubikey_auth_server" value="<?php echo htmlspecialchars(getConfig('yubikey_auth_server', YK_DEFAULT_VERIFY_URL)); ?>" size="30" /> |
51 <input type="text" name="yubikey_auth_server" value="<?php echo htmlspecialchars(getConfig('yubikey_auth_server', YK_DEFAULT_VERIFY_URL)); ?>" size="30" /> |
52 <?php |
52 <?php |
53 if ( defined('YMS_INSTALLED') ) |
53 if ( defined('YMS_INSTALLED') ) |
54 { |
54 { |
55 echo '<br />'; |
55 echo '<br />'; |
56 echo $lang->get('yubiacp_field_use_local_pre'); |
56 echo $lang->get('yubiacp_field_use_local_pre'); |
57 ?> <label><input type="checkbox" name="yubikey_use_local_yms" <?php echo getConfig('yubikey_use_local_yms', 0) ? 'checked="checked" ' : ''; ?>/><?php |
57 ?> <label><input type="checkbox" name="yubikey_use_local_yms" <?php echo getConfig('yubikey_use_local_yms', 0) ? 'checked="checked" ' : ''; ?>/><?php |
58 echo $lang->get('yubiacp_field_use_local'); |
58 echo $lang->get('yubiacp_field_use_local'); |
59 echo '</label>'; |
59 echo '</label>'; |
60 } |
60 } |
61 ?> |
61 ?> |
62 </td> |
62 </td> |
63 </tr> |
63 </tr> |
64 |
64 |
65 <tr> |
65 <tr> |
66 <td class="row1"> |
66 <td class="row1"> |
67 <?php echo $lang->get('yubiacp_field_enroll_limit'); ?> |
67 <?php echo $lang->get('yubiacp_field_enroll_limit'); ?> |
68 </td> |
68 </td> |
69 <td class="row1"> |
69 <td class="row1"> |
70 <input type="text" name="yubikey_enroll_limit" value="<?php echo strval(intval(getConfig('yubikey_enroll_limit', '3'))); ?>" size="5" /> |
70 <input type="text" name="yubikey_enroll_limit" value="<?php echo strval(intval(getConfig('yubikey_enroll_limit', '3'))); ?>" size="5" /> |
71 </td> |
71 </td> |
72 </tr> |
72 </tr> |
73 |
73 |
74 <tr> |
74 <tr> |
75 <td class="row2"> |
75 <td class="row2"> |
76 <?php echo $lang->get('yubiacp_field_reg_require_otp_title'); ?><br /> |
76 <?php echo $lang->get('yubiacp_field_reg_require_otp_title'); ?><br /> |
77 <small><?php echo $lang->get('yubiacp_field_reg_require_otp_hint'); ?></small> |
77 <small><?php echo $lang->get('yubiacp_field_reg_require_otp_hint'); ?></small> |
78 </td> |
78 </td> |
79 <td class="row2"> |
79 <td class="row2"> |
80 <label> |
80 <label> |
81 <input type="checkbox" name="yubikey_reg_require_otp" <?php if ( getConfig('yubikey_reg_require_otp', '0') == '1' ) echo 'checked="checked" '; ?>/> |
81 <input type="checkbox" name="yubikey_reg_require_otp" <?php if ( getConfig('yubikey_reg_require_otp', '0') == '1' ) echo 'checked="checked" '; ?>/> |
82 <?php echo $lang->get('yubiacp_field_reg_require_otp'); ?> |
82 <?php echo $lang->get('yubiacp_field_reg_require_otp'); ?> |
83 </label> |
83 </label> |
84 </td> |
84 </td> |
85 </tr> |
85 </tr> |
86 |
86 |
87 <?php |
87 <?php |
88 } |
88 } |
89 |
89 |
90 function yubikey_admin_cp_save() |
90 function yubikey_admin_cp_save() |
91 { |
91 { |
92 global $lang; |
92 global $lang; |
93 |
93 |
94 // yubikey_enable, yubikey_api_key, yubikey_api_key_id, yubikey_auth_server, yubikey_enroll_limit |
94 // yubikey_enable, yubikey_api_key, yubikey_api_key_id, yubikey_auth_server, yubikey_enroll_limit |
95 setConfig('yubikey_enable', isset($_POST['yubikey_enable']) ? '1' : '0'); |
95 setConfig('yubikey_enable', isset($_POST['yubikey_enable']) ? '1' : '0'); |
96 setConfig('yubikey_api_key', $_POST['yubikey_api_key']); |
96 setConfig('yubikey_api_key', $_POST['yubikey_api_key']); |
97 setConfig('yubikey_api_key_id', intval($_POST['yubikey_api_key_id'])); |
97 setConfig('yubikey_api_key_id', intval($_POST['yubikey_api_key_id'])); |
98 setConfig('yubikey_enroll_limit', intval($_POST['yubikey_enroll_limit'])); |
98 setConfig('yubikey_enroll_limit', intval($_POST['yubikey_enroll_limit'])); |
99 setConfig('yubikey_reg_require_otp', isset($_POST['yubikey_reg_require_otp']) ? '1' : '0'); |
99 setConfig('yubikey_reg_require_otp', isset($_POST['yubikey_reg_require_otp']) ? '1' : '0'); |
100 setConfig('yubikey_use_local_yms', isset($_POST['yubikey_use_local_yms']) && defined('YMS_INSTALLED') ? '1' : '0'); |
100 setConfig('yubikey_use_local_yms', isset($_POST['yubikey_use_local_yms']) && defined('YMS_INSTALLED') ? '1' : '0'); |
101 |
101 |
102 if ( preg_match('#^(?:https?://)?(\[?[a-z0-9-:]+(?:\.[a-z0-9-:]+\]?)*)(/.*)$#', $_POST['yubikey_auth_server']) ) |
102 if ( preg_match('#^(?:https?://)?(\[?[a-z0-9-:]+(?:\.[a-z0-9-:]+\]?)*)(/.*)$#', $_POST['yubikey_auth_server']) ) |
103 setConfig('yubikey_auth_server', $_POST['yubikey_auth_server']); |
103 setConfig('yubikey_auth_server', $_POST['yubikey_auth_server']); |
104 else |
104 else |
105 echo '<div class="error-box">' . $lang->get('yubiacp_err_invalid_auth_server') . '</div>'; |
105 echo '<div class="error-box">' . $lang->get('yubiacp_err_invalid_auth_server') . '</div>'; |
106 } |
106 } |
107 |
107 |