<?php

use CodeIgniter\Boot;
use Config\Paths;

/*
 *---------------------------------------------------------------
 * CHECK PHP VERSION
 *---------------------------------------------------------------
 */

$minPhpVersion = '8.2'; // If you update this, don't forget to update `spark`.
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
    $message = sprintf(
        'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
        $minPhpVersion,
        PHP_VERSION,
    );

    header('HTTP/1.1 503 Service Unavailable.', true, 503);
    echo $message;

    exit(1);
}

/*
 *---------------------------------------------------------------
 * SET THE CURRENT DIRECTORY
 *---------------------------------------------------------------
 */

// Path to the front controller (this file)
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);

// Ensure the current directory is pointing to the front controller's directory
if (getcwd() . DIRECTORY_SEPARATOR !== FCPATH) {
    chdir(FCPATH);
}

/*
 *---------------------------------------------------------------
 * APPLICATION CONSTANTS
 *---------------------------------------------------------------
 * These were defined at the top of system/bootstrap.php, which the
 * 4.7.6 upgrade replaced with the stock file. They have to be set
 * here because Config\Constants is loaded by Boot before ENVIRONMENT
 * is defined, so it cannot branch on it.
 *
 * Boot::defineEnvironment() only sets ENVIRONMENT when it is not
 * already defined, so this host-based override still wins.
 */

$host = $_SERVER['HTTP_HOST'] ?? '';

if ($host === 'localhost' || str_contains($host, '192.168') || $host === 'dev.admedia.com') {
    define('ENVIRONMENT', 'development');
    define('PROTOCOL', 'https://');
    define('DOMAIN_PATH', 'dev.admedia.com/php85/mehak/designgpt.com/html/public');
    define('baseUrl', 'http://192.168.30.106/php85/mehak/designgpt.com/html/public/?/');
} else {
    define('ENVIRONMENT', 'production');
    define('PROTOCOL', 'https://');
    define('DOMAIN_PATH', $host . '/');
    define('baseUrl', $host . '/');
}

/*
 *---------------------------------------------------------------
 * BOOTSTRAP THE APPLICATION
 *---------------------------------------------------------------
 * This process sets up the path constants, loads and registers
 * our autoloader, along with Composer's, loads our constants
 * and fires up an environment-specific bootstrapping.
 */

// LOAD OUR PATHS CONFIG FILE
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH . '../app/Config/Paths.php';
// ^^^ Change this line if you move your application folder

$paths = new Paths();

// LOAD THE FRAMEWORK BOOTSTRAP FILE
require $paths->systemDirectory . '/Boot.php';

exit(Boot::bootWeb($paths));
