plugins/yubikey/admincp.php
changeset 0 9d2c4f04a0d0
child 8 032ca892b9a2
equal deleted inserted replaced
-1:000000000000 0:9d2c4f04a0d0
       
     1 <?php
       
     2 
       
     3 $plugins->attachHook('acp_general_users', 'yubikey_admin_cp_ui();');
       
     4 $plugins->attachHook('acp_general_save', 'yubikey_admin_cp_save();');
       
     5 
       
     6 function yubikey_admin_cp_ui()
       
     7 {
       
     8   global $lang;
       
     9   ?>
       
    10     <tr>
       
    11       <th colspan="2" class="subhead">
       
    12         <?php echo $lang->get('yubiacp_th'); ?>
       
    13       </th>
       
    14     </tr>
       
    15     
       
    16     <tr>
       
    17       <td class="row1">
       
    18         <?php echo $lang->get('yubiacp_field_enable_title'); ?>
       
    19       </td>
       
    20       <td class="row1">
       
    21         <label>
       
    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'); ?>
       
    24         </label>
       
    25       </td>
       
    26     </tr>
       
    27     
       
    28     <tr>
       
    29       <td class="row2">
       
    30         <?php echo $lang->get('yubiacp_field_api_key'); ?>
       
    31       </td>
       
    32       <td class="row2">
       
    33         <input type="text" name="yubikey_api_key" value="<?php echo htmlspecialchars(getConfig('yubikey_api_key', '')); ?>" size="30" />
       
    34       </td>
       
    35     </tr>
       
    36     
       
    37     <tr>
       
    38       <td class="row1">
       
    39         <?php echo $lang->get('yubiacp_field_api_key_id'); ?>
       
    40       </td>
       
    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" />
       
    43       </td>
       
    44     </tr>
       
    45     
       
    46     <tr>
       
    47       <td class="row2">
       
    48         <?php echo $lang->get('yubiacp_field_auth_server'); ?>
       
    49       </td>
       
    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" />
       
    52       </td>
       
    53     </tr>
       
    54     
       
    55     <tr>
       
    56       <td class="row1">
       
    57         <?php echo $lang->get('yubiacp_field_enroll_limit'); ?>
       
    58       </td>
       
    59       <td class="row1">
       
    60         <input type="text" name="yubikey_enroll_limit" value="<?php echo strval(intval(getConfig('yubikey_enroll_limit', '3'))); ?>" size="5" />
       
    61       </td>
       
    62     </tr>
       
    63     
       
    64   <?php
       
    65 }
       
    66 
       
    67 function yubikey_admin_cp_save()
       
    68 {
       
    69   global $lang;
       
    70   
       
    71   // yubikey_enable, yubikey_api_key, yubikey_api_key_id, yubikey_auth_server, yubikey_enroll_limit
       
    72   setConfig('yubikey_enable', isset($_POST['yubikey_enable']) ? '1' : '0');
       
    73   setConfig('yubikey_api_key', $_POST['yubikey_api_key']);
       
    74   setConfig('yubikey_api_key_id', intval($_POST['yubikey_api_key_id']));
       
    75   setConfig('yubikey_enroll_limit', intval($_POST['yubikey_enroll_limit']));
       
    76   
       
    77   if ( preg_match('#^(?:https?://)?(\[?[a-z0-9-:]+(?:\.[a-z0-9-:]+\]?)*)(/.*)$#', $_POST['yubikey_auth_server']) )
       
    78     setConfig('yubikey_auth_server', $_POST['yubikey_auth_server']);
       
    79   else
       
    80     echo '<div class="error-box">' . $lang->get('yubiacp_err_invalid_auth_server') . '</div>';
       
    81 }
       
    82