File: /home/frenchy/refonte2023/wordpress/evenements/paiement2-us.php
<?php
require_once("_mysql.php");
require_once("admin/phpmailer/class.phpmailer.php");
setlocale (LC_TIME, 'en_US.utf8');
if (isset($_POST['email']) && $_POST['email'] != "")
{
die("Robot");
}
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 ("This event doesn't exist");
}
}
else
{
die ("This event doesn't exist");
}
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'];
$membre_contact = 'N/A';
$checkbox_journee = "";
if (isset($_POST['checkbox_journee']))
{
$checkbox_journee = 250;
}
$journee_sup = '';
if (isset($_POST['journee_sup']) && $_POST['journee_sup'] != '' && is_numeric($_POST['journee_sup']))
{
$journee_sup = $_POST['journee_sup'];
}
$checkbox_diner = "";
if (isset($_POST['checkbox_diner']))
{
if ($_POST['radio_diner'] == 'individuel')
{
$checkbox_diner = 500;
}
if ($_POST['radio_diner'] == 'couple')
{
$checkbox_diner = 750;
}
}
$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 . "|" . $journee_sup . "|" . $checkbox_diner . "|" . $diner_sup . "|" . $don_sup;
mysqli_query($link_bdd, "INSERT INTO `contacts2us` ( `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')
{
// On envoi un mail
$subject = "Registration confirmation : ".html_entity_decode($line['libelle_evenement'])." on november 18-19, 2011";
$fd = fopen("mailconfirmation-us.htm", "r");
$message = fread($fd, filesize('mailconfirmation-us.htm'));
fclose($fd);
$ligne1 = "<td width='50%'>".$line['libelle_evenement']."</td><td width='50%'> </td>";
$ligne2 = "<td width='50%'>";
if ($checkbox_journee != '')
{
$ligne2 .= "Journées du trentième anniversaire<br/>Participation aux frais<br />";
}
if ($journee_sup != '')
{
$ligne2 .= "Don Trentième anniversaire<br />";
}
if ($checkbox_diner != '')
{
if ($_POST['radio_diner'] == 'individuel')
{
$ligne2 .= "Dîner de Gala Individuel<br />";
}
if ($_POST['radio_diner'] == 'couple')
{
$ligne2 .= "Dîner de Gala Couple<br />";
}
}
if ($diner_sup != '')
{
$ligne2 .= "Don Gala<br />";
}
if ($don_sup != '')
{
$ligne2 .= "Sans participation - Don<br />";
}
$ligne2 .= "</td>";
$ligne2 .= "<td width='50%'>";
if ($checkbox_journee != '')
{
$ligne2 .= "<br/>250,00€<br/>";
}
if ($journee_sup != '')
{
$ligne2 .= number_format($journee_sup, 2, ',', ' ')."€<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>";
$ligne3 = "<td width='50%'><b>Total réglé</b></td><td width='50%'><b>".number_format($montant, 2, ',', ' ')."€</b></td>";
$message = str_replace("%LIGNEPAIEMENT%", "Merci d'envoyer votre règlement par chèque libellé à l'ordre de la French-American Foundation - France, 18 bis boulevard Arago, 75013 Paris.", $message);
$message = str_replace("%MESSAGE1%", "Celle-ci sera confirmée dès réception de votre règlement.", $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);
// 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 ($membre_contact == 'NON')
{
$message = str_replace("%MESSAGE2%", "<p>Nous avons bien noté que vous n'êtiez pas membre de la French-American Foundation - France et nous vous invitons à remplir le bulletin d'adhésion qui se trouve en pièce jointe de ce message.</p><br />", $message);
$mail->AddAttachment("France_Adhesion_indiv 2020.pdf");
}
else
{
$message = str_replace("%MESSAGE2%", "", $message);
}
$mail->Subject=$subject;
$mail->Body=utf8_decode($message);
$mail->ClearAddresses();
$mail->AddAddress($_POST['email_contact']);
if ($line['confirmation'] != 'non')
{
$mail->Send();
}
if ($montant !=0)
{
// Envoi de la copie du pdf
$reqContact = mysqli_query($link_bdd, "select * from contacts2us where id_contact=".$id_contact);
$lineContact = mysqli_fetch_array($reqContact);
$reqEvenement = mysqli_query($link_bdd, "select * from evenements where id_evenement=".$lineContact['id_evenement']);
$lineEvenement = mysqli_fetch_array($reqEvenement);
$type_paiement = 'CHEQUE';
require_once("admin/pdf/genepdf2.php");
// 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');
$mail2->Send();
@unlink("admin/pdf/factures/".$nompdf);
}
header('location:http://www.french-american.org/evenements/thanks.php?id_evenement='.$id_evenement);
}
}
if ($id_evenement == '')
{
die ("This event doesn't exist");
}
?>
<!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>Event <?=$line['libelle_evenement']?> - Thank you for your registration</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>november 18-19, 2011</b></div>
</td>
</tr>
<tr>
<td colspan="2">
<?php
/* Debut de paiement Paypal */
echo '<font face=Verdana size=2><center><br><br>
Thank you.<br /><br />To complete your registration, please make your payment online in the amount of <b>'.($montant).' $</b> with your credit card on 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/thanks.php?id_evenement='.$id_evenement.'">
<input name="cancel_return" type="hidden" value="http://www.french-american.org/evenements/cancel.php?id_evenement='.$id_evenement.'">
<input name="notify_url" type="hidden" value="http://www.french-american.org/evenements/ipn_paypal2-us.php?id_commande='.$id_contact.'">
<input type=hidden name="email" value="'.$_POST['email_contact'].'">
<input type=hidden name="currency_code" value="USD">
<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="Event '.$line['libelle_evenement'].'">
<input type="hidden" name="lc" value="EN">
<input type=hidden name="no_note" value="1">
<input name="custom" type="hidden" value="'.$id_contact.'" />
<input type=submit name=submit value="Make payment >>">
</form>
<br><br>';
/* Fin de paiement Paypal */
?>
</td>
</tr>
</table>
</div>
</body></html>