diff --git a/ci4/app/Config/App.php b/ci4/app/Config/App.php index 6cc09416..7a913ab6 100755 --- a/ci4/app/Config/App.php +++ b/ci4/app/Config/App.php @@ -25,6 +25,19 @@ class App extends BaseConfig */ public $baseURL = ''; + /** + * Allowed Hostnames in the Site URL other than the hostname in the baseURL. + * If you want to accept multiple Hostnames, set this. + * + * E.g., + * When your site URL ($baseURL) is 'http://example.com/', and your site + * also accepts 'http://media.example.com/' and 'http://accounts.example.com/': + * ['media.example.com', 'accounts.example.com'] + * + * @var list + */ + public array $allowedHostnames = []; + /** * -------------------------------------------------------------------------- * Index File @@ -325,6 +338,7 @@ class App extends BaseConfig */ public $cookieSameSite = 'Lax'; + /** * -------------------------------------------------------------------------- * Reverse Proxy IPs @@ -332,18 +346,21 @@ class App extends BaseConfig * * If your server is behind a reverse proxy, you must whitelist the proxy * IP addresses from which CodeIgniter should trust headers such as - * HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify + * X-Forwarded-For or Client-IP in order to properly identify * the visitor's IP address. * - * You can use both an array or a comma-separated list of proxy addresses, - * as well as specifying whole subnets. Here are a few examples: + * You need to set a proxy IP address or IP address with subnets and + * the HTTP header for the client IP address. * - * Comma-separated: '10.0.1.200,192.168.5.0/24' - * Array: ['10.0.1.200', '192.168.5.0/24'] + * Here are some examples: + * [ + * '10.0.1.200' => 'X-Forwarded-For', + * '192.168.5.0/24' => 'X-Real-IP', + * ] * - * @var string|string[] + * @var array */ - public $proxyIPs = ''; + public array $proxyIPs = []; /** * -------------------------------------------------------------------------- diff --git a/ci4/app/Config/CURLRequest.php b/ci4/app/Config/CURLRequest.php new file mode 100644 index 00000000..b3552baa --- /dev/null +++ b/ci4/app/Config/CURLRequest.php @@ -0,0 +1,20 @@ + '', - 'hostname' => 'localhost', - 'username' => '', - 'password' => '', - 'database' => '', - 'DBDriver' => 'MySQLi', - 'DBPrefix' => '', - 'pConnect' => false, - 'DBDebug' => (ENVIRONMENT !== 'production'), - 'charset' => 'utf8', - 'DBCollat' => 'utf8_general_ci', - 'swapPre' => '', - 'encrypt' => false, - 'compress' => false, - 'strictOn' => false, - 'failover' => [], - 'port' => 3306, + public array $default = [ + 'DSN' => '', + 'hostname' => 'localhost', + 'username' => '', + 'password' => '', + 'database' => '', + 'DBDriver' => 'MySQLi', + 'DBPrefix' => '', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + 'numberNative' => false, ]; /** * This database connection is used when * running PHPUnit database tests. - * - * @var array */ - public $tests = [ - 'DSN' => '', - 'hostname' => '127.0.0.1', - 'username' => '', - 'password' => '', - 'database' => ':memory:', - 'DBDriver' => 'SQLite3', - 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS - 'pConnect' => false, - 'DBDebug' => (ENVIRONMENT !== 'production'), - 'charset' => 'utf8', - 'DBCollat' => 'utf8_general_ci', - 'swapPre' => '', - 'encrypt' => false, - 'compress' => false, - 'strictOn' => false, - 'failover' => [], - 'port' => 3306, + public array $tests = [ + 'DSN' => '', + 'hostname' => '127.0.0.1', + 'username' => '', + 'password' => '', + 'database' => ':memory:', + 'DBDriver' => 'SQLite3', + 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + 'foreignKeys' => true, + 'busyTimeout' => 1000, ]; public function __construct() diff --git a/ci4/app/Config/Events.php b/ci4/app/Config/Events.php index 183280eb..4a465ab0 100755 --- a/ci4/app/Config/Events.php +++ b/ci4/app/Config/Events.php @@ -4,6 +4,7 @@ namespace Config; use CodeIgniter\Events\Events; use CodeIgniter\Exceptions\FrameworkException; +use CodeIgniter\HotReloader\HotReloader; /* * -------------------------------------------------------------------- @@ -32,9 +33,7 @@ Events::on('pre_system', static function () { ob_end_flush(); } - ob_start(static function ($buffer) { - return $buffer; - }); + ob_start(static fn ($buffer) => $buffer); } /* @@ -46,5 +45,24 @@ Events::on('pre_system', static function () { if (CI_DEBUG && ! is_cli()) { Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect'); Services::toolbar()->respond(); + // Hot Reload route - for framework use on the hot reloader. + if (ENVIRONMENT === 'development') { + Services::routes()->get('__hot-reload', static function () { + (new HotReloader())->run(); + }); + } } }); + +/* +Events::on('login', static function ($user) { + helper('logger'); + getSystemSettings(); + setLog('information','user-login', $user->id); +}); + +Events::on('logout', static function ($user) { + helper('logger'); + setLog('information','user-logout', $user->id); +}); +*/ \ No newline at end of file diff --git a/ci4/app/Config/Exceptions.php b/ci4/app/Config/Exceptions.php index 7cbc78a8..4173dcdd 100755 --- a/ci4/app/Config/Exceptions.php +++ b/ci4/app/Config/Exceptions.php @@ -3,6 +3,10 @@ namespace Config; use CodeIgniter\Config\BaseConfig; +use CodeIgniter\Debug\ExceptionHandler; +use CodeIgniter\Debug\ExceptionHandlerInterface; +use Psr\Log\LogLevel; +use Throwable; /** * Setup how the exception handler works. @@ -17,10 +21,8 @@ class Exceptions extends BaseConfig * through Services::Log. * * Default: true - * - * @var bool */ - public $log = true; + public bool $log = true; /** * -------------------------------------------------------------------------- @@ -28,10 +30,8 @@ class Exceptions extends BaseConfig * -------------------------------------------------------------------------- * Any status codes here will NOT be logged if logging is turned on. * By default, only 404 (Page Not Found) exceptions are ignored. - * - * @var array */ - public $ignoreCodes = [404]; + public array $ignoreCodes = [404]; /** * -------------------------------------------------------------------------- @@ -41,10 +41,8 @@ class Exceptions extends BaseConfig * directories that hold the views used to generate errors. * * Default: APPPATH.'Views/errors' - * - * @var string */ - public $errorViewPath = APPPATH . 'Views/errors'; + public string $errorViewPath = APPPATH . 'Views/errors'; /** * -------------------------------------------------------------------------- @@ -53,8 +51,54 @@ class Exceptions extends BaseConfig * Any data that you would like to hide from the debug trace. * In order to specify 2 levels, use "/" to separate. * ex. ['server', 'setup/password', 'secret_token'] - * - * @var array */ - public $sensitiveDataInTrace = []; + public array $sensitiveDataInTrace = []; + + /** + * -------------------------------------------------------------------------- + * LOG DEPRECATIONS INSTEAD OF THROWING? + * -------------------------------------------------------------------------- + * By default, CodeIgniter converts deprecations into exceptions. Also, + * starting in PHP 8.1 will cause a lot of deprecated usage warnings. + * Use this option to temporarily cease the warnings and instead log those. + * This option also works for user deprecations. + */ + public bool $logDeprecations = true; + + /** + * -------------------------------------------------------------------------- + * LOG LEVEL THRESHOLD FOR DEPRECATIONS + * -------------------------------------------------------------------------- + * If `$logDeprecations` is set to `true`, this sets the log level + * to which the deprecation will be logged. This should be one of the log + * levels recognized by PSR-3. + * + * The related `Config\Logger::$threshold` should be adjusted, if needed, + * to capture logging the deprecations. + */ + public string $deprecationLogLevel = LogLevel::WARNING; + + /* + * DEFINE THE HANDLERS USED + * -------------------------------------------------------------------------- + * Given the HTTP status code, returns exception handler that + * should be used to deal with this error. By default, it will run CodeIgniter's + * default handler and display the error information in the expected format + * for CLI, HTTP, or AJAX requests, as determined by is_cli() and the expected + * response format. + * + * Custom handlers can be returned if you want to handle one or more specific + * error codes yourself like: + * + * if (in_array($statusCode, [400, 404, 500])) { + * return new \App\Libraries\MyExceptionHandler(); + * } + * if ($exception instanceOf PageNotFoundException) { + * return new \App\Libraries\MyExceptionHandler(); + * } + */ + public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface + { + return new ExceptionHandler($this); + } } diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 2ee527dd..cd7334ff 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -2,6 +2,9 @@ namespace Config; +use CodeIgniter\Router\RouteCollection; + +/* // Create a new instance of our RouteCollection class. $routes = Services::routes(); @@ -11,18 +14,23 @@ if (file_exists(SYSTEMPATH . 'Config/Routes.php')) { require SYSTEMPATH . 'Config/Routes.php'; } - +*/ /* * -------------------------------------------------------------------- * Router Setup * -------------------------------------------------------------------- */ +/* $routes->setDefaultNamespace('App\Controllers'); $routes->setDefaultController('Home'); $routes->setDefaultMethod('index'); $routes->setTranslateURIDashes(false); $routes->set404Override(); $routes->setAutoRoute(true); +*/ + +// Create a new instance of our RouteCollection class. +$routes = Services::routes(); //WEB ROUTER ------------------------------------------------------ //------------------------------------------------------------------ diff --git a/ci4/app/Config/Routing.php b/ci4/app/Config/Routing.php new file mode 100644 index 00000000..c0234da8 --- /dev/null +++ b/ci4/app/Config/Routing.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Config; + +use CodeIgniter\Config\Routing as BaseRouting; + +/** + * Routing configuration + */ +class Routing extends BaseRouting +{ + /** + * An array of files that contain route definitions. + * Route files are read in order, with the first match + * found taking precedence. + * + * Default: APPPATH . 'Config/Routes.php' + */ + public array $routeFiles = [ + APPPATH . 'Config/Routes.php', + ]; + + /** + * The default namespace to use for Controllers when no other + * namespace has been specified. + * + * Default: 'App\Controllers' + */ + public string $defaultNamespace = 'App\Controllers'; + + /** + * The default controller to use when no other controller has been + * specified. + * + * Default: 'Home' + */ + public string $defaultController = 'Home'; + + /** + * The default method to call on the controller when no other + * method has been set in the route. + * + * Default: 'index' + */ + public string $defaultMethod = 'index'; + + /** + * Whether to translate dashes in URIs to underscores. + * Primarily useful when using the auto-routing. + * + * Default: false + */ + public bool $translateURIDashes = false; + + /** + * Sets the class/method that should be called if routing doesn't + * find a match. It can be the controller/method name like: Users::index + * + * This setting is passed to the Router class and handled there. + * + * If you want to use a closure, you will have to set it in the + * routes file by calling: + * + * $routes->set404Override(function() { + * // Do something here + * }); + * + * Example: + * public $override404 = 'App\Errors::show404'; + */ + public ?string $override404 = null; + + /** + * If TRUE, the system will attempt to match the URI against + * Controllers by matching each segment against folders/files + * in APPPATH/Controllers, when a match wasn't found against + * defined routes. + * + * If FALSE, will stop searching and do NO automatic routing. + */ + public bool $autoRoute = false; + + /** + * If TRUE, will enable the use of the 'prioritize' option + * when defining routes. + * + * Default: false + */ + public bool $prioritize = false; + + /** + * Map of URI segments and namespaces. For Auto Routing (Improved). + * + * The key is the first URI segment. The value is the controller namespace. + * E.g., + * [ + * 'blog' => 'Acme\Blog\Controllers', + * ] + * + * @var array [ uri_segment => namespace ] + */ + public array $moduleRoutes = []; +} diff --git a/ci4/app/Config/Security.php b/ci4/app/Config/Security.php index c4cf7a25..d73bbb43 100755 --- a/ci4/app/Config/Security.php +++ b/ci4/app/Config/Security.php @@ -6,38 +6,52 @@ use CodeIgniter\Config\BaseConfig; class Security extends BaseConfig { + /** + * -------------------------------------------------------------------------- + * CSRF Protection Method + * -------------------------------------------------------------------------- + * + * Protection Method for Cross Site Request Forgery protection. + * + * @var string 'cookie' or 'session' + */ + public string $csrfProtection = 'session'; + + /** + * -------------------------------------------------------------------------- + * CSRF Token Randomization + * -------------------------------------------------------------------------- + * + * Randomize the CSRF Token for added security. + */ + public bool $tokenRandomize = false; + /** * -------------------------------------------------------------------------- * CSRF Token Name * -------------------------------------------------------------------------- * - * Token name for Cross Site Request Forgery protection cookie. - * - * @var string + * Token name for Cross Site Request Forgery protection. */ - public $tokenName = 'csrf_test_name'; + public string $tokenName = 'csrf_test_name'; /** * -------------------------------------------------------------------------- * CSRF Header Name * -------------------------------------------------------------------------- * - * Token name for Cross Site Request Forgery protection cookie. - * - * @var string + * Header name for Cross Site Request Forgery protection. */ - public $headerName = 'X-CSRF-TOKEN'; + public string $headerName = 'X-CSRF-TOKEN'; /** * -------------------------------------------------------------------------- * CSRF Cookie Name * -------------------------------------------------------------------------- * - * Cookie name for Cross Site Request Forgery protection cookie. - * - * @var string + * Cookie name for Cross Site Request Forgery protection. */ - public $cookieName = 'csrf_cookie_name'; + public string $cookieName = 'csrf_cookie_name'; /** * -------------------------------------------------------------------------- @@ -47,21 +61,17 @@ class Security extends BaseConfig * Expiration time for Cross Site Request Forgery protection cookie. * * Defaults to two hours (in seconds). - * - * @var int */ - public $expires = 7200; + public int $expires = 7200; /** * -------------------------------------------------------------------------- * CSRF Regenerate * -------------------------------------------------------------------------- * - * Regenerate CSRF Token on every request. - * - * @var bool + * Regenerate CSRF Token on every submission. */ - public $regenerate = true; + public bool $regenerate = true; /** * -------------------------------------------------------------------------- @@ -69,10 +79,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Redirect to previous page with error on failure. - * - * @var bool */ - public $redirect = true; + public bool $redirect = false; /** * -------------------------------------------------------------------------- @@ -87,9 +95,7 @@ class Security extends BaseConfig * * @see https://portswigger.net/web-security/csrf/samesite-cookies * - * @var string - * - * @deprecated + * @deprecated `Config\Cookie` $samesite property is used. */ - public $samesite = 'Lax'; + public string $samesite = 'Lax'; } diff --git a/ci4/app/Config/Session.php b/ci4/app/Config/Session.php new file mode 100644 index 00000000..e077df64 --- /dev/null +++ b/ci4/app/Config/Session.php @@ -0,0 +1,102 @@ + + */ + public string $driver = FileHandler::class; + + /** + * -------------------------------------------------------------------------- + * Session Cookie Name + * -------------------------------------------------------------------------- + * + * The session cookie name, must contain only [0-9a-z_-] characters + */ + public string $cookieName = 'ci_session'; + + /** + * -------------------------------------------------------------------------- + * Session Expiration + * -------------------------------------------------------------------------- + * + * The number of SECONDS you want the session to last. + * Setting to 0 (zero) means expire when the browser is closed. + */ + public int $expiration = 7200; + + /** + * -------------------------------------------------------------------------- + * Session Save Path + * -------------------------------------------------------------------------- + * + * The location to save sessions to and is driver dependent. + * + * For the 'files' driver, it's a path to a writable directory. + * WARNING: Only absolute paths are supported! + * + * For the 'database' driver, it's a table name. + * Please read up the manual for the format with other session drivers. + * + * IMPORTANT: You are REQUIRED to set a valid save path! + */ + public string $savePath = WRITEPATH . 'session'; + + /** + * -------------------------------------------------------------------------- + * Session Match IP + * -------------------------------------------------------------------------- + * + * Whether to match the user's IP address when reading the session data. + * + * WARNING: If you're using the database driver, don't forget to update + * your session table's PRIMARY KEY when changing this setting. + */ + public bool $matchIP = false; + + /** + * -------------------------------------------------------------------------- + * Session Time to Update + * -------------------------------------------------------------------------- + * + * How many seconds between CI regenerating the session ID. + */ + public int $timeToUpdate = 300; + + /** + * -------------------------------------------------------------------------- + * Session Regenerate Destroy + * -------------------------------------------------------------------------- + * + * Whether to destroy session data associated with the old session ID + * when auto-regenerating the session ID. When set to FALSE, the data + * will be later deleted by the garbage collector. + */ + public bool $regenerateDestroy = false; + + /** + * -------------------------------------------------------------------------- + * Session Database Group + * -------------------------------------------------------------------------- + * + * DB Group for the database session. + */ + public ?string $DBGroup = null; +} diff --git a/ci4/app/Config/Toolbar.php b/ci4/app/Config/Toolbar.php index 16a37e83..97fbda28 100755 --- a/ci4/app/Config/Toolbar.php +++ b/ci4/app/Config/Toolbar.php @@ -33,7 +33,7 @@ class Toolbar extends BaseConfig * * @var string[] */ - public $collectors = [ + public array $collectors = [ Timers::class, Database::class, Logs::class, @@ -44,6 +44,16 @@ class Toolbar extends BaseConfig Events::class, ]; + /** + * -------------------------------------------------------------------------- + * Collect Var Data + * -------------------------------------------------------------------------- + * + * If set to false var data from the views will not be colleted. Useful to + * avoid high memory usage when there are lots of data passed to the view. + */ + public bool $collectVarData = true; + /** * -------------------------------------------------------------------------- * Max History @@ -52,10 +62,8 @@ class Toolbar extends BaseConfig * `$maxHistory` sets a limit on the number of past requests that are stored, * helping to conserve file space used to store them. You can set it to * 0 (zero) to not have any history stored, or -1 for unlimited history. - * - * @var int */ - public $maxHistory = 20; + public int $maxHistory = 20; /** * -------------------------------------------------------------------------- @@ -64,10 +72,8 @@ class Toolbar extends BaseConfig * * The full path to the the views that are used by the toolbar. * This MUST have a trailing slash. - * - * @var string */ - public $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/'; + public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/'; /** * -------------------------------------------------------------------------- @@ -80,8 +86,33 @@ class Toolbar extends BaseConfig * with hundreds of queries. * * `$maxQueries` defines the maximum amount of queries that will be stored. - * - * @var int */ - public $maxQueries = 100; + public int $maxQueries = 100; + + /** + * -------------------------------------------------------------------------- + * Watched Directories + * -------------------------------------------------------------------------- + * + * Contains an array of directories that will be watched for changes and + * used to determine if the hot-reload feature should reload the page or not. + * We restrict the values to keep performance as high as possible. + * + * NOTE: The ROOTPATH will be prepended to all values. + */ + public array $watchedDirectories = [ + 'app', + ]; + + /** + * -------------------------------------------------------------------------- + * Watched File Extensions + * -------------------------------------------------------------------------- + * + * Contains an array of file extensions that will be watched for changes and + * used to determine if the hot-reload feature should reload the page or not. + */ + public array $watchedExtensions = [ + 'php', 'css', 'js', 'html', 'svg', 'json', 'env', + ]; } diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php index 9c187b01..6bfa7ab0 100755 --- a/ci4/app/Filters/LoginAuthFilter.php +++ b/ci4/app/Filters/LoginAuthFilter.php @@ -40,7 +40,7 @@ class LoginAuthFilter implements FilterInterface */ public function validateControllerAccess(){ $request = \Config\Services::request(); - $uri = $request->uri; + $uri = $request->getUri(); $language = \Config\Services::language(); $language->setLocale(session()->lang); @@ -161,7 +161,7 @@ class LoginAuthFilter implements FilterInterface public function validateIgnoreControllerAccess(){ $request = \Config\Services::request(); - $uri = $request->uri; + $uri = $request->getUri(); $getList = $this->ignoreListController(); foreach ($getList as $item){ diff --git a/ci4/app/Views/errors/cli/error_exception.php b/ci4/app/Views/errors/cli/error_exception.php index f24e98fb..98d83b0e 100755 --- a/ci4/app/Views/errors/cli/error_exception.php +++ b/ci4/app/Views/errors/cli/error_exception.php @@ -3,17 +3,26 @@ use CodeIgniter\CLI\CLI; // The main Exception -CLI::newLine(); CLI::write('[' . get_class($exception) . ']', 'light_gray', 'red'); -CLI::newLine(); CLI::write($message); -CLI::newLine(); CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green')); CLI::newLine(); +$last = $exception; + +while ($prevException = $last->getPrevious()) { + $last = $prevException; + + CLI::write(' Caused by:'); + CLI::write(' [' . get_class($prevException) . ']', 'red'); + CLI::write(' ' . $prevException->getMessage()); + CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green')); + CLI::newLine(); +} + // The backtrace if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) { - $backtraces = $exception->getTrace(); + $backtraces = $last->getTrace(); if ($backtraces) { CLI::write('Backtrace:', 'green'); diff --git a/ci4/app/Views/errors/html/debug.css b/ci4/app/Views/errors/html/debug.css index 384d66d9..98f54dbc 100755 --- a/ci4/app/Views/errors/html/debug.css +++ b/ci4/app/Views/errors/html/debug.css @@ -1,197 +1,197 @@ :root { - --main-bg-color: #fff; - --main-text-color: #555; - --dark-text-color: #222; - --light-text-color: #c7c7c7; - --brand-primary-color: #E06E3F; - --light-bg-color: #ededee; - --dark-bg-color: #404040; + --main-bg-color: #fff; + --main-text-color: #555; + --dark-text-color: #222; + --light-text-color: #c7c7c7; + --brand-primary-color: #E06E3F; + --light-bg-color: #ededee; + --dark-bg-color: #404040; } body { - height: 100%; - background: var(--main-bg-color); - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; - color: var(--main-text-color); - font-weight: 300; - margin: 0; - padding: 0; + height: 100%; + background: var(--main-bg-color); + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; + color: var(--main-text-color); + font-weight: 300; + margin: 0; + padding: 0; } h1 { - font-weight: lighter; - letter-spacing: 0.8; - font-size: 3rem; - color: var(--dark-text-color); - margin: 0; + font-weight: lighter; + letter-spacing: 0.8; + font-size: 3rem; + color: var(--dark-text-color); + margin: 0; } h1.headline { - margin-top: 20%; - font-size: 5rem; + margin-top: 20%; + font-size: 5rem; } .text-center { - text-align: center; + text-align: center; } p.lead { - font-size: 1.6rem; + font-size: 1.6rem; } .container { - max-width: 75rem; - margin: 0 auto; - padding: 1rem; + max-width: 75rem; + margin: 0 auto; + padding: 1rem; } .header { - background: var(--light-bg-color); - color: var(--dark-text-color); + background: var(--light-bg-color); + color: var(--dark-text-color); } .header .container { - padding: 1rem 1.75rem 1.75rem 1.75rem; + padding: 1rem 1.75rem 1.75rem 1.75rem; } .header h1 { - font-size: 2.5rem; - font-weight: 500; + font-size: 2.5rem; + font-weight: 500; } .header p { - font-size: 1.2rem; - margin: 0; - line-height: 2.5; + font-size: 1.2rem; + margin: 0; + line-height: 2.5; } .header a { - color: var(--brand-primary-color); - margin-left: 2rem; - display: none; - text-decoration: none; + color: var(--brand-primary-color); + margin-left: 2rem; + display: none; + text-decoration: none; } .header:hover a { - display: inline; + display: inline; } .footer { - background: var(--dark-bg-color); - color: var(--light-text-color); + background: var(--dark-bg-color); + color: var(--light-text-color); } .footer .container { - border-top: 1px solid #e7e7e7; - margin-top: 1rem; - text-align: center; + border-top: 1px solid #e7e7e7; + margin-top: 1rem; + text-align: center; } .source { - background: #343434; - color: var(--light-text-color); - padding: 0.5em 1em; - border-radius: 5px; - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - font-size: 0.85rem; - margin: 0; - overflow-x: scroll; + background: #343434; + color: var(--light-text-color); + padding: 0.5em 1em; + border-radius: 5px; + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + font-size: 0.85rem; + margin: 0; + overflow-x: scroll; } .source span.line { - line-height: 1.4; + line-height: 1.4; } .source span.line .number { - color: #666; + color: #666; } .source .line .highlight { - display: block; - background: var(--dark-text-color); - color: var(--light-text-color); + display: block; + background: var(--dark-text-color); + color: var(--light-text-color); } .source span.highlight .number { - color: #fff; + color: #fff; } .tabs { - list-style: none; - list-style-position: inside; - margin: 0; - padding: 0; - margin-bottom: -1px; + list-style: none; + list-style-position: inside; + margin: 0; + padding: 0; + margin-bottom: -1px; } .tabs li { - display: inline; + display: inline; } .tabs a:link, .tabs a:visited { - padding: 0rem 1rem; - line-height: 2.7; - text-decoration: none; - color: var(--dark-text-color); - background: var(--light-bg-color); - border: 1px solid rgba(0,0,0,0.15); - border-bottom: 0; - border-top-left-radius: 5px; - border-top-right-radius: 5px; - display: inline-block; + padding: 0rem 1rem; + line-height: 2.7; + text-decoration: none; + color: var(--dark-text-color); + background: var(--light-bg-color); + border: 1px solid rgba(0,0,0,0.15); + border-bottom: 0; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + display: inline-block; } .tabs a:hover { - background: var(--light-bg-color); - border-color: rgba(0,0,0,0.15); + background: var(--light-bg-color); + border-color: rgba(0,0,0,0.15); } .tabs a.active { - background: var(--main-bg-color); - color: var(--main-text-color); + background: var(--main-bg-color); + color: var(--main-text-color); } .tab-content { - background: var(--main-bg-color); - border: 1px solid rgba(0,0,0,0.15); + background: var(--main-bg-color); + border: 1px solid rgba(0,0,0,0.15); } .content { - padding: 1rem; + padding: 1rem; } .hide { - display: none; + display: none; } .alert { - margin-top: 2rem; - display: block; - text-align: center; - line-height: 3.0; - background: #d9edf7; - border: 1px solid #bcdff1; - border-radius: 5px; - color: #31708f; + margin-top: 2rem; + display: block; + text-align: center; + line-height: 3.0; + background: #d9edf7; + border: 1px solid #bcdff1; + border-radius: 5px; + color: #31708f; } ul, ol { - line-height: 1.8; + line-height: 1.8; } table { - width: 100%; - overflow: hidden; + width: 100%; + overflow: hidden; } th { - text-align: left; - border-bottom: 1px solid #e7e7e7; - padding-bottom: 0.5rem; + text-align: left; + border-bottom: 1px solid #e7e7e7; + padding-bottom: 0.5rem; } td { - padding: 0.2rem 0.5rem 0.2rem 0; + padding: 0.2rem 0.5rem 0.2rem 0; } tr:hover td { - background: #f1f1f1; + background: #f1f1f1; } td pre { - white-space: pre-wrap; + white-space: pre-wrap; } .trace a { - color: inherit; + color: inherit; } .trace table { - width: auto; + width: auto; } .trace tr td:first-child { - min-width: 5em; - font-weight: bold; + min-width: 5em; + font-weight: bold; } .trace td { - background: var(--light-bg-color); - padding: 0 1rem; + background: var(--light-bg-color); + padding: 0 1rem; } .trace td pre { - margin: 0; + margin: 0; } .args { - display: none; + display: none; } diff --git a/ci4/app/Views/errors/html/debug.js b/ci4/app/Views/errors/html/debug.js index 2b4d0638..99199cac 100755 --- a/ci4/app/Views/errors/html/debug.js +++ b/ci4/app/Views/errors/html/debug.js @@ -1,118 +1,116 @@ -// Tabs - var tabLinks = new Array(); var contentDivs = new Array(); function init() { - // Grab the tab links and content divs from the page - var tabListItems = document.getElementById('tabs').childNodes; - console.log(tabListItems); - for (var i = 0; i < tabListItems.length; i ++) - { - if (tabListItems[i].nodeName == "LI") - { - var tabLink = getFirstChildWithTagName(tabListItems[i], 'A'); - var id = getHash(tabLink.getAttribute('href')); - tabLinks[id] = tabLink; - contentDivs[id] = document.getElementById(id); - } - } + // Grab the tab links and content divs from the page + var tabListItems = document.getElementById('tabs').childNodes; + console.log(tabListItems); + for (var i = 0; i < tabListItems.length; i ++) + { + if (tabListItems[i].nodeName == "LI") + { + var tabLink = getFirstChildWithTagName(tabListItems[i], 'A'); + var id = getHash(tabLink.getAttribute('href')); + tabLinks[id] = tabLink; + contentDivs[id] = document.getElementById(id); + } + } - // Assign onclick events to the tab links, and - // highlight the first tab - var i = 0; + // Assign onclick events to the tab links, and + // highlight the first tab + var i = 0; - for (var id in tabLinks) - { - tabLinks[id].onclick = showTab; - tabLinks[id].onfocus = function () { - this.blur() - }; - if (i == 0) - { - tabLinks[id].className = 'active'; - } - i ++; - } + for (var id in tabLinks) + { + tabLinks[id].onclick = showTab; + tabLinks[id].onfocus = function () { + this.blur() + }; + if (i == 0) + { + tabLinks[id].className = 'active'; + } + i ++; + } - // Hide all content divs except the first - var i = 0; + // Hide all content divs except the first + var i = 0; - for (var id in contentDivs) - { - if (i != 0) - { - console.log(contentDivs[id]); - contentDivs[id].className = 'content hide'; - } - i ++; - } + for (var id in contentDivs) + { + if (i != 0) + { + console.log(contentDivs[id]); + contentDivs[id].className = 'content hide'; + } + i ++; + } } function showTab() { - var selectedId = getHash(this.getAttribute('href')); + var selectedId = getHash(this.getAttribute('href')); - // Highlight the selected tab, and dim all others. - // Also show the selected content div, and hide all others. - for (var id in contentDivs) - { - if (id == selectedId) - { - tabLinks[id].className = 'active'; - contentDivs[id].className = 'content'; - } - else - { - tabLinks[id].className = ''; - contentDivs[id].className = 'content hide'; - } - } + // Highlight the selected tab, and dim all others. + // Also show the selected content div, and hide all others. + for (var id in contentDivs) + { + if (id == selectedId) + { + tabLinks[id].className = 'active'; + contentDivs[id].className = 'content'; + } + else + { + tabLinks[id].className = ''; + contentDivs[id].className = 'content hide'; + } + } - // Stop the browser following the link - return false; + // Stop the browser following the link + return false; } function getFirstChildWithTagName(element, tagName) { - for (var i = 0; i < element.childNodes.length; i ++) - { - if (element.childNodes[i].nodeName == tagName) - { - return element.childNodes[i]; - } - } + for (var i = 0; i < element.childNodes.length; i ++) + { + if (element.childNodes[i].nodeName == tagName) + { + return element.childNodes[i]; + } + } } function getHash(url) { - var hashPos = url.lastIndexOf('#'); - return url.substring(hashPos + 1); + var hashPos = url.lastIndexOf('#'); + return url.substring(hashPos + 1); } function toggle(elem) { - elem = document.getElementById(elem); + elem = document.getElementById(elem); - if (elem.style && elem.style['display']) - { - // Only works with the "style" attr - var disp = elem.style['display']; - } - else if (elem.currentStyle) - { - // For MSIE, naturally - var disp = elem.currentStyle['display']; - } - else if (window.getComputedStyle) - { - // For most other browsers - var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display'); - } + if (elem.style && elem.style['display']) + { + // Only works with the "style" attr + var disp = elem.style['display']; + } + else if (elem.currentStyle) + { + // For MSIE, naturally + var disp = elem.currentStyle['display']; + } + else if (window.getComputedStyle) + { + // For most other browsers + var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display'); + } - // Toggle the state of the "display" style - elem.style.display = disp == 'block' ? 'none' : 'block'; + // Toggle the state of the "display" style + elem.style.display = disp == 'block' ? 'none' : 'block'; - return false; + return false; } diff --git a/ci4/app/Views/errors/html/error_404.php b/ci4/app/Views/errors/html/error_404.php index 1cca20c4..e506f083 100755 --- a/ci4/app/Views/errors/html/error_404.php +++ b/ci4/app/Views/errors/html/error_404.php @@ -1,84 +1,84 @@ - - 404 Page Not Found + + <?= lang('Errors.pageNotFound') ?> - + -
-

404 - File Not Found

+
+

404

-

- - - - Sorry! Cannot seem to find the page you were looking for. - -

-
+

+ + + + + +

+
diff --git a/ci4/app/Views/errors/html/error_exception.php b/ci4/app/Views/errors/html/error_exception.php index 4477ee08..406b48ec 100755 --- a/ci4/app/Views/errors/html/error_exception.php +++ b/ci4/app/Views/errors/html/error_exception.php @@ -1,397 +1,418 @@ - + - - + + - <?= esc($title) ?> - + <?= esc($title) ?> + - + - -
-
-

getCode() ? ' #' . $exception->getCode() : '') ?>

-

- getMessage())) ?> - getMessage())) ?>" - rel="noreferrer" target="_blank">search → -

-
-
+ +
+
+

getCode() ? ' #' . $exception->getCode() : '') ?>

+

+ getMessage())) ?> + getMessage())) ?>" + rel="noreferrer" target="_blank">search → +

+
+
- -
-

at line

+ +
+

at line

- -
- -
- -
+ +
+ +
+ +
-
+
+ -
  • Backtrace
  • -
  • Server
  • -
  • Request
  • -
  • Response
  • -
  • Files
  • -
  • Memory
  • - + while ($prevException = $last->getPrevious()) { + $last = $prevException; + ?> -
    +
    +    Caused by:
    +    getCode() ? ' #' . $prevException->getCode() : '') ?>
     
    -			
    -			
    + getMessage())) ?> + getMessage())) ?>" + rel="noreferrer" target="_blank">search → + getFile()) . ':' . $prevException->getLine()) ?> +
    -
      - $row) : ?> + +
    -
  • -

    - - - +

    + + + +
    + + +
    + +
      + $row) : ?> + +
    1. +

      + + + - - {PHP internal code} - + + {PHP internal code} + - - -   —   - - - ( arguments ) -

      - + + +   —   + + + ( arguments ) +
      +
      - getParameters(); } foreach ($row['args'] as $key => $value) : ?> - - - - - + + + + + -
      name : "#{$key}") ?>
      name : "#{$key}") ?>
      -
      - - () - - + +
    + + () + + - -   —   () - -

    + +   —   () + +

    - - -
    - -
    - -
  • + + +
    + +
    + + - - + + -
    +
    - -
    - - +
    + + -

    $

    +

    $

    - - - - - - - - - $value) : ?> - - - - - - -
    KeyValue
    - - - -
    - -
    + + + + + + + + + $value) : ?> + + + + + + +
    KeyValue
    + + + +
    + +
    - + - - - -

    Constants

    + + + +

    Constants

    - - - - - - - - - $value) : ?> - - - - - - -
    KeyValue
    - - - -
    - -
    - -
    + + + + + + + + + $value) : ?> + + + + + + +
    KeyValue
    + + + +
    + +
    + +
    - -
    - + +
    + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
    Pathuri) ?>
    HTTP MethodgetMethod(true)) ?>
    IP AddressgetIPAddress()) ?>
    Is AJAX Request?isAJAX() ? 'yes' : 'no' ?>
    Is CLI Request?isCLI() ? 'yes' : 'no' ?>
    Is Secure Request?isSecure() ? 'yes' : 'no' ?>
    User AgentgetUserAgent()->getAgentString()) ?>
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - -
    PathgetUri()) ?>
    HTTP MethodgetMethod())) ?>
    IP AddressgetIPAddress()) ?>
    Is AJAX Request?isAJAX() ? 'yes' : 'no' ?>
    Is CLI Request?isCLI() ? 'yes' : 'no' ?>
    Is Secure Request?isSecure() ? 'yes' : 'no' ?>
    User AgentgetUserAgent()->getAgentString()) ?>
    + + - - - + + - + -

    $

    +

    $

    - - - - - - - - - $value) : ?> - - - - - - -
    KeyValue
    - - - -
    - -
    + + + + + + + + + $value) : ?> + + + + + + +
    KeyValue
    + + + +
    + +
    - + - + -
    - No $_GET, $_POST, or $_COOKIE Information to show. -
    +
    + No $_GET, $_POST, or $_COOKIE Information to show. +
    - + - getHeaders(); ?> - + headers(); ?> + -

    Headers

    +

    Headers

    - - - - - - - - - - + + + + + + + + + + + + + + +
    HeaderValue
    HeaderValue
    getName(), 'html') ?>getValueLine(), 'html') ?>
    - if (! is_array($value)) { - $value = [$value]; - } ?> - - - getName(), 'html') ?> - getValueLine(), 'html') ?> - - - - - + +
    - -
    - - - + setStatusCode(http_response_code()); ?> -
    - - - - - -
    Response StatusgetStatusCode() . ' - ' . $response->getReason()) ?>
    +
    + + + + + +
    Response StatusgetStatusCode() . ' - ' . $response->getReasonPhrase()) ?>
    - getHeaders(); ?> - - + headers(); ?> + + -

    Headers

    +

    Headers

    - - - - - - - - - $value) : ?> - - - - - - -
    HeaderValue
    getHeaderLine($name), 'html') ?>
    + + + + + + + + + + + + + + + +
    HeaderValue
    getHeaderLine($name), 'html') ?>
    - -
    + +
    - -
    - + +
    + -
      - -
    1. - -
    -
    +
      + +
    1. + +
    +
    - -
    + +
    - - - - - - - - - - - - - - - -
    Memory Usage
    Peak Memory Usage:
    Memory Limit:
    + + + + + + + + + + + + + + + +
    Memory Usage
    Peak Memory Usage:
    Memory Limit:
    -
    +
    - + - + + - diff --git a/ci4/app/Views/errors/html/production.php b/ci4/app/Views/errors/html/production.php index cca49c2e..2f59a8de 100755 --- a/ci4/app/Views/errors/html/production.php +++ b/ci4/app/Views/errors/html/production.php @@ -1,24 +1,24 @@ - - + + - Whoops! + <?= lang('Errors.whoops') ?> - + -
    +
    -

    Whoops!

    +

    -

    We seem to have hit a snag. Please try again later...

    +

    -
    +
    diff --git a/ci4/composer.json b/ci4/composer.json index c2b4eef4..2ec57917 100755 --- a/ci4/composer.json +++ b/ci4/composer.json @@ -6,12 +6,9 @@ "license": "MIT", "require": { "php": "^7.3 || ^8.0", + "codeigniter4/shield": "^1.0", "codeigniter4/framework": "^4", "phpoffice/phpspreadsheet": "^1.18", - "google/apiclient": "^2.11.0", - "firebase/php-jwt": "^5.4", - "aws/aws-sdk-php": "^3.206", - "spatie/db-dumper": "^2.21", "dompdf/dompdf": "^2.0" }, "require-dev": { diff --git a/ci4/spark.old b/ci4/spark.old new file mode 100644 index 00000000..f2ba3f30 --- /dev/null +++ b/ci4/spark.old @@ -0,0 +1,99 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +/* + * -------------------------------------------------------------------- + * CodeIgniter command-line tools + * -------------------------------------------------------------------- + * The main entry point into the CLI system and allows you to run + * commands and perform maintenance on your application. + * + * Because CodeIgniter can handle CLI requests as just another web request + * this class mainly acts as a passthru to the framework itself. + */ + +// Refuse to run when called from php-cgi +if (strpos(PHP_SAPI, 'cgi') === 0) { + exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n"); +} + +// Check PHP version. +$minPhpVersion = '7.4'; // If you update this, don't forget to update `public/index.php`. +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 + ); + + exit($message); +} + +// We want errors to be shown when using it from the CLI. +error_reporting(-1); +ini_set('display_errors', '1'); + +/** + * @var bool + * + * @deprecated No longer in use. `CodeIgniter` has `$context` property. + */ +define('SPARKED', true); + +// Path to the front controller +define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); + +// Ensure the current directory is pointing to the front controller's directory +chdir(FCPATH); + +/* + *--------------------------------------------------------------- + * 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 Config\Paths(); + +// Location of the framework bootstrap file. +require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php'; + +// Load environment settings from .env files into $_SERVER and $_ENV +require_once SYSTEMPATH . 'Config/DotEnv.php'; +(new CodeIgniter\Config\DotEnv(ROOTPATH))->load(); + +// Grab our CodeIgniter +$app = Config\Services::codeigniter(); +$app->initialize(); + +// Grab our Console +$console = new CodeIgniter\CLI\Console(); + +// Show basic information before we do anything else. +if (is_int($suppress = array_search('--no-header', $_SERVER['argv'], true))) { + unset($_SERVER['argv'][$suppress]); // @codeCoverageIgnore + $suppress = true; +} + +$console->showHeader($suppress); + +// fire off the command in the main framework. +$exit = $console->run(); + +exit(is_int($exit) ? $exit : EXIT_SUCCESS); diff --git a/httpdocs/index.php b/httpdocs/index.php index c3f801ac..86b2370d 100755 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -1,15 +1,39 @@ Current version: " . phpversion()); + +/* + *--------------------------------------------------------------- + * CHECK PHP VERSION + *--------------------------------------------------------------- + */ + +$minPhpVersion = '8.1'; // 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); } -unset($minPHPVersion); + +/* + *--------------------------------------------------------------- + * 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); +} + /* *--------------------------------------------------------------- * BOOTSTRAP THE APPLICATION @@ -19,60 +43,14 @@ define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR); * and fires up an environment-specific bootstrapping. */ -// Ensure the current directory is pointing to the front controller's directory -chdir(FCPATH); - -// Load our paths config file +// LOAD OUR PATHS CONFIG FILE // This is the line that might need to be changed, depending on your folder structure. -$pathsConfig = FCPATH . '../ci4/app/Config/Paths.php'; -// ^^^ Change this if you move your application folder -require realpath($pathsConfig) ?: $pathsConfig; +require FCPATH . '../ci4/app/Config/Paths.php'; +// ^^^ Change this line if you move your application folder $paths = new Config\Paths(); -//Check Installation -$rootFolder = realpath(rtrim($paths->appDirectory, '/ ') . '/../'); -$env = file_exists($rootFolder . '/.env'); -if($env == false) { - $domain = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; - $domain = preg_replace('/index.php.*/', '', $domain); //remove everything after index.php - if (!empty($_SERVER['HTTPS'])) { - $domain = 'https://' . $domain; - } else { - $domain = 'http://' . $domain; - } - header("Location: $domain./install"); - exit; -} +// LOAD THE FRAMEWORK BOOTSTRAP FILE +require $paths->systemDirectory . '/Boot.php'; -// Location of the framework bootstrap file. -require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php'; - -// Load environment settings from .env files into $_SERVER and $_ENV -require_once SYSTEMPATH . 'Config/DotEnv.php'; -(new CodeIgniter\Config\DotEnv(ROOTPATH))->load(); - -/* - * --------------------------------------------------------------- - * GRAB OUR CODEIGNITER INSTANCE - * --------------------------------------------------------------- - * - * The CodeIgniter class contains the core functionality to make - * the application run, and does all of the dirty work to get - * the pieces all working together. - */ - -$app = Config\Services::codeigniter(); -$app->initialize(); -$context = is_cli() ? 'php-cli' : 'web'; -$app->setContext($context); - -/* - *--------------------------------------------------------------- - * LAUNCH THE APPLICATION - *--------------------------------------------------------------- - * Now that everything is setup, it's time to actually fire - * up the engines and make this app do its thang. - */ - -$app->run(); \ No newline at end of file +exit(CodeIgniter\Boot::bootWeb($paths)); diff --git a/httpdocs/index.php.old b/httpdocs/index.php.old new file mode 100644 index 00000000..c3f801ac --- /dev/null +++ b/httpdocs/index.php.old @@ -0,0 +1,78 @@ +Current version: " . phpversion()); +} +unset($minPHPVersion); + +// Path to the front controller (this file) +define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR); + +/* + *--------------------------------------------------------------- + * 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. + */ + +// Ensure the current directory is pointing to the front controller's directory +chdir(FCPATH); + +// Load our paths config file +// This is the line that might need to be changed, depending on your folder structure. +$pathsConfig = FCPATH . '../ci4/app/Config/Paths.php'; +// ^^^ Change this if you move your application folder +require realpath($pathsConfig) ?: $pathsConfig; + +$paths = new Config\Paths(); + +//Check Installation +$rootFolder = realpath(rtrim($paths->appDirectory, '/ ') . '/../'); +$env = file_exists($rootFolder . '/.env'); +if($env == false) { + $domain = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; + $domain = preg_replace('/index.php.*/', '', $domain); //remove everything after index.php + if (!empty($_SERVER['HTTPS'])) { + $domain = 'https://' . $domain; + } else { + $domain = 'http://' . $domain; + } + header("Location: $domain./install"); + exit; +} + +// Location of the framework bootstrap file. +require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php'; + +// Load environment settings from .env files into $_SERVER and $_ENV +require_once SYSTEMPATH . 'Config/DotEnv.php'; +(new CodeIgniter\Config\DotEnv(ROOTPATH))->load(); + +/* + * --------------------------------------------------------------- + * GRAB OUR CODEIGNITER INSTANCE + * --------------------------------------------------------------- + * + * The CodeIgniter class contains the core functionality to make + * the application run, and does all of the dirty work to get + * the pieces all working together. + */ + +$app = Config\Services::codeigniter(); +$app->initialize(); +$context = is_cli() ? 'php-cli' : 'web'; +$app->setContext($context); + +/* + *--------------------------------------------------------------- + * LAUNCH THE APPLICATION + *--------------------------------------------------------------- + * Now that everything is setup, it's time to actually fire + * up the engines and make this app do its thang. + */ + +$app->run(); \ No newline at end of file