Skip to content
Snippets Groups Projects
apikey.inc.php 3.91 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jared Hancock's avatar
    Jared Hancock committed
    <?php
    
    if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
    
    Jared Hancock's avatar
    Jared Hancock committed
    $info=array();
    $qstr='';
    if($api && $_REQUEST['a']!='add'){
        $title='Update API Key';
        $action='update';
        $submit_text='Save Changes';
    
    Jared Hancock's avatar
    Jared Hancock committed
        $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(); ?>
    
    Jared Hancock's avatar
    Jared Hancock committed
     <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 auto-generated. Delete and re-add to change the key.</em>
    
    Jared Hancock's avatar
    Jared Hancock committed
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
    
    Jared Hancock's avatar
    Jared Hancock committed
                    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>
    
    Jared Hancock's avatar
    Jared Hancock committed
                    IP Address:
                </td>
                <td>
                    <?php echo $api->getIPAddr(); ?>
                </td>
            </tr>
            <tr>
    
    Jared Hancock's avatar
    Jared Hancock committed
                    API Key:
                </td>
    
                <td><?php echo $api->getKey(); ?> &nbsp;</td>
    
    Jared Hancock's avatar
    Jared Hancock committed
            </tr>
            <?php }else{ ?>
            <tr>
    
    Jared Hancock's avatar
    Jared Hancock committed
                   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>Services:</strong>: Check applicable API services enabled for the key.</em>
    
    Jared Hancock's avatar
    Jared Hancock committed
                </th>
            </tr>
            <tr>
    
                <td colspan=2 style="padding-left:5px">
    
                    <label>
                        <input type="checkbox" name="can_create_tickets" value="1" <?php echo $info['can_create_tickets']?'checked="checked"':''; ?> >
                        Can Create Tickets <em>(XML/JSON/EMAIL)</em>
                    </label>
                </td>
            </tr>
            <tr>
                <td colspan=2 style="padding-left:5px">
                    <label>
                        <input type="checkbox" name="can_exec_cron" value="1" <?php echo $info['can_exec_cron']?'checked="checked"':''; ?> >
                        Can Execute Cron
                    </label>
    
    Jared Hancock's avatar
    Jared Hancock committed
                </td>
            </tr>
            <tr>
                <th colspan="2">
                    <em><strong>Admin Notes</strong>: Internal notes.&nbsp;</em>
                </th>
            </tr>
            <tr>
                <td colspan=2>
    
                    <textarea class="richtext no-bar" name="notes" cols="21"
                        rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
    
    Jared Hancock's avatar
    Jared Hancock committed
                </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>