Integrado ultimo CI4 y modificando archivos para que rule

This commit is contained in:
imnavajas
2024-04-25 23:02:43 +02:00
parent d0b340535b
commit 16a5120e2b
22 changed files with 1308 additions and 787 deletions

View File

@ -25,6 +25,19 @@ class App extends BaseConfig
*/ */
public $baseURL = ''; public $baseURL = '';
/**
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
* If you want to accept multiple Hostnames, set this.
*
* E.g.,
* When your site URL ($baseURL) is 'http://example.com/', and your site
* also accepts 'http://media.example.com/' and 'http://accounts.example.com/':
* ['media.example.com', 'accounts.example.com']
*
* @var list<string>
*/
public array $allowedHostnames = [];
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* Index File * Index File
@ -325,6 +338,7 @@ class App extends BaseConfig
*/ */
public $cookieSameSite = 'Lax'; public $cookieSameSite = 'Lax';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* Reverse Proxy IPs * Reverse Proxy IPs
@ -332,18 +346,21 @@ class App extends BaseConfig
* *
* If your server is behind a reverse proxy, you must whitelist the proxy * If your server is behind a reverse proxy, you must whitelist the proxy
* IP addresses from which CodeIgniter should trust headers such as * IP addresses from which CodeIgniter should trust headers such as
* HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify * X-Forwarded-For or Client-IP in order to properly identify
* the visitor's IP address. * the visitor's IP address.
* *
* You can use both an array or a comma-separated list of proxy addresses, * You need to set a proxy IP address or IP address with subnets and
* as well as specifying whole subnets. Here are a few examples: * the HTTP header for the client IP address.
* *
* Comma-separated: '10.0.1.200,192.168.5.0/24' * Here are some examples:
* Array: ['10.0.1.200', '192.168.5.0/24'] * [
* '10.0.1.200' => 'X-Forwarded-For',
* '192.168.5.0/24' => 'X-Real-IP',
* ]
* *
* @var string|string[] * @var array<string, string>
*/ */
public $proxyIPs = ''; public array $proxyIPs = [];
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------

View File

@ -0,0 +1,20 @@
<?php
namespace App\Config;
use CodeIgniter\Config\BaseConfig;
class CURLRequest extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* CURLRequest Share Options
* --------------------------------------------------------------------------
*
* Whether share options between requests or not.
*
* If true, all the options won't be reset between requests.
* It may cause an error request with unnecessary headers.
*/
public bool $shareOptions = false;
}

View File

@ -13,10 +13,8 @@ class Cookie extends BaseConfig
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Set a cookie name prefix if you need to avoid collisions. * Set a cookie name prefix if you need to avoid collisions.
*
* @var string
*/ */
public $prefix = ''; public string $prefix = '';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -37,10 +35,8 @@ class Cookie extends BaseConfig
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Typically will be a forward slash. * Typically will be a forward slash.
*
* @var string
*/ */
public $path = '/'; public string $path = '/';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -48,10 +44,8 @@ class Cookie extends BaseConfig
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Set to `.your-domain.com` for site-wide cookies. * Set to `.your-domain.com` for site-wide cookies.
*
* @var string
*/ */
public $domain = ''; public string $domain = '';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -59,10 +53,8 @@ class Cookie extends BaseConfig
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Cookie will only be set if a secure HTTPS connection exists. * Cookie will only be set if a secure HTTPS connection exists.
*
* @var bool
*/ */
public $secure = false; public bool $secure = false;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -70,10 +62,8 @@ class Cookie extends BaseConfig
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Cookie will only be accessible via HTTP(S) (no JavaScript). * Cookie will only be accessible via HTTP(S) (no JavaScript).
*
* @var bool
*/ */
public $httponly = true; public bool $httponly = true;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -95,9 +85,9 @@ class Cookie extends BaseConfig
* (empty string) means default SameSite attribute set by browsers (`Lax`) * (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$secure` must also be set. * will be set on cookies. If set to `None`, `$secure` must also be set.
* *
* @var string * @phpstan-var 'None'|'Lax'|'Strict'|''
*/ */
public $samesite = 'Lax'; public string $samesite = 'Lax';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -110,10 +100,8 @@ class Cookie extends BaseConfig
* If this is set to `true`, cookie names should be compliant of RFC 2616's * If this is set to `true`, cookie names should be compliant of RFC 2616's
* list of allowed characters. * list of allowed characters.
* *
* @var bool
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
* @see https://tools.ietf.org/html/rfc2616#section-2.2 * @see https://tools.ietf.org/html/rfc2616#section-2.2
*/ */
public $raw = false; public bool $raw = false;
} }

View File

@ -12,25 +12,19 @@ class Database extends Config
/** /**
* The directory that holds the Migrations * The directory that holds the Migrations
* and Seeds directories. * and Seeds directories.
*
* @var string
*/ */
public $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR; public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
/** /**
* Lets you choose which connection group to * Lets you choose which connection group to
* use if no other is specified. * use if no other is specified.
*
* @var string
*/ */
public $defaultGroup = 'default'; public string $defaultGroup = 'default';
/** /**
* The default database connection. * The default database connection.
*
* @var array
*/ */
public $default = [ public array $default = [
'DSN' => '', 'DSN' => '',
'hostname' => 'localhost', 'hostname' => 'localhost',
'username' => '', 'username' => '',
@ -39,7 +33,7 @@ class Database extends Config
'DBDriver' => 'MySQLi', 'DBDriver' => 'MySQLi',
'DBPrefix' => '', 'DBPrefix' => '',
'pConnect' => false, 'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'), 'DBDebug' => true,
'charset' => 'utf8', 'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci', 'DBCollat' => 'utf8_general_ci',
'swapPre' => '', 'swapPre' => '',
@ -48,15 +42,14 @@ class Database extends Config
'strictOn' => false, 'strictOn' => false,
'failover' => [], 'failover' => [],
'port' => 3306, 'port' => 3306,
'numberNative' => false,
]; ];
/** /**
* This database connection is used when * This database connection is used when
* running PHPUnit database tests. * running PHPUnit database tests.
*
* @var array
*/ */
public $tests = [ public array $tests = [
'DSN' => '', 'DSN' => '',
'hostname' => '127.0.0.1', 'hostname' => '127.0.0.1',
'username' => '', 'username' => '',
@ -65,7 +58,7 @@ class Database extends Config
'DBDriver' => 'SQLite3', 'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false, 'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'), 'DBDebug' => true,
'charset' => 'utf8', 'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci', 'DBCollat' => 'utf8_general_ci',
'swapPre' => '', 'swapPre' => '',
@ -74,6 +67,8 @@ class Database extends Config
'strictOn' => false, 'strictOn' => false,
'failover' => [], 'failover' => [],
'port' => 3306, 'port' => 3306,
'foreignKeys' => true,
'busyTimeout' => 1000,
]; ];
public function __construct() public function __construct()

View File

@ -4,6 +4,7 @@ namespace Config;
use CodeIgniter\Events\Events; use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\FrameworkException; use CodeIgniter\Exceptions\FrameworkException;
use CodeIgniter\HotReloader\HotReloader;
/* /*
* -------------------------------------------------------------------- * --------------------------------------------------------------------
@ -32,9 +33,7 @@ Events::on('pre_system', static function () {
ob_end_flush(); ob_end_flush();
} }
ob_start(static function ($buffer) { ob_start(static fn ($buffer) => $buffer);
return $buffer;
});
} }
/* /*
@ -46,5 +45,24 @@ Events::on('pre_system', static function () {
if (CI_DEBUG && ! is_cli()) { if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect'); Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond(); Services::toolbar()->respond();
// Hot Reload route - for framework use on the hot reloader.
if (ENVIRONMENT === 'development') {
Services::routes()->get('__hot-reload', static function () {
(new HotReloader())->run();
});
}
} }
}); });
/*
Events::on('login', static function ($user) {
helper('logger');
getSystemSettings();
setLog('information','user-login', $user->id);
});
Events::on('logout', static function ($user) {
helper('logger');
setLog('information','user-logout', $user->id);
});
*/

View File

@ -3,6 +3,10 @@
namespace Config; namespace Config;
use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Debug\ExceptionHandler;
use CodeIgniter\Debug\ExceptionHandlerInterface;
use Psr\Log\LogLevel;
use Throwable;
/** /**
* Setup how the exception handler works. * Setup how the exception handler works.
@ -17,10 +21,8 @@ class Exceptions extends BaseConfig
* through Services::Log. * through Services::Log.
* *
* Default: true * Default: true
*
* @var bool
*/ */
public $log = true; public bool $log = true;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -28,10 +30,8 @@ class Exceptions extends BaseConfig
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* Any status codes here will NOT be logged if logging is turned on. * Any status codes here will NOT be logged if logging is turned on.
* By default, only 404 (Page Not Found) exceptions are ignored. * By default, only 404 (Page Not Found) exceptions are ignored.
*
* @var array
*/ */
public $ignoreCodes = [404]; public array $ignoreCodes = [404];
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -41,10 +41,8 @@ class Exceptions extends BaseConfig
* directories that hold the views used to generate errors. * directories that hold the views used to generate errors.
* *
* Default: APPPATH.'Views/errors' * Default: APPPATH.'Views/errors'
*
* @var string
*/ */
public $errorViewPath = APPPATH . 'Views/errors'; public string $errorViewPath = APPPATH . 'Views/errors';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -53,8 +51,54 @@ class Exceptions extends BaseConfig
* Any data that you would like to hide from the debug trace. * Any data that you would like to hide from the debug trace.
* In order to specify 2 levels, use "/" to separate. * In order to specify 2 levels, use "/" to separate.
* ex. ['server', 'setup/password', 'secret_token'] * ex. ['server', 'setup/password', 'secret_token']
*
* @var array
*/ */
public $sensitiveDataInTrace = []; public array $sensitiveDataInTrace = [];
/**
* --------------------------------------------------------------------------
* LOG DEPRECATIONS INSTEAD OF THROWING?
* --------------------------------------------------------------------------
* By default, CodeIgniter converts deprecations into exceptions. Also,
* starting in PHP 8.1 will cause a lot of deprecated usage warnings.
* Use this option to temporarily cease the warnings and instead log those.
* This option also works for user deprecations.
*/
public bool $logDeprecations = true;
/**
* --------------------------------------------------------------------------
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
* --------------------------------------------------------------------------
* If `$logDeprecations` is set to `true`, this sets the log level
* to which the deprecation will be logged. This should be one of the log
* levels recognized by PSR-3.
*
* The related `Config\Logger::$threshold` should be adjusted, if needed,
* to capture logging the deprecations.
*/
public string $deprecationLogLevel = LogLevel::WARNING;
/*
* DEFINE THE HANDLERS USED
* --------------------------------------------------------------------------
* Given the HTTP status code, returns exception handler that
* should be used to deal with this error. By default, it will run CodeIgniter's
* default handler and display the error information in the expected format
* for CLI, HTTP, or AJAX requests, as determined by is_cli() and the expected
* response format.
*
* Custom handlers can be returned if you want to handle one or more specific
* error codes yourself like:
*
* if (in_array($statusCode, [400, 404, 500])) {
* return new \App\Libraries\MyExceptionHandler();
* }
* if ($exception instanceOf PageNotFoundException) {
* return new \App\Libraries\MyExceptionHandler();
* }
*/
public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface
{
return new ExceptionHandler($this);
}
} }

View File

@ -2,6 +2,9 @@
namespace Config; namespace Config;
use CodeIgniter\Router\RouteCollection;
/*
// Create a new instance of our RouteCollection class. // Create a new instance of our RouteCollection class.
$routes = Services::routes(); $routes = Services::routes();
@ -11,18 +14,23 @@ if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
require SYSTEMPATH . 'Config/Routes.php'; require SYSTEMPATH . 'Config/Routes.php';
} }
*/
/* /*
* -------------------------------------------------------------------- * --------------------------------------------------------------------
* Router Setup * Router Setup
* -------------------------------------------------------------------- * --------------------------------------------------------------------
*/ */
/*
$routes->setDefaultNamespace('App\Controllers'); $routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home'); $routes->setDefaultController('Home');
$routes->setDefaultMethod('index'); $routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false); $routes->setTranslateURIDashes(false);
$routes->set404Override(); $routes->set404Override();
$routes->setAutoRoute(true); $routes->setAutoRoute(true);
*/
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
//WEB ROUTER ------------------------------------------------------ //WEB ROUTER ------------------------------------------------------
//------------------------------------------------------------------ //------------------------------------------------------------------

112
ci4/app/Config/Routing.php Normal file
View File

@ -0,0 +1,112 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Config;
use CodeIgniter\Config\Routing as BaseRouting;
/**
* Routing configuration
*/
class Routing extends BaseRouting
{
/**
* An array of files that contain route definitions.
* Route files are read in order, with the first match
* found taking precedence.
*
* Default: APPPATH . 'Config/Routes.php'
*/
public array $routeFiles = [
APPPATH . 'Config/Routes.php',
];
/**
* The default namespace to use for Controllers when no other
* namespace has been specified.
*
* Default: 'App\Controllers'
*/
public string $defaultNamespace = 'App\Controllers';
/**
* The default controller to use when no other controller has been
* specified.
*
* Default: 'Home'
*/
public string $defaultController = 'Home';
/**
* The default method to call on the controller when no other
* method has been set in the route.
*
* Default: 'index'
*/
public string $defaultMethod = 'index';
/**
* Whether to translate dashes in URIs to underscores.
* Primarily useful when using the auto-routing.
*
* Default: false
*/
public bool $translateURIDashes = false;
/**
* Sets the class/method that should be called if routing doesn't
* find a match. It can be the controller/method name like: Users::index
*
* This setting is passed to the Router class and handled there.
*
* If you want to use a closure, you will have to set it in the
* routes file by calling:
*
* $routes->set404Override(function() {
* // Do something here
* });
*
* Example:
* public $override404 = 'App\Errors::show404';
*/
public ?string $override404 = null;
/**
* If TRUE, the system will attempt to match the URI against
* Controllers by matching each segment against folders/files
* in APPPATH/Controllers, when a match wasn't found against
* defined routes.
*
* If FALSE, will stop searching and do NO automatic routing.
*/
public bool $autoRoute = false;
/**
* If TRUE, will enable the use of the 'prioritize' option
* when defining routes.
*
* Default: false
*/
public bool $prioritize = false;
/**
* Map of URI segments and namespaces. For Auto Routing (Improved).
*
* The key is the first URI segment. The value is the controller namespace.
* E.g.,
* [
* 'blog' => 'Acme\Blog\Controllers',
* ]
*
* @var array [ uri_segment => namespace ]
*/
public array $moduleRoutes = [];
}

View File

@ -6,38 +6,52 @@ use CodeIgniter\Config\BaseConfig;
class Security extends BaseConfig class Security extends BaseConfig
{ {
/**
* --------------------------------------------------------------------------
* CSRF Protection Method
* --------------------------------------------------------------------------
*
* Protection Method for Cross Site Request Forgery protection.
*
* @var string 'cookie' or 'session'
*/
public string $csrfProtection = 'session';
/**
* --------------------------------------------------------------------------
* CSRF Token Randomization
* --------------------------------------------------------------------------
*
* Randomize the CSRF Token for added security.
*/
public bool $tokenRandomize = false;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* CSRF Token Name * CSRF Token Name
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Token name for Cross Site Request Forgery protection cookie. * Token name for Cross Site Request Forgery protection.
*
* @var string
*/ */
public $tokenName = 'csrf_test_name'; public string $tokenName = 'csrf_test_name';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* CSRF Header Name * CSRF Header Name
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Token name for Cross Site Request Forgery protection cookie. * Header name for Cross Site Request Forgery protection.
*
* @var string
*/ */
public $headerName = 'X-CSRF-TOKEN'; public string $headerName = 'X-CSRF-TOKEN';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* CSRF Cookie Name * CSRF Cookie Name
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Cookie name for Cross Site Request Forgery protection cookie. * Cookie name for Cross Site Request Forgery protection.
*
* @var string
*/ */
public $cookieName = 'csrf_cookie_name'; public string $cookieName = 'csrf_cookie_name';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -47,21 +61,17 @@ class Security extends BaseConfig
* Expiration time for Cross Site Request Forgery protection cookie. * Expiration time for Cross Site Request Forgery protection cookie.
* *
* Defaults to two hours (in seconds). * Defaults to two hours (in seconds).
*
* @var int
*/ */
public $expires = 7200; public int $expires = 7200;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* CSRF Regenerate * CSRF Regenerate
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Regenerate CSRF Token on every request. * Regenerate CSRF Token on every submission.
*
* @var bool
*/ */
public $regenerate = true; public bool $regenerate = true;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -69,10 +79,8 @@ class Security extends BaseConfig
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Redirect to previous page with error on failure. * Redirect to previous page with error on failure.
*
* @var bool
*/ */
public $redirect = true; public bool $redirect = false;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -87,9 +95,7 @@ class Security extends BaseConfig
* *
* @see https://portswigger.net/web-security/csrf/samesite-cookies * @see https://portswigger.net/web-security/csrf/samesite-cookies
* *
* @var string * @deprecated `Config\Cookie` $samesite property is used.
*
* @deprecated
*/ */
public $samesite = 'Lax'; public string $samesite = 'Lax';
} }

102
ci4/app/Config/Session.php Normal file
View File

@ -0,0 +1,102 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\BaseHandler;
use CodeIgniter\Session\Handlers\FileHandler;
class Session extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Session Driver
* --------------------------------------------------------------------------
*
* The session storage driver to use:
* - `CodeIgniter\Session\Handlers\FileHandler`
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler`
*
* @var class-string<BaseHandler>
*/
public string $driver = FileHandler::class;
/**
* --------------------------------------------------------------------------
* Session Cookie Name
* --------------------------------------------------------------------------
*
* The session cookie name, must contain only [0-9a-z_-] characters
*/
public string $cookieName = 'ci_session';
/**
* --------------------------------------------------------------------------
* Session Expiration
* --------------------------------------------------------------------------
*
* The number of SECONDS you want the session to last.
* Setting to 0 (zero) means expire when the browser is closed.
*/
public int $expiration = 7200;
/**
* --------------------------------------------------------------------------
* Session Save Path
* --------------------------------------------------------------------------
*
* The location to save sessions to and is driver dependent.
*
* For the 'files' driver, it's a path to a writable directory.
* WARNING: Only absolute paths are supported!
*
* For the 'database' driver, it's a table name.
* Please read up the manual for the format with other session drivers.
*
* IMPORTANT: You are REQUIRED to set a valid save path!
*/
public string $savePath = WRITEPATH . 'session';
/**
* --------------------------------------------------------------------------
* Session Match IP
* --------------------------------------------------------------------------
*
* Whether to match the user's IP address when reading the session data.
*
* WARNING: If you're using the database driver, don't forget to update
* your session table's PRIMARY KEY when changing this setting.
*/
public bool $matchIP = false;
/**
* --------------------------------------------------------------------------
* Session Time to Update
* --------------------------------------------------------------------------
*
* How many seconds between CI regenerating the session ID.
*/
public int $timeToUpdate = 300;
/**
* --------------------------------------------------------------------------
* Session Regenerate Destroy
* --------------------------------------------------------------------------
*
* Whether to destroy session data associated with the old session ID
* when auto-regenerating the session ID. When set to FALSE, the data
* will be later deleted by the garbage collector.
*/
public bool $regenerateDestroy = false;
/**
* --------------------------------------------------------------------------
* Session Database Group
* --------------------------------------------------------------------------
*
* DB Group for the database session.
*/
public ?string $DBGroup = null;
}

View File

@ -33,7 +33,7 @@ class Toolbar extends BaseConfig
* *
* @var string[] * @var string[]
*/ */
public $collectors = [ public array $collectors = [
Timers::class, Timers::class,
Database::class, Database::class,
Logs::class, Logs::class,
@ -44,6 +44,16 @@ class Toolbar extends BaseConfig
Events::class, Events::class,
]; ];
/**
* --------------------------------------------------------------------------
* Collect Var Data
* --------------------------------------------------------------------------
*
* If set to false var data from the views will not be colleted. Useful to
* avoid high memory usage when there are lots of data passed to the view.
*/
public bool $collectVarData = true;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* Max History * Max History
@ -52,10 +62,8 @@ class Toolbar extends BaseConfig
* `$maxHistory` sets a limit on the number of past requests that are stored, * `$maxHistory` sets a limit on the number of past requests that are stored,
* helping to conserve file space used to store them. You can set it to * helping to conserve file space used to store them. You can set it to
* 0 (zero) to not have any history stored, or -1 for unlimited history. * 0 (zero) to not have any history stored, or -1 for unlimited history.
*
* @var int
*/ */
public $maxHistory = 20; public int $maxHistory = 20;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -64,10 +72,8 @@ class Toolbar extends BaseConfig
* *
* The full path to the the views that are used by the toolbar. * The full path to the the views that are used by the toolbar.
* This MUST have a trailing slash. * This MUST have a trailing slash.
*
* @var string
*/ */
public $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/'; public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
@ -80,8 +86,33 @@ class Toolbar extends BaseConfig
* with hundreds of queries. * with hundreds of queries.
* *
* `$maxQueries` defines the maximum amount of queries that will be stored. * `$maxQueries` defines the maximum amount of queries that will be stored.
*
* @var int
*/ */
public $maxQueries = 100; public int $maxQueries = 100;
/**
* --------------------------------------------------------------------------
* Watched Directories
* --------------------------------------------------------------------------
*
* Contains an array of directories that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not.
* We restrict the values to keep performance as high as possible.
*
* NOTE: The ROOTPATH will be prepended to all values.
*/
public array $watchedDirectories = [
'app',
];
/**
* --------------------------------------------------------------------------
* Watched File Extensions
* --------------------------------------------------------------------------
*
* Contains an array of file extensions that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not.
*/
public array $watchedExtensions = [
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
];
} }

View File

@ -40,7 +40,7 @@ class LoginAuthFilter implements FilterInterface
*/ */
public function validateControllerAccess(){ public function validateControllerAccess(){
$request = \Config\Services::request(); $request = \Config\Services::request();
$uri = $request->uri; $uri = $request->getUri();
$language = \Config\Services::language(); $language = \Config\Services::language();
$language->setLocale(session()->lang); $language->setLocale(session()->lang);
@ -161,7 +161,7 @@ class LoginAuthFilter implements FilterInterface
public function validateIgnoreControllerAccess(){ public function validateIgnoreControllerAccess(){
$request = \Config\Services::request(); $request = \Config\Services::request();
$uri = $request->uri; $uri = $request->getUri();
$getList = $this->ignoreListController(); $getList = $this->ignoreListController();
foreach ($getList as $item){ foreach ($getList as $item){

View File

@ -3,17 +3,26 @@
use CodeIgniter\CLI\CLI; use CodeIgniter\CLI\CLI;
// The main Exception // The main Exception
CLI::newLine();
CLI::write('[' . get_class($exception) . ']', 'light_gray', 'red'); CLI::write('[' . get_class($exception) . ']', 'light_gray', 'red');
CLI::newLine();
CLI::write($message); CLI::write($message);
CLI::newLine();
CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green')); CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green'));
CLI::newLine(); CLI::newLine();
$last = $exception;
while ($prevException = $last->getPrevious()) {
$last = $prevException;
CLI::write(' Caused by:');
CLI::write(' [' . get_class($prevException) . ']', 'red');
CLI::write(' ' . $prevException->getMessage());
CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green'));
CLI::newLine();
}
// The backtrace // The backtrace
if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) { if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
$backtraces = $exception->getTrace(); $backtraces = $last->getTrace();
if ($backtraces) { if ($backtraces) {
CLI::write('Backtrace:', 'green'); CLI::write('Backtrace:', 'green');

View File

@ -1,5 +1,3 @@
// Tabs
var tabLinks = new Array(); var tabLinks = new Array();
var contentDivs = new Array(); var contentDivs = new Array();

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>404 Page Not Found</title> <title><?= lang('Errors.pageNotFound') ?></title>
<style> <style>
div.logo { div.logo {
@ -24,7 +24,7 @@
} }
h1 { h1 {
font-weight: lighter; font-weight: lighter;
letter-spacing: 0.8; letter-spacing: normal;
font-size: 3rem; font-size: 3rem;
margin-top: 0; margin-top: 0;
margin-bottom: 0; margin-bottom: 0;
@ -70,14 +70,14 @@
</head> </head>
<body> <body>
<div class="wrap"> <div class="wrap">
<h1>404 - File Not Found</h1> <h1>404</h1>
<p> <p>
<?php if (! empty($message) && $message !== '(null)') : ?> <?php if (ENVIRONMENT !== 'production') : ?>
<?= nl2br(esc($message)) ?> <?= nl2br(esc($message)) ?>
<?php else : ?> <?php else : ?>
Sorry! Cannot seem to find the page you were looking for. <?= lang('Errors.sorryCannotFind') ?>
<?php endif ?> <?php endif; ?>
</p> </p>
</div> </div>
</body> </body>

View File

@ -1,4 +1,9 @@
<?php $error_id = uniqid('error', true); ?> <?php
use Config\Services;
use CodeIgniter\CodeIgniter;
$errorId = uniqid('error', true);
?>
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -6,11 +11,11 @@
<meta name="robots" content="noindex"> <meta name="robots" content="noindex">
<title><?= esc($title) ?></title> <title><?= esc($title) ?></title>
<style type="text/css"> <style>
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?> <?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style> </style>
<script type="text/javascript"> <script>
<?= file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.js') ?> <?= file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.js') ?>
</script> </script>
</head> </head>
@ -30,7 +35,7 @@
<!-- Source --> <!-- Source -->
<div class="container"> <div class="container">
<p><b><?= esc(static::cleanPath($file, $line)) ?></b> at line <b><?= esc($line) ?></b></p> <p><b><?= esc(clean_path($file)) ?></b> at line <b><?= esc($line) ?></b></p>
<?php if (is_file($file)) : ?> <?php if (is_file($file)) : ?>
<div class="source"> <div class="source">
@ -39,6 +44,30 @@
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="container">
<?php
$last = $exception;
while ($prevException = $last->getPrevious()) {
$last = $prevException;
?>
<pre>
Caused by:
<?= esc(get_class($prevException)), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?>
<?= nl2br(esc($prevException->getMessage())) ?>
<a href="https://www.duckduckgo.com/?q=<?= urlencode(get_class($prevException) . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $prevException->getMessage())) ?>"
rel="noreferrer" target="_blank">search &rarr;</a>
<?= esc(clean_path($prevException->getFile()) . ':' . $prevException->getLine()) ?>
</pre>
<?php
}
?>
</div>
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) : ?>
<div class="container"> <div class="container">
<ul class="tabs" id="tabs"> <ul class="tabs" id="tabs">
@ -64,9 +93,9 @@
<?php if (isset($row['file']) && is_file($row['file'])) : ?> <?php if (isset($row['file']) && is_file($row['file'])) : ?>
<?php <?php
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true)) { if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true)) {
echo esc($row['function'] . ' ' . static::cleanPath($row['file'])); echo esc($row['function'] . ' ' . clean_path($row['file']));
} else { } else {
echo esc(static::cleanPath($row['file']) . ' : ' . $row['line']); echo esc(clean_path($row['file']) . ' : ' . $row['line']);
} }
?> ?>
<?php else: ?> <?php else: ?>
@ -77,16 +106,16 @@
<?php if (isset($row['class'])) : ?> <?php if (isset($row['class'])) : ?>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;<?= esc($row['class'] . $row['type'] . $row['function']) ?> &nbsp;&nbsp;&mdash;&nbsp;&nbsp;<?= esc($row['class'] . $row['type'] . $row['function']) ?>
<?php if (! empty($row['args'])) : ?> <?php if (! empty($row['args'])) : ?>
<?php $args_id = $error_id . 'args' . $index ?> <?php $argsId = $errorId . 'args' . $index ?>
( <a href="#" onclick="return toggle('<?= esc($args_id, 'attr') ?>');">arguments</a> ) ( <a href="#" onclick="return toggle('<?= esc($argsId, 'attr') ?>');">arguments</a> )
<div class="args" id="<?= esc($args_id, 'attr') ?>"> <div class="args" id="<?= esc($argsId, 'attr') ?>">
<table cellspacing="0"> <table cellspacing="0">
<?php <?php
$params = null; $params = null;
// Reflection by name is not available for closure function // Reflection by name is not available for closure function
if (substr($row['function'], -1) !== '}') { if (substr($row['function'], -1) !== '}') {
$mirror = isset($row['class']) ? new \ReflectionMethod($row['class'], $row['function']) : new \ReflectionFunction($row['function']); $mirror = isset($row['class']) ? new ReflectionMethod($row['class'], $row['function']) : new ReflectionFunction($row['function']);
$params = $mirror->getParameters(); $params = $mirror->getParameters();
} }
@ -189,17 +218,17 @@
<!-- Request --> <!-- Request -->
<div class="content" id="request"> <div class="content" id="request">
<?php $request = \Config\Services::request(); ?> <?php $request = Services::request(); ?>
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td style="width: 10em">Path</td> <td style="width: 10em">Path</td>
<td><?= esc($request->uri) ?></td> <td><?= esc($request->getUri()) ?></td>
</tr> </tr>
<tr> <tr>
<td>HTTP Method</td> <td>HTTP Method</td>
<td><?= esc($request->getMethod(true)) ?></td> <td><?= esc(strtoupper($request->getMethod())) ?></td>
</tr> </tr>
<tr> <tr>
<td>IP Address</td> <td>IP Address</td>
@ -270,7 +299,7 @@
<?php endif; ?> <?php endif; ?>
<?php $headers = $request->getHeaders(); ?> <?php $headers = $request->headers(); ?>
<?php if (! empty($headers)) : ?> <?php if (! empty($headers)) : ?>
<h3>Headers</h3> <h3>Headers</h3>
@ -283,22 +312,12 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($headers as $value) : ?> <?php foreach ($headers as $header) : ?>
<?php
if (empty($value)) {
continue;
}
if (! is_array($value)) {
$value = [$value];
} ?>
<?php foreach ($value as $h) : ?>
<tr> <tr>
<td><?= esc($h->getName(), 'html') ?></td> <td><?= esc($header->getName(), 'html') ?></td>
<td><?= esc($h->getValueLine(), 'html') ?></td> <td><?= esc($header->getValueLine(), 'html') ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php endforeach; ?>
</tbody> </tbody>
</table> </table>
@ -307,18 +326,18 @@
<!-- Response --> <!-- Response -->
<?php <?php
$response = \Config\Services::response(); $response = Services::response();
$response->setStatusCode(http_response_code()); $response->setStatusCode(http_response_code());
?> ?>
<div class="content" id="response"> <div class="content" id="response">
<table> <table>
<tr> <tr>
<td style="width: 15em">Response Status</td> <td style="width: 15em">Response Status</td>
<td><?= esc($response->getStatusCode() . ' - ' . $response->getReason()) ?></td> <td><?= esc($response->getStatusCode() . ' - ' . $response->getReasonPhrase()) ?></td>
</tr> </tr>
</table> </table>
<?php $headers = $response->getHeaders(); ?> <?php $headers = $response->headers(); ?>
<?php if (! empty($headers)) : ?> <?php if (! empty($headers)) : ?>
<?php natsort($headers) ?> <?php natsort($headers) ?>
@ -332,7 +351,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($headers as $name => $value) : ?> <?php foreach (array_keys($headers) as $name) : ?>
<tr> <tr>
<td><?= esc($name, 'html') ?></td> <td><?= esc($name, 'html') ?></td>
<td><?= esc($response->getHeaderLine($name), 'html') ?></td> <td><?= esc($response->getHeaderLine($name), 'html') ?></td>
@ -350,7 +369,7 @@
<ol> <ol>
<?php foreach ($files as $file) :?> <?php foreach ($files as $file) :?>
<li><?= esc(static::cleanPath($file)) ?></li> <li><?= esc(clean_path($file)) ?></li>
<?php endforeach ?> <?php endforeach ?>
</ol> </ol>
</div> </div>
@ -380,6 +399,7 @@
</div> <!-- /tab-content --> </div> <!-- /tab-content -->
</div> <!-- /container --> </div> <!-- /container -->
<?php endif; ?>
<div class="footer"> <div class="footer">
<div class="container"> <div class="container">
@ -387,7 +407,8 @@
<p> <p>
Displayed at <?= esc(date('H:i:sa')) ?> &mdash; Displayed at <?= esc(date('H:i:sa')) ?> &mdash;
PHP: <?= esc(PHP_VERSION) ?> &mdash; PHP: <?= esc(PHP_VERSION) ?> &mdash;
CodeIgniter: <?= esc(\CodeIgniter\CodeIgniter::CI_VERSION) ?> CodeIgniter: <?= esc(CodeIgniter::CI_VERSION) ?> --
Environment: <?= ENVIRONMENT ?>
</p> </p>
</div> </div>

View File

@ -4,9 +4,9 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="robots" content="noindex"> <meta name="robots" content="noindex">
<title>Whoops!</title> <title><?= lang('Errors.whoops') ?></title>
<style type="text/css"> <style>
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?> <?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style> </style>
</head> </head>
@ -14,9 +14,9 @@
<div class="container text-center"> <div class="container text-center">
<h1 class="headline">Whoops!</h1> <h1 class="headline"><?= lang('Errors.whoops') ?></h1>
<p class="lead">We seem to have hit a snag. Please try again later...</p> <p class="lead"><?= lang('Errors.weHitASnag') ?></p>
</div> </div>

View File

@ -6,12 +6,9 @@
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^7.3 || ^8.0", "php": "^7.3 || ^8.0",
"codeigniter4/shield": "^1.0",
"codeigniter4/framework": "^4", "codeigniter4/framework": "^4",
"phpoffice/phpspreadsheet": "^1.18", "phpoffice/phpspreadsheet": "^1.18",
"google/apiclient": "^2.11.0",
"firebase/php-jwt": "^5.4",
"aws/aws-sdk-php": "^3.206",
"spatie/db-dumper": "^2.21",
"dompdf/dompdf": "^2.0" "dompdf/dompdf": "^2.0"
}, },
"require-dev": { "require-dev": {

99
ci4/spark.old Normal file
View File

@ -0,0 +1,99 @@
#!/usr/bin/env php
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
/*
* --------------------------------------------------------------------
* CodeIgniter command-line tools
* --------------------------------------------------------------------
* The main entry point into the CLI system and allows you to run
* commands and perform maintenance on your application.
*
* Because CodeIgniter can handle CLI requests as just another web request
* this class mainly acts as a passthru to the framework itself.
*/
// Refuse to run when called from php-cgi
if (strpos(PHP_SAPI, 'cgi') === 0) {
exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
}
// Check PHP version.
$minPhpVersion = '7.4'; // If you update this, don't forget to update `public/index.php`.
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
$message = sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
$minPhpVersion,
PHP_VERSION
);
exit($message);
}
// We want errors to be shown when using it from the CLI.
error_reporting(-1);
ini_set('display_errors', '1');
/**
* @var bool
*
* @deprecated No longer in use. `CodeIgniter` has `$context` property.
*/
define('SPARKED', true);
// Path to the front controller
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
// Ensure the current directory is pointing to the front controller's directory
chdir(FCPATH);
/*
*---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION
*---------------------------------------------------------------
* This process sets up the path constants, loads and registers
* our autoloader, along with Composer's, loads our constants
* and fires up an environment-specific bootstrapping.
*/
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH . '../app/Config/Paths.php';
// ^^^ Change this line if you move your application folder
$paths = new Config\Paths();
// Location of the framework bootstrap file.
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
// Grab our CodeIgniter
$app = Config\Services::codeigniter();
$app->initialize();
// Grab our Console
$console = new CodeIgniter\CLI\Console();
// Show basic information before we do anything else.
if (is_int($suppress = array_search('--no-header', $_SERVER['argv'], true))) {
unset($_SERVER['argv'][$suppress]); // @codeCoverageIgnore
$suppress = true;
}
$console->showHeader($suppress);
// fire off the command in the main framework.
$exit = $console->run();
exit(is_int($exit) ? $exit : EXIT_SUCCESS);

View File

@ -1,15 +1,39 @@
<?php <?php
// Valid PHP Version?
$minPHPVersion = '7.3'; /*
if (phpversion() < $minPHPVersion) *---------------------------------------------------------------
{ * CHECK PHP VERSION
die("Your PHP version must be {$minPHPVersion} or higher to run CodeIgniter 4.<br>Current version: " . phpversion()); *---------------------------------------------------------------
*/
$minPhpVersion = '8.1'; // If you update this, don't forget to update `spark`.
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
$message = sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
$minPhpVersion,
PHP_VERSION
);
header('HTTP/1.1 503 Service Unavailable.', true, 503);
echo $message;
exit(1);
} }
unset($minPHPVersion);
/*
*---------------------------------------------------------------
* SET THE CURRENT DIRECTORY
*---------------------------------------------------------------
*/
// Path to the front controller (this file) // Path to the front controller (this file)
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR); define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
// Ensure the current directory is pointing to the front controller's directory
if (getcwd() . DIRECTORY_SEPARATOR !== FCPATH) {
chdir(FCPATH);
}
/* /*
*--------------------------------------------------------------- *---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION * BOOTSTRAP THE APPLICATION
@ -19,60 +43,14 @@ define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
* and fires up an environment-specific bootstrapping. * and fires up an environment-specific bootstrapping.
*/ */
// Ensure the current directory is pointing to the front controller's directory // LOAD OUR PATHS CONFIG FILE
chdir(FCPATH);
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure. // This is the line that might need to be changed, depending on your folder structure.
$pathsConfig = FCPATH . '../ci4/app/Config/Paths.php'; require FCPATH . '../ci4/app/Config/Paths.php';
// ^^^ Change this if you move your application folder // ^^^ Change this line if you move your application folder
require realpath($pathsConfig) ?: $pathsConfig;
$paths = new Config\Paths(); $paths = new Config\Paths();
//Check Installation // LOAD THE FRAMEWORK BOOTSTRAP FILE
$rootFolder = realpath(rtrim($paths->appDirectory, '/ ') . '/../'); require $paths->systemDirectory . '/Boot.php';
$env = file_exists($rootFolder . '/.env');
if($env == false) {
$domain = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$domain = preg_replace('/index.php.*/', '', $domain); //remove everything after index.php
if (!empty($_SERVER['HTTPS'])) {
$domain = 'https://' . $domain;
} else {
$domain = 'http://' . $domain;
}
header("Location: $domain./install");
exit;
}
// Location of the framework bootstrap file. exit(CodeIgniter\Boot::bootWeb($paths));
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
/*
* ---------------------------------------------------------------
* GRAB OUR CODEIGNITER INSTANCE
* ---------------------------------------------------------------
*
* The CodeIgniter class contains the core functionality to make
* the application run, and does all of the dirty work to get
* the pieces all working together.
*/
$app = Config\Services::codeigniter();
$app->initialize();
$context = is_cli() ? 'php-cli' : 'web';
$app->setContext($context);
/*
*---------------------------------------------------------------
* LAUNCH THE APPLICATION
*---------------------------------------------------------------
* Now that everything is setup, it's time to actually fire
* up the engines and make this app do its thang.
*/
$app->run();

78
httpdocs/index.php.old Normal file
View File

@ -0,0 +1,78 @@
<?php
// Valid PHP Version?
$minPHPVersion = '7.3';
if (phpversion() < $minPHPVersion)
{
die("Your PHP version must be {$minPHPVersion} or higher to run CodeIgniter 4.<br>Current version: " . phpversion());
}
unset($minPHPVersion);
// Path to the front controller (this file)
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
/*
*---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION
*---------------------------------------------------------------
* This process sets up the path constants, loads and registers
* our autoloader, along with Composer's, loads our constants
* and fires up an environment-specific bootstrapping.
*/
// Ensure the current directory is pointing to the front controller's directory
chdir(FCPATH);
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
$pathsConfig = FCPATH . '../ci4/app/Config/Paths.php';
// ^^^ Change this if you move your application folder
require realpath($pathsConfig) ?: $pathsConfig;
$paths = new Config\Paths();
//Check Installation
$rootFolder = realpath(rtrim($paths->appDirectory, '/ ') . '/../');
$env = file_exists($rootFolder . '/.env');
if($env == false) {
$domain = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$domain = preg_replace('/index.php.*/', '', $domain); //remove everything after index.php
if (!empty($_SERVER['HTTPS'])) {
$domain = 'https://' . $domain;
} else {
$domain = 'http://' . $domain;
}
header("Location: $domain./install");
exit;
}
// Location of the framework bootstrap file.
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
// Load environment settings from .env files into $_SERVER and $_ENV
require_once SYSTEMPATH . 'Config/DotEnv.php';
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
/*
* ---------------------------------------------------------------
* GRAB OUR CODEIGNITER INSTANCE
* ---------------------------------------------------------------
*
* The CodeIgniter class contains the core functionality to make
* the application run, and does all of the dirty work to get
* the pieces all working together.
*/
$app = Config\Services::codeigniter();
$app->initialize();
$context = is_cli() ? 'php-cli' : 'web';
$app->setContext($context);
/*
*---------------------------------------------------------------
* LAUNCH THE APPLICATION
*---------------------------------------------------------------
* Now that everything is setup, it's time to actually fire
* up the engines and make this app do its thang.
*/
$app->run();