<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flux CMS - Server Environment Checker</title>
    <style>
        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh; /* Ensure the body takes at least the full height of the viewport */
            font-family: Arial, Helvetica, sans-serif;
            font-size: 14px;
            background-color: #f4f4f4;
            color: #333;
            margin: 0;
            padding: 0;
        }

        h1 {
            background-color: #2c3e50;
            color: #ecf0f1;
            padding: 15px;
            text-align: center;
            margin: 0;
            font-size: 1.5rem;
        }

        .container {
            flex: 1; /* Allow the container to grow and take available space */
            max-width: 800px;
            margin: 30px auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        .pass {
            color: #27ae60;
            font-weight: bold;
        }

        .fail {
            color: #e74c3c;
            font-weight: bold;
        }

        ul {
            padding-left: 20px;
            list-style-type: none; /* Remove the default bullet points */
        }

        p {
            font-size: 1rem;
            margin-bottom: 20px;
        }

        .summary {
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            padding: 15px;
            margin-top: 20px;
            border-radius: 8px;
        }

        .success {
            color: #27ae60;
            font-weight: bold;
        }

        .error {
            color: #e74c3c;
            font-weight: bold;
        }

        footer {
            text-align: center;
            padding: 10px;
            background-color: #2c3e50;
            color: #ecf0f1;
            width: 100%;
        }
		footer a {
		color: #ADD8E6; /* Lighter shade of violet */
		text-decoration: none; /* Remove underline */
		}
	
		footer a:hover {
			color: #ffffff; /* Even lighter shade on hover */
			text-decoration: underline; /* Add underline on hover */
		}
    </style>
</head>
<body>
    <h1>Flux CMS - Server Environment Checker</h1>
    <div class="container">
        <?php
        extension_check(array( 
            'curl',
            'dom', 
            'gd', 
            'iconv',
            'mbstring',
            'pcre', 
            'pdo', 
            'SimpleXML',
            'openssl',
            'json',
            'session',
            'xml',
            'Reflection'
        ));

        function extension_check($extensions) {
            $required_php_version = '7.1.0';
            $required_loader = '10.0.0';
            $fail = '';
            $pass = '';

            if (version_compare(phpversion(), $required_php_version, '<')) {
                $fail .= '<li class="fail">You need<strong> PHP '.$required_php_version.'</strong> (or greater)</li>';
            } else {
                $pass .= '<li class="pass">✓ You have<strong> PHP '.$required_php_version.'</strong> (or greater)</li>';
            }

            foreach ($extensions as $extension) {
                if (!extension_loaded($extension)) {
                    $fail .= '<li class="fail">You are missing the <strong>'.$extension.'</strong> extension</li>';
                } else {    
                    $pass .= '<li class="pass">✓ You have the <strong>'.$extension.'</strong> extension</li>';
                }
            }

            if (!extension_loaded("pdo_odbc") && !extension_loaded("pdo_sqlsrv") && !extension_loaded("sqlsrv") && !extension_loaded("pdo_dblib")) {
                $fail .= '<li class="fail">You are missing all of the following extensions: pdo_odbc, pdo_sqlserv, pdo_dblib, sqlsrv. Install at least one of them</li>';
            }

            if (function_exists('ioncube_loader_iversion')) {
                $ilv = ioncube_loader_iversion();
                $current_loader = sprintf("%d.%d.%d", $ilv / 10000, ($ilv / 100) % 100, $ilv % 100);
                if (version_compare($required_loader, $current_loader, ">")) {
                    $fail .= '<li class="fail">Required IonCube loader <strong>'.$required_loader.'</strong> or later. Your IonCube loader version is <strong>'.$current_loader.'</strong></li>';
                } else {
                    $pass .= '<li class="pass">✓ You have IonCube loader version <strong>'.$required_loader.'</strong> (or greater)</li>';
                }
            } else {
                $fail .= '<li class="fail">You are missing <strong>IonCube</strong> loaders.</li>';
            }

            if ($fail) {
                echo '<div class="summary error">Your server does not meet the following requirements to install Flux CMS:</div>';
                echo '<ul>'.$fail.'</ul>';
                echo '<div class="summary success">The following requirements were successfully met:</div>';
                echo '<ul>'.$pass.'</ul>';
            } else {
                echo '<div class="summary success"><strong>Congratulations!</strong> Your server meets the requirements for Flux CMS.</div>';
                echo '<ul>'.$pass.'</ul>';
            }
        }
        ?>
    </div>
    <footer>
        <p>&copy; <?php echo date('Y'); ?> <a href="https://creativstock.biz" target="_blank">Flux CMS</a> All rights reserved.</p>
    </footer>
</body>
</html>