Skip to content

Commit

Permalink
Update v_mailto.php
Browse files Browse the repository at this point in the history
  • Loading branch information
markjcrane authored Jan 17, 2017
1 parent 809da1d commit ea025c4
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions secure/v_mailto.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@
require_once "resources/require.php";

//define a function to remove html tags
function rip_tags($string) {
function remove_tags($string) {
// ----- remove HTML TAGs -----
$string = preg_replace ('/<[^>]*>/', ' ', $string);

// ----- remove control characters -----
// remove control characters

$string = str_replace("\r", '', $string); // --- replace with empty space
$string = str_replace("\n", ' ', $string); // --- replace with space
$string = str_replace("\t", ' ', $string); // --- replace with space

// ----- remove multiple spaces -----
//remove multiple spaces
$string = trim(preg_replace('/ {2,}/', ' ', $string));
return $string;
}
Expand Down Expand Up @@ -313,7 +313,7 @@ function rip_tags($string) {
}

//add the body to the email
$body_plain = rip_tags($body);
$body_plain = remove_tags($body);
//echo "body_plain = $body_plain\n";
if ((substr($body, 0, 5) == "<html") || (substr($body, 0, 9) == "<!doctype")) {
$mail->ContentType = "text/html";
Expand All @@ -336,30 +336,32 @@ function rip_tags($string) {
echo "Retained in v_emails \n";
} else {
// log/store message in database for review
$email_uuid = uuid();
$sql = "insert into v_emails ( ";
$sql .= "email_uuid, ";
if ($call_uuid) {
$sql .= "call_uuid, ";
}
$sql .= "domain_uuid, ";
$sql .= "sent_date, ";
$sql .= "type, ";
$sql .= "status, ";
$sql .= "email ";
$sql .= ") values ( ";
$sql .= "'".$email_uuid."', ";
if ($call_uuid) {
$sql .= "'".$call_uuid."', ";
if (!isset($email_uuid)) {
$email_uuid = uuid();
$sql = "insert into v_emails ( ";
$sql .= "email_uuid, ";
if ($call_uuid) {
$sql .= "call_uuid, ";
}
$sql .= "domain_uuid, ";
$sql .= "sent_date, ";
$sql .= "type, ";
$sql .= "status, ";
$sql .= "email ";
$sql .= ") values ( ";
$sql .= "'".$email_uuid."', ";
if ($call_uuid) {
$sql .= "'".$call_uuid."', ";
}
$sql .= "'".$headers["X-FusionPBX-Domain-UUID"]."', ";
$sql .= "now(),";
$sql .= "'".$headers["X-FusionPBX-Email-Type"]."', ";
$sql .= "'failed', ";
$sql .= "'".str_replace("'", "''", $msg)."' ";
$sql .= ") ";
$db->exec(check_sql($sql));
unset($sql);
}
$sql .= "'".$headers["X-FusionPBX-Domain-UUID"]."', ";
$sql .= "now(),";
$sql .= "'".$headers["X-FusionPBX-Email-Type"]."', ";
$sql .= "'failed', ";
$sql .= "'".str_replace("'", "''", $msg)."' ";
$sql .= ") ";
$db->exec(check_sql($sql));
unset($sql);

echo "Retained in v_emails as email_uuid = ".$email_uuid."\n";
}
Expand Down

0 comments on commit ea025c4

Please sign in to comment.