-
Notifications
You must be signed in to change notification settings - Fork 2
/
enviarFeedback.php
33 lines (30 loc) · 952 Bytes
/
enviarFeedback.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
<?php
// Envia o feedback do usuário
// Valida os dados
$email = @$_POST['email'];
$msg = @$_POST['msg'];
$userAgent = @$_POST['userAgent'];
if (strlen($email) && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
// Email inválido
echo 'email';
exit;
}
if (strlen($msg) < 5) {
// Mensagem muito curta
echo 'msg';
exit;
}
// Salva o arquivo
$arquivo = '';
if (isset($_POST['arquivo'])) {
$nome = date('Y-m-d_H-i-s_') . uniqid() . '.txt';
file_put_contents("feedback-arquivos/$nome", $_POST['arquivo']);
$arquivo = "\r\n\r\nArquivo anexo: http://sitegui.com.br/editorHP/feedback-arquivos/$nome";
}
// Envia
if ($email)
$headers = "From: $email\r\nContent-type: text/plain; charset=utf-8\r\nSender: [email protected]";
else
$headers = "From: [email protected]\r\nContent-type: text/plain; charset=utf-8";
mail('[email protected]', 'Fale conosco - editorHP', "$msg\r\n\r\nUser-Agent: $userAgent$arquivo", $headers);
echo 'true';