-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_testeparser.php
More file actions
63 lines (56 loc) · 2.57 KB
/
Copy pathphp_testeparser.php
File metadata and controls
63 lines (56 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<title>Teste de Classe \jacknpoe\ParserEndereco (para fisco em NF-e)</title>
<link rel="stylesheet" href="php_testeparser.css"/>
<link rel="icon" type="image/png" href="php_testeparser.png"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<?php
header( "Content-Type: text/html; charset=ISO-8859-1", true);
define( "EST_NENHUM", 'Nenhum endereço enviado até o momento!');
define( "EST_VAZIO", 'O endereço enviado está vazio!');
define( "EST_ENVIADO", 'Endereço enviado e processado.');
define( "RESULTADO", 'Resultado');
define( "LOGRADOURO", 'Logradouro');
define( "NUMERO", 'Número');
define( "COMPLEMENTO", 'Complemento');
define( "PROCESSAR", 'Processar');
define( "ENDERECO", 'Endereço (sem CEP):');
define( "GITHUB", 'Repositório no GitHub');
$endereco = '';
$resultado = '';
$estado = EST_NENHUM;
if( isset( $_POST[ 'processar']))
{
$endereco = trim( $_POST[ 'endereco']);
if( strlen( $endereco) > 0)
{
require_once( 'ParserEndereco.php'); // salve o código de http://pastebin.com/ypLiC6Nv com esse nome.
$parser = new \jacknpoe\ParserEndereco();
$parser->reconhecerEndereco( $endereco);
$resultado = '<h1>' . RESULTADO . ': <br></h1>' .
'<p>' . LOGRADOURO . ': ' . htmlspecialchars( $parser->logradouro, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, "ISO-8859-1") . '</p>' .
'<p>' . NUMERO . ': ' . htmlspecialchars( $parser->numero, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, "ISO-8859-1") . '</p>' .
'<p>' . COMPLEMENTO . ': ' . htmlspecialchars( $parser->complemento, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, "ISO-8859-1") . '</p>';
$estado = EST_ENVIADO;
}
else
{
$estado = EST_VAZIO;
}
}
?>
<h1><?php echo $estado; ?><br></h1>
<form action="php_testeparser.php" method="POST" style="border: 0px">
<p><?php echo ENDERECO; ?> <input type="text" name="endereco" value="<?php echo htmlspecialchars( $endereco, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, "ISO-8859-1"); ?>" style="width: 500px" autofocus></p>
<p><input type="submit" name="processar" value="<?php echo PROCESSAR; ?>"></p>
</form>
<br><?php echo $resultado; ?><br><br>
<p><a href="https://github.com/jacknpoe/php_testeparser"><?php echo GITHUB; ?></a></p><br><br>
<form action="index.html" method="POST" style="border: 0px">
<p><input type="submit" name="voltar" value="Voltar"></p>
</form>
</body>
</html>