X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl-cms.git;a=blobdiff_plain;f=contact.php;h=ff5cb42706dadc50a47b3260246f6007507e80cd;hp=769b2c54189028fd874e068a9fe58cba48ad55da;hb=HEAD;hpb=608730c54e00a21b2d2615387e7980dd413eec39 diff --git a/contact.php b/contact.php index 769b2c5..ff5cb42 100644 --- a/contact.php +++ b/contact.php @@ -1,88 +1,120 @@ "; - $reply_to = $to; - 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) { - $reply_to = "$data[name] <$reply_to>"; - } - } - $subject = "Your message via $host/contact"; - $email_template = new tem(); - $email_template->load('contact.email.txt'); - $email_template->sets($data); - $email_template->set('$host', this_host()); - $message = $email_template->run(); - $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) { - # FIXME create this page or change this to go elsewhere - return './contact_thanks'; - } - } - # otherwise, we display the form again. We've got the form field - # values in $data and will put those back in the filds below. You - # should add some message asking people to fix their entry in - # whatever way you require. - } else { - # form not submitted, you can set default values like so: - #$data = array('name' => 'Yes'); - $data = array(); - } - - tem_set('form', $data); +function contact_main_form() { + if (isset($_POST['name'])) { + $data = contact_get_fields(); + $host = this_host(); + + # gj robot, you did it ;) + if ($data['robot'] !== '') { + return './contact_thanks'; + } + + if (!$data['name'] && !$data['email'] && !$data['comments']) { + // message("you didn't fill anything out") + } elseif (!$data['email']) { + message("Error: Please fill out the email field."); + } else { + $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'])) { + $reply_to = $data['email']; + if ($data['name'] and preg_match('/^[a-zA-Z0-9_\'. -]*$/', $data['name']) !== false) { + $reply_to = "$data[name] <$reply_to>"; + } + } + 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 = $GLOBALS['contact_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) { + # FIXME create this page or change this to go elsewhere + return './contact_thanks'; + } + } + # otherwise, we display the form again. We've got the form field + # values in $data and will put those back in the filds below. You + # should add some message asking people to fix their entry in + # whatever way you require. + } else { + # form not submitted, you can set default values like so: + #$data = array('name' => 'Yes'); + $data = array(); + } + + $data['robot_field'] = contact_new_field_key(); + $data['email_field'] = contact_new_field_key(); + + tem_set('form', $data); }