public static function parse_to($address)
{
$template = Falcon::get_option('bbsub_replyto');
// No plus address in saved, parse via splitting
$has_match = preg_match('/\\+(\\w+)-(\\d+)-(\\d+)-(\\w+)\\@.*/i', $address, $matches);
if (!$has_match) {
throw new Exception(__('Reply-to not formatted correctly', 'bbsub'));
}
return array($matches[1], $matches[2], $matches[3], $matches[4]);
}
/** * Handles Mandrill inbound web hook * * @return void */ public function handle_post() { if (isset($_POST['mandrill_events'])) { $parsed = reset(json_decode(wp_unslash($_POST['mandrill_events']))); if (!$parsed) { return; } $reply = new Falcon_Reply(); $reply->subject = $parsed->msg->subject; $reply->body = $parsed->msg->text; list($reply->post, $reply->site, $reply->user, $reply->nonce) = Falcon_Reply::parse_to($parsed->msg->email); $reply_id = $reply->insert(); if ($reply_id === false) { header('X-Fail: No reply ID', true, 400); echo 'Reply could not be added?'; // intentionally not translated // Log this? } } }