Completed
Push — master ( a8e8b7...373ce5 )
by Reginaldo
19:01
created

HomeController::timeline()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 login() {
30
		$this->set('admin', false);
31
		
32
		$this->layout = 'login';
33
	}
34
35
	function enviar_email() {
36
		$dados = $this->request->data('dados');
37
38
		// Check for empty fields
39
		if(empty($dados['name'])  		||
40
   			empty($dados['email']) 		||
41
   			empty($dados['message'])	||
42
   			!filter_var($dados['email'], FILTER_VALIDATE_EMAIL)) {
43
				$this->Session->setFlash('Você deve preencher todos os dados!');
44
	            return $this->redirect('/');
45
		}	
46
	
47
		$name = $dados['name'];
48
		$email_address = $dados['email'];
49
		$message = $dados['message'];
50
	
51
		// Create the email and send the message
52
		$to = '[email protected]'; // Add your email address inbetween the '' replacing [email protected] - This is where the form will send a message to.
53
		$email_subject = "Contato Winners Desenvolvimento";
54
		$email_body = "Mensagem site: ".$message;
55
		$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected].
56
		$headers .= "Reply-To: $email_address";	
57
		mail($to,$email_subject,$email_body,$headers);
58
		//resposta automatica ao cliente
59
		$to = $email_address;
60
		$email_subject = '[email protected]';
61
		$email_body = "A sua mensagem foi recebida, em breve responderemos";
62
		$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected].
63
		$headers .= "Reply-To: $email_address";	
64
		mail($to,$email_subject,$email_body,$headers);
65
66
		$this->Session->setFlash('Seu e-mail foi enviado com sucesso em breve responderemos!');
67
        return $this->redirect('/');
68
	}
69
70
	public function sendmail() {
71
		App::uses('CakeEmail', 'Network/Email');
72
73
		$email = new CakeEmail('default');
74
		$email->from('[email protected]', 'reginaldo')
75
			->to('[email protected]')
76
			->subject('Contato CakePHP MyStore');
77
		$mensagem = '
78
				<p><strong>Nome</strong>: adfasdf</p>
79
				<p><strong>Email</strong>: fasdf@laksjdf</p>
80
				<p><strong>Telefone</strong>: asdfasdf</p>
81
				<p><strong>Mensagem</strong>:fasdf</p>
82
			';
83
		
84
		if ($email->send($mensagem)) {
85
			echo('Mensagem enviada com sucesso');
86
		} else {
87
			echo('Sua mensagem não foi enviada, tente denovo');
88
		}
89
90
		exit();
0 ignored issues
show
Coding Style Compatibility introduced by
The method sendmail() contains an exit expression.

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.

Loading history...
91
	}
92
93
}
94