diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9d499f92..482997d3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,7 +7,7 @@ on: jobs: deploy: name: 'Deploy to Production' - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: diff --git a/README.md b/README.md index 01e37a30..6e4169b3 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,17 @@ [![](https://github.com/codeigniter4projects/website/workflows/Deptrac/badge.svg)](https://github.com/codeigniter4projects/website/actions/workflows/deptrac.yml) [![Coverage Status](https://coveralls.io/repos/github/codeigniter4projects/website/badge.svg?branch=develop)](https://coveralls.io/github/codeigniter4projects/website?branch=develop) -This is the official website for the CodeIgniter PHP framework. +This is the official website for the CodeIgniter PHP framework. The website has been open-sourced in the interest of transparency. -We welcome issues and pull requests, to handle corrections. +We welcome issues and pull requests, to handle corrections. New blog posts will not be accepted without prior authorization. ## Implementation The site has been built with CodeIgniter 4, and is meant to be an example of "good" programming style, although definitely not -the only way to do things. +the only way to do things. Some of the programming design decisions reflected: @@ -23,12 +23,12 @@ Some of the programming design decisions reflected: - The architecture adheres more to the "model-view-adapter" convention, where the view is unaware of the source of data and the model is unaware of how any data might be presented. The controllers are go-betweens. -- A "master template" lets each controller focus +- A "master template" lets each controller focus only with building its part of a webpage. -- A base controller takes care of assembling finished pages, using the +- A base controller takes care of assembling finished pages, using the master template. - Mock data for the recent news and most recently active threads, means - that the website can be tested locally, without needing access to + that the website can be tested locally, without needing access to the live forum database. - View fragments are used to style single "records" on their own, improving cohesion. @@ -41,7 +41,7 @@ Some of the programming design decisions reflected: ## Server Requirements -PHP version 7.2 or higher is required, with the following extensions installed: +PHP version 7.4 or higher is required, with the following extensions installed: - [intl](https://php.net/manual/en/intl.requirements.php) - [libcurl](https://php.net/manual/en/curl.requirements.php) if you plan to use the `HTTP\CURLRequest` library @@ -63,21 +63,25 @@ Use these steps to create a local installation for development and testing. 4. Install dependencies: `composer install` 5. Create your **.env** file: `cp env .env` 6. Edit **.env** and set at least the following: - * `CI_ENVIRONMENT = development` - * `database.default.database = ../writable/database.db` - * `database.default.DBDriver = SQLite3` - -The website is intended to live on the same server as the forums, and uses the forum -database to pull in the most recent posts. When developing locally, this poses a challenge. -To make local development simpler, a migration and seed have been provided to setup a -table with some mock data that can be used in place of having a local MyBB install. - -1. Migrate the database: `php spark migrate -all` -2. Run the seeder: `php spark db:seed ForumSeeder` + * `GITHUB_ACCESS_TOKEN = ghp_***` + * Set your GitHub Personal Access Token. + * `CI_ENVIRONMENT = development` + * `app.forceGlobalSecureRequests = false` + * `database.default.database = ../writable/database.db` + * `database.default.DBDriver = SQLite3` +7. Seed fake Forum data + + The website is intended to live on the same server as the forums, and uses the forum + database to pull in the most recent posts. When developing locally, this poses a challenge. + To make local development simpler, a migration and seed have been provided to setup a + table with some mock data that can be used in place of having a local MyBB install. + + 1. Migrate the database: `php spark migrate -all` + 2. Run the seeder: `php spark db:seed ForumSeeder` At this point you should have a usable version of the current code! Try launching it locally: 1. From the repo directory start serving the website: `php spark serve` 2. In your web browser of choice navigate to the local URL: `http://localhost:8080` -> Note: The example commands above are for Linux-based systems. You may need to adjust for your operating system. +> **Note** The example commands above are for Linux-based systems. You may need to adjust for your operating system. diff --git a/app/Common.php b/app/Common.php index 23e3e614..95f55442 100644 --- a/app/Common.php +++ b/app/Common.php @@ -11,5 +11,5 @@ * loaded early on, and may also contain additional functions * that you'd like to use throughout your entire application * - * @see: https://codeigniter4.github.io/CodeIgniter4/ + * @see: https://codeigniter.com/user_guide/extending/common.html */ diff --git a/app/Config/App.php b/app/Config/App.php index 2917e407..1d3ebcf2 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -12,19 +12,26 @@ class App extends BaseConfig * Base Site URL * -------------------------------------------------------------------------- * - * URL to your CodeIgniter root. Typically this will be your base URL, + * URL to your CodeIgniter root. Typically, this will be your base URL, * WITH a trailing slash: * * http://example.com/ + */ + public string $baseURL = 'http://localhost:8080/'; + + /** + * Allowed Hostnames in the Site URL other than the hostname in the baseURL. + * If you want to accept multiple Hostnames, set this. * - * If this is not set then CodeIgniter will try guess the protocol, domain - * and path to your installation. However, you should always configure this - * explicitly and never rely on auto-guessing, especially in production - * environments. + * 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 string + * @var string[] + * @phpstan-var list */ - public $baseURL = 'http://localhost:8080/'; + public array $allowedHostnames = []; /** * -------------------------------------------------------------------------- @@ -34,10 +41,8 @@ class App extends BaseConfig * Typically this will be your index.php file, unless you've renamed it to * something else. If you are using mod_rewrite to remove the page set this * variable so that it is blank. - * - * @var string */ - public $indexPage = ''; + public string $indexPage = ''; /** * -------------------------------------------------------------------------- @@ -53,10 +58,8 @@ class App extends BaseConfig * 'PATH_INFO' Uses $_SERVER['PATH_INFO'] * * WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded! - * - * @var string */ - public $uriProtocol = 'REQUEST_URI'; + public string $uriProtocol = 'REQUEST_URI'; /** * -------------------------------------------------------------------------- @@ -67,10 +70,8 @@ class App extends BaseConfig * is viewing the site from. It affects the language strings and other * strings (like currency markers, numbers, etc), that your program * should run under for this request. - * - * @var string */ - public $defaultLocale = 'en'; + public string $defaultLocale = 'en'; /** * -------------------------------------------------------------------------- @@ -81,10 +82,8 @@ class App extends BaseConfig * language to use based on the value of the Accept-Language header. * * If false, no automatic detection will be performed. - * - * @var bool */ - public $negotiateLocale = false; + public bool $negotiateLocale = false; /** * -------------------------------------------------------------------------- @@ -95,9 +94,11 @@ class App extends BaseConfig * by the application in descending order of priority. If no match is * found, the first locale will be used. * + * IncomingRequest::setLocale() also uses this list. + * * @var string[] */ - public $supportedLocales = ['en']; + public array $supportedLocales = ['en']; /** * -------------------------------------------------------------------------- @@ -107,9 +108,9 @@ class App extends BaseConfig * The default timezone that will be used in your application to display * dates with the date helper, and can be retrieved through app_timezone() * - * @var string + * @see https://www.php.net/manual/en/timezones.php for list of timezones supported by PHP. */ - public $appTimezone = 'America/Chicago'; + public string $appTimezone = 'UTC'; /** * -------------------------------------------------------------------------- @@ -119,11 +120,9 @@ class App extends BaseConfig * This determines which character set is used by default in various methods * that require a character set to be provided. * - * @see https://php.net/htmlspecialchars for a list of supported charsets. - * - * @var string + * @see http://php.net/htmlspecialchars for a list of supported charsets. */ - public $charset = 'UTF-8'; + public string $charset = 'UTF-8'; /** * -------------------------------------------------------------------------- @@ -134,10 +133,8 @@ class App extends BaseConfig * made via a secure connection (HTTPS). If the incoming request is not * secure, the user will be redirected to a secure version of the page * and the HTTP Strict Transport Security header will be set. - * - * @var bool */ - public $forceGlobalSecureRequests = true; + public bool $forceGlobalSecureRequests = true; /** * -------------------------------------------------------------------------- @@ -150,9 +147,9 @@ class App extends BaseConfig * - `CodeIgniter\Session\Handlers\MemcachedHandler` * - `CodeIgniter\Session\Handlers\RedisHandler` * - * @var string + * @deprecated use Config\Session::$driver instead. */ - public $sessionDriver = FileHandler::class; + public string $sessionDriver = FileHandler::class; /** * -------------------------------------------------------------------------- @@ -161,9 +158,9 @@ class App extends BaseConfig * * The session cookie name, must contain only [0-9a-z_-] characters * - * @var string + * @deprecated use Config\Session::$cookieName instead. */ - public $sessionCookieName = 'ci_session'; + public string $sessionCookieName = 'ci_session'; /** * -------------------------------------------------------------------------- @@ -173,9 +170,9 @@ class App extends BaseConfig * The number of SECONDS you want the session to last. * Setting to 0 (zero) means expire when the browser is closed. * - * @var int + * @deprecated use Config\Session::$expiration instead. */ - public $sessionExpiration = 7200; + public int $sessionExpiration = 7200; /** * -------------------------------------------------------------------------- @@ -192,9 +189,9 @@ class App extends BaseConfig * * IMPORTANT: You are REQUIRED to set a valid save path! * - * @var string + * @deprecated use Config\Session::$savePath instead. */ - public $sessionSavePath = WRITEPATH . 'session'; + public string $sessionSavePath = WRITEPATH . 'session'; /** * -------------------------------------------------------------------------- @@ -206,9 +203,9 @@ class App extends BaseConfig * WARNING: If you're using the database driver, don't forget to update * your session table's PRIMARY KEY when changing this setting. * - * @var bool + * @deprecated use Config\Session::$matchIP instead. */ - public $sessionMatchIP = false; + public bool $sessionMatchIP = false; /** * -------------------------------------------------------------------------- @@ -217,9 +214,9 @@ class App extends BaseConfig * * How many seconds between CI regenerating the session ID. * - * @var int + * @deprecated use Config\Session::$timeToUpdate instead. */ - public $sessionTimeToUpdate = 300; + public int $sessionTimeToUpdate = 300; /** * -------------------------------------------------------------------------- @@ -230,9 +227,20 @@ class App extends BaseConfig * when auto-regenerating the session ID. When set to FALSE, the data * will be later deleted by the garbage collector. * - * @var bool + * @deprecated use Config\Session::$regenerateDestroy instead. + */ + public bool $sessionRegenerateDestroy = false; + + /** + * -------------------------------------------------------------------------- + * Session Database Group + * -------------------------------------------------------------------------- + * + * DB Group for the database session. + * + * @deprecated use Config\Session::$DBGroup instead. */ - public $sessionRegenerateDestroy = false; + public ?string $sessionDBGroup = null; /** * -------------------------------------------------------------------------- @@ -241,11 +249,9 @@ class App extends BaseConfig * * Set a cookie name prefix if you need to avoid collisions. * - * @var string - * * @deprecated use Config\Cookie::$prefix property instead. */ - public $cookiePrefix = ''; + public string $cookiePrefix = ''; /** * -------------------------------------------------------------------------- @@ -254,11 +260,9 @@ class App extends BaseConfig * * Set to `.your-domain.com` for site-wide cookies. * - * @var string - * * @deprecated use Config\Cookie::$domain property instead. */ - public $cookieDomain = ''; + public string $cookieDomain = ''; /** * -------------------------------------------------------------------------- @@ -267,11 +271,9 @@ class App extends BaseConfig * * Typically will be a forward slash. * - * @var string - * * @deprecated use Config\Cookie::$path property instead. */ - public $cookiePath = '/'; + public string $cookiePath = '/'; /** * -------------------------------------------------------------------------- @@ -280,11 +282,9 @@ class App extends BaseConfig * * Cookie will only be set if a secure HTTPS connection exists. * - * @var bool - * * @deprecated use Config\Cookie::$secure property instead. */ - public $cookieSecure = false; + public bool $cookieSecure = false; /** * -------------------------------------------------------------------------- @@ -293,11 +293,9 @@ class App extends BaseConfig * * Cookie will only be accessible via HTTP(S) (no JavaScript). * - * @var bool - * * @deprecated use Config\Cookie::$httponly property instead. */ - public $cookieHTTPOnly = true; + public bool $cookieHTTPOnly = true; /** * -------------------------------------------------------------------------- @@ -319,11 +317,9 @@ class App extends BaseConfig * (empty string) means default SameSite attribute set by browsers (`Lax`) * will be set on cookies. If set to `None`, `$cookieSecure` must also be set. * - * @var string|null - * * @deprecated use Config\Cookie::$samesite property instead. */ - public $cookieSameSite = 'Lax'; + public ?string $cookieSameSite = 'Lax'; /** * -------------------------------------------------------------------------- @@ -332,18 +328,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 = []; /** * -------------------------------------------------------------------------- @@ -353,10 +352,8 @@ class App extends BaseConfig * The token name. * * @deprecated Use `Config\Security` $tokenName property instead of using this property. - * - * @var string */ - public $CSRFTokenName = 'csrf_test_name'; + public string $CSRFTokenName = 'csrf_test_name'; /** * -------------------------------------------------------------------------- @@ -366,10 +363,8 @@ class App extends BaseConfig * The header name. * * @deprecated Use `Config\Security` $headerName property instead of using this property. - * - * @var string */ - public $CSRFHeaderName = 'X-CSRF-TOKEN'; + public string $CSRFHeaderName = 'X-CSRF-TOKEN'; /** * -------------------------------------------------------------------------- @@ -379,10 +374,8 @@ class App extends BaseConfig * The cookie name. * * @deprecated Use `Config\Security` $cookieName property instead of using this property. - * - * @var string */ - public $CSRFCookieName = 'csrf_cookie_name'; + public string $CSRFCookieName = 'csrf_cookie_name'; /** * -------------------------------------------------------------------------- @@ -392,10 +385,8 @@ class App extends BaseConfig * The number in seconds the token should expire. * * @deprecated Use `Config\Security` $expire property instead of using this property. - * - * @var int */ - public $CSRFExpire = 7200; + public int $CSRFExpire = 7200; /** * -------------------------------------------------------------------------- @@ -405,10 +396,8 @@ class App extends BaseConfig * Regenerate token on every submission? * * @deprecated Use `Config\Security` $regenerate property instead of using this property. - * - * @var bool */ - public $CSRFRegenerate = true; + public bool $CSRFRegenerate = true; /** * -------------------------------------------------------------------------- @@ -418,10 +407,8 @@ class App extends BaseConfig * Redirect to previous page with error on failure? * * @deprecated Use `Config\Security` $redirect property instead of using this property. - * - * @var bool */ - public $CSRFRedirect = true; + public bool $CSRFRedirect = false; /** * -------------------------------------------------------------------------- @@ -439,10 +426,8 @@ class App extends BaseConfig * @see https://portswigger.net/web-security/csrf/samesite-cookies * * @deprecated `Config\Cookie` $samesite property is used. - * - * @var string */ - public $CSRFSameSite = 'Lax'; + public string $CSRFSameSite = 'Lax'; /** * -------------------------------------------------------------------------- @@ -457,10 +442,8 @@ class App extends BaseConfig * * For a better understanding of CSP, see these documents: * - * @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/ - * @see https://www.w3.org/TR/CSP/ - * - * @var bool + * @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/ + * @see http://www.w3.org/TR/CSP/ */ - public $CSPEnabled = false; + public bool $CSPEnabled = false; } diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index ee27e3b2..21324e89 100644 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -31,12 +31,10 @@ class Autoload extends AutoloadConfig * else you will need to modify all of those classes for this to work. * * Prototype: - *``` * $psr4 = [ * 'CodeIgniter' => SYSTEMPATH, * 'App' => APPPATH * ]; - *``` * * @var array */ @@ -56,11 +54,9 @@ class Autoload extends AutoloadConfig * were being autoloaded through a namespace. * * Prototype: - *``` * $classmap = [ * 'MyClass' => '/path/to/class/file.php' * ]; - *``` * * @var array */ @@ -75,13 +71,26 @@ class Autoload extends AutoloadConfig * or for loading functions. * * Prototype: - * ``` - * $files = [ - * '/path/to/my/file.php', - * ]; - * ``` + * $files = [ + * '/path/to/my/file.php', + * ]; * - * @var array + * @var string[] + * @phpstan-var list */ public $files = []; + + /** + * ------------------------------------------------------------------- + * Helpers + * ------------------------------------------------------------------- + * Prototype: + * $helpers = [ + * 'form', + * ]; + * + * @var string[] + * @phpstan-var list + */ + public $helpers = []; } diff --git a/app/Config/CURLRequest.php b/app/Config/CURLRequest.php index b4c8e5c4..6c3ed74a 100644 --- a/app/Config/CURLRequest.php +++ b/app/Config/CURLRequest.php @@ -15,8 +15,6 @@ class CURLRequest extends BaseConfig * * If true, all the options won't be reset between requests. * It may cause an error request with unnecessary headers. - * - * @var bool */ - public $shareOptions = true; + public bool $shareOptions = true; } diff --git a/app/Config/Cache.php b/app/Config/Cache.php index 2d1fea90..659d9ed6 100644 --- a/app/Config/Cache.php +++ b/app/Config/Cache.php @@ -19,10 +19,8 @@ class Cache extends BaseConfig * * The name of the preferred handler that should be used. If for some reason * it is not available, the $backupHandler will be used in its place. - * - * @var string */ - public $handler = 'file'; + public string $handler = 'file'; /** * -------------------------------------------------------------------------- @@ -32,10 +30,8 @@ class Cache extends BaseConfig * The name of the handler that will be used in case the first one is * unreachable. Often, 'file' is used here since the filesystem is * always available, though that's not always practical for the app. - * - * @var string */ - public $backupHandler = 'dummy'; + public string $backupHandler = 'dummy'; /** * -------------------------------------------------------------------------- @@ -45,11 +41,9 @@ class Cache extends BaseConfig * The path to where cache files should be stored, if using a file-based * system. * - * @var string - * * @deprecated Use the driver-specific variant under $file */ - public $storePath = WRITEPATH . 'cache/'; + public string $storePath = WRITEPATH . 'cache/'; /** * -------------------------------------------------------------------------- @@ -77,10 +71,8 @@ class Cache extends BaseConfig * * This string is added to all cache item names to help avoid collisions * if you run multiple applications with the same cache engine. - * - * @var string */ - public $prefix = ''; + public string $prefix = ''; /** * -------------------------------------------------------------------------- @@ -92,10 +84,8 @@ class Cache extends BaseConfig * WARNING: This is not used by framework handlers where 60 seconds is * hard-coded, but may be useful to projects and modules. This will replace * the hard-coded value in a future release. - * - * @var int */ - public $ttl = 60; + public int $ttl = 60; /** * -------------------------------------------------------------------------- @@ -106,10 +96,8 @@ class Cache extends BaseConfig * Strings that violate this restriction will cause handlers to throw. * Default: {}()/\@: * Note: The default set is required for PSR-6 compliance. - * - * @var string */ - public $reservedCharacters = '{}()/\@:'; + public string $reservedCharacters = '{}()/\@:'; /** * -------------------------------------------------------------------------- @@ -120,7 +108,7 @@ class Cache extends BaseConfig * * @var array */ - public $file = [ + public array $file = [ 'storePath' => WRITEPATH . 'cache/', 'mode' => 0640, ]; @@ -134,9 +122,9 @@ class Cache extends BaseConfig * * @see https://codeigniter.com/user_guide/libraries/caching.html#memcached * - * @var array + * @var array */ - public $memcached = [ + public array $memcached = [ 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 1, @@ -152,7 +140,7 @@ class Cache extends BaseConfig * * @var array */ - public $redis = [ + public array $redis = [ 'host' => '127.0.0.1', 'password' => null, 'port' => 6379, @@ -170,7 +158,7 @@ class Cache extends BaseConfig * * @var array */ - public $validHandlers = [ + public array $validHandlers = [ 'dummy' => DummyHandler::class, 'file' => FileHandler::class, 'memcached' => MemcachedHandler::class, diff --git a/app/Config/ContentSecurityPolicy.php b/app/Config/ContentSecurityPolicy.php index 0be61630..18612e15 100644 --- a/app/Config/ContentSecurityPolicy.php +++ b/app/Config/ContentSecurityPolicy.php @@ -21,27 +21,21 @@ class ContentSecurityPolicy extends BaseConfig /** * Default CSP report context - * - * @var bool */ - public $reportOnly = false; + public bool $reportOnly = false; /** * Specifies a URL where a browser will send reports * when a content security policy is violated. - * - * @var string|null */ - public $reportURI; + public ?string $reportURI = null; /** * Instructs user agents to rewrite URL schemes, changing * HTTP to HTTPS. This directive is for websites with * large numbers of old URLs that need to be rewritten. - * - * @var bool */ - public $upgradeInsecureRequests = false; + public bool $upgradeInsecureRequests = false; // ------------------------------------------------------------------------- // Sources allowed @@ -167,22 +161,16 @@ class ContentSecurityPolicy extends BaseConfig /** * Nonce tag for style - * - * @var string */ - public $styleNonceTag = '{csp-style-nonce}'; + public string $styleNonceTag = '{csp-style-nonce}'; /** * Nonce tag for script - * - * @var string */ - public $scriptNonceTag = '{csp-script-nonce}'; + public string $scriptNonceTag = '{csp-script-nonce}'; /** * Replace nonce tag automatically - * - * @var bool */ - public $autoNonce = true; + public bool $autoNonce = true; } diff --git a/app/Config/Cookie.php b/app/Config/Cookie.php index 8ee01c71..440af5ee 100644 --- a/app/Config/Cookie.php +++ b/app/Config/Cookie.php @@ -13,10 +13,8 @@ class Cookie extends BaseConfig * -------------------------------------------------------------------------- * * Set a cookie name prefix if you need to avoid collisions. - * - * @var string */ - public $prefix = ''; + public string $prefix = ''; /** * -------------------------------------------------------------------------- @@ -37,10 +35,8 @@ class Cookie extends BaseConfig * -------------------------------------------------------------------------- * * Typically will be a forward slash. - * - * @var string */ - public $path = '/'; + public string $path = '/'; /** * -------------------------------------------------------------------------- @@ -48,10 +44,8 @@ class Cookie extends BaseConfig * -------------------------------------------------------------------------- * * Set to `.your-domain.com` for site-wide cookies. - * - * @var string */ - public $domain = ''; + public string $domain = ''; /** * -------------------------------------------------------------------------- @@ -59,10 +53,8 @@ class Cookie extends BaseConfig * -------------------------------------------------------------------------- * * Cookie will only be set if a secure HTTPS connection exists. - * - * @var bool */ - public $secure = false; + public bool $secure = false; /** * -------------------------------------------------------------------------- @@ -70,10 +62,8 @@ class Cookie extends BaseConfig * -------------------------------------------------------------------------- * * Cookie will only be accessible via HTTP(S) (no JavaScript). - * - * @var bool */ - public $httponly = true; + public bool $httponly = true; /** * -------------------------------------------------------------------------- @@ -94,10 +84,8 @@ class Cookie extends BaseConfig * Defaults to `Lax` for compatibility with modern browsers. Setting `''` * (empty string) means default SameSite attribute set by browsers (`Lax`) * will be set on cookies. If set to `None`, `$secure` must also be set. - * - * @var string */ - public $samesite = 'Lax'; + public string $samesite = 'Lax'; /** * -------------------------------------------------------------------------- @@ -110,10 +98,8 @@ class Cookie extends BaseConfig * If this is set to `true`, cookie names should be compliant of RFC 2616's * list of allowed characters. * - * @var bool - * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes * @see https://tools.ietf.org/html/rfc2616#section-2.2 */ - public $raw = false; + public bool $raw = false; } diff --git a/app/Config/Database.php b/app/Config/Database.php index 87d73b13..2c092124 100644 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -12,25 +12,19 @@ class Database extends Config /** * The directory that holds the Migrations * and Seeds directories. - * - * @var string */ - public $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR; + public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR; /** * Lets you choose which connection group to * use if no other is specified. - * - * @var string */ - public $defaultGroup = 'default'; + public string $defaultGroup = 'default'; /** * The default database connection. - * - * @var array */ - public $default = [ + public array $default = [ 'DSN' => '', 'hostname' => 'localhost', 'username' => '', @@ -39,7 +33,7 @@ class Database extends Config 'DBDriver' => 'MySQLi', 'DBPrefix' => '', 'pConnect' => false, - 'DBDebug' => (ENVIRONMENT !== 'production'), + 'DBDebug' => true, 'charset' => 'utf8', 'DBCollat' => 'utf8_general_ci', 'swapPre' => '', @@ -53,10 +47,8 @@ class Database extends Config /** * This database connection is used when * running PHPUnit database tests. - * - * @var array */ - public $tests = [ + public array $tests = [ 'DSN' => '', 'hostname' => '127.0.0.1', 'username' => '', @@ -65,7 +57,7 @@ class Database extends Config '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'), + 'DBDebug' => true, 'charset' => 'utf8', 'DBCollat' => 'utf8_general_ci', 'swapPre' => '', @@ -75,6 +67,7 @@ class Database extends Config 'failover' => [], 'port' => 3306, 'foreignKeys' => true, + 'busyTimeout' => 1000, ]; public function __construct() diff --git a/app/Config/DocTypes.php b/app/Config/DocTypes.php index 6f166936..788d68fd 100755 --- a/app/Config/DocTypes.php +++ b/app/Config/DocTypes.php @@ -9,7 +9,7 @@ class DocTypes * * @var array */ - public $list = [ + public array $list = [ 'xhtml11' => '', 'xhtml1-strict' => '', 'xhtml1-trans' => '', @@ -30,4 +30,14 @@ class DocTypes 'xhtml-rdfa-1' => '', 'xhtml-rdfa-2' => '', ]; + + /** + * Whether to remove the solidus (`/`) character for void HTML elements (e.g. ``) + * for HTML5 compatibility. + * + * Set to: + * `true` - to be HTML5 compatible + * `false` - to be XHTML compatible + */ + public bool $html5 = true; } diff --git a/app/Config/Email.php b/app/Config/Email.php index 3a42fbe6..01350186 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -6,165 +6,112 @@ class Email extends BaseConfig { - /** - * @var string - */ - public $fromEmail; - - /** - * @var string - */ - public $fromName; - - /** - * @var string - */ - public $recipients; + public string $fromEmail = ''; + public string $fromName = ''; + public string $recipients = ''; /** * The "user agent" - * - * @var string */ - public $userAgent = 'CodeIgniter'; + public string $userAgent = 'CodeIgniter'; /** * The mail sending protocol: mail, sendmail, smtp - * - * @var string */ - public $protocol = 'mail'; + public string $protocol = 'mail'; /** * The server path to Sendmail. - * - * @var string */ - public $mailPath = '/usr/sbin/sendmail'; + public string $mailPath = '/usr/sbin/sendmail'; /** * SMTP Server Address - * - * @var string */ - public $SMTPHost; + public string $SMTPHost = ''; /** * SMTP Username - * - * @var string */ - public $SMTPUser; + public string $SMTPUser = ''; /** * SMTP Password - * - * @var string */ - public $SMTPPass; + public string $SMTPPass = ''; /** * SMTP Port - * - * @var int */ - public $SMTPPort = 25; + public int $SMTPPort = 25; /** * SMTP Timeout (in seconds) - * - * @var int */ - public $SMTPTimeout = 5; + public int $SMTPTimeout = 5; /** * Enable persistent SMTP connections - * - * @var bool */ - public $SMTPKeepAlive = false; + public bool $SMTPKeepAlive = false; /** * SMTP Encryption. Either tls or ssl - * - * @var string */ - public $SMTPCrypto = 'tls'; + public string $SMTPCrypto = 'tls'; /** * Enable word-wrap - * - * @var bool */ - public $wordWrap = true; + public bool $wordWrap = true; /** * Character count to wrap at - * - * @var int */ - public $wrapChars = 76; + public int $wrapChars = 76; /** * Type of mail, either 'text' or 'html' - * - * @var string */ - public $mailType = 'text'; + public string $mailType = 'text'; /** * Character set (utf-8, iso-8859-1, etc.) - * - * @var string */ - public $charset = 'UTF-8'; + public string $charset = 'UTF-8'; /** * Whether to validate the email address - * - * @var bool */ - public $validate = false; + public bool $validate = false; /** * Email Priority. 1 = highest. 5 = lowest. 3 = normal - * - * @var int */ - public $priority = 3; + public int $priority = 3; /** * Newline character. (Use “\r\n” to comply with RFC 822) - * - * @var string */ - public $CRLF = "\r\n"; + public string $CRLF = "\r\n"; /** * Newline character. (Use “\r\n” to comply with RFC 822) - * - * @var string */ - public $newline = "\r\n"; + public string $newline = "\r\n"; /** * Enable BCC Batch Mode. - * - * @var bool */ - public $BCCBatchMode = false; + public bool $BCCBatchMode = false; /** * Number of emails in each BCC batch - * - * @var int */ - public $BCCBatchSize = 200; + public int $BCCBatchSize = 200; /** * Enable notify message from server - * - * @var bool */ - public $DSN = false; + public bool $DSN = false; } diff --git a/app/Config/Encryption.php b/app/Config/Encryption.php index 07b45a0b..28344134 100644 --- a/app/Config/Encryption.php +++ b/app/Config/Encryption.php @@ -20,10 +20,8 @@ class Encryption extends BaseConfig * If you use the Encryption class you must set an encryption key (seed). * You need to ensure it is long enough for the cipher and mode you plan to use. * See the user guide for more info. - * - * @var string */ - public $key = ''; + public string $key = ''; /** * -------------------------------------------------------------------------- @@ -35,10 +33,8 @@ class Encryption extends BaseConfig * Available drivers: * - OpenSSL * - Sodium - * - * @var string */ - public $driver = 'OpenSSL'; + public string $driver = 'OpenSSL'; /** * -------------------------------------------------------------------------- @@ -49,10 +45,8 @@ class Encryption extends BaseConfig * before it is encrypted. This value should be greater than zero. * * See the user guide for more information on padding. - * - * @var int */ - public $blockSize = 16; + public int $blockSize = 16; /** * -------------------------------------------------------------------------- @@ -60,8 +54,39 @@ class Encryption extends BaseConfig * -------------------------------------------------------------------------- * * HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'. + */ + public string $digest = 'SHA512'; + + /** + * Whether the cipher-text should be raw. If set to false, then it will be base64 encoded. + * This setting is only used by OpenSSLHandler. + * + * Set to false for CI3 Encryption compatibility. + */ + public bool $rawData = true; + + /** + * Encryption key info. + * This setting is only used by OpenSSLHandler. + * + * Set to 'encryption' for CI3 Encryption compatibility. + */ + public string $encryptKeyInfo = ''; + + /** + * Authentication key info. + * This setting is only used by OpenSSLHandler. + * + * Set to 'authentication' for CI3 Encryption compatibility. + */ + public string $authKeyInfo = ''; + + /** + * Cipher to use. + * This setting is only used by OpenSSLHandler. * - * @var string + * Set to 'AES-128-CBC' to decrypt encrypted data that encrypted + * by CI3 Encryption default configuration. */ - public $digest = 'SHA512'; + public string $cipher = 'AES-256-CTR'; } diff --git a/app/Config/Exceptions.php b/app/Config/Exceptions.php index 7cbc78a8..bf3a1b96 100644 --- a/app/Config/Exceptions.php +++ b/app/Config/Exceptions.php @@ -3,6 +3,7 @@ namespace Config; use CodeIgniter\Config\BaseConfig; +use Psr\Log\LogLevel; /** * Setup how the exception handler works. @@ -17,10 +18,8 @@ class Exceptions extends BaseConfig * through Services::Log. * * Default: true - * - * @var bool */ - public $log = true; + public bool $log = true; /** * -------------------------------------------------------------------------- @@ -28,10 +27,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 +38,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 +48,30 @@ 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'] + */ + 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. * - * @var array + * The related `Config\Logger::$threshold` should be adjusted, if needed, + * to capture logging the deprecations. */ - public $sensitiveDataInTrace = []; + public string $deprecationLogLevel = LogLevel::WARNING; } diff --git a/app/Config/Feature.php b/app/Config/Feature.php index 4c5ec90c..0bc45c6f 100644 --- a/app/Config/Feature.php +++ b/app/Config/Feature.php @@ -20,10 +20,8 @@ class Feature extends BaseConfig * - CodeIgniter\Router\Router::handle() uses: * - property $filtersInfo, instead of $filterInfo * - CodeIgniter\Router\RouteCollection::getFiltersForRoute(), instead of getFilterForRoute() - * - * @var bool */ - public $multipleFilters = false; + public bool $multipleFilters = false; /** * Use improved new auto routing instead of the default legacy version. diff --git a/app/Config/Filters.php b/app/Config/Filters.php index d0a97238..7b70c4fb 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -14,10 +14,8 @@ class Filters extends BaseConfig /** * Configures aliases for Filter classes to * make reading things nicer and simpler. - * - * @var array */ - public $aliases = [ + public array $aliases = [ 'csrf' => CSRF::class, 'toolbar' => DebugToolbar::class, 'honeypot' => Honeypot::class, @@ -28,10 +26,8 @@ class Filters extends BaseConfig /** * List of filter aliases that are always * applied before and after every request. - * - * @var array */ - public $globals = [ + public array $globals = [ 'before' => [ // 'honeypot', // 'csrf', @@ -54,10 +50,8 @@ class Filters extends BaseConfig * If you use this, you should disable auto-routing because auto-routing * permits any HTTP method to access a controller. Accessing the controller * with a method you don’t expect could bypass the filter. - * - * @var array */ - public $methods = []; + public array $methods = []; /** * List of filter aliases that should run on any @@ -65,8 +59,6 @@ class Filters extends BaseConfig * * Example: * 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']] - * - * @var array */ - public $filters = []; + public array $filters = []; } diff --git a/app/Config/Format.php b/app/Config/Format.php index d89e4084..749da3e5 100644 --- a/app/Config/Format.php +++ b/app/Config/Format.php @@ -24,7 +24,7 @@ class Format extends BaseConfig * * @var string[] */ - public $supportedResponseFormats = [ + public array $supportedResponseFormats = [ 'application/json', 'application/xml', // machine-readable XML 'text/xml', // human-readable XML @@ -41,7 +41,7 @@ class Format extends BaseConfig * * @var array */ - public $formatters = [ + public array $formatters = [ 'application/json' => JSONFormatter::class, 'application/xml' => XMLFormatter::class, 'text/xml' => XMLFormatter::class, @@ -57,7 +57,7 @@ class Format extends BaseConfig * * @var array */ - public $formatterOptions = [ + public array $formatterOptions = [ 'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, 'application/xml' => 0, 'text/xml' => 0, diff --git a/app/Config/Generators.php b/app/Config/Generators.php index 11214fdc..6566a31e 100644 --- a/app/Config/Generators.php +++ b/app/Config/Generators.php @@ -25,7 +25,9 @@ class Generators extends BaseConfig * * @var array */ - public $views = [ + public array $views = [ + 'make:cell' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php', + 'make:cell_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/Honeypot.php b/app/Config/Honeypot.php index 42b5a0dc..67ebcb0e 100644 --- a/app/Config/Honeypot.php +++ b/app/Config/Honeypot.php @@ -8,36 +8,35 @@ class Honeypot extends BaseConfig { /** * Makes Honeypot visible or not to human - * - * @var bool */ - public $hidden = true; + public bool $hidden = true; /** * Honeypot Label Content - * - * @var string */ - public $label = 'Fill This Field'; + public string $label = 'Fill This Field'; /** * Honeypot Field Name - * - * @var string */ - public $name = 'honeypot'; + public string $name = 'honeypot'; /** * Honeypot HTML Template - * - * @var string */ - public $template = ''; + public string $template = ''; /** * Honeypot container * - * @var string + * If you enabled CSP, you can remove `style="display:none"`. + */ + public string $container = '
{template}
'; + + /** + * The id attribute for Honeypot container tag + * + * Used when CSP is enabled. */ - public $container = '
{template}
'; + public string $containerId = 'hpc'; } diff --git a/app/Config/Images.php b/app/Config/Images.php index 1c15d815..a33ddadb 100644 --- a/app/Config/Images.php +++ b/app/Config/Images.php @@ -10,25 +10,21 @@ class Images extends BaseConfig { /** * Default handler used if no other handler is specified. - * - * @var string */ - public $defaultHandler = 'gd'; + public string $defaultHandler = 'gd'; /** * The path to the image library. * Required for ImageMagick, GraphicsMagick, or NetPBM. - * - * @var string */ - public $libraryPath = '/usr/local/bin/convert'; + public string $libraryPath = '/usr/local/bin/convert'; /** * The available handler classes. * * @var array */ - public $handlers = [ + public array $handlers = [ 'gd' => GDHandler::class, 'imagick' => ImageMagickHandler::class, ]; diff --git a/app/Config/Kint.php b/app/Config/Kint.php index b1016ed5..c7b570c8 100644 --- a/app/Config/Kint.php +++ b/app/Config/Kint.php @@ -3,7 +3,7 @@ namespace Config; use CodeIgniter\Config\BaseConfig; -use Kint\Renderer\Renderer; +use Kint\Renderer\AbstractRenderer; /** * -------------------------------------------------------------------------- @@ -24,18 +24,23 @@ class Kint extends BaseConfig */ public $plugins; - public $maxDepth = 6; - public $displayCalledFrom = true; - public $expanded = false; + public int $maxDepth = 6; + public bool $displayCalledFrom = true; + public bool $expanded = false; /* |-------------------------------------------------------------------------- | RichRenderer Settings |-------------------------------------------------------------------------- */ - public $richTheme = 'aante-light.css'; - public $richFolder = false; - public $richSort = Renderer::SORT_FULL; + public string $richTheme = 'aante-light.css'; + public bool $richFolder = false; + + /** + * @psalm-suppress UndefinedClass + */ + public int $richSort = AbstractRenderer::SORT_FULL; + public $richObjectPlugins; public $richTabPlugins; @@ -44,8 +49,8 @@ class Kint extends BaseConfig | CLI Settings |-------------------------------------------------------------------------- */ - public $cliColors = true; - public $cliForceUTF8 = false; - public $cliDetectWidth = true; - public $cliMinWidth = 40; + public bool $cliColors = true; + public bool $cliForceUTF8 = false; + public bool $cliDetectWidth = true; + public int $cliMinWidth = 40; } diff --git a/app/Config/Logger.php b/app/Config/Logger.php index 74381503..695f5c82 100644 --- a/app/Config/Logger.php +++ b/app/Config/Logger.php @@ -38,7 +38,7 @@ class Logger extends BaseConfig * * @var array|int */ - public $threshold = 4; + public $threshold = (ENVIRONMENT === 'production') ? 4 : 9; /** * -------------------------------------------------------------------------- @@ -47,10 +47,8 @@ class Logger extends BaseConfig * * Each item that is logged has an associated date. You can use PHP date * codes to set your own date formatting - * - * @var string */ - public $dateFormat = 'Y-m-d H:i:s'; + public string $dateFormat = 'Y-m-d H:i:s'; /** * -------------------------------------------------------------------------- @@ -60,7 +58,7 @@ class Logger extends BaseConfig * The logging system supports multiple actions to be taken when something * is logged. This is done by allowing for multiple Handlers, special classes * designed to write the log to their chosen destinations, whether that is - * a file on the server, a cloud-based service, or even taking actions such + * a file on the getServer, a cloud-based service, or even taking actions such * as emailing the dev team. * * Each handler is defined by the class name used for that handler, and it @@ -74,10 +72,8 @@ class Logger extends BaseConfig * * Handlers are executed in the order defined in this array, starting with * the handler on top and continuing down. - * - * @var array */ - public $handlers = [ + public array $handlers = [ /* * -------------------------------------------------------------------- diff --git a/app/Config/Migrations.php b/app/Config/Migrations.php index 91e80b4a..af28e8ef 100644 --- a/app/Config/Migrations.php +++ b/app/Config/Migrations.php @@ -15,10 +15,8 @@ class Migrations extends BaseConfig * * You should enable migrations whenever you intend to do a schema migration * and disable it back when you're done. - * - * @var bool */ - public $enabled = true; + public bool $enabled = true; /** * -------------------------------------------------------------------------- @@ -30,10 +28,8 @@ class Migrations extends BaseConfig * level the system is at. It then compares the migration level in this * table to the $config['migration_version'] if they are not the same it * will migrate up. This must be set. - * - * @var string */ - public $table = 'migrations'; + public string $table = 'migrations'; /** * -------------------------------------------------------------------------- @@ -42,14 +38,15 @@ class Migrations extends BaseConfig * * This is the format that will be used when creating new migrations * using the CLI command: - * > php spark migrate:create + * > php spark make:migration * - * Typical formats: + * Note: if you set an unsupported format, migration runner will not find + * your migration files. + * + * Supported formats: * - YmdHis_ * - Y-m-d-His_ * - Y_m_d_His_ - * - * @var string */ - public $timestampFormat = 'Y-m-d-His_'; + public string $timestampFormat = 'Y-m-d-His_'; } diff --git a/app/Config/Mimes.php b/app/Config/Mimes.php index 884e76bc..99d28e5f 100644 --- a/app/Config/Mimes.php +++ b/app/Config/Mimes.php @@ -20,10 +20,8 @@ class Mimes { /** * Map of extensions to mime types. - * - * @var array */ - public static $mimes = [ + public static array $mimes = [ 'hqx' => [ 'application/mac-binhex40', 'application/mac-binhex', @@ -55,6 +53,8 @@ class Mimes 'lzh' => 'application/octet-stream', 'exe' => [ 'application/octet-stream', + 'application/vnd.microsoft.portable-executable', + 'application/x-dosexec', 'application/x-msdownload', ], 'class' => 'application/octet-stream', diff --git a/app/Config/Modules.php b/app/Config/Modules.php index bde4079f..5b6a639b 100644 --- a/app/Config/Modules.php +++ b/app/Config/Modules.php @@ -31,6 +31,29 @@ class Modules extends BaseModules */ public $discoverInComposer = true; + /** + * The Composer package list for Auto-Discovery + * This setting is optional. + * + * E.g.: + * [ + * 'only' => [ + * // List up all packages to auto-discover + * 'codeigniter4/shield', + * ], + * ] + * or + * [ + * 'exclude' => [ + * // List up packages to exclude. + * 'pestphp/pest', + * ], + * ] + * + * @var array + */ + public $composerPackages = []; + /** * -------------------------------------------------------------------------- * Auto-Discovery Rules diff --git a/app/Config/MyBB.php b/app/Config/MyBB.php index 58c71985..a0b43940 100644 --- a/app/Config/MyBB.php +++ b/app/Config/MyBB.php @@ -23,7 +23,7 @@ class MyBB extends BaseConfig * An array of user names to restrict our search for news articles to. * This simply helps limit the work to do. */ - public $newsUsernames = ['ciadmin', 'jlp', 'kilishan', 'Narf']; + public $newsUsernames = ['ciadmin', 'kilishan', 'kenjis', 'MGatner']; /** * -------------------------------------------------------------------------- diff --git a/app/Config/Pager.php b/app/Config/Pager.php index 92257538..e341f4d3 100644 --- a/app/Config/Pager.php +++ b/app/Config/Pager.php @@ -20,7 +20,7 @@ class Pager extends BaseConfig * * @var array */ - public $templates = [ + public array $templates = [ 'default_full' => 'CodeIgniter\Pager\Views\default_full', 'default_simple' => 'CodeIgniter\Pager\Views\default_simple', 'default_head' => 'CodeIgniter\Pager\Views\default_head', @@ -32,8 +32,6 @@ class Pager extends BaseConfig * -------------------------------------------------------------------------- * * The default number of results shown in a single page. - * - * @var int */ - public $perPage = 20; + public int $perPage = 20; } diff --git a/app/Config/Paths.php b/app/Config/Paths.php index bcdc20d5..d0035fbc 100644 --- a/app/Config/Paths.php +++ b/app/Config/Paths.php @@ -22,10 +22,8 @@ class Paths * * This must contain the name of your "system" folder. Include * the path if the folder is not in the same directory as this file. - * - * @var string */ - public $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system'; + public string $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system'; /** * --------------------------------------------------------------- @@ -37,11 +35,9 @@ class Paths * can also be renamed or relocated anywhere on your server. If * you do, use a full server path. * - * @see https://codeigniter.com/user_guide/general/managing_apps.html - * - * @var string + * @see http://codeigniter.com/user_guide/general/managing_apps.html */ - public $appDirectory = __DIR__ . '/..'; + public string $appDirectory = __DIR__ . '/..'; /** * --------------------------------------------------------------- @@ -53,10 +49,8 @@ class Paths * need write permission to a single place that can be tucked away * for maximum security, keeping it out of the app and/or * system directories. - * - * @var string */ - public $writableDirectory = __DIR__ . '/../../writable'; + public string $writableDirectory = __DIR__ . '/../../writable'; /** * --------------------------------------------------------------- @@ -64,10 +58,8 @@ class Paths * --------------------------------------------------------------- * * This variable must contain the name of your "tests" directory. - * - * @var string */ - public $testsDirectory = __DIR__ . '/../../tests'; + public string $testsDirectory = __DIR__ . '/../../tests'; /** * --------------------------------------------------------------- @@ -78,8 +70,6 @@ class Paths * contains the view files used by your application. By * default this is in `app/Views`. This value * is used when no value is provided to `Services::renderer()`. - * - * @var string */ - public $viewDirectory = __DIR__ . '/../Views'; + public string $viewDirectory = __DIR__ . '/../Views'; } diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 039f7e1c..36a3f5b2 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -5,12 +5,6 @@ // Create a new instance of our RouteCollection class. $routes = Services::routes(); -// Load the system's routing file first, so that the app and ENVIRONMENT -// can override as needed. -if (is_file(SYSTEMPATH . 'Config/Routes.php')) { - require SYSTEMPATH . 'Config/Routes.php'; -} - /* * -------------------------------------------------------------------- * Router Setup @@ -43,11 +37,6 @@ $routes->get('the-fine-print', 'FinePrint::index'); $routes->get('security-disclosures', 'Disclosures::index'); -// Blog -$routes->get('news', 'Blog::index'); -$routes->get('news/c/(:segment)', 'Blog::category/$1'); -$routes->get('news/(:segment)', 'Blog::post/$1'); - /** * -------------------------------------------------------------------- * Additional Routing diff --git a/app/Config/Security.php b/app/Config/Security.php index 107bd954..57be4ee4 100644 --- a/app/Config/Security.php +++ b/app/Config/Security.php @@ -15,7 +15,7 @@ class Security extends BaseConfig * * @var string 'cookie' or 'session' */ - public $csrfProtection = 'cookie'; + public string $csrfProtection = 'cookie'; /** * -------------------------------------------------------------------------- @@ -23,10 +23,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Randomize the CSRF Token for added security. - * - * @var bool */ - public $tokenRandomize = false; + public bool $tokenRandomize = false; /** * -------------------------------------------------------------------------- @@ -34,10 +32,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Token name for Cross Site Request Forgery protection. - * - * @var string */ - public $tokenName = 'csrf_test_name'; + public string $tokenName = 'csrf_test_name'; /** * -------------------------------------------------------------------------- @@ -45,10 +41,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Header name for Cross Site Request Forgery protection. - * - * @var string */ - public $headerName = 'X-CSRF-TOKEN'; + public string $headerName = 'X-CSRF-TOKEN'; /** * -------------------------------------------------------------------------- @@ -56,10 +50,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Cookie name for Cross Site Request Forgery protection. - * - * @var string */ - public $cookieName = 'csrf_cookie_name'; + public string $cookieName = 'csrf_cookie_name'; /** * -------------------------------------------------------------------------- @@ -69,10 +61,8 @@ 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; /** * -------------------------------------------------------------------------- @@ -80,10 +70,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Regenerate CSRF Token on every submission. - * - * @var bool */ - public $regenerate = true; + public bool $regenerate = true; /** * -------------------------------------------------------------------------- @@ -91,10 +79,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Redirect to previous page with error on failure. - * - * @var bool */ - public $redirect = true; + public bool $redirect = false; /** * -------------------------------------------------------------------------- @@ -109,9 +95,7 @@ class Security extends BaseConfig * * @see https://portswigger.net/web-security/csrf/samesite-cookies * - * @var string - * * @deprecated `Config\Cookie` $samesite property is used. */ - public $samesite = 'Lax'; + public string $samesite = 'Lax'; } diff --git a/app/Config/Session.php b/app/Config/Session.php new file mode 100644 index 00000000..ea834805 --- /dev/null +++ b/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/app/Config/Toolbar.php b/app/Config/Toolbar.php index 7183e133..1b7527c7 100644 --- a/app/Config/Toolbar.php +++ b/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, @@ -51,10 +51,8 @@ class Toolbar extends BaseConfig * * If set to false var data from the views will not be colleted. Usefull to * avoid high memory usage when there are lots of data passed to the view. - * - * @var bool */ - public $collectVarData = true; + public bool $collectVarData = true; /** * -------------------------------------------------------------------------- @@ -64,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; /** * -------------------------------------------------------------------------- @@ -76,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/'; /** * -------------------------------------------------------------------------- @@ -92,8 +86,6 @@ 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; } diff --git a/app/Config/UserAgents.php b/app/Config/UserAgents.php index e1dbfa63..fda73748 100644 --- a/app/Config/UserAgents.php +++ b/app/Config/UserAgents.php @@ -23,7 +23,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $platforms = [ + public array $platforms = [ 'windows nt 10.0' => 'Windows 10', 'windows nt 6.3' => 'Windows 8.1', 'windows nt 6.2' => 'Windows 8', @@ -78,7 +78,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $browsers = [ + public array $browsers = [ 'OPR' => 'Opera', 'Flock' => 'Flock', 'Edge' => 'Spartan', @@ -119,7 +119,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $mobiles = [ + public array $mobiles = [ // legacy array, old values commented out 'mobileexplorer' => 'Mobile Explorer', // 'openwave' => 'Open Wave', @@ -228,7 +228,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $robots = [ + public array $robots = [ 'googlebot' => 'Googlebot', 'msnbot' => 'MSNBot', 'baiduspider' => 'Baiduspider', diff --git a/app/Config/Validation.php b/app/Config/Validation.php index e0a03bdf..017dac5a 100644 --- a/app/Config/Validation.php +++ b/app/Config/Validation.php @@ -3,10 +3,10 @@ namespace Config; use CodeIgniter\Config\BaseConfig; -use CodeIgniter\Validation\CreditCardRules; -use CodeIgniter\Validation\FileRules; -use CodeIgniter\Validation\FormatRules; -use CodeIgniter\Validation\Rules; +use CodeIgniter\Validation\StrictRules\CreditCardRules; +use CodeIgniter\Validation\StrictRules\FileRules; +use CodeIgniter\Validation\StrictRules\FormatRules; +use CodeIgniter\Validation\StrictRules\Rules; class Validation extends BaseConfig { @@ -20,7 +20,7 @@ class Validation extends BaseConfig * * @var string[] */ - public $ruleSets = [ + public array $ruleSets = [ Rules::class, FormatRules::class, FileRules::class, @@ -33,7 +33,7 @@ class Validation extends BaseConfig * * @var array */ - public $templates = [ + public array $templates = [ 'list' => 'CodeIgniter\Validation\Views\list', 'single' => 'CodeIgniter\Validation\Views\single', ]; diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 8b3efa77..3575d621 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -43,6 +43,12 @@ abstract class BaseController extends Controller */ protected $github; + /** + * Be sure to declare properties for any property fetch you initialized. + * The creation of dynamic property is deprecated in PHP 8.2. + */ + // protected $session; + /** * Constructor. */ diff --git a/app/Database/Migrations/2020-10-29-035422_CreateForumsTable.php b/app/Database/Migrations/2020-10-29-035422_CreateForumsTable.php index 6e20e499..c8f9da28 100644 --- a/app/Database/Migrations/2020-10-29-035422_CreateForumsTable.php +++ b/app/Database/Migrations/2020-10-29-035422_CreateForumsTable.php @@ -20,6 +20,7 @@ public function up() { // fx_threads $this->forge->addField([ + 'fid' => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'autoincrement' => true], 'tid' => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'autoincrement' => true], 'subject' => ['type' => 'varchar', 'constraint' => 255], 'username' => ['type' => 'varchar', 'constraint' => 255], diff --git a/app/Database/Seeds/ForumSeeder.php b/app/Database/Seeds/ForumSeeder.php index cc065728..209895ad 100644 --- a/app/Database/Seeds/ForumSeeder.php +++ b/app/Database/Seeds/ForumSeeder.php @@ -19,11 +19,16 @@ class ForumSeeder extends Seeder { protected $threads = [ - ['subject' => 'Multi Table Select (Active Records)', 'username' => 'Han Solo', 'lastpost' => '1414737566', 'tid' => '407'], - ['subject' => 'unexpected end of file', 'username' => 'Yoda', 'lastpost' => '1414567370', 'tid' => '413'], - ['subject' => 'Status Enable & Disable Not Working', 'username' => 'Luke Skywalker', 'lastpost' => '1414567370', 'tid' => '403'], - ['subject' => 'waiting for CI3.0 version', 'username' => 'Princess Leia', 'lastpost' => '1414567370', 'tid' => '4'], - ['subject' => 'How i can select most common value with codeigniter', 'username' => 'Obi Wan Kenobi', 'lastpost' => '1414567370', 'tid' => '414'], + ['subject' => 'Multi Table Select (Active Records)', 'username' => 'Han Solo', 'lastpost' => '1414737566', 'tid' => '407', 'fid' => 1], + ['subject' => 'unexpected end of file', 'username' => 'Yoda', 'lastpost' => '1414567370', 'tid' => '408', 'fid' => 1], + ['subject' => 'Status Enable & Disable Not Working', 'username' => 'Luke Skywalker', 'lastpost' => '1414567370', 'tid' => '409', 'fid' => 1], + ['subject' => 'waiting for CI3.0 version', 'username' => 'Princess Leia', 'lastpost' => '1414567370', 'tid' => '410', 'fid' => 1], + ['subject' => 'How i can select most common value with codeigniter', 'username' => 'Obi Wan Kenobi', 'lastpost' => '1414567370', 'tid' => '411', 'fid' => 1], + ['subject' => 'CodeIgniter 4.3.7 released', 'username' => 'ciadmin', 'lastpost' => '1414737566', 'tid' => '412', 'fid' => 2], + ['subject' => 'CodeIgniter 4.3.6 released', 'username' => 'ciadmin', 'lastpost' => '1414567370', 'tid' => '413', 'fid' => 2], + ['subject' => 'Shield Authentication Library', 'username' => 'ciadmin', 'lastpost' => '1414567370', 'tid' => '414', 'fid' => 2], + ['subject' => 'Settings Library released', 'username' => 'ciadmin', 'lastpost' => '1414567370', 'tid' => '415', 'fid' => 2], + ['subject' => 'Tasks Library released', 'username' => 'ciadmin', 'lastpost' => '1414567370', 'tid' => '416', 'fid' => 2], ]; public function run() diff --git a/app/Libraries/Forums.php b/app/Libraries/Forums.php index 205fd05a..1ceca357 100644 --- a/app/Libraries/Forums.php +++ b/app/Libraries/Forums.php @@ -61,4 +61,29 @@ public function posts($params = []) return view('forum/_drats'); } + + public function news($params = []) + { + $limit = $params['limit'] ?? $this->limit; + + // get the forum posts + if (! $items = cache('bb_news')) { + $items = $this->mybb->getRecentNews($limit); + $ttl = 60 * 60 * 4; // time to live s/b 4 hours + cache()->save('bb_news', $items, $ttl); + } + + if (! empty($items) && is_array($items)) { + // massage the date formats + foreach ($items as &$item) { + $item['lastpost'] = date('Y.m.d', $item['lastpost']); + $item['mybb_forum_url'] = $this->forumUrl; + $item['subject'] = strip_tags($item['subject']); // fix #79 + } + + return view('forum/_posts', ['posts' => $items]); + } + + return view('forum/_drats'); + } } diff --git a/app/Models/MyBBModel.php b/app/Models/MyBBModel.php index 6af122d5..86d864c8 100644 --- a/app/Models/MyBBModel.php +++ b/app/Models/MyBBModel.php @@ -18,19 +18,18 @@ class MyBBModel extends Model protected $useAutoIncrement = true; protected $returnType = 'array'; protected $allowedFields = [ - 'tid', 'subject', 'username', 'lastpost', 'lastposter', 'visible', 'deletetime', + 'fid', 'tid', 'subject', 'username', 'lastpost', 'lastposter', 'visible', 'deletetime', ]; /** * Grabs the most recently active threads from the forums. * - * @param int $limit - * @param string $order - * * @return array|null */ - public function getRecentPosts($limit = 5, $order = 'desc') + public function getRecentPosts(int $limit = 5, string $order = 'desc') { + $forumId = config('MyBB')->newsForumId; + $where = [ 'visible' => 1, 'deletetime' => 0, @@ -39,10 +38,37 @@ public function getRecentPosts($limit = 5, $order = 'desc') $builder = $this->db->table('fx_threads'); $query = $builder->select('tid, subject, username, lastpost, lastposter') ->where($where) + ->where('fid != ' . $forumId) ->limit($limit, 0) ->orderBy('lastpost', $order) ->get(); return $query->getResultArray(); } + + /** + * Grabs the most recent announcements from the forums. + * + * @return array + */ + public function getRecentNews(int $limit = 5, string $order = 'desc') + { + $admins = config('MyBB')->newsUsernames; + $forumId = config('MyBB')->newsForumId; + + $where = [ + 'fid' => $forumId, + 'visible' => 1, + 'deletetime' => 0, + ]; + + $builder = $this->db->table('fx_threads'); + $query = $builder->select('tid, subject, username, lastpost, lastposter') + ->where($where) + ->whereIn('username', $admins) + ->orderBy('lastpost', $order) + ->get(); + + return $query->getResultArray(); + } } diff --git a/app/Views/contribute.php b/app/Views/contribute.php index 382d9b6e..5cce03f3 100644 --- a/app/Views/contribute.php +++ b/app/Views/contribute.php @@ -12,7 +12,7 @@
-
+

CodeIgniter is a community driven project and accepts contributions of code and documentation from the community. These contributions are made in the form of Issues diff --git a/app/Views/disclosures.php b/app/Views/disclosures.php index 097aea2f..7d73bb57 100644 --- a/app/Views/disclosures.php +++ b/app/Views/disclosures.php @@ -10,12 +10,12 @@

-

The following items have been reported to the CodeIgniter core team and addressed as potential security +

The following items have been reported to the CodeIgniter core team and addressed as potential security concerns. Not all of them will affect your sites, but you should periodically review this list to determine any threats.

-

These disclosures are primarily aimed at the website and surrounding environment. Security disclosures +

These disclosures are primarily aimed at the website and surrounding environment. Security disclosures affecting the framework will be handled through GitHub's built-in Security Advisors functionality.

diff --git a/app/Views/discuss.php b/app/Views/discuss.php index 828cb190..0f033da7 100644 --- a/app/Views/discuss.php +++ b/app/Views/discuss.php @@ -40,7 +40,7 @@

The forum is where you can ask for help or discuss issues you are having with framework.
- Visit The Forum + Visit The Forum



@@ -57,7 +57,7 @@ class="link-primary" target="_blank">signup for it :)

- Slack + Slack



@@ -77,8 +77,8 @@ class="link-primary" target="_blank">signup for it :) Github issues are also used for tracking planned and approved enhancements, often tied in to specific releases.

- CodeIgniter 3 - CodeIgniter 4 + CodeIgniter 3 + CodeIgniter 4



diff --git a/app/Views/download.php b/app/Views/download.php index 182d8816..7b4504dc 100644 --- a/app/Views/download.php +++ b/app/Views/download.php @@ -21,11 +21,11 @@

@@ -42,10 +42,10 @@
diff --git a/app/Views/errors/html/error_404.php b/app/Views/errors/html/error_404.php index 5ba9f8ad..c3010132 100644 --- a/app/Views/errors/html/error_404.php +++ b/app/Views/errors/html/error_404.php @@ -2,7 +2,7 @@ - 404 Page Not Found + <?= lang('Errors.pageNotFound') ?> - @@ -77,16 +82,16 @@   —   - - ( arguments ) -
+ + ( arguments ) +
getParameters(); } @@ -189,7 +194,7 @@
- +
@@ -283,21 +288,11 @@ - - - - - - - - + + + + +
getName(), 'html') ?>getValueLine(), 'html') ?>
getName(), 'html') ?>getValueLine(), 'html') ?>
@@ -307,7 +302,7 @@ setStatusCode(http_response_code()); ?>
@@ -332,7 +327,7 @@ - $value) : ?> + getHeaderLine($name), 'html') ?> @@ -387,7 +382,7 @@

Displayed at — PHP: — - CodeIgniter: + CodeIgniter:

diff --git a/app/Views/errors/html/production.php b/app/Views/errors/html/production.php index 9faa4a15..2f59a8de 100644 --- a/app/Views/errors/html/production.php +++ b/app/Views/errors/html/production.php @@ -4,9 +4,9 @@ - Whoops! + <?= lang('Errors.whoops') ?> - @@ -14,9 +14,9 @@
-

Whoops!

+

-

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

+

diff --git a/app/Views/forum/_posts.php b/app/Views/forum/_posts.php index 1391133c..45e0b4fa 100644 --- a/app/Views/forum/_posts.php +++ b/app/Views/forum/_posts.php @@ -2,7 +2,8 @@
diff --git a/app/Views/home.php b/app/Views/home.php index 229e13a1..01039a72 100644 --- a/app/Views/home.php +++ b/app/Views/home.php @@ -2,9 +2,9 @@ section('headerAssets') ?> endSection() ?> section('content') ?> @@ -66,7 +66,7 @@
- +
Framework with a small footprint
@@ -79,7 +79,7 @@
- +
Exceptional performance
@@ -96,7 +96,7 @@
- +
Simple solutions over complexity
@@ -109,7 +109,7 @@
- +
Strong Security
@@ -127,7 +127,7 @@
- +
Clear documentation
@@ -140,7 +140,7 @@
- +
Nearly zero configuration
@@ -183,7 +183,7 @@
@@ -218,7 +218,7 @@
Recent News
- +
@@ -236,4 +236,3 @@
endSection() ?> - diff --git a/app/Views/layouts/_footer.php b/app/Views/layouts/_footer.php index 6889be17..e1bcdae1 100644 --- a/app/Views/layouts/_footer.php +++ b/app/Views/layouts/_footer.php @@ -4,7 +4,6 @@ Policies The Fine Print Security Disclosures - News Discuss Contribute Download @@ -14,7 +13,7 @@