Exemple #1
0
});
$app->post('/ajoutRendezVous', function () use($app) {
    $data = json_decode($app->request->getBody());
    $mandatory = array('DateDebut', 'DateFin', 'idAgenda');
    $data->DateDebut = date('Y-m-d H:i:s', strtotime($data->DateDebut));
    $data->DateFin = date('Y-m-d H:i:s', strtotime($data->DateFin));
    global $db;
    $rows = $db->insert("rendez_vous", $data, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Rendez-vous ajouté !";
    }
    echoResponse(200, $rows);
});
$app->delete('/agendas/:idAgenda', function ($idAgenda) {
    global $db;
    $rows = $db->delete("agenda", array('idAgenda' => $idAgenda));
    if ($rows["status"] == "success") {
        $rows["message"] = "Agenda effacé";
    }
    echoResponse(200, $rows);
});
$app->delete('/rendez_vous/:idRDV', function ($idRDV) {
    global $db;
    $rows = $db->delete("rendez_vous", array('idRDV' => $idRDV));
    if ($rows["status"] == "success") {
        $rows["message"] = "Rendez-vous effacé";
    }
    echoResponse(200, $rows);
});
$app->delete('/inscription/:mail/:idRDV', function ($mail, $idRDV) {
    global $db;
        $rows["message"] = "Product added successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/products/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('id' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("products", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->delete('/products/:id', function ($id) {
    global $db;
    $rows = $db->delete("products", array('id' => $id));
    if ($rows["status"] == "success") {
        $rows["message"] = "Product removed successfully.";
    }
    echoResponse(200, $rows);
});
function echoResponse($status_code, $response)
{
    global $app;
    $app->status($status_code);
    $app->contentType('application/json');
    echo json_encode($response, JSON_NUMERIC_CHECK);
}
$app->run();
Exemple #3
0
        $rows["message"] = "Company added successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/companies/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('CompanyID' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("companies", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Company information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->delete('/companies/:id', function ($id) {
    global $db;
    $rows = $db->delete("companies", array('CompanyID' => $id));
    if ($rows["status"] == "success") {
        $rows["message"] = "Company removed successfully.";
    }
    echoResponse(200, $rows);
});
function echoResponse($status_code, $response)
{
    global $app;
    $app->status($status_code);
    $app->contentType('application/json');
    echo json_encode($response, JSON_NUMERIC_CHECK);
}
$app->run();
Exemple #4
0
    //error_log("$time [$script_name] [rtbh] [$remote_addr-$myuser] [no chain specified]\n", 3, $log_file);
    $error = " invalid params ";
    $status = "ERROR";
    $message = $error;
}
if ($error === "") {
    /* select row from DB */
    $del_user = $_SESSION['USER'];
    $rows = $db->select6($table_name, array('id' => "{$id}"));
    /* make sure we have at leats 1 row . If not it means rowid not in DB */
    if (count($rows['data']) > 0) {
        $sourceip = $rows['data'][0]['ip'];
        /* keep track of the user deleting the row */
        $rows = $db->update($table_name, array('insertby' => "{$del_user}"), array('id' => "{$id}"), array('insertby'));
        /* delete the row */
        $rows = $db->delete($table_name, array('id' => "{$id}"));
        $status = $rows['status'];
        $message = $rows['message'] . ", {$sourceip} deleted.";
    } else {
        $error = " row id does not exist ";
        $status = "ERROR";
        $message = $error;
    }
}
?>
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="description" content="RTBH">
<link rel="shortcut icon" href="/common/favicon.ico" />
    echoResponse(200, $rows);
});
$app->put('/bolas/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('id' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("bolas", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->delete('/bolas/:id', function ($id) {
    global $db;
    $rows = $db->delete("bolas", array('id' => $id));
    if ($rows["status"] == "success") {
        $rows["message"] = "Product removed successfully.";
    }
    echoResponse(200, $rows);
});
$app->get('/personas', function () {
    global $db;
    $rows = $db->select("personas", "*", array());
    echoResponse(200, $rows);
});
$app->post('/personas', function () use($app) {
    $data = json_decode($app->request->getBody());
    $mandatory = array('name');
    global $db;
    $rows = $db->insert("personas", $data, $mandatory);
    echoResponse(200, $rows);
});
$app->put('/users/:user_id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('user_id' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("users", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "User information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->delete('/products/:id', function ($id) {
    global $db;
    $rows = $db->delete("products", array('user_id' => $id));
    if ($rows["status"] == "success") {
        $rows["message"] = "Product removed successfully.";
    }
    echoResponse(200, $rows);
});
$app->delete('/users/:user_id', function ($id) {
    global $db;
    $rows = $db->delete("users", array('user_id' => $id));
    if ($rows["status"] == "success") {
        $rows["message"] = "Product removed successfully.";
    }
    echoResponse(200, $rows);
});
function echoResponse($status_code, $response)
{
Exemple #7
0
        $rows["message"] = "Product added successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/products/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('id' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("inventory", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->delete('/products/:id', function ($id) {
    global $db;
    $rows = $db->delete("inventory", array('id' => $id));
    if ($rows["status"] == "success") {
        $rows["message"] = "Product removed successfully.";
    }
    echoResponse(200, $rows);
});
function echoResponse($status_code, $response)
{
    global $app;
    $app->status($status_code);
    $app->contentType('application/json');
    echo json_encode($response, JSON_NUMERIC_CHECK);
}
$app->run();