Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • adaures/castopod
  • mkljczk/castopod-host
  • spaetz/castopod-host
  • PatrykMis/castopod
  • jonas/castopod
  • ajeremias/castopod
  • misuzu/castopod
  • KrzysztofDomanczyk/castopod
  • Behel/castopod
  • nebulon/castopod
  • ewen/castopod
  • NeoluxConsulting/castopod
  • nateritter/castopod-og
  • prcutler/castopod
14 results
Show changes
Showing
with 1333 additions and 884 deletions
<IfModule authz_core_module> <IfModule authz_core_module> Require all denied </IfModule>
Require all denied <IfModule !authz_core_module> Deny from all </IfModule>
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
<?php
namespace App\Authorization;
class FlatAuthorization extends \Myth\Auth\Authorization\FlatAuthorization
{
//--------------------------------------------------------------------
// Actions
//--------------------------------------------------------------------
/**
* Checks a group to see if they have the specified permission.
*
* @param int|string $permission
* @param int $groupId
*
* @return mixed
*/
public function groupHasPermission($permission, int $groupId)
{
if (
empty($permission) ||
(!is_string($permission) && !is_numeric($permission))
) {
return null;
}
if (empty($groupId) || !is_numeric($groupId)) {
return null;
}
// Get the Permission ID
$permissionId = $this->getPermissionID($permission);
if (!is_numeric($permissionId)) {
return false;
}
if (
$this->permissionModel->doesGroupHavePermission(
$groupId,
(int) $permissionId
)
) {
return true;
}
return false;
}
/**
* Makes user part of given groups.
*
* @param $userId
* @param array|null $groups // Either collection of ID or names
*
* @return bool
*/
public function setUserGroups(int $userId, $groups)
{
if (empty($userId) || !is_numeric($userId)) {
return null;
}
// remove user from all groups before resetting it in new groups
$this->groupModel->removeUserFromAllGroups($userId);
if (empty($groups)) {
return true;
}
foreach ($groups as $group) {
$this->addUserToGroup($userId, $group);
}
return true;
}
}
<?php
namespace App\Authorization;
class GroupModel extends \Myth\Auth\Authorization\GroupModel
{
public function getContributorRoles()
{
return $this->select('auth_groups.*')
->like('name', 'podcast_', 'after')
->findAll();
}
public function getUserRoles()
{
return $this->select('auth_groups.*')
->notLike('name', 'podcast_', 'after')
->findAll();
}
}
<?php
namespace App\Authorization;
class PermissionModel extends \Myth\Auth\Authorization\PermissionModel
{
/**
* Checks to see if a user, or one of their groups,
* has a specific permission.
*
* @param $userId
* @param $permissionId
*
* @return bool
*/
public function doesGroupHavePermission(
int $groupId,
int $permissionId
): bool {
// Check group permissions and take advantage of caching
$groupPerms = $this->getPermissionsForGroup($groupId);
return count($groupPerms) &&
array_key_exists($permissionId, $groupPerms);
}
/**
* Gets all permissions for a group in a way that can be
* easily used to check against:
*
* [
* id => name,
* id => name
* ]
*
* @param int $groupId
*
* @return array
*/
public function getPermissionsForGroup(int $groupId): array
{
if (!($found = cache("group{$groupId}_permissions"))) {
$groupPermissions = $this->db
->table('auth_groups_permissions')
->select('id, auth_permissions.name')
->join(
'auth_permissions',
'auth_permissions.id = permission_id',
'inner'
)
->where('group_id', $groupId)
->get()
->getResultObject();
$found = [];
foreach ($groupPermissions as $row) {
$found[$row->id] = strtolower($row->name);
}
cache()->save("group{$groupId}_permissions", $found, 300);
}
return $found;
}
}
<?php
declare(strict_types=1);
namespace App\Commands;
use App\Models\EpisodeModel;
use CodeIgniter\CLI\BaseCommand;
class EpisodesComputeDownloads extends BaseCommand
{
/**
* The Command's Group
*
* @var string
*/
protected $group = 'Episodes';
/**
* The Command's Name
*
* @var string
*/
protected $name = 'episodes:compute-downloads';
/**
* The Command's Description
*
* @var string
*/
protected $description = "Calculates all episodes downloads and stores results in episodes' downloads_count field.";
/**
* Actually execute a command.
*/
public function run(array $params): void
{
$episodesModel = new EpisodeModel();
$query = $episodesModel->builder()
->select('episodes.id as id, IFNULL(SUM(ape.hits),0) as downloads_count')
->join('analytics_podcasts_by_episode ape', 'episodes.id=ape.episode_id', 'left')
->groupBy('episodes.id');
$episodeModel2 = new EpisodeModel();
$episodeModel2->builder()
->setQueryAsData($query)
->onConstraint('id')
->updateBatch();
}
}
<?php <?php
declare(strict_types=1);
use ViewThemes\Theme;
/** /**
* The goal of this file is to allow developers a location * The goal of this file is to allow developers a location where they can overwrite core procedural functions and
* where they can overwrite core procedural functions and * replace them with their own. This file is loaded during the bootstrap process and is called during the framework's
* replace them with their own. This file is loaded during
* the bootstrap process and is called during the frameworks
* execution. * execution.
* *
* This can be looked at as a `master helper` file that is * This can be looked at as a `master helper` file that is loaded early on, and may also contain additional functions
* loaded early on, and may also contain additional functions
* that you'd like to use throughout your entire application * that you'd like to use throughout your entire application
* *
* @link: https://codeigniter4.github.io/CodeIgniter4/ * @see: https://codeigniter.com/user_guide/extending/common.html
*/ */
if (! function_exists('view')) {
/**
* Grabs the current RendererInterface-compatible class and tells it to render the specified view. Simply provides a
* convenience method that can be used in Controllers, libraries, and routed closures.
*
* NOTE: Does not provide any escaping of the data, so that must all be handled manually by the developer.
*
* @param array<string, mixed> $data
* @param array<string, mixed> $options Unused - reserved for third-party extensions.
*/
function view(string $name, array $data = [], array $options = []): string
{
if (array_key_exists('theme', $options)) {
Theme::setTheme($options['theme']);
}
$path = Theme::path();
/** @var CodeIgniter\View\View $renderer */
$renderer = single_service('renderer', $path);
$saveData = config('View')
->saveData;
if (array_key_exists('saveData', $options)) {
$saveData = (bool) $options['saveData'];
unset($options['saveData']);
}
return $renderer->setData($data, 'raw')
->render($name, $options, $saveData);
}
}
<?php <?php
declare(strict_types=1);
namespace Config; namespace Config;
use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\BaseConfig;
use Override;
class App extends BaseConfig class App extends BaseConfig
{ {
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Base Site URL * Base Site URL
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| URL to your CodeIgniter root. Typically this will be your base URL, * URL to your CodeIgniter root. Typically, this will be your base URL,
| WITH a trailing slash: * WITH a trailing slash:
| *
| http://example.com/ * E.g., http://example.com/
| */
| If this is not set then CodeIgniter will try guess the protocol, domain public string $baseURL = 'http://localhost:8080/';
| and path to your installation. However, you should always configure this
| explicitly and never rely on auto-guessing, especially in production
| environments.
|
*/
public $baseURL = 'http://localhost:8080/';
/* /**
|-------------------------------------------------------------------------- * Allowed Hostnames in the Site URL other than the hostname in the baseURL.
| Index File * If you want to accept multiple Hostnames, set this.
|-------------------------------------------------------------------------- *
| * E.g.,
| Typically this will be your index.php file, unless you've renamed it to * When your site URL ($baseURL) is 'http://example.com/', and your site
| something else. If you are using mod_rewrite to remove the page set this * also accepts 'http://media.example.com/' and 'http://accounts.example.com/':
| variable so that it is blank. * ['media.example.com', 'accounts.example.com']
| *
*/ * @var list<string>
public $indexPage = ''; */
public array $allowedHostnames = [];
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| URI PROTOCOL * Index File
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| This item determines which getServer global should be used to retrieve the * Typically, this will be your `index.php` file, unless you've renamed it to
| URI string. The default setting of 'REQUEST_URI' works for most servers. * something else. If you have configured your web server to remove this file
| If your links do not seem to work, try one of the other delicious flavors: * from your site URIs, set this variable to an empty string.
| */
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI'] public string $indexPage = '';
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO' Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
public $uriProtocol = 'REQUEST_URI';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Default Locale * URI PROTOCOL
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| The Locale roughly represents the language and location that your visitor * This item determines which server global should be used to retrieve the
| is viewing the site from. It affects the language strings and other * URI string. The default setting of 'REQUEST_URI' works for most servers.
| strings (like currency markers, numbers, etc), that your program * If your links do not seem to work, try one of the other delicious flavors:
| should run under for this request. *
| * 'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
*/ * 'QUERY_STRING': Uses $_SERVER['QUERY_STRING']
public $defaultLocale = 'en'; * 'PATH_INFO': Uses $_SERVER['PATH_INFO']
*
* WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
public string $uriProtocol = 'REQUEST_URI';
/* /*
|-------------------------------------------------------------------------- *--------------------------------------------------------------------------
| Negotiate Locale * Allowed URL Characters
|-------------------------------------------------------------------------- *--------------------------------------------------------------------------
| *
| If true, the current Request object will automatically determine the * This lets you specify which characters are permitted within your URLs.
| language to use based on the value of the Accept-Language header. * When someone tries to submit a URL with disallowed characters they will
| * get a warning message.
| If false, no automatic detection will be performed. *
| * As a security measure you are STRONGLY encouraged to restrict URLs to
* as few characters as possible.
*
* By default, only these are allowed: `a-z 0-9~%.:_-`
*
* Set an empty string to allow all characters -- but only if you are insane.
*
* The configured value is actually a regular expression character group
* and it will be used as: '/\A[<permittedURIChars>]+\z/iu'
*
* DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
*
*/ */
public $negotiateLocale = true; public string $permittedURIChars = 'a-z 0-9~%.:_\-@';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Supported Locales * Default Locale
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| If $negotiateLocale is true, this array lists the locales supported * The Locale roughly represents the language and location that your visitor
| by the application in descending order of priority. If no match is * is viewing the site from. It affects the language strings and other
| found, the first locale will be used. * strings (like currency markers, numbers, etc), that your program
| * should run under for this request.
*/ */
public $supportedLocales = ['en']; public string $defaultLocale = 'en';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Application Timezone * Negotiate Locale
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| The default timezone that will be used in your application to display * If true, the current Request object will automatically determine the
| dates with the date helper, and can be retrieved through app_timezone() * language to use based on the value of the Accept-Language header.
| *
*/ * If false, no automatic detection will be performed.
public $appTimezone = 'UTC'; */
public bool $negotiateLocale = true;
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Default Character Set * Supported Locales
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| This determines which character set is used by default in various methods * If $negotiateLocale is true, this array lists the locales supported
| that require a character set to be provided. * by the application in descending order of priority. If no match is
| * found, the first locale will be used.
| See http://php.net/htmlspecialchars for a list of supported charsets. *
| * IncomingRequest::setLocale() also uses this list.
*/ *
public $charset = 'UTF-8'; * @var list<string>
*/
public array $supportedLocales = [
'en',
'fr',
'pl',
'de',
'pt-br',
'nn-no',
'es',
'zh-hans',
'ca',
'br',
'sr-latn',
];
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| URI PROTOCOL * Application Timezone
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| If true, this will force every request made to this application to be * The default timezone that will be used in your application to display
| made via a secure connection (HTTPS). If the incoming request is not * dates with the date helper, and can be retrieved through app_timezone()
| secure, the user will be redirected to a secure version of the page *
| and the HTTP Strict Transport Security header will be set. * @see https://www.php.net/manual/en/timezones.php for list of timezones
*/ * supported by PHP.
public $forceGlobalSecureRequests = false; */
public string $appTimezone = 'UTC';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Session Variables * Default Character Set
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| 'sessionDriver' * This determines which character set is used by default in various methods
| * that require a character set to be provided.
| The storage driver to use: files, database, redis, memcached *
| - CodeIgniter\Session\Handlers\FileHandler * @see http://php.net/htmlspecialchars for a list of supported charsets.
| - CodeIgniter\Session\Handlers\DatabaseHandler */
| - CodeIgniter\Session\Handlers\MemcachedHandler public string $charset = 'UTF-8';
| - CodeIgniter\Session\Handlers\RedisHandler
|
| 'sessionCookieName'
|
| The session cookie name, must contain only [0-9a-z_-] characters
|
| 'sessionExpiration'
|
| The number of SECONDS you want the session to last.
| Setting to 0 (zero) means expire when the browser is closed.
|
| 'sessionSavePath'
|
| The location to save sessions to, 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!
|
| 'sessionMatchIP'
|
| 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.
|
| 'sessionTimeToUpdate'
|
| How many seconds between CI regenerating the session ID.
|
| 'sessionRegenerateDestroy'
|
| 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.
|
| Other session cookie settings are shared with the rest of the application,
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
*/
public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler';
public $sessionCookieName = 'ci_session';
public $sessionExpiration = 7200;
public $sessionSavePath = WRITEPATH . 'session';
public $sessionMatchIP = false;
public $sessionTimeToUpdate = 300;
public $sessionRegenerateDestroy = false;
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Cookie Related Variables * URI PROTOCOL
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| 'cookiePrefix' = Set a cookie name prefix if you need to avoid collisions * If true, this will force every request made to this application to be
| 'cookieDomain' = Set to .your-domain.com for site-wide cookies * made via a secure connection (HTTPS). If the incoming request is not
| 'cookiePath' = Typically will be a forward slash * secure, the user will be redirected to a secure version of the page
| 'cookieSecure' = Cookie will only be set if a secure HTTPS connection exists. * and the HTTP Strict Transport Security (HSTS) header will be set.
| 'cookieHTTPOnly' = Cookie will only be accessible via HTTP(S) (no javascript) */
| public bool $forceGlobalSecureRequests = true;
| Note: These settings (with the exception of 'cookie_prefix' and
| 'cookie_httponly') will also affect sessions.
|
*/
public $cookiePrefix = '';
public $cookieDomain = '';
public $cookiePath = '/';
public $cookieSecure = false;
public $cookieHTTPOnly = false;
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Reverse Proxy IPs * Reverse Proxy IPs
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| 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: array('10.0.1.200', '192.168.5.0/24') * [
*/ * '10.0.1.200' => 'X-Forwarded-For',
public $proxyIPs = ''; * '192.168.5.0/24' => 'X-Real-IP',
* ]
*
* @var array<string, string>|string
*/
public $proxyIPs = [];
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Cross Site Request Forgery * Content Security Policy
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be *
| checked on a submitted form. If you are accepting user data, it is strongly * Enables the Response's Content Secure Policy to restrict the sources that
| recommended CSRF protection be enabled. * can be used for images, scripts, CSS files, audio, video, etc. If enabled,
| * the Response object will populate default values for the policy from the
| CSRFTokenName = The token name * `ContentSecurityPolicy.php` file. Controllers can always add to those
| CSRFHeaderName = The header name * restrictions at run time.
| CSRFCookieName = The cookie name *
| CSRFExpire = The number in seconds the token should expire. * For a better understanding of CSP, see these documents:
| CSRFRegenerate = Regenerate token on every submission *
| CSRFRedirect = Redirect to previous page with error on failure * @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
*/ * @see http://www.w3.org/TR/CSP/
public $CSRFTokenName = 'csrf_test_name'; */
public $CSRFHeaderName = 'X-CSRF-TOKEN'; public bool $CSPEnabled = false;
public $CSRFCookieName = 'csrf_cookie_name';
public $CSRFExpire = 7200;
public $CSRFRegenerate = true;
public $CSRFRedirect = true;
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Content Security Policy * Instance / Site Config
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Enables the Response's Content Secure Policy to restrict the sources that */
| can be used for images, scripts, CSS files, audio, video, etc. If enabled, public string $siteName = 'Castopod';
| the Response object will populate default values for the policy from the
| ContentSecurityPolicy.php file. Controllers can always add to those
| restrictions at run time.
|
| For a better understanding of CSP, see these documents:
| - http://www.html5rocks.com/en/tutorials/security/content-security-policy/
| - http://www.w3.org/TR/CSP/
*/
public $CSPEnabled = false;
/* public string $siteTitleSeparator = ' | ';
|--------------------------------------------------------------------------
| Media root folder
|--------------------------------------------------------------------------
| Defines the root folder for media files storage
*/
public $mediaRoot = 'media';
/* public string $siteDescription = 'Castopod is an open-source hosting platform made for podcasters who want engage and interact with their audience.';
|--------------------------------------------------------------------------
| Admin gateway
|--------------------------------------------------------------------------
| Defines a base route for all admin pages
*/
public $adminGateway = 'cp-admin';
/* /**
|-------------------------------------------------------------------------- * @var array<int|string, string>
| Auth gateway */
|-------------------------------------------------------------------------- public array $siteIcon = [
| Defines a base route for all authentication related pages 'ico' => '/favicon.ico',
*/ '64' => '/icon-64.png',
public $authGateway = 'cp-auth'; '180' => '/icon-180.png',
'192' => '/icon-192.png',
'512' => '/icon-512.png',
];
/* public string $theme = 'pine';
|--------------------------------------------------------------------------
| Install gateway /**
|-------------------------------------------------------------------------- * Storage limit in Gigabytes
| Defines a base route for instance installation */
*/ public ?int $storageLimit = null;
public $installGateway = 'cp-install';
/**
* Bandwidth limit (per month) in Gigabytes
*/
public ?int $bandwidthLimit = null;
public ?string $legalNoticeURL = null;
/**
* AuthToken Config Constructor
*/
public function __construct()
{
parent::__construct();
if (is_string($this->proxyIPs)) {
$array = json_decode($this->proxyIPs, true);
if (is_array($array)) {
$this->proxyIPs = $array;
}
}
}
/**
* Override parent initEnvValue() to allow for direct setting to array properties values from ENV
*
* In order to set array properties via ENV vars we need to set the property to a string value first.
*
* @param mixed $property
*/
#[Override]
protected function initEnvValue(&$property, string $name, string $prefix, string $shortPrefix): void
{
// if attempting to set property from ENV, first set to empty string
if ($name === 'proxyIPs' && $this->getEnvValue($name, $prefix, $shortPrefix) !== null) {
$property = '';
}
parent::initEnvValue($property, $name, $prefix, $shortPrefix);
}
} }
<?php
namespace Config;
class Auth extends \Myth\Auth\Config\Auth
{
//--------------------------------------------------------------------
// Views used by Auth Controllers
//--------------------------------------------------------------------
public $views = [
'login' => 'auth/login',
'register' => 'auth/register',
'forgot' => 'auth/forgot',
'reset' => 'auth/reset',
'emailForgot' => 'auth/emails/forgot',
'emailActivation' => 'auth/emails/activation',
];
//--------------------------------------------------------------------
// Layout for the views to extend
//--------------------------------------------------------------------
public $viewLayout = 'auth/_layout';
//--------------------------------------------------------------------
// Allow User Registration
//--------------------------------------------------------------------
// When enabled (default) any unregistered user may apply for a new
// account. If you disable registration you may need to ensure your
// controllers and views know not to offer registration.
//
public $allowRegistration = false;
//--------------------------------------------------------------------
// Require confirmation registration via email
//--------------------------------------------------------------------
// When enabled, every registered user will receive an email message
// with a special link he have to confirm to activate his account.
//
public $requireActivation = false;
}
<?php <?php
declare(strict_types=1);
namespace Config; namespace Config;
require_once SYSTEMPATH . 'Config/AutoloadConfig.php'; use CodeIgniter\Config\AutoloadConfig;
/** /**
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* AUTO-LOADER * AUTO-LOADER
* ------------------------------------------------------------------- * -------------------------------------------------------------------
*
* This file defines the namespaces and class maps so the Autoloader * This file defines the namespaces and class maps so the Autoloader
* can find the files as needed. * can find the files as needed.
*
* NOTE: If you use an identical key in $psr4 or $classmap, then
* the values in this file will overwrite the framework's values.
*
* @immutable
*/ */
class Autoload extends \CodeIgniter\Config\AutoloadConfig class Autoload extends AutoloadConfig
{ {
/**
* -------------------------------------------------------------------
* Namespaces
* -------------------------------------------------------------------
* This maps the locations of any namespaces in your application to
* their location on the file system. These are used by the autoloader
* to locate files the first time they have been instantiated.
*
* The 'Config' (APPPATH . 'Config') and 'CodeIgniter' (SYSTEMPATH) are
* already mapped for you.
*
* You may change the name of the 'App' namespace if you wish,
* but this should be done prior to creating any namespaced classes,
* else you will need to modify all of those classes for this to work.
*
* @var array<string, list<string>|string>
*/
public $psr4 = [ public $psr4 = [
'App' => APPPATH, APP_NAMESPACE => APPPATH,
'Modules' => ROOTPATH . 'modules/',
'Modules\Admin' => ROOTPATH . 'modules/Admin/',
'Modules\Analytics' => ROOTPATH . 'modules/Analytics/',
'Modules\Api\Rest\V1' => ROOTPATH . 'modules/Api/Rest/V1',
'Modules\Auth' => ROOTPATH . 'modules/Auth/',
'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/',
'Modules\Install' => ROOTPATH . 'modules/Install/',
'Modules\Media' => ROOTPATH . 'modules/Media/',
'Modules\MediaClipper' => ROOTPATH . 'modules/MediaClipper/',
'Modules\Platforms' => ROOTPATH . 'modules/Platforms/',
'Modules\Plugins' => ROOTPATH . 'modules/Plugins/',
'Modules\PodcastImport' => ROOTPATH . 'modules/PodcastImport/',
'Modules\PremiumPodcasts' => ROOTPATH . 'modules/PremiumPodcasts/',
'Modules\Update' => ROOTPATH . 'modules/Update/',
'Modules\WebSub' => ROOTPATH . 'modules/WebSub/',
'Themes' => ROOTPATH . 'themes',
'ViewComponents' => APPPATH . 'Libraries/ViewComponents/',
'ViewThemes' => APPPATH . 'Libraries/ViewThemes/',
]; ];
/**
* -------------------------------------------------------------------
* -------------------------------------------------------------------
* The class map provides a map of class names and their exact
* location on the drive. Classes loaded in this manner will have
* slightly faster performance because they will not have to be
* searched for within one or more directories as they would if they
* were being autoloaded through a namespace.
*
* Prototype:
*
* $classmap = [
* 'MyClass' => '/path/to/class/file.php'
* ];
*
* @var array<string, string>
*/
public $classmap = []; public $classmap = [];
//--------------------------------------------------------------------
/** /**
* Collects the application-specific autoload settings and merges * -------------------------------------------------------------------
* them with the framework's required settings. * Files
* -------------------------------------------------------------------
* The files array provides a list of paths to __non-class__ files
* that will be autoloaded. This can be useful for bootstrap operations
* or for loading functions.
*
* Prototype:
*
* $files = [
* '/path/to/my/file.php',
* ];
* *
* NOTE: If you use an identical key in $psr4 or $classmap, then * @var list<string>
* the values in this file will overwrite the framework's values.
*/ */
public function __construct() public $files = [];
{
parent::__construct();
/**
* -------------------------------------------------------------------
* Namespaces
* -------------------------------------------------------------------
* This maps the locations of any namespaces in your application
* to their location on the file system. These are used by the
* Autoloader to locate files the first time they have been instantiated.
*
* The '/app' and '/system' directories are already mapped for
* you. You may change the name of the 'App' namespace if you wish,
* but this should be done prior to creating any namespaced classes,
* else you will need to modify all of those classes for this to work.
*
* DO NOT change the name of the CodeIgniter namespace or your application
* WILL break. *
* Prototype:
*
* $Config['psr4'] = [
* 'CodeIgniter' => SYSPATH
* `];
*/
$psr4 = [
'App' => APPPATH, // To ensure filters, etc still found,
APP_NAMESPACE => APPPATH, // For custom namespace
'Config' => APPPATH . 'Config',
];
/**
* -------------------------------------------------------------------
* Class Map
* -------------------------------------------------------------------
* The class map provides a map of class names and their exact
* location on the drive. Classes loaded in this manner will have
* slightly faster performance because they will not have to be
* searched for within one or more directories as they would if they
* were being autoloaded through a namespace.
*
* Prototype:
*
* $Config['classmap'] = [
* 'MyClass' => '/path/to/class/file.php'
* ];
*/
$classmap = [];
//--------------------------------------------------------------------
// Do Not Edit Below This Line
//--------------------------------------------------------------------
$this->psr4 = array_merge($this->psr4, $psr4); /**
$this->classmap = array_merge($this->classmap, $classmap); * -------------------------------------------------------------------
* Helpers
unset($psr4, $classmap); * -------------------------------------------------------------------
} * Prototype:
* $helpers = [
//-------------------------------------------------------------------- * 'form',
* ];
*
* @var list<string>
*/
public $helpers = ['auth', 'setting', 'plugins'];
} }
<?php <?php
/* declare(strict_types=1);
|--------------------------------------------------------------------------
| ERROR DISPLAY /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help * ERROR DISPLAY
| make sure they don't make it to production. And save us hours of * --------------------------------------------------------------------------
| painful debugging. * In development, we want to show as many errors as possible to help
* make sure they don't make it to production. And save us hours of
* painful debugging.
*
* If you set 'display_errors' to '1', CI4's detailed error report will show.
*/ */
error_reporting(-1); error_reporting(E_ALL);
ini_set('display_errors', '1'); ini_set('display_errors', '1');
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| DEBUG BACKTRACES * DEBUG BACKTRACES
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug * If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would * backtraces along with the other error information. If you would
| prefer to not see this, set this value to false. * prefer to not see this, set this value to false.
*/ */
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true); defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| DEBUG MODE * DEBUG MODE
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout * Debug mode is an experimental flag that can allow changes throughout
| the system. This will control whether Kint is loaded, and a few other * the system. This will control whether Kint is loaded, and a few other
| items. It can always be used within your own application too. * items. It can always be used within your own application too.
*/ */
defined('CI_DEBUG') || define('CI_DEBUG', true);
defined('CI_DEBUG') || define('CI_DEBUG', 1);
<?php <?php
/* declare(strict_types=1);
|--------------------------------------------------------------------------
| ERROR DISPLAY /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch * ERROR DISPLAY
| it and display a generic error message. * --------------------------------------------------------------------------
* Don't show ANY in production environments. Instead, let the system catch
* it and display a generic error message.
*
* If you set 'display_errors' to '1', CI4's detailed error report will show.
*/ */
error_reporting(E_ALL & ~E_DEPRECATED);
// If you want to suppress more types of errors.
// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
ini_set('display_errors', '0'); ini_set('display_errors', '0');
error_reporting(
E_ALL &
~E_NOTICE &
~E_DEPRECATED &
~E_STRICT &
~E_USER_NOTICE &
~E_USER_DEPRECATED
);
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| DEBUG MODE * DEBUG MODE
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout * Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive * the system. It's not widely used currently, and may not survive
| release of the framework. * release of the framework.
*/ */
defined('CI_DEBUG') || define('CI_DEBUG', false);
defined('CI_DEBUG') || define('CI_DEBUG', 0);
<?php <?php
declare(strict_types=1);
/* /*
|-------------------------------------------------------------------------- * The environment testing is reserved for PHPUnit testing. It has special
| ERROR DISPLAY * conditions built into the framework at various places to assist with that.
|-------------------------------------------------------------------------- * You can’t use it for your development.
| In development, we want to show as many errors as possible to help */
| make sure they don't make it to production. And save us hours of
| painful debugging. /**
* --------------------------------------------------------------------------
* ERROR DISPLAY
* --------------------------------------------------------------------------
* In development, we want to show as many errors as possible to help
* make sure they don't make it to production. And save us hours of
* painful debugging.
*/ */
error_reporting(-1); error_reporting(E_ALL);
ini_set('display_errors', '1'); ini_set('display_errors', '1');
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| DEBUG BACKTRACES * DEBUG BACKTRACES
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug * If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would * backtraces along with the other error information. If you would
| prefer to not see this, set this value to false. * prefer to not see this, set this value to false.
*/ */
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true); defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| DEBUG MODE * DEBUG MODE
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout * Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive * the system. It's not widely used currently, and may not survive
| release of the framework. * release of the framework.
*/ */
defined('CI_DEBUG') || define('CI_DEBUG', true);
defined('CI_DEBUG') || define('CI_DEBUG', 1);
<?php
declare(strict_types=1);
namespace 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;
}
<?php <?php
declare(strict_types=1);
namespace Config; namespace Config;
use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\Cache\Handlers\DummyHandler;
use CodeIgniter\Cache\Handlers\FileHandler;
use CodeIgniter\Cache\Handlers\MemcachedHandler;
use CodeIgniter\Cache\Handlers\PredisHandler;
use CodeIgniter\Cache\Handlers\RedisHandler;
use CodeIgniter\Cache\Handlers\WincacheHandler;
use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\BaseConfig;
class Cache extends BaseConfig class Cache extends BaseConfig
{ {
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Primary Handler * Primary Handler
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| The name of the preferred handler that should be used. If for some reason * The name of the preferred handler that should be used. If for some reason
| it is not available, the $backupHandler will be used in its place. * it is not available, the $backupHandler will be used in its place.
| */
*/ public string $handler = 'file';
public $handler = 'file';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Backup Handler * Backup Handler
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| The name of the handler that will be used in case the first one is * The name of the handler that will be used in case the first one is
| unreachable. Often, 'file' is used here since the filesystem is * unreachable. Often, 'file' is used here since the filesystem is
| always available, though that's not always practical for the app. * always available, though that's not always practical for the app.
| */
*/ public string $backupHandler = 'dummy';
public $backupHandler = 'dummy';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Cache Directory Path * Key Prefix
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| The path to where cache files should be stored, if using a file-based * This string is added to all cache item names to help avoid collisions
| system. * if you run multiple applications with the same cache engine.
| */
*/ public string $prefix = '';
public $storePath = WRITEPATH . 'cache/';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Cache Include Query String * Default TTL
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| Whether to take the URL query string into consideration when generating * The default number of seconds to save items when none is specified.
| output cache files. Valid options are: *
| * WARNING: This is not used by framework handlers where 60 seconds is
| false = Disabled * hard-coded, but may be useful to projects and modules. This will replace
| true = Enabled, take all query parameters into account. * the hard-coded value in a future release.
| Please be aware that this may result in numerous cache */
| files generated for the same page over and over again. public int $ttl = 60;
| array('q') = Enabled, but only take into account the specified list
| of query parameters. /**
| * --------------------------------------------------------------------------
*/ * Reserved Characters
public $cacheQueryString = false; * --------------------------------------------------------------------------
*
* A string of reserved characters that will not be allowed in keys or tags.
* Strings that violate this restriction will cause handlers to throw.
* Default: {}()/\@:
*
* Note: The default set is required for PSR-6 compliance.
*/
public string $reservedCharacters = '{}()/\@:';
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Key Prefix * File settings
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| This string is added to all cache item names to help avoid collisions * Your file storage preferences can be specified below, if you are using
| if you run multiple applications with the same cache engine. * the File driver.
| *
*/ * @var array<string, string|int|null>
public $prefix = ''; */
public array $file = [
'storePath' => WRITEPATH . 'cache/',
'mode' => 0640,
];
/* /**
| ------------------------------------------------------------------------- * -------------------------------------------------------------------------
| Memcached settings * Memcached settings
| ------------------------------------------------------------------------- * -------------------------------------------------------------------------
| Your Memcached servers can be specified below, if you are using *
| the Memcached drivers. * Your Memcached servers can be specified below, if you are using
| * the Memcached drivers.
| See: https://codeigniter.com/user_guide/libraries/caching.html#memcached *
| * @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
*/ *
public $memcached = [ * @var array<string, string|int|bool>
'host' => '127.0.0.1', */
'port' => 11211, public array $memcached = [
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 1, 'weight' => 1,
'raw' => false, 'raw' => false,
]; ];
/* /**
| ------------------------------------------------------------------------- * -------------------------------------------------------------------------
| Redis settings * Redis settings
| ------------------------------------------------------------------------- * -------------------------------------------------------------------------
| Your Redis server can be specified below, if you are using * Your Redis server can be specified below, if you are using
| the Redis or Predis drivers. * the Redis or Predis drivers.
| *
*/ * @var array<string, string|int|null>
public $redis = [ */
'host' => '127.0.0.1', public array $redis = [
'host' => '127.0.0.1',
'password' => null, 'password' => null,
'port' => 6379, 'port' => 6379,
'timeout' => 0, 'timeout' => 0,
'database' => 0, 'database' => 0,
]; ];
/* /**
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| Available Cache Handlers * Available Cache Handlers
|-------------------------------------------------------------------------- * --------------------------------------------------------------------------
| *
| This is an array of cache engine alias' and class names. Only engines * This is an array of cache engine alias' and class names. Only engines
| that are listed here are allowed to be used. * that are listed here are allowed to be used.
| *
*/ * @var array<string, class-string<CacheInterface>>
public $validHandlers = [ */
'dummy' => \CodeIgniter\Cache\Handlers\DummyHandler::class, public array $validHandlers = [
'file' => \CodeIgniter\Cache\Handlers\FileHandler::class, 'dummy' => DummyHandler::class,
'memcached' => \CodeIgniter\Cache\Handlers\MemcachedHandler::class, 'file' => FileHandler::class,
'predis' => \CodeIgniter\Cache\Handlers\PredisHandler::class, 'memcached' => MemcachedHandler::class,
'redis' => \CodeIgniter\Cache\Handlers\RedisHandler::class, 'predis' => PredisHandler::class,
'wincache' => \CodeIgniter\Cache\Handlers\WincacheHandler::class, 'redis' => RedisHandler::class,
'wincache' => WincacheHandler::class,
]; ];
/**
* --------------------------------------------------------------------------
* Web Page Caching: Cache Include Query String
* --------------------------------------------------------------------------
*
* Whether to take the URL query string into consideration when generating
* output cache files. Valid options are:
*
* false = Disabled
* true = Enabled, take all query parameters into account.
* Please be aware that this may result in numerous cache
* files generated for the same page over and over again.
* ['q'] = Enabled, but only take into account the specified list
* of query parameters.
*
* @var bool|list<string>
*/
public $cacheQueryString = false;
} }
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Colors extends BaseConfig
{
/**
* @var array<string, array<string, mixed>>
*/
public array $themes = [
/* Castopod's brand color */
'pine' => [
'accent-base' => [174, 100, 29],
'accent-hover' => [172, 100, 17],
'accent-muted' => [131, 100, 12],
'accent-contrast' => [0, 0, 100],
'heading-foreground' => [172, 100, 17],
'heading-background' => [111, 64, 94],
'background-elevated' => [0, 0, 100],
'background-base' => [173, 44, 96],
'background-navigation' => [172, 100, 17],
'background-header' => [172, 100, 17],
'background-highlight' => [111, 64, 94],
'background-backdrop' => [0, 0, 50],
'border-subtle' => [111, 42, 86],
'border-contrast' => [0, 0, 0],
'border-navigation' => [131, 100, 12],
'text-base' => [158, 8, 3],
'text-muted' => [172, 8, 38],
],
/* Red / Rose color */
'crimson' => [
'accent-base' => [350, 87, 61],
'accent-hover' => [348, 75, 40],
'accent-muted' => [348, 73, 32],
'accent-contrast' => [0, 0, 100],
'heading-foreground' => [348, 73, 32],
'heading-background' => [344, 79, 96],
'background-elevated' => [0, 0, 100],
'background-base' => [350, 44, 96],
'background-header' => [348, 75, 40],
'background-highlight' => [344, 79, 96],
'background-backdrop' => [0, 0, 50],
'border-subtle' => [348, 42, 86],
'border-contrast' => [0, 0, 0],
'text-base' => [340, 8, 3],
'text-muted' => [345, 8, 38],
],
/* Blue color */
'lake' => [
'accent-base' => [194, 100, 44],
'accent-hover' => [194, 100, 22],
'accent-muted' => [195, 100, 11],
'accent-contrast' => [0, 0, 100],
'heading-foreground' => [194, 100, 22],
'heading-background' => [195, 100, 92],
'background-elevated' => [0, 0, 100],
'background-base' => [196, 44, 96],
'background-header' => [194, 100, 22],
'background-highlight' => [195, 100, 92],
'background-backdrop' => [0, 0, 50],
'border-subtle' => [195, 42, 86],
'border-contrast' => [0, 0, 0],
'text-base' => [194, 8, 3],
'text-muted' => [195, 8, 38],
],
/* Orange color */
'amber' => [
'accent-base' => [17, 100, 57],
'accent-hover' => [17, 100, 35],
'accent-muted' => [17, 100, 24],
'accent-contrast' => [0, 0, 100],
'heading-foreground' => [17, 100, 35],
'heading-background' => [17, 100, 89],
'background-elevated' => [0, 0, 100],
'background-base' => [15, 44, 96],
'background-header' => [17, 100, 35],
'background-highlight' => [17, 100, 89],
'background-backdrop' => [0, 0, 50],
'border-subtle' => [17, 42, 86],
'border-contrast' => [0, 0, 0],
'text-base' => [15, 8, 3],
'text-muted' => [17, 8, 38],
],
/* Violet color */
'jacaranda' => [
'accent-base' => [254, 72, 52],
'accent-hover' => [254, 73, 30],
'accent-muted' => [254, 71, 19],
'accent-contrast' => [0, 0, 100],
'heading-foreground' => [254, 73, 30],
'heading-background' => [254, 73, 84],
'background-elevated' => [0, 0, 100],
'background-base' => [253, 44, 96],
'background-header' => [254, 73, 30],
'background-highlight' => [254, 88, 91],
'background-backdrop' => [0, 0, 50],
'border-subtle' => [254, 42, 86],
'border-contrast' => [0, 0, 0],
'text-base' => [253, 8, 3],
'text-muted' => [254, 8, 38],
],
/* Black color */
'onyx' => [
'accent-base' => [240, 17, 2],
'accent-hover' => [240, 17, 17],
'accent-muted' => [240, 17, 17],
'accent-contrast' => [0, 0, 100],
'heading-foreground' => [240, 17, 17],
'heading-background' => [240, 17, 94],
'background-elevated' => [0, 0, 100],
'background-base' => [240, 17, 96],
'background-header' => [240, 12, 17],
'background-highlight' => [240, 17, 94],
'background-backdrop' => [0, 0, 50],
'border-subtle' => [240, 17, 86],
'border-contrast' => [0, 0, 0],
'text-base' => [240, 8, 3],
'text-muted' => [240, 8, 38],
],
];
}
<?php <?php
//-------------------------------------------------------------------- declare(strict_types=1);
// App Namespace
//-------------------------------------------------------------------- /*
// This defines the default Namespace that is used throughout | --------------------------------------------------------------------
// CodeIgniter to refer to the Application directory. Change | Castopod Version
// this constant to change the namespace that all application | --------------------------------------------------------------------
// classes should use. |
// | The Castopod version number to display.
// NOTE: changing this will require manually modifying the |
// existing namespaces of App\* namespaced-classes. | NOTE: this constant is updated upon release with Continuous Integration.
// */
defined('CP_VERSION') || define('CP_VERSION', '2.0.0-next.3');
/*
| --------------------------------------------------------------------
| App Namespace
| --------------------------------------------------------------------
|
| This defines the default Namespace that is used throughout
| CodeIgniter to refer to the Application directory. Change
| this constant to change the namespace that all application
| classes should use.
|
| NOTE: changing this will require manually modifying the
| existing namespaces of App* namespaced-classes.
*/
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App'); defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
/* /*
|-------------------------------------------------------------------------- | --------------------------------------------------------------------
| Composer Path | Plugins Path
|-------------------------------------------------------------------------- | --------------------------------------------------------------------
| |
| The path that Composer's autoload file is expected to live. By default, | This defines the folder in which plugins will live.
| the vendor folder is in the Root directory, but you can customize that here. */
*/ defined('PLUGINS_PATH') ||
define('PLUGINS_PATH', ROOTPATH . 'plugins' . DIRECTORY_SEPARATOR);
defined('PLUGINS_KEY_PATTERN') ||
define('PLUGINS_KEY_PATTERN', '[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9]([_.-]?[a-z0-9]+)*');
/*
| --------------------------------------------------------------------------
| Composer Path
| --------------------------------------------------------------------------
|
| The path that Composer's autoload file is expected to live. By default,
| the vendor folder is in the Root directory, but you can customize that here.
*/
defined('COMPOSER_PATH') || defined('COMPOSER_PATH') ||
define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php'); define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Timing Constants | Timing Constants
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Provide simple ways to work with the myriad of PHP functions that | Provide simple ways to work with the myriad of PHP functions that
| require information to be in seconds. | require information to be in seconds.
*/ */
defined('SECOND') || define('SECOND', 1); defined('SECOND') || define('SECOND', 1);
defined('MINUTE') || define('MINUTE', 60); defined('MINUTE') || define('MINUTE', 60);
defined('HOUR') || define('HOUR', 3600); defined('HOUR') || define('HOUR', 3600);
defined('DAY') || define('DAY', 86400); defined('DAY') || define('DAY', 86400);
defined('WEEK') || define('WEEK', 604800); defined('WEEK') || define('WEEK', 604800);
defined('MONTH') || define('MONTH', 2592000); defined('MONTH') || define('MONTH', 2_592_000);
defined('YEAR') || define('YEAR', 31536000); defined('YEAR') || define('YEAR', 31_536_000);
defined('DECADE') || define('DECADE', 315360000); defined('DECADE') || define('DECADE', 315_360_000);
/* /*
|-------------------------------------------------------------------------- | --------------------------------------------------------------------------
| Exit Status Codes | Exit Status Codes
|-------------------------------------------------------------------------- | --------------------------------------------------------------------------
| |
| Used to indicate the conditions under which the script is exit()ing. | Used to indicate the conditions under which the script is exit()ing.
| While there is no universal standard for error codes, there are some | While there is no universal standard for error codes, there are some
| broad conventions. Three such conventions are mentioned below, for | broad conventions. Three such conventions are mentioned below, for
| those who wish to make use of them. The CodeIgniter defaults were | those who wish to make use of them. The CodeIgniter defaults were
| chosen for the least overlap with these conventions, while still | chosen for the least overlap with these conventions, while still
| leaving room for others to be defined in future versions and user | leaving room for others to be defined in future versions and user
| applications. | applications.
| |
| The three main conventions used for determining exit status codes | The three main conventions used for determining exit status codes
| are as follows: | are as follows:
| |
| Standard C/C++ Library (stdlibc): | Standard C/C++ Library (stdlibc):
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html | http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
| (This link also contains other GNU-specific conventions) | (This link also contains other GNU-specific conventions)
| BSD sysexits.h: | BSD sysexits.h:
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits | http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
| Bash scripting: | Bash scripting:
| http://tldp.org/LDP/abs/html/exitcodes.html | http://tldp.org/LDP/abs/html/exitcodes.html
| |
*/ */
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
......
<?php <?php
declare(strict_types=1);
namespace Config; namespace Config;
use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\BaseConfig;
/** /**
* Class ContentSecurityPolicyConfig * Stores the default settings for the ContentSecurityPolicy, if you choose to use it. The values here will be read in
* * and set as defaults for the site. If needed, they can be overridden on a page-by-page basis.
* Stores the default settings for the ContentSecurityPolicy, if you
* choose to use it. The values here will be read in and set as defaults
* for the site. If needed, they can be overridden on a page-by-page basis.
* *
* Suggested reference for explanations: * Suggested reference for explanations:
* https://www.html5rocks.com/en/tutorials/security/content-security-policy/
* *
* @package Config * @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
*/ */
class ContentSecurityPolicy extends BaseConfig class ContentSecurityPolicy extends BaseConfig
{ {
// broadbrush CSP management /**
* Default CSP report context
public $reportOnly = false; // default CSP report context */
public $reportURI = null; // URL to send violation reports to public bool $reportOnly = false;
public $upgradeInsecureRequests = false; // toggle for forcing https
/**
// sources allowed; string or array of strings * Specifies a URL where a browser will send reports when a content security policy is violated.
// Note: once you set a policy to 'none', it cannot be further restricted */
public ?string $reportURI = null;
public $defaultSrc = null; // will default to self if not over-ridden
public $scriptSrc = 'self'; /**
public $styleSrc = 'self'; * Instructs user agents to rewrite URL schemes, changing HTTP to HTTPS. This directive is for websites with large
public $imageSrc = 'self'; * numbers of old URLs that need to be rewritten.
public $baseURI = null; // will default to self if not over-ridden */
public $childSrc = 'self'; public bool $upgradeInsecureRequests = false;
public $connectSrc = 'self';
public $fontSrc = null; /**
public $formAction = 'self'; * Will default to self if not overridden
public $frameAncestors = null; *
public $mediaSrc = null; * @var list<string>|string|null
public $objectSrc = 'self'; */
public $manifestSrc = null; public string | array | null $defaultSrc = null;
// mime types allowed; string or array of strings /**
public $pluginTypes = null; * Lists allowed scripts' URLs.
*
// list of actions allowed; string or array of strings * @var list<string>|string
public $sandbox = null; */
public string | array $scriptSrc = 'self';
/**
* Lists allowed stylesheets' URLs.
*
* @var list<string>|string
*/
public string | array $styleSrc = 'self';
/**
* Defines the origins from which images can be loaded.
*
* @var list<string>|string
*/
public string | array $imageSrc = 'self';
/**
* Restricts the URLs that can appear in a page's `<base>` element.
*
* Will default to self if not overridden
*
* @var list<string>|string|null
*/
public string | array | null $baseURI = null;
/**
* Lists the URLs for workers and embedded frame contents
*
* @var list<string>|string
*/
public string | array $childSrc = 'self';
/**
* Limits the origins that you can connect to (via XHR, WebSockets, and EventSource).
*
* @var list<string>|string
*/
public string | array $connectSrc = 'self';
/**
* Specifies the origins that can serve web fonts.
*
* @var list<string>|string
*/
public string | array $fontSrc;
/**
* Lists valid endpoints for submission from `<form>` tags.
*
* @var list<string>|string
*/
public string | array $formAction = 'self';
/**
* Specifies the sources that can embed the current page. This directive applies to `<frame>`, `<iframe>`,
* `<embed>`, and `<applet>` tags. This directive can't be used in `<meta>` tags and applies only to non-HTML
* resources.
*
* @var list<string>|string|null
*/
public string | array | null $frameAncestors = null;
/**
* The frame-src directive restricts the URLs which may be loaded into nested browsing contexts.
*
* @var list<string>|string|null
*/
public string | array | null $frameSrc = null;
/**
* Restricts the origins allowed to deliver video and audio.
*
* @var list<string>|string|null
*/
public string | array | null $mediaSrc = null;
/**
* Allows control over Flash and other plugins.
*
* @var list<string>|string
*/
public string | array $objectSrc = 'self';
/**
* @var list<string>|string|null
*/
public string | array | null $manifestSrc = null;
/**
* Limits the kinds of plugins a page may invoke.
*
* @var list<string>|string|null
*/
public string | array | null $pluginTypes = null;
/**
* List of actions allowed.
*
* @var list<string>|string|null
*/
public string | array | null $sandbox = null;
/**
* Nonce tag for style
*/
public string $styleNonceTag = '{csp-style-nonce}';
/**
* Nonce tag for script
*/
public string $scriptNonceTag = '{csp-script-nonce}';
/**
* Replace nonce tag automatically
*/
public bool $autoNonce = true;
} }
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;
use DateTimeInterface;
class Cookie extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Cookie Prefix
* --------------------------------------------------------------------------
*
* Set a cookie name prefix if you need to avoid collisions.
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Cookie Expires Timestamp
* --------------------------------------------------------------------------
*
* Default expires timestamp for cookies. Setting this to `0` will mean the
* cookie will not have the `Expires` attribute and will behave as a session
* cookie.
*/
public DateTimeInterface | int | string $expires = 0;
/**
* --------------------------------------------------------------------------
* Cookie Path
* --------------------------------------------------------------------------
*
* Typically will be a forward slash.
*/
public string $path = '/';
/**
* --------------------------------------------------------------------------
* Cookie Domain
* --------------------------------------------------------------------------
*
* Set to `.your-domain.com` for site-wide cookies.
*/
public string $domain = '';
/**
* --------------------------------------------------------------------------
* Cookie Secure
* --------------------------------------------------------------------------
*
* Cookie will only be set if a secure HTTPS connection exists.
*/
public bool $secure = false;
/**
* --------------------------------------------------------------------------
* Cookie HTTPOnly
* --------------------------------------------------------------------------
*
* Cookie will only be accessible via HTTP(S) (no JavaScript).
*/
public bool $httponly = true;
/**
* --------------------------------------------------------------------------
* Cookie SameSite
* --------------------------------------------------------------------------
*
* Configure cookie SameSite setting. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Alternatively, you can use the constant names:
* - `Cookie::SAMESITE_NONE`
* - `Cookie::SAMESITE_LAX`
* - `Cookie::SAMESITE_STRICT`
*
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$secure` must also be set.
*
* @phpstan-var 'None'|'Lax'|'Strict'|''
*/
public string $samesite = 'Lax';
/**
* --------------------------------------------------------------------------
* Cookie Raw
* --------------------------------------------------------------------------
*
* This flag allows setting a "raw" cookie, i.e., its name and value are
* not URL encoded using `rawurlencode()`.
*
* If this is set to `true`, cookie names should be compliant of RFC 2616's
* list of allowed characters.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
* @see https://tools.ietf.org/html/rfc2616#section-2.2
*/
public bool $raw = false;
}
<?php
declare(strict_types=1);
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Cross-Origin Resource Sharing (CORS) Configuration
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
*/
class Cors extends BaseConfig
{
/**
* The default CORS configuration.
*
* @var array{
* allowedOrigins: list<string>,
* allowedOriginsPatterns: list<string>,
* supportsCredentials: bool,
* allowedHeaders: list<string>,
* exposedHeaders: list<string>,
* allowedMethods: list<string>,
* maxAge: int,
* }
*/
public array $default = [
/**
* Origins for the `Access-Control-Allow-Origin` header.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
*
* E.g.:
* - ['http://localhost:8080']
* - ['https://www.example.com']
*/
'allowedOrigins' => [],
/**
* Origin regex patterns for the `Access-Control-Allow-Origin` header.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
*
* NOTE: A pattern specified here is part of a regular expression. It will
* be actually `#\A<pattern>\z#`.
*
* E.g.:
* - ['https://\w+\.example\.com']
*/
'allowedOriginsPatterns' => [],
/**
* Weather to send the `Access-Control-Allow-Credentials` header.
*
* The Access-Control-Allow-Credentials response header tells browsers whether
* the server allows cross-origin HTTP requests to include credentials.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
*/
'supportsCredentials' => false,
/**
* Set headers to allow.
*
* The Access-Control-Allow-Headers response header is used in response to
* a preflight request which includes the Access-Control-Request-Headers to
* indicate which HTTP headers can be used during the actual request.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
*/
'allowedHeaders' => [],
/**
* Set headers to expose.
*
* The Access-Control-Expose-Headers response header allows a server to
* indicate which response headers should be made available to scripts running
* in the browser, in response to a cross-origin request.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
*/
'exposedHeaders' => [],
/**
* Set methods to allow.
*
* The Access-Control-Allow-Methods response header specifies one or more
* methods allowed when accessing a resource in response to a preflight
* request.
*
* E.g.:
* - ['GET', 'POST', 'PUT', 'DELETE']
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
*/
'allowedMethods' => [],
/**
* Set how many seconds the results of a preflight request can be cached.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
*/
'maxAge' => 7200,
];
}
<?php <?php
declare(strict_types=1);
namespace Config; namespace Config;
use CodeIgniter\Database\Config;
/** /**
* Database Configuration * Database Configuration
*
* @package Config
*/ */
class Database extends Config
class Database extends \CodeIgniter\Database\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/'; 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 * @var array<string, mixed>
*/ */
public $default = [ public array $default = [
'DSN' => '', 'DSN' => '',
'hostname' => 'localhost', 'hostname' => 'localhost',
'username' => '', 'username' => '',
'password' => '', 'password' => '',
'database' => '', 'database' => '',
'DBDriver' => 'MySQLi', 'DBDriver' => 'MySQLi',
'DBPrefix' => 'cp_', 'DBPrefix' => 'cp_',
'pConnect' => false, 'pConnect' => false,
'DBDebug' => ENVIRONMENT !== 'production', 'DBDebug' => true,
'cacheOn' => false, 'charset' => 'utf8mb4',
'cacheDir' => '', 'DBCollat' => 'utf8mb4_unicode_ci',
'charset' => 'utf8', 'swapPre' => '',
'DBCollat' => 'utf8_general_ci', 'encrypt' => false,
'swapPre' => '', 'compress' => false,
'encrypt' => false, 'strictOn' => false,
'compress' => false, 'failover' => [],
'strictOn' => false, 'port' => 3306,
'failover' => [], 'numberNative' => false,
'port' => 3306, 'foundRows' => false,
'dateFormat' => [
'date' => 'Y-m-d',
'datetime' => 'Y-m-d H:i:s',
'time' => 'H:i:s',
],
]; ];
/** /**
* This database connection is used when * This database connection is used when running PHPUnit database tests.
* running PHPUnit database tests.
* *
* @var array * @var array<string, mixed>
*/ */
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_',
'pConnect' => false, // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'DBDebug' => ENVIRONMENT !== 'production', 'pConnect' => false,
'cacheOn' => false, 'DBDebug' => true,
'cacheDir' => '', 'charset' => 'utf8',
'charset' => 'utf8', 'DBCollat' => '',
'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,
'dateFormat' => [
'date' => 'Y-m-d',
'datetime' => 'Y-m-d H:i:s',
'time' => 'H:i:s',
],
]; ];
//-------------------------------------------------------------------- //--------------------------------------------------------------------
...@@ -92,21 +97,6 @@ class Database extends \CodeIgniter\Database\Config ...@@ -92,21 +97,6 @@ class Database extends \CodeIgniter\Database\Config
// we don't overwrite live data on accident. // we don't overwrite live data on accident.
if (ENVIRONMENT === 'testing') { if (ENVIRONMENT === 'testing') {
$this->defaultGroup = 'tests'; $this->defaultGroup = 'tests';
// Under Travis-CI, we can set an ENV var named 'DB_GROUP'
// so that we can test against multiple databases.
if ($group = getenv('DB')) {
if (is_file(TESTPATH . 'travis/Database.php')) {
require TESTPATH . 'travis/Database.php';
if (
!empty($dbconfig) &&
array_key_exists($group, $dbconfig)
) {
$this->tests = $dbconfig[$group];
}
}
}
} }
} }
......