Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/hopeinstoughton_www/wp-content/plugins/form-wizard/ |
Upload File : |
<?php
// prepare html, replacing fields
// create plain text
// combine into one email
// send it using wp_mail
// recipients. subject can also have macro
class form_wizard_mailer {
var $data;
public function SetData($data) { // these are the fields/values that will be used to expand macros in the body
$this->data = array();
foreach($data as $key => $value) {
$this->data[strtolower(trim($key))] = nl2br(htmlspecialchars($value)); // convert everything to a displayable format
}
}
// The Sender should ALWAYS be us, and NEVER the CLIENT
// if an email address is in the format '"person;s name" <email@domain.com>' --> $from is just email@domain.com
public function SendEmail($from, $to, $subject, $body, $client = '') {
$recipients = explode(',', $to);
$headers = array();
if ($from != '') $headers[] = 'From: ' . $from;
if ($client != '') $headers[] = 'Reply-To: ' . $client; // $client: we are sending email "On Behalf of" client, not "Sending as" client
//$headers[] = 'BCC: iluvwp@wordpress.org';
add_filter( 'wp_mail_content_type', array($this, 'set_html_content_type'));
$body = $this->apply_macro($body);
$subject = $this->apply_macro($subject);
$x = wp_mail( $recipients, $subject, $body, $headers);
remove_filter( 'wp_mail_content_type', array($this, 'set_html_content_type'));
return $x;
}
private function remove_nbsp($macro) {
$macro = strip_tags(str_replace(array(" ", "\0xC2\0xA0"), ' ', $macro));
return $macro;
}
public function apply_macro($body) {
$last = -1;
while (($last < strlen($body) - 1) && ($p = strpos($body, '%', $last + 1)) !== FALSE) {
if (($next = strpos($body, '%', $p + 1)) === FALSE) {
$macro = substr($body, $p + 1);
} else {
$macro = substr($body, $p + 1, $next - $p - 1);
}
$macrolen = strlen($macro);
$macro = $this->remove_nbsp($macro);
$macro = strtolower(trim($macro));
if (isset($this->data[$macro])) {
$body = substr($body, 0, $p) . $this->data[$macro] . substr($body, $p + $macrolen + 2);
$last = $p + strlen($this->data[$macro]);
} else {
if ($next === FALSE) break;
$last = $next - 1;
}
}
return $body;
}
function set_html_content_type() {
return 'text/html';
}
// function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
}