<?php
if (!class_exists('Authenticate')) require_once("common_cadline_libraries/crm_test.class.php");

$encodedSession = isset($_GET['session']) ? $_GET['session'] : '';
$authCode       = isset($_GET['authCode']) ? $_GET['authCode'] : '';
$session        = base64_decode($encodedSession);

$auth = new Authenticate();
$auth->setAuthCode($authCode);
$auth->setAuthSession($encodedSession);
$auth->auth();

$action = isset($_GET['mode']) ? $_GET['mode'] : '';
$lang   = isset($_GET['lang']) ? $_GET['lang'] : '';
$blank  = false;

$fileName = Webform::getLanguageFile($lang);

require_once($fileName);

switch ($action) {
    case 'reg':
        $success_message    = $regSuccess_msg['activation_message'];
        $title              = $regSuccess_msg['register'];
        break;

    case 'unreg':
        $success_message    = $regSuccess_msg['deactivation_message'];
        $title              = $regSuccess_msg['unregister'];
        break;

    default:
        $blank = true;
        break;
}

if (!$blank) : ?>
    <html>

    <head>
        <title><?= $title ?></title>

        <link href="/public/img/icons/<?= $common_msg['favicon'] ?>" rel="shortcut icon" type="image/vnd.microsoft.icon" />
        <link rel="stylesheet" href="../css/bootstrap.min.css" />

        <style>
            .alert {
                display: inline-block;
            }

            .container {
                margin-top: 15%;
                margin-left: 30%;
            }

            img {
                position: absolute;
                margin-top: -12%;
                margin-left: 1%;
            }
        </style>
    </head>

    <body>
        <a href="<?= $common_msg['webpage'] ?>" target="_blank"><img src="<?= $common_msg['logo'] ?>" /></a>
        <div class="container">
            <div class="alert alert-warning" role="alert">
                <?= $success_message ?>
            </div>
            <br />

            <div class="alert alert-success" role="alert">
                <?= $regSuccess_msg['close_browser'] ?>
            </div>
        </div>
    </body>

    </html>
<?php endif; ?>