diff --git a/.idea/safekat.iml b/.idea/safekat.iml index 30e3cdd1..c956989b 100755 --- a/.idea/safekat.iml +++ b/.idea/safekat.iml @@ -1,13 +1,7 @@ - - - - - - - + diff --git a/ci4/app/Config/CURLRequest.php b/ci4/app/Config/CURLRequest.php index b3552baa..5a3d4e93 100644 --- a/ci4/app/Config/CURLRequest.php +++ b/ci4/app/Config/CURLRequest.php @@ -1,6 +1,6 @@ */ - public $file = [ + public array $file = [ 'storePath' => WRITEPATH . 'cache/', 'mode' => 0640, ]; @@ -120,9 +124,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, @@ -138,7 +142,7 @@ class Cache extends BaseConfig * * @var array */ - public $redis = [ + public array $redis = [ 'host' => '127.0.0.1', 'password' => null, 'port' => 6379, @@ -154,9 +158,9 @@ class Cache extends BaseConfig * This is an array of cache engine alias' and class names. Only engines * that are listed here are allowed to be used. * - * @var array + * @var array> */ - public $validHandlers = [ + public array $validHandlers = [ 'dummy' => DummyHandler::class, 'file' => FileHandler::class, 'memcached' => MemcachedHandler::class, diff --git a/ci4/app/Config/Constants.php b/ci4/app/Config/Constants.php index 8f8498a5..47b92f83 100755 --- a/ci4/app/Config/Constants.php +++ b/ci4/app/Config/Constants.php @@ -38,9 +38,9 @@ defined('MINUTE') || define('MINUTE', 60); defined('HOUR') || define('HOUR', 3600); defined('DAY') || define('DAY', 86400); defined('WEEK') || define('WEEK', 604800); -defined('MONTH') || define('MONTH', 2592000); -defined('YEAR') || define('YEAR', 31536000); -defined('DECADE') || define('DECADE', 315360000); +defined('MONTH') || define('MONTH', 2_592_000); +defined('YEAR') || define('YEAR', 31_536_000); +defined('DECADE') || define('DECADE', 315_360_000); /* | -------------------------------------------------------------------------- @@ -67,13 +67,28 @@ defined('DECADE') || define('DECADE', 315360000); | http://tldp.org/LDP/abs/html/exitcodes.html | */ -defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors -defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error -defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error -defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found -defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class +defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors +defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error +defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error +defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found +defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member -defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input -defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error -defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code -defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code +defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input +defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error +defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code +defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code + +/** + * @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead. + */ +define('EVENT_PRIORITY_LOW', 200); + +/** + * @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead. + */ +define('EVENT_PRIORITY_NORMAL', 100); + +/** + * @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead. + */ +define('EVENT_PRIORITY_HIGH', 10); diff --git a/ci4/app/Config/ContentSecurityPolicy.php b/ci4/app/Config/ContentSecurityPolicy.php index 6fa5bd7b..7799c476 100755 --- a/ci4/app/Config/ContentSecurityPolicy.php +++ b/ci4/app/Config/ContentSecurityPolicy.php @@ -15,38 +15,32 @@ use CodeIgniter\Config\BaseConfig; */ class ContentSecurityPolicy extends BaseConfig { - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- // Broadbrush CSP management - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- /** * 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 - // Note: once you set a policy to 'none', it cannot be further restricted - //------------------------------------------------------------------------- + // NOTE: once you set a policy to 'none', it cannot be further restricted + // ------------------------------------------------------------------------- /** * Will default to self if not overridden @@ -164,4 +158,19 @@ class ContentSecurityPolicy extends BaseConfig * @var string|string[]|null */ public $sandbox; + + /** + * Nonce tag for style + */ + public string $styleNonceTag = '{csp-style-nonce}'; + + /** + * Nonce tag for script + */ + public string $scriptNonceTag = '{csp-script-nonce}'; + + /** + * Replace nonce tag automatically + */ + public bool $autoNonce = true; } diff --git a/ci4/app/Config/DocTypes.php b/ci4/app/Config/DocTypes.php index 6f166936..7e8aaacf 100755 --- a/ci4/app/Config/DocTypes.php +++ b/ci4/app/Config/DocTypes.php @@ -2,6 +2,9 @@ namespace Config; +/** + * @immutable + */ class DocTypes { /** @@ -9,7 +12,7 @@ class DocTypes * * @var array */ - public $list = [ + public array $list = [ 'xhtml11' => '', 'xhtml1-strict' => '', 'xhtml1-trans' => '', @@ -30,4 +33,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/ci4/app/Config/Email.php b/ci4/app/Config/Email.php index 8da5812d..43b3edb0 100755 --- a/ci4/app/Config/Email.php +++ b/ci4/app/Config/Email.php @@ -6,165 +6,116 @@ use CodeIgniter\Config\BaseConfig; class Email extends BaseConfig { - /** - * @var string - */ - public $fromEmail; - - /** - * @var string - */ - public $fromName; - - /** - * @var string - */ - public $recipients; + public string $fromEmail = 'safekat@imnavajas.es'; + public string $fromName = 'Safekat ERP'; + public string $recipients = ''; /** * The "user agent" - * - * @var string */ - public $userAgent = 'Safekat ERP'; + public string $userAgent = 'Safekat SL'; /** * The mail sending protocol: mail, sendmail, smtp - * - * @var string */ - public $protocol = 'smtp'; + public string $protocol = 'smtp'; /** * The server path to Sendmail. - * - * @var string */ - public $mailPath = '/usr/sbin/sendmail'; + public string $mailPath = '/usr/sbin/sendmail'; /** - * SMTP Server Address - * - * @var string + * SMTP Server Hostname */ - public $SMTPHost = "imnavajas.es"; + public string $SMTPHost = 'imnavajas.es'; /** * SMTP Username - * - * @var string */ - public $SMTPUser = "safekat@imnavajas.es"; + public string $SMTPUser = 'safekat@imnavajas.es'; /** * SMTP Password - * - * @var string */ - public $SMTPPass = "Etkd9~448"; + public string $SMTPPass = 'Etkd9~448'; /** * 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 + * SMTP Encryption. * - * @var string + * @var string '', 'tls' or 'ssl'. 'tls' will issue a STARTTLS command + * to the server. 'ssl' means implicit SSL. Connection on port + * 465 should set this to ''. */ - 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 = 'html'; + public string $mailType = 'html'; /** * 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/ci4/app/Config/Encryption.php b/ci4/app/Config/Encryption.php index 07b45a0b..28344134 100755 --- a/ci4/app/Config/Encryption.php +++ b/ci4/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'. - * - * @var string */ - public $digest = '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. + * + * Set to 'AES-128-CBC' to decrypt encrypted data that encrypted + * by CI3 Encryption default configuration. + */ + public string $cipher = 'AES-256-CTR'; } diff --git a/ci4/app/Config/Feature.php b/ci4/app/Config/Feature.php new file mode 100644 index 00000000..0bc45c6f --- /dev/null +++ b/ci4/app/Config/Feature.php @@ -0,0 +1,30 @@ + */ - public $formatters = [ - 'application/json' => 'CodeIgniter\Format\JSONFormatter', - 'application/xml' => 'CodeIgniter\Format\XMLFormatter', - 'text/xml' => 'CodeIgniter\Format\XMLFormatter', + public array $formatters = [ + 'application/json' => JSONFormatter::class, + 'application/xml' => XMLFormatter::class, + 'text/xml' => XMLFormatter::class, ]; /** @@ -55,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/ci4/app/Config/Generators.php b/ci4/app/Config/Generators.php index c47153d4..6566a31e 100755 --- a/ci4/app/Config/Generators.php +++ b/ci4/app/Config/Generators.php @@ -25,8 +25,11 @@ 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', 'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php', 'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php', diff --git a/ci4/app/Config/Honeypot.php b/ci4/app/Config/Honeypot.php index 42b5a0dc..67ebcb0e 100755 --- a/ci4/app/Config/Honeypot.php +++ b/ci4/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 $container = '
{template}
'; + public string $container = '
{template}
'; + + /** + * The id attribute for Honeypot container tag + * + * Used when CSP is enabled. + */ + public string $containerId = 'hpc'; } diff --git a/ci4/app/Config/Images.php b/ci4/app/Config/Images.php index 1c15d815..a33ddadb 100755 --- a/ci4/app/Config/Images.php +++ b/ci4/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/ci4/app/Config/Logger.php b/ci4/app/Config/Logger.php index a4eaeb64..568c5da6 100755 --- a/ci4/app/Config/Logger.php +++ b/ci4/app/Config/Logger.php @@ -3,6 +3,7 @@ namespace Config; use CodeIgniter\Config\BaseConfig; +use CodeIgniter\Log\Handlers\FileHandler; class Logger extends BaseConfig { @@ -37,7 +38,7 @@ class Logger extends BaseConfig * * @var array|int */ - public $threshold = 4; + public $threshold = (ENVIRONMENT === 'production') ? 4 : 9; /** * -------------------------------------------------------------------------- @@ -46,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'; /** * -------------------------------------------------------------------------- @@ -73,18 +72,14 @@ 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 = [ /* * -------------------------------------------------------------------- * File Handler * -------------------------------------------------------------------- */ - 'CodeIgniter\Log\Handlers\FileHandler' => [ - + FileHandler::class => [ // The log levels that this handler will handle. 'handles' => [ 'critical', @@ -102,7 +97,7 @@ class Logger extends BaseConfig * An extension of 'php' allows for protecting the log files via basic * scripting, when they are to be stored under a publicly accessible directory. * - * Note: Leaving it blank will default to 'log'. + * NOTE: Leaving it blank will default to 'log'. */ 'fileExtension' => '', @@ -140,14 +135,14 @@ class Logger extends BaseConfig * Uncomment this block to use it. */ // 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [ - // /* The log levels this handler can handle. */ - // 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'], + // /* The log levels this handler can handle. */ + // 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'], // - // /* - // * The message type where the error should go. Can be 0 or 4, or use the - // * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4) - // */ - // 'messageType' => 0, + // /* + // * The message type where the error should go. Can be 0 or 4, or use the + // * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4) + // */ + // 'messageType' => 0, // ], ]; } diff --git a/ci4/app/Config/Migrations.php b/ci4/app/Config/Migrations.php index 91e80b4a..1dec8b9b 100755 --- a/ci4/app/Config/Migrations.php +++ b/ci4/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; /** * -------------------------------------------------------------------------- @@ -27,13 +25,9 @@ class Migrations extends BaseConfig * * This is the name of the table that will store the current migrations state. * When migrations runs it will store in a database table which migration - * 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 + * files have already been run. */ - public $table = 'migrations'; + public string $table = 'migrations'; /** * -------------------------------------------------------------------------- @@ -42,14 +36,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/ci4/app/Config/Mimes.php b/ci4/app/Config/Mimes.php index 973fb398..d02df1ab 100755 --- a/ci4/app/Config/Mimes.php +++ b/ci4/app/Config/Mimes.php @@ -15,15 +15,15 @@ namespace Config; * * When working with mime types, please make sure you have the ´fileinfo´ * extension enabled to reliably detect the media types. + * + * @immutable */ 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 +55,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', @@ -102,8 +104,6 @@ class Mimes ], 'pptx' => [ 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'application/x-zip', - 'application/zip', ], 'wbxml' => 'application/wbxml', 'wmlc' => 'application/wmlc', @@ -260,6 +260,7 @@ class Mimes 'image/png', 'image/x-png', ], + 'webp' => 'image/webp', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'css' => [ @@ -509,22 +510,21 @@ class Mimes { $type = trim(strtolower($type), '. '); - $proposedExtension = trim(strtolower($proposedExtension)); + $proposedExtension = trim(strtolower($proposedExtension ?? '')); - if ($proposedExtension !== '') { - if (array_key_exists($proposedExtension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposedExtension]) ? [static::$mimes[$proposedExtension]] : static::$mimes[$proposedExtension], true)) { - // The detected mime type matches with the proposed extension. - return $proposedExtension; - } - - // An extension was proposed, but the media type does not match the mime type list. - return null; + if ( + $proposedExtension !== '' + && array_key_exists($proposedExtension, static::$mimes) + && in_array($type, (array) static::$mimes[$proposedExtension], true) + ) { + // The detected mime type matches with the proposed extension. + return $proposedExtension; } // Reverse check the mime type list if no extension was proposed. // This search is order sensitive! foreach (static::$mimes as $ext => $types) { - if ((is_string($types) && $types === $type) || (is_array($types) && in_array($type, $types, true))) { + if (in_array($type, (array) $types, true)) { return $ext; } } diff --git a/ci4/app/Config/Modules.php b/ci4/app/Config/Modules.php index bde4079f..8d4bf565 100755 --- a/ci4/app/Config/Modules.php +++ b/ci4/app/Config/Modules.php @@ -4,6 +4,14 @@ namespace Config; use CodeIgniter\Modules\Modules as BaseModules; +/** + * Modules Configuration. + * + * NOTE: This class is required prior to Autoloader instantiation, + * and does not extend BaseConfig. + * + * @immutable + */ class Modules extends BaseModules { /** @@ -31,6 +39,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{only?: list, exclude?: list} + */ + public $composerPackages = []; + /** * -------------------------------------------------------------------------- * Auto-Discovery Rules @@ -41,7 +72,7 @@ class Modules extends BaseModules * * If it is not listed, only the base application elements will be used. * - * @var string[] + * @var list */ public $aliases = [ 'events', diff --git a/ci4/app/Config/Pager.php b/ci4/app/Config/Pager.php index 92257538..e341f4d3 100755 --- a/ci4/app/Config/Pager.php +++ b/ci4/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/ci4/app/Config/Paths.php b/ci4/app/Config/Paths.php index d97bbb35..d0035fbc 100755 --- a/ci4/app/Config/Paths.php +++ b/ci4/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'; /** * --------------------------------------------------------------- @@ -34,14 +32,12 @@ class Paths * * If you want this front controller to use a different "app" * folder than the default one you can set its name here. The folder - * can also be renamed or relocated anywhere on your getServer. If - * you do, use a full getServer path. + * can also be renamed or relocated anywhere on your server. If + * you do, use a full server path. * * @see http://codeigniter.com/user_guide/general/managing_apps.html - * - * @var string */ - 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/ci4/app/Config/UserAgents.php b/ci4/app/Config/UserAgents.php index e1dbfa63..fda73748 100755 --- a/ci4/app/Config/UserAgents.php +++ b/ci4/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/ci4/app/Config/Validation.php b/ci4/app/Config/Validation.php index 7570f6ae..a93a7146 100755 --- a/ci4/app/Config/Validation.php +++ b/ci4/app/Config/Validation.php @@ -2,18 +2,17 @@ namespace Config; +use CodeIgniter\Config\BaseConfig; +use CodeIgniter\Validation\StrictRules\CreditCardRules; +use CodeIgniter\Validation\StrictRules\FileRules; +use CodeIgniter\Validation\StrictRules\FormatRules; +use CodeIgniter\Validation\StrictRules\Rules; -use CodeIgniter\Shield\Authentication\Passwords\ValidationRules; -use CodeIgniter\Validation\CreditCardRules; -use CodeIgniter\Validation\FileRules; -use CodeIgniter\Validation\FormatRules; -use CodeIgniter\Validation\Rules; - -class Validation +class Validation extends BaseConfig { - //-------------------------------------------------------------------- + // -------------------------------------------------------------------- // Setup - //-------------------------------------------------------------------- + // -------------------------------------------------------------------- /** * Stores the classes that contain the @@ -26,7 +25,6 @@ class Validation FormatRules::class, FileRules::class, CreditCardRules::class, - ValidationRules::class, ]; /** @@ -39,44 +37,9 @@ class Validation 'list' => 'CodeIgniter\Validation\Views\list', 'single' => 'CodeIgniter\Validation\Views\single', 'bootstrap_style' => 'themes/_commonPartialsBs/_form_validation_errors', - ]; - //-------------------------------------------------------------------- + // -------------------------------------------------------------------- // Rules - //-------------------------------------------------------------------- - //-------------------------------------------------------------------- - // Rules For Login - //-------------------------------------------------------------------- - /*public $login = [ - // 'username' => [ - // 'label' => 'Auth.username', - // 'rules' => [ - // 'required', - // 'max_length[30]', - // 'min_length[3]', - // 'regex_match[/\A[a-zA-Z0-9\.]+\z/]', - // ], - // ], - 'email' => [ - 'label' => 'Auth.email', - 'rules' => [ - 'required', - 'max_length[254]', - 'valid_email' - ], - ], - 'password' => [ - 'label' => 'Auth.password', - 'rules' => [ - 'required', - 'max_byte[72]', - ], - 'errors' => [ - 'max_byte' => 'Auth.errorPasswordTooLongBytes', - ] - ], - ];*/ - - + // -------------------------------------------------------------------- } diff --git a/ci4/app/Config/View.php b/ci4/app/Config/View.php index 024e8302..cf00863f 100755 --- a/ci4/app/Config/View.php +++ b/ci4/app/Config/View.php @@ -3,7 +3,12 @@ namespace Config; use CodeIgniter\Config\View as BaseView; +use CodeIgniter\View\ViewDecoratorInterface; +/** + * @phpstan-type ParserCallable (callable(mixed): mixed) + * @phpstan-type ParserCallableString (callable(mixed): mixed)&string + */ class View extends BaseView { /** @@ -29,7 +34,8 @@ class View extends BaseView * { title|esc(js) } * { created_on|date(Y-m-d)|esc(attr) } * - * @var array + * @var array + * @phpstan-var array */ public $filters = []; @@ -38,7 +44,19 @@ class View extends BaseView * by the core Parser by creating aliases that will be replaced with * any callable. Can be single or tag pair. * - * @var array + * @var array|callable|string> + * @phpstan-var array|ParserCallableString|ParserCallable> */ public $plugins = []; + + /** + * View Decorators are class methods that will be run in sequence to + * have a chance to alter the generated output just prior to caching + * the results. + * + * All classes must implement CodeIgniter\View\ViewDecoratorInterface + * + * @var class-string[] + */ + public array $decorators = []; } diff --git a/ci4/app/Language/en/Auth.php b/ci4/app/Language/en/Auth.php new file mode 100644 index 00000000..6f34fe3e --- /dev/null +++ b/ci4/app/Language/en/Auth.php @@ -0,0 +1,117 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +return [ + // Exceptions + 'unknownAuthenticator' => '{0} is not a valid authenticator.', + 'unknownUserProvider' => 'Unable to determine the User Provider to use.', + 'invalidUser' => 'Unable to locate the specified user.', + 'bannedUser' => 'Can not log you in as you are currently banned.', + 'logOutBannedUser' => 'You have been logged out because you have been banned.', + 'badAttempt' => 'Unable to log you in. Please check your credentials.', + 'noPassword' => 'Cannot validate a user without a password.', + 'invalidPassword' => 'Unable to log you in. Please check your password.', + 'noToken' => 'Every request must have a bearer token in the {0} header.', + 'badToken' => 'The access token is invalid.', + 'oldToken' => 'The access token has expired.', + 'noUserEntity' => 'User Entity must be provided for password validation.', + 'invalidEmail' => 'Unable to verify the email address matches the email on record.', + 'unableSendEmailToUser' => 'Sorry, there was a problem sending the email. We could not send an email to "{0}".', + 'throttled' => 'Too many requests made from this IP address. You may try again in {0} seconds.', + 'notEnoughPrivilege' => 'You do not have the necessary permission to perform the desired operation.', + // JWT Exceptions + 'invalidJWT' => 'The token is invalid.', + 'expiredJWT' => 'The token has expired.', + 'beforeValidJWT' => 'The token is not yet available.', + + 'email' => 'Email Address', + 'username' => 'Username', + 'password' => 'Password', + 'passwordConfirm' => 'Password (again)', + 'haveAccount' => 'Already have an account?', + 'token' => 'Token', + + // Buttons + 'confirm' => 'Confirm', + 'send' => 'Send', + + // Registration + 'register' => 'Register', + 'registerDisabled' => 'Registration is not currently allowed.', + 'registerSuccess' => 'Welcome aboard!', + + // Login + 'login' => 'Login', + 'needAccount' => 'Need an account?', + 'rememberMe' => 'Remember me?', + 'forgotPassword' => 'Forgot your password?', + 'useMagicLink' => 'Use a Login Link', + 'magicLinkSubject' => 'Your Login Link', + 'magicTokenNotFound' => 'Unable to verify the link.', + 'magicLinkExpired' => 'Sorry, link has expired.', + 'checkYourEmail' => 'Check your email!', + 'magicLinkDetails' => 'We just sent you an email with a Login link inside. It is only valid for {0} minutes.', + 'magicLinkDisabled' => 'Use of MagicLink is currently not allowed.', + 'successLogout' => 'You have successfully logged out.', + 'backToLogin' => 'Back to Login', + + // Passwords + 'errorPasswordLength' => 'Passwords must be at least {0, number} characters long.', + 'suggestPasswordLength' => 'Pass phrases - up to 255 characters long - make more secure passwords that are easy to remember.', + 'errorPasswordCommon' => 'Password must not be a common password.', + 'suggestPasswordCommon' => 'The password was checked against over 65k commonly used passwords or passwords that have been leaked through hacks.', + 'errorPasswordPersonal' => 'Passwords cannot contain re-hashed personal information.', + 'suggestPasswordPersonal' => 'Variations on your email address or username should not be used for passwords.', + 'errorPasswordTooSimilar' => 'Password is too similar to the username.', + 'suggestPasswordTooSimilar' => 'Do not use parts of your username in your password.', + 'errorPasswordPwned' => 'The password {0} has been exposed due to a data breach and has been seen {1, number} times in {2} of compromised passwords.', + 'suggestPasswordPwned' => '{0} should never be used as a password. If you are using it anywhere change it immediately.', + 'errorPasswordEmpty' => 'A Password is required.', + 'errorPasswordTooLongBytes' => 'Password cannot exceed {param} bytes in length.', + 'passwordChangeSuccess' => 'Password changed successfully', + 'userDoesNotExist' => 'Password was not changed. User does not exist', + 'resetTokenExpired' => 'Sorry. Your reset token has expired.', + + // Email Globals + 'emailInfo' => 'Some information about the person:', + 'emailIpAddress' => 'IP Address:', + 'emailDevice' => 'Device:', + 'emailDate' => 'Date:', + + // 2FA + 'email2FATitle' => 'Two Factor Authentication', + 'confirmEmailAddress' => 'Confirm your email address.', + 'emailEnterCode' => 'Confirm your Email', + 'emailConfirmCode' => 'Enter the 6-digit code we just sent to your email address.', + 'email2FASubject' => 'Your authentication code', + 'email2FAMailBody' => 'Your authentication code is:', + 'invalid2FAToken' => 'The code was incorrect.', + 'need2FA' => 'You must complete a two-factor verification.', + 'needVerification' => 'Check your email to complete account activation.', + + // Activate + 'emailActivateTitle' => 'Email Activation', + 'emailActivateBody' => 'We just sent an email to you with a code to confirm your email address. Copy that code and paste it below.', + 'emailActivateSubject' => 'Your activation code', + 'emailActivateMailBody' => 'Please use the code below to activate your account and start using the site.', + 'invalidActivateToken' => 'The code was incorrect.', + 'needActivate' => 'You must complete your registration by confirming the code sent to your email address.', + 'activationBlocked' => 'You must activate your account before logging in.', + + // Groups + 'unknownGroup' => '{0} is not a valid group.', + 'missingTitle' => 'Groups must have a title.', + + // Permissions + 'unknownPermission' => '{0} is not a valid permission.', +]; diff --git a/ci4/app/Language/es/Auth.php b/ci4/app/Language/es/Auth.php new file mode 100644 index 00000000..def23c16 --- /dev/null +++ b/ci4/app/Language/es/Auth.php @@ -0,0 +1,117 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +return [ + // Excepciones + 'unknownAuthenticator' => '{0} no es un autenticador válido.', + 'unknownUserProvider' => 'No se puede determinar el proveedor de usuario a utilizar.', + 'invalidUser' => 'No se puede localizar al usuario especificado.', + 'bannedUser' => 'No puedes iniciar sesión ya que estás actualmente vetado.', + 'logOutBannedUser' => 'Se ha cerrado la sesión porque se ha vetado al usuario.', + 'badAttempt' => 'No se puede iniciar sesión. Por favor, comprueba tus credenciales.', + 'noPassword' => 'No se puede validar un usuario sin contraseña.', + 'invalidPassword' => 'No se puede iniciar sesión. Por favor, comprueba tu contraseña.', + 'noToken' => 'Cada solicitud debe tener un token de portador en la cabecera {0}.', + 'badToken' => 'El token de acceso no es válido.', + 'oldToken' => 'El token de acceso ha caducado.', + 'noUserEntity' => 'Se debe proporcionar una entidad de usuario para la validación de contraseña.', + 'invalidEmail' => 'No se puede verificar que la dirección de correo electrónico coincida con la registrada.', + 'unableSendEmailToUser' => 'Lo siento, hubo un problema al enviar el correo electrónico. No pudimos enviar un correo electrónico a "{0}".', + 'throttled' => 'Se han realizado demasiadas solicitudes desde esta dirección IP. Puedes intentarlo de nuevo en {0} segundos.', + 'notEnoughPrivilege' => 'No tienes los permisos necesarios para realizar la operación deseada.', + // JWT Exceptions + 'invalidJWT' => '(To be translated) The token is invalid.', + 'expiredJWT' => '(To be translated) The token has expired.', + 'beforeValidJWT' => '(To be translated) The token is not yet available.', + + 'email' => 'Correo Electrónico', + 'username' => 'Nombre de usuario', + 'password' => 'Contraseña', + 'passwordConfirm' => 'Contraseña (otra vez)', + 'haveAccount' => '¿Ya tienes una cuenta?', + 'token' => '(To be translated) Token', + + // Botones + 'confirm' => 'Confirmar', + 'send' => 'Enviar', + + // Registro + 'register' => 'Registrarse', + 'registerDisabled' => 'Actualmente no se permite el registro.', + 'registerSuccess' => '¡Bienvenido a bordo!', + + // Login + 'login' => 'Iniciar sesión', + 'needAccount' => '¿Necesitas una cuenta?', + 'rememberMe' => 'Recordarme', + 'forgotPassword' => '¿Olvidaste tu contraseña?', + 'useMagicLink' => 'Usar un enlace de inicio de sesión', + 'magicLinkSubject' => 'Tu enlace de inicio de sesión', + 'magicTokenNotFound' => 'No se puede verificar el enlace.', + 'magicLinkExpired' => 'Lo siento, el enlace ha caducado.', + 'checkYourEmail' => '¡Revisa tu correo electrónico!', + 'magicLinkDetails' => 'Acabamos de enviarte un correo electrónico con un enlace de inicio de sesión. Solo es válido durante {0} minutos.', + 'magicLinkDisabled' => '(To be translated) Use of MagicLink is currently not allowed.', + 'successLogout' => 'Has cerrado sesión correctamente.', + 'backToLogin' => 'Volver al inicio de sesión', + + // Contraseñas + 'errorPasswordLength' => 'Las contraseñas deben tener al menos {0, number} caracteres.', + 'suggestPasswordLength' => 'Las frases de contraseña, de hasta 255 caracteres de longitud, hacen que las contraseñas sean más seguras y fáciles de recordar.', + 'errorPasswordCommon' => 'La contraseña no puede ser una contraseña común.', + 'suggestPasswordCommon' => 'La contraseña se comprobó frente a más de 65k contraseñas comúnmente utilizadas o contraseñas que se filtraron a través de ataques.', + 'errorPasswordPersonal' => 'Las contraseñas no pueden contener información personal reutilizada.', + 'suggestPasswordPersonal' => 'No se deben usar variaciones de su dirección de correo electrónico o nombre de usuario como contraseña.', + 'errorPasswordTooSimilar' => 'La contraseña es demasiado similar al nombre de usuario.', + 'suggestPasswordTooSimilar' => 'No use partes de su nombre de usuario en su contraseña.', + 'errorPasswordPwned' => 'La contraseña {0} se ha expuesto debido a una violación de datos y se ha visto {1, number} veces en {2} de contraseñas comprometidas.', + 'suggestPasswordPwned' => 'Nunca se debe usar {0} como contraseña. Si lo está utilizando en algún lugar, cambie su contraseña de inmediato.', + 'errorPasswordEmpty' => 'Se requiere una contraseña.', + 'errorPasswordTooLongBytes' => 'La contraseña no puede tener más de {param} caracteres', + 'passwordChangeSuccess' => 'Contraseña cambiada correctamente', + 'userDoesNotExist' => 'La contraseña no se cambió. El usuario no existe', + 'resetTokenExpired' => 'Lo siento. Su token de reinicio ha caducado.', + + // Email Globals + 'emailInfo' => 'Alguna información sobre la persona:', + 'emailIpAddress' => 'Dirección IP:', + 'emailDevice' => 'Dispositivo:', + 'emailDate' => 'Fecha:', + + // 2FA + 'email2FATitle' => 'Autenticación de dos factores', + 'confirmEmailAddress' => 'Confirma tu dirección de correo electrónico.', + 'emailEnterCode' => 'Confirma tu correo electrónico', + 'emailConfirmCode' => 'Ingresa el código de 6 dígitos que acabamos de enviar a tu correo electrónico.', + 'email2FASubject' => 'Tu código de autenticación', + 'email2FAMailBody' => 'Tu código de autenticación es:', + 'invalid2FAToken' => 'El código era incorrecto.', + 'need2FA' => 'Debes completar la verificación de dos factores.', + 'needVerification' => 'Verifica tu correo electrónico para completar la activación de la cuenta.', + + // Activar + 'emailActivateTitle' => 'Activación de correo electrónico', + 'emailActivateBody' => 'Acabamos de enviarte un correo electrónico con un código para confirmar tu dirección de correo electrónico. Copia ese código y pégalo a continuación.', + 'emailActivateSubject' => 'Tu código de activación', + 'emailActivateMailBody' => 'Utiliza el código siguiente para activar tu cuenta y comenzar a usar el sitio.', + 'invalidActivateToken' => 'El código era incorrecto.', + 'needActivate' => 'Debes completar tu registro confirmando el código enviado a tu dirección de correo electrónico.', + 'activationBlocked' => 'Debes activar tu cuenta antes de iniciar sesión.', + + // Grupos + 'unknownGroup' => '{0} no es un grupo válido.', + 'missingTitle' => 'Los grupos deben tener un título.', + + // Permisos + 'unknownPermission' => '{0} no es un permiso válido.', +]; diff --git a/ci4/composer.json b/ci4/composer.json index e0f6f959..29e24c40 100755 --- a/ci4/composer.json +++ b/ci4/composer.json @@ -1,24 +1,26 @@ { "name": "codeigniter4/appstarter", - "type": "project", "description": "CodeIgniter4 starter app", - "homepage": "https://codeigniter.com", "license": "MIT", + "type": "project", + "homepage": "https://codeigniter.com", + "support": { + "forum": "https://forum.codeigniter.com/", + "source": "https://github.com/codeigniter4/CodeIgniter4", + "slack": "https://codeigniterchat.slack.com" + }, "require": { "php": "^8.1", + "codeigniter4/framework": "^4.0", "codeigniter4/shield": "^1.0", - "codeigniter4/framework": "^4", - "phpoffice/phpspreadsheet": "^1.18", - "dompdf/dompdf": "^2.0" + "dompdf/dompdf": "^2.0", + //"phpoffice/phpspreadsheet": "^1.18" }, "require-dev": { "fakerphp/faker": "^1.9", "mikey179/vfsstream": "^1.6", "phpunit/phpunit": "^9.1" }, - "suggest": { - "ext-fileinfo": "Improves mime type detection for files" - }, "autoload": { "psr-4": { "App\\": "app", @@ -33,12 +35,12 @@ "Tests\\Support\\": "tests/_support" } }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, "scripts": { "test": "phpunit" - }, - "support": { - "forum": "http://forum.codeigniter.com/", - "source": "https://github.com/codeigniter4/CodeIgniter4", - "slack": "https://codeigniterchat.slack.com" } }