get.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. if (!isset($_POST['details'])) {
  3. header('Location:report.html');
  4. exit;
  5. }
  6. try {
  7. // Fazendo login no wekan:
  8. $ch = curl_init();
  9. curl_setopt($ch, CURLOPT_URL,"http://200.144.254.107/wekan/users/login");
  10. curl_setopt($ch, CURLOPT_POST, 1);
  11. curl_setopt($ch, CURLOPT_POSTFIELDS,
  12. "username=ivprogsite&password=T2mWR4vNr7tVwpTVR2gS");
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. $server_output = curl_exec($ch);
  15. curl_close ($ch);
  16. $dadosLogin = json_decode($server_output);
  17. if (!$dadosLogin) {
  18. throw new Exception();
  19. }
  20. // Preparando o texto para submeter ao wekan:
  21. $details = '';
  22. if (isset($_POST['name']) && !empty(trim($_POST['name']))) {
  23. $details .= 'Nome: ' . strip_tags(trim($_POST['name'])) . '\n';
  24. }
  25. if (isset($_POST['email']) && !empty(trim($_POST['email']))) {
  26. $details .= 'E-mail: ' . strip_tags(trim($_POST['email'])) . '\n';
  27. }
  28. $details .= 'Detalhes: ' . strip_tags(trim($_POST['details']));
  29. $summary = '';
  30. if (isset($_POST['summary']) && !empty(trim($_POST['summary']))) {
  31. $summary = strip_tags(trim($_POST['summary']));
  32. }
  33. // Fazendo a submissão dos dados para o Wekan:
  34. $ch = curl_init();
  35. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  36. 'Authorization: Bearer ' . $dadosLogin->token,
  37. 'Content-type:application/json'
  38. ));
  39. curl_setopt($ch, CURLOPT_URL,"http://200.144.254.107/wekan/api/boards/v82Wx3C3dk79t4pJw/lists/dHNhYSSyyqWhRn6NX/cards");
  40. curl_setopt($ch, CURLOPT_POST, 1);
  41. curl_setopt($ch, CURLOPT_POSTFIELDS,
  42. '{ "title": "'.$summary.'", "description": "'.$details.'", "authorId": "'. $dadosLogin->id.'", "swimlaneId": "HeJBje3EdmJ3GpZyb" }');
  43. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  44. $retorno = curl_exec($ch);
  45. curl_close ($ch);
  46. $resposta = json_decode($retorno);
  47. if (!$resposta->_id) {
  48. throw new Exception();
  49. }
  50. } catch (Exception $ex) {
  51. if (isset($_POST['redirect'])) {
  52. header('Location:'.$_POST['redirect'].'?error=true');
  53. exit;
  54. } else {
  55. header('Location:report.html?error=true');
  56. exit;
  57. }
  58. }
  59. if (isset($_POST['redirect'])) {
  60. header('Location:'.$_POST['redirect'].'?reported=true');
  61. exit;
  62. } else {
  63. header('Location:report.html?reported=true');
  64. exit;
  65. }
  66. ?>