From ffa74c0f708532ec99a719ab407de24e276390db Mon Sep 17 00:00:00 2001 From: Kelvinsbs Date: Thu, 18 Nov 2021 21:49:02 -0300 Subject: [PATCH 1/3] back-end finalizado --- arquivo.xml | 13 +++++++++++ index.html | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 51 +++++++++++++++++++++++++++++++++++++++++++ viaCep.sql | 13 +++++++++++ 4 files changed, 139 insertions(+) create mode 100644 arquivo.xml create mode 100644 index.html create mode 100644 index.php create mode 100644 viaCep.sql diff --git a/arquivo.xml b/arquivo.xml new file mode 100644 index 00000000..f228cacf --- /dev/null +++ b/arquivo.xml @@ -0,0 +1,13 @@ + + + 88060-000 + Rodovia João Gualberto Soares + de 4001/4002 a 16999/17000 + São João do Rio Vermelho + Florianópolis + SC + 4205407 + + 48 + 8105 + diff --git a/index.html b/index.html new file mode 100644 index 00000000..d7a9d3a4 --- /dev/null +++ b/index.html @@ -0,0 +1,62 @@ + + + + + + + + Document + + + + + +
+
+
+ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
ceplogradourocomplementobairrolocalidadeufibgegiadddsiafi
+
+ + + + + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 00000000..f9c8a08e --- /dev/null +++ b/index.php @@ -0,0 +1,51 @@ +connect_errno) { + echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; + } + + $validacao = "SELECT * FROM enderecos_pesquisados WHERE cep = '$cep'"; + + $teste = $mysqli->query($validacao); + $temRegistros = mysqli_fetch_array($teste); + + if(empty($temRegistros)){ + + $url = "viacep.com.br/ws/$cep/json/"; + + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + )); + + $response = curl_exec($curl); + + curl_close($curl); + + // $teste = file_put_contents('arquivo.xml', $response); + + $response = json_decode($response); + $response = (object)$response; + + $query = "INSERT INTO enderecos_pesquisados (cep,logradouro,complemento,bairro,localidade,uf,ibge,gia,ddd,siafi) VALUES ('$response->cep','$response->logradouro','$response->complemento','$response->bairro','$response->localidade','$response->uf','$response->ibge','$response->gia','$response->ddd','$response->siafi')"; + + $mysqli->query($query); + + return $response; + // echo 'cep cadastrado com sucesso'; + }else{ + return $temRegistros; + // echo 'cep ja cadastrado'; + } +?> \ No newline at end of file diff --git a/viaCep.sql b/viaCep.sql new file mode 100644 index 00000000..981e4d8f --- /dev/null +++ b/viaCep.sql @@ -0,0 +1,13 @@ +CREATE TABLE `enderecos_pesquisados` ( + `id` int(11) PRIMARY KEY AUTO_INCREMENT not null, + `cep` int(11) not null, + `logradouro` varchar(250) not null, + `complemento` varchar(250) not null, + `bairro` varchar(100) not null, + `localidade` varchar(100) not null, + `uf` varchar(2) not null, + `ibge` int(11) not null, + `gia` varchar(100) not null, + `ddd` int(2) not null, + `siafi` int(10) not null +); \ No newline at end of file From 0ccb3cd065c1b92beb17536af8bcf841cd978e28 Mon Sep 17 00:00:00 2001 From: Kelvinsbs Date: Thu, 18 Nov 2021 22:54:42 -0300 Subject: [PATCH 2/3] corrigido alguns detalhes --- README.md | 4 -- index.html | 6 +-- index.php | 131 +++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 125 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9a3804a6..cffa9a25 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,3 @@ Premissas: ● Tratar o erro. Dar um retorno amigável para usuário leigo. -## PS: Valorizamos a criatividade no layout. - -# Entrega: - * Disponibilizar um link do repositório no GitHub e encaminhar para developer@cd2.com.br diff --git a/index.html b/index.html index d7a9d3a4..32ecd14e 100644 --- a/index.html +++ b/index.html @@ -16,13 +16,13 @@
- +
- + + + + \ No newline at end of file From 11147ed497bbf93207fcba6a16d4917659e2fb64 Mon Sep 17 00:00:00 2001 From: Kelvinsbs Date: Wed, 12 Jan 2022 21:52:17 -0300 Subject: [PATCH 3/3] arrumado front --- index.css | 6 +++ index.html | 131 +++++++++++++++++++++++++++++++++++------------------ index.php | 91 +++++++++++++++++++++++++++++++++---- 3 files changed, 173 insertions(+), 55 deletions(-) create mode 100644 index.css diff --git a/index.css b/index.css new file mode 100644 index 00000000..55ab7a11 --- /dev/null +++ b/index.css @@ -0,0 +1,6 @@ +/* Show it is fixed to the top */ +body { + min-height: 75rem; + padding-top: 4.5rem; + } + \ No newline at end of file diff --git a/index.html b/index.html index 32ecd14e..e1cc2951 100644 --- a/index.html +++ b/index.html @@ -2,61 +2,102 @@ - + + + + + - Document + PHP Test + + + + + + + + + + + + + -
-
-
- - + + +
+
+
+ + +
+
+
+ + +
+
+
+
+ +
+
+ + +
- - -
- - +
+ + + + + + \ No newline at end of file diff --git a/index.php b/index.php index c43c0d96..770173e1 100644 --- a/index.php +++ b/index.php @@ -104,26 +104,97 @@ - + + + + + - Document + PHP Test + + + + + + + + + + + + +
-
-
- - + +
+
+
+ + +
+
+
+ + +
+
+
+
+ +
+
+ + +
- +
+
@@ -143,7 +214,7 @@ ?>
cep
- +