-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·182 lines (170 loc) · 7.98 KB
/
index.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
// Variáveis de ambiente
require_once ".env.php";
// Biblioteca de funções
require_once "_lib/functions.php";
?>
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Desenvolvimento de sites e sistemas web.">
<meta property="og:url" content="<?= DJC_URL ?>">
<meta property="og:type" content="website">
<meta property="og:title" content="<?= DJC_TITULO ?>">
<meta property="og:description" content="Desenvolvimento de sites e sistemas web.">
<meta property="og:image" content="<?= fileVersion("_lib/images/link-preview.jpg", DJC_PATH, DJC_URL) ?>">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<title><?= DJC_TITULO ?> — Full Stack Web Developer</title>
<link href="<?= fileVersion("_lib/images/favicon.ico") ?>" rel="icon">
<link href="https://code.cdn.mozilla.net" rel="preconnect">
<link href="https://code.cdn.mozilla.net/fonts/fira.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css" rel="stylesheet">
<link href="<?= fileVersion("_lib/css/main.css") ?>" rel="stylesheet">
<?php
if (DJC_SANDBOX === false) {
// reCAPTCHA
if (empty($_SERVER['QUERY_STRING'])) {
echo ' <script src="https://www.google.com/recaptcha/api.js"></script>' . PHP_EOL;
}
// Matomo
?>
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//stats.djcontel.com.br/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<?php
}
?>
<script src="<?= fileVersion("_lib/js/main.js", DJC_PATH, DJC_URL) ?>"></script>
</head>
<body>
<main>
<div class="container">
<h1><a href="<?= DJC_URL ?>" title="<?= DJC_TITULO ?>"><?= DJC_TITULO ?></a></h1>
<h3>Desenvolvimento de <mark>sites e sistemas web</mark></h3>
<form name="contato" id="contato" method="post" action="<?= DJC_URL ?>enviar">
<fieldset>
<?php
if (empty($_SERVER['QUERY_STRING'])) {
?>
<input type="text" name="nome" id="nome" placeholder="Nome" required maxlength="120">
<input type="text" name="telefone" id="telefone" placeholder="Telefone" required maxlength="15">
<input type="email" name="email" id="email" placeholder="E-mail" required maxlength="200">
<textarea name="mensagem" id="mensagem" placeholder="Mensagem" required rows="5"></textarea>
<div id="recaptcha" class="g-recaptcha" data-sitekey="<?= reCAPTCHA_SITE_KEY ?>" data-callback="verifyCallback"></div>
<button type="submit" id="enviar">Enviar</button>
<?php
} else {
if ($_SERVER['QUERY_STRING'] === 'enviar') {
$formValido = ['nome', 'telefone', 'email', 'mensagem'];
$formValido = array_flip($formValido);
$form = [];
// Filtra os dados do formulário
if (count($_POST) > 0) {
foreach ($_POST as $name => $value) {
$recaptcha = stripos($name, 'g-');
if ($recaptcha === false) {
if ($name !== 'email') {
$field = filter_input(INPUT_POST, $name, FILTER_SANITIZE_STRING);
if ($field !== false && !is_null($field)) {
$form[$name] = $field;
}
} else {
$email = filter_input(INPUT_POST, $name, FILTER_SANITIZE_EMAIL);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$form[$name] = $email;
}
}
}
}
}
// Verifica o formulário
$diff = array_diff_key($formValido, $form);
// Verifica o reCAPTCHA
$recaptcha = vrfRecaptcha();
// Envia o e-mail
if (count($diff) === 0 && $recaptcha === true) {
$para = DJC_EMAIL;
$assunto = DJC_TITULO . " - Contato";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "From: " . $_POST['nome'] . " <" . $_POST['email'] . ">\r\n";
$msg = DJC_TITULO . " - Contato\n";
$msg .= date("d/m/Y - H:i:s") . "\n";
$msg .= "\n";
$msg .= "- Nome:\n";
$msg .= $form['nome'] . "\n";
$msg .= "\n";
$msg .= "- Telefone:\n";
$msg .= $form['telefone'] . "\n";
$msg .= "\n";
$msg .= "- E-mail:\n";
$msg .= $form['email'] . "\n";
$msg .= "\n";
$msg .= "- Mensagem:\n";
$msg .= $form['mensagem'];
if (mail($para, $assunto, $msg, $headers)) {
$tipo = "sucesso";
$titulo = "Mensagem enviada com sucesso!";
$mensagem = "Aguarde que entrarei em contato.";
} else {
$tipo = "erro";
$titulo = "Erro ao enviar mensagem!";
$mensagem = "Tente novamente mais tarde.";
}
} else {
$tipo = "alerta";
if ($recaptcha === false) {
$titulo = "reCAPTCHA inválido!";
$mensagem = "Clique no botão voltar e preencha os dados novamente.";
} else {
$titulo = "Todos os campos são obrigatórios!";
$mensagem = "É necessário que você preencha todos os campos.";
}
}
?>
<div class="msg <?= $tipo ?>">
<p class="titulo"><?= $titulo ?></p>
<p><?= $mensagem ?></p>
<button type="button" onclick="javascript:history.back();">Voltar</button>
</div>
<?php
} else {
echo ' <script>window.location.href = "' . DJC_URL . '";</script>' . PHP_EOL;
}
}
?>
</fieldset>
</form>
<ul class="stacks">
<li><i class="devicon-php-plain" title="PHP"></i></li>
<li><i class="devicon-laravel-plain" title="Laravel"></i></li>
<li><i class="devicon-html5-plain-wordmark" title="HTML5"></i></li>
<li><i class="devicon-css3-plain-wordmark" title="CSS3"></i></li>
<li><i class="devicon-bootstrap-plain" title="Bootstrap"></i></li>
<li><i class="devicon-javascript-plain" title="JavaScript"></i></li>
<li><i class="devicon-jquery-plain" title="jQuery"></i></li>
<li><i class="devicon-mysql-plain" title="MySQL"></i></li>
<li><i class="devicon-postgresql-plain" title="PostgreSQL"></i></li>
</ul>
<h2><strong>Daniel J. Contel</strong><span>Full Stack Web Developer</span></h2>
<ul class="links">
<li><a href="https://github.com/djcontel" title="GitHub" target="_blank"><i class="devicon-github-original"></i></a></li>
<li><a href="https://www.linkedin.com/in/djcontel/" title="LinkedIn" target="_blank"><i class="devicon-linkedin-plain"></i></a></li>
</ul>
</div>
</main>
</body>
</html>