X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FMailForm.php;fp=plugins%2FMailForm.php;h=8125ebbfd653579c0baa0d053642e982c9c359b8;hb=6855525e48fad5de270500a5445c4f4ff85d8bda;hp=0000000000000000000000000000000000000000;hpb=e69709aa8ee6108a1197e46b45367ba8dab55a52;p=diogenes.git diff --git a/plugins/MailForm.php b/plugins/MailForm.php new file mode 100644 index 0000000..8125ebb --- /dev/null +++ b/plugins/MailForm.php @@ -0,0 +1,134 @@ +{MailForm} in your page where the mail form should appear."; + + /** Plugin parameters */ + var $params = array('email' => '', 'title' => '', 'subject_tag' => '[web form] '); + + /** Show an instance of the MailForm plugin. + */ + function show() + { + global $page; + + // get params + $to_email = $this->params['email']; + $form_title = $this->params['title']; + + if (!isvalid_email($to_email)) { + return '

You must specify a valid e-mail in the "email" parameter to make use of the MailForm plugin.

'; + } + + // get input + $action = clean_request('action'); + $from = clean_request('from'); + + $refer = strip_request('refer'); + if (!$refer) + $refer = $_SERVER['HTTP_REFERER']; + $message = strip_request('message'); + $subject = strip_request('subject'); + + $showform=0; + $output = ''; + switch($action) { + case "mail": + if ((!$subject)||(!$message)||(!$from)) { + $output .= '

Missing fields !

'; + $showform=1; + break; + } + + if (!isvalid_email($from)) { + $output .= '

Invalid email address !

'; + $showform=1; + break; + } + + $mymail = new HermesMailer(); + $mymail->setFrom($from); + $mymail->setSubject($this->params['subject_tag'].$subject); + $mymail->addTo($to_email); + $mymail->setTxtBody($message); + $mymail->send(); + + $output .= '

Message sent !

'; + if ($refer!="") { + $output .= '

To return to referring web page click here

'; + } + break; + default: + $showform=1; + } + + if ($showform) { + $output .= + '
+ +
+ + + + + + + + + + + + + + + + + + + + + +
'.$form_title.'
'.__("from").'
'.__("subject").'
'.__("message").'
  + + + +
+ +
'; + } + return $output; + } +} +?>