コード例 #1
0
ファイル: rest.php プロジェクト: ehasanbegovic/testapp
    echo json_encode("ERROR!");
}
$method = $_SERVER['REQUEST_METHOD'];
$request = $_SERVER['REQUEST_URI'];
switch ($method) {
    case 'PUT':
        parse_str(file_get_contents('php://input'), $put_vars);
        sendHeaders();
        $data = $put_vars;
        rest_put($request, $data);
        break;
    case 'POST':
        sendHeaders();
        $data = $_POST;
        rest_post($request, $data);
        break;
    case 'GET':
        sendHeaders();
        $data = $_GET;
        rest_get($request, $data);
        break;
    case 'DELETE':
        sendHeaders();
        rest_delete($request);
        break;
    default:
        header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found");
        rest_error($request);
        break;
}
exit;
コード例 #2
0
ファイル: subproject.php プロジェクト: kitware/cdash
$projectid = pdo_real_escape_numeric($projectid);
// Make sure the user has access to this page.
$Project = new Project();
$User = new User();
$User->Id = $userid;
$Project->Id = $projectid;
$role = $Project->GetUserRole($userid);
if ($User->IsAdmin() === false && $role <= 1) {
    echo_error("You ({$userid}) don't have the permissions to access this page ({$projectid})");
    return;
}
// Route based on what type of request this is.
$method = $_SERVER['REQUEST_METHOD'];
switch ($method) {
    case 'DELETE':
        rest_delete();
        break;
    case 'POST':
        rest_post();
        break;
    case 'PUT':
        rest_put();
        break;
    case 'GET':
    default:
        rest_get();
        break;
}
/* Handle GET requests */
function rest_get()
{
コード例 #3
0
ファイル: test.php プロジェクト: OlegSmelov/old-projects
}
function rest_get($table, $id = null)
{
    $ch = get_curl($table, $id);
    return execute_curl($ch);
}
function rest_post($table, $values)
{
    $ch = get_curl($table, null);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, implode('|', $values));
    return execute_curl($ch);
}
function rest_delete($table, $id)
{
    $ch = get_curl($table, $id);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
    return execute_curl($ch);
}
echo "Getting students:\n";
echo rest_get('students');
echo "Adding a new student:\n";
$response = rest_post('students', array('Vardenis', 'Pavardenis', '857471588'));
preg_match('/Row id: ([0-9]+)/', $response, $matches);
$id = $matches[1];
echo $response;
echo "Getting students:\n";
echo rest_get('students');
echo "Deleting student:\n";
echo rest_delete('students', $id);
コード例 #4
0
    $value = rest_post();
    exit(json_encode($value));
});
$app->post('/post/html/update', function () use($app) {
    include 'post.php';
    $value = rest_post_html_update();
    exit(json_encode($value));
});
$app->post('/post/image', function () use($app) {
    include 'putImage.php';
    $value = saveImageFile();
    exit(json_encode($value));
});
$app->delete('/post/:id', function ($id) {
    include 'post.php';
    $value = rest_delete($id);
    exit(json_encode($value));
});
$app->put('/post/:id', function ($id) use($app) {
    include 'post.php';
    $put_vars = $app->request->put();
    $images_name = null;
    if (isset($put_vars['images_name'])) {
        $images_name = $put_vars['images_name'];
        unset($put_vars['images_name']);
    }
    $thumb_img_url = null;
    if (array_key_exists('thumb_img_path', $put_vars)) {
        $thumb_img_url = $put_vars['thumb_img_path'];
    }
    $keys = array_keys($put_vars);
コード例 #5
0
ファイル: api.php プロジェクト: Torniojaws/vortech-angular
    }
    switch ($method) {
        case 'PUT':
            rest_put($table, $id, $db);
            break;
        case 'POST':
            rest_post($table, $id, $db);
            break;
        case 'GET':
            rest_get($table, $id, $db, $params);
            break;
        case 'HEAD':
            rest_head($table, $id, $db);
            break;
        case 'DELETE':
            rest_delete($table, $id, $db);
            break;
        case 'OPTIONS':
            rest_options($table, $id, $db);
            break;
        default:
            rest_error();
            break;
    }
}
function rest_put($table, $id = null, $db, $data)
{
    /*
    	PUT /shows/123		Updates data of show "123"
    	PUT /shows			Updates data of all shows
    */