<?php

if (PHP_MAJOR_VERSION < 7) {
    echo "Server error 0x01";
    exit;
}

$__RB_error = [];
$__RB_success = [];

session_start();

require_once(__DIR__ .'/sessionHandler.php');

/*
if (!empty($_SESSION['returnPage']) && !empty($_GET['a']) && in_array($_GET['a'], ['checkout', 'thankyou'])) {
    $returnPage = $_SESSION['returnPage'];
    $returnPage = explode('/', $returnPage);

    array_pop($returnPage);

    $returnPage = implode('/', $returnPage);

    if ($_GET['a'] == 'checkout') {
        $returnPage .= '/checkout.php?error=1';

    } else {
        $var = $_SESSION['returnPage'];

        $var = explode('/', $var);
        $lng = array_pop($var);

        if (empty($lng) || strpos($lng, '.') !== false) {
            $lng = array_pop($var);
        }

        $template = array_pop($var);

        include(__DIR__ .'/cp/'. $template .'/'. $lng .'/thankyou.php');

        exit;

        $returnPage .= '/thankyou.php';
    }

    header("location: " . $returnPage);

    exit;
}

if (!empty($_POST['submitTo3d']) && !empty($_POST['returnPage'])) {
    $_SESSION['returnPage'] = $_POST['returnPage'];

    $executeTo3d = json_decode($_POST['submitTo3d'], true);

    if (!empty($executeTo3d['script'])) {
        echo "<html><head></head><body><script>". $executeTo3d['script'] ." </script></body></html>";

        exit;
    }

    if (!empty($executeTo3d['url'])) {
        echo "<script>window.location = '". $executeTo3d['script'] ."';</script>";

        exit;
    }

    http_response_code(404);

    exit;
}
*/

require_once(__DIR__ .'/const.php');
require_once(__DIR__ .'/api.php');
require_once(__DIR__ .'/cloud/init.php');
