Site PHP+MySQL Evénementiel

crabs_web_event-2.0 ©2005-2006 - Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)

~~ / contact.php
Makefile index.php tous.php annonce.php contact.php favicon.ico install.flag
    1 <?php
    2 //
    3 // =============================================================================
    4 //  crabs_web_event-2.0 : Site PHP+MySQL Evénementiel
    5 //  Copyright (C) 2005-2006 : Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)
    6 //
    7 //  Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer
    8 //  et/ou le modifier en respectant les termes de la GNU General Public License
    9 //  version 2 ou (suite a votre propre choix) une version ulterieure.
   10 //
   11 //  Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais
   12 //  sans aucune garantie, meme si il est associe a un produit qui vous en
   13 //  propose une. Conformez-vous a la GNU General Public License pour avoir
   14 //  plus de precisions.
   15 //
   16 //  L'auteur ne peut etre tenu responsable de l'utilisation faite des
   17 //  composantes associees a ce projet (en partie ou dans leur totalite).
   18 //
   19 //  Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC
   20 //  de ce projet sous le nom gnu_gpl.txt
   21 //
   22 // =============================================================================
   23 //
   24 include( 'LIB/param.php' ) ;
   25 include( 'LIB/entities.php' ) ;
   26 include( 'LIB/util.php' ) ;
   27 include( 'LIB/class_mysql.php' ) ;
   28 
   29 $vars = array(
   30     'vous' =>   "vous n'indiquez pas qui vous êtes",
   31     'email'=>   "donnez-nous une adresse mail",
   32     'sujet'=>   "précisez le sujet de votre message",
   33     'message'=> "que voulez-vous nous dire ?"
   34     ) ;
   35 // Init des variables
   36 foreach( $vars as $var=>$val ) $$var = '' ;
   37 if ( array_key_exists( 'a', $_GET ) )
   38     {
   39     $id = fromGET('a') ;
   40     $sql = "SELECT titre FROM ${DB_PRFX}annonce WHERE id='$id'" ;
   41     $c = new MYSQL ; $res = $c->query( $sql ) ; $r = mysql_fetch_object($res) ;
   42     $sujet = "ANNONCE: ".fromMySQL( $r->titre ) ;
   43     }
   44 $is_post = array_key_exists( 'vous', $_POST ) ;
   45 $err = false ;
   46 if ( $is_post )
   47     {
   48     foreach( $vars as $var=>$val )
   49         $$var = htmlentities( fromPOST( $var, '' ) ) ;
   50     $emsg ="<div class=\"status\">\n" ;
   51     $emsg.="<p>Votre message n'a pas été envoyé pour les raisons" ;
   52     $emsg.=" suivantes&nbsp;:</p>\n<ul>\n";
   53     foreach( $vars as $var=>$val )
   54         if ( empty( $$var ) )
   55             {
   56             $emsg.= "<li>$val <i>(champ $var vide)</i></li>\n" ;
   57             $err = true ;
   58             }
   59     $emsg.="</ul>\n</div>" ;
   60     $drawpost = $err ;
   61     if ( $err ) $msg = $drawpost ;
   62     }
   63 else
   64     { $emsg = '' ; $drawpost = true ; }
   65 
   66 $html = file_get_contents( 'HTML/page.html' ) ;
   67 $html = str_replace( '[[TMPL:TITRE]]', '', $html ) ;
   68 $titre = templateExtract( $html, 'FORMULAIRE', 'CONTACT' ) ;
   69 
   70 if ( $drawpost )
   71     $cnt = <<<HTML
   72 $emsg
   73 <form method="post" action="contact.php">
   74 <table>
   75     <tr><th colspan="2">$titre</th></tr>
   76     <tr>
   77         <td class="label">Vous :</td>
   78         <td><input type="text" name="vous" size="60" value="$vous"></td>
   79     </tr><tr>
   80         <td class="label">Email :</td>
   81         <td><input type="text" name="email" size="60" value="$email"></td>
   82     </tr><tr>
   83         <td class="label">Sujet :</td>
   84         <td><input type="text" name="sujet" size="80" value="$sujet"></td>
   85     </tr><tr>
   86         <td class="label">Message :</td>
   87         <td><textarea rows="8" cols="80" name="message">$message</textarea></td>
   88     </tr><tr>
   89         <td class="button" colspan="2">
   90             <input type="submit" value="  Envoyer le message  " name="ok">
   91         </td>
   92     </tr>
   93 </table>
   94 </form>
   95 
   96 HTML;
   97 else
   98     {
   99     // On envoit le mail
  100     $site = SITE ;
  101     $nom_email = html_entity_decode( $vous ) ;
  102     if ( MAIL_HTML == 'Y' )
  103         {
  104         $message = nl2br( $message ) ;
  105         $headers  = "MIME-Version: 1.0\r\n";
  106         $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  107         $headers .= "From: $nom_email <$email>\r\n";
  108         $mailcorps = <<<HTML
  109 <html>
  110 <head>
  111     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
  112     <title>Site -- CFC</title>
  113     <meta http-equiv="CONTENT-LANGUAGE" content="fr">
  114 <style type="text/css">
  115     body { font-family: sans-serif; font-size: 12pt ; }
  116     h1 { text-align: center; margin: 10px 0; font-size: 14pt ; }
  117     h2 { text-align: left; margin: 10px 10%; font-size: 13pt ; }
  118     p { text-align: justify ; margin: 5px 15% ; }
  119 </style>
  120 </head>
  121 <body>
  122     <h1>$site</h1>
  123     <h2>Correspondant</h2>
  124     <p><a href="mailto:$email">$vous</a> ($email)</p>
  125     <h2>Sujet</h2>
  126     <p>$sujet</p>
  127     <h2>Message</h2>
  128     <p>$message</p>
  129 </body>
  130 </html>
  131 
  132 HTML;
  133         } // MAIL_HTML
  134     else
  135         {
  136         $headers  = "MIME-Version: 1.0\r\n";
  137         $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  138         $headers .= "From: $nom_email <$email>\r\n";
  139         $mailcorps = <<<TEXTE
  140 Emetteur : $vous
  141 Email    : $email
  142 Sujet    : $sujet
  143 
  144 $message
  145 
  146 TEXTE;
  147         }
  148     if ( demoMode('.') )
  149         {
  150         $cnt ="<div class=\"status\"><p>Mode démo: pas d'envoi de message</p></div>\n" ;
  151         }
  152     else
  153         {
  154         mail( EMAIL, SITE, $mailcorps, $headers ) ;
  155         $cnt ="<div class=\"status\"><p>Votre message a été envoyé...</p></div>\n" ;
  156         }
  157     }
  158 $page = str_replace( CONTENU, $cnt, $html ) ;
  159 echo $page ;
  160 ?>
  161 
Makefile index.php tous.php annonce.php contact.php favicon.ico install.flag
~~ / contact.php

Haut de page

Contacter crabs

Date de génération : 22/09/2011 21:48