@@ -2,19 +2,19 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class AJAXRouter extends Router |
|
6 | -{ |
|
5 | +class AJAXRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() |
|
9 | + { |
|
10 | 10 | return array( |
11 | 11 | (object) array( |
12 | 12 | 'pattern' => '@^/$@', |
13 | 13 | 'replace' => 'https://home.jacobemerick.com/')); |
14 | 14 | } |
15 | 15 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
16 | + protected function get_direct_array() |
|
17 | + { |
|
18 | 18 | return array( |
19 | 19 | (object) array( |
20 | 20 | 'match' => '/get/portfolioImage.json', |
@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | 'waterfall/WaterfallCollector')); |
6 | 6 | Loader::load('router', 'Router'); |
7 | 7 | |
8 | -class WaterfallRouter extends Router |
|
9 | -{ |
|
8 | +class WaterfallRouter extends Router |
|
9 | +{ |
|
10 | 10 | |
11 | - protected function get_redirect_array() |
|
12 | - { |
|
11 | + protected function get_redirect_array() |
|
12 | + { |
|
13 | 13 | return array( |
14 | 14 | (object) array( |
15 | 15 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | ); |
72 | 72 | } |
73 | 73 | |
74 | - protected function check_for_special_redirect($uri) |
|
75 | - { |
|
74 | + protected function check_for_special_redirect($uri) |
|
75 | + { |
|
76 | 76 | if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
77 | 77 | $alias = $matches[1]; |
78 | 78 | $alias = str_replace("'", '', $alias); |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | return $uri; |
129 | 129 | } |
130 | 130 | |
131 | - protected function get_direct_array() |
|
132 | - { |
|
131 | + protected function get_direct_array() |
|
132 | + { |
|
133 | 133 | return array( |
134 | 134 | (object) array( |
135 | 135 | 'match' => '/', |
@@ -7,34 +7,38 @@ discard block |
||
7 | 7 | 'Request', |
8 | 8 | 'Validate')); |
9 | 9 | |
10 | -final class CommentSubmitModule |
|
11 | -{ |
|
10 | +final class CommentSubmitModule |
|
11 | +{ |
|
12 | 12 | |
13 | 13 | private $site; |
14 | 14 | private $path; |
15 | 15 | private $full_path; |
16 | 16 | private $page_title; |
17 | 17 | |
18 | - public function __construct($site, $path, $full_path, $page_title) |
|
19 | - { |
|
18 | + public function __construct($site, $path, $full_path, $page_title) |
|
19 | + { |
|
20 | 20 | $this->site = $site; |
21 | 21 | $this->path = $path; |
22 | 22 | $this->full_path = $full_path; |
23 | 23 | $this->page_title = $page_title; |
24 | 24 | } |
25 | 25 | |
26 | - public function activate() |
|
27 | - { |
|
28 | - if(!Request::hasPost()) |
|
29 | - return false; |
|
30 | - if(!Request::getPost('submit') == 'Submit Comment') |
|
31 | - return false; |
|
26 | + public function activate() |
|
27 | + { |
|
28 | + if(!Request::hasPost()) { |
|
29 | + return false; |
|
30 | + } |
|
31 | + if(!Request::getPost('submit') == 'Submit Comment') { |
|
32 | + return false; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $errors = $this->fetch_errors(); |
34 | - if(count($errors) > 0) |
|
35 | - return $errors; |
|
36 | - if(Request::getPost('catch') !== '') |
|
37 | - return false; |
|
36 | + if(count($errors) > 0) { |
|
37 | + return $errors; |
|
38 | + } |
|
39 | + if(Request::getPost('catch') !== '') { |
|
40 | + return false; |
|
41 | + } |
|
38 | 42 | |
39 | 43 | $page_id = $this->save_comment_page(); |
40 | 44 | $commenter_id = $this->save_commenter(); |
@@ -47,30 +51,37 @@ discard block |
||
47 | 51 | $this->redirect_to_comment($comment_meta_id); |
48 | 52 | } |
49 | 53 | |
50 | - private function fetch_errors() |
|
51 | - { |
|
54 | + private function fetch_errors() |
|
55 | + { |
|
52 | 56 | $errors = array(); |
53 | - if(!Validate::checkRequest('post', 'name', 'name')) |
|
54 | - $errors['name'] = 'You must include a valid name'; |
|
55 | - if(!Validate::checkRequest('post', 'email', 'email')) |
|
56 | - $errors['email'] = 'You must include a valid email'; |
|
57 | - if(Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url')) |
|
58 | - $errors['website'] = 'Please enter a valid website'; |
|
59 | - if(!Validate::checkRequest('post', 'comment', 'string')) |
|
60 | - $errors['comment'] = 'You must enter a comment'; |
|
61 | - if(Request::getPost('notify') && Request::getPost('notify') != 'check') |
|
62 | - $errors['notify'] = 'You entered an invalid notify request'; |
|
63 | - if(Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer')) |
|
64 | - $errors['reply'] = 'You entered an invalid reply request'; |
|
57 | + if(!Validate::checkRequest('post', 'name', 'name')) { |
|
58 | + $errors['name'] = 'You must include a valid name'; |
|
59 | + } |
|
60 | + if(!Validate::checkRequest('post', 'email', 'email')) { |
|
61 | + $errors['email'] = 'You must include a valid email'; |
|
62 | + } |
|
63 | + if(Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url')) { |
|
64 | + $errors['website'] = 'Please enter a valid website'; |
|
65 | + } |
|
66 | + if(!Validate::checkRequest('post', 'comment', 'string')) { |
|
67 | + $errors['comment'] = 'You must enter a comment'; |
|
68 | + } |
|
69 | + if(Request::getPost('notify') && Request::getPost('notify') != 'check') { |
|
70 | + $errors['notify'] = 'You entered an invalid notify request'; |
|
71 | + } |
|
72 | + if(Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer')) { |
|
73 | + $errors['reply'] = 'You entered an invalid reply request'; |
|
74 | + } |
|
65 | 75 | |
66 | 76 | return $errors; |
67 | 77 | } |
68 | 78 | |
69 | - private function save_comment_page() |
|
70 | - { |
|
79 | + private function save_comment_page() |
|
80 | + { |
|
71 | 81 | $page_result = CommentCollector::getCommentPageByURL($this->path, $this->site); |
72 | - if($page_result !== null) |
|
73 | - return $page_result->id; |
|
82 | + if($page_result !== null) { |
|
83 | + return $page_result->id; |
|
84 | + } |
|
74 | 85 | |
75 | 86 | $query = "INSERT INTO `jpemeric_comment`.`comment_page` (`site`, `path`) VALUES ('%d', '%s')"; |
76 | 87 | $query = sprintf($query, $this->site, $this->path); |
@@ -79,20 +90,22 @@ discard block |
||
79 | 90 | return Database::lastInsertID(); |
80 | 91 | } |
81 | 92 | |
82 | - private function save_commenter() |
|
83 | - { |
|
93 | + private function save_commenter() |
|
94 | + { |
|
84 | 95 | $cookie_value = array( |
85 | 96 | 'name' => Request::getPost('name'), |
86 | 97 | 'email' => Request::getPost('email')); |
87 | 98 | |
88 | - if(Request::getPost('website') != '') |
|
89 | - $cookie_value['website'] = Request::getPost('website'); |
|
99 | + if(Request::getPost('website') != '') { |
|
100 | + $cookie_value['website'] = Request::getPost('website'); |
|
101 | + } |
|
90 | 102 | |
91 | 103 | setcookie('commenter', json_encode($cookie_value), time() + 31536000, '/', 'jacobemerick.com'); |
92 | 104 | |
93 | 105 | $commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website')); |
94 | - if($commenter_result !== null) |
|
95 | - return $commenter_result->id; |
|
106 | + if($commenter_result !== null) { |
|
107 | + return $commenter_result->id; |
|
108 | + } |
|
96 | 109 | |
97 | 110 | $query = "INSERT INTO `jpemeric_comment`.`commenter` (`name`,`email`,`url`) VALUES ('%s','%s','%s')"; |
98 | 111 | |
@@ -105,11 +118,12 @@ discard block |
||
105 | 118 | return Database::lastInsertID(); |
106 | 119 | } |
107 | 120 | |
108 | - private function save_comment() |
|
109 | - { |
|
121 | + private function save_comment() |
|
122 | + { |
|
110 | 123 | $comment_result = CommentCollector::getCommentByBody(Request::getPost('comment')); |
111 | - if($comment_result !== null) |
|
112 | - return $comment_result->id; |
|
124 | + if($comment_result !== null) { |
|
125 | + return $comment_result->id; |
|
126 | + } |
|
113 | 127 | |
114 | 128 | $query = "INSERT INTO `jpemeric_comment`.`comment` (`body`, `body_format`) VALUES ('%s', '%s')"; |
115 | 129 | |
@@ -124,13 +138,14 @@ discard block |
||
124 | 138 | return Database::lastInsertID(); |
125 | 139 | } |
126 | 140 | |
127 | - private function save_comment_meta($commenter, $comment, $page) |
|
128 | - { |
|
141 | + private function save_comment_meta($commenter, $comment, $page) |
|
142 | + { |
|
129 | 143 | $query = "INSERT INTO `jpemeric_comment`.`comment_meta` (`commenter`,`comment`,`reply`,`notify`,`comment_page`,`date`,`display`) VALUES ('%d','%d','%d','%d','%d','%s','%d')"; |
130 | 144 | |
131 | 145 | $reply = Database::escape(Request::getPost('type')); |
132 | - if($reply == 'new') |
|
133 | - $reply = 0; |
|
146 | + if($reply == 'new') { |
|
147 | + $reply = 0; |
|
148 | + } |
|
134 | 149 | // else check to make sure value is legit |
135 | 150 | |
136 | 151 | $notify = (Request::getPost('notify') == 'check') ? 1 : 0; |
@@ -142,8 +157,8 @@ discard block |
||
142 | 157 | return Database::lastInsertID(); |
143 | 158 | } |
144 | 159 | |
145 | - private function send_notifications($page) |
|
146 | - { |
|
160 | + private function send_notifications($page) |
|
161 | + { |
|
147 | 162 | $email_recipient_array = array(); |
148 | 163 | |
149 | 164 | $commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website')); |
@@ -154,8 +169,9 @@ discard block |
||
154 | 169 | |
155 | 170 | foreach($notification_result as $notification_row) |
156 | 171 | { |
157 | - if($notification_row->email == Request::getPost('email')) |
|
158 | - continue; |
|
172 | + if($notification_row->email == Request::getPost('email')) { |
|
173 | + continue; |
|
174 | + } |
|
159 | 175 | |
160 | 176 | $email_recipient_array[$notification_row->email] = array( |
161 | 177 | 'email' => $notification_row->email, |
@@ -186,8 +202,8 @@ discard block |
||
186 | 202 | } |
187 | 203 | } |
188 | 204 | |
189 | - private function redirect_to_comment($comment_id) |
|
190 | - { |
|
205 | + private function redirect_to_comment($comment_id) |
|
206 | + { |
|
191 | 207 | $url = ''; |
192 | 208 | $url .= $this->full_path; |
193 | 209 | $url .= "#comment-{$comment_id}"; |
@@ -196,8 +212,8 @@ discard block |
||
196 | 212 | exit; |
197 | 213 | } |
198 | 214 | |
199 | - private function save_to_comment_service(array $data) |
|
200 | - { |
|
215 | + private function save_to_comment_service(array $data) |
|
216 | + { |
|
201 | 217 | $path = $_SERVER['REQUEST_URI']; |
202 | 218 | $path = explode('/', $path); |
203 | 219 | $path = array_filter($path); |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -class Error503Controller extends PageController |
|
6 | -{ |
|
5 | +class Error503Controller extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_header_method('send503'); |
11 | 11 | $this->add_css('normalize'); |
12 | 12 | $this->add_css('503'); |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $this->set_keywords(array()); |
17 | 17 | } |
18 | 18 | |
19 | - protected function set_body_data() |
|
20 | - { |
|
19 | + protected function set_body_data() |
|
20 | + { |
|
21 | 21 | $this->set_body_view('/503'); |
22 | 22 | } |
23 | 23 |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | |
5 | 5 | Loader::load('controller', 'site/DefaultPageController'); |
6 | 6 | |
7 | -final class ChangelogController extends DefaultPageController |
|
8 | -{ |
|
7 | +final class ChangelogController extends DefaultPageController |
|
8 | +{ |
|
9 | 9 | |
10 | - protected function set_head_data() |
|
11 | - { |
|
10 | + protected function set_head_data() |
|
11 | + { |
|
12 | 12 | $this->set_title("Changelog for Jacob Emerick's Sites"); |
13 | 13 | $this->set_description("Listing of the last changes done on the framework behind Jacob Emerick's websites. Yeah, he's down with that version control."); |
14 | 14 | $this->set_keywords(array('changelog', 'version control', 'code', 'comments', 'Jacob Emerick')); |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | parent::set_head_data(); |
17 | 17 | } |
18 | 18 | |
19 | - protected function set_body_data() |
|
20 | - { |
|
19 | + protected function set_body_data() |
|
20 | + { |
|
21 | 21 | parent::set_body_data(); |
22 | 22 | |
23 | 23 | $this->set_body('top_data', array('title' => 'Change Log')); |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $this->set_body('body_view', 'Changelog'); |
27 | 27 | } |
28 | 28 | |
29 | - private function get_changelog() |
|
30 | - { |
|
29 | + private function get_changelog() |
|
30 | + { |
|
31 | 31 | global $container; |
32 | 32 | $changelogRepository = new MysqlChangelogRepository($container['db_connection_locator']); |
33 | 33 | $changelog_result = $changelogRepository->getChanges(40); |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -abstract class DefaultPageController extends PageController |
|
6 | -{ |
|
5 | +abstract class DefaultPageController extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $MENU = array( |
9 | 9 | array( |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | 'name' => 'Contact', |
20 | 20 | 'uri' => 'contact')); |
21 | 21 | |
22 | - protected function set_head_data() |
|
23 | - { |
|
22 | + protected function set_head_data() |
|
23 | + { |
|
24 | 24 | $this->add_css('reset'); |
25 | 25 | $this->add_css('site'); |
26 | 26 | } |
27 | 27 | |
28 | - protected function set_body_data() |
|
29 | - { |
|
28 | + protected function set_body_data() |
|
29 | + { |
|
30 | 30 | $this->set_body('top_data', array()); |
31 | 31 | $this->set_body('body_data', array()); |
32 | 32 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $this->set_body_view('Page'); |
37 | 37 | } |
38 | 38 | |
39 | - private function get_menu() |
|
40 | - { |
|
39 | + private function get_menu() |
|
40 | + { |
|
41 | 41 | $active_page = $this->get_active_page(); |
42 | 42 | |
43 | 43 | $menu = array(); |
@@ -52,18 +52,20 @@ discard block |
||
52 | 52 | return $menu; |
53 | 53 | } |
54 | 54 | |
55 | - private function get_active_page() |
|
56 | - { |
|
55 | + private function get_active_page() |
|
56 | + { |
|
57 | 57 | $current_uri = URLDecode::getPiece(1); |
58 | 58 | |
59 | - if(!isset($current_uri)) |
|
60 | - return 'About'; |
|
59 | + if(!isset($current_uri)) { |
|
60 | + return 'About'; |
|
61 | + } |
|
61 | 62 | |
62 | 63 | $menu = self::$MENU; |
63 | 64 | foreach($menu as $link) |
64 | 65 | { |
65 | - if($link['uri'] == $current_uri) |
|
66 | - return $link['name']; |
|
66 | + if($link['uri'] == $current_uri) { |
|
67 | + return $link['name']; |
|
68 | + } |
|
67 | 69 | } |
68 | 70 | |
69 | 71 | return 'About'; |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'site/DefaultPageController'); |
4 | 4 | |
5 | -final class HomeController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class HomeController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_title("Jacob Emerick's Site Information | General and Technical Information"); |
11 | 11 | $this->set_description("Meta information about Jacob Emerick's websites and content. Introduces the man behind the code, discusses the reasons behind the sites, and goes into some technical background of the custom framework."); |
12 | 12 | $this->set_keywords(array('site', 'technical', 'support', 'help', 'information', 'Jacob Emerick')); |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | parent::set_head_data(); |
15 | 15 | } |
16 | 16 | |
17 | - protected function set_body_data() |
|
18 | - { |
|
17 | + protected function set_body_data() |
|
18 | + { |
|
19 | 19 | $this->set_body('body_view', 'Home'); |
20 | 20 | |
21 | 21 | parent::set_body_data(); |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'site/DefaultPageController'); |
4 | 4 | |
5 | -final class TermsController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class TermsController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_title("Terms of Use for Jacob Emerick's Sites"); |
11 | 11 | $this->set_description("Some basic (and boring) legal jargon and perferred usage of the content on Jacob Emerick's sites. Includes re-use terms and advice on retracing hikes."); |
12 | 12 | $this->set_keywords(array('terms of use', 'legal', 'accountability', 'trespassing', 'Jacob Emerick')); |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | parent::set_head_data(); |
15 | 15 | } |
16 | 16 | |
17 | - protected function set_body_data() |
|
18 | - { |
|
17 | + protected function set_body_data() |
|
18 | + { |
|
19 | 19 | $this->set_body('top_data', array('title' => 'Terms of Use')); |
20 | 20 | |
21 | 21 | $this->set_body('body_view', 'Terms'); |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | Loader::load('utility', array( |
5 | 5 | 'Validate')); |
6 | 6 | |
7 | -final class ContactController extends DefaultPageController |
|
8 | -{ |
|
7 | +final class ContactController extends DefaultPageController |
|
8 | +{ |
|
9 | 9 | |
10 | - protected function set_head_data() |
|
11 | - { |
|
10 | + protected function set_head_data() |
|
11 | + { |
|
12 | 12 | $this->set_title("Contact Form for Jacob Emerick's Sites"); |
13 | 13 | $this->set_description("Want to reach out to Jacob Emerick with questions or concerns? Well, then here's a handy contact form for you that will connect you with the man himself."); |
14 | 14 | $this->set_keywords(array('contact', 'webmaster', 'support', 'help', 'Jacob Emerick')); |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | parent::set_head_data(); |
17 | 17 | } |
18 | 18 | |
19 | - protected function set_body_data() |
|
20 | - { |
|
19 | + protected function set_body_data() |
|
20 | + { |
|
21 | 21 | parent::set_body_data(); |
22 | 22 | |
23 | 23 | $this->set_body('top_data', array('title' => 'Contact Me')); |
@@ -26,17 +26,21 @@ discard block |
||
26 | 26 | $this->set_body('body_view', 'Contact'); |
27 | 27 | } |
28 | 28 | |
29 | - private function get_form_results() |
|
30 | - { |
|
31 | - if(!Request::hasPost()) |
|
32 | - return array(); |
|
29 | + private function get_form_results() |
|
30 | + { |
|
31 | + if(!Request::hasPost()) { |
|
32 | + return array(); |
|
33 | + } |
|
33 | 34 | |
34 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
35 | - $error_message['name'] = 'Please enter a value for your name.'; |
|
36 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
37 | - $error_message['email'] = 'Please enter a valid email address.'; |
|
38 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
39 | - $error_message['message'] = 'Please enter a message.'; |
|
35 | + if(!Validate::checkRequest('post', 'name', 'string')) { |
|
36 | + $error_message['name'] = 'Please enter a value for your name.'; |
|
37 | + } |
|
38 | + if(!Validate::checkRequest('post', 'email', 'string')) { |
|
39 | + $error_message['email'] = 'Please enter a valid email address.'; |
|
40 | + } |
|
41 | + if(!Validate::checkRequest('post', 'message', 'string')) { |
|
42 | + $error_message['message'] = 'Please enter a message.'; |
|
43 | + } |
|
40 | 44 | |
41 | 45 | if(!empty($error_message)) |
42 | 46 | { |