Esempio n. 1
0
 public function parseResponse($doc, $format = TWG_DEFAULT_DATA_FORMAT)
 {
     $data = ApiData::parseDocument($doc, $format);
     if (empty($data)) {
         return false;
     }
     if (!empty($data['error'])) {
         $this->errors = ApiData::getObjects($data['error']);
     }
     $this->data = $data;
     return true;
 }
Esempio n. 2
0
function fn_twg_get_api_data($response, $format, $required = true)
{
    $data = array();
    if (!empty($_REQUEST['data'])) {
        $data = ApiData::parseDocument(base64_decode(rawurldecode($_REQUEST['data'])), $format);
    } elseif ($required) {
        $response->addError('ERROR_WRONG_DATA', __('twgadmin_wrong_api_data'));
        $response->returnResponse();
    }
    return $data;
}
Esempio n. 3
0
$api_version = !empty($_REQUEST['api_version']) ? $_REQUEST['api_version'] : TWG_DEFAULT_API_VERSION;
$response = new ApiData($api_version, $format);
$object = !empty($_REQUEST['object']) ? $_REQUEST['object'] : '';
$lang_code = CART_LANGUAGE;
if (!empty($_REQUEST['language'])) {
    if (in_array($_REQUEST['language'], array_keys(Registry::get('languages')))) {
        $lang_code = $_REQUEST['language'];
    }
}
if (!fn_twg_validate_auth()) {
    $response->addError('ERROR_ACCESS_DENIED', __('access_denied', $lang_code));
    $response->returnResponse();
}
$data = '';
if (!empty($_REQUEST['data'])) {
    $data = ApiData::parseDocument(base64_decode(rawurldecode($_REQUEST['data'])), $format);
    if (!empty($_REQUEST['action'])) {
        $_data = Api::parseApiList($data, $object);
        $data = ApiData::getObjects($_data);
    }
}
$update_actions = array('update', 'delete');
if ($_SERVER['REQUEST_METHOD'] == 'POST' && in_array($_REQUEST['action'], $update_actions)) {
    if (empty($data)) {
        $response->addError('ERROR_WRONG_DATA', __('twgadmin_wrong_api_data'));
    }
    if ($mode == 'post') {
        if ($object == 'users') {
            foreach ($data as $user) {
                if (!empty($user['user_id'])) {
                    if ($_REQUEST['action'] == 'update') {