<?php
session_start();
include "../includes/connect.php";
require_once "../includes/Mobile_Detect.php";

$openFile = fopen("cdata.txt", "r") or die("Unable to open file!");
$campaignData = fread($openFile, filesize("cdata.txt"));
fclose($openFile);

$campaignInfo = explode(PHP_EOL, $campaignData);
$campaignid = $campaignInfo[0];

$datiCampagna = $connection->query("SELECT meta_key,meta_value FROM campaigns_meta WHERE campaign_id = '$campaignid' UNION ALL select 'txtLang' as meta_key,left(code,2) as meta_value from languages where id=(select meta_value from campaigns_meta where campaign_id='$campaignid' and meta_key='language');");

$campaignData = $datiCampagna->fetchAll(PDO::FETCH_KEY_PAIR);

$detect = new Mobile_Detect;

?>
<!DOCTYPE html>
<html lang="<?php echo $campaignData['txtLang']; ?>">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="<?php echo $campaignData['campaign_description']; ?>" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
    <!-- <link rel="shortcut icon" href="assets/1_66bce83c4ac77e50c0afcad5ee7bf433.ico?v=39884" />
        <link rel="apple-touch-icon" href="assets/1_66bce83c4ac77e50c0afcad5ee7bf433.ico?v=39884"> -->
    <title>
        <?php echo $campaignData['campaign_title']; ?>
    </title>
    <meta property="og:title" content="<?php echo $campaignData['campaign_title']; ?>" />
    <meta property="og:description" content="<?php echo $campaignData['campaign_description']; ?>" />
    <link href="../campaignsAssets/css/common.css" rel="stylesheet">
    <link href="../campaignsAssets/css/voucherzone_style.css" rel="stylesheet">
    <link href="../campaignsAssets/css/layout.css" rel="stylesheet">
    <link href="../campaignsAssets/css/white.css" rel="stylesheet">
    <link href="../campaignsAssets/css/branding.css" rel="stylesheet">
</head>

<body>
    <div class="body-wrap lang_it" style="background-image: url(assets/<?php echo $campaignData['bg']; ?>)">
        <!-- immagine grande di sfondo -->
        <div class="body-wrap-in">
            <div class="content">
                <div class="content-in">
                    <div class="panels">
                        <div class="panel" id="thanks">
                            <div class="container">
                                <div class="row content-row">
                                    <div class="position-info">
                                        <div class="position-text">
                                            <div class="position-title-wrap">
                                                <div class="title"></div>
                                                <div class="subtitle"></div>
                                            </div>
                                            <div class="position-image">
                                                <img src="assets/<?php echo $campaignData['front_desktop']; ?>" alt="" class="pure-pic packshot-large" /> <!-- immagine front desktop form -->
                                                <img src="assets/<?php echo $campaignData['front_mobile']; ?>" alt="" class="pure-pic packshot-small" /> <!-- immagine front mobile form -->
                                            </div>
                                        </div>
                                    </div>
                                    <div class="position-form">
                                        <div class="questions" id="question-container">
                                            <div class="questions-progress-wrap">
                                                <div class="questions-progress">
                                                    <div class="questions-almost ">
                                                        <!-- <div class="questions-almost-img">
                                                                    <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                                                 width="200px" height="141.406px" viewBox="100 29.297 200 141.406" enable-background="new 100 29.297 200 141.406"
                                                 xml:space="preserve">
                                                                                            <path fill="#F30B0B" d="M137.578,37.578l-8.281-8.281C110.391,48.203,100,73.281,100,100s10.391,51.836,29.297,70.703l8.281-8.281
                                                                                                c-16.68-16.68-25.859-38.828-25.859-62.422S120.898,54.258,137.578,37.578z"/>
                                                <path fill="#F30B0B" d="M145.898,45.898C131.406,60.352,123.438,79.57,123.438,100s7.969,39.648,22.461,54.102l8.281-8.281
                                                                                                c-12.266-12.266-19.023-28.516-19.023-45.82s6.758-33.555,19.023-45.82L145.898,45.898z"/>
                                                <path fill="#F30B0B" d="M270.703,29.297l-8.281,8.281c16.68,16.68,25.859,38.867,25.859,62.422s-9.18,45.742-25.859,62.422
                                                                                                l8.281,8.281C289.609,151.797,300,126.719,300,100S289.609,48.203,270.703,29.297z"/>
                                                <path fill="#F30B0B" d="M254.102,45.898l-8.281,8.281c12.266,12.266,19.023,28.555,19.023,45.82c0,17.305-6.758,33.555-19.023,45.82
                                                                                                l8.281,8.281c14.492-14.453,22.461-33.672,22.461-54.102S268.594,60.352,254.102,45.898z"/>
                                                <path fill="#F30B0B" d="M163.945,119.922h72.07v9.18h-72.07V119.922z"/>
                                                <path fill="#F30B0B" d="M191.367,142.695c0,4.766,3.867,8.633,8.633,8.633s8.633-3.867,8.633-8.633v-1.875h-17.266V142.695z"/>
                                                <path fill="#F30B0B" d="M225.742,96.133V84.258c0-12.227-8.516-22.422-19.883-25.078V48.711h-11.719V59.18
                                                                                                c-11.406,2.656-19.883,12.891-19.883,25.078v11.875c0,4.258-1.094,8.398-3.047,12.031h57.656
                                                                                                C226.836,104.531,225.742,100.43,225.742,96.133z"/>
                                                                                            </svg>                    </div>
                                            -->
                                                        <div class="questions-almost-text">
                                                            <?
if (isset($_SESSION["isRegist"]) && !empty($_SESSION["isRegist"]) && $_SESSION["isRegist"] === "no") {
	?>
                                                                <div class="onLeadCreated" style="color:black!important;" >
                                                                    <?if ($campaignData["txtLang"] == "it") {?>
                                                                        Grazie per esserti registrato su LaBakeca.eu! <br><b>
                                                                        Ti abbiamo inviato una mail di conferma dell'iscrizione! <br><br>
                                                                        <em>Se non dovessi trovarla, verifica anche nello spam!</em>
                                                                        </b>
                                                                    <?} elseif ($campaignData["txtLang"] == "es") {?>

                                                                        Gracias por registrarse en LaBakeca.eu<br><b>
                                                                        ¡Te hemos enviado un correo electrónico confirmando tu registro! <br><br>
                                                                        <em>Si no lo encuentras, comprueba tu carpeta de correo no deseado.</em>
                                                                        </b>

                                                                    <?} elseif ($campaignData["txtLang"] == "en") {?>

                                                                        Thank you for registering on LaBakeca.eu! <br><b>
                                                                            We have sent you an e-mail confirming your registration!<br><br>
                                                                        <em>If you don't find it, please check your spam folder!</em>
                                                                        </b>
                                                                    <?}?>

                                                                <?
} else {
	?>
                                                                    <div class="onLeadCreated" style="color:black!important;">
                                                                     <b>
                                                                        <?if ($campaignData["txtLang"] == "it") {?>
                                                                            Il tuo account è già stato creato in precedenza!
                                                                        <?} elseif ($campaignData["txtLang"] == "es") {?>
                                                                            Su cuenta ya ha sido creada.
                                                                        <?} elseif ($campaignData["txtLang"] == "en") {?>
                                                                            Your account has already been created!
                                                                        <?}?>
                                                                     </b>
                                                                    <br><a href="https://labakeca.eu">
                                                                        <?if ($campaignData["txtLang"] == "it") {?>
                                                                            Se non ti ricordi la password puoi sempre recuperarla dal pannello Account sulla nostra Homepage!
                                                                        <?} elseif ($campaignData["txtLang"] == "es") {?>
                                                                           Si no recuerda su contraseña, siempre puede recuperarla en el panel Cuenta de nuestra página de inicio.
                                                                        <?} elseif ($campaignData["txtLang"] == "en") {?>
                                                                            If you don't remember your password, you can always retrieve it from the Account panel on our Homepage!
                                                                        <?}?>

                                                                </a>
                                                                    <?
}
$_SESSION["isRegist"] = "";
session_destroy();
?>
                                                                </div>
                                                                                                                   <!-- <div class="question-progress-impulse">
                                                                               Ricorda, se non l'hai ancora fatto, di confermare il tuo indirizzo email per validare la tua partecipazione al concorso: se non trovi l'email nella "Posta in arrivo", controlla anche nello spam!</div>
                                                                           </div>
                                                                       </div>
                                                                       <p class="hide"></p>
                                                                       <div class="question-progress">
                                                                           <div id="question-progress-bar"></div>
                                                                           <span class="question-progress-num"></span>
                                                                       </div>
                                                                   </div>-->
                                                                                                                   <!-- <div class="question-progress-impulse">
                                                                               Ricorda, se non l'hai ancora fatto, di confermare il tuo indirizzo email per validare la tua partecipazione al concorso: se non trovi l'email nella "Posta in arrivo", controlla anche nello spam!</div>
                                                                           </div>-->
                                                            <div class="questions-in">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Footer Section -->

</body>

</html>