';
}
return false;
}
}
/* Check for a valid emal Adress */
function mlcf_check_email($email) {
$nonascii = "\x80-\xff"; # Non-ASCII-Chars are not allowed
$nqtext = "[^\\\\$nonascii\015\012\"]";
$qchar = "\\\\[^$nonascii]";
$protocol = '(?:mailto:)';
$normuser = '[a-zA-Z0-9][a-zA-Z0-9_.-]*';
$quotedstring = "\"(?:$nqtext|$qchar)+\"";
$user_part = "(?:$normuser|$quotedstring)";
$dom_mainpart = '[a-zA-Z0-9][a-zA-Z0-9._-]*\\.';
$dom_subpart = '(?:[a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*';
$dom_tldpart = '[a-zA-Z]{2,5}';
$domain_part = "$dom_subpart$dom_mainpart$dom_tldpart";
$regex = "$protocol?$user_part\@$domain_part";
return preg_match("/^$regex$/",$email);
}
/* Wrapper function to use in a Template .*/
function mlcf_form(){
mlcf_callback($content, true);
}
/*Wrapper function which calls the form.*/
function mlcf_callback( $content , $templateTag=false) {
global $mlcf_strings;
/* Run the input check. */
if(false === strpos($content, '') and !$templateTag) {
return $content;
}
//recaptcha
$recaptcha_html ='';
$recaptcha_enabled = false;
$recaptcha_check = false;
if ( get_option('mlcf_recaptcha_enabled') ){
$recaptcha_check = true;
$recaptcha_enabled = true;
require_once('recaptchalib.php');
// recaptcha HTML-Block
$recaptcha_html= recaptcha_get_html( stripslashes(get_option('mlcf_recaptcha_public')));
/**
* Recaptcha Options (JS)
*
* theme : "red" (default theme) or "white" or "blackglass" or "clean"
* --> http://code.google.com/intl/de-DE/apis/recaptcha/docs/customization.html
**/
$recaptcha_js = '';
// Check the captcha answer
if( isset($_POST['mlcf_stage']) ){
$recaptcha_response = recaptcha_check_answer (
stripslashes(get_option('mlcf_recaptcha_private')),
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]
);
if ($recaptcha_response->is_valid ) $recaptcha_check = false;
}
}
// If the input check returns true (ie. there has been a submission & input is ok)
if( !$recaptcha_check and mlcf_check_input() )
{
$recipient = get_option('mlcf_email');
$from_mail = get_option('mlcf_email_from');
$success_message = get_option('mlcf_success_message');
$success_message = stripslashes($success_message);
$name = utf8_decode(html_entity_decode($_POST['mlcf_name']));
$email = utf8_decode(html_entity_decode($_POST['mlcf_email']));
$subject = utf8_decode(html_entity_decode($_POST['mlcf_subject']))." ".get_option('mlcf_subject');
$website = utf8_decode(html_entity_decode($_POST['mlcf_www']));
$text = utf8_decode(html_entity_decode($_POST['mlcf_message']));
$headers = "MIME-Version: 1.0\n";
$headers .= "From: $name <$email>\n";
$headers .= "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
$header2 = "Reply-To:".$email."\n";
$header2 .= "From: ".$from_mail."\r\n";
$message = "e-Mail from ".get_bloginfo("name")." Contact Form: \n\n";
$message .= wordwrap($text, 80, "\n") . "\n\n";
$message .= "_____________________________________________\n\n";
$message .= "Name: " . $name . "\n";
$message .= "email: " . $email . "\n";
$message .= "Subject: " . $subject . "\n";
$message .= "Website: " . $website . "\n";
$message .= "IP: " . mlcf_getip();
$message .= "\n_____________________________________________\n";
if (mail($recipient,utf8_decode($subject),$message,$header2)){
$results = '
' . $success_message . '
';
echo $results;
}
}
else // Else show the form. If there are errors the strings will have updated during running the inputcheck.
{
if($recaptcha_enabled){
if(!$recaptcha_response->is_valid){
$recaptcha_html = '