// Email form validation functions
<?php
// Function to look for suspicious looking text in submitted values
function is_injected($str)
{
$injections = array('(Content-Type:)','(MIME-Version:)','(Content-Transfer-Encoding:)','(From:)','(to:)','(cc:)','(bcc:)');
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// Logic for page that calls the mail() function
if ($not_injected)
{
// email send code...
}
/* Strips html tags and trims whitespace from data */
function clean_up($data) {
$data = strip_tags($data);
$data = trim(htmlentities($data));
return $data;
}
?>