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,68 +12,63 @@ 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' => '',
'password' => '', 'password' => '',
'database' => '', 'database' => '',
'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' => '',
'encrypt' => false, 'encrypt' => false,
'compress' => false, 'compress' => false,
'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' => '',
'password' => '', 'password' => '',
'database' => ':memory:', 'database' => ':memory:',
'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' => '',
'encrypt' => false, 'encrypt' => false,
'compress' => false, 'compress' => false,
'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,197 +1,197 @@
:root { :root {
--main-bg-color: #fff; --main-bg-color: #fff;
--main-text-color: #555; --main-text-color: #555;
--dark-text-color: #222; --dark-text-color: #222;
--light-text-color: #c7c7c7; --light-text-color: #c7c7c7;
--brand-primary-color: #E06E3F; --brand-primary-color: #E06E3F;
--light-bg-color: #ededee; --light-bg-color: #ededee;
--dark-bg-color: #404040; --dark-bg-color: #404040;
} }
body { body {
height: 100%; height: 100%;
background: var(--main-bg-color); background: var(--main-bg-color);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
color: var(--main-text-color); color: var(--main-text-color);
font-weight: 300; font-weight: 300;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
h1 { h1 {
font-weight: lighter; font-weight: lighter;
letter-spacing: 0.8; letter-spacing: 0.8;
font-size: 3rem; font-size: 3rem;
color: var(--dark-text-color); color: var(--dark-text-color);
margin: 0; margin: 0;
} }
h1.headline { h1.headline {
margin-top: 20%; margin-top: 20%;
font-size: 5rem; font-size: 5rem;
} }
.text-center { .text-center {
text-align: center; text-align: center;
} }
p.lead { p.lead {
font-size: 1.6rem; font-size: 1.6rem;
} }
.container { .container {
max-width: 75rem; max-width: 75rem;
margin: 0 auto; margin: 0 auto;
padding: 1rem; padding: 1rem;
} }
.header { .header {
background: var(--light-bg-color); background: var(--light-bg-color);
color: var(--dark-text-color); color: var(--dark-text-color);
} }
.header .container { .header .container {
padding: 1rem 1.75rem 1.75rem 1.75rem; padding: 1rem 1.75rem 1.75rem 1.75rem;
} }
.header h1 { .header h1 {
font-size: 2.5rem; font-size: 2.5rem;
font-weight: 500; font-weight: 500;
} }
.header p { .header p {
font-size: 1.2rem; font-size: 1.2rem;
margin: 0; margin: 0;
line-height: 2.5; line-height: 2.5;
} }
.header a { .header a {
color: var(--brand-primary-color); color: var(--brand-primary-color);
margin-left: 2rem; margin-left: 2rem;
display: none; display: none;
text-decoration: none; text-decoration: none;
} }
.header:hover a { .header:hover a {
display: inline; display: inline;
} }
.footer { .footer {
background: var(--dark-bg-color); background: var(--dark-bg-color);
color: var(--light-text-color); color: var(--light-text-color);
} }
.footer .container { .footer .container {
border-top: 1px solid #e7e7e7; border-top: 1px solid #e7e7e7;
margin-top: 1rem; margin-top: 1rem;
text-align: center; text-align: center;
} }
.source { .source {
background: #343434; background: #343434;
color: var(--light-text-color); color: var(--light-text-color);
padding: 0.5em 1em; padding: 0.5em 1em;
border-radius: 5px; border-radius: 5px;
font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
font-size: 0.85rem; font-size: 0.85rem;
margin: 0; margin: 0;
overflow-x: scroll; overflow-x: scroll;
} }
.source span.line { .source span.line {
line-height: 1.4; line-height: 1.4;
} }
.source span.line .number { .source span.line .number {
color: #666; color: #666;
} }
.source .line .highlight { .source .line .highlight {
display: block; display: block;
background: var(--dark-text-color); background: var(--dark-text-color);
color: var(--light-text-color); color: var(--light-text-color);
} }
.source span.highlight .number { .source span.highlight .number {
color: #fff; color: #fff;
} }
.tabs { .tabs {
list-style: none; list-style: none;
list-style-position: inside; list-style-position: inside;
margin: 0; margin: 0;
padding: 0; padding: 0;
margin-bottom: -1px; margin-bottom: -1px;
} }
.tabs li { .tabs li {
display: inline; display: inline;
} }
.tabs a:link, .tabs a:link,
.tabs a:visited { .tabs a:visited {
padding: 0rem 1rem; padding: 0rem 1rem;
line-height: 2.7; line-height: 2.7;
text-decoration: none; text-decoration: none;
color: var(--dark-text-color); color: var(--dark-text-color);
background: var(--light-bg-color); background: var(--light-bg-color);
border: 1px solid rgba(0,0,0,0.15); border: 1px solid rgba(0,0,0,0.15);
border-bottom: 0; border-bottom: 0;
border-top-left-radius: 5px; border-top-left-radius: 5px;
border-top-right-radius: 5px; border-top-right-radius: 5px;
display: inline-block; display: inline-block;
} }
.tabs a:hover { .tabs a:hover {
background: var(--light-bg-color); background: var(--light-bg-color);
border-color: rgba(0,0,0,0.15); border-color: rgba(0,0,0,0.15);
} }
.tabs a.active { .tabs a.active {
background: var(--main-bg-color); background: var(--main-bg-color);
color: var(--main-text-color); color: var(--main-text-color);
} }
.tab-content { .tab-content {
background: var(--main-bg-color); background: var(--main-bg-color);
border: 1px solid rgba(0,0,0,0.15); border: 1px solid rgba(0,0,0,0.15);
} }
.content { .content {
padding: 1rem; padding: 1rem;
} }
.hide { .hide {
display: none; display: none;
} }
.alert { .alert {
margin-top: 2rem; margin-top: 2rem;
display: block; display: block;
text-align: center; text-align: center;
line-height: 3.0; line-height: 3.0;
background: #d9edf7; background: #d9edf7;
border: 1px solid #bcdff1; border: 1px solid #bcdff1;
border-radius: 5px; border-radius: 5px;
color: #31708f; color: #31708f;
} }
ul, ol { ul, ol {
line-height: 1.8; line-height: 1.8;
} }
table { table {
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
} }
th { th {
text-align: left; text-align: left;
border-bottom: 1px solid #e7e7e7; border-bottom: 1px solid #e7e7e7;
padding-bottom: 0.5rem; padding-bottom: 0.5rem;
} }
td { td {
padding: 0.2rem 0.5rem 0.2rem 0; padding: 0.2rem 0.5rem 0.2rem 0;
} }
tr:hover td { tr:hover td {
background: #f1f1f1; background: #f1f1f1;
} }
td pre { td pre {
white-space: pre-wrap; white-space: pre-wrap;
} }
.trace a { .trace a {
color: inherit; color: inherit;
} }
.trace table { .trace table {
width: auto; width: auto;
} }
.trace tr td:first-child { .trace tr td:first-child {
min-width: 5em; min-width: 5em;
font-weight: bold; font-weight: bold;
} }
.trace td { .trace td {
background: var(--light-bg-color); background: var(--light-bg-color);
padding: 0 1rem; padding: 0 1rem;
} }
.trace td pre { .trace td pre {
margin: 0; margin: 0;
} }
.args { .args {
display: none; display: none;
} }

View File

@ -1,118 +1,116 @@
// Tabs
var tabLinks = new Array(); var tabLinks = new Array();
var contentDivs = new Array(); var contentDivs = new Array();
function init() function init()
{ {
// Grab the tab links and content divs from the page // Grab the tab links and content divs from the page
var tabListItems = document.getElementById('tabs').childNodes; var tabListItems = document.getElementById('tabs').childNodes;
console.log(tabListItems); console.log(tabListItems);
for (var i = 0; i < tabListItems.length; i ++) for (var i = 0; i < tabListItems.length; i ++)
{ {
if (tabListItems[i].nodeName == "LI") if (tabListItems[i].nodeName == "LI")
{ {
var tabLink = getFirstChildWithTagName(tabListItems[i], 'A'); var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
var id = getHash(tabLink.getAttribute('href')); var id = getHash(tabLink.getAttribute('href'));
tabLinks[id] = tabLink; tabLinks[id] = tabLink;
contentDivs[id] = document.getElementById(id); contentDivs[id] = document.getElementById(id);
} }
} }
// Assign onclick events to the tab links, and // Assign onclick events to the tab links, and
// highlight the first tab // highlight the first tab
var i = 0; var i = 0;
for (var id in tabLinks) for (var id in tabLinks)
{ {
tabLinks[id].onclick = showTab; tabLinks[id].onclick = showTab;
tabLinks[id].onfocus = function () { tabLinks[id].onfocus = function () {
this.blur() this.blur()
}; };
if (i == 0) if (i == 0)
{ {
tabLinks[id].className = 'active'; tabLinks[id].className = 'active';
} }
i ++; i ++;
} }
// Hide all content divs except the first // Hide all content divs except the first
var i = 0; var i = 0;
for (var id in contentDivs) for (var id in contentDivs)
{ {
if (i != 0) if (i != 0)
{ {
console.log(contentDivs[id]); console.log(contentDivs[id]);
contentDivs[id].className = 'content hide'; contentDivs[id].className = 'content hide';
} }
i ++; i ++;
} }
} }
function showTab() function showTab()
{ {
var selectedId = getHash(this.getAttribute('href')); var selectedId = getHash(this.getAttribute('href'));
// Highlight the selected tab, and dim all others. // Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others. // Also show the selected content div, and hide all others.
for (var id in contentDivs) for (var id in contentDivs)
{ {
if (id == selectedId) if (id == selectedId)
{ {
tabLinks[id].className = 'active'; tabLinks[id].className = 'active';
contentDivs[id].className = 'content'; contentDivs[id].className = 'content';
} }
else else
{ {
tabLinks[id].className = ''; tabLinks[id].className = '';
contentDivs[id].className = 'content hide'; contentDivs[id].className = 'content hide';
} }
} }
// Stop the browser following the link // Stop the browser following the link
return false; return false;
} }
function getFirstChildWithTagName(element, tagName) function getFirstChildWithTagName(element, tagName)
{ {
for (var i = 0; i < element.childNodes.length; i ++) for (var i = 0; i < element.childNodes.length; i ++)
{ {
if (element.childNodes[i].nodeName == tagName) if (element.childNodes[i].nodeName == tagName)
{ {
return element.childNodes[i]; return element.childNodes[i];
} }
} }
} }
function getHash(url) function getHash(url)
{ {
var hashPos = url.lastIndexOf('#'); var hashPos = url.lastIndexOf('#');
return url.substring(hashPos + 1); return url.substring(hashPos + 1);
} }
function toggle(elem) function toggle(elem)
{ {
elem = document.getElementById(elem); elem = document.getElementById(elem);
if (elem.style && elem.style['display']) if (elem.style && elem.style['display'])
{ {
// Only works with the "style" attr // Only works with the "style" attr
var disp = elem.style['display']; var disp = elem.style['display'];
} }
else if (elem.currentStyle) else if (elem.currentStyle)
{ {
// For MSIE, naturally // For MSIE, naturally
var disp = elem.currentStyle['display']; var disp = elem.currentStyle['display'];
} }
else if (window.getComputedStyle) else if (window.getComputedStyle)
{ {
// For most other browsers // For most other browsers
var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display'); var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
} }
// Toggle the state of the "display" style // Toggle the state of the "display" style
elem.style.display = disp == 'block' ? 'none' : 'block'; elem.style.display = disp == 'block' ? 'none' : 'block';
return false; return false;
} }

View File

@ -1,84 +1,84 @@
<!DOCTYPE html> <!DOCTYPE html>
<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 {
height: 200px; height: 200px;
width: 155px; width: 155px;
display: inline-block; display: inline-block;
opacity: 0.08; opacity: 0.08;
position: absolute; position: absolute;
top: 2rem; top: 2rem;
left: 50%; left: 50%;
margin-left: -73px; margin-left: -73px;
} }
body { body {
height: 100%; height: 100%;
background: #fafafa; background: #fafafa;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #777; color: #777;
font-weight: 300; font-weight: 300;
} }
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;
color: #222; color: #222;
} }
.wrap { .wrap {
max-width: 1024px; max-width: 1024px;
margin: 5rem auto; margin: 5rem auto;
padding: 2rem; padding: 2rem;
background: #fff; background: #fff;
text-align: center; text-align: center;
border: 1px solid #efefef; border: 1px solid #efefef;
border-radius: 0.5rem; border-radius: 0.5rem;
position: relative; position: relative;
} }
pre { pre {
white-space: normal; white-space: normal;
margin-top: 1.5rem; margin-top: 1.5rem;
} }
code { code {
background: #fafafa; background: #fafafa;
border: 1px solid #efefef; border: 1px solid #efefef;
padding: 0.5rem 1rem; padding: 0.5rem 1rem;
border-radius: 5px; border-radius: 5px;
display: block; display: block;
} }
p { p {
margin-top: 1.5rem; margin-top: 1.5rem;
} }
.footer { .footer {
margin-top: 2rem; margin-top: 2rem;
border-top: 1px solid #efefef; border-top: 1px solid #efefef;
padding: 1em 2em 0 2em; padding: 1em 2em 0 2em;
font-size: 85%; font-size: 85%;
color: #999; color: #999;
} }
a:active, a:active,
a:link, a:link,
a:visited { a:visited {
color: #dd4814; color: #dd4814;
} }
</style> </style>
</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>
</html> </html>

View File

@ -1,397 +1,418 @@
<?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>
<meta charset="UTF-8"> <meta charset="UTF-8">
<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>
<body onload="init()"> <body onload="init()">
<!-- Header --> <!-- Header -->
<div class="header"> <div class="header">
<div class="container"> <div class="container">
<h1><?= esc($title), esc($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1> <h1><?= esc($title), esc($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1>
<p> <p>
<?= nl2br(esc($exception->getMessage())) ?> <?= nl2br(esc($exception->getMessage())) ?>
<a href="https://www.duckduckgo.com/?q=<?= urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>" <a href="https://www.duckduckgo.com/?q=<?= urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>"
rel="noreferrer" target="_blank">search &rarr;</a> rel="noreferrer" target="_blank">search &rarr;</a>
</p> </p>
</div> </div>
</div> </div>
<!-- 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">
<?= static::highlightFile($file, $line, 15); ?> <?= static::highlightFile($file, $line, 15); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="container"> <div class="container">
<?php
$last = $exception;
<ul class="tabs" id="tabs"> while ($prevException = $last->getPrevious()) {
<li><a href="#backtrace">Backtrace</a></li> $last = $prevException;
<li><a href="#server">Server</a></li> ?>
<li><a href="#request">Request</a></li>
<li><a href="#response">Response</a></li>
<li><a href="#files">Files</a></li>
<li><a href="#memory">Memory</a></li>
</ul>
<div class="tab-content"> <pre>
Caused by:
<?= esc(get_class($prevException)), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?>
<!-- Backtrace --> <?= nl2br(esc($prevException->getMessage())) ?>
<div class="content" id="backtrace"> <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>
<ol class="trace"> <?php
<?php foreach ($trace as $index => $row) : ?> }
?>
</div>
<li> <?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) : ?>
<p> <div class="container">
<!-- Trace info -->
<?php if (isset($row['file']) && is_file($row['file'])) :?> <ul class="tabs" id="tabs">
<?php <li><a href="#backtrace">Backtrace</a></li>
<li><a href="#server">Server</a></li>
<li><a href="#request">Request</a></li>
<li><a href="#response">Response</a></li>
<li><a href="#files">Files</a></li>
<li><a href="#memory">Memory</a></li>
</ul>
<div class="tab-content">
<!-- Backtrace -->
<div class="content" id="backtrace">
<ol class="trace">
<?php foreach ($trace as $index => $row) : ?>
<li>
<p>
<!-- Trace info -->
<?php if (isset($row['file']) && is_file($row['file'])) : ?>
<?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: ?>
{PHP internal code} {PHP internal code}
<?php endif; ?> <?php endif; ?>
<!-- Class/Method --> <!-- Class/Method -->
<?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();
} }
foreach ($row['args'] as $key => $value) : ?> foreach ($row['args'] as $key => $value) : ?>
<tr> <tr>
<td><code><?= esc(isset($params[$key]) ? '$' . $params[$key]->name : "#{$key}") ?></code></td> <td><code><?= esc(isset($params[$key]) ? '$' . $params[$key]->name : "#{$key}") ?></code></td>
<td><pre><?= esc(print_r($value, true)) ?></pre></td> <td><pre><?= esc(print_r($value, true)) ?></pre></td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
</table> </table>
</div> </div>
<?php else : ?> <?php else : ?>
() ()
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
<?php if (! isset($row['class']) && isset($row['function'])) : ?> <?php if (! isset($row['class']) && isset($row['function'])) : ?>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp; <?= esc($row['function']) ?>() &nbsp;&nbsp;&mdash;&nbsp;&nbsp; <?= esc($row['function']) ?>()
<?php endif; ?> <?php endif; ?>
</p> </p>
<!-- Source? --> <!-- Source? -->
<?php if (isset($row['file']) && is_file($row['file']) && isset($row['class'])) : ?> <?php if (isset($row['file']) && is_file($row['file']) && isset($row['class'])) : ?>
<div class="source"> <div class="source">
<?= static::highlightFile($row['file'], $row['line']) ?> <?= static::highlightFile($row['file'], $row['line']) ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>
</ol> </ol>
</div> </div>
<!-- Server --> <!-- Server -->
<div class="content" id="server"> <div class="content" id="server">
<?php foreach (['_SERVER', '_SESSION'] as $var) : ?> <?php foreach (['_SERVER', '_SESSION'] as $var) : ?>
<?php <?php
if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) { if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
continue; continue;
} ?> } ?>
<h3>$<?= esc($var) ?></h3> <h3>$<?= esc($var) ?></h3>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Key</th> <th>Key</th>
<th>Value</th> <th>Value</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($GLOBALS[$var] as $key => $value) : ?> <?php foreach ($GLOBALS[$var] as $key => $value) : ?>
<tr> <tr>
<td><?= esc($key) ?></td> <td><?= esc($key) ?></td>
<td> <td>
<?php if (is_string($value)) : ?> <?php if (is_string($value)) : ?>
<?= esc($value) ?> <?= esc($value) ?>
<?php else: ?> <?php else: ?>
<pre><?= esc(print_r($value, true)) ?></pre> <pre><?= esc(print_r($value, true)) ?></pre>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php endforeach ?> <?php endforeach ?>
<!-- Constants --> <!-- Constants -->
<?php $constants = get_defined_constants(true); ?> <?php $constants = get_defined_constants(true); ?>
<?php if (! empty($constants['user'])) : ?> <?php if (! empty($constants['user'])) : ?>
<h3>Constants</h3> <h3>Constants</h3>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Key</th> <th>Key</th>
<th>Value</th> <th>Value</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($constants['user'] as $key => $value) : ?> <?php foreach ($constants['user'] as $key => $value) : ?>
<tr> <tr>
<td><?= esc($key) ?></td> <td><?= esc($key) ?></td>
<td> <td>
<?php if (is_string($value)) : ?> <?php if (is_string($value)) : ?>
<?= esc($value) ?> <?= esc($value) ?>
<?php else: ?> <?php else: ?>
<pre><?= esc(print_r($value, true)) ?></pre> <pre><?= esc(print_r($value, true)) ?></pre>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php endif; ?> <?php endif; ?>
</div> </div>
<!-- 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>
<td><?= esc($request->getIPAddress()) ?></td> <td><?= esc($request->getIPAddress()) ?></td>
</tr> </tr>
<tr> <tr>
<td style="width: 10em">Is AJAX Request?</td> <td style="width: 10em">Is AJAX Request?</td>
<td><?= $request->isAJAX() ? 'yes' : 'no' ?></td> <td><?= $request->isAJAX() ? 'yes' : 'no' ?></td>
</tr> </tr>
<tr> <tr>
<td>Is CLI Request?</td> <td>Is CLI Request?</td>
<td><?= $request->isCLI() ? 'yes' : 'no' ?></td> <td><?= $request->isCLI() ? 'yes' : 'no' ?></td>
</tr> </tr>
<tr> <tr>
<td>Is Secure Request?</td> <td>Is Secure Request?</td>
<td><?= $request->isSecure() ? 'yes' : 'no' ?></td> <td><?= $request->isSecure() ? 'yes' : 'no' ?></td>
</tr> </tr>
<tr> <tr>
<td>User Agent</td> <td>User Agent</td>
<td><?= esc($request->getUserAgent()->getAgentString()) ?></td> <td><?= esc($request->getUserAgent()->getAgentString()) ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<?php $empty = true; ?> <?php $empty = true; ?>
<?php foreach (['_GET', '_POST', '_COOKIE'] as $var) : ?> <?php foreach (['_GET', '_POST', '_COOKIE'] as $var) : ?>
<?php <?php
if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) { if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
continue; continue;
} ?> } ?>
<?php $empty = false; ?> <?php $empty = false; ?>
<h3>$<?= esc($var) ?></h3> <h3>$<?= esc($var) ?></h3>
<table style="width: 100%"> <table style="width: 100%">
<thead> <thead>
<tr> <tr>
<th>Key</th> <th>Key</th>
<th>Value</th> <th>Value</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($GLOBALS[$var] as $key => $value) : ?> <?php foreach ($GLOBALS[$var] as $key => $value) : ?>
<tr> <tr>
<td><?= esc($key) ?></td> <td><?= esc($key) ?></td>
<td> <td>
<?php if (is_string($value)) : ?> <?php if (is_string($value)) : ?>
<?= esc($value) ?> <?= esc($value) ?>
<?php else: ?> <?php else: ?>
<pre><?= esc(print_r($value, true)) ?></pre> <pre><?= esc(print_r($value, true)) ?></pre>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php endforeach ?> <?php endforeach ?>
<?php if ($empty) : ?> <?php if ($empty) : ?>
<div class="alert"> <div class="alert">
No $_GET, $_POST, or $_COOKIE Information to show. No $_GET, $_POST, or $_COOKIE Information to show.
</div> </div>
<?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>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Header</th> <th>Header</th>
<th>Value</th> <th>Value</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($headers as $value) : ?> <?php foreach ($headers as $header) : ?>
<?php <tr>
if (empty($value)) { <td><?= esc($header->getName(), 'html') ?></td>
continue; <td><?= esc($header->getValueLine(), 'html') ?></td>
} </tr>
<?php endforeach; ?>
</tbody>
</table>
if (! is_array($value)) { <?php endif; ?>
$value = [$value]; </div>
} ?>
<?php foreach ($value as $h) : ?>
<tr>
<td><?= esc($h->getName(), 'html') ?></td>
<td><?= esc($h->getValueLine(), 'html') ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?> <!-- Response -->
</div> <?php
$response = Services::response();
<!-- Response -->
<?php
$response = \Config\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) ?>
<h3>Headers</h3> <h3>Headers</h3>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Header</th> <th>Header</th>
<th>Value</th> <th>Value</th>
</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>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php endif; ?> <?php endif; ?>
</div> </div>
<!-- Files --> <!-- Files -->
<div class="content" id="files"> <div class="content" id="files">
<?php $files = get_included_files(); ?> <?php $files = get_included_files(); ?>
<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>
<!-- Memory --> <!-- Memory -->
<div class="content" id="memory"> <div class="content" id="memory">
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td>Memory Usage</td> <td>Memory Usage</td>
<td><?= esc(static::describeMemory(memory_get_usage(true))) ?></td> <td><?= esc(static::describeMemory(memory_get_usage(true))) ?></td>
</tr> </tr>
<tr> <tr>
<td style="width: 12em">Peak Memory Usage:</td> <td style="width: 12em">Peak Memory Usage:</td>
<td><?= esc(static::describeMemory(memory_get_peak_usage(true))) ?></td> <td><?= esc(static::describeMemory(memory_get_peak_usage(true))) ?></td>
</tr> </tr>
<tr> <tr>
<td>Memory Limit:</td> <td>Memory Limit:</td>
<td><?= esc(ini_get('memory_limit')) ?></td> <td><?= esc(ini_get('memory_limit')) ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> <!-- /tab-content --> </div> <!-- /tab-content -->
</div> <!-- /container --> </div> <!-- /container -->
<?php endif; ?>
<div class="footer"> <div class="footer">
<div class="container"> <div class="container">
<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) ?> --
</p> Environment: <?= ENVIRONMENT ?>
</p>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,24 +1,24 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<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>
<body> <body>
<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>
</body> </body>

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();