@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $comment_id = $this->save_comment(); |
| 42 | 42 | |
| 43 | 43 | $comment_meta_id = $this->save_comment_meta($commenter_id, $comment_id, $page_id); |
| 44 | - $comment_service_id = $this->save_to_comment_service(Request::getPost()); |
|
| 44 | + $comment_service_id = $this->save_to_comment_service(Request::getPost()); |
|
| 45 | 45 | |
| 46 | 46 | $this->send_notifications($page_id); |
| 47 | 47 | $this->redirect_to_comment($comment_meta_id); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | if(Request::getPost('website') != '') |
| 89 | 89 | $cookie_value['website'] = Request::getPost('website'); |
| 90 | 90 | |
| 91 | - setcookie('commenter', json_encode($cookie_value), time() + 31536000, '/', 'jacobemerick.com'); |
|
| 91 | + setcookie('commenter', json_encode($cookie_value), time() + 31536000, '/', 'jacobemerick.com'); |
|
| 92 | 92 | |
| 93 | 93 | $commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website')); |
| 94 | 94 | if($commenter_result !== null) |
@@ -163,26 +163,26 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $site = URLDecode::getSite(); |
|
| 166 | + $site = URLDecode::getSite(); |
|
| 167 | 167 | |
| 168 | - if ($site == 'blog') { |
|
| 169 | - $subject = "New Comment on Jacob Emerick's Blog"; |
|
| 170 | - $message = "Hello!\nThere has been a new comment on the post '{$this->page_title}' at Jacob Emerick's Blog. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
| 171 | - } else if ($site == 'waterfalls') { |
|
| 172 | - $subject = "New Comment on Waterfalls of the Keweenaw"; |
|
| 173 | - $message = "Hello!\nThere has been a new comment on the page '{$this->page_title}' at Waterfalls of the Keweenaw. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
| 174 | - } |
|
| 168 | + if ($site == 'blog') { |
|
| 169 | + $subject = "New Comment on Jacob Emerick's Blog"; |
|
| 170 | + $message = "Hello!\nThere has been a new comment on the post '{$this->page_title}' at Jacob Emerick's Blog. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
| 171 | + } else if ($site == 'waterfalls') { |
|
| 172 | + $subject = "New Comment on Waterfalls of the Keweenaw"; |
|
| 173 | + $message = "Hello!\nThere has been a new comment on the page '{$this->page_title}' at Waterfalls of the Keweenaw. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - global $container; |
|
| 176 | + global $container; |
|
| 177 | 177 | |
| 178 | 178 | foreach($email_recipient_array as $email_recipient) |
| 179 | 179 | { |
| 180 | - $sent = $container['mail'] |
|
| 181 | - ->addTo($email_recipient['email'], $email_recipient['name']) |
|
| 182 | - ->addBCC($container['config']->admin_email) |
|
| 183 | - ->setSubject($subject) |
|
| 184 | - ->setPlainMessage($message) |
|
| 185 | - ->send(); |
|
| 180 | + $sent = $container['mail'] |
|
| 181 | + ->addTo($email_recipient['email'], $email_recipient['name']) |
|
| 182 | + ->addBCC($container['config']->admin_email) |
|
| 183 | + ->setSubject($subject) |
|
| 184 | + ->setPlainMessage($message) |
|
| 185 | + ->send(); |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -196,42 +196,42 @@ discard block |
||
| 196 | 196 | exit; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - private function save_to_comment_service(array $data) |
|
| 200 | - { |
|
| 201 | - $path = $_SERVER['REQUEST_URI']; |
|
| 202 | - $path = explode('/', $path); |
|
| 203 | - $path = array_filter($path); |
|
| 204 | - $path = array_slice($path, 0, 2); |
|
| 205 | - $path = implode('/', $path); |
|
| 206 | - |
|
| 207 | - $body = [ |
|
| 208 | - 'commenter' => [ |
|
| 209 | - 'name' => $data['name'], |
|
| 210 | - 'email' => $data['email'], |
|
| 211 | - 'website' => $data['website'], |
|
| 212 | - ], |
|
| 213 | - 'body' => $data['comment'], |
|
| 214 | - 'should_notify' => (isset($data['notify']) && $data['notify'] == 'check'), |
|
| 215 | - 'domain' => (URLDecode::getSite() == 'blog' ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com'), |
|
| 216 | - 'path' => $path, |
|
| 217 | - 'url' => "{$this->full_path}#comment-{{id}}", |
|
| 218 | - 'thread' => 'comments', |
|
| 219 | - 'reply_to' => ($data['type'] == 'new' ? 0 : $data['type']), |
|
| 220 | - 'ip_address' => $_SERVER['REMOTE_ADDR'], |
|
| 221 | - 'user_agent' => $_SERVER['HTTP_USER_AGENT'], |
|
| 222 | - 'referrer' => $_SERVER['HTTP_REFERER'], |
|
| 223 | - ]; |
|
| 224 | - |
|
| 225 | - global $config; |
|
| 226 | - $configuration = new Jacobemerick\CommentService\Configuration(); |
|
| 227 | - $configuration->setUsername($config->comments->user); |
|
| 228 | - $configuration->setPassword($config->comments->password); |
|
| 229 | - $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
| 230 | - $configuration->setHost($config->comments->host); |
|
| 231 | - $configuration->setCurlTimeout($config->comments->timeout); |
|
| 232 | - |
|
| 233 | - $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
| 234 | - $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
| 235 | - $response = $api->createComment($body); |
|
| 236 | - } |
|
| 199 | + private function save_to_comment_service(array $data) |
|
| 200 | + { |
|
| 201 | + $path = $_SERVER['REQUEST_URI']; |
|
| 202 | + $path = explode('/', $path); |
|
| 203 | + $path = array_filter($path); |
|
| 204 | + $path = array_slice($path, 0, 2); |
|
| 205 | + $path = implode('/', $path); |
|
| 206 | + |
|
| 207 | + $body = [ |
|
| 208 | + 'commenter' => [ |
|
| 209 | + 'name' => $data['name'], |
|
| 210 | + 'email' => $data['email'], |
|
| 211 | + 'website' => $data['website'], |
|
| 212 | + ], |
|
| 213 | + 'body' => $data['comment'], |
|
| 214 | + 'should_notify' => (isset($data['notify']) && $data['notify'] == 'check'), |
|
| 215 | + 'domain' => (URLDecode::getSite() == 'blog' ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com'), |
|
| 216 | + 'path' => $path, |
|
| 217 | + 'url' => "{$this->full_path}#comment-{{id}}", |
|
| 218 | + 'thread' => 'comments', |
|
| 219 | + 'reply_to' => ($data['type'] == 'new' ? 0 : $data['type']), |
|
| 220 | + 'ip_address' => $_SERVER['REMOTE_ADDR'], |
|
| 221 | + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], |
|
| 222 | + 'referrer' => $_SERVER['HTTP_REFERER'], |
|
| 223 | + ]; |
|
| 224 | + |
|
| 225 | + global $config; |
|
| 226 | + $configuration = new Jacobemerick\CommentService\Configuration(); |
|
| 227 | + $configuration->setUsername($config->comments->user); |
|
| 228 | + $configuration->setPassword($config->comments->password); |
|
| 229 | + $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
| 230 | + $configuration->setHost($config->comments->host); |
|
| 231 | + $configuration->setCurlTimeout($config->comments->timeout); |
|
| 232 | + |
|
| 233 | + $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
| 234 | + $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
| 235 | + $response = $api->createComment($body); |
|
| 236 | + } |
|
| 237 | 237 | } |