diff --git a/modules/contactform/Process.php b/modules/contactform/Process.php index 3722475a..47eb158d 100644 --- a/modules/contactform/Process.php +++ b/modules/contactform/Process.php @@ -10,7 +10,7 @@ class Process { $this->mail_dir = dirname(__FILE__); - $_to = Db::getInstance()->ExecuteS("SELECT email FROM "._DB_PREFIX_."contactform_email"); + $_to = Db::getInstance()->ExecuteS('SELECT email FROM '._DB_PREFIX_.'contactform_email'); foreach ($_to as $k => $email) { $this->to[] = $email; } @@ -24,37 +24,41 @@ class Process if (!$isCorrect) { $errors[] = 'Tous les champs ne sont pas remplis'; } else { - $query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [ - 'brand' => pSQL($this->data['brand']), - 'compagny' => pSQL($this->data['compagny']), - 'lastname' => pSQL($this->data['lastname']), - 'firstname' => pSQL($this->data['firstname']), - 'function' => pSQL($this->data['function']), - 'email1' => pSQL($this->data['email1']), - 'email2' => pSQL($this->data['email2']), - 'phone1' => pSQL($this->data['phone1']), - 'phone2' => pSQL($this->data['phone2']), - 'purpose' => pSQL($this->data['purpose']), - 'content' => pSQL($this->data['content']), - 'type' => Contactform::TYPE_PROVIDER - ], 'INSERT'); - - if (!$query) { - $errors[] = "Une erreur s'est produite. Votre message n'a pas été envoyé"; + if (!Validate::isEmail($tthis->data['email1']) || !(Validate::isEmail($tthis->data['email1']) && Validate::isEmail($tthis->data['email2']))) { + $errors[] = 'Certains champs ne sont pas valide'; } else { - Mail::Send( - intval($cookie->id_lang), - 'provider', - 'sujet', - $this->data, - $this->to, - NULL, - NULL, - NULL, - NULL, - NULL, - $this->mail_dir - ); + $query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [ + 'brand' => pSQL($this->data['brand']), + 'compagny' => pSQL($this->data['compagny']), + 'lastname' => pSQL($this->data['lastname']), + 'firstname' => pSQL($this->data['firstname']), + 'function' => pSQL($this->data['function']), + 'email1' => pSQL($this->data['email1']), + 'email2' => pSQL($this->data['email2']), + 'phone1' => pSQL($this->data['phone1']), + 'phone2' => pSQL($this->data['phone2']), + 'purpose' => pSQL($this->data['purpose']), + 'content' => pSQL($this->data['content']), + 'type' => Contactform::TYPE_PROVIDER + ], 'INSERT'); + + if (!$query) { + $errors[] = 'Une erreur s\'est produite. Votre message n\'a pas été envoyé'; + } else { + Mail::Send( + intval($cookie->id_lang), + 'provider', + 'sujet', + $this->data, + $this->to, + NULL, + NULL, + NULL, + NULL, + NULL, + $this->mail_dir + ); + } } } @@ -72,35 +76,39 @@ class Process if (!$isCorrect) { $errors[] = 'Tous les champs ne sont pas remplis'; } else { - $query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [ - 'compagny' => pSQL($this->data['compagny']), - 'lastname' => pSQL($this->data['lastname']), - 'firstname' => pSQL($this->data['firstname']), - 'function' => pSQL($this->data['function']), - 'email1' => pSQL($this->data['email1']), - 'email2' => pSQL($this->data['email2']), - 'phone1' => pSQL($this->data['phone1']), - 'phone2' => pSQL($this->data['phone2']), - 'content' => pSQL($this->data['content']), - 'type' => Contactform::TYPE_PRESS - ], 'INSERT'); - - if (!$query) { - $errors[] = "Une erreur s'est produite. Votre message n'a pas été envoyé"; + if (!Validate::isEmail($tthis->data['email1']) || !(Validate::isEmail($tthis->data['email1']) && Validate::isEmail($tthis->data['email2']))) { + $errors[] = 'Certains champs ne sont pas valide'; } else { - Mail::Send( - intval($cookie->id_lang), - 'press', - 'sujet', - $this->data, - $this->to, - NULL, - NULL, - NULL, - NULL, - NULL, - $this->mail_dir - ); + $query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [ + 'compagny' => pSQL($this->data['compagny']), + 'lastname' => pSQL($this->data['lastname']), + 'firstname' => pSQL($this->data['firstname']), + 'function' => pSQL($this->data['function']), + 'email1' => pSQL($this->data['email1']), + 'email2' => pSQL($this->data['email2']), + 'phone1' => pSQL($this->data['phone1']), + 'phone2' => pSQL($this->data['phone2']), + 'content' => pSQL($this->data['content']), + 'type' => Contactform::TYPE_PRESS + ], 'INSERT'); + + if (!$query) { + $errors[] = 'Une erreur s\'est produite. Votre message n\'a pas été envoyé'; + } else { + Mail::Send( + intval($cookie->id_lang), + 'press', + 'sujet', + $this->data, + $this->to, + NULL, + NULL, + NULL, + NULL, + NULL, + $this->mail_dir + ); + } } } diff --git a/modules/contactform/press.php b/modules/contactform/press.php index 5f8450c9..09d61219 100644 --- a/modules/contactform/press.php +++ b/modules/contactform/press.php @@ -8,7 +8,7 @@ include_once(dirname(__FILE__).'/Process.php'); include(dirname(__FILE__).'/../../header.php'); $result = null; -if (!empty($_POST['type'])) { +if (Tools::isSubmit('press_form')) { $Process = new Process(); $result = $Process->addPress($_POST); } diff --git a/modules/contactform/press.tpl b/modules/contactform/press.tpl index 809a546a..818ada7e 100644 --- a/modules/contactform/press.tpl +++ b/modules/contactform/press.tpl @@ -75,7 +75,7 @@ - + diff --git a/modules/contactform/provider.php b/modules/contactform/provider.php index 0e8cd09c..1821248a 100644 --- a/modules/contactform/provider.php +++ b/modules/contactform/provider.php @@ -8,7 +8,7 @@ include_once(dirname(__FILE__).'/Process.php'); include(dirname(__FILE__).'/../../header.php'); $result = null; -if (!empty($_POST['type'])) { +if (Tools::isSubmit('provider_form')) { $Process = new Process(); $result = $Process->addProvider($_POST); } diff --git a/modules/contactform/provider.tpl b/modules/contactform/provider.tpl index 5ba4a346..fe26fc0d 100644 --- a/modules/contactform/provider.tpl +++ b/modules/contactform/provider.tpl @@ -84,7 +84,7 @@ - +