<?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'] : '';
$result = isset($_GET['result']) ? $_GET['result'] : '';
$blank  = false;

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

require_once($fileName);

$title = $loginSuccess_msg['login'];

if ($result == 'result_ok')
    $success_message = $loginSuccess_msg['loginSuccess_message'];
else
    $success_message = $loginSuccess_msg['loginFailed_message'];

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; ?>