Location: PHPKode > projects > osTicket > osTicket-osTicket-1.7-86abb65/include/staff/apikey.inc.php
<?php
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$info=array();
$qstr='';
if($api && $_REQUEST['a']!='add'){
    $title='Update API Key';
    $action='update';
    $submit_text='Save Changes';
    $info['id']=$api->getId();
    $info['isactive']=$api->isActive()?1:0;
    $info['notes']=$api->getNotes();
    $qstr.='&id='.$api->getId();
}else {
    $title='Add New API Key';
    $action='add';
    $submit_text='Add Key';
    $info['isactive']=isset($info['isactive'])?$info['isactive']:1;
    $qstr.='&a='.urlencode($_REQUEST['a']);
}
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
?>
<form action="apikeys.php?<?php echo $qstr; ?>" method="post" id="save">
 <?php csrf_token(); ?>
 <input type="hidden" name="do" value="<?php echo $action; ?>">
 <input type="hidden" name="a" value="<?php echo Format::htmlchars($_REQUEST['a']); ?>">
 <input type="hidden" name="id" value="<?php echo $info['id']; ?>">
 <h2>API Key</h2>
 <table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
    <thead>
        <tr>
            <th colspan="2">
                <h4><?php echo $title; ?></h4>
                <em>API Key is autogenerated and unique per IP address.</em>
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td width="180" class="required">
                Status:
            </td>
            <td>
                <input type="radio" name="isactive" value="1" <?php echo $info['isactive']?'checked="checked"':''; ?>><strong>Active</strong>
                <input type="radio" name="isactive" value="0" <?php echo !$info['isactive']?'checked="checked"':''; ?>>Disabled
                &nbsp;<span class="error">*&nbsp;</span>
            </td>
        </tr>
        <?php if($api){ ?>
        <tr>
            <td width="180">
                IP Address:
            </td>
            <td>
                <?php echo $api->getIPAddr(); ?>
            </td>
        </tr>
        <tr>
            <td width="180">
                API Key:
            </td>
            <td><?php echo $api->getKey(); ?> &nbsp;&nbsp;<em>(Delete and re-add to change the key)</em></td>
        </tr>
        <?php }else{ ?>
        <tr>
            <td width="180" class="required">
               IP Address:
            </td>
            <td>
                <input type="text" size="30" name="ipaddr" value="<?php echo $info['ipaddr']; ?>">
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['ipaddr']; ?></span>
            </td>
        </tr>
        <?php } ?>
        <tr>
            <th colspan="2">
                <em><strong>Enabled Services:</strong>: Check applicable API services.</em>
            </th>
        </tr>
        <tr>
            <td width="180">
                Email piping:
            </td>
            <td>
                <input type="checkbox" name="email_piping" value="1" checked="checked" disabled="disabled" >
                    <strong>Enable</strong> remote email piping.
            </td>
        </tr>
        <tr>
            <th colspan="2">
                <em><strong>Admin Notes</strong>: Internal notes.&nbsp;</em>
            </th>
        </tr>
        <tr>
            <td colspan=2>
                <textarea name="notes" cols="21" rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
            </td>
        </tr>
    </tbody>
</table>
<p style="padding-left:225px;">
    <input type="submit" name="submit" value="<?php echo $submit_text; ?>">
    <input type="reset"  name="reset"  value="Reset">
    <input type="button" name="cancel" value="Cancel" onclick='window.location.href="apikeys.php"'>
</p>
</form>
Return current item: osTicket