Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <?php
  2.  
  3. $app->get('/api/logins/{id}', function(){
  4. require_once('db/dbconnect.php');
  5. foreach($db -> users()
  6. as $row) {
  7. $data[] = $row;
  8. }
  9. echo json_encode($data, JSON_UNESCAPED_UNICODE);
  10. });
  11.  
  12. $app->get('/api/id/{username}', function($request){
  13. $username = $request -> getAttribute('username');
  14. require_once('db/dbconnect.php');
  15. foreach($db -> users()
  16. -> select('id', 'username')
  17. -> where('username', $username)
  18. as $row){
  19. $data[] = $row;
  20. }
  21. if(isset($data)){
  22. echo json_encode($data, JSON_UNESCAPED_UNICODE);
  23. } else {
  24. echo json_encode("Id não existe.", JSON_UNESCAPED_UNICODE);
  25. }
  26. });
  27.  
  28. $app->get('/api/certificados/{id}', function($request){
  29. $id = $request -> getAttribute('id');
  30. require_once('db/dbconnect.php');
  31. foreach($db -> users()
  32. -> select('nome', 'nmrsaude', 'tiposangue', 'id')
  33. -> where ('id', $id)
  34. as $row){
  35. $data = $row;
  36. }
  37. if(isset($data)){
  38. echo json_encode($data, JSON_UNESCAPED_UNICODE);
  39. } else {
  40. echo json_encode("Certificado não existe.", JSON_UNESCAPED_UNICODE);
  41. }
  42. });
  43.  
  44. $app->get('/api/login/{username}', function($request){
  45. require_once('db/dbconnect.php');
  46. $dados = explode(";", $request -> getAttribute('username'),2);
  47.  
  48. $username = $dados[0];
  49. $password = $dados[1];
  50.  
  51. foreach($db -> users()
  52. -> select('username', 'password', 'id')
  53. -> where ('username', $username)
  54. -> where ('password', $password)
  55. as $row){
  56.  
  57. $data = $row;
  58.  
  59. }
  60. if(isset($data)) {
  61. echo "success";
  62. //echo json_encode($data, JSON_UNESCAPED_UNICODE);
  63. } else {
  64. echo json_encode("Login não existe.", JSON_UNESCAPED_UNICODE);
  65. }
  66. });
  67.  
  68.  
  69. $app->get('/api/historico/{id_user}', function($request){
  70. $id_user = $request -> getAttribute('id_user');
  71. require_once('db/dbconnect.php');
  72. foreach($db -> doacao()
  73. -> select('data','estado', 'id_user')
  74. -> where('id_user', $id_user)
  75. -> order("data")
  76. as $row){
  77. $data[] = $row;
  78. }
  79. if(isset($data)) {
  80. echo json_encode($data, JSON_UNESCAPED_UNICODE);
  81. } else {
  82. echo json_encode("Doação não existe.", JSON_UNESCAPED_UNICODE);
  83. }
  84. });
  85.  
  86. $app->get('/api/proxima/{id_user}', function($request){
  87. $id_user = $request -> getAttribute('id_user');
  88. require_once('db/dbconnect.php');
  89. foreach($db -> doacao()
  90. -> select('data')
  91. -> where('id_user', $id_user)
  92. -> order("data")
  93. as $row){
  94. $data[] = $row;
  95. }
  96. if(isset($data)) {
  97. echo json_encode($data, JSON_UNESCAPED_UNICODE);
  98. } else {
  99. echo json_encode("Doação não existe.", JSON_UNESCAPED_UNICODE);
  100. }
  101. });
  102.  
  103. $app->get('/api/notification/{id_user}', function($request){
  104. $id_user = $request -> getAttribute('id_user');
  105. require_once('db/dbconnect.php');
  106. foreach($db -> doacao()
  107. -> select('ID')
  108. -> where('estado', "1")
  109. -> where ('id_user', $id_user)
  110. -> order("ID")
  111. as $row){
  112. $data[] = $row;
  113. }
  114. if(isset($data)) {
  115. echo json_encode($data, JSON_UNESCAPED_UNICODE);
  116. } else {
  117. echo json_encode("Doação não existe.", JSON_UNESCAPED_UNICODE);
  118. }
  119. });
  120.  
  121. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement