<?php
- if(file_exists($this->path("libs")."ptitcaptcha.php")) require $this->path("libs")."ptitcaptcha.php";
+ class mw_forms_contact extends mw_mod{
- class mw_forms_contact extends mw_mod
- {
-
- function validate(&$env)
- { if($pages_view_mod = $env->get_mod("pages/view"))
- { return $pages_view_mod->validate(&$env);
- }
- return true;
- }
-
- function index(&$env)
- { if($env->config("contact_form") && $env->config("email"))
- { if($_POST)
- { if
- ( $this->send
- ( $env,
+ function index(&$env){
+ if($env->config("contact_form") && $env->config("email")){
+ if($env->config("captcha")){
+ if(file_exists($env->path("libs")."ptitcaptcha.php")){
+ require $env->path("libs")."ptitcaptcha.php";
+ }
+ else{
+ $env->erreur("fichier du captcha introuvable");
+ return;
+ }
+ }
+ if($_POST){
+ if(
+ $this->__send_form(
+ $env,
$_POST["email"],
"[".$env->config("site_name")."] nouveau message",
$_POST["message"],
$env->config("email"),
$env->config("captcha")
)
- )
- { $env->redirect
- ( $env->url("index"),
+ ){
+ $env->redirect(
+ $env->url("index"),
"Le message a été envoyé",
2
);
else $env->run("index");
}
- function send(&$env, $from, $titre, $message, $dest, $captcha)
- { $env->set_out("ENVOYE", false);
- if($captcha && !file_exists($env->path("libs")."ptitcaptcha.php"))
- { $env->erreur("fichier du captcha introuvable");
- return false;
- }
- if(!$captcha || PtitCaptchaHelper::checkCaptcha())
- { if($from)
- { if($dest)
- { if
- ( mail
- ( $dest,
+ function __send_form(&$env, $from, $titre, $message, $dest, $captcha){
+ $env->set_out("ENVOYE", false);
+ if(!$captcha || PtitCaptchaHelper::checkCaptcha()){
+ if($from){
+ if($dest){
+ if(
+ @mail(
+ $dest,
$titre,
$message,
"From: ".$from."\r\n"
."Reply-To: ".$from."\r\n"
)
- )
- { $env->set_out("ENVOYE", true);
+ ){
+ $env->set_out("ENVOYE", true);
return true;
}
else $env->erreur("Erreur à l'envoi du mail");