ldc-reghalal/unsubscribe.php
2021-07-09 11:43:56 +02:00

149 lines
No EOL
5.6 KiB
PHP

<?php
require_once 'LDCCRM/ApiV1.php';
require_once 'vendor/autoload.php';
Dotenv\Dotenv::createImmutable(__DIR__)->load();
/* CRM */
define( 'CRM_TOKEN', getenv('CRM_API_TOKEN') );
define( 'CRM_ENDPOINT', getenv('CRM_ENDPOINT') );
if (!isset($_GET['hashcode']) || empty($_GET['hashcode']))
die('Missing fields.');
$hashcode = filter_var($_GET['hashcode'], FILTER_SANITIZE_STRING);
$apiCrm = new \LDCCRM\ApiV1(CRM_ENDPOINT, CRM_TOKEN);
$result = $apiCrm->removeOptInCustomer($hashcode);
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Désinscription à la newsletter Réghalal</title>
<style>
@font-face {
font-family: 'Barlow';
src: url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Barlow-Regular.eot');
src: url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Barlow-Regular.eot?#iefix') format('embedded-opentype'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Barlow-Regular.woff2') format('woff2'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Barlow-Regular.woff') format('woff'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Barlow-Regular.ttf') format('truetype'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Barlow-Regular.svg#Barlow-Regular') format('svg');
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Merienda';
src: url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Merienda-Bold.eot');
src: url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Merienda-Bold.eot?#iefix') format('embedded-opentype'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Merienda-Bold.woff2') format('woff2'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Merienda-Bold.woff') format('woff'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Merienda-Bold.ttf') format('truetype'),
url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Merienda-Bold.svg#Merienda-Bold') format('svg');
font-weight: bold;
font-style: normal;
font-display: swap;
}
html, body, ::before, ::after, *{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background: url('https://www.reghalal.com/wp-content/themes/reghalal/theme/img/prod-slider-background.jpg') center center no-repeat;
background-size: cover;
background-color: #f5ecde;
font-family: 'Barlow', Arial, Helvetica, sans-serif;
font-size: 30px;
font-weight: normal;
color: #000000;
}
.post-title{
font-family: 'Merienda', Arial, Helvetica, sans-serif;
font-size: 1.33em;
font-weight: 700;
color: #e30613;
}
a{
color: #000000;
transition: color .5s;
}
a:hover{color: #e30613;}
p{
margin: 1em 0;
font-size: .8em;
}
span{font-size: .6em;}
.wrapper-unsub{
display: grid;
grid-template-rows: min-content min-content auto min-content;
justify-items: center;
min-height: 100vh;
padding: 10vw 4vw;
}
.unsub--logo{
width: 60%;
text-align: center;
}
.unsub--logo img{
width: 100%;
max-width: 300px;
}
.unsub--title{
margin: 4vw 0;
text-align: center;
}
.unsub--footer{width: 100%;}
@media only screen and (min-width:768px) {
.post-title{font-size: 2em;}
p{font-size: 1em;}
span{font-size: .8em;}
.wrapper-unsub{padding: 4vw 10vw;}
}
@media only screen and (min-width:1024px) {
.post-title{font-size: 2.33em;}
p{font-size: 1.2em;}
span{font-size: 1em;}
}
@media only screen and (min-width:1440px) {
}
@media only screen and (min-width:1920px) {
}
</style>
</head>
<body>
<div class="wrapper-unsub">
<div class="unsub--logo">
<img src="https://www.reghalal.com/wp-content/uploads/2020/09/logo.png" alt="Logo de la marque Réghalal">
</div>
<div class="unsub--title">
<h1 class="post-title">Désinscription</h1>
</div>
<?php if ($result->status === "OK"){ ?>
<div class="unsub--content">
<p>Vous êtes désinscris de la newsletter Réghalal.</p>
<p>En espérant vous revoir bientôt !</p>
</div>
<?php } else {
error_log("ERROR CRM API : $result->code - $result->message | hashcode : $hashcode");
?>
<div class="unsub--content">
<p>Une erreur est survenue.</p>
<p>Veuillez réessayer ultérieurement.</p>
</div>
<?php } ?>
<div class="unsub--footer">
<span>Retrouvez-nous sur <a href="https://www.reghalal.com">reghalal.com</a> !</span>
</div>
</div>
</body>
</html>