X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=contact.php;h=55077d9baac55a77a1a4cb1ebe40d2b61642a64c;hb=9ff52f0dfa297b13659a78a55596c8904a9732d0;hp=b2a4cc71ce22ad498c119dd403c56bae35bd217f;hpb=c469d2530ad9684e56742d38f5817cb08ad98eef;p=wfpl-cms.git diff --git a/contact.php b/contact.php index b2a4cc7..55077d9 100644 --- a/contact.php +++ b/contact.php @@ -1,25 +1,46 @@ "; + $error = false; + if ($data['robot'] === '' && $GLOBALS['contact_to'] != 'fixme@example.com') { + $to = $GLOBALS['contact_to']; + if ($GLOBALS['contact_from'] === '') { + $from = "$host/contact "; + } else { + $from = $GLOBALS['contact_from']; + } $reply_to = $to; - if(isset($data['email']) and valid_email($data['email'])) { + if (isset($data['email']) and valid_email($data['email'])) { $reply_to = $data['email']; - if($data['name'] and ereg('^[a-zA-Z0-9_\' -]*$', $data['name']) !== false) { + if ($data['name'] and preg_match('/^[a-zA-Z0-9_\'. -]*$/', $data['name']) !== false) { $reply_to = "$data[name] <$reply_to>"; } } - $subject = "Your message via $host/contact"; + if ($GLOBALS['contact_subject'] === '') { + $subject = "Your message via $host/contact"; + } else { + $subject = $GLOBALS['contact_subject']; + } $email_template = new tem(); $email_template->load('contact.email.txt'); $email_template->sets($data); $email_template->set('$host', $host); $message = $email_template->run(); - $cc = ''; + $cc = $GLOBALS['contact_cc']; $bcc = ''; - if(email($from, $to, $subject, $message, $reply_to, $cc, $bcc)) { + if (email($from, $to, $subject, $message, $reply_to, $cc, $bcc)) { message('Due to an internal error, your message could not be sent. Please try again later.'); $error = true; } else { message('Message sent'); } } - if($error !== true) { + if ($error !== true) { # FIXME create this page or change this to go elsewhere return './contact_thanks'; } @@ -84,5 +113,8 @@ function contact_main_form($id = false) { $data = array(); } + $data['robot_field'] = contact_new_field_key(); + $data['email_field'] = contact_new_field_key(); + tem_set('form', $data); }