<?php

$errors = array();

if (version_compare(PHP_VERSION, '8.2.0', '<')) {
    $errors[] = 'PHP Version 8.2.0 or above is required';
}

if (!extension_loaded('ionCube Loader')) {
    $errors[] = 'You are missing the ionCube Loader';
}

if (function_exists('ioncube_loader_version')) {
    $ioncubeVersion = ioncube_loader_version();
    $phpVersion = PHP_VERSION;

    if ((version_compare($phpVersion, '8.4', '>=') && version_compare($ioncubeVersion, '15.0', '<')) ||
        (version_compare($phpVersion, '8.2', '>=') && version_compare($phpVersion, '8.4', '<') && version_compare($ioncubeVersion, '14.0', '<'))
    ) {
        $errors[] = 'Your ionCube Loader version is not compatible with your PHP version';
    }
}


if ((isset($_REQUEST['missingExtension']) && $_REQUEST['missingExtension'] == true) || (count($errors) > 0)) {
    $requiredExtensions = ['pdo_mysql', 'mysqli', 'curl', 'mbstring', 'json', 'SimpleXML', 'iconv', 'soap'];
    $missingExtensions = [];
    foreach ($requiredExtensions as $extension) {
        if (!extension_loaded($extension)) {
            $missingExtensions[] = $extension;
        }
    }
    if (count($missingExtensions) > 0 || count($errors) > 0) {
        include 'templates/default/views/home/indexpublic/dependencyerrors.phtml';
        die();
    } else {
        header('Location: index.php');
    }
}

require 'library/front.php';
