} } } } $r_resource_vars = array(); if (preg_match_all('/([^\\/]+)\\/(\\d+)/', $_url_parts_with_ext[0], $matches)) { for ($i = 0, $len = count($matches[0]); $i < $len; ++$i) { $r_resource_vars[$matches[1][$i]] = $matches[2][$i]; } } $post_data = array(); if ($_SERVER['REQUEST_METHOD'] == 'PUT') { $r_put = json_decode(file_get_contents('php://input')); $post_data = $r_put = (array) $r_put; } if ($r_resource_cmd == '/users/logout' || checkAclLinks($_SERVER['REQUEST_METHOD'], $r_resource_cmd, $r_resource_vars, $post_data)) { // /users/5/products/10 -> array('users' => 5, 'products' => 10) ... if (!empty($response['scope'])) { $scope = explode(" ", $response['scope']); } if ($r_resource_type == 'json') { $is_valid_req = false; // Server... switch ($_SERVER['REQUEST_METHOD']) { case 'GET': if (in_array('read', $scope)) { r_get($r_resource_cmd, $r_resource_vars, $r_resource_filters); $is_valid_req = true; } else { header($_SERVER['SERVER_PROTOCOL'] . ' 401 Authentication failed', true, 401); }
echo json_encode($response); exit; } else { if ($r_resource_cmd != '/settings') { $post_val = array('grant_type' => 'client_credentials', 'client_id' => OAUTH_CLIENTID, 'client_secret' => OAUTH_CLIENT_SECRET); $response = getToken($post_val); $qry_val_arr = array(3); $role_links = executeQuery('SELECT * FROM role_links_listing WHERE id = $1', $qry_val_arr); $response = array_merge($response, $role_links); echo json_encode($response); exit; } } } } if ($r_resource_cmd == '/users/logout' || checkAclLinks($_SERVER['REQUEST_METHOD'], $r_resource_cmd)) { // /users/5/products/10 -> array('users' => 5, 'products' => 10) ... $r_resource_vars = array(); if (preg_match_all('/([^\\/]+)\\/(\\d+)/', $_url_parts_with_ext[0], $matches)) { for ($i = 0, $len = count($matches[0]); $i < $len; ++$i) { $r_resource_vars[$matches[1][$i]] = $matches[2][$i]; } } if ($r_resource_type == 'json') { $is_valid_req = false; // Server... switch ($_SERVER['REQUEST_METHOD']) { case 'GET': r_get($r_resource_cmd, $r_resource_vars, $r_resource_filters); $is_valid_req = true; break;