Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $app->get('/api/logins/{id}', function(){
- require_once('db/dbconnect.php');
- foreach($db -> users()
- as $row) {
- $data[] = $row;
- }
- echo json_encode($data, JSON_UNESCAPED_UNICODE);
- });
- $app->get('/api/id/{username}', function($request){
- $username = $request -> getAttribute('username');
- require_once('db/dbconnect.php');
- foreach($db -> users()
- -> select('id', 'username')
- -> where('username', $username)
- as $row){
- $data[] = $row;
- }
- if(isset($data)){
- echo json_encode($data, JSON_UNESCAPED_UNICODE);
- } else {
- echo json_encode("Id não existe.", JSON_UNESCAPED_UNICODE);
- }
- });
- $app->get('/api/certificados/{id}', function($request){
- $id = $request -> getAttribute('id');
- require_once('db/dbconnect.php');
- foreach($db -> users()
- -> select('nome', 'nmrsaude', 'tiposangue', 'id')
- -> where ('id', $id)
- as $row){
- $data = $row;
- }
- if(isset($data)){
- echo json_encode($data, JSON_UNESCAPED_UNICODE);
- } else {
- echo json_encode("Certificado não existe.", JSON_UNESCAPED_UNICODE);
- }
- });
- $app->get('/api/login/{username}', function($request){
- require_once('db/dbconnect.php');
- $dados = explode(";", $request -> getAttribute('username'),2);
- $username = $dados[0];
- $password = $dados[1];
- foreach($db -> users()
- -> select('username', 'password', 'id')
- -> where ('username', $username)
- -> where ('password', $password)
- as $row){
- $data = $row;
- }
- if(isset($data)) {
- echo "success";
- //echo json_encode($data, JSON_UNESCAPED_UNICODE);
- } else {
- echo json_encode("Login não existe.", JSON_UNESCAPED_UNICODE);
- }
- });
- $app->get('/api/historico/{id_user}', function($request){
- $id_user = $request -> getAttribute('id_user');
- require_once('db/dbconnect.php');
- foreach($db -> doacao()
- -> select('data','estado', 'id_user')
- -> where('id_user', $id_user)
- -> order("data")
- as $row){
- $data[] = $row;
- }
- if(isset($data)) {
- echo json_encode($data, JSON_UNESCAPED_UNICODE);
- } else {
- echo json_encode("Doação não existe.", JSON_UNESCAPED_UNICODE);
- }
- });
- $app->get('/api/proxima/{id_user}', function($request){
- $id_user = $request -> getAttribute('id_user');
- require_once('db/dbconnect.php');
- foreach($db -> doacao()
- -> select('data')
- -> where('id_user', $id_user)
- -> order("data")
- as $row){
- $data[] = $row;
- }
- if(isset($data)) {
- echo json_encode($data, JSON_UNESCAPED_UNICODE);
- } else {
- echo json_encode("Doação não existe.", JSON_UNESCAPED_UNICODE);
- }
- });
- $app->get('/api/notification/{id_user}', function($request){
- $id_user = $request -> getAttribute('id_user');
- require_once('db/dbconnect.php');
- foreach($db -> doacao()
- -> select('ID')
- -> where('estado', "1")
- -> where ('id_user', $id_user)
- -> order("ID")
- as $row){
- $data[] = $row;
- }
- if(isset($data)) {
- echo json_encode($data, JSON_UNESCAPED_UNICODE);
- } else {
- echo json_encode("Doação não existe.", JSON_UNESCAPED_UNICODE);
- }
- });
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement