diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad151ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,126 @@ +#------------------------- +# Operating Specific Junk Files +#------------------------- + +# OS X +.DS_Store +.AppleDouble +.LSOverride + +# OS X Thumbnails +._* + +# Windows image file caches +Thumbs.db +ehthumbs.db +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Linux +*~ + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +#------------------------- +# Environment Files +#------------------------- +# These should never be under version control, +# as it poses a security risk. +.env +.vagrant +Vagrantfile + +#------------------------- +# Temporary Files +#------------------------- +writable/cache/* +!writable/cache/index.html + +writable/logs/* +!writable/logs/index.html + +writable/session/* +!writable/session/index.html + +writable/uploads/* +!writable/uploads/index.html + +writable/debugbar/* + +php_errors.log + +#------------------------- +# User Guide Temp Files +#------------------------- +user_guide_src/build/* +user_guide_src/cilexer/build/* +user_guide_src/cilexer/dist/* +user_guide_src/cilexer/pycilexer.egg-info/* + +#------------------------- +# Test Files +#------------------------- +tests/coverage* + +# Don't save phpunit under version control. +phpunit + +#------------------------- +# Composer +#------------------------- +vendor/ +composer.lock + +#------------------------- +# IDE / Development Files +#------------------------- + +# Modules Testing +_modules/* + +# phpenv local config +.php-version + +# Jetbrains editors (PHPStorm, etc) +.idea/ +*.iml + +# Netbeans +nbproject/ +build/ +nbbuild/ +dist/ +nbdist/ +nbactions.xml +nb-configuration.xml +.nb-gradle/ + +# Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache +*.sublime-workspace +*.sublime-project +.phpintel +/api/ + +# Visual Studio Code +.vscode/ + +/results/ +/phpunit*.xml \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..81ddccc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 CodeIgniter 4 web framework + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/app/.htaccess b/app/.htaccess new file mode 100644 index 0000000..f24db0a --- /dev/null +++ b/app/.htaccess @@ -0,0 +1,6 @@ + + Require all denied + + + Deny from all + diff --git a/app/Common.php b/app/Common.php new file mode 100644 index 0000000..780ba3f --- /dev/null +++ b/app/Common.php @@ -0,0 +1,15 @@ + SYSPATH + * `]; + */ + $psr4 = [ + 'Config' => APPPATH . 'Config', + APP_NAMESPACE => APPPATH, // For custom namespace + 'App' => APPPATH, // To ensure filters, etc still found, + ]; + + /** + * ------------------------------------------------------------------- + * Class Map + * ------------------------------------------------------------------- + * The class map provides a map of class names and their exact + * location on the drive. Classes loaded in this manner will have + * slightly faster performance because they will not have to be + * searched for within one or more directories as they would if they + * were being autoloaded through a namespace. + * + * Prototype: + * + * $Config['classmap'] = [ + * 'MyClass' => '/path/to/class/file.php' + * ]; + */ + $classmap = []; + + //-------------------------------------------------------------------- + // Do Not Edit Below This Line + //-------------------------------------------------------------------- + + $this->psr4 = array_merge($this->psr4, $psr4); + $this->classmap = array_merge($this->classmap, $classmap); + + unset($psr4, $classmap); + } + + //-------------------------------------------------------------------- + +} diff --git a/app/Config/Boot/development.php b/app/Config/Boot/development.php new file mode 100644 index 0000000..7d6ae48 --- /dev/null +++ b/app/Config/Boot/development.php @@ -0,0 +1,32 @@ + '127.0.0.1', + 'port' => 11211, + 'weight' => 1, + 'raw' => false, + ]; + + /* + | ------------------------------------------------------------------------- + | Redis settings + | ------------------------------------------------------------------------- + | Your Redis server can be specified below, if you are using + | the Redis or Predis drivers. + | + */ + public $redis = [ + 'host' => '127.0.0.1', + 'password' => null, + 'port' => 6379, + 'timeout' => 0, + 'database' => 0, + ]; + + /* + |-------------------------------------------------------------------------- + | Available Cache Handlers + |-------------------------------------------------------------------------- + | + | This is an array of cache engine alias' and class names. Only engines + | that are listed here are allowed to be used. + | + */ + public $validHandlers = [ + 'dummy' => \CodeIgniter\Cache\Handlers\DummyHandler::class, + 'file' => \CodeIgniter\Cache\Handlers\FileHandler::class, + 'memcached' => \CodeIgniter\Cache\Handlers\MemcachedHandler::class, + 'predis' => \CodeIgniter\Cache\Handlers\PredisHandler::class, + 'redis' => \CodeIgniter\Cache\Handlers\RedisHandler::class, + 'wincache' => \CodeIgniter\Cache\Handlers\WincacheHandler::class, + ]; +} diff --git a/app/Config/Constants.php b/app/Config/Constants.php new file mode 100644 index 0000000..b25f71c --- /dev/null +++ b/app/Config/Constants.php @@ -0,0 +1,77 @@ + '', + 'hostname' => 'localhost', + 'username' => '', + 'password' => '', + 'database' => '', + 'DBDriver' => 'MySQLi', + 'DBPrefix' => '', + 'pConnect' => false, + 'DBDebug' => (ENVIRONMENT !== 'production'), + 'cacheOn' => false, + 'cacheDir' => '', + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + ]; + + /** + * This database connection is used when + * running PHPUnit database tests. + * + * @var array + */ + public $tests = [ + 'DSN' => '', + 'hostname' => '127.0.0.1', + 'username' => '', + 'password' => '', + 'database' => '', + 'DBDriver' => '', + 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE. + 'pConnect' => false, + 'DBDebug' => (ENVIRONMENT !== 'production'), + 'cacheOn' => false, + 'cacheDir' => '', + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + ]; + + //-------------------------------------------------------------------- + + public function __construct() + { + parent::__construct(); + + // Ensure that we always set the database group to 'tests' if + // we are currently running an automated test suite, so that + // we don't overwrite live data on accident. + if (ENVIRONMENT === 'testing') + { + $this->defaultGroup = 'tests'; + + // Under Travis-CI, we can set an ENV var named 'DB_GROUP' + // so that we can test against multiple databases. + if ($group = getenv('DB')) + { + if (is_file(TESTPATH . 'travis/Database.php')) + { + require TESTPATH . 'travis/Database.php'; + + if (! empty($dbconfig) && array_key_exists($group, $dbconfig)) + { + $this->tests = $dbconfig[$group]; + } + } + } + } + } + + //-------------------------------------------------------------------- + +} diff --git a/app/Config/DocTypes.php b/app/Config/DocTypes.php new file mode 100755 index 0000000..67d5dd2 --- /dev/null +++ b/app/Config/DocTypes.php @@ -0,0 +1,33 @@ + '', + 'xhtml1-strict' => '', + 'xhtml1-trans' => '', + 'xhtml1-frame' => '', + 'xhtml-basic11' => '', + 'html5' => '', + 'html4-strict' => '', + 'html4-trans' => '', + 'html4-frame' => '', + 'mathml1' => '', + 'mathml2' => '', + 'svg10' => '', + 'svg11' => '', + 'svg11-basic' => '', + 'svg11-tiny' => '', + 'xhtml-math-svg-xh' => '', + 'xhtml-math-svg-sh' => '', + 'xhtml-rdfa-1' => '', + 'xhtml-rdfa-2' => '', + ]; +} diff --git a/app/Config/Email.php b/app/Config/Email.php new file mode 100644 index 0000000..d580c53 --- /dev/null +++ b/app/Config/Email.php @@ -0,0 +1,164 @@ + 0) + { + \ob_end_flush(); + } + + \ob_start(function ($buffer) { + return $buffer; + }); + + /* + * -------------------------------------------------------------------- + * Debug Toolbar Listeners. + * -------------------------------------------------------------------- + * If you delete, they will no longer be collected. + */ + if (ENVIRONMENT !== 'production') + { + Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect'); + Services::toolbar()->respond(); + } +}); diff --git a/app/Config/Exceptions.php b/app/Config/Exceptions.php new file mode 100644 index 0000000..c0245b2 --- /dev/null +++ b/app/Config/Exceptions.php @@ -0,0 +1,41 @@ + \CodeIgniter\Filters\CSRF::class, + 'toolbar' => \CodeIgniter\Filters\DebugToolbar::class, + 'honeypot' => \CodeIgniter\Filters\Honeypot::class, + ]; + + // Always applied before every request + public $globals = [ + 'before' => [ + //'honeypot' + // 'csrf', + ], + 'after' => [ + 'toolbar', + //'honeypot' + ], + ]; + + // Works on all of a particular HTTP method + // (GET, POST, etc) as BEFORE filters only + // like: 'post' => ['CSRF', 'throttle'], + public $methods = []; + + // List filter aliases and any before/after uri patterns + // that they should run on, like: + // 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']], + public $filters = []; +} diff --git a/app/Config/ForeignCharacters.php b/app/Config/ForeignCharacters.php new file mode 100644 index 0000000..8ee6f11 --- /dev/null +++ b/app/Config/ForeignCharacters.php @@ -0,0 +1,6 @@ + \CodeIgniter\Format\JSONFormatter::class, + 'application/xml' => \CodeIgniter\Format\XMLFormatter::class, + 'text/xml' => \CodeIgniter\Format\XMLFormatter::class, + ]; + + //-------------------------------------------------------------------- + + /** + * A Factory method to return the appropriate formatter for the given mime type. + * + * @param string $mime + * + * @return \CodeIgniter\Format\FormatterInterface + */ + public function getFormatter(string $mime) + { + if (! array_key_exists($mime, $this->formatters)) + { + throw new \InvalidArgumentException('No Formatter defined for mime type: ' . $mime); + } + + $class = $this->formatters[$mime]; + + if (! class_exists($class)) + { + throw new \BadMethodCallException($class . ' is not a valid Formatter.'); + } + + return new $class(); + } + + //-------------------------------------------------------------------- + +} diff --git a/app/Config/Honeypot.php b/app/Config/Honeypot.php new file mode 100644 index 0000000..f4444a5 --- /dev/null +++ b/app/Config/Honeypot.php @@ -0,0 +1,34 @@ +{label}'; +} diff --git a/app/Config/Images.php b/app/Config/Images.php new file mode 100644 index 0000000..730ddee --- /dev/null +++ b/app/Config/Images.php @@ -0,0 +1,31 @@ + \CodeIgniter\Images\Handlers\GDHandler::class, + 'imagick' => \CodeIgniter\Images\Handlers\ImageMagickHandler::class, + ]; +} diff --git a/app/Config/Logger.php b/app/Config/Logger.php new file mode 100644 index 0000000..d32e195 --- /dev/null +++ b/app/Config/Logger.php @@ -0,0 +1,140 @@ + [ + + /* + * The log levels that this handler will handle. + */ + 'handles' => [ + 'critical', + 'alert', + 'emergency', + 'debug', + 'error', + 'info', + 'notice', + 'warning', + ], + + /* + * Leave this BLANK unless you would like to set something other than the default + * writeable/logs/ directory. Use a full getServer path with trailing slash. + */ + 'path' => WRITEPATH . 'logs/', + + /* + * The default filename extension for log files. The default '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 'php'. + */ + 'fileExtension' => 'php', + + /* + * The file system permissions to be applied on newly created log files. + * + * IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal + * integer notation (i.e. 0700, 0644, etc.) + */ + 'filePermissions' => 0644, + ], + + /** + * The ChromeLoggerHandler requires the use of the Chrome web browser + * and the ChromeLogger extension. Uncomment this block to use it. + */ + // 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [ + // /* + // * The log levels that this handler will handle. + // */ + // 'handles' => ['critical', 'alert', 'emergency', 'debug', + // 'error', 'info', 'notice', 'warning'], + // ] + ]; +} diff --git a/app/Config/Migrations.php b/app/Config/Migrations.php new file mode 100644 index 0000000..b83fe90 --- /dev/null +++ b/app/Config/Migrations.php @@ -0,0 +1,50 @@ + php spark migrate:create + | + | Typical formats: + | YmdHis_ + | Y-m-d-His_ + | Y_m_d_His_ + | + */ + public $timestampFormat = 'Y-m-d-His_'; + +} diff --git a/app/Config/Mimes.php b/app/Config/Mimes.php new file mode 100644 index 0000000..a570ef5 --- /dev/null +++ b/app/Config/Mimes.php @@ -0,0 +1,534 @@ + [ + 'application/mac-binhex40', + 'application/mac-binhex', + 'application/x-binhex40', + 'application/x-mac-binhex40', + ], + 'cpt' => 'application/mac-compactpro', + 'csv' => [ + 'text/csv', + 'text/x-comma-separated-values', + 'text/comma-separated-values', + 'application/octet-stream', + 'application/vnd.ms-excel', + 'application/x-csv', + 'text/x-csv', + 'application/csv', + 'application/excel', + 'application/vnd.msexcel', + 'text/plain', + ], + 'bin' => [ + 'application/macbinary', + 'application/mac-binary', + 'application/octet-stream', + 'application/x-binary', + 'application/x-macbinary', + ], + 'dms' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'exe' => [ + 'application/octet-stream', + 'application/x-msdownload', + ], + 'class' => 'application/octet-stream', + 'psd' => [ + 'application/x-photoshop', + 'image/vnd.adobe.photoshop', + ], + 'so' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => [ + 'application/pdf', + 'application/force-download', + 'application/x-download', + 'binary/octet-stream', + ], + 'ai' => [ + 'application/pdf', + 'application/postscript', + ], + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => [ + 'application/vnd.ms-excel', + 'application/msexcel', + 'application/x-msexcel', + 'application/x-ms-excel', + 'application/x-excel', + 'application/x-dos_ms_excel', + 'application/xls', + 'application/x-xls', + 'application/excel', + 'application/download', + 'application/vnd.ms-office', + 'application/msword', + ], + 'ppt' => [ + 'application/vnd.ms-powerpoint', + 'application/powerpoint', + 'application/vnd.ms-office', + 'application/msword', + ], + 'pptx' => [ + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/x-zip', + 'application/zip', + ], + 'wbxml' => 'application/wbxml', + 'wmlc' => 'application/wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'gz' => 'application/x-gzip', + 'gzip' => 'application/x-gzip', + 'php' => [ + 'application/x-php', + 'application/x-httpd-php', + 'application/php', + 'text/php', + 'text/x-php', + 'application/x-httpd-php-source', + ], + 'php4' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'js' => [ + 'application/x-javascript', + 'text/plain', + ], + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => [ + 'application/x-tar', + 'application/x-gzip-compressed', + ], + 'z' => 'application/x-compress', + 'xhtml' => 'application/xhtml+xml', + 'xht' => 'application/xhtml+xml', + 'zip' => [ + 'application/x-zip', + 'application/zip', + 'application/x-zip-compressed', + 'application/s-compressed', + 'multipart/x-zip', + ], + 'rar' => [ + 'application/x-rar', + 'application/rar', + 'application/x-rar-compressed', + ], + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mpga' => 'audio/mpeg', + 'mp2' => 'audio/mpeg', + 'mp3' => [ + 'audio/mpeg', + 'audio/mpg', + 'audio/mpeg3', + 'audio/mp3', + ], + 'aif' => [ + 'audio/x-aiff', + 'audio/aiff', + ], + 'aiff' => [ + 'audio/x-aiff', + 'audio/aiff', + ], + 'aifc' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'rv' => 'video/vnd.rn-realvideo', + 'wav' => [ + 'audio/x-wav', + 'audio/wave', + 'audio/wav', + ], + 'bmp' => [ + 'image/bmp', + 'image/x-bmp', + 'image/x-bitmap', + 'image/x-xbitmap', + 'image/x-win-bitmap', + 'image/x-windows-bmp', + 'image/ms-bmp', + 'image/x-ms-bmp', + 'application/bmp', + 'application/x-bmp', + 'application/x-win-bitmap', + ], + 'gif' => 'image/gif', + 'jpg' => [ + 'image/jpeg', + 'image/pjpeg', + ], + 'jpeg' => [ + 'image/jpeg', + 'image/pjpeg', + ], + 'jpe' => [ + 'image/jpeg', + 'image/pjpeg', + ], + 'jp2' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'j2k' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'jpf' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'jpg2' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'jpx' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'jpm' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'mj2' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'mjp2' => [ + 'image/jp2', + 'video/mj2', + 'image/jpx', + 'image/jpm', + ], + 'png' => [ + 'image/png', + 'image/x-png', + ], + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'css' => [ + 'text/css', + 'text/plain', + ], + 'html' => [ + 'text/html', + 'text/plain', + ], + 'htm' => [ + 'text/html', + 'text/plain', + ], + 'shtml' => [ + 'text/html', + 'text/plain', + ], + 'txt' => 'text/plain', + 'text' => 'text/plain', + 'log' => [ + 'text/plain', + 'text/x-log', + ], + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'xml' => [ + 'application/xml', + 'text/xml', + 'text/plain', + ], + 'xsl' => [ + 'application/xml', + 'text/xsl', + 'text/xml', + ], + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'qt' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'avi' => [ + 'video/x-msvideo', + 'video/msvideo', + 'video/avi', + 'application/x-troff-msvideo', + ], + 'movie' => 'video/x-sgi-movie', + 'doc' => [ + 'application/msword', + 'application/vnd.ms-office', + ], + 'docx' => [ + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/zip', + 'application/msword', + 'application/x-zip', + ], + 'dot' => [ + 'application/msword', + 'application/vnd.ms-office', + ], + 'dotx' => [ + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/zip', + 'application/msword', + ], + 'xlsx' => [ + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/zip', + 'application/vnd.ms-excel', + 'application/msword', + 'application/x-zip', + ], + 'word' => [ + 'application/msword', + 'application/octet-stream', + ], + 'xl' => 'application/excel', + 'eml' => 'message/rfc822', + 'json' => [ + 'application/json', + 'text/json', + ], + 'pem' => [ + 'application/x-x509-user-cert', + 'application/x-pem-file', + 'application/octet-stream', + ], + 'p10' => [ + 'application/x-pkcs10', + 'application/pkcs10', + ], + 'p12' => 'application/x-pkcs12', + 'p7a' => 'application/x-pkcs7-signature', + 'p7c' => [ + 'application/pkcs7-mime', + 'application/x-pkcs7-mime', + ], + 'p7m' => [ + 'application/pkcs7-mime', + 'application/x-pkcs7-mime', + ], + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'crt' => [ + 'application/x-x509-ca-cert', + 'application/x-x509-user-cert', + 'application/pkix-cert', + ], + 'crl' => [ + 'application/pkix-crl', + 'application/pkcs-crl', + ], + 'der' => 'application/x-x509-ca-cert', + 'kdb' => 'application/octet-stream', + 'pgp' => 'application/pgp', + 'gpg' => 'application/gpg-keys', + 'sst' => 'application/octet-stream', + 'csr' => 'application/octet-stream', + 'rsa' => 'application/x-pkcs7', + 'cer' => [ + 'application/pkix-cert', + 'application/x-x509-ca-cert', + ], + '3g2' => 'video/3gpp2', + '3gp' => [ + 'video/3gp', + 'video/3gpp', + ], + 'mp4' => 'video/mp4', + 'm4a' => 'audio/x-m4a', + 'f4v' => [ + 'video/mp4', + 'video/x-f4v', + ], + 'flv' => 'video/x-flv', + 'webm' => 'video/webm', + 'aac' => 'audio/x-acc', + 'm4u' => 'application/vnd.mpegurl', + 'm3u' => 'text/plain', + 'xspf' => 'application/xspf+xml', + 'vlc' => 'application/videolan', + 'wmv' => [ + 'video/x-ms-wmv', + 'video/x-ms-asf', + ], + 'au' => 'audio/x-au', + 'ac3' => 'audio/ac3', + 'flac' => 'audio/x-flac', + 'ogg' => [ + 'audio/ogg', + 'video/ogg', + 'application/ogg', + ], + 'kmz' => [ + 'application/vnd.google-earth.kmz', + 'application/zip', + 'application/x-zip', + ], + 'kml' => [ + 'application/vnd.google-earth.kml+xml', + 'application/xml', + 'text/xml', + ], + 'ics' => 'text/calendar', + 'ical' => 'text/calendar', + 'zsh' => 'text/x-scriptzsh', + '7zip' => [ + 'application/x-compressed', + 'application/x-zip-compressed', + 'application/zip', + 'multipart/x-zip', + ], + 'cdr' => [ + 'application/cdr', + 'application/coreldraw', + 'application/x-cdr', + 'application/x-coreldraw', + 'image/cdr', + 'image/x-cdr', + 'zz-application/zz-winassoc-cdr', + ], + 'wma' => [ + 'audio/x-ms-wma', + 'video/x-ms-asf', + ], + 'jar' => [ + 'application/java-archive', + 'application/x-java-application', + 'application/x-jar', + 'application/x-compressed', + ], + 'svg' => [ + 'image/svg+xml', + 'application/xml', + 'text/xml', + ], + 'vcf' => 'text/x-vcard', + 'srt' => [ + 'text/srt', + 'text/plain', + ], + 'vtt' => [ + 'text/vtt', + 'text/plain', + ], + 'ico' => [ + 'image/x-icon', + 'image/x-ico', + 'image/vnd.microsoft.icon', + ], + ]; + + //-------------------------------------------------------------------- + + /** + * Attempts to determine the best mime type for the given file extension. + * + * @param string $extension + * + * @return string|null The mime type found, or none if unable to determine. + */ + public static function guessTypeFromExtension(string $extension) + { + $extension = trim(strtolower($extension), '. '); + + if (! array_key_exists($extension, static::$mimes)) + { + return null; + } + + return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension]; + } + + //-------------------------------------------------------------------- + + /** + * Attempts to determine the best file extension for a given mime type. + * + * @param string $type + * @param string $proposed_extension - default extension (in case there is more than one with the same mime type) + * + * @return string|null The extension determined, or null if unable to match. + */ + public static function guessExtensionFromType(string $type, ?string $proposed_extension = null) + { + $type = trim(strtolower($type), '. '); + + $proposed_extension = trim(strtolower($proposed_extension)); + + if (! is_null($proposed_extension) && array_key_exists($proposed_extension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposed_extension]) ? [static::$mimes[$proposed_extension]] : static::$mimes[$proposed_extension])) + { + return $proposed_extension; + } + + foreach (static::$mimes as $ext => $types) + { + if (is_string($types) && $types === $type) + { + return $ext; + } + else if (is_array($types) && in_array($type, $types)) + { + return $ext; + } + } + + return null; + } + + //-------------------------------------------------------------------- + +} diff --git a/app/Config/Modules.php b/app/Config/Modules.php new file mode 100644 index 0000000..28bbc7d --- /dev/null +++ b/app/Config/Modules.php @@ -0,0 +1,67 @@ +enabled) + { + return false; + } + + $alias = strtolower($alias); + + return in_array($alias, $this->activeExplorers); + } +} diff --git a/app/Config/Pager.php b/app/Config/Pager.php new file mode 100644 index 0000000..9b6ed83 --- /dev/null +++ b/app/Config/Pager.php @@ -0,0 +1,35 @@ + 'CodeIgniter\Pager\Views\default_full', + 'default_simple' => 'CodeIgniter\Pager\Views\default_simple', + 'default_head' => 'CodeIgniter\Pager\Views\default_head', + ]; + + /* + |-------------------------------------------------------------------------- + | Items Per Page + |-------------------------------------------------------------------------- + | + | The default number of results shown in a single page. + | + */ + public $perPage = 20; +} diff --git a/app/Config/Paths.php b/app/Config/Paths.php new file mode 100644 index 0000000..6251124 --- /dev/null +++ b/app/Config/Paths.php @@ -0,0 +1,77 @@ +defaultNamespace() + * + * Modifies the namespace that is added to a controller if it doesn't + * already have one. By default this is the global namespace (\). + * + * $routes->defaultController() + * + * Changes the name of the class used as a controller when the route + * points to a folder instead of a class. + * + * $routes->defaultMethod() + * + * Assigns the method inside the controller that is ran when the + * Router is unable to determine the appropriate method to run. + * + * $routes->setAutoRoute() + * + * Determines whether the Router will attempt to match URIs to + * Controllers when no specific route has been defined. If false, + * only routes that have been defined here will be available. + */ +$routes->setDefaultNamespace('App\Controllers'); +$routes->setDefaultController('Home'); +$routes->setDefaultMethod('index'); +$routes->setTranslateURIDashes(false); +$routes->set404Override(); +$routes->setAutoRoute(true); + +/** + * -------------------------------------------------------------------- + * Route Definitions + * -------------------------------------------------------------------- + */ + +// We get a performance increase by specifying the default +// route since we don't have to scan directories. +$routes->get('/', 'Home::index'); + +/** + * -------------------------------------------------------------------- + * Additional Routing + * -------------------------------------------------------------------- + * + * There will often be times that you need additional routing and you + * need to it be able to override any defaults in this file. Environment + * based routes is one such time. require() additional route files here + * to make that happen. + * + * You will have access to the $routes object within that file without + * needing to reload it. + */ +if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) +{ + require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; +} diff --git a/app/Config/Services.php b/app/Config/Services.php new file mode 100644 index 0000000..79a2afb --- /dev/null +++ b/app/Config/Services.php @@ -0,0 +1,33 @@ + 'Windows 10', + 'windows nt 6.3' => 'Windows 8.1', + 'windows nt 6.2' => 'Windows 8', + 'windows nt 6.1' => 'Windows 7', + 'windows nt 6.0' => 'Windows Vista', + 'windows nt 5.2' => 'Windows 2003', + 'windows nt 5.1' => 'Windows XP', + 'windows nt 5.0' => 'Windows 2000', + 'windows nt 4.0' => 'Windows NT 4.0', + 'winnt4.0' => 'Windows NT 4.0', + 'winnt 4.0' => 'Windows NT', + 'winnt' => 'Windows NT', + 'windows 98' => 'Windows 98', + 'win98' => 'Windows 98', + 'windows 95' => 'Windows 95', + 'win95' => 'Windows 95', + 'windows phone' => 'Windows Phone', + 'windows' => 'Unknown Windows OS', + 'android' => 'Android', + 'blackberry' => 'BlackBerry', + 'iphone' => 'iOS', + 'ipad' => 'iOS', + 'ipod' => 'iOS', + 'os x' => 'Mac OS X', + 'ppc mac' => 'Power PC Mac', + 'freebsd' => 'FreeBSD', + 'ppc' => 'Macintosh', + 'linux' => 'Linux', + 'debian' => 'Debian', + 'sunos' => 'Sun Solaris', + 'beos' => 'BeOS', + 'apachebench' => 'ApacheBench', + 'aix' => 'AIX', + 'irix' => 'Irix', + 'osf' => 'DEC OSF', + 'hp-ux' => 'HP-UX', + 'netbsd' => 'NetBSD', + 'bsdi' => 'BSDi', + 'openbsd' => 'OpenBSD', + 'gnu' => 'GNU/Linux', + 'unix' => 'Unknown Unix OS', + 'symbian' => 'Symbian OS', + ]; + + // The order of this array should NOT be changed. Many browsers return + // multiple browser types so we want to identify the sub-type first. + public $browsers = [ + 'OPR' => 'Opera', + 'Flock' => 'Flock', + 'Edge' => 'Spartan', + 'Chrome' => 'Chrome', + // Opera 10+ always reports Opera/9.80 and appends Version/ to the user agent string + 'Opera.*?Version' => 'Opera', + 'Opera' => 'Opera', + 'MSIE' => 'Internet Explorer', + 'Internet Explorer' => 'Internet Explorer', + 'Trident.* rv' => 'Internet Explorer', + 'Shiira' => 'Shiira', + 'Firefox' => 'Firefox', + 'Chimera' => 'Chimera', + 'Phoenix' => 'Phoenix', + 'Firebird' => 'Firebird', + 'Camino' => 'Camino', + 'Netscape' => 'Netscape', + 'OmniWeb' => 'OmniWeb', + 'Safari' => 'Safari', + 'Mozilla' => 'Mozilla', + 'Konqueror' => 'Konqueror', + 'icab' => 'iCab', + 'Lynx' => 'Lynx', + 'Links' => 'Links', + 'hotjava' => 'HotJava', + 'amaya' => 'Amaya', + 'IBrowse' => 'IBrowse', + 'Maxthon' => 'Maxthon', + 'Ubuntu' => 'Ubuntu Web Browser', + 'Vivaldi' => 'Vivaldi', + ]; + + public $mobiles = [ + // legacy array, old values commented out + 'mobileexplorer' => 'Mobile Explorer', + // 'openwave' => 'Open Wave', + // 'opera mini' => 'Opera Mini', + // 'operamini' => 'Opera Mini', + // 'elaine' => 'Palm', + 'palmsource' => 'Palm', + // 'digital paths' => 'Palm', + // 'avantgo' => 'Avantgo', + // 'xiino' => 'Xiino', + 'palmscape' => 'Palmscape', + // 'nokia' => 'Nokia', + // 'ericsson' => 'Ericsson', + // 'blackberry' => 'BlackBerry', + // 'motorola' => 'Motorola' + + // Phones and Manufacturers + 'motorola' => 'Motorola', + 'nokia' => 'Nokia', + 'palm' => 'Palm', + 'iphone' => 'Apple iPhone', + 'ipad' => 'iPad', + 'ipod' => 'Apple iPod Touch', + 'sony' => 'Sony Ericsson', + 'ericsson' => 'Sony Ericsson', + 'blackberry' => 'BlackBerry', + 'cocoon' => 'O2 Cocoon', + 'blazer' => 'Treo', + 'lg' => 'LG', + 'amoi' => 'Amoi', + 'xda' => 'XDA', + 'mda' => 'MDA', + 'vario' => 'Vario', + 'htc' => 'HTC', + 'samsung' => 'Samsung', + 'sharp' => 'Sharp', + 'sie-' => 'Siemens', + 'alcatel' => 'Alcatel', + 'benq' => 'BenQ', + 'ipaq' => 'HP iPaq', + 'mot-' => 'Motorola', + 'playstation portable' => 'PlayStation Portable', + 'playstation 3' => 'PlayStation 3', + 'playstation vita' => 'PlayStation Vita', + 'hiptop' => 'Danger Hiptop', + 'nec-' => 'NEC', + 'panasonic' => 'Panasonic', + 'philips' => 'Philips', + 'sagem' => 'Sagem', + 'sanyo' => 'Sanyo', + 'spv' => 'SPV', + 'zte' => 'ZTE', + 'sendo' => 'Sendo', + 'nintendo dsi' => 'Nintendo DSi', + 'nintendo ds' => 'Nintendo DS', + 'nintendo 3ds' => 'Nintendo 3DS', + 'wii' => 'Nintendo Wii', + 'open web' => 'Open Web', + 'openweb' => 'OpenWeb', + + // Operating Systems + 'android' => 'Android', + 'symbian' => 'Symbian', + 'SymbianOS' => 'SymbianOS', + 'elaine' => 'Palm', + 'series60' => 'Symbian S60', + 'windows ce' => 'Windows CE', + + // Browsers + 'obigo' => 'Obigo', + 'netfront' => 'Netfront Browser', + 'openwave' => 'Openwave Browser', + 'mobilexplorer' => 'Mobile Explorer', + 'operamini' => 'Opera Mini', + 'opera mini' => 'Opera Mini', + 'opera mobi' => 'Opera Mobile', + 'fennec' => 'Firefox Mobile', + + // Other + 'digital paths' => 'Digital Paths', + 'avantgo' => 'AvantGo', + 'xiino' => 'Xiino', + 'novarra' => 'Novarra Transcoder', + 'vodafone' => 'Vodafone', + 'docomo' => 'NTT DoCoMo', + 'o2' => 'O2', + + // Fallback + 'mobile' => 'Generic Mobile', + 'wireless' => 'Generic Mobile', + 'j2me' => 'Generic Mobile', + 'midp' => 'Generic Mobile', + 'cldc' => 'Generic Mobile', + 'up.link' => 'Generic Mobile', + 'up.browser' => 'Generic Mobile', + 'smartphone' => 'Generic Mobile', + 'cellphone' => 'Generic Mobile', + ]; + + // There are hundreds of bots but these are the most common. + public $robots = [ + 'googlebot' => 'Googlebot', + 'msnbot' => 'MSNBot', + 'baiduspider' => 'Baiduspider', + 'bingbot' => 'Bing', + 'slurp' => 'Inktomi Slurp', + 'yahoo' => 'Yahoo', + 'ask jeeves' => 'Ask Jeeves', + 'fastcrawler' => 'FastCrawler', + 'infoseek' => 'InfoSeek Robot 1.0', + 'lycos' => 'Lycos', + 'yandex' => 'YandexBot', + 'mediapartners-google' => 'MediaPartners Google', + 'CRAZYWEBCRAWLER' => 'Crazy Webcrawler', + 'adsbot-google' => 'AdsBot Google', + 'feedfetcher-google' => 'Feedfetcher Google', + 'curious george' => 'Curious George', + 'ia_archiver' => 'Alexa Crawler', + 'MJ12bot' => 'Majestic-12', + 'Uptimebot' => 'Uptimebot', + ]; +} diff --git a/app/Config/Validation.php b/app/Config/Validation.php new file mode 100644 index 0000000..97f08c7 --- /dev/null +++ b/app/Config/Validation.php @@ -0,0 +1,36 @@ + 'CodeIgniter\Validation\Views\list', + 'single' => 'CodeIgniter\Validation\Views\single', + ]; + + //-------------------------------------------------------------------- + // Rules + //-------------------------------------------------------------------- +} diff --git a/app/Config/View.php b/app/Config/View.php new file mode 100644 index 0000000..f66b253 --- /dev/null +++ b/app/Config/View.php @@ -0,0 +1,34 @@ +session = \Config\Services::session(); + } + +} diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php new file mode 100644 index 0000000..1ef9a0a --- /dev/null +++ b/app/Controllers/Home.php @@ -0,0 +1,23 @@ +db); + $table->setTable($model->noticeTable()) + ->setDefaultOrder("id","DESC") + ->setSearch(["title","slug"]) + ->setOutput([$model->noticeButton(), + "title", + "slug"]); + echo $table->getDatatable(); + } +} diff --git a/app/Database/Migrations/.gitkeep b/app/Database/Migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Database/Seeds/.gitkeep b/app/Database/Seeds/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Filters/.gitkeep b/app/Filters/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Helpers/.gitkeep b/app/Helpers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Language/.gitkeep b/app/Language/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Libraries/.gitkeep b/app/Libraries/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Models/.gitkeep b/app/Models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php new file mode 100644 index 0000000..91697ed --- /dev/null +++ b/app/Models/HomeModel.php @@ -0,0 +1,29 @@ +db = \Config\Database::connect(); + } + + public function noticeTable(){ + $closureFun = function(&$db){ + return $db->table("news"); + }; + return $closureFun; + } + + public function noticeButton(){ + $closureFun = function(array $row){ + return <<del + EOF; + }; + return $closureFun; + } + +} diff --git a/app/ThirdParty/.gitkeep b/app/ThirdParty/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Views/Home_view.php b/app/Views/Home_view.php new file mode 100644 index 0000000..23dc4af --- /dev/null +++ b/app/Views/Home_view.php @@ -0,0 +1,45 @@ + + + + tableIgniter example + + + + + +

ex1

+ + + + + + + + +
idtitleslug
+ + + + + + + + +
idtitleslug
+ + + diff --git a/app/Views/errors/.htaccess b/app/Views/errors/.htaccess new file mode 100644 index 0000000..f24db0a --- /dev/null +++ b/app/Views/errors/.htaccess @@ -0,0 +1,6 @@ + + Require all denied + + + Deny from all + diff --git a/app/Views/errors/cli/error_404.php b/app/Views/errors/cli/error_404.php new file mode 100644 index 0000000..d5bccb4 --- /dev/null +++ b/app/Views/errors/cli/error_404.php @@ -0,0 +1,6 @@ + +Message: +Filename: getFile(), "\n"; ?> +Line Number: getLine(); ?> + + + + Backtrace: + getTrace() as $error): ?> + + + + + + diff --git a/app/Views/errors/cli/production.php b/app/Views/errors/cli/production.php new file mode 100644 index 0000000..7db744e --- /dev/null +++ b/app/Views/errors/cli/production.php @@ -0,0 +1,5 @@ + + + + + 404 Page Not Found + + + + +
+

404 - File Not Found

+ +

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

+
+ + diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php new file mode 100644 index 0000000..7052e53 --- /dev/null +++ b/app/Views/errors/html/error_exception.php @@ -0,0 +1,401 @@ + + + + + + + + <?= htmlspecialchars($title, ENT_SUBSTITUTE, 'UTF-8') ?> + + + + + + + +
+
+

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

+

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

+
+
+ + +
+

at line

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

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

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

    + + + +
    + +
    + +
  2. + + +
+ +
+ + +
+ + + +

$

+ + + + + + + + + + $value) : ?> + + + + + + +
KeyValue
+ + + + ' . print_r($value, true) ?> + +
+ + + + + + +

Constants

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

$

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

Headers

+ + + + + + + + + + $value) : ?> + + + + + + + + + + +
HeaderValue
getName(), 'html') ?>getValueLine(), 'html') ?>
+ + +
+ + + setStatusCode(http_response_code()); + ?> +
+ + + + + +
Response StatusgetStatusCode() . ' - ' . $response->getReason() ?>
+ + getHeaders(); ?> + + + +

Headers

+ + + + + + + + + + $value) : ?> + + + + + + +
HeaderValue
getHeaderLine($name), 'html') ?>
+ + +
+ + +
+ + +
    + +
  1. + +
+
+ + +
+ + + + + + + + + + + + + + + + +
Memory Usage
Peak Memory Usage:
Memory Limit:
+ +
+ +
+ +
+ + + + + diff --git a/app/Views/errors/html/production.php b/app/Views/errors/html/production.php new file mode 100644 index 0000000..cca49c2 --- /dev/null +++ b/app/Views/errors/html/production.php @@ -0,0 +1,25 @@ + + + + + + + Whoops! + + + + + +
+ +

Whoops!

+ +

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

+ +
+ + + + diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/app/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..136a99e --- /dev/null +++ b/composer.json @@ -0,0 +1,26 @@ +{ + "name": "codeigniter4/appstarter", + "type": "project", + "description": "CodeIgniter4 starter app", + "homepage": "https://codeigniter.com", + "license": "MIT", + "require": { + "php": ">=7.2", + "codeigniter4/framework": "^4@rc", + "monken/tablesigniter": "^1.0" + }, + "require-dev": { + "mikey179/vfsstream": "1.6.*", + "phpunit/phpunit": "^7.0" + }, + "scripts": { + "post-update-cmd": [ + "@composer dump-autoload" + ] + }, + "support": { + "forum": "http://forum.codeigniter.com/", + "source": "https://github.com/codeigniter4/CodeIgniter4", + "slack": "https://codeigniterchat.slack.com" + } +} diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..09dff38 --- /dev/null +++ b/contributing.md @@ -0,0 +1,79 @@ +# Contributing to CodeIgniter4 + + +## Contributions + +We expect all contributions to conform to our style guide, be commented (inside the PHP source files), +be documented (in the user guide), and unit tested (in the test folder). +There is a [Contributing to CodeIgniter](./contributing/README.rst) section in the repository which describes the contribution process; this page is an overview. + +## Issues + +Issues are a quick way to point out a bug. If you find a bug or documentation error in CodeIgniter then please check a few things first: + +1. There is not already an open Issue +2. The issue has already been fixed (check the develop branch, or look for closed Issues) +3. Is it something really obvious that you can fix yourself? + +Reporting issues is helpful but an even [better approach](./contributing/workflow.rst) is to send a Pull Request, which is done by "Forking" the main repository and committing to your own copy. This will require you to use the version control system called Git. + +## Guidelines + +Before we look into how, here are the guidelines. If your Pull Requests fail +to pass these guidelines it will be declined and you will need to re-submit +when youā€™ve made the changes. This might sound a bit tough, but it is required +for us to maintain quality of the code-base. + +### PHP Style + +All code must meet the [Style Guide](./contributing/styleguide.rst). +This makes certain that all code is the same format as the existing code and means it will be as readable as possible. + +### Documentation + +If you change anything that requires a change to documentation then you will need to add it. New classes, methods, parameters, changing default values, etc are all things that will require a change to documentation. The change-log must also be updated for every change. Also PHPDoc blocks must be maintained. + +### Compatibility + +CodeIgniter4 requires PHP 7.2. + +### Branching + +CodeIgniter4 uses the [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model which requires all pull requests to be sent to the "develop" branch. This is +where the next planned version will be developed. The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g: an emergency security patch) can be applied to master to create a new version, without worrying about other features holding it up. For this reason all commits need to be made to "develop" and any sent to "master" will be closed automatically. If you have multiple changes to submit, please place all changes into their own branch on your fork. + +One thing at a time: A pull request should only contain one change. That does not mean only one commit, but one change - however many commits it took. The reason for this is that if you change X and Y but send a pull request for both at the same time, we might really want X but disagree with Y, meaning we cannot merge the request. Using the Git-Flow branching model you can create new branches for both of these features and send two requests. + +### Signing + +You must [GPG-sign](./contributing/signing.rst) your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open source project. This is *not* just a "signed-off-by" commit, but instead a digitally signed one. + +## How-to Guide + +The best way to contribute is to fork the CodeIgniter4 repository, and "clone" that to your development area. That sounds like some jargon, but "forking" on GitHub means "making a copy of that repo to your account" and "cloning" means "copying that code to your environment so you can work on it". + +1. Set up Git (Windows, Mac & Linux) +2. Go to the CodeIgniter4 repo +3. Fork it (to your Github account) +4. Clone your CodeIgniter repo: git@github.com:\/CodeIgniter4.git +5. Create a new branch in your project for each set of changes you want to make. +6. Fix existing bugs on the Issue tracker after taking a look to see nobody else is working on them. +7. Commit the changed files in your contribution branch +8. Push your contribution branch to your fork +9. Send a pull request [http://help.github.com/send-pull-requests/](http://help.github.com/send-pull-requests/) + +The codebase maintainers will now be alerted about the change and at least one of the team will respond. If your change fails to meet the guidelines it will be bounced, or feedback will be provided to help you improve it. + +Once the maintainer handling your pull request is happy with it they will merge it into develop and your patch will be part of the next release. + +### Keeping your fork up-to-date + +Unlike systems like Subversion, Git can have multiple remotes. A remote is the name for a URL of a Git repository. By default your fork will have a remote named "origin" which points to your fork, but you can add another remote named "codeigniter" which points to `git://github.com/codeigniter4/CodeIgniter4.git`. This is a read-only remote but you can pull from this develop branch to update your own. + +If you are using command-line you can do the following: + +1. `git remote add codeigniter git://github.com/codeigniter4/CodeIgniter4.git` +2. `git pull codeigniter develop` +3. `git push origin develop` + +Now your fork is up to date. This should be done regularly, or before you send a pull request at least. diff --git a/env b/env new file mode 100644 index 0000000..bc1a156 --- /dev/null +++ b/env @@ -0,0 +1,93 @@ +#-------------------------------------------------------------------- +# Example Environment Configuration file +# +# This file can be used as a starting point for your own +# custom .env files, and contains most of the possible settings +# available in a default install. +# +# By default, all of the settings are commented out. If you want +# to override the setting, you must un-comment it by removing the '#' +# at the beginning of the line. +#-------------------------------------------------------------------- + +#-------------------------------------------------------------------- +# ENVIRONMENT +#-------------------------------------------------------------------- + +# CI_ENVIRONMENT = production + +#-------------------------------------------------------------------- +# APP +#-------------------------------------------------------------------- + +# app.baseURL = '' +# app.forceGlobalSecureRequests = false + +# app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler' +# app.sessionCookieName = 'ci_session' +# app.sessionSavePath = NULL +# app.sessionMatchIP = false +# app.sessionTimeToUpdate = 300 +# app.sessionRegenerateDestroy = false + +# app.cookiePrefix = '' +# app.cookieDomain = '' +# app.cookiePath = '/' +# app.cookieSecure = false +# app.cookieHTTPOnly = false + +# app.CSRFProtection = false +# app.CSRFTokenName = 'csrf_test_name' +# app.CSRFCookieName = 'csrf_cookie_name' +# app.CSRFExpire = 7200 +# app.CSRFRegenerate = true +# app.CSRFExcludeURIs = [] + +# app.CSPEnabled = false + +#-------------------------------------------------------------------- +# DATABASE +#-------------------------------------------------------------------- + +# database.default.hostname = localhost +# database.default.database = ci4 +# database.default.username = root +# database.default.password = root +# database.default.DBDriver = MySQLi + +# database.tests.hostname = localhost +# database.tests.database = ci4 +# database.tests.username = root +# database.tests.password = root +# database.tests.DBDriver = MySQLi + +#-------------------------------------------------------------------- +# CONTENT SECURITY POLICY +#-------------------------------------------------------------------- + +# contentsecuritypolicy.reportOnly = false +# contentsecuritypolicy.defaultSrc = 'none' +# contentsecuritypolicy.scriptSrc = 'self' +# contentsecuritypolicy.styleSrc = 'self' +# contentsecuritypolicy.imageSrc = 'self' +# contentsecuritypolicy.base_uri = null +# contentsecuritypolicy.childSrc = null +# contentsecuritypolicy.connectSrc = 'self' +# contentsecuritypolicy.fontSrc = null +# contentsecuritypolicy.formAction = null +# contentsecuritypolicy.frameAncestors = null +# contentsecuritypolicy.mediaSrc = null +# contentsecuritypolicy.objectSrc = null +# contentsecuritypolicy.pluginTypes = null +# contentsecuritypolicy.reportURI = null +# contentsecuritypolicy.sandbox = false +# contentsecuritypolicy.upgradeInsecureRequests = false + +#-------------------------------------------------------------------- +# HONEYPOT +#-------------------------------------------------------------------- + +# honeypot.hidden = 'true' +# honeypot.label = 'Fill This Field' +# honeypot.name = 'honeypot' +# honeypot.template = '' diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..6dea8d0 --- /dev/null +++ b/license.txt @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014-2019 British Columbia Institute of Technology +Copyright (c) 2019 CodeIgniter Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..aedc35f --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + ./tests + + + + + + + + diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..8af50c9 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,47 @@ +# Disable directory browsing +Options All -Indexes + +# ---------------------------------------------------------------------- +# Rewrite engine +# ---------------------------------------------------------------------- + +# Turning on the rewrite engine is necessary for the following rules and features. +# FollowSymLinks must be enabled for this to work. + + Options +FollowSymlinks + RewriteEngine On + + # If you installed CodeIgniter in a subfolder, you will need to + # change the following line to match the subfolder you need. + # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase + # RewriteBase / + + # Redirect Trailing Slashes... + RewriteRule ^(.*)/$ /$1 [L,R=301] + + # Rewrite "www.example.com -> example.com" + RewriteCond %{HTTPS} !=on + RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] + RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] + + # Checks to see if the user is attempting to access a valid file, + # such as an image or css document, if this isn't true it sends the + # request to the front controller, index.php + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)$ index.php/$1 [L] + + # Ensure Authorization header is passed along + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + + + # If we don't have mod_rewrite installed, all 404's + # can be sent to index.php, and everything works as normal. + ErrorDocument 404 index.php + + +# Disable server signature start + ServerSignature Off +# Disable server signature end diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..7ecfce2 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..5b9e912 --- /dev/null +++ b/public/index.php @@ -0,0 +1,45 @@ +systemDirectory, '/ ') . '/bootstrap.php'; + +/* + *--------------------------------------------------------------- + * LAUNCH THE APPLICATION + *--------------------------------------------------------------- + * Now that everything is setup, it's time to actually fire + * up the engines and make this app do its thang. + */ +$app->run(); diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..9e60f97 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/spark b/spark new file mode 100755 index 0000000..396ad59 --- /dev/null +++ b/spark @@ -0,0 +1,61 @@ +#!/usr/bin/env php +systemDirectory, '/ ') . '/bootstrap.php'; + +// Grab our Console +$console = new \CodeIgniter\CLI\Console($app); + +// We want errors to be shown when using it from the CLI. +error_reporting(-1); +ini_set('display_errors', 1); + +// Show basic information before we do anything else. +$console->showHeader(); + +// fire off the command in the main framework. +$response = $console->run(); +if ($response->getStatusCode() >= 300) +{ + exit($response->getStatusCode()); +} diff --git a/tablesLibrary.sql b/tablesLibrary.sql new file mode 100644 index 0000000..ad148a1 --- /dev/null +++ b/tablesLibrary.sql @@ -0,0 +1,79 @@ +-- phpMyAdmin SQL Dump +-- version 4.9.2 +-- https://www.phpmyadmin.net/ +-- +-- äø»ę©Ÿļ¼š 127.0.0.1 +-- ē”¢ē”Ÿę™‚é–“ļ¼š 2020 幓 02 ꜈ 02 ę—„ 22:45 +-- ä¼ŗ꜍å™Øē‰ˆęœ¬ļ¼š 8.0.18 +-- PHP ē‰ˆęœ¬ļ¼š 7.3.11 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- č³‡ę–™åŗ«ļ¼š `tablesLibrary` +-- + +-- -------------------------------------------------------- + +-- +-- č³‡ę–™č”Øēµę§‹ `news` +-- + +CREATE TABLE `news` ( + `id` int(11) NOT NULL, + `title` varchar(128) COLLATE utf8_unicode_ci NOT NULL, + `slug` varchar(128) COLLATE utf8_unicode_ci NOT NULL, + `body` text COLLATE utf8_unicode_ci NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- +-- å‚¾å°č³‡ę–™č”Øēš„č³‡ę–™ `news` +-- + +INSERT INTO `news` (`id`, `title`, `slug`, `body`) VALUES +(1, 'title1', 't1', 'body1'), +(2, 'title2', 't2', 'body2'), +(3, 'title3', 't3', 'body3'), +(4, 'title4', 't4', 'body4'), +(5, 'title5', 't5', 'body5'), +(6, 'title6', 't6', 'body6'), +(7, 'title7', 't7', 'body7'), +(8, 'title8', 't8', 'body8'), +(9, 'title9', 't9', 'body9'), +(10, 'title10', 't10', 'body10'), +(11, 'title11', 't11', 'body11'); + +-- +-- å·²å‚¾å°č³‡ę–™č”Øēš„ē“¢å¼• +-- + +-- +-- č³‡ę–™č”Øē“¢å¼• `news` +-- +ALTER TABLE `news` + ADD PRIMARY KEY (`id`), + ADD KEY `slug` (`slug`); + +-- +-- åœØ傾印ēš„č³‡ę–™č”Øä½æē”Øč‡Ŗ動遞增(AUTO_INCREMENT) +-- + +-- +-- ä½æē”Øč³‡ę–™č”Øč‡Ŗ動遞增(AUTO_INCREMENT) `news` +-- +ALTER TABLE `news` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..d92566a --- /dev/null +++ b/tests/README.md @@ -0,0 +1,59 @@ +# Running System Tests + +This is the quick-start to CodeIgniter testing. Its intent is to describe what +it takes to get your system setup and ready to run the system tests. +It is not intended to be a full description of the test features that you can +use to test your application, since that can be found in the documentation. + +## Requirements + +It is recommended to use the latest version of PHPUnit. At the time of this +writing we are running version 7.5.1. Support for this has been built into the +**composer.json** file that ships with CodeIgniter, and can easily be installed +via [Composer](https://getcomposer.org/) if you don't already have it installed globally. + + > composer install + +If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer. + + > ln -s ./vendor/bin/phpunit ./phpunit + +You also need to install [XDebug](https://xdebug.org/index.php) in order +for the unit tests to successfully complete. + +## Setup + +A number of the tests that are ran during the test suite are ran against a running database. +In order to setup the database used here, edit the details for the `tests` database +group in **app/Config/Database.php**. Make sure that you provide a database engine +that is currently running, and have already created a table that you can use only +for these tests, as it will be wiped and refreshed often while running the test suite. + +A simplified PHPunit configuration file, **phpunit.dist.xml**, is provided. +You can use it as is, or copy it to **phpunit.xml**, and tailor it to suit your +application. + +## Running the tests + +The entire test suite can be ran by simply typing one command from the command line within the main directory. + + > ./phpunit + +You can limit tests to those within a single test directory by specifying the +directory name after phpunit. + + > ./phpunit app/Models + +## Generating Code Coverage + +To generate coverage information, including HTML reports you can view in your browser, +you can use the following command: + + > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m + +This runs all of the tests again, collecting information about how many lines, +functions, and files are tested, and the percent of the code that is covered by the tests. +It is collected in two formats: a simple text file that provides an overview, +as well as comprehensive collection of HTML files that show the status of every line of code in the project. + +Code coverage details will be left in the **tests/coverage** folder. diff --git a/tests/_support/Autoloader/UnnamespacedClass.php b/tests/_support/Autoloader/UnnamespacedClass.php new file mode 100644 index 0000000..67b1ed3 --- /dev/null +++ b/tests/_support/Autoloader/UnnamespacedClass.php @@ -0,0 +1,5 @@ +prefix . $key; + + return array_key_exists($key, $this->cache) + ? $this->cache[$key] + : null; + } + + //-------------------------------------------------------------------- + + /** + * Saves an item to the cache store. + * + * The $raw parameter is only utilized by Mamcache in order to + * allow usage of increment() and decrement(). + * + * @param string $key Cache item name + * @param $value the data to save + * @param null $ttl Time To Live, in seconds (default 60) + * @param boolean $raw Whether to store the raw value. + * + * @return mixed + */ + public function save(string $key, $value, int $ttl = 60, bool $raw = false) + { + $key = $this->prefix . $key; + + $this->cache[$key] = $value; + + return true; + } + + //-------------------------------------------------------------------- + + /** + * Deletes a specific item from the cache store. + * + * @param string $key Cache item name + * + * @return mixed + */ + public function delete(string $key) + { + unset($this->cache[$key]); + } + + //-------------------------------------------------------------------- + + /** + * Performs atomic incrementation of a raw stored value. + * + * @param string $key Cache ID + * @param integer $offset Step/value to increase by + * + * @return mixed + */ + public function increment(string $key, int $offset = 1) + { + $key = $this->prefix . $key; + + $data = $this->cache[$key] ?: null; + + if (empty($data)) + { + $data = 0; + } + elseif (! is_int($data)) + { + return false; + } + + return $this->save($key, $data + $offset); + } + + //-------------------------------------------------------------------- + + /** + * Performs atomic decrementation of a raw stored value. + * + * @param string $key Cache ID + * @param integer $offset Step/value to increase by + * + * @return mixed + */ + public function decrement(string $key, int $offset = 1) + { + $key = $this->prefix . $key; + + $data = $this->cache[$key] ?: null; + + if (empty($data)) + { + $data = 0; + } + elseif (! is_int($data)) + { + return false; + } + + return $this->save($key, $data - $offset); + } + + //-------------------------------------------------------------------- + + /** + * Will delete all items in the entire cache. + * + * @return mixed + */ + public function clean() + { + $this->cache = []; + } + + //-------------------------------------------------------------------- + + /** + * Returns information on the entire cache. + * + * The information returned and the structure of the data + * varies depending on the handler. + * + * @return mixed + */ + public function getCacheInfo() + { + return []; + } + + //-------------------------------------------------------------------- + + /** + * Returns detailed information about the specific item in the cache. + * + * @param string $key Cache item name. + * + * @return mixed + */ + public function getMetaData(string $key) + { + return false; + } + + //-------------------------------------------------------------------- + + /** + * Determines if the driver is supported on this system. + * + * @return boolean + */ + public function isSupported(): bool + { + return true; + } + + //-------------------------------------------------------------------- + +} diff --git a/tests/_support/Commands/AbstractInfo.php b/tests/_support/Commands/AbstractInfo.php new file mode 100644 index 0000000..2ca684e --- /dev/null +++ b/tests/_support/Commands/AbstractInfo.php @@ -0,0 +1,13 @@ +showError($oops); + } + } + + public function helpme() + { + $this->call('help'); + } +} diff --git a/tests/_support/Commands/CommandsTestStreamFilter.php b/tests/_support/Commands/CommandsTestStreamFilter.php new file mode 100644 index 0000000..599075b --- /dev/null +++ b/tests/_support/Commands/CommandsTestStreamFilter.php @@ -0,0 +1,18 @@ +data; + $consumed += $bucket->datalen; + } + return PSFS_PASS_ON; + } +} + +stream_filter_register('CommandsTestStreamFilter', 'CodeIgniter\Commands\CommandsTestStreamFilter'); diff --git a/tests/_support/Config/BadRegistrar.php b/tests/_support/Config/BadRegistrar.php new file mode 100644 index 0000000..a651d11 --- /dev/null +++ b/tests/_support/Config/BadRegistrar.php @@ -0,0 +1,18 @@ + [ + /* + * The log levels that this handler will handle. + */ + 'handles' => [ + 'critical', + 'alert', + 'emergency', + 'debug', + 'error', + 'info', + 'notice', + 'warning', + ], + ], + ]; + +} diff --git a/tests/_support/Config/MockServices.php b/tests/_support/Config/MockServices.php new file mode 100644 index 0000000..0bd6400 --- /dev/null +++ b/tests/_support/Config/MockServices.php @@ -0,0 +1,28 @@ + TESTPATH . '_support/', + ]; + public $classmap = []; + + //-------------------------------------------------------------------- + + public function __construct() + { + // Don't call the parent since we don't want the default mappings. + // parent::__construct(); + } + + //-------------------------------------------------------------------- + public static function locator(bool $getShared = true) + { + return new \CodeIgniter\Autoloader\FileLocator(static::autoloader()); + } + +} diff --git a/tests/_support/Config/Registrar.php b/tests/_support/Config/Registrar.php new file mode 100644 index 0000000..9d00c6a --- /dev/null +++ b/tests/_support/Config/Registrar.php @@ -0,0 +1,27 @@ + [ + 'first', + 'second', + ], + 'format' => 'nice', + 'fruit' => [ + 'apple', + 'banana', + ], + ]; + } + +} diff --git a/tests/_support/Config/Routes.php b/tests/_support/Config/Routes.php new file mode 100644 index 0000000..2369e33 --- /dev/null +++ b/tests/_support/Config/Routes.php @@ -0,0 +1,7 @@ +add('testing', 'TestController::index'); diff --git a/tests/_support/Controllers/Popcorn.php b/tests/_support/Controllers/Popcorn.php new file mode 100644 index 0000000..8af998d --- /dev/null +++ b/tests/_support/Controllers/Popcorn.php @@ -0,0 +1,77 @@ +respond('Oops', 567, 'Surprise'); + } + + public function popper() + { + throw new \RuntimeException('Surprise', 500); + } + + public function weasel() + { + $this->respond('', 200); + } + + public function oops() + { + $this->failUnauthorized(); + } + + public function goaway() + { + return redirect()->to('/'); + } + + // @see https://github.com/codeigniter4/CodeIgniter4/issues/1834 + public function index3() + { + $response = $this->response->setJSON([ + 'lang' => $this->request->getLocale(), + ]); + + // echo var_dump($this->response->getBody()); + return $response; + } + + public function canyon() + { + echo 'Hello-o-o'; + } + + public function cat() + { + } + + public function json() + { + $this->responsd(['answer' => 42]); + } + + public function xml() + { + $this->respond('cat'); + } + +} diff --git a/tests/_support/Database/MockBuilder.php b/tests/_support/Database/MockBuilder.php new file mode 100644 index 0000000..98c7fb6 --- /dev/null +++ b/tests/_support/Database/MockBuilder.php @@ -0,0 +1,15 @@ +returnValues[$method] = $return; + + return $this; + } + + //-------------------------------------------------------------------- + + /** + * Orchestrates a query against the database. Queries must use + * Database\Statement objects to store the query and build it. + * This method works with the cache. + * + * Should automatically handle different connections for read/write + * queries if needed. + * + * @param string $sql + * @param mixed ...$binds + * @param boolean $setEscapeFlags + * @param string $queryClass + * + * @return \CodeIgniter\Database\BaseResult|\CodeIgniter\Database\Query|false + */ + + public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = 'CodeIgniter\\Database\\Query') + { + $queryClass = str_replace('Connection', 'Query', get_class($this)); + + $query = new $queryClass($this); + + $query->setQuery($sql, $binds, $setEscapeFlags); + + if (! empty($this->swapPre) && ! empty($this->DBPrefix)) + { + $query->swapPrefix($this->DBPrefix, $this->swapPre); + } + + $startTime = microtime(true); + + $this->lastQuery = $query; + + // Run the query + if (false === ($this->resultID = $this->simpleQuery($query->getQuery()))) + { + $query->setDuration($startTime, $startTime); + + // @todo deal with errors + + return false; + } + + $query->setDuration($startTime); + + $resultClass = str_replace('Connection', 'Result', get_class($this)); + + return new $resultClass($this->connID, $this->resultID); + } + + //-------------------------------------------------------------------- + + /** + * Connect to the database. + * + * @param boolean $persistent + * + * @return mixed + */ + public function connect(bool $persistent = false) + { + $return = $this->returnValues['connect'] ?? true; + + if (is_array($return)) + { + // By removing the top item here, we can + // get a different value for, say, testing failover connections. + $return = array_shift($this->returnValues['connect']); + } + + return $return; + } + + //-------------------------------------------------------------------- + + /** + * Keep or establish the connection if no queries have been sent for + * a length of time exceeding the server's idle timeout. + * + * @return boolean + */ + public function reconnect(): bool + { + return true; + } + + //-------------------------------------------------------------------- + + /** + * Select a specific database table to use. + * + * @param string $databaseName + * + * @return mixed + */ + public function setDatabase(string $databaseName) + { + $this->database = $databaseName; + + return $this; + } + + //-------------------------------------------------------------------- + + /** + * Returns a string containing the version of the database being used. + * + * @return string + */ + public function getVersion(): string + { + return CodeIgniter::CI_VERSION; + } + + //-------------------------------------------------------------------- + + /** + * Executes the query against the database. + * + * @param string $sql + * + * @return mixed + */ + protected function execute(string $sql) + { + return $this->returnValues['execute']; + } + + //-------------------------------------------------------------------- + + /** + * Returns the total number of rows affected by this query. + * + * @return integer + */ + public function affectedRows(): int + { + return 1; + } + + //-------------------------------------------------------------------- + + /** + * Returns the last error code and message. + * + * Must return an array with keys 'code' and 'message': + * + * return ['code' => null, 'message' => null); + * + * @return array + */ + public function error(): array + { + return [ + 'code' => null, + 'message' => null, + ]; + } + + //-------------------------------------------------------------------- + + /** + * Insert ID + * + * @return integer + */ + public function insertID(): int + { + return $this->connID->insert_id; + } + + //-------------------------------------------------------------------- + + /** + * Generates the SQL for listing tables in a platform-dependent manner. + * + * @param boolean $constrainByPrefix + * + * @return string + */ + protected function _listTables(bool $constrainByPrefix = false): string + { + return ''; + } + + //-------------------------------------------------------------------- + + /** + * Generates a platform-specific query string so that the column names can be fetched. + * + * @param string $table + * + * @return string + */ + protected function _listColumns(string $table = ''): string + { + return ''; + } + + /** + * @param string $table + * @return array + */ + protected function _fieldData(string $table): array + { + return []; + } + + /** + * @param string $table + * @return array + */ + protected function _indexData(string $table): array + { + return []; + } + + /** + * @param string $table + * @return array + */ + protected function _foreignKeyData(string $table): array + { + return []; + } + + //-------------------------------------------------------------------- + + /** + * Close the connection. + */ + protected function _close() + { + return; + } + + //-------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @return boolean + */ + protected function _transBegin(): bool + { + return true; + } + + //-------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return boolean + */ + protected function _transCommit(): bool + { + return true; + } + + //-------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return boolean + */ + protected function _transRollback(): bool + { + return true; + } + + //-------------------------------------------------------------------- +} diff --git a/tests/_support/Database/MockQuery.php b/tests/_support/Database/MockQuery.php new file mode 100644 index 0000000..0008104 --- /dev/null +++ b/tests/_support/Database/MockQuery.php @@ -0,0 +1,8 @@ + [ + [ + 'name' => 'Derek Jones', + 'email' => 'derek@world.com', + 'country' => 'US', + ], + [ + 'name' => 'Ahmadinejad', + 'email' => 'ahmadinejad@world.com', + 'country' => 'Iran', + ], + [ + 'name' => 'Richard A Causey', + 'email' => 'richard@world.com', + 'country' => 'US', + ], + [ + 'name' => 'Chris Martin', + 'email' => 'chris@world.com', + 'country' => 'UK', + ], + ], + 'job' => [ + [ + 'name' => 'Developer', + 'description' => 'Awesome job, but sometimes makes you bored', + ], + [ + 'name' => 'Politician', + 'description' => 'This is not really a job', + ], + [ + 'name' => 'Accountant', + 'description' => 'Boring job, but you will get free snack at lunch', + ], + [ + 'name' => 'Musician', + 'description' => 'Only Coldplay can actually called Musician', + ], + ], + 'misc' => [ + [ + 'key' => '\\xxxfoo456', + 'value' => 'Entry with \\xxx', + ], + [ + 'key' => '\\%foo456', + 'value' => 'Entry with \\%', + ], + [ + 'key' => 'spaces and tabs', + 'value' => ' One two three tab', + ], + ], + ]; + + foreach ($data as $table => $dummy_data) + { + $this->db->table($table)->truncate(); + + foreach ($dummy_data as $single_dummy_data) + { + $this->db->table($table)->insert($single_dummy_data); + } + } + } + + //-------------------------------------------------------------------- + +} diff --git a/tests/_support/DatabaseTestMigrations/Database/Migrations/20160428212500_Create_test_tables.php b/tests/_support/DatabaseTestMigrations/Database/Migrations/20160428212500_Create_test_tables.php new file mode 100644 index 0000000..8514ba4 --- /dev/null +++ b/tests/_support/DatabaseTestMigrations/Database/Migrations/20160428212500_Create_test_tables.php @@ -0,0 +1,148 @@ +db->DBDriver === 'SQLite3' ? 'unique' : 'auto_increment'; + + // User Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + ], + 'email' => [ + 'type' => 'VARCHAR', + 'constraint' => 100, + ], + 'country' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'deleted_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('user', true); + + // Job Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'description' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'created_at' => [ + 'type' => 'INTEGER', + 'constraint' => 11, + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'INTEGER', + 'constraint' => 11, + 'null' => true, + ], + 'deleted_at' => [ + 'type' => 'INTEGER', + 'constraint' => 11, + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('job', true); + + // Misc Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'key' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'value' => ['type' => 'TEXT'], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('misc', true); + + // Empty Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'created_at' => [ + 'type' => 'DATE', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATE', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('empty', true); + + // Secondary Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'key' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'value' => ['type' => 'TEXT'], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('secondary', true); + } + + //-------------------------------------------------------------------- + + public function down() + { + $this->forge->dropTable('user', true); + $this->forge->dropTable('job', true); + $this->forge->dropTable('misc', true); + $this->forge->dropTable('empty', true); + $this->forge->dropTable('secondary', true); + } + + //-------------------------------------------------------------------- + +} diff --git a/tests/_support/Events/MockEvents.php b/tests/_support/Events/MockEvents.php new file mode 100644 index 0000000..eb9186b --- /dev/null +++ b/tests/_support/Events/MockEvents.php @@ -0,0 +1,66 @@ +output = $output; + + return $this; + } + + //-------------------------------------------------------------------- + + protected function sendRequest(array $curl_options = []): string + { + // Save so we can access later. + $this->curl_options = $curl_options; + + return $this->output; + } + + //-------------------------------------------------------------------- + // for testing purposes only + public function getBaseURI() + { + return $this->baseURI; + } + + // for testing purposes only + public function getDelay() + { + return $this->delay; + } + +} diff --git a/tests/_support/HTTP/MockIncomingRequest.php b/tests/_support/HTTP/MockIncomingRequest.php new file mode 100644 index 0000000..627fc9a --- /dev/null +++ b/tests/_support/HTTP/MockIncomingRequest.php @@ -0,0 +1,17 @@ +pretend; + } + + // artificial error for testing + public function misbehave() + { + $this->statusCode = 0; + } + +} diff --git a/tests/_support/Images/EXIFsamples/down-mirrored.jpg b/tests/_support/Images/EXIFsamples/down-mirrored.jpg new file mode 100644 index 0000000..34a7b1d Binary files /dev/null and b/tests/_support/Images/EXIFsamples/down-mirrored.jpg differ diff --git a/tests/_support/Images/EXIFsamples/down.jpg b/tests/_support/Images/EXIFsamples/down.jpg new file mode 100644 index 0000000..9077a7c Binary files /dev/null and b/tests/_support/Images/EXIFsamples/down.jpg differ diff --git a/tests/_support/Images/EXIFsamples/left-mirrored.jpg b/tests/_support/Images/EXIFsamples/left-mirrored.jpg new file mode 100644 index 0000000..1832702 Binary files /dev/null and b/tests/_support/Images/EXIFsamples/left-mirrored.jpg differ diff --git a/tests/_support/Images/EXIFsamples/left.jpg b/tests/_support/Images/EXIFsamples/left.jpg new file mode 100644 index 0000000..ad1f898 Binary files /dev/null and b/tests/_support/Images/EXIFsamples/left.jpg differ diff --git a/tests/_support/Images/EXIFsamples/right-mirrored.jpg b/tests/_support/Images/EXIFsamples/right-mirrored.jpg new file mode 100644 index 0000000..cc8a29a Binary files /dev/null and b/tests/_support/Images/EXIFsamples/right-mirrored.jpg differ diff --git a/tests/_support/Images/EXIFsamples/right.jpg b/tests/_support/Images/EXIFsamples/right.jpg new file mode 100644 index 0000000..183ffeb Binary files /dev/null and b/tests/_support/Images/EXIFsamples/right.jpg differ diff --git a/tests/_support/Images/EXIFsamples/up-mirrored.jpg b/tests/_support/Images/EXIFsamples/up-mirrored.jpg new file mode 100644 index 0000000..e1865a5 Binary files /dev/null and b/tests/_support/Images/EXIFsamples/up-mirrored.jpg differ diff --git a/tests/_support/Images/EXIFsamples/up.jpg b/tests/_support/Images/EXIFsamples/up.jpg new file mode 100644 index 0000000..70fc26f Binary files /dev/null and b/tests/_support/Images/EXIFsamples/up.jpg differ diff --git a/tests/_support/Images/Steveston_dusk.JPG b/tests/_support/Images/Steveston_dusk.JPG new file mode 100644 index 0000000..c3b9b12 Binary files /dev/null and b/tests/_support/Images/Steveston_dusk.JPG differ diff --git a/tests/_support/Images/ci-logo.gif b/tests/_support/Images/ci-logo.gif new file mode 100644 index 0000000..3001b2f Binary files /dev/null and b/tests/_support/Images/ci-logo.gif differ diff --git a/tests/_support/Images/ci-logo.jpeg b/tests/_support/Images/ci-logo.jpeg new file mode 100644 index 0000000..1b0178b Binary files /dev/null and b/tests/_support/Images/ci-logo.jpeg differ diff --git a/tests/_support/Images/ci-logo.png b/tests/_support/Images/ci-logo.png new file mode 100644 index 0000000..34fb010 Binary files /dev/null and b/tests/_support/Images/ci-logo.png differ diff --git a/tests/_support/Language/MockLanguage.php b/tests/_support/Language/MockLanguage.php new file mode 100644 index 0000000..49301db --- /dev/null +++ b/tests/_support/Language/MockLanguage.php @@ -0,0 +1,61 @@ +language[$locale ?? $this->locale][$file] = $data; + + return $this; + } + + //-------------------------------------------------------------------- + + /** + * Provides an override that allows us to set custom + * data to be returned easily during testing. + * + * @param string $path + * + * @return array|mixed + */ + protected function requireFile(string $path): array + { + return $this->data ?? []; + } + + //-------------------------------------------------------------------- + + /** + * Arbitrarily turnoff internationalization support for testing + */ + public function disableIntlSupport() + { + $this->intlSupport = false; + } + +} diff --git a/tests/_support/Language/SecondMockLanguage.php b/tests/_support/Language/SecondMockLanguage.php new file mode 100644 index 0000000..7142885 --- /dev/null +++ b/tests/_support/Language/SecondMockLanguage.php @@ -0,0 +1,27 @@ +load($file, $locale, $return); + } + + //-------------------------------------------------------------------- + + /** + * Expose the loaded language files + */ + public function loaded(string $locale = 'en') + { + return $this->loadedFiles[$locale]; + } + +} diff --git a/tests/_support/Language/ab-CD/Allin.php b/tests/_support/Language/ab-CD/Allin.php new file mode 100644 index 0000000..3b15388 --- /dev/null +++ b/tests/_support/Language/ab-CD/Allin.php @@ -0,0 +1,8 @@ + 'Pyramid of Giza', + 'tre' => 'Colossus of Rhodes', + 'fiv' => 'Temple of Artemis', + 'sev' => 'Hanging Gardens of Babylon', +]; diff --git a/tests/_support/Language/ab/Allin.php b/tests/_support/Language/ab/Allin.php new file mode 100644 index 0000000..6912075 --- /dev/null +++ b/tests/_support/Language/ab/Allin.php @@ -0,0 +1,8 @@ + 'gluttony', + 'tre' => 'greed', + 'six' => 'envy', + 'sev' => 'pride', +]; diff --git a/tests/_support/Language/en-ZZ/More.php b/tests/_support/Language/en-ZZ/More.php new file mode 100644 index 0000000..6681020 --- /dev/null +++ b/tests/_support/Language/en-ZZ/More.php @@ -0,0 +1,6 @@ + 'These are not the droids you are looking for', + 'notaMoon' => "It's made of cheese", + 'wisdom' => 'There is no try', +]; diff --git a/tests/_support/Language/en/Allin.php b/tests/_support/Language/en/Allin.php new file mode 100644 index 0000000..6a10dcc --- /dev/null +++ b/tests/_support/Language/en/Allin.php @@ -0,0 +1,8 @@ + 'four calling birds', + 'fiv' => 'five golden rings', + 'six' => 'six geese a laying', + 'sev' => 'seven swans a swimming', +]; diff --git a/tests/_support/Language/en/Core.php b/tests/_support/Language/en/Core.php new file mode 100644 index 0000000..b2fc4c1 --- /dev/null +++ b/tests/_support/Language/en/Core.php @@ -0,0 +1,20 @@ + '{0} extension could not be found.', + 'bazillion' => 'billions and billions', // adds a new setting +]; diff --git a/tests/_support/Language/en/More.php b/tests/_support/Language/en/More.php new file mode 100644 index 0000000..5b4eaea --- /dev/null +++ b/tests/_support/Language/en/More.php @@ -0,0 +1,7 @@ + 'These are not the droids you are looking for', + 'notaMoon' => "That's no moon... it's a space station", + 'cannotMove' => 'I have a very bad feeling about this', +]; diff --git a/tests/_support/Language/ru/Language.php b/tests/_support/Language/ru/Language.php new file mode 100644 index 0000000..d6c6632 --- /dev/null +++ b/tests/_support/Language/ru/Language.php @@ -0,0 +1,5 @@ + 'Whatever this would be, translated', +]; diff --git a/tests/_support/Log/Handlers/MockChromeHandler.php b/tests/_support/Log/Handlers/MockChromeHandler.php new file mode 100644 index 0000000..1a64b22 --- /dev/null +++ b/tests/_support/Log/Handlers/MockChromeHandler.php @@ -0,0 +1,25 @@ +json['rows'][0]; + } + +} diff --git a/tests/_support/Log/Handlers/MockFileHandler.php b/tests/_support/Log/Handlers/MockFileHandler.php new file mode 100644 index 0000000..efd72a9 --- /dev/null +++ b/tests/_support/Log/Handlers/MockFileHandler.php @@ -0,0 +1,25 @@ +handles = $config['handles'] ?? []; + $this->destination = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension; + } + +} diff --git a/tests/_support/Log/Handlers/TestHandler.php b/tests/_support/Log/Handlers/TestHandler.php new file mode 100644 index 0000000..e22559c --- /dev/null +++ b/tests/_support/Log/Handlers/TestHandler.php @@ -0,0 +1,64 @@ +handles = $config['handles'] ?? []; + $this->destination = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension; + + self::$logs = []; + } + + //-------------------------------------------------------------------- + + /** + * Handles logging the message. + * If the handler returns false, then execution of handlers + * will stop. Any handlers that have not run, yet, will not + * be run. + * + * @param $level + * @param $message + * + * @return boolean + */ + public function handle($level, $message): bool + { + $date = date($this->dateFormat); + + self::$logs[] = strtoupper($level) . ' - ' . $date . ' --> ' . $message; + + return true; + } + + //-------------------------------------------------------------------- + + public static function getLogs() + { + return self::$logs; + } + + //-------------------------------------------------------------------- +} diff --git a/tests/_support/Log/TestLogger.php b/tests/_support/Log/TestLogger.php new file mode 100644 index 0000000..a88eb62 --- /dev/null +++ b/tests/_support/Log/TestLogger.php @@ -0,0 +1,82 @@ +assertLogged() methods. + * + * @param string $level + * @param string $message + * @param array $context + * + * @return boolean + */ + public function log($level, $message, array $context = []): bool + { + // While this requires duplicate work, we want to ensure + // we have the final message to test against. + $log_message = $this->interpolate($message, $context); + + // Determine the file and line by finding the first + // backtrace that is not part of our logging system. + $trace = debug_backtrace(); + $file = null; + + foreach ($trace as $row) + { + if (! in_array($row['function'], ['log', 'log_message'])) + { + $file = basename($row['file'] ?? ''); + break; + } + } + + self::$op_logs[] = [ + 'level' => $level, + 'message' => $log_message, + 'file' => $file, + ]; + + // Let the parent do it's thing. + return parent::log($level, $message, $context); + } + + //-------------------------------------------------------------------- + + /** + * Used by CIUnitTestCase class to provide ->assertLogged() methods. + * + * @param string $level + * @param string $message + * + * @return boolean + */ + public static function didLog(string $level, $message) + { + foreach (self::$op_logs as $log) + { + if (strtolower($log['level']) === strtolower($level) && $message === $log['message']) + { + return true; + } + } + + return false; + } + + //-------------------------------------------------------------------- + // Expose cleanFileNames() + public function cleanup($file) + { + return $this->cleanFileNames($file); + } + +} diff --git a/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102300_Another_migration.py b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102300_Another_migration.py new file mode 100644 index 0000000..908a6dd --- /dev/null +++ b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102300_Another_migration.py @@ -0,0 +1,24 @@ +forge->addField([ + 'key' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + ], + ]); + $this->forge->createTable('foo', true); + + $this->db->table('foo')->insert([ + 'key' => 'foobar', + ]); + } + + public function down() + { + $this->forge->dropTable('foo', true); + } +} diff --git a/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php new file mode 100644 index 0000000..e7763a8 --- /dev/null +++ b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php @@ -0,0 +1,24 @@ +forge->addField([ + 'key' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + ], + ]); + $this->forge->createTable('foo', true); + + $this->db->table('foo')->insert([ + 'key' => 'foobar', + ]); + } + + public function down() + { + $this->forge->dropTable('foo', true); + } +} diff --git a/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php new file mode 100644 index 0000000..797aae7 --- /dev/null +++ b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php @@ -0,0 +1,28 @@ + [ + 'type' => 'VARCHAR', + 'constraint' => 255, + ], + ]; + $this->forge->addColumn('foo', $fields); + + $this->db->table('foo')->insert([ + 'key' => 'foobar', + 'value' => 'raboof', + ]); + } + + public function down() + { + if ($this->db->tableExists('foo')) + { + $this->forge->dropColumn('foo', 'value'); + } + } +} diff --git a/tests/_support/MockCodeIgniter.php b/tests/_support/MockCodeIgniter.php new file mode 100644 index 0000000..3e31d00 --- /dev/null +++ b/tests/_support/MockCodeIgniter.php @@ -0,0 +1,11 @@ +tokens[] = 'beforeInsert'; + + return $data; + } + + protected function afterInsertMethod(array $data) + { + $this->tokens[] = 'afterInsert'; + + return $data; + } + + protected function beforeUpdateMethod(array $data) + { + $this->tokens[] = 'beforeUpdate'; + + return $data; + } + + protected function afterUpdateMethod(array $data) + { + $this->tokens[] = 'afterUpdate'; + + return $data; + } + + protected function afterFindMethod(array $data) + { + $this->tokens[] = 'afterFind'; + + return $data; + } + + protected function afterDeleteMethod(array $data) + { + $this->tokens[] = 'afterDelete'; + + return $data; + } + + public function hasToken(string $token) + { + return in_array($token, $this->tokens); + } + +} diff --git a/tests/_support/Models/JobModel.php b/tests/_support/Models/JobModel.php new file mode 100644 index 0000000..98c4ad2 --- /dev/null +++ b/tests/_support/Models/JobModel.php @@ -0,0 +1,23 @@ + [ + 'required', + 'min_length[10]', + 'errors' => [ + 'min_length' => 'Minimum Length Error', + ] + ], + 'token' => 'in_list[{id}]', + ]; +} diff --git a/tests/_support/Models/ValidModel.php b/tests/_support/Models/ValidModel.php new file mode 100644 index 0000000..69842d8 --- /dev/null +++ b/tests/_support/Models/ValidModel.php @@ -0,0 +1,34 @@ + [ + 'required', + 'min_length[3]', + ], + 'token' => 'in_list[{id}]', + ]; + + protected $validationMessages = [ + 'name' => [ + 'required' => 'You forgot to name the baby.', + 'min_length' => 'Too short, man!', + ], + ]; +} diff --git a/tests/_support/RESTful/MockResourceController.php b/tests/_support/RESTful/MockResourceController.php new file mode 100644 index 0000000..21f4343 --- /dev/null +++ b/tests/_support/RESTful/MockResourceController.php @@ -0,0 +1,24 @@ +model; + } + + public function getModelName() + { + return $this->modelName; + } + + public function getFormat() + { + return $this->format; + } + +} diff --git a/tests/_support/RESTful/MockResourcePresenter.php b/tests/_support/RESTful/MockResourcePresenter.php new file mode 100644 index 0000000..d9b0951 --- /dev/null +++ b/tests/_support/RESTful/MockResourcePresenter.php @@ -0,0 +1,24 @@ +model; + } + + public function getModelName() + { + return $this->modelName; + } + + public function getFormat() + { + return $this->format; + } + +} diff --git a/tests/_support/RESTful/Worker.php b/tests/_support/RESTful/Worker.php new file mode 100644 index 0000000..973543f --- /dev/null +++ b/tests/_support/RESTful/Worker.php @@ -0,0 +1,11 @@ +CSRFHash; + + return $this; + } + + //-------------------------------------------------------------------- + +} diff --git a/tests/_support/Services.php b/tests/_support/Services.php new file mode 100644 index 0000000..48e8283 --- /dev/null +++ b/tests/_support/Services.php @@ -0,0 +1,70 @@ +driver, true); + } + + //-------------------------------------------------------------------- + + /** + * Starts the session. + * Extracted for testing reasons. + */ + protected function startSession() + { + // session_start(); + } + + //-------------------------------------------------------------------- + + /** + * Takes care of setting the cookie on the client side. + * Extracted for testing reasons. + */ + protected function setCookie() + { + $this->cookies[] = [ + $this->sessionCookieName, + session_id(), + (empty($this->sessionExpiration) ? 0 : time() + $this->sessionExpiration), + $this->cookiePath, + $this->cookieDomain, + $this->cookieSecure, + true, + ]; + } + + //-------------------------------------------------------------------- + + public function regenerate(bool $destroy = false) + { + $this->didRegenerate = true; + $_SESSION['__ci_last_regenerate'] = time(); + } + + //-------------------------------------------------------------------- +} diff --git a/tests/_support/SomeEntity.php b/tests/_support/SomeEntity.php new file mode 100644 index 0000000..3d22993 --- /dev/null +++ b/tests/_support/SomeEntity.php @@ -0,0 +1,14 @@ + null, + 'bar' => null, + ]; + +} diff --git a/tests/_support/Validation/TestRules.php b/tests/_support/Validation/TestRules.php new file mode 100644 index 0000000..2c40f32 --- /dev/null +++ b/tests/_support/Validation/TestRules.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/tests/_support/View/Views/simpler.php b/tests/_support/View/Views/simpler.php new file mode 100644 index 0000000..0588b62 --- /dev/null +++ b/tests/_support/View/Views/simpler.php @@ -0,0 +1 @@ +

{testString}

\ No newline at end of file diff --git a/tests/_support/_bootstrap.php b/tests/_support/_bootstrap.php new file mode 100644 index 0000000..65dd9a1 --- /dev/null +++ b/tests/_support/_bootstrap.php @@ -0,0 +1,32 @@ + + Require all denied + + + Deny from all + diff --git a/writable/cache/index.html b/writable/cache/index.html new file mode 100755 index 0000000..b702fbc --- /dev/null +++ b/writable/cache/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/logs/index.html b/writable/logs/index.html new file mode 100755 index 0000000..b702fbc --- /dev/null +++ b/writable/logs/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/session/index.html b/writable/session/index.html new file mode 100755 index 0000000..b702fbc --- /dev/null +++ b/writable/session/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/uploads/index.html b/writable/uploads/index.html new file mode 100755 index 0000000..b702fbc --- /dev/null +++ b/writable/uploads/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + +