示例#1
0
 public function read($data)
 {
     msAPI::log('[' . strtoupper($this->handler) . '] Reading data into readable array supported by all formats');
     switch ($this->handler) {
         case 'json':
             if (!in_array('json', $this->allowed)) {
                 msAPI::response('ERROR', 'JSON handler not enabled in settings, please enable.');
             }
             return msAPI::decode($data);
             break;
         case 'xml':
             if (!in_array('xml', $this->allowed)) {
                 msAPI::response('ERROR', 'XML handler not enabled in settings, please enable.');
             }
             if (!empty($data)) {
                 if (function_exists('simplexml_load_string')) {
                     return simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
                 } else {
                     msAPI::response('ERROR', 'Simple XML functions not enabled on server. Must be enabled to read xml data.');
                 }
             } else {
                 msAPI::response('ERROR', 'No post data received.');
             }
             break;
     }
 }
示例#2
0
    // Determine ops..
    $ops = $MSAPI->ops($read);
    // Check key..
    if (isset($ops['key']) && $ops['key'] == $SETTINGS->apiKey) {
        $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Key successfully checked and authenticated');
        // Run operation...
        switch ($ops['op']) {
            // Create ticket..
            case 'ticket':
                $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Preparing to add new tickets');
                include PATH . 'control/system/api/create-tickets.php';
                break;
                // Create account..
            // Create account..
            case 'account':
                $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Preparing to add new accounts');
                include PATH . 'control/system/api/create-accounts.php';
                break;
                // Something else?
            // Something else?
            default:
                $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Invalid operation: ' . $ops['op'] . ' is not supported');
                break;
        }
    } else {
        $MSAPI->log('[' . strtoupper($MSAPI->handler) . '] Invalid API key');
    }
}
// If we are, there wasn`t anything..
$MSAPI->response('ERROR', 'Nothing updated, check data or view log if enabled.');