|
1
|
|
|
<? |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
Loader::load('controller', 'home/DefaultPageController'); |
|
4
|
|
|
|
|
5
|
|
|
final class ContactController extends DefaultPageController |
|
6
|
|
|
{ |
|
7
|
|
|
|
|
8
|
|
|
private static $TITLE = 'Contact | Jacob Emerick'; |
|
9
|
|
|
private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
|
10
|
|
|
|
|
11
|
|
|
private static $KEYWORD_ARRAY = array( |
|
12
|
|
|
'Jacob Emerick', |
|
13
|
|
|
'jacobemerick', |
|
14
|
|
|
'jpemeric', |
|
15
|
|
|
'contact', |
|
16
|
|
|
'email', |
|
17
|
|
|
'connect'); |
|
18
|
|
|
|
|
19
|
|
|
protected function set_head_data() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->set_title(self::$TITLE); |
|
22
|
|
|
$this->set_description(self::$DESCRIPTION); |
|
23
|
|
|
$this->set_keywords(self::$KEYWORD_ARRAY); |
|
24
|
|
|
|
|
25
|
|
|
parent::set_head_data(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
protected function set_body_data() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->set_body('form_container', $this->process_form()); |
|
31
|
|
|
$this->set_body_view('Contact'); |
|
32
|
|
|
|
|
33
|
|
|
parent::set_body_data(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
private function process_form() |
|
37
|
|
|
{ |
|
38
|
|
|
if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
39
|
|
|
return (object) array('display' => 'normal'); |
|
40
|
|
|
|
|
41
|
|
|
Loader::load('utility', 'Validate'); |
|
42
|
|
|
$error_result = array(); |
|
43
|
|
|
if(!Validate::checkRequest('post', 'name', 'string')) |
|
44
|
|
|
$error_result['name'] = 'please enter your name'; |
|
45
|
|
|
if(!Validate::checkRequest('post', 'email', 'string')) |
|
46
|
|
|
$error_result['email'] = 'please enter a valid email'; |
|
47
|
|
|
if(!Validate::checkRequest('post', 'message', 'string')) |
|
48
|
|
|
$error_result['message'] = 'please write a message'; |
|
49
|
|
|
|
|
50
|
|
|
$values = (object) array( |
|
51
|
|
|
'name' => Request::getPost('name'), |
|
52
|
|
|
'email' => Request::getPost('email'), |
|
53
|
|
|
'message' => Request::getPost('message')); |
|
54
|
|
|
|
|
55
|
|
|
if(count($error_result) > 0) |
|
56
|
|
|
{ |
|
57
|
|
|
return (object) array( |
|
58
|
|
|
'display' => 'error', |
|
59
|
|
|
'messages' => $error_result, |
|
60
|
|
|
'values' => $values); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
global $container; |
|
64
|
|
|
$sent = $container['mail'] |
|
|
|
|
|
|
65
|
|
|
->addTo($container['config']->admin_email) |
|
66
|
|
|
->setSubject('Home Page Contact') |
|
67
|
|
|
->setPlainMessage( |
|
68
|
|
|
"Name: {$values->name}\n" . |
|
69
|
|
|
"Email: {$values->email}\n" . |
|
70
|
|
|
"Message: {$values->message}" |
|
71
|
|
|
) |
|
72
|
|
|
->send(); |
|
73
|
|
|
|
|
74
|
|
|
return (object) array('display' => 'success'); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.
As a precaution to avoid these problems better use the long opening tag
<?php.