浏览代码

Implementada a página de reportar bugs

Igor 6 年之前
父节点
当前提交
04ce69d539
共有 3 个文件被更改,包括 228 次插入2 次删除
  1. 75 0
      bugs/get.php
  2. 148 0
      bugs/report.html
  3. 5 2
      index.html

+ 75 - 0
bugs/get.php

@@ -0,0 +1,75 @@
+<?php
+	if (!isset($_POST['details'])) {
+    	header('Location:report.html');
+    	exit;
+ 	}
+
+ 	try {
+		// Fazendo login no wekan:
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL,"http://200.144.254.107/wekan/users/login");
+		curl_setopt($ch, CURLOPT_POST, 1);
+		curl_setopt($ch, CURLOPT_POSTFIELDS,
+		            "username=ivprogsite&password=T2mWR4vNr7tVwpTVR2gS");
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		$server_output = curl_exec($ch);
+		curl_close ($ch);
+		$dadosLogin = json_decode($server_output);
+
+		if (!$dadosLogin) {
+			throw new Exception();
+		}
+
+		// Preparando o texto para submeter ao wekan:
+		$details = '';
+		if (isset($_POST['name']) && !empty(trim($_POST['name']))) {
+			$details .= 'Nome: ' . strip_tags(trim($_POST['name'])) . '\n';
+		}
+		if (isset($_POST['email']) && !empty(trim($_POST['email']))) {
+			$details .= 'E-mail: ' . strip_tags(trim($_POST['email'])) . '\n';
+		}
+		$details .= 'Detalhes: ' . strip_tags(trim($_POST['details']));
+
+		$summary = '';
+		if (isset($_POST['summary']) && !empty(trim($_POST['summary']))) {
+			$summary = strip_tags(trim($_POST['summary']));
+		}
+		// Fazendo a submissão dos dados para o Wekan:
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+		    'Authorization: Bearer ' . $dadosLogin->token,
+		    'Content-type:application/json'
+		));
+		curl_setopt($ch, CURLOPT_URL,"http://200.144.254.107/wekan/api/boards/v82Wx3C3dk79t4pJw/lists/dHNhYSSyyqWhRn6NX/cards");
+		curl_setopt($ch, CURLOPT_POST, 1);
+		curl_setopt($ch, CURLOPT_POSTFIELDS,
+		            '{ "title": "'.$summary.'", "description": "'.$details.'", "authorId": "'. $dadosLogin->id.'", "swimlaneId": "HeJBje3EdmJ3GpZyb" }');
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		$retorno = curl_exec($ch);
+		curl_close ($ch);
+		$resposta = json_decode($retorno);
+		if (!$resposta->_id) {
+			throw new Exception();
+		}
+	} catch (Exception $ex) {
+		if (isset($_POST['redirect'])) {
+			header('Location:'.$_POST['redirect'].'?error=true');
+	    	exit;
+		} else {
+			header('Location:report.html?error=true');
+	    	exit;
+		}
+	}
+
+	if (isset($_POST['redirect'])) {
+		header('Location:'.$_POST['redirect'].'?reported=true');
+    	exit;
+	} else {
+		header('Location:report.html?reported=true');
+    	exit;
+	}
+
+?>
+
+
+

+ 148 - 0
bugs/report.html

@@ -0,0 +1,148 @@
+<!doctype html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+    <title>iVProgH - LInE (free educational software and contents)</title>
+    <link href="../css/bootstrap.min.css" rel="stylesheet">
+    <link href="../css/style.css" rel="stylesheet">
+  </head>
+
+  <body>
+    <nav class="navbar navbar-expand-md navbar-dark fixed-top" style="background-color: #03396c;">
+      <b><a class="navbar-brand" href="#">iVProgH</a></b>
+      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
+        <span class="navbar-toggler-icon"></span>
+      </button>
+      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
+        <ul class="navbar-nav mr-auto">
+          <li class="nav-item active">
+            <a class="nav-link" href="#">Home</a>
+          </li>
+          <li class="nav-item">
+            <a class="nav-link" href="manual_pt/index.html" title="manual iVProgH">Conheça</a>
+          </li>
+          <li class="nav-item">
+            <a class="nav-link" href="ex_pt/index.html">Exemplos</a>
+          </li>
+          <li class="nav-item">
+            <a class="nav-link" href="#">Download</a>
+          </li>
+          <li class="nav-item">
+            <a class="nav-link" href="../bugs/report.html">Informar uma falha</a>
+          </li>
+          <li class="nav-item">
+            <a class="nav-link" href="#">LInE</a>
+          </li>
+          <li class="nav-item">
+            <a class="nav-link" href="#">Ajuda</a>
+          </li>
+        </ul>
+        <div class="form-inline my-2 my-lg-0">
+          <img src="../img/img_flag_brazil.png">
+          <img src="../img/img_flag_usa.png">
+        </div>
+      </div>
+    </nav>
+
+    <main role="main">
+      <div class="jumbotron ivprogh-desc">
+        <div class="container">
+          <h1>iVProgH</h1>
+          
+        </div>
+      </div>
+      <div class="container ivprog-container" style="padding: 3em; margin-top: 3em;">
+      	<h4>Informar uma falha</h4>
+      	<p style="color: gray">Obrigado pelo interesse em informar os problemas encontrados no iVProgH! <br />
+      		Por favor, preencha os campos abaixo e nos conte o que aconteceu.</p>
+      	<form action="get.php" method="post" class="needs-validation" novalidate>
+      		<input type="hidden" name="redirect" value="report.html">
+      		<div class="form-group row">
+				<label for="inputname" class="col-sm-2 col-form-label">Nome:</label>
+				<div class="col-sm-10">
+			    	<input type="text" class="form-control" id="inputname" name="name">
+			    </div>
+			</div>
+			<div class="form-group row">
+				<label for="inputemail" class="col-sm-2 col-form-label">E-mail:</label>
+				<div class="col-sm-10">
+			    	<input type="email" class="form-control" id="inputemail" name="email">
+			    </div>
+			</div>
+			<div class="form-group row">
+				<label for="inputsummary" class="col-sm-2 col-form-label">Falha resumida:</label>
+				<div class="col-sm-10">
+			    	<input type="text" class="form-control" id="inputsummary" name="summary">
+			    </div>
+			</div>
+			<div class="form-group row">
+				<label for="inputdetails" class="col-sm-2 col-form-label">Falha detalhada:*</label>
+				<div class="col-sm-10">
+			    	<textarea id="inputdetails" class="form-control" name="details" style="height: 15em;" required></textarea>
+			    	<div class="invalid-feedback">
+			        	Por favor, conte-nos exatamente o que aconteceu!
+			        </div>
+			    </div>
+			</div>
+			<div class="form-group row">
+		      <div class="offset-sm-2 col-sm-10">
+		        <button type="submit" class="btn btn-primary">Enviar</button>
+		        <span class="reported" style="color: green; font-size: 120%;"></span>
+		        <span class="error" style="color: red; font-size: 120%;"></span>
+		      </div>
+		    </div>
+
+      	</form>
+      </div>
+
+    </main>
+    <footer class="container text-center">
+      <a href="http://www.ime.usp.br/line">iVProgH</a> | 
+      <a href="http://www.ime.usp.br/line">LInE</a> |
+      <a href="http://www.matematica.br">iM&aacute;tica</a>
+    </footer>
+
+    <script src="../js/jquery.min.js"></script>
+    <script src="../js/bootstrap.bundle.min.js"></script>
+    <script type="text/javascript">
+    	$( document ).ready(function() {
+    		$( '#inputname' ).focus();
+    		var forms = document.getElementsByClassName('needs-validation');
+		    // Loop over them and prevent submission
+		    var validation = Array.prototype.filter.call(forms, function(form) {
+		      form.addEventListener('submit', function(event) {
+		        if (form.checkValidity() === false) {
+		          event.preventDefault();
+		          event.stopPropagation();
+		          $(' #inputdetails').focus();
+		        }
+		        form.classList.add('was-validated');
+		      }, false);
+		    });
+
+		    if (getUrlParameter('reported')) {
+		    	$('.reported').text('As informações foram enviadas com sucesso!');
+		    } else if (getUrlParameter('error')) {
+		    	$('.error').text('Ocorreu um erro ao tentar enviar os dados, por favor, tente novamente!');
+		    }
+		});
+
+		function getUrlParameter(sParam) {
+		    var sPageURL = window.location.search.substring(1),
+		        sURLVariables = sPageURL.split('&'),
+		        sParameterName,
+		        i;
+
+		    for (i = 0; i < sURLVariables.length; i++) {
+		        sParameterName = sURLVariables[i].split('=');
+
+		        if (sParameterName[0] === sParam) {
+		            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
+		        }
+		    }
+		}
+		
+    </script>
+  </body>
+</html>

+ 5 - 2
index.html

@@ -28,6 +28,9 @@
           <li class="nav-item">
             <a class="nav-link" href="#">Download</a>
           </li>
+          <li class="nav-item">
+            <a class="nav-link" href="bugs/report.html">Informar uma falha</a>
+          </li>
           <li class="nav-item">
             <a class="nav-link" href="#">LInE</a>
           </li>
@@ -79,7 +82,7 @@
       <a href="http://www.matematica.br">iM&aacute;tica</a>
     </footer>
 
-    <script src="js/jquery-min.js"></script>
-    <script src="js/bootstrap.min.js"></script>
+    <script src="js/jquery.min.js"></script>
+    <script src="js/bootstrap.bundle.min.js"></script>
   </body>
 </html>