1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class HomeController extends AppController{ |
4
|
|
|
|
5
|
|
|
public function beforeFilter(){ |
6
|
|
|
return true; |
7
|
|
|
} |
8
|
|
|
|
9
|
|
|
function index(){ |
10
|
|
|
$this->layout = 'winners'; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
function servicos(){ |
14
|
|
|
$this->layout = 'winners'; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
function contact(){ |
18
|
|
|
$this->layout = 'winners'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function timeline(){ |
22
|
|
|
$this->layout = 'winners'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
function developers(){ |
26
|
|
|
$this->layout = 'winners'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
function cases(){ |
30
|
|
|
$this->layout = 'winners'; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function login() { |
34
|
|
|
$this->set('admin', false); |
35
|
|
|
|
36
|
|
|
$this->layout = 'login'; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
function enviar_email() { |
40
|
|
|
$dados = $this->request->data('dados'); |
41
|
|
|
|
42
|
|
|
// Check for empty fields |
43
|
|
|
if(empty($dados['name']) || |
44
|
|
|
empty($dados['email']) || |
45
|
|
|
empty($dados['message']) || |
46
|
|
|
!filter_var($dados['email'], FILTER_VALIDATE_EMAIL)) { |
47
|
|
|
$this->Session->setFlash('Você deve preencher todos os dados!'); |
48
|
|
|
return $this->redirect('/'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$name = $dados['name']; |
52
|
|
|
$email_address = $dados['email']; |
53
|
|
|
$message = $dados['message']; |
54
|
|
|
|
55
|
|
|
// Create the email and send the message |
56
|
|
|
$to = '[email protected]'; // Add your email address inbetween the '' replacing [email protected] - This is where the form will send a message to. |
57
|
|
|
$email_subject = "Contato Winners Desenvolvimento"; |
58
|
|
|
$email_body = "Mensagem site: ".$message; |
59
|
|
|
$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
60
|
|
|
$headers .= "Reply-To: $email_address"; |
61
|
|
|
mail($to,$email_subject,$email_body,$headers); |
62
|
|
|
//resposta automatica ao cliente |
63
|
|
|
$to = $email_address; |
64
|
|
|
$email_subject = '[email protected]'; |
65
|
|
|
$email_body = "A sua mensagem foi recebida, em breve responderemos"; |
66
|
|
|
$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
67
|
|
|
$headers .= "Reply-To: $email_address"; |
68
|
|
|
|
69
|
|
|
mail($to,$email_subject,$email_body,$headers); |
70
|
|
|
|
71
|
|
|
$this->Session->setFlash('O e-mail foi enviado em breve entraremos em contato!'); |
72
|
|
|
|
73
|
|
|
return $this->redirect('/'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function sendmail() { |
77
|
|
|
App::uses('CakeEmail', 'Network/Email'); |
78
|
|
|
|
79
|
|
|
$email = new CakeEmail('default'); |
80
|
|
|
$email->from('[email protected]', 'reginaldo') |
81
|
|
|
->to('[email protected]') |
82
|
|
|
->subject('Contato CakePHP MyStore'); |
83
|
|
|
$mensagem = ' |
84
|
|
|
<p><strong>Nome</strong>: adfasdf</p> |
85
|
|
|
<p><strong>Email</strong>: fasdf@laksjdf</p> |
86
|
|
|
<p><strong>Telefone</strong>: asdfasdf</p> |
87
|
|
|
<p><strong>Mensagem</strong>:fasdf</p> |
88
|
|
|
'; |
89
|
|
|
|
90
|
|
|
if ($email->send($mensagem)) { |
91
|
|
|
echo('Mensagem enviada com sucesso'); |
92
|
|
|
} else { |
93
|
|
|
echo('Sua mensagem não foi enviada, tente denovo'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
exit(); |
|
|
|
|
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.