TeleQom.org/php/newsletter.php

26 lines
1.0 KiB
PHP
Raw Normal View History

2023-03-15 19:53:04 +00:00
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/config/PRIVATE/NEWSLETTER.php';
$lang_folder = $_GET['newsletter-language']=="fr"?"/pages/fr/":"/pages/en/";
$contact_form_url = $_GET['newsletter-language']=="fr"?$_ENV['newsletter_url_fr']:$_ENV['newsletter_url_en'];
if(!str_contains($_GET['newsletter-email'], "@") || !str_contains($_GET['newsletter-email'], ".") || strlen($_GET['newsletter-email']) < 6 || $_GET['newsletter-email-2'] != "") {
header('Location: '.$lang_folder.'err/general.html');
die();
}
$ch = curl_init($contact_form_url);
curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode('email').'='.urlencode($_GET['newsletter-email']));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode==200){
header('Location: '.$lang_folder.'confirmation.html');
die();
}
header('Location: '.$lang_folder.'err/general.html');
?>