File: /home/frenchy/refonte2023/wordpress/evenements/paiement2.php
<?php
require_once("_mysql.php");
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'admin/PHPMailer/src/Exception.php';
require 'admin/PHPMailer/src/PHPMailer.php';
require 'admin/PHPMailer/src/SMTP.php';
setlocale (LC_TIME, 'fr_FR.utf8','fra');
if (isset($_POST['email']) && $_POST['email'] != "")
{
die("Robot");
}
$erreur = '';
if (isset($_POST['id_evenement']))
{
$id_evenement = $_POST['id_evenement'];
$req = mysqli_query($link_bdd, "select * from evenements where id_evenement = ".$id_evenement." and date_debut_evenement <= '".date("Y-m-d")."' and date_fin_evenement >= '".date("Y-m-d")."'");
if (mysqli_num_rows($req) != 0)
{
$line = mysqli_fetch_array($req);
}
else
{
die ("Aucun evenement ne correspond");
}
}
else
{
die ("Aucun evenement ne correspond");
}
if (isset($_POST['envoiForm']))
{
$type_paiement = 'NON PAYE PAYPAL';
if ($_POST['type_paiement'] == 'CHEQUE')
{
$type_paiement = 'CHEQUE';
}
if ($_POST['type_paiement'] == 'AUCUN')
{
$type_paiement = 'AUCUN';
}
$montant = $_POST['montant_total'];
if ($montant == 0)
{
$type_paiement ='AUCUN';
}
$membre_contact = 'N/A';
$checkbox_journee = $_POST['radio_1'].'!'.$_POST['radio_2'].'!'.$_POST['radio_3'].'!'.$_POST['radio_4'].'!'.$_POST['radio_5'];
$choix_diner = "";
$checkbox_diner = "";
$nb_diner = "";
if (isset($_POST['checkbox_diner']))
{
$choix_diner = $_POST['radio_diner'];
if ($_POST['radio_diner'] == '500individuel')
{
$checkbox_diner = $_POST['hnombretotal500personneindividuel'];
$nb_diner = $_POST['nombre500personneindividuel'];
}
if ($_POST['radio_diner'] == '750partenaire')
{
$checkbox_diner = $_POST['hnombretotal750personneindividuel'];
$nb_diner = $_POST['nombre750personneindividuel'];
}
if ($_POST['radio_diner'] == '750couple')
{
$checkbox_diner = $_POST['hnombretotal750personnecouple'];
$nb_diner = $_POST['nombre750personnecouple'];
}
if ($_POST['radio_diner'] == '1000leader')
{
$checkbox_diner = $_POST['hnombretotal1000personne'];
$nb_diner = $_POST['nombre1000personne'];
}
if ($_POST['radio_diner'] == '5000table')
{
$checkbox_diner = $_POST['hnombretotal5000personne'];
$nb_diner = $_POST['nombre5000personne'];
}
}
$diner_sup = '';
if (isset($_POST['diner_sup']) && $_POST['diner_sup'] != '' && is_numeric($_POST['diner_sup']))
{
$diner_sup = $_POST['diner_sup'];
}
$don_sup = "";
if (isset($_POST['checkbox_don']))
{
if (isset($_POST['don_sup']) && $_POST['don_sup'] != '' && is_numeric($_POST['don_sup']))
{
$don_sup = $_POST['don_sup'];
}
}
$choix = $checkbox_journee . "|" . $choix_diner.'-'.$nb_diner.'-'.$checkbox_diner . "|" . $diner_sup . "|" . $don_sup;
mysqli_query($link_bdd, "INSERT INTO `contacts2` ( `civilite_contact`, `prenom_contact`, `nom_contact`, `fonction_contact`, `entreprise_contact`, `telephone_contact`, `portable_contact`, `email_contact`, `adresse_entreprise_contact`, `code_postal_entreprise_contact`, `ville_entreprise_contact`, `membre_contact`, `id_evenement`, `montant_paiement`, `top_paiement`, `choix`) VALUES
( '".mysqli_real_escape_string($link_bdd, $_POST['civilite_contact'])."', '".mysqli_real_escape_string($link_bdd, $_POST['prenom_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['nom_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['fonction_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['entreprise_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['telephone_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['portable_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['email_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['adresse_entreprise_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['code_postal_entreprise_contact'])."','".mysqli_real_escape_string($link_bdd, $_POST['ville_entreprise_contact'])."','".mysqli_real_escape_string($link_bdd, $membre_contact)."',".$id_evenement.",'".mysqli_real_escape_string($link_bdd, $montant)."','".$type_paiement."','".$choix."')");
$id_contact = mysqli_insert_id($link_bdd);
// Gestion email Cheque
if ($type_paiement =='CHEQUE' || $type_paiement =='AUCUN' || $montant == 0)
{
// Specifique Facture
$Specifique = "";
// On envoi un mail
$subject = "Confirmation inscription : ".html_entity_decode($line['libelle_evenement'])." du 18-19 novembre 2011";
$fd = fopen("mailconfirmation2.htm", "r");
$message = fread($fd, filesize('mailconfirmation2.htm'));
fclose($fd);
$ligne1 = "<td width='50%'>".$line['libelle_evenement']."</td><td width='50%'> </td>";
$ligne2 = "<td width='50%'>";
if ($checkbox_journee != '')
{
if ($_POST['radio_1'] == 'a')
{
$ligne2 .= "Déjeuner du vendredi 18 novembre à l'Ambassade des Etats-Unis<br />";
}
if ($_POST['radio_2'] == 'b')
{
$ligne2 .= "Rencontres du vendredi 18 novembre après-midi<br />";
}
if ($_POST['radio_3'] == 'c')
{
$ligne2 .= "Visite du château de Versailles le samedi 19 novembre matin<br />";
}
if ($_POST['radio_4'] == 'd')
{
$ligne2 .= "Déjeuner du samedi 19 novembre au Trianon Palace<br />";
}
if ($_POST['radio_5'] == 'e')
{
$ligne2 .= "Panels de discussion Young Leaders du samedi 19 novembre après-midi et cocktail de clôture<br />";
}
}
if ($checkbox_diner != '')
{
$Specifique .=" concernant votre inscription au dîner de gala";
if ($_POST['radio_diner'] == '500individuel')
{
$ligne2 .= $nb_diner." X Dîner de Gala 500€ Individuel<br />";
}
if ($_POST['radio_diner'] == '750partenaire')
{
$ligne2 .= $nb_diner." X Dîner de Gala 750€ Partenaire<br />";
}
if ($_POST['radio_diner'] == '750couple')
{
$ligne2 .= $nb_diner." X Dîner de Gala 750€ Couple<br />";
}
if ($_POST['radio_diner'] == '1000leader')
{
$ligne2 .= $nb_diner." X Dîner de Gala 1000€ Leader<br />";
}
if ($_POST['radio_diner'] == '5000table')
{
$ligne2 .= $nb_diner." X Dîner de Gala 6000€ Table 12 personnes<br />";
}
}
if ($diner_sup != '')
{
$ligne2 .= "Don Gala<br />";
}
if ($don_sup != '')
{
$Specifique .=" concernant votre don.";
$ligne2 .= "Sans participation - Don<br />";
}
$ligne2 .= "</td>";
$ligne2 .= "<td width='50%'>";
if ($checkbox_journee != '')
{
$ligne2 .= " ";
if ($_POST['radio_1'] == 'a')
{
$ligne2 .= " <br />";
}
if ($_POST['radio_2'] == 'b')
{
$ligne2 .= " <br />";
}
if ($_POST['radio_3'] == 'c')
{
$ligne2 .= " <br />";
}
if ($_POST['radio_4'] == 'd')
{
$ligne2 .= " <br />";
}
if ($_POST['radio_5'] == 'e')
{
$ligne2 .= " <br />";
}
}
if ($checkbox_diner != '')
{
$ligne2 .= number_format($checkbox_diner, 2, ',', ' ')."€<br/>";
}
if ($diner_sup != '')
{
$ligne2 .= number_format($diner_sup, 2, ',', ' ')."€<br/>";
}
if ($don_sup != '')
{
$ligne2 .= number_format($don_sup, 2, ',', ' ')."€<br/>";
}
$ligne2 .= "</td>";
if ($montant != 0)
{
$ligne3 = "<td width='50%'><b>Total à payer</b></td><td width='50%'><b>".number_format($montant, 2, ',', ' ')."€</b></td>";
}
else
{
$ligne3 = "";
}
$message = str_replace("%LIGNEPAIEMENT%", "", $message);
if ($montant != 0)
{
$message = str_replace("%FACTUREJOINTE%", "Vous trouverez en pièce jointe votre facture".$Specifique, $message);
$message = str_replace("%MESSAGE1%", "<p>Merci d'envoyer votre règlement par chèque libellé à l'ordre de la French-American Foundation - France, 18 bis boulevard Arago, 75013 Paris <br />Votre inscription sera confirmée dès réception de votre règlement.</p>", $message);
}
else
{
$message = str_replace("%FACTUREJOINTE%", " ", $message);
$message = str_replace("%MESSAGE1%", " ", $message);
}
$message = str_replace("%DATEEVENEMENT%", "18-19 novembre 2011", $message);
$message = str_replace("%LIGNE1%", $ligne1, $message);
$message = str_replace("%LIGNE2%", $ligne2, $message);
$message = str_replace("%LIGNE3%", $ligne3, $message);
$message = str_replace("%LIBELLEEVENEMENT%", $line['libelle_evenement'], $message);
$message = str_replace("%ENTETENOM%", stripcslashes($_POST['civilite_contact'] . " " . $_POST['prenom_contact'] . " " . $_POST['nom_contact']), $message);
// Envoi de la copie du pdf
$reqContact = mysqli_query($link_bdd, "select * from contacts2 where id_contact=".$id_contact);
$lineContact = mysqli_fetch_array($reqContact);
$type_paiement = 'CHEQUE';
$designation = html_entity_decode($line['libelle_evenement'])." du 18-19 novembre 2011";
if ($montant !=0)
{
require_once("admin/pdf/genepdf2.php");
}
// PHP Mailer
$mail = new PHPmailer();
$mail->IsSMTP(); // send via SMTP
$mail->Mailer = "smtp"; // Mode d'acces
$mail->Host = "smtp.outlook.office365.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentification
$mail->Username = "sendmail@french-american.org"; // SMTP username
$mail->Password = "SE4848+1"; // SMTP password
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->IsHTML(true);
$mail->Sender = "contact@french-american.org";
$mail->From="contact@french-american.org";
$mail->FromName="French-american.org";
$mail->AddReplyTo("contact@french-american.org");
if ($montant !=0)
{
$mail->AddAttachment("admin/pdf/factures/".$nompdf);
}
$mail->Subject=$subject;
$mail->Body=utf8_decode($message);
$mail->ClearAddresses();
$mail->AddAddress($_POST['email_contact']);
if ($line['confirmation'] != 'non')
{
if (!$mail->Send())
{
echo '<script>document.location.href="http://www.french-american.org/evenements/merci.php?id_evenement='.$id_evenement.'&top=ko";</script>';
}
}
if ($montant !=0)
{
// PHP Mailer
$mail2 = new PHPmailer();
$mail2->IsSMTP(); // send via SMTP
$mail2->Mailer = "smtp"; // Mode d'acces
$mail2->Host = "smtp.outlook.office365.com"; // SMTP servers
$mail2->SMTPAuth = true; // turn on SMTP authentification
$mail2->Username = "sendmail@french-american.org"; // SMTP username
$mail2->Password = "SE4848+1"; // SMTP password
$mail2->SMTPSecure = 'tls';
$mail2->Port = 587;
$mail2->IsHTML(true);
$mail2->Sender = "contact@french-american.org";
$mail2->From="contact@french-american.org";
$mail2->FromName="French-american.org";
$mail2->AddReplyTo("contact@french-american.org");
$mail2->AddAttachment("admin/pdf/factures/".$nompdf);
$mail2->Subject='Commande par Cheque Formulaire French American Foundation';
$mail2->Body=utf8_decode($message);
$mail2->ClearAddresses();
$mail2->AddAddress('rozenn.jouannigot@french-american.org');
$mail2->AddAddress('rim.hammami@french-american.org');
//$mail2->AddAddress('stephane.didier@live.fr');
if (!$mail2->Send())
{
echo '<script>document.location.href="http://www.french-american.org/evenements/merci.php?id_evenement='.$id_evenement.'&top=ko";</script>';
}
@unlink("admin/pdf/factures/".$nompdf);
}
header('location:http://www.french-american.org/evenements/merci.php?id_evenement='.$id_evenement);
}
}
if ($id_evenement == '')
{
die ("Aucun evenement ne correspond");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html;charset=UTF-8" http-equiv="content-type"/>
<title>Evenement <?=$line['libelle_evenement']?> - Merci de votre inscription</title>
<style type="text/css">
/* General styles */
body { margin: 0; padding: 0; font: 80%/1.5 Arial,Helvetica,sans-serif; color: #111; background-color: #FFF; }
a:hover{
color:#0172b6;
}
a{
color:#0172b6;
}
a:visited{
color:#0172b6;
}
h2 { margin: 0px; padding: 10px; font-family: Georgia, "Times New Roman", Times, serif; font-size: 200%; font-weight: normal; color: #FFF; background-color: #CCC; border-bottom: #BBB 2px solid; }
/* Form styles */
div.form-container {margin: auto; padding: 5px;}
p.legend { margin-bottom: 1em; }
p.legend em { color: #C00; font-style: normal; }
div.form-container form p { margin: 0; }
div.form-container form p.note { margin-left: 170px; font-size: 90%; color: #333; }
div.form-container form fieldset { margin: 10px 0; padding: 10px; border: #DDD 1px solid; }
div.form-container form legend { font-weight: bold; color: #666; }
div.form-container form fieldset div { padding: 0.25em 0; }
div.form-container label,
div.form-container span.label { margin-right: 10px; padding-right: 10px; width: 150px; display: block; float: left; text-align: right; position: relative; }
div.form-container label em,
div.form-container span.label em { position: absolute; right: 0; font-size: 120%; font-style: normal; color: #C00; }
div.form-container input:focus,
div.form-container textarea:focus { background-color: #FFC; border-color: #FC6; }
div.form-container div.controlset label,
div.form-container div.controlset input { display: inline; float: none; }
div.form-container div.controlset div { margin-left: 170px; }
div.form-container div.buttonrow { margin: auto; text-align:center;}
#divAdhesion { margin: auto; text-align:center; border-width:2px; border-style:solid; border-color:#000000;}
#messageNonMembre { text-align:center; font-size: 12px; font-weight: bold;color:#FF0000;}
#checkboxMembre { font-size: 14px; font-weight: bold;}
</style>
</head>
<body>
<div id="header" style="border: 1px solid #8a959b; width: 752px; margin: auto;">
<table width="100%" cellspacing="0" cellpaddin="0">
<tr>
<td width="50%">
<img src="/evenements/images/logo_faf.jpg" alt="logo FAF" style="float: left; margin: 30px;" width="300">
</td>
<td width="50%">
<p style="font-size: 24px;font-weight:bold; color:#0172b6; text-align:right; margin: 30px;">Inscription</p>
</td>
</tr>
<tr>
<td colspan="2" style="background-color:#0172b6; width: 100%;">
<div style="text-align: center; color:#ffffff; font-size: 20px;"><b><?=utf8_encode(html_entity_decode($line['libelle_evenement']))?></b></div>
<?php
if ($line['descriptif_evenement'] != '')
{
?>
<div style="text-align: center; color:#ffffff; font-size: 14px;"><b><?=nl2br($line['descriptif_evenement'])?></b></div>
<?php
}
?>
<div style="text-align: center; color:#ffffff; font-size: 18px;"><b>18-19 novembre 2011</b></div>
</td>
</tr>
<tr>
<td colspan="2">
<?php
/* Debut de paiement Paypal */
echo '<font face=Verdana size=2><center><br><br>
Merci.<br /><br />Pour finaliser votre inscription, nous vous invitons à effectuer votre paiement en ligne d\'un montant de <b>'.($montant).' €</b> par carte bancaire via Paypal.<br>
<br><br>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type=hidden name="amount" value="'.number_format($montant, 2, '.', '').'">
<input type=hidden name="cmd" value="_xclick">
<input name="return" type="hidden" value="http://www.french-american.org/evenements/merci.php?id_evenement='.$id_evenement.'">
<input name="cancel_return" type="hidden" value="http://www.french-american.org/evenements/annule.php?id_evenement='.$id_evenement.'">
<input name="notify_url" type="hidden" value="http://www.french-american.org/evenements/ipn_paypal2.php?id_commande='.$id_contact.'">
<input type=hidden name="email" value="'.$_POST['email_contact'].'">
<input type=hidden name="currency_code" value="EUR">
<input type=hidden name="no_shipping" value="1">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="business_dev" value="'.'franck_1300481920_biz@netcourrier.com'.'">
<input type="hidden" name="business" value="'.'hugues.derevel@french-american.org'.'">
<input type=hidden name="item_name" value="Evenement '.$line['libelle_evenement'].'">
<input type=hidden name="no_note" value="1">
<input name="custom" type="hidden" value="'.$id_contact.'" />
<input type=submit name=submit value="Procéder au paiement sécurisé par CB >>">
</form>
<br><br>';
/* Fin de paiement Paypal */
?>
</td>
</tr>
</table>
</div>
</body></html>