Completed
Push — master ( 373ce5...4970c6 )
by Reginaldo
18:28
created

HomeController   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 97
rs 10
c 0
b 0
f 0
wmc 15
lcom 2
cbo 5

10 Methods

Rating   Name   Duplication   Size   Complexity  
A beforeFilter() 0 3 1
A index() 0 3 1
A servicos() 0 3 1
A contact() 0 3 1
A timeline() 0 3 1
A developers() 0 3 1
A cases() 0 3 1
A login() 0 5 1
B enviar_email() 0 36 5
A sendmail() 0 22 2
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();
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...
97
	}
98
99
}
100