Exemplo n.º 1
0
echo pluginContact::generateToken(true);
?>
">
			<input id="name" type="text" name="name" value="<?php 
echo pluginContact::cleanString($name);
?>
" placeholder="<?php 
echo $Language->get('Name');
?>
" class="pure-input-1-2">
			<input id="email" type="email" name="email" value="<?php 
echo pluginContact::cleanString($email);
?>
" placeholder="<?php 
echo $Language->get('Email');
?>
" class="pure-input-1-2">
			<textarea id="message" rows="6" name="message" placeholder="<?php 
echo $Language->get('Message');
?>
" class="pure-input-1-2"><?php 
echo pluginContact::cleanString($message);
?>
</textarea>
		</fieldset>
		<input type="checkbox" name="interested" style="display: none;">
		<button id="submit" name="submit" type="submit" class="pure-button pure-button-primary"><?php 
echo $Language->get('Send');
?>
</button>
</form>
Exemplo n.º 2
0
 /**
  * Add the contact form after content page
  *
  */
 public function pageEnd()
 {
     global $Page, $Url, $Site, $Language;
     # On charge le script uniquement sur la page en paramètre
     if ($Url->whereAmI() === 'page' && $Page->slug() == $this->getDbField('page')) {
         $error = false;
         $success = false;
         $token = pluginContact::generateToken();
         // Très important de déclarer le jeton !!!
         # $_POST
         $name = isset($_POST['name']) ? $_POST['name'] : '';
         $email = isset($_POST['email']) ? $_POST['email'] : '';
         $message = isset($_POST['message']) ? $_POST['message'] : '';
         $interested = isset($_POST['interested']) ? $_POST['interested'] : '';
         $contentType = 'text';
         // Type de mail (text/html)
         if (isset($_POST['submit']) && pluginContact::checkToken($token)) {
             # Paramètres
             $site_title = $Site->title();
             $site_charset = 'UTF-8';
             $site_email = $this->getDbField('email');
             # Object du mail
             $subject = $Language->get('New contact from ') . $site_title;
             # Contenu du mail.
             $email_content = $Language->get('Name:') . $name . "\r\n";
             $email_content .= $Language->get('Email:') . $email . "\r\n";
             $email_content .= $Language->get('Message:') . "\r\n" . $message . "\r\n";
             # Entêtes du mail
             $email_headers = "From: " . $name . " <" . $email . ">\r\n";
             $email_headers .= "Reply-To: " . $email . "\r\n";
             $email_headers .= 'MIME-Version: 1.0' . "\r\n";
             # Content-Type
             if ($contentType == 'html') {
                 $email_headers .= 'Content-type: text/html; charset="' . $site_charset . '"' . "\r\n";
             } else {
                 $email_headers .= 'Content-type: text/plain; charset="' . $site_charset . '"' . "\r\n";
             }
             $email_headers .= 'Content-transfer-encoding: 8bit' . "\r\n";
             $email_headers .= 'Date: ' . date("D, j M Y G:i:s O") . "\r\n";
             // Sat, 7 Jun 2001 12:35:58 -0700
             # On vérifie les champs qu'ils soient remplis
             if (trim($name) == '') {
                 $error = $Language->get('Please enter your name');
             } elseif (trim($email) == '') {
                 $error = $Language->get('Please enter a valid email address');
             } elseif (trim($message) == '') {
                 $error = $Language->get('Please enter the content of your message');
             } elseif ($interested) {
                 $error = $Language->get('Oh my god a Bot!');
             }
             if (!$error) {
                 if (mail($site_email, $subject, $email_content, $email_headers)) {
                     # Reset fields, work ?
                     $_POST = array();
                     # Envoi du Mail
                     $success = $Language->get('Thank you for having contacted me. I will reply you as soon as possible.');
                     #Redirect::page($Page->slug());
                 } else {
                     $error = $Language->get('Oops! An error occurred while sending your message, thank you to try again later.');
                 }
             }
             # On retourne les erreurs
             if ($error) {
                 echo '<div class="alert fade error">' . $error . '</div>' . "\r\n";
             } elseif ($success) {
                 echo '<div class="alert fade success">' . $success . '</div>' . "\r\n";
             }
         }
         /** 
          * VERSION 0.3
          * ON INCLUT LE TEMPLATE PAR DÉFAUT DU PLUG-IN OU LE TEMPLATE PERSONNALISÉ STOCKER DANS NOTRE THÈME 
          */
         $template = PATH_THEMES . $Site->theme() . '/php/contact.php';
         if (file_exists($template)) {
             include_once $template;
         } else {
             include dirname(__FILE__) . '/layout/contact.php';
         }
     }
 }