From da33778c3ab694d9de3de7789907b9e344f73cf7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 14 May 2024 17:16:35 +0900 Subject: [PATCH] Patch framework (v4.4.7 => v4.5.1) Conflicts: Config/Boot/production.php Views/welcome_message.php app/Config/Autoload.php app/Config/Cache.php app/Config/Cors.php app/Config/Optimize.php --- app/Config/Autoload.php | 9 +- app/Config/Boot/production.php | 7 +- app/Config/Cache.php | 38 +++---- app/Config/Cors.php | 105 +++++++++++++++++ app/Config/Database.php | 130 ++++++++++++++++++++-- app/Config/Feature.php | 25 ++--- app/Config/Filters.php | 46 +++++++- app/Config/Generators.php | 8 +- app/Config/Kint.php | 3 +- app/Config/Optimize.php | 32 ++++++ app/Config/Routing.php | 30 ++++- app/Config/Security.php | 4 +- app/Config/Session.php | 25 +++++ app/Views/errors/cli/error_exception.php | 23 ++-- app/Views/errors/html/error_exception.php | 41 +++++-- env | 80 +------------ public/.htaccess | 2 +- public/index.php | 73 ++++-------- spark | 64 ++++------- 19 files changed, 485 insertions(+), 260 deletions(-) create mode 100644 app/Config/Cors.php create mode 100644 app/Config/Optimize.php diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index 647b5ee9..298bd7e9 100644 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -30,8 +30,10 @@ class Autoload extends AutoloadConfig * their location on the file system. These are used by the autoloader * to locate files the first time they have been instantiated. * - * The '/app' and '/system' directories are already mapped for you. - * you may change the name of the 'App' namespace if you wish, + * The 'Config' (APPPATH . 'Config') and 'CodeIgniter' (SYSTEMPATH) are + * already mapped for you. + * + * You may change the name of the 'App' namespace if you wish, * but this should be done prior to creating any namespaced classes, * else you will need to modify all of those classes for this to work. * @@ -44,8 +46,7 @@ class Autoload extends AutoloadConfig * @var array|string> */ public $psr4 = [ - APP_NAMESPACE => APPPATH, // For custom app namespace - 'Config' => APPPATH . 'Config', + APP_NAMESPACE => APPPATH, ]; /** diff --git a/app/Config/Boot/production.php b/app/Config/Boot/production.php index 1241907c..21609f98 100644 --- a/app/Config/Boot/production.php +++ b/app/Config/Boot/production.php @@ -6,9 +6,13 @@ |-------------------------------------------------------------------------- | Don't show ANY in production environments. Instead, let the system catch | it and display a generic error message. + | + | If you set 'display_errors' to '1', CI4's detailed error report will show. */ +error_reporting(E_ALL & ~E_DEPRECATED); +// If you want to suppress more types of errors. +// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); ini_set('display_errors', '0'); -error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); /* |-------------------------------------------------------------------------- @@ -18,5 +22,4 @@ | the system. It's not widely used currently, and may not survive | release of the framework. */ - defined('CI_DEBUG') || define('CI_DEBUG', false); diff --git a/app/Config/Cache.php b/app/Config/Cache.php index 665be3c8..d3738215 100644 --- a/app/Config/Cache.php +++ b/app/Config/Cache.php @@ -46,25 +46,6 @@ class Cache extends BaseConfig */ public string $storePath = WRITEPATH . 'cache/'; - /** - * -------------------------------------------------------------------------- - * Cache Include Query String - * -------------------------------------------------------------------------- - * - * Whether to take the URL query string into consideration when generating - * output cache files. Valid options are: - * - * false = Disabled - * true = Enabled, take all query parameters into account. - * Please be aware that this may result in numerous cache - * files generated for the same page over and over again. - * array('q') = Enabled, but only take into account the specified list - * of query parameters. - * - * @var bool|list - */ - public $cacheQueryString = false; - /** * -------------------------------------------------------------------------- * Key Prefix @@ -167,4 +148,23 @@ class Cache extends BaseConfig 'redis' => RedisHandler::class, 'wincache' => WincacheHandler::class, ]; + + /** + * -------------------------------------------------------------------------- + * Web Page Caching: Cache Include Query String + * -------------------------------------------------------------------------- + * + * Whether to take the URL query string into consideration when generating + * output cache files. Valid options are: + * + * false = Disabled + * true = Enabled, take all query parameters into account. + * Please be aware that this may result in numerous cache + * files generated for the same page over and over again. + * ['q'] = Enabled, but only take into account the specified list + * of query parameters. + * + * @var bool|list + */ + public $cacheQueryString = false; } diff --git a/app/Config/Cors.php b/app/Config/Cors.php new file mode 100644 index 00000000..2b4edf6b --- /dev/null +++ b/app/Config/Cors.php @@ -0,0 +1,105 @@ +, + * allowedOriginsPatterns: list, + * supportsCredentials: bool, + * allowedHeaders: list, + * exposedHeaders: list, + * allowedMethods: list, + * maxAge: int, + * } + */ + public array $default = [ + /** + * Origins for the `Access-Control-Allow-Origin` header. + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin + * + * E.g.: + * - ['http://localhost:8080'] + * - ['https://www.example.com'] + */ + 'allowedOrigins' => [], + + /** + * Origin regex patterns for the `Access-Control-Allow-Origin` header. + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin + * + * NOTE: A pattern specified here is part of a regular expression. It will + * be actually `#\A\z#`. + * + * E.g.: + * - ['https://\w+\.example\.com'] + */ + 'allowedOriginsPatterns' => [], + + /** + * Weather to send the `Access-Control-Allow-Credentials` header. + * + * The Access-Control-Allow-Credentials response header tells browsers whether + * the server allows cross-origin HTTP requests to include credentials. + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials + */ + 'supportsCredentials' => false, + + /** + * Set headers to allow. + * + * The Access-Control-Allow-Headers response header is used in response to + * a preflight request which includes the Access-Control-Request-Headers to + * indicate which HTTP headers can be used during the actual request. + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers + */ + 'allowedHeaders' => [], + + /** + * Set headers to expose. + * + * The Access-Control-Expose-Headers response header allows a server to + * indicate which response headers should be made available to scripts running + * in the browser, in response to a cross-origin request. + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers + */ + 'exposedHeaders' => [], + + /** + * Set methods to allow. + * + * The Access-Control-Allow-Methods response header specifies one or more + * methods allowed when accessing a resource in response to a preflight + * request. + * + * E.g.: + * - ['GET', 'POST', 'PUT', 'DELETE'] + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods + */ + 'allowedMethods' => [], + + /** + * Set how many seconds the results of a preflight request can be cached. + * + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age + */ + 'maxAge' => 7200, + ]; +} diff --git a/app/Config/Database.php b/app/Config/Database.php index 8c823602..7a1fd21e 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -10,14 +10,12 @@ class Database extends Config { /** - * The directory that holds the Migrations - * and Seeds directories. + * The directory that holds the Migrations and Seeds directories. */ public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR; /** - * Lets you choose which connection group to - * use if no other is specified. + * Lets you choose which connection group to use if no other is specified. */ public string $defaultGroup = 'default'; @@ -36,8 +34,8 @@ class Database extends Config 'DBPrefix' => '', 'pConnect' => false, 'DBDebug' => true, - 'charset' => 'utf8', - 'DBCollat' => 'utf8_general_ci', + 'charset' => 'utf8mb4', + 'DBCollat' => 'utf8mb4_general_ci', 'swapPre' => '', 'encrypt' => false, 'compress' => false, @@ -45,11 +43,120 @@ class Database extends Config 'failover' => [], 'port' => 3306, 'numberNative' => false, + 'dateFormat' => [ + 'date' => 'Y-m-d', + 'datetime' => 'Y-m-d H:i:s', + 'time' => 'H:i:s', + ], ]; + // /** + // * Sample database connection for SQLite3. + // * + // * @var array + // */ + // public array $default = [ + // 'database' => 'database.db', + // 'DBDriver' => 'SQLite3', + // 'DBPrefix' => '', + // 'DBDebug' => true, + // 'swapPre' => '', + // 'failover' => [], + // 'foreignKeys' => true, + // 'busyTimeout' => 1000, + // 'dateFormat' => [ + // 'date' => 'Y-m-d', + // 'datetime' => 'Y-m-d H:i:s', + // 'time' => 'H:i:s', + // ], + // ]; + + // /** + // * Sample database connection for Postgre. + // * + // * @var array + // */ + // public array $default = [ + // 'DSN' => '', + // 'hostname' => 'localhost', + // 'username' => 'root', + // 'password' => 'root', + // 'database' => 'ci4', + // 'schema' => 'public', + // 'DBDriver' => 'Postgre', + // 'DBPrefix' => '', + // 'pConnect' => false, + // 'DBDebug' => true, + // 'charset' => 'utf8', + // 'swapPre' => '', + // 'failover' => [], + // 'port' => 5432, + // 'dateFormat' => [ + // 'date' => 'Y-m-d', + // 'datetime' => 'Y-m-d H:i:s', + // 'time' => 'H:i:s', + // ], + // ]; + + // /** + // * Sample database connection for SQLSRV. + // * + // * @var array + // */ + // public array $default = [ + // 'DSN' => '', + // 'hostname' => 'localhost', + // 'username' => 'root', + // 'password' => 'root', + // 'database' => 'ci4', + // 'schema' => 'dbo', + // 'DBDriver' => 'SQLSRV', + // 'DBPrefix' => '', + // 'pConnect' => false, + // 'DBDebug' => true, + // 'charset' => 'utf8', + // 'swapPre' => '', + // 'encrypt' => false, + // 'failover' => [], + // 'port' => 1433, + // 'dateFormat' => [ + // 'date' => 'Y-m-d', + // 'datetime' => 'Y-m-d H:i:s', + // 'time' => 'H:i:s', + // ], + // ]; + + // /** + // * Sample database connection for OCI8. + // * + // * You may need the following environment variables: + // * NLS_LANG = 'AMERICAN_AMERICA.UTF8' + // * NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS' + // * NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS' + // * NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS' + // * + // * @var array + // */ + // public array $default = [ + // 'DSN' => 'localhost:1521/XEPDB1', + // 'username' => 'root', + // 'password' => 'root', + // 'DBDriver' => 'OCI8', + // 'DBPrefix' => '', + // 'pConnect' => false, + // 'DBDebug' => true, + // 'charset' => 'AL32UTF8', + // 'swapPre' => '', + // 'failover' => [], + // 'dateFormat' => [ + // 'date' => 'Y-m-d', + // 'datetime' => 'Y-m-d H:i:s', + // 'time' => 'H:i:s', + // ], + // ]; + /** - * This database connection is used when - * running PHPUnit database tests. + * This database connection is used when running PHPUnit database tests. * * @var array */ @@ -64,7 +171,7 @@ class Database extends Config 'pConnect' => false, 'DBDebug' => true, 'charset' => 'utf8', - 'DBCollat' => 'utf8_general_ci', + 'DBCollat' => '', 'swapPre' => '', 'encrypt' => false, 'compress' => false, @@ -73,6 +180,11 @@ class Database extends Config 'port' => 3306, 'foreignKeys' => true, 'busyTimeout' => 1000, + 'dateFormat' => [ + 'date' => 'Y-m-d', + 'datetime' => 'Y-m-d H:i:s', + 'time' => 'H:i:s', + ], ]; public function __construct() diff --git a/app/Config/Feature.php b/app/Config/Feature.php index 0bc45c6f..efd4a0b2 100644 --- a/app/Config/Feature.php +++ b/app/Config/Feature.php @@ -10,21 +10,20 @@ class Feature extends BaseConfig { /** - * Enable multiple filters for a route or not. - * - * If you enable this: - * - CodeIgniter\CodeIgniter::handleRequest() uses: - * - CodeIgniter\Filters\Filters::enableFilters(), instead of enableFilter() - * - CodeIgniter\CodeIgniter::tryToRouteIt() uses: - * - CodeIgniter\Router\Router::getFilters(), instead of getFilter() - * - CodeIgniter\Router\Router::handle() uses: - * - property $filtersInfo, instead of $filterInfo - * - CodeIgniter\Router\RouteCollection::getFiltersForRoute(), instead of getFilterForRoute() + * Use improved new auto routing instead of the default legacy version. */ - public bool $multipleFilters = false; + public bool $autoRoutesImproved = false; /** - * Use improved new auto routing instead of the default legacy version. + * Use filter execution order in 4.4 or before. */ - public bool $autoRoutesImproved = false; + public bool $oldFilterOrder = false; + + /** + * The behavior of `limit(0)` in Query Builder. + * + * If true, `limit(0)` returns all records. (the behavior of 4.4.x or before in version 4.x.) + * If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.) + */ + public bool $limitZeroAsAll = true; } diff --git a/app/Config/Filters.php b/app/Config/Filters.php index 57aaed2e..eb46a1d7 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -2,21 +2,27 @@ namespace Config; -use CodeIgniter\Config\BaseConfig; +use CodeIgniter\Config\Filters as BaseFilters; +use CodeIgniter\Filters\Cors; use CodeIgniter\Filters\CSRF; use CodeIgniter\Filters\DebugToolbar; +use CodeIgniter\Filters\ForceHTTPS; use CodeIgniter\Filters\Honeypot; use CodeIgniter\Filters\InvalidChars; +use CodeIgniter\Filters\PageCache; +use CodeIgniter\Filters\PerformanceMetrics; use CodeIgniter\Filters\SecureHeaders; -class Filters extends BaseConfig +class Filters extends BaseFilters { /** * Configures aliases for Filter classes to * make reading things nicer and simpler. * - * @var array> [filter_name => classname] - * or [filter_name => [classname1, classname2, ...]] + * @var array> + * + * [filter_name => classname] + * or [filter_name => [classname1, classname2, ...]] */ public array $aliases = [ 'csrf' => CSRF::class, @@ -24,6 +30,35 @@ class Filters extends BaseConfig 'honeypot' => Honeypot::class, 'invalidchars' => InvalidChars::class, 'secureheaders' => SecureHeaders::class, + 'cors' => Cors::class, + 'forcehttps' => ForceHTTPS::class, + 'pagecache' => PageCache::class, + 'performance' => PerformanceMetrics::class, + ]; + + /** + * List of special required filters. + * + * The filters listed here are special. They are applied before and after + * other kinds of filters, and always applied even if a route does not exist. + * + * Filters set by default provide framework functionality. If removed, + * those functions will no longer work. + * + * @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters + * + * @var array{before: list, after: list} + */ + public array $required = [ + 'before' => [ + 'forcehttps', // Force Global Secure Requests + 'pagecache', // Web Page Caching + ], + 'after' => [ + 'pagecache', // Web Page Caching + 'performance', // Performance Metrics + 'toolbar', // Debug Toolbar + ], ]; /** @@ -39,7 +74,6 @@ class Filters extends BaseConfig // 'invalidchars', ], 'after' => [ - 'toolbar', // 'honeypot', // 'secureheaders', ], @@ -50,7 +84,7 @@ class Filters extends BaseConfig * particular HTTP method (GET, POST, etc.). * * Example: - * 'post' => ['foo', 'bar'] + * 'POST' => ['foo', 'bar'] * * If you use this, you should disable auto-routing because auto-routing * permits any HTTP method to access a controller. Accessing the controller diff --git a/app/Config/Generators.php b/app/Config/Generators.php index 6566a31e..cc92c7aa 100644 --- a/app/Config/Generators.php +++ b/app/Config/Generators.php @@ -23,11 +23,13 @@ class Generators extends BaseConfig * * YOU HAVE BEEN WARNED! * - * @var array + * @var array|string> */ public array $views = [ - 'make:cell' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php', - 'make:cell_view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php', + 'make:cell' => [ + 'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php', + 'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php', + ], 'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php', 'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php', 'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php', diff --git a/app/Config/Kint.php b/app/Config/Kint.php index 117e66d8..d0707827 100644 --- a/app/Config/Kint.php +++ b/app/Config/Kint.php @@ -2,7 +2,6 @@ namespace Config; -use CodeIgniter\Config\BaseConfig; use Kint\Parser\ConstructablePluginInterface; use Kint\Renderer\AbstractRenderer; use Kint\Renderer\Rich\TabPluginInterface; @@ -18,7 +17,7 @@ * * @see https://kint-php.github.io/kint/ for details on these settings. */ -class Kint extends BaseConfig +class Kint { /* |-------------------------------------------------------------------------- diff --git a/app/Config/Optimize.php b/app/Config/Optimize.php new file mode 100644 index 00000000..6fb441fd --- /dev/null +++ b/app/Config/Optimize.php @@ -0,0 +1,32 @@ + */ public array $moduleRoutes = []; + + /** + * For Auto Routing (Improved). + * Whether to translate dashes in URIs for controller/method to CamelCase. + * E.g., blog-controller -> BlogController + * + * If you enable this, $translateURIDashes is ignored. + * + * Default: false + */ + public bool $translateUriToCamelCase = false; } diff --git a/app/Config/Security.php b/app/Config/Security.php index 57be4ee4..0858b9bb 100644 --- a/app/Config/Security.php +++ b/app/Config/Security.php @@ -79,8 +79,10 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Redirect to previous page with error on failure. + * + * @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure */ - public bool $redirect = false; + public bool $redirect = (ENVIRONMENT === 'production'); /** * -------------------------------------------------------------------------- diff --git a/app/Config/Session.php b/app/Config/Session.php index e077df64..6944710f 100644 --- a/app/Config/Session.php +++ b/app/Config/Session.php @@ -99,4 +99,29 @@ class Session extends BaseConfig * DB Group for the database session. */ public ?string $DBGroup = null; + + /** + * -------------------------------------------------------------------------- + * Lock Retry Interval (microseconds) + * -------------------------------------------------------------------------- + * + * This is used for RedisHandler. + * + * Time (microseconds) to wait if lock cannot be acquired. + * The default is 100,000 microseconds (= 0.1 seconds). + */ + public int $lockRetryInterval = 100_000; + + /** + * -------------------------------------------------------------------------- + * Lock Max Retries + * -------------------------------------------------------------------------- + * + * This is used for RedisHandler. + * + * Maximum number of lock acquisition attempts. + * The default is 300 times. That is lock timeout is about 30 (0.1 * 300) + * seconds. + */ + public int $lockMaxRetries = 300; } diff --git a/app/Views/errors/cli/error_exception.php b/app/Views/errors/cli/error_exception.php index 98d83b0e..9f47d251 100644 --- a/app/Views/errors/cli/error_exception.php +++ b/app/Views/errors/cli/error_exception.php @@ -3,7 +3,7 @@ use CodeIgniter\CLI\CLI; // The main Exception -CLI::write('[' . get_class($exception) . ']', 'light_gray', 'red'); +CLI::write('[' . $exception::class . ']', 'light_gray', 'red'); CLI::write($message); CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green')); CLI::newLine(); @@ -14,7 +14,7 @@ $last = $prevException; CLI::write(' Caused by:'); - CLI::write(' [' . get_class($prevException) . ']', 'red'); + CLI::write(' [' . $prevException::class . ']', 'red'); CLI::write(' ' . $prevException->getMessage()); CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green')); CLI::newLine(); @@ -50,20 +50,11 @@ $function .= $padClass . $error['function']; } - $args = implode(', ', array_map(static function ($value) { - switch (true) { - case is_object($value): - return 'Object(' . get_class($value) . ')'; - - case is_array($value): - return count($value) ? '[...]' : '[]'; - - case $value === null: - return 'null'; // return the lowercased version - - default: - return var_export($value, true); - } + $args = implode(', ', array_map(static fn ($value) => match (true) { + is_object($value) => 'Object(' . $value::class . ')', + is_array($value) => count($value) ? '[...]' : '[]', + $value === null => 'null', // return the lowercased version + default => var_export($value, true), }, array_values($error['args'] ?? []))); $function .= '(' . $args . ')'; diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php index 047c2f4c..44d74989 100644 --- a/app/Views/errors/html/error_exception.php +++ b/app/Views/errors/html/error_exception.php @@ -1,4 +1,5 @@ Caused by: - getCode() ? ' #' . $prevException->getCode() : '') ?> + getCode() ? ' #' . $prevException->getCode() : '') ?> getMessage())) ?> - getMessage())) ?>" + getMessage())) ?>" rel="noreferrer" target="_blank">search → getFile()) . ':' . $prevException->getLine()) ?> @@ -120,7 +121,7 @@ getParameters(); } @@ -234,7 +235,7 @@ HTTP Method - getMethod())) ?> + getMethod()) ?> IP Address @@ -318,10 +319,20 @@ - + $value) : ?> - getName(), 'html') ?> - getValueLine(), 'html') ?> + + + getValueLine(), 'html'); + } else { + foreach ($value as $i => $header) { + echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html'); + } + } + ?> + @@ -345,8 +356,6 @@ headers(); ?> - -

Headers

@@ -357,10 +366,20 @@ - + $value) : ?> - + diff --git a/env b/env index 4d0f5a4f..7e4b05db 100644 --- a/env +++ b/env @@ -41,106 +41,32 @@ GITHUB_ACCESS_TOKEN = # database.default.DBPrefix = # database.default.port = 3306 +# If you use MySQLi as tests, first update the values of Config\Database::$tests. # database.tests.hostname = localhost # database.tests.database = ci4 # database.tests.username = root # database.tests.password = root # database.tests.DBDriver = MySQLi # database.tests.DBPrefix = +# database.tests.charset = utf8mb4 +# database.tests.DBCollat = utf8mb4_general_ci # database.tests.port = 3306 -#-------------------------------------------------------------------- -# CONTENT SECURITY POLICY -#-------------------------------------------------------------------- - -# contentsecuritypolicy.reportOnly = false -# contentsecuritypolicy.defaultSrc = 'none' -# contentsecuritypolicy.scriptSrc = 'self' -# contentsecuritypolicy.styleSrc = 'self' -# contentsecuritypolicy.imageSrc = 'self' -# contentsecuritypolicy.baseURI = null -# contentsecuritypolicy.childSrc = null -# contentsecuritypolicy.connectSrc = 'self' -# contentsecuritypolicy.fontSrc = null -# contentsecuritypolicy.formAction = null -# contentsecuritypolicy.frameAncestors = null -# contentsecuritypolicy.frameSrc = null -# contentsecuritypolicy.mediaSrc = null -# contentsecuritypolicy.objectSrc = null -# contentsecuritypolicy.pluginTypes = null -# contentsecuritypolicy.reportURI = null -# contentsecuritypolicy.sandbox = false -# contentsecuritypolicy.upgradeInsecureRequests = false -# contentsecuritypolicy.styleNonceTag = '{csp-style-nonce}' -# contentsecuritypolicy.scriptNonceTag = '{csp-script-nonce}' -# contentsecuritypolicy.autoNonce = true - -#-------------------------------------------------------------------- -# COOKIE -#-------------------------------------------------------------------- - -# cookie.prefix = '' -# cookie.expires = 0 -# cookie.path = '/' -# cookie.domain = '' -# cookie.secure = false -# cookie.httponly = false -# cookie.samesite = 'Lax' -# cookie.raw = false - #-------------------------------------------------------------------- # ENCRYPTION #-------------------------------------------------------------------- # encryption.key = -# encryption.driver = OpenSSL -# encryption.blockSize = 16 -# encryption.digest = SHA512 - -#-------------------------------------------------------------------- -# HONEYPOT -#-------------------------------------------------------------------- - -# honeypot.hidden = 'true' -# honeypot.label = 'Fill This Field' -# honeypot.name = 'honeypot' -# honeypot.template = '' -# honeypot.container = '
{template}
' - -#-------------------------------------------------------------------- -# SECURITY -#-------------------------------------------------------------------- - -# security.csrfProtection = 'cookie' -# security.tokenRandomize = false -# security.tokenName = 'csrf_token_name' -# security.headerName = 'X-CSRF-TOKEN' -# security.cookieName = 'csrf_cookie_name' -# security.expires = 7200 -# security.regenerate = true -# security.redirect = false -# security.samesite = 'Lax' #-------------------------------------------------------------------- # SESSION #-------------------------------------------------------------------- # session.driver = 'CodeIgniter\Session\Handlers\FileHandler' -# session.cookieName = 'ci_session' -# session.expiration = 7200 # session.savePath = null -# session.matchIP = false -# session.timeToUpdate = 300 -# session.regenerateDestroy = false #-------------------------------------------------------------------- # LOGGER #-------------------------------------------------------------------- # logger.threshold = 4 - -#-------------------------------------------------------------------- -# CURLRequest -#-------------------------------------------------------------------- - -# curlrequest.shareOptions = false diff --git a/public/.htaccess b/public/.htaccess index 1ab98921..4db52aef 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -45,5 +45,5 @@ Options -Indexes # Disable server signature start - ServerSignature Off +ServerSignature Off # Disable server signature end diff --git a/public/index.php b/public/index.php index 1cc47105..5ec58a77 100644 --- a/public/index.php +++ b/public/index.php @@ -1,7 +1,12 @@ 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(); - -// Define ENVIRONMENT -if (! defined('ENVIRONMENT')) { - define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production')); -} - -// Load Config Cache -// $factoriesCache = new \CodeIgniter\Cache\FactoriesCache(); -// $factoriesCache->load('config'); -// ^^^ Uncomment these lines if you want to use Config Caching. - -/* - * --------------------------------------------------------------- - * GRAB OUR CODEIGNITER INSTANCE - * --------------------------------------------------------------- - * - * The CodeIgniter class contains the core functionality to make - * the application run, and does all 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 set up, it's time to actually fire - * up the engines and make this app do its thang. - */ - -$app->run(); - -// Save Config Cache -// $factoriesCache->save('config'); -// ^^^ Uncomment this line if you want to use Config Caching. +// LOAD THE FRAMEWORK BOOTSTRAP FILE +require $paths->systemDirectory . '/Boot.php'; -// Exits the application, setting the exit code for CLI-based applications -// that might be watching. -exit(EXIT_SUCCESS); +exit(CodeIgniter\Boot::bootWeb($paths)); diff --git a/spark b/spark index 9daa4403..a56fbc1b 100755 --- a/spark +++ b/spark @@ -12,13 +12,16 @@ /* * -------------------------------------------------------------------- - * CodeIgniter command-line tools + * 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. + */ + +/* + *--------------------------------------------------------------- + * CHECK SERVER API + *--------------------------------------------------------------- */ // Refuse to run when called from php-cgi @@ -26,8 +29,13 @@ 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`. +/* + *--------------------------------------------------------------- + * CHECK PHP VERSION + *--------------------------------------------------------------- + */ + +$minPhpVersion = '8.1'; // 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', @@ -42,12 +50,11 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) { error_reporting(E_ALL); ini_set('display_errors', '1'); -/** - * @var bool - * - * @deprecated No longer in use. `CodeIgniter` has `$context` property. +/* + *--------------------------------------------------------------- + * SET THE CURRENT DIRECTORY + *--------------------------------------------------------------- */ -define('SPARKED', true); // Path to the front controller define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); @@ -64,41 +71,14 @@ chdir(FCPATH); * and fires up an environment-specific bootstrapping. */ -// 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. 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(); - -// Define ENVIRONMENT -if (! defined('ENVIRONMENT')) { - define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production')); -} - -// 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(); +// LOAD THE FRAMEWORK BOOTSTRAP FILE +require $paths->systemDirectory . '/Boot.php'; -exit(is_int($exit) ? $exit : EXIT_SUCCESS); +exit(CodeIgniter\Boot::bootSpark($paths));
getHeaderLine($name), 'html') ?> + getHeaderLine($name), 'html'); + } else { + foreach ($value as $i => $header) { + echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html'); + } + } + ?> +