daemon-idc init...
This commit is contained in:
parent
85fd2b5895
commit
cbc5b5e73c
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#codeigniter4
|
||||
.env
|
||||
composer.lock
|
||||
vendor/
|
||||
public/vendor/
|
||||
writable/caceh/*
|
||||
!writable/caceh/index.html
|
||||
writable/logs/*
|
||||
!writable/logs/index.html
|
||||
writable/session/*
|
||||
!writable/session/index.html
|
||||
writable/uploads/*
|
||||
!writable/uploads/index.html
|
||||
writable/debugbar/*
|
||||
!writable/debugbar/index.html
|
||||
writable/download/*
|
||||
!writable/download/index.html
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"php.version": "8.3"
|
||||
}
|
||||
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2019 British Columbia Institute of Technology
|
||||
Copyright (c) 2019-present CodeIgniter Foundation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
68
README.md
68
README.md
@ -1,2 +1,68 @@
|
||||
# daemon-idc
|
||||
# CodeIgniter 4 Application Starter
|
||||
|
||||
## What is CodeIgniter?
|
||||
|
||||
CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure.
|
||||
More information can be found at the [official site](https://codeigniter.com).
|
||||
|
||||
This repository holds a composer-installable app starter.
|
||||
It has been built from the
|
||||
[development repository](https://github.com/codeigniter4/CodeIgniter4).
|
||||
|
||||
More information about the plans for version 4 can be found in [CodeIgniter 4](https://forum.codeigniter.com/forumdisplay.php?fid=28) on the forums.
|
||||
|
||||
You can read the [user guide](https://codeigniter.com/user_guide/)
|
||||
corresponding to the latest version of the framework.
|
||||
|
||||
## Installation & updates
|
||||
|
||||
`composer create-project codeigniter4/appstarter` then `composer update` whenever
|
||||
there is a new release of the framework.
|
||||
|
||||
When updating, check the release notes to see if there are any changes you might need to apply
|
||||
to your `app` folder. The affected files can be copied or merged from
|
||||
`vendor/codeigniter4/framework/app`.
|
||||
|
||||
## Setup
|
||||
|
||||
Copy `env` to `.env` and tailor for your app, specifically the baseURL
|
||||
and any database settings.
|
||||
|
||||
## Important Change with index.php
|
||||
|
||||
`index.php` is no longer in the root of the project! It has been moved inside the *public* folder,
|
||||
for better security and separation of components.
|
||||
|
||||
This means that you should configure your web server to "point" to your project's *public* folder, and
|
||||
not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the
|
||||
framework are exposed.
|
||||
|
||||
**Please** read the user guide for a better explanation of how CI4 works!
|
||||
|
||||
## Repository Management
|
||||
|
||||
We use GitHub issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
|
||||
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
|
||||
FEATURE REQUESTS.
|
||||
|
||||
This repository is a "distribution" one, built by our release preparation script.
|
||||
Problems with it can be raised on our forum, or as issues in the main repository.
|
||||
|
||||
## Server Requirements
|
||||
|
||||
PHP version 8.1 or higher is required, with the following extensions installed:
|
||||
|
||||
- [intl](http://php.net/manual/en/intl.requirements.php)
|
||||
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
|
||||
|
||||
> [!WARNING]
|
||||
> - The end of life date for PHP 7.4 was November 28, 2022.
|
||||
> - The end of life date for PHP 8.0 was November 26, 2023.
|
||||
> - If you are still using PHP 7.4 or 8.0, you should upgrade immediately.
|
||||
> - The end of life date for PHP 8.1 will be December 31, 2025.
|
||||
|
||||
Additionally, make sure that the following extensions are enabled in your PHP:
|
||||
|
||||
- json (enabled by default - don't turn it off)
|
||||
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL
|
||||
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library
|
||||
|
||||
6
app/.htaccess
Normal file
6
app/.htaccess
Normal file
@ -0,0 +1,6 @@
|
||||
<IfModule authz_core_module>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !authz_core_module>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
15
app/Common.php
Normal file
15
app/Common.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The goal of this file is to allow developers a location
|
||||
* 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
|
||||
* execution.
|
||||
*
|
||||
* This can be looked at as a `master helper` file that is
|
||||
* loaded early on, and may also contain additional functions
|
||||
* that you'd like to use throughout your entire application
|
||||
*
|
||||
* @see: https://codeigniter.com/user_guide/extending/common.html
|
||||
*/
|
||||
202
app/Config/App.php
Normal file
202
app/Config/App.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class App extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Base Site URL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* URL to your CodeIgniter root. Typically, this will be your base URL,
|
||||
* WITH a trailing slash:
|
||||
*
|
||||
* E.g., http://example.com/
|
||||
*/
|
||||
public string $baseURL = 'http://localhost:8080/';
|
||||
|
||||
/**
|
||||
* 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
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Typically, this will be your `index.php` file, unless you've renamed it to
|
||||
* something else. If you have configured your web server to remove this file
|
||||
* from your site URIs, set this variable to an empty string.
|
||||
*/
|
||||
public string $indexPage = 'index.php';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* URI PROTOCOL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This item determines which server global should be used to retrieve the
|
||||
* URI string. The default setting of 'REQUEST_URI' works for most servers.
|
||||
* If your links do not seem to work, try one of the other delicious flavors:
|
||||
*
|
||||
* 'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
|
||||
* '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 string $uriProtocol = 'REQUEST_URI';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Allowed URL Characters
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This lets you specify which characters are permitted within your URLs.
|
||||
| When someone tries to submit a URL with disallowed characters they will
|
||||
| get a warning message.
|
||||
|
|
||||
| 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 string $permittedURIChars = 'a-z 0-9~%.:_\-';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Default Locale
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The Locale roughly represents the language and location that your visitor
|
||||
* is viewing the site from. It affects the language strings and other
|
||||
* strings (like currency markers, numbers, etc), that your program
|
||||
* should run under for this request.
|
||||
*/
|
||||
public string $defaultLocale = 'en';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Negotiate Locale
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, the current Request object will automatically determine the
|
||||
* language to use based on the value of the Accept-Language header.
|
||||
*
|
||||
* If false, no automatic detection will be performed.
|
||||
*/
|
||||
public bool $negotiateLocale = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Supported Locales
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If $negotiateLocale is true, this array lists the locales supported
|
||||
* by the application in descending order of priority. If no match is
|
||||
* found, the first locale will be used.
|
||||
*
|
||||
* IncomingRequest::setLocale() also uses this list.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $supportedLocales = ['en'];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Application Timezone
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default timezone that will be used in your application to display
|
||||
* dates with the date helper, and can be retrieved through app_timezone()
|
||||
*
|
||||
* @see https://www.php.net/manual/en/timezones.php for list of timezones
|
||||
* supported by PHP.
|
||||
*/
|
||||
public string $appTimezone = 'UTC';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Default Character Set
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This determines which character set is used by default in various methods
|
||||
* that require a character set to be provided.
|
||||
*
|
||||
* @see http://php.net/htmlspecialchars for a list of supported charsets.
|
||||
*/
|
||||
public string $charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Force Global Secure Requests
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, this will force every request made to this application to be
|
||||
* made via a secure connection (HTTPS). If the incoming request is not
|
||||
* secure, the user will be redirected to a secure version of the page
|
||||
* and the HTTP Strict Transport Security (HSTS) header will be set.
|
||||
*/
|
||||
public bool $forceGlobalSecureRequests = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Reverse Proxy IPs
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If your server is behind a reverse proxy, you must whitelist the proxy
|
||||
* IP addresses from which CodeIgniter should trust headers such as
|
||||
* X-Forwarded-For or Client-IP in order to properly identify
|
||||
* the visitor's IP address.
|
||||
*
|
||||
* You need to set a proxy IP address or IP address with subnets and
|
||||
* the HTTP header for the client IP address.
|
||||
*
|
||||
* Here are some examples:
|
||||
* [
|
||||
* '10.0.1.200' => 'X-Forwarded-For',
|
||||
* '192.168.5.0/24' => 'X-Real-IP',
|
||||
* ]
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $proxyIPs = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Content Security Policy
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* 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,
|
||||
* 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:
|
||||
*
|
||||
* @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||
* @see http://www.w3.org/TR/CSP/
|
||||
*/
|
||||
public bool $CSPEnabled = false;
|
||||
}
|
||||
92
app/Config/Autoload.php
Normal file
92
app/Config/Autoload.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\AutoloadConfig;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* AUTOLOADER CONFIGURATION
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* This file defines the namespaces and class maps so the Autoloader
|
||||
* 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.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*/
|
||||
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 = [
|
||||
APP_NAMESPACE => APPPATH,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* 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:
|
||||
* $classmap = [
|
||||
* 'MyClass' => '/path/to/class/file.php'
|
||||
* ];
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $classmap = [];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* 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',
|
||||
* ];
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $files = [];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Helpers
|
||||
* -------------------------------------------------------------------
|
||||
* Prototype:
|
||||
* $helpers = [
|
||||
* 'form',
|
||||
* ];
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $helpers = [];
|
||||
}
|
||||
34
app/Config/Boot/development.php
Normal file
34
app/Config/Boot/development.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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.
|
||||
|
|
||||
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG BACKTRACES
|
||||
|--------------------------------------------------------------------------
|
||||
| If true, this constant will tell the error screens to display debug
|
||||
| backtraces along with the other error information. If you would
|
||||
| prefer to not see this, set this value to false.
|
||||
*/
|
||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. This will control whether Kint is loaded, and a few other
|
||||
| items. It can always be used within your own application too.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||
25
app/Config/Boot/production.php
Normal file
25
app/Config/Boot/production.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| 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');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. It's not widely used currently, and may not survive
|
||||
| release of the framework.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
||||
38
app/Config/Boot/testing.php
Normal file
38
app/Config/Boot/testing.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The environment testing is reserved for PHPUnit testing. It has special
|
||||
* conditions built into the framework at various places to assist with that.
|
||||
* You can’t use it for your development.
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG BACKTRACES
|
||||
|--------------------------------------------------------------------------
|
||||
| If true, this constant will tell the error screens to display debug
|
||||
| backtraces along with the other error information. If you would
|
||||
| prefer to not see this, set this value to false.
|
||||
*/
|
||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. It's not widely used currently, and may not survive
|
||||
| release of the framework.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||
20
app/Config/CURLRequest.php
Normal file
20
app/Config/CURLRequest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
}
|
||||
162
app/Config/Cache.php
Normal file
162
app/Config/Cache.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
class Cache extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Primary Handler
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
public string $handler = 'file';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Backup Handler
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* 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
|
||||
* always available, though that's not always practical for the app.
|
||||
*/
|
||||
public string $backupHandler = 'dummy';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Key Prefix
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This string is added to all cache item names to help avoid collisions
|
||||
* if you run multiple applications with the same cache engine.
|
||||
*/
|
||||
public string $prefix = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Default TTL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default number of seconds to save items when none is specified.
|
||||
*
|
||||
* WARNING: This is not used by framework handlers where 60 seconds is
|
||||
* hard-coded, but may be useful to projects and modules. This will replace
|
||||
* the hard-coded value in a future release.
|
||||
*/
|
||||
public int $ttl = 60;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Reserved Characters
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* 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 = '{}()/\@:';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* File settings
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Your file storage preferences can be specified below, if you are using
|
||||
* the File driver.
|
||||
*
|
||||
* @var array{storePath?: string, mode?: int}
|
||||
*/
|
||||
public array $file = [
|
||||
'storePath' => WRITEPATH . 'cache/',
|
||||
'mode' => 0640,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Memcached settings
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Your Memcached servers can be specified below, if you are using
|
||||
* the Memcached drivers.
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
||||
*
|
||||
* @var array{host?: string, port?: int, weight?: int, raw?: bool}
|
||||
*/
|
||||
public array $memcached = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'weight' => 1,
|
||||
'raw' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Redis settings
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Your Redis server can be specified below, if you are using
|
||||
* the Redis or Predis drivers.
|
||||
*
|
||||
* @var array{host?: string, password?: string|null, port?: int, timeout?: int, database?: int}
|
||||
*/
|
||||
public array $redis = [
|
||||
'host' => '127.0.0.1',
|
||||
'password' => null,
|
||||
'port' => 6379,
|
||||
'timeout' => 0,
|
||||
'database' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Available Cache Handlers
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is an array of cache engine alias' and class names. Only engines
|
||||
* that are listed here are allowed to be used.
|
||||
*
|
||||
* @var array<string, class-string<CacheInterface>>
|
||||
*/
|
||||
public array $validHandlers = [
|
||||
'dummy' => DummyHandler::class,
|
||||
'file' => FileHandler::class,
|
||||
'memcached' => MemcachedHandler::class,
|
||||
'predis' => PredisHandler::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;
|
||||
}
|
||||
290
app/Config/Constants.php
Normal file
290
app/Config/Constants.php
Normal file
@ -0,0 +1,290 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------
|
||||
| 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');
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------------
|
||||
| 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') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Timing Constants
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Provide simple ways to work with the myriad of PHP functions that
|
||||
| require information to be in seconds.
|
||||
*/
|
||||
defined('SECOND') || define('SECOND', 1);
|
||||
defined('MINUTE') || define('MINUTE', 60);
|
||||
defined('HOUR') || define('HOUR', 3600);
|
||||
defined('DAY') || define('DAY', 86400);
|
||||
defined('WEEK') || define('WEEK', 604800);
|
||||
defined('MONTH') || define('MONTH', 2_592_000);
|
||||
defined('YEAR') || define('YEAR', 31_536_000);
|
||||
defined('DECADE') || define('DECADE', 315_360_000);
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------------
|
||||
| Exit Status Codes
|
||||
| --------------------------------------------------------------------------
|
||||
|
|
||||
| Used to indicate the conditions under which the script is exit()ing.
|
||||
| While there is no universal standard for error codes, there are some
|
||||
| broad conventions. Three such conventions are mentioned below, for
|
||||
| those who wish to make use of them. The CodeIgniter defaults were
|
||||
| chosen for the least overlap with these conventions, while still
|
||||
| leaving room for others to be defined in future versions and user
|
||||
| applications.
|
||||
|
|
||||
| The three main conventions used for determining exit status codes
|
||||
| are as follows:
|
||||
|
|
||||
| Standard C/C++ Library (stdlibc):
|
||||
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
|
||||
| (This link also contains other GNU-specific conventions)
|
||||
| BSD sysexits.h:
|
||||
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
|
||||
| Bash scripting:
|
||||
| http://tldp.org/LDP/abs/html/exitcodes.html
|
||||
|
|
||||
*/
|
||||
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
|
||||
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
|
||||
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
|
||||
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
|
||||
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
|
||||
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
|
||||
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
|
||||
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
|
||||
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
|
||||
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
|
||||
|
||||
define('MESSAGES', [
|
||||
'CREATED' => '생성되었습니다.',
|
||||
'UPDATED' => '수정되였습니다.',
|
||||
'DELETED' => '삭제되였습니다.',
|
||||
'SUCCESS' => '작업이 성공적으로 완료되었습니다.',
|
||||
'FAILED' => '작업이 실패하였습니다.',
|
||||
'NOT_FOUND' => '데이터가 존재하지 않습니다.',
|
||||
'NOT_AUTH' => '권한이 없습니다.',
|
||||
'NOT_LOGIN' => '로그인이 필요합니다.',
|
||||
'NOT_MATCH' => '데이터가 일치하지 않습니다.',
|
||||
'NOT_EMPTY' => '데이터가 비어있습니다.',
|
||||
'NOT_UNIQUE' => '중복된 데이터가 존재합니다.',
|
||||
'NOT_DELETE' => '삭제할 수 없는 데이터가 존재합니다.',
|
||||
'NOT_UPDATE' => '수정할 수 없는 데이터가 존재합니다.',
|
||||
'NOT_CREATE' => '생성할 수 없는 데이터가 존재합니다.',
|
||||
'NOT_SYNC' => '동기화할 수 없는 데이터가 존재합니다.',
|
||||
'NOT_SYNC_RESULT' => '동기화 결과가 실패하였습니다.',
|
||||
'NOT_SYNC_SUCCESS' => '동기화 결과가 성공하였습니다.',
|
||||
'NOT_SYNC_ERROR' => '동기화 결과가 실패하였습니다.',
|
||||
'NOT_SYNC_NOTHING' => '동기화할 데이터가 없습니다.',
|
||||
'NOT_SYNC_NOTHING_RESULT' => '동기화 결과가 없습니다.',
|
||||
'NOT_SYNC_NOTHING_ERROR' => '동기화 결과가 없습니다.',
|
||||
'LOGIN' => '로그인 하셨습니다.',
|
||||
'LOGOUT' => '로그아웃 하셨습니다.'
|
||||
]);
|
||||
//URL
|
||||
define('URLS', [
|
||||
'LOGIN' => '/auth/login',
|
||||
'GOOGLE_LOGIN' => '/auth/google_login',
|
||||
'SIGNUP' => '/auth/signup',
|
||||
'LOGOUT' => '/auth/logout',
|
||||
]);
|
||||
//SESSION 관련
|
||||
define('SESSION_NAMES', [
|
||||
'RETURN_URL' => "return_url",
|
||||
'RETURN_MSG' => "return_message",
|
||||
'ISLOGIN' => "islogined",
|
||||
'AUTH' => 'auth',
|
||||
]);
|
||||
//메신저 관련
|
||||
define("MESSENGERS", [
|
||||
"skype" => [
|
||||
"url" => "//join.skype.com/invite/uKUgXfZThSQC",
|
||||
"icon" => 'SKYPE',
|
||||
"id" => '',
|
||||
],
|
||||
"discord" => [
|
||||
"url" => "//discord.gg/k6nQg84N",
|
||||
"icon" => 'DISCORD',
|
||||
"id" => '',
|
||||
],
|
||||
"telegram" => [
|
||||
"url" => "//t.me/daemonidc",
|
||||
"icon" => 'TELEGRAM',
|
||||
"id" => '@daemonidc',
|
||||
],
|
||||
"kakaotalk" => [
|
||||
"url" => "//t.me/daemonidc",
|
||||
"icon" => 'KAKAO',
|
||||
"id" => '',
|
||||
],
|
||||
]);
|
||||
//아이콘 및 Sound관련
|
||||
define('ICONS', [
|
||||
'ADD' => '➕',
|
||||
'LOGO' => '🖼️',
|
||||
'EXCEL' => '📊',
|
||||
'PDF' => '📄',
|
||||
'GOOGLE' => '🌐',
|
||||
'MEMBER' => '👤',
|
||||
'CLIENT' => '🤵',
|
||||
'LOGIN' => '🔑',
|
||||
'LOGOUT' => '🚪',
|
||||
'HOME' => '🏠',
|
||||
'MENU' => '☰',
|
||||
'NEW' => '🆕',
|
||||
'REPLY' => '↩️',
|
||||
'DATABASE' => '🗄️',
|
||||
'DISLIKE' => '👎',
|
||||
'LIKE' => '👍',
|
||||
'DOWNLOAD' => '⬇️',
|
||||
'UPLOAD' => '⬆️',
|
||||
'COPY' => '📋',
|
||||
'PASTE' => '📌',
|
||||
'EDIT' => '✏️',
|
||||
'VIEW' => '👁️',
|
||||
'VIEW_OFF' => '🙈',
|
||||
'PRINT' => '🖨️',
|
||||
'SAVE' => '✔️',
|
||||
'CANCEL' => '❌',
|
||||
'CLOSE' => '✖️',
|
||||
'CHART' => '📈',
|
||||
'CHECK' => '✔️',
|
||||
'CHECK_OFF' => '⬜',
|
||||
'CHECK_ON' => '☑️',
|
||||
'CHECK_ALL' => '📑',
|
||||
'CHECK_NONE' => '🚫',
|
||||
'CHECK_SOME' => '➖',
|
||||
'COUPON' => '🎟️',
|
||||
'HISTORY' => '🕘',
|
||||
'MODIFY' => '🔧',
|
||||
'MODIFY_ALL' => '🛠️',
|
||||
'BATCHJOB' => '⚙️',
|
||||
'DELETE' => '🗑️',
|
||||
'REBOOT' => '🔄',
|
||||
'RELOAD' => '🔁',
|
||||
'SETUP' => '⚙️',
|
||||
'FOLDER' => '📁',
|
||||
'FLAG' => '🚩',
|
||||
'SEARCH' => '🔍',
|
||||
'PLAY' => '▶️',
|
||||
'CART' => '🛒',
|
||||
'CARD' => '💳',
|
||||
'DEPOSIT' => '💰',
|
||||
'DESKTOP' => '🖥️',
|
||||
'DEVICE' => '📟',
|
||||
'UP' => '⬆️',
|
||||
'DOWN' => '⬇️',
|
||||
'LEFT' => '⬅️',
|
||||
'RIGHT' => '➡️',
|
||||
'IMAGE_FILE' => '🖼️',
|
||||
'CLOUD' => '☁️',
|
||||
'SIGNPOST' => '📌',
|
||||
'LOCK' => '🔒',
|
||||
'UNLOCK' => '🔓',
|
||||
'BOX' => '📦',
|
||||
'BOXS' => '📦📦',
|
||||
'ONETIME' => '1️⃣',
|
||||
'MONTH' => '📅',
|
||||
'EMAIL' => '✉️',
|
||||
'MAIL' => '📧',
|
||||
'PHONE' => '📞',
|
||||
'POINT' => '⭐',
|
||||
'ALRAM' => '🔔',
|
||||
'PAYMENT' => '💸',
|
||||
'LINK' => '🔗',
|
||||
'SALE_UP' => '📈',
|
||||
'SALE_DOWN' => '📉',
|
||||
'SERVICE' => '🛎️',
|
||||
'CONSOLE' => '>_',
|
||||
'SERVICE_ITEM' => '📦',
|
||||
'SERVICE_ITEM_LINE' => '🌐',
|
||||
'SERVICE_ITEM_IP' => '📍',
|
||||
'SERVICE_ITEM_SERVER' => '🖥️',
|
||||
'SERVICE_ITEM_CPU' => '⚙️',
|
||||
'SERVICE_ITEM_RAM' => '🧠',
|
||||
'SERVICE_ITEM_STORAGE' => '💾',
|
||||
'SERVICE_ITEM_SOFTWARE' => '💿',
|
||||
'SERVICE_ITEM_DOMAIN' => '🔗',
|
||||
'SERVICE_ITEM_OTHER' => '📎',
|
||||
'SERVER_ITEM_CPU' => '🔳',
|
||||
'SERVER_ITEM_RAM' => '📼',
|
||||
'SERVER_ITEM_DISK' => '🗄️',
|
||||
'SERVER_ITEM_SWITCH' => '🖧',
|
||||
'SERVER_ITEM_OS' => '🐧',
|
||||
'SERVER_ITEM_DB' => '📊',
|
||||
'SERVER_ITEM_DEFENCE' => '🛡️',
|
||||
'SERVER_ITEM_CS' => '🛡️',
|
||||
'SERVER_ITEM_SOFTWARE' => '💻',
|
||||
'SERVER_ITEM_IP' => '🌍',
|
||||
'SERVER_ITEM_ETC' => '➕',
|
||||
]);
|
||||
|
||||
//STATUS
|
||||
define("STATUS", [
|
||||
'AVAILABLE' => "available",
|
||||
'FORBIDDEN' => "forbidden",
|
||||
'OCCUPIED' => "occupied",
|
||||
'SUCCESS' => "success",
|
||||
'FAILED' => "fail",
|
||||
'PAUSE' => "pause",
|
||||
'TERMINATED' => "terminated",
|
||||
'WITHDRAWAL' => "withdrawal",
|
||||
'DEPOSIT' => "deposit",
|
||||
'PAID' => 'paid',
|
||||
'UNPAID' => 'unpaid',
|
||||
]);
|
||||
|
||||
//ROLE
|
||||
define("ROLE", [
|
||||
'USER' => [
|
||||
'MANAGER' => "manager",
|
||||
'CLOUDFLARE' => "cloudflare",
|
||||
'FIREWALL' => "firewall",
|
||||
'SECURITY' => "security",
|
||||
'DIRECTOR' => "director",
|
||||
'MASTER' => "master",
|
||||
],
|
||||
'CLIENT' => [
|
||||
'USER' => 'user',
|
||||
'VIP' => 'vip',
|
||||
'RESELLER' => 'reseller',
|
||||
],
|
||||
]);
|
||||
|
||||
//Default값 정의
|
||||
define('DEFAULTS', [
|
||||
'DELIMITER_PIPE' => "||",
|
||||
'DELIMITER_COMMA' => ",",
|
||||
'INDEX_PERPAGE' => 20,
|
||||
'STATUS' => STATUS['AVAILABLE']
|
||||
]);
|
||||
|
||||
//게시판 관련
|
||||
define("BOARD", [
|
||||
'CATEGORY' => [
|
||||
'NOTICE' => 'notice',
|
||||
'REQUESTTASK' => 'requesttask'
|
||||
],
|
||||
]);
|
||||
176
app/Config/ContentSecurityPolicy.php
Normal file
176
app/Config/ContentSecurityPolicy.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* 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:
|
||||
*
|
||||
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||
*/
|
||||
class ContentSecurityPolicy extends BaseConfig
|
||||
{
|
||||
// -------------------------------------------------------------------------
|
||||
// Broadbrush CSP management
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Default CSP report context
|
||||
*/
|
||||
public bool $reportOnly = false;
|
||||
|
||||
/**
|
||||
* Specifies a URL where a browser will send reports
|
||||
* when a content security policy is violated.
|
||||
*/
|
||||
public ?string $reportURI = null;
|
||||
|
||||
/**
|
||||
* Instructs user agents to rewrite URL schemes, changing
|
||||
* HTTP to HTTPS. This directive is for websites with
|
||||
* large numbers of old URLs that need to be rewritten.
|
||||
*/
|
||||
public bool $upgradeInsecureRequests = false;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Sources allowed
|
||||
// NOTE: once you set a policy to 'none', it cannot be further restricted
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Will default to self if not overridden
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $defaultSrc;
|
||||
|
||||
/**
|
||||
* Lists allowed scripts' URLs.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $scriptSrc = 'self';
|
||||
|
||||
/**
|
||||
* Lists allowed stylesheets' URLs.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $styleSrc = 'self';
|
||||
|
||||
/**
|
||||
* Defines the origins from which images can be loaded.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $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 $baseURI;
|
||||
|
||||
/**
|
||||
* Lists the URLs for workers and embedded frame contents
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $childSrc = 'self';
|
||||
|
||||
/**
|
||||
* Limits the origins that you can connect to (via XHR,
|
||||
* WebSockets, and EventSource).
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $connectSrc = 'self';
|
||||
|
||||
/**
|
||||
* Specifies the origins that can serve web fonts.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $fontSrc;
|
||||
|
||||
/**
|
||||
* Lists valid endpoints for submission from `<form>` tags.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $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 $frameAncestors;
|
||||
|
||||
/**
|
||||
* The frame-src directive restricts the URLs which may
|
||||
* be loaded into nested browsing contexts.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $frameSrc;
|
||||
|
||||
/**
|
||||
* Restricts the origins allowed to deliver video and audio.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $mediaSrc;
|
||||
|
||||
/**
|
||||
* Allows control over Flash and other plugins.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $objectSrc = 'self';
|
||||
|
||||
/**
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $manifestSrc;
|
||||
|
||||
/**
|
||||
* Limits the kinds of plugins a page may invoke.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $pluginTypes;
|
||||
|
||||
/**
|
||||
* List of actions allowed.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $sandbox;
|
||||
|
||||
/**
|
||||
* Nonce tag for style
|
||||
*/
|
||||
public string $styleNonceTag = '{csp-style-nonce}';
|
||||
|
||||
/**
|
||||
* Nonce tag for script
|
||||
*/
|
||||
public string $scriptNonceTag = '{csp-script-nonce}';
|
||||
|
||||
/**
|
||||
* Replace nonce tag automatically
|
||||
*/
|
||||
public bool $autoNonce = true;
|
||||
}
|
||||
107
app/Config/Cookie.php
Normal file
107
app/Config/Cookie.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
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.
|
||||
*
|
||||
* @var DateTimeInterface|int|string
|
||||
*/
|
||||
public $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.
|
||||
*
|
||||
* @var ''|'Lax'|'None'|'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;
|
||||
}
|
||||
105
app/Config/Cors.php
Normal file
105
app/Config/Cors.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
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,
|
||||
];
|
||||
}
|
||||
204
app/Config/Database.php
Normal file
204
app/Config/Database.php
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Database\Config;
|
||||
|
||||
/**
|
||||
* Database Configuration
|
||||
*/
|
||||
class Database extends Config
|
||||
{
|
||||
/**
|
||||
* The directory that holds the Migrations and Seeds directories.
|
||||
*/
|
||||
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Lets you choose which connection group to use if no other is specified.
|
||||
*/
|
||||
public string $defaultGroup = 'default';
|
||||
|
||||
/**
|
||||
* The default database connection.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $default = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'numberNative' => false,
|
||||
'foundRows' => false,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for SQLite3.
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'database' => 'database.db',
|
||||
// 'DBDriver' => 'SQLite3',
|
||||
// 'DBPrefix' => '',
|
||||
// 'DBDebug' => true,
|
||||
// 'swapPre' => '',
|
||||
// 'failover' => [],
|
||||
// 'foreignKeys' => true,
|
||||
// 'busyTimeout' => 1000,
|
||||
// 'synchronous' => null,
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for Postgre.
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'DSN' => '',
|
||||
// 'hostname' => 'localhost',
|
||||
// 'username' => 'root',
|
||||
// 'password' => 'root',
|
||||
// 'database' => 'ci4',
|
||||
// 'schema' => 'public',
|
||||
// 'DBDriver' => 'Postgre',
|
||||
// 'DBPrefix' => '',
|
||||
// 'pConnect' => false,
|
||||
// 'DBDebug' => true,
|
||||
// 'charset' => 'utf8',
|
||||
// 'swapPre' => '',
|
||||
// 'failover' => [],
|
||||
// 'port' => 5432,
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for SQLSRV.
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'DSN' => '',
|
||||
// 'hostname' => 'localhost',
|
||||
// 'username' => 'root',
|
||||
// 'password' => 'root',
|
||||
// 'database' => 'ci4',
|
||||
// 'schema' => 'dbo',
|
||||
// 'DBDriver' => 'SQLSRV',
|
||||
// 'DBPrefix' => '',
|
||||
// 'pConnect' => false,
|
||||
// 'DBDebug' => true,
|
||||
// 'charset' => 'utf8',
|
||||
// 'swapPre' => '',
|
||||
// 'encrypt' => false,
|
||||
// 'failover' => [],
|
||||
// 'port' => 1433,
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// /**
|
||||
// * Sample database connection for OCI8.
|
||||
// *
|
||||
// * You may need the following environment variables:
|
||||
// * NLS_LANG = 'AMERICAN_AMERICA.UTF8'
|
||||
// * NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||
// * NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||
// * NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
|
||||
// *
|
||||
// * @var array<string, mixed>
|
||||
// */
|
||||
// public array $default = [
|
||||
// 'DSN' => 'localhost:1521/XEPDB1',
|
||||
// 'username' => 'root',
|
||||
// 'password' => 'root',
|
||||
// 'DBDriver' => 'OCI8',
|
||||
// 'DBPrefix' => '',
|
||||
// 'pConnect' => false,
|
||||
// 'DBDebug' => true,
|
||||
// 'charset' => 'AL32UTF8',
|
||||
// 'swapPre' => '',
|
||||
// 'failover' => [],
|
||||
// 'dateFormat' => [
|
||||
// 'date' => 'Y-m-d',
|
||||
// 'datetime' => 'Y-m-d H:i:s',
|
||||
// 'time' => 'H:i:s',
|
||||
// ],
|
||||
// ];
|
||||
|
||||
/**
|
||||
* This database connection is used when running PHPUnit database tests.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $tests = [
|
||||
'DSN' => '',
|
||||
'hostname' => '127.0.0.1',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => ':memory:',
|
||||
'DBDriver' => 'SQLite3',
|
||||
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8',
|
||||
'DBCollat' => '',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
'synchronous' => null,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Ensure that we always set the database group to 'tests' if
|
||||
// we are currently running an automated test suite, so that
|
||||
// we don't overwrite live data on accident.
|
||||
if (ENVIRONMENT === 'testing') {
|
||||
$this->defaultGroup = 'tests';
|
||||
}
|
||||
}
|
||||
}
|
||||
43
app/Config/DocTypes.php
Normal file
43
app/Config/DocTypes.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
class DocTypes
|
||||
{
|
||||
/**
|
||||
* List of valid document types.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $list = [
|
||||
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
|
||||
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
||||
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
||||
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
|
||||
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
|
||||
'html5' => '<!DOCTYPE html>',
|
||||
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
||||
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
||||
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
|
||||
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
|
||||
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
|
||||
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
|
||||
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
|
||||
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
|
||||
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
|
||||
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
|
||||
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
|
||||
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
|
||||
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">',
|
||||
];
|
||||
|
||||
/**
|
||||
* Whether to remove the solidus (`/`) character for void HTML elements (e.g. `<input>`)
|
||||
* for HTML5 compatibility.
|
||||
*
|
||||
* Set to:
|
||||
* `true` - to be HTML5 compatible
|
||||
* `false` - to be XHTML compatible
|
||||
*/
|
||||
public bool $html5 = true;
|
||||
}
|
||||
121
app/Config/Email.php
Normal file
121
app/Config/Email.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Email extends BaseConfig
|
||||
{
|
||||
public string $fromEmail = '';
|
||||
public string $fromName = '';
|
||||
public string $recipients = '';
|
||||
|
||||
/**
|
||||
* The "user agent"
|
||||
*/
|
||||
public string $userAgent = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The mail sending protocol: mail, sendmail, smtp
|
||||
*/
|
||||
public string $protocol = 'mail';
|
||||
|
||||
/**
|
||||
* The server path to Sendmail.
|
||||
*/
|
||||
public string $mailPath = '/usr/sbin/sendmail';
|
||||
|
||||
/**
|
||||
* SMTP Server Hostname
|
||||
*/
|
||||
public string $SMTPHost = '';
|
||||
|
||||
/**
|
||||
* SMTP Username
|
||||
*/
|
||||
public string $SMTPUser = '';
|
||||
|
||||
/**
|
||||
* SMTP Password
|
||||
*/
|
||||
public string $SMTPPass = '';
|
||||
|
||||
/**
|
||||
* SMTP Port
|
||||
*/
|
||||
public int $SMTPPort = 25;
|
||||
|
||||
/**
|
||||
* SMTP Timeout (in seconds)
|
||||
*/
|
||||
public int $SMTPTimeout = 5;
|
||||
|
||||
/**
|
||||
* Enable persistent SMTP connections
|
||||
*/
|
||||
public bool $SMTPKeepAlive = false;
|
||||
|
||||
/**
|
||||
* SMTP Encryption.
|
||||
*
|
||||
* @var string '', 'tls' or 'ssl'. 'tls' will issue a STARTTLS command
|
||||
* to the server. 'ssl' means implicit SSL. Connection on port
|
||||
* 465 should set this to ''.
|
||||
*/
|
||||
public string $SMTPCrypto = 'tls';
|
||||
|
||||
/**
|
||||
* Enable word-wrap
|
||||
*/
|
||||
public bool $wordWrap = true;
|
||||
|
||||
/**
|
||||
* Character count to wrap at
|
||||
*/
|
||||
public int $wrapChars = 76;
|
||||
|
||||
/**
|
||||
* Type of mail, either 'text' or 'html'
|
||||
*/
|
||||
public string $mailType = 'text';
|
||||
|
||||
/**
|
||||
* Character set (utf-8, iso-8859-1, etc.)
|
||||
*/
|
||||
public string $charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Whether to validate the email address
|
||||
*/
|
||||
public bool $validate = false;
|
||||
|
||||
/**
|
||||
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
|
||||
*/
|
||||
public int $priority = 3;
|
||||
|
||||
/**
|
||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||
*/
|
||||
public string $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||
*/
|
||||
public string $newline = "\r\n";
|
||||
|
||||
/**
|
||||
* Enable BCC Batch Mode.
|
||||
*/
|
||||
public bool $BCCBatchMode = false;
|
||||
|
||||
/**
|
||||
* Number of emails in each BCC batch
|
||||
*/
|
||||
public int $BCCBatchSize = 200;
|
||||
|
||||
/**
|
||||
* Enable notify message from server
|
||||
*/
|
||||
public bool $DSN = false;
|
||||
}
|
||||
92
app/Config/Encryption.php
Normal file
92
app/Config/Encryption.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Encryption configuration.
|
||||
*
|
||||
* These are the settings used for encryption, if you don't pass a parameter
|
||||
* array to the encrypter for creation/initialization.
|
||||
*/
|
||||
class Encryption extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption Key Starter
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If you use the Encryption class you must set an encryption key (seed).
|
||||
* You need to ensure it is long enough for the cipher and mode you plan to use.
|
||||
* See the user guide for more info.
|
||||
*/
|
||||
public string $key = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption Driver to Use
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* One of the supported encryption drivers.
|
||||
*
|
||||
* Available drivers:
|
||||
* - OpenSSL
|
||||
* - Sodium
|
||||
*/
|
||||
public string $driver = 'OpenSSL';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* SodiumHandler's Padding Length in Bytes
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the number of bytes that will be padded to the plaintext message
|
||||
* before it is encrypted. This value should be greater than zero.
|
||||
*
|
||||
* See the user guide for more information on padding.
|
||||
*/
|
||||
public int $blockSize = 16;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption digest
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
|
||||
*/
|
||||
public string $digest = 'SHA512';
|
||||
|
||||
/**
|
||||
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to false for CI3 Encryption compatibility.
|
||||
*/
|
||||
public bool $rawData = true;
|
||||
|
||||
/**
|
||||
* Encryption key info.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'encryption' for CI3 Encryption compatibility.
|
||||
*/
|
||||
public string $encryptKeyInfo = '';
|
||||
|
||||
/**
|
||||
* Authentication key info.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'authentication' for CI3 Encryption compatibility.
|
||||
*/
|
||||
public string $authKeyInfo = '';
|
||||
|
||||
/**
|
||||
* Cipher to use.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'AES-128-CBC' to decrypt encrypted data that encrypted
|
||||
* by CI3 Encryption default configuration.
|
||||
*/
|
||||
public string $cipher = 'AES-256-CTR';
|
||||
}
|
||||
55
app/Config/Events.php
Normal file
55
app/Config/Events.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Events\Events;
|
||||
use CodeIgniter\Exceptions\FrameworkException;
|
||||
use CodeIgniter\HotReloader\HotReloader;
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Application Events
|
||||
* --------------------------------------------------------------------
|
||||
* Events allow you to tap into the execution of the program without
|
||||
* modifying or extending core files. This file provides a central
|
||||
* location to define your events, though they can always be added
|
||||
* at run-time, also, if needed.
|
||||
*
|
||||
* You create code that can execute by subscribing to events with
|
||||
* the 'on()' method. This accepts any form of callable, including
|
||||
* Closures, that will be executed when the event is triggered.
|
||||
*
|
||||
* Example:
|
||||
* Events::on('create', [$myInstance, 'myMethod']);
|
||||
*/
|
||||
|
||||
Events::on('pre_system', static function (): void {
|
||||
if (ENVIRONMENT !== 'testing') {
|
||||
if (ini_get('zlib.output_compression')) {
|
||||
throw FrameworkException::forEnabledZlibOutputCompression();
|
||||
}
|
||||
|
||||
while (ob_get_level() > 0) {
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
ob_start(static fn ($buffer) => $buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Debug Toolbar Listeners.
|
||||
* --------------------------------------------------------------------
|
||||
* If you delete, they will no longer be collected.
|
||||
*/
|
||||
if (CI_DEBUG && ! is_cli()) {
|
||||
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
|
||||
service('toolbar')->respond();
|
||||
// Hot Reload route - for framework use on the hot reloader.
|
||||
if (ENVIRONMENT === 'development') {
|
||||
service('routes')->get('__hot-reload', static function (): void {
|
||||
(new HotReloader())->run();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
106
app/Config/Exceptions.php
Normal file
106
app/Config/Exceptions.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Debug\ExceptionHandler;
|
||||
use CodeIgniter\Debug\ExceptionHandlerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Setup how the exception handler works.
|
||||
*/
|
||||
class Exceptions extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG EXCEPTIONS?
|
||||
* --------------------------------------------------------------------------
|
||||
* If true, then exceptions will be logged
|
||||
* through Services::Log.
|
||||
*
|
||||
* Default: true
|
||||
*/
|
||||
public bool $log = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* DO NOT LOG STATUS CODES
|
||||
* --------------------------------------------------------------------------
|
||||
* Any status codes here will NOT be logged if logging is turned on.
|
||||
* By default, only 404 (Page Not Found) exceptions are ignored.
|
||||
*
|
||||
* @var list<int>
|
||||
*/
|
||||
public array $ignoreCodes = [404];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Error Views Path
|
||||
* --------------------------------------------------------------------------
|
||||
* This is the path to the directory that contains the 'cli' and 'html'
|
||||
* directories that hold the views used to generate errors.
|
||||
*
|
||||
* Default: APPPATH.'Views/errors'
|
||||
*/
|
||||
public string $errorViewPath = APPPATH . 'Views/errors';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* HIDE FROM DEBUG TRACE
|
||||
* --------------------------------------------------------------------------
|
||||
* Any data that you would like to hide from the debug trace.
|
||||
* In order to specify 2 levels, use "/" to separate.
|
||||
* ex. ['server', 'setup/password', 'secret_token']
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $sensitiveDataInTrace = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* WHETHER TO THROW AN EXCEPTION ON DEPRECATED ERRORS
|
||||
* --------------------------------------------------------------------------
|
||||
* If set to `true`, DEPRECATED errors are only logged and no exceptions are
|
||||
* thrown. 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);
|
||||
}
|
||||
}
|
||||
37
app/Config/Feature.php
Normal file
37
app/Config/Feature.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Enable/disable backward compatibility breaking features.
|
||||
*/
|
||||
class Feature extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Use improved new auto routing instead of the legacy version.
|
||||
*/
|
||||
public bool $autoRoutesImproved = true;
|
||||
|
||||
/**
|
||||
* Use filter execution order in 4.4 or before.
|
||||
*/
|
||||
public bool $oldFilterOrder = false;
|
||||
|
||||
/**
|
||||
* The behavior of `limit(0)` in Query Builder.
|
||||
*
|
||||
* If true, `limit(0)` returns all records. (the behavior of 4.4.x or before in version 4.x.)
|
||||
* If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.)
|
||||
*/
|
||||
public bool $limitZeroAsAll = true;
|
||||
|
||||
/**
|
||||
* Use strict location negotiation.
|
||||
*
|
||||
* By default, the locale is selected based on a loose comparison of the language code (ISO 639-1)
|
||||
* Enabling strict comparison will also consider the region code (ISO 3166-1 alpha-2).
|
||||
*/
|
||||
public bool $strictLocaleNegotiation = false;
|
||||
}
|
||||
111
app/Config/Filters.php
Normal file
111
app/Config/Filters.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Filters as BaseFilters;
|
||||
use CodeIgniter\Filters\Cors;
|
||||
use CodeIgniter\Filters\CSRF;
|
||||
use CodeIgniter\Filters\DebugToolbar;
|
||||
use CodeIgniter\Filters\ForceHTTPS;
|
||||
use CodeIgniter\Filters\Honeypot;
|
||||
use CodeIgniter\Filters\InvalidChars;
|
||||
use CodeIgniter\Filters\PageCache;
|
||||
use CodeIgniter\Filters\PerformanceMetrics;
|
||||
use CodeIgniter\Filters\SecureHeaders;
|
||||
use App\Filters\AuthFilter;
|
||||
class Filters extends BaseFilters
|
||||
{
|
||||
/**
|
||||
* Configures aliases for Filter classes to
|
||||
* make reading things nicer and simpler.
|
||||
*
|
||||
* @var array<string, class-string|list<class-string>>
|
||||
*
|
||||
* [filter_name => classname]
|
||||
* or [filter_name => [classname1, classname2, ...]]
|
||||
*/
|
||||
public array $aliases = [
|
||||
'csrf' => CSRF::class,
|
||||
'toolbar' => DebugToolbar::class,
|
||||
'honeypot' => Honeypot::class,
|
||||
'invalidchars' => InvalidChars::class,
|
||||
'secureheaders' => SecureHeaders::class,
|
||||
'cors' => Cors::class,
|
||||
'forcehttps' => ForceHTTPS::class,
|
||||
'pagecache' => PageCache::class,
|
||||
'performance' => PerformanceMetrics::class,
|
||||
'authFilter' => AuthFilter::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* List of special required filters.
|
||||
*
|
||||
* The filters listed here are special. They are applied before and after
|
||||
* other kinds of filters, and always applied even if a route does not exist.
|
||||
*
|
||||
* Filters set by default provide framework functionality. If removed,
|
||||
* those functions will no longer work.
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
|
||||
*
|
||||
* @var array{before: list<string>, after: list<string>}
|
||||
*/
|
||||
public array $required = [
|
||||
'before' => [
|
||||
'forcehttps', // Force Global Secure Requests
|
||||
'pagecache', // Web Page Caching
|
||||
],
|
||||
'after' => [
|
||||
'pagecache', // Web Page Caching
|
||||
'performance', // Performance Metrics
|
||||
'toolbar', // Debug Toolbar
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* List of filter aliases that are always
|
||||
* applied before and after every request.
|
||||
*
|
||||
* @var array{
|
||||
* before: array<string, array{except: list<string>|string}>|list<string>,
|
||||
* after: array<string, array{except: list<string>|string}>|list<string>
|
||||
* }
|
||||
*/
|
||||
public array $globals = [
|
||||
'before' => [
|
||||
// 'honeypot',
|
||||
// 'csrf',
|
||||
// 'invalidchars',
|
||||
],
|
||||
'after' => [
|
||||
// 'honeypot',
|
||||
// 'secureheaders',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* List of filter aliases that works on a
|
||||
* particular HTTP method (GET, POST, etc.).
|
||||
*
|
||||
* Example:
|
||||
* 'POST' => ['foo', 'bar']
|
||||
*
|
||||
* If you use this, you should disable auto-routing because auto-routing
|
||||
* permits any HTTP method to access a controller. Accessing the controller
|
||||
* with a method you don't expect could bypass the filter.
|
||||
*
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
public array $methods = [];
|
||||
|
||||
/**
|
||||
* List of filter aliases that should run on any
|
||||
* before or after URI patterns.
|
||||
*
|
||||
* Example:
|
||||
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
*/
|
||||
public array $filters = [];
|
||||
}
|
||||
12
app/Config/ForeignCharacters.php
Normal file
12
app/Config/ForeignCharacters.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
|
||||
|
||||
/**
|
||||
* @immutable
|
||||
*/
|
||||
class ForeignCharacters extends BaseForeignCharacters
|
||||
{
|
||||
}
|
||||
64
app/Config/Format.php
Normal file
64
app/Config/Format.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Format\JSONFormatter;
|
||||
use CodeIgniter\Format\XMLFormatter;
|
||||
|
||||
class Format extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Available Response Formats
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* When you perform content negotiation with the request, these are the
|
||||
* available formats that your application supports. This is currently
|
||||
* only used with the API\ResponseTrait. A valid Formatter must exist
|
||||
* for the specified format.
|
||||
*
|
||||
* These formats are only checked when the data passed to the respond()
|
||||
* method is an array.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $supportedResponseFormats = [
|
||||
'application/json',
|
||||
'application/xml', // machine-readable XML
|
||||
'text/xml', // human-readable XML
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Formatters
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Lists the class to use to format responses with of a particular type.
|
||||
* For each mime type, list the class that should be used. Formatters
|
||||
* can be retrieved through the getFormatter() method.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $formatters = [
|
||||
'application/json' => JSONFormatter::class,
|
||||
'application/xml' => XMLFormatter::class,
|
||||
'text/xml' => XMLFormatter::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Formatters Options
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Additional Options to adjust default formatters behaviour.
|
||||
* For each mime type, list the additional options that should be used.
|
||||
*
|
||||
* @var array<string, int>
|
||||
*/
|
||||
public array $formatterOptions = [
|
||||
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
|
||||
'application/xml' => 0,
|
||||
'text/xml' => 0,
|
||||
];
|
||||
}
|
||||
44
app/Config/Generators.php
Normal file
44
app/Config/Generators.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Generators extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Generator Commands' Views
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This array defines the mapping of generator commands to the view files
|
||||
* they are using. If you need to customize them for your own, copy these
|
||||
* view files in your own folder and indicate the location here.
|
||||
*
|
||||
* You will notice that the views have special placeholders enclosed in
|
||||
* curly braces `{...}`. These placeholders are used internally by the
|
||||
* generator commands in processing replacements, thus you are warned
|
||||
* not to delete them or modify the names. If you will do so, you may
|
||||
* end up disrupting the scaffolding process and throw errors.
|
||||
*
|
||||
* YOU HAVE BEEN WARNED!
|
||||
*
|
||||
* @var array<string, array<string, string>|string>
|
||||
*/
|
||||
public array $views = [
|
||||
'make:cell' => [
|
||||
'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
|
||||
'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
|
||||
],
|
||||
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
|
||||
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
|
||||
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
|
||||
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
|
||||
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
|
||||
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
|
||||
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
|
||||
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
|
||||
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||
];
|
||||
}
|
||||
42
app/Config/Honeypot.php
Normal file
42
app/Config/Honeypot.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Honeypot extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Makes Honeypot visible or not to human
|
||||
*/
|
||||
public bool $hidden = true;
|
||||
|
||||
/**
|
||||
* Honeypot Label Content
|
||||
*/
|
||||
public string $label = 'Fill This Field';
|
||||
|
||||
/**
|
||||
* Honeypot Field Name
|
||||
*/
|
||||
public string $name = 'honeypot';
|
||||
|
||||
/**
|
||||
* Honeypot HTML Template
|
||||
*/
|
||||
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
|
||||
|
||||
/**
|
||||
* Honeypot container
|
||||
*
|
||||
* If you enabled CSP, you can remove `style="display:none"`.
|
||||
*/
|
||||
public string $container = '<div style="display:none">{template}</div>';
|
||||
|
||||
/**
|
||||
* The id attribute for Honeypot container tag
|
||||
*
|
||||
* Used when CSP is enabled.
|
||||
*/
|
||||
public string $containerId = 'hpc';
|
||||
}
|
||||
31
app/Config/Images.php
Normal file
31
app/Config/Images.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Images\Handlers\GDHandler;
|
||||
use CodeIgniter\Images\Handlers\ImageMagickHandler;
|
||||
|
||||
class Images extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Default handler used if no other handler is specified.
|
||||
*/
|
||||
public string $defaultHandler = 'gd';
|
||||
|
||||
/**
|
||||
* The path to the image library.
|
||||
* Required for ImageMagick, GraphicsMagick, or NetPBM.
|
||||
*/
|
||||
public string $libraryPath = '/usr/local/bin/convert';
|
||||
|
||||
/**
|
||||
* The available handler classes.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $handlers = [
|
||||
'gd' => GDHandler::class,
|
||||
'imagick' => ImageMagickHandler::class,
|
||||
];
|
||||
}
|
||||
63
app/Config/Kint.php
Normal file
63
app/Config/Kint.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use Kint\Parser\ConstructablePluginInterface;
|
||||
use Kint\Renderer\Rich\TabPluginInterface;
|
||||
use Kint\Renderer\Rich\ValuePluginInterface;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Kint
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
|
||||
* that you can set to customize how Kint works for you.
|
||||
*
|
||||
* @see https://kint-php.github.io/kint/ for details on these settings.
|
||||
*/
|
||||
class Kint
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
|
||||
*/
|
||||
public $plugins;
|
||||
|
||||
public int $maxDepth = 6;
|
||||
public bool $displayCalledFrom = true;
|
||||
public bool $expanded = false;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RichRenderer Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public string $richTheme = 'aante-light.css';
|
||||
public bool $richFolder = false;
|
||||
|
||||
/**
|
||||
* @var array<string, class-string<ValuePluginInterface>>|null
|
||||
*/
|
||||
public $richObjectPlugins;
|
||||
|
||||
/**
|
||||
* @var array<string, class-string<TabPluginInterface>>|null
|
||||
*/
|
||||
public $richTabPlugins;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CLI Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public bool $cliColors = true;
|
||||
public bool $cliForceUTF8 = false;
|
||||
public bool $cliDetectWidth = true;
|
||||
public int $cliMinWidth = 40;
|
||||
}
|
||||
151
app/Config/Logger.php
Normal file
151
app/Config/Logger.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Log\Handlers\FileHandler;
|
||||
use CodeIgniter\Log\Handlers\HandlerInterface;
|
||||
|
||||
class Logger extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Error Logging Threshold
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* You can enable error logging by setting a threshold over zero. The
|
||||
* threshold determines what gets logged. Any values below or equal to the
|
||||
* threshold will be logged.
|
||||
*
|
||||
* Threshold options are:
|
||||
*
|
||||
* - 0 = Disables logging, Error logging TURNED OFF
|
||||
* - 1 = Emergency Messages - System is unusable
|
||||
* - 2 = Alert Messages - Action Must Be Taken Immediately
|
||||
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
||||
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
||||
* - 5 = Warnings - Exceptional occurrences that are not errors.
|
||||
* - 6 = Notices - Normal but significant events.
|
||||
* - 7 = Info - Interesting events, like user logging in, etc.
|
||||
* - 8 = Debug - Detailed debug information.
|
||||
* - 9 = All Messages
|
||||
*
|
||||
* You can also pass an array with threshold levels to show individual error types
|
||||
*
|
||||
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
|
||||
*
|
||||
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
|
||||
* your log files will fill up very fast.
|
||||
*
|
||||
* @var int|list<int>
|
||||
*/
|
||||
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Date Format for Logs
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Each item that is logged has an associated date. You can use PHP date
|
||||
* codes to set your own date formatting
|
||||
*/
|
||||
public string $dateFormat = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Log Handlers
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The logging system supports multiple actions to be taken when something
|
||||
* is logged. This is done by allowing for multiple Handlers, special classes
|
||||
* designed to write the log to their chosen destinations, whether that is
|
||||
* a file on the getServer, a cloud-based service, or even taking actions such
|
||||
* as emailing the dev team.
|
||||
*
|
||||
* Each handler is defined by the class name used for that handler, and it
|
||||
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
|
||||
*
|
||||
* The value of each key is an array of configuration items that are sent
|
||||
* to the constructor of each handler. The only required configuration item
|
||||
* is the 'handles' element, which must be an array of integer log levels.
|
||||
* This is most easily handled by using the constants defined in the
|
||||
* `Psr\Log\LogLevel` class.
|
||||
*
|
||||
* Handlers are executed in the order defined in this array, starting with
|
||||
* the handler on top and continuing down.
|
||||
*
|
||||
* @var array<class-string<HandlerInterface>, array<string, int|list<string>|string>>
|
||||
*/
|
||||
public array $handlers = [
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* File Handler
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
FileHandler::class => [
|
||||
// The log levels that this handler will handle.
|
||||
'handles' => [
|
||||
'critical',
|
||||
'alert',
|
||||
'emergency',
|
||||
'debug',
|
||||
'error',
|
||||
'info',
|
||||
'notice',
|
||||
'warning',
|
||||
],
|
||||
|
||||
/*
|
||||
* The default filename extension for log files.
|
||||
* An extension of 'php' allows for protecting the log files via basic
|
||||
* scripting, when they are to be stored under a publicly accessible directory.
|
||||
*
|
||||
* NOTE: Leaving it blank will default to 'log'.
|
||||
*/
|
||||
'fileExtension' => '',
|
||||
|
||||
/*
|
||||
* The file system permissions to be applied on newly created log files.
|
||||
*
|
||||
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
|
||||
* integer notation (i.e. 0700, 0644, etc.)
|
||||
*/
|
||||
'filePermissions' => 0644,
|
||||
|
||||
/*
|
||||
* Logging Directory Path
|
||||
*
|
||||
* By default, logs are written to WRITEPATH . 'logs/'
|
||||
* Specify a different destination here, if desired.
|
||||
*/
|
||||
'path' => '',
|
||||
],
|
||||
|
||||
/*
|
||||
* The ChromeLoggerHandler requires the use of the Chrome web browser
|
||||
* and the ChromeLogger extension. Uncomment this block to use it.
|
||||
*/
|
||||
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
|
||||
// /*
|
||||
// * The log levels that this handler will handle.
|
||||
// */
|
||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
|
||||
// 'error', 'info', 'notice', 'warning'],
|
||||
// ],
|
||||
|
||||
/*
|
||||
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
|
||||
* Uncomment this block to use it.
|
||||
*/
|
||||
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
|
||||
// /* The log levels this handler can handle. */
|
||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
|
||||
//
|
||||
// /*
|
||||
// * The message type where the error should go. Can be 0 or 4, or use the
|
||||
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
|
||||
// */
|
||||
// 'messageType' => 0,
|
||||
// ],
|
||||
];
|
||||
}
|
||||
50
app/Config/Migrations.php
Normal file
50
app/Config/Migrations.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Migrations extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable/Disable Migrations
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Migrations are enabled by default.
|
||||
*
|
||||
* You should enable migrations whenever you intend to do a schema migration
|
||||
* and disable it back when you're done.
|
||||
*/
|
||||
public bool $enabled = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Migrations Table
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the name of the table that will store the current migrations state.
|
||||
* When migrations runs it will store in a database table which migration
|
||||
* files have already been run.
|
||||
*/
|
||||
public string $table = 'migrations';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Timestamp Format
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the format that will be used when creating new migrations
|
||||
* using the CLI command:
|
||||
* > php spark make:migration
|
||||
*
|
||||
* NOTE: if you set an unsupported format, migration runner will not find
|
||||
* your migration files.
|
||||
*
|
||||
* Supported formats:
|
||||
* - YmdHis_
|
||||
* - Y-m-d-His_
|
||||
* - Y_m_d_His_
|
||||
*/
|
||||
public string $timestampFormat = 'Y-m-d-His_';
|
||||
}
|
||||
534
app/Config/Mimes.php
Normal file
534
app/Config/Mimes.php
Normal file
@ -0,0 +1,534 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* This file contains an array of mime types. It is used by the
|
||||
* Upload class to help identify allowed file types.
|
||||
*
|
||||
* When more than one variation for an extension exist (like jpg, jpeg, etc)
|
||||
* the most common one should be first in the array to aid the guess*
|
||||
* methods. The same applies when more than one mime-type exists for a
|
||||
* single extension.
|
||||
*
|
||||
* When working with mime types, please make sure you have the ´fileinfo´
|
||||
* extension enabled to reliably detect the media types.
|
||||
*/
|
||||
class Mimes
|
||||
{
|
||||
/**
|
||||
* Map of extensions to mime types.
|
||||
*
|
||||
* @var array<string, list<string>|string>
|
||||
*/
|
||||
public static array $mimes = [
|
||||
'hqx' => [
|
||||
'application/mac-binhex40',
|
||||
'application/mac-binhex',
|
||||
'application/x-binhex40',
|
||||
'application/x-mac-binhex40',
|
||||
],
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'csv' => [
|
||||
'text/csv',
|
||||
'text/x-comma-separated-values',
|
||||
'text/comma-separated-values',
|
||||
'application/vnd.ms-excel',
|
||||
'application/x-csv',
|
||||
'text/x-csv',
|
||||
'application/csv',
|
||||
'application/excel',
|
||||
'application/vnd.msexcel',
|
||||
'text/plain',
|
||||
],
|
||||
'bin' => [
|
||||
'application/macbinary',
|
||||
'application/mac-binary',
|
||||
'application/octet-stream',
|
||||
'application/x-binary',
|
||||
'application/x-macbinary',
|
||||
],
|
||||
'dms' => 'application/octet-stream',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'exe' => [
|
||||
'application/octet-stream',
|
||||
'application/vnd.microsoft.portable-executable',
|
||||
'application/x-dosexec',
|
||||
'application/x-msdownload',
|
||||
],
|
||||
'class' => 'application/octet-stream',
|
||||
'psd' => [
|
||||
'application/x-photoshop',
|
||||
'image/vnd.adobe.photoshop',
|
||||
],
|
||||
'so' => 'application/octet-stream',
|
||||
'sea' => 'application/octet-stream',
|
||||
'dll' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'pdf' => [
|
||||
'application/pdf',
|
||||
'application/force-download',
|
||||
'application/x-download',
|
||||
],
|
||||
'ai' => [
|
||||
'application/pdf',
|
||||
'application/postscript',
|
||||
],
|
||||
'eps' => 'application/postscript',
|
||||
'ps' => 'application/postscript',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => [
|
||||
'application/vnd.ms-excel',
|
||||
'application/msexcel',
|
||||
'application/x-msexcel',
|
||||
'application/x-ms-excel',
|
||||
'application/x-excel',
|
||||
'application/x-dos_ms_excel',
|
||||
'application/xls',
|
||||
'application/x-xls',
|
||||
'application/excel',
|
||||
'application/download',
|
||||
'application/vnd.ms-office',
|
||||
'application/msword',
|
||||
],
|
||||
'ppt' => [
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/powerpoint',
|
||||
'application/vnd.ms-office',
|
||||
'application/msword',
|
||||
],
|
||||
'pptx' => [
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
],
|
||||
'wbxml' => 'application/wbxml',
|
||||
'wmlc' => 'application/wmlc',
|
||||
'dcr' => 'application/x-director',
|
||||
'dir' => 'application/x-director',
|
||||
'dxr' => 'application/x-director',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'gz' => 'application/x-gzip',
|
||||
'gzip' => 'application/x-gzip',
|
||||
'php' => [
|
||||
'application/x-php',
|
||||
'application/x-httpd-php',
|
||||
'application/php',
|
||||
'text/php',
|
||||
'text/x-php',
|
||||
'application/x-httpd-php-source',
|
||||
],
|
||||
'php4' => 'application/x-httpd-php',
|
||||
'php3' => 'application/x-httpd-php',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'js' => [
|
||||
'application/x-javascript',
|
||||
'text/plain',
|
||||
],
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'tar' => 'application/x-tar',
|
||||
'tgz' => [
|
||||
'application/x-tar',
|
||||
'application/x-gzip-compressed',
|
||||
],
|
||||
'z' => 'application/x-compress',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'zip' => [
|
||||
'application/x-zip',
|
||||
'application/zip',
|
||||
'application/x-zip-compressed',
|
||||
'application/s-compressed',
|
||||
'multipart/x-zip',
|
||||
],
|
||||
'rar' => [
|
||||
'application/vnd.rar',
|
||||
'application/x-rar',
|
||||
'application/rar',
|
||||
'application/x-rar-compressed',
|
||||
],
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => [
|
||||
'audio/mpeg',
|
||||
'audio/mpg',
|
||||
'audio/mpeg3',
|
||||
'audio/mp3',
|
||||
],
|
||||
'aif' => [
|
||||
'audio/x-aiff',
|
||||
'audio/aiff',
|
||||
],
|
||||
'aiff' => [
|
||||
'audio/x-aiff',
|
||||
'audio/aiff',
|
||||
],
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rm' => 'audio/x-pn-realaudio',
|
||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'rv' => 'video/vnd.rn-realvideo',
|
||||
'wav' => [
|
||||
'audio/x-wav',
|
||||
'audio/wave',
|
||||
'audio/wav',
|
||||
],
|
||||
'bmp' => [
|
||||
'image/bmp',
|
||||
'image/x-bmp',
|
||||
'image/x-bitmap',
|
||||
'image/x-xbitmap',
|
||||
'image/x-win-bitmap',
|
||||
'image/x-windows-bmp',
|
||||
'image/ms-bmp',
|
||||
'image/x-ms-bmp',
|
||||
'application/bmp',
|
||||
'application/x-bmp',
|
||||
'application/x-win-bitmap',
|
||||
],
|
||||
'gif' => 'image/gif',
|
||||
'jpg' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jpeg' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jpe' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jp2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'j2k' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpf' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpg2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpx' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpm' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'mj2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'mjp2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'png' => [
|
||||
'image/png',
|
||||
'image/x-png',
|
||||
],
|
||||
'webp' => 'image/webp',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff',
|
||||
'css' => [
|
||||
'text/css',
|
||||
'text/plain',
|
||||
],
|
||||
'html' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'htm' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'shtml' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => [
|
||||
'text/plain',
|
||||
'text/x-log',
|
||||
],
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => [
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
'text/plain',
|
||||
],
|
||||
'xsl' => [
|
||||
'application/xml',
|
||||
'text/xsl',
|
||||
'text/xml',
|
||||
],
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'avi' => [
|
||||
'video/x-msvideo',
|
||||
'video/msvideo',
|
||||
'video/avi',
|
||||
'application/x-troff-msvideo',
|
||||
],
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'doc' => [
|
||||
'application/msword',
|
||||
'application/vnd.ms-office',
|
||||
],
|
||||
'docx' => [
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/zip',
|
||||
'application/msword',
|
||||
'application/x-zip',
|
||||
],
|
||||
'dot' => [
|
||||
'application/msword',
|
||||
'application/vnd.ms-office',
|
||||
],
|
||||
'dotx' => [
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/zip',
|
||||
'application/msword',
|
||||
],
|
||||
'xlsx' => [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/zip',
|
||||
'application/vnd.ms-excel',
|
||||
'application/msword',
|
||||
'application/x-zip',
|
||||
],
|
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'word' => [
|
||||
'application/msword',
|
||||
'application/octet-stream',
|
||||
],
|
||||
'xl' => 'application/excel',
|
||||
'eml' => 'message/rfc822',
|
||||
'json' => [
|
||||
'application/json',
|
||||
'text/json',
|
||||
],
|
||||
'pem' => [
|
||||
'application/x-x509-user-cert',
|
||||
'application/x-pem-file',
|
||||
'application/octet-stream',
|
||||
],
|
||||
'p10' => [
|
||||
'application/x-pkcs10',
|
||||
'application/pkcs10',
|
||||
],
|
||||
'p12' => 'application/x-pkcs12',
|
||||
'p7a' => 'application/x-pkcs7-signature',
|
||||
'p7c' => [
|
||||
'application/pkcs7-mime',
|
||||
'application/x-pkcs7-mime',
|
||||
],
|
||||
'p7m' => [
|
||||
'application/pkcs7-mime',
|
||||
'application/x-pkcs7-mime',
|
||||
],
|
||||
'p7r' => 'application/x-pkcs7-certreqresp',
|
||||
'p7s' => 'application/pkcs7-signature',
|
||||
'crt' => [
|
||||
'application/x-x509-ca-cert',
|
||||
'application/x-x509-user-cert',
|
||||
'application/pkix-cert',
|
||||
],
|
||||
'crl' => [
|
||||
'application/pkix-crl',
|
||||
'application/pkcs-crl',
|
||||
],
|
||||
'der' => 'application/x-x509-ca-cert',
|
||||
'kdb' => 'application/octet-stream',
|
||||
'pgp' => 'application/pgp',
|
||||
'gpg' => 'application/gpg-keys',
|
||||
'sst' => 'application/octet-stream',
|
||||
'csr' => 'application/octet-stream',
|
||||
'rsa' => 'application/x-pkcs7',
|
||||
'cer' => [
|
||||
'application/pkix-cert',
|
||||
'application/x-x509-ca-cert',
|
||||
],
|
||||
'3g2' => 'video/3gpp2',
|
||||
'3gp' => [
|
||||
'video/3gp',
|
||||
'video/3gpp',
|
||||
],
|
||||
'mp4' => 'video/mp4',
|
||||
'm4a' => 'audio/x-m4a',
|
||||
'f4v' => [
|
||||
'video/mp4',
|
||||
'video/x-f4v',
|
||||
],
|
||||
'flv' => 'video/x-flv',
|
||||
'webm' => 'video/webm',
|
||||
'aac' => 'audio/x-acc',
|
||||
'm4u' => 'application/vnd.mpegurl',
|
||||
'm3u' => 'text/plain',
|
||||
'xspf' => 'application/xspf+xml',
|
||||
'vlc' => 'application/videolan',
|
||||
'wmv' => [
|
||||
'video/x-ms-wmv',
|
||||
'video/x-ms-asf',
|
||||
],
|
||||
'au' => 'audio/x-au',
|
||||
'ac3' => 'audio/ac3',
|
||||
'flac' => 'audio/x-flac',
|
||||
'ogg' => [
|
||||
'audio/ogg',
|
||||
'video/ogg',
|
||||
'application/ogg',
|
||||
],
|
||||
'kmz' => [
|
||||
'application/vnd.google-earth.kmz',
|
||||
'application/zip',
|
||||
'application/x-zip',
|
||||
],
|
||||
'kml' => [
|
||||
'application/vnd.google-earth.kml+xml',
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
],
|
||||
'ics' => 'text/calendar',
|
||||
'ical' => 'text/calendar',
|
||||
'zsh' => 'text/x-scriptzsh',
|
||||
'7zip' => [
|
||||
'application/x-compressed',
|
||||
'application/x-zip-compressed',
|
||||
'application/zip',
|
||||
'multipart/x-zip',
|
||||
],
|
||||
'cdr' => [
|
||||
'application/cdr',
|
||||
'application/coreldraw',
|
||||
'application/x-cdr',
|
||||
'application/x-coreldraw',
|
||||
'image/cdr',
|
||||
'image/x-cdr',
|
||||
'zz-application/zz-winassoc-cdr',
|
||||
],
|
||||
'wma' => [
|
||||
'audio/x-ms-wma',
|
||||
'video/x-ms-asf',
|
||||
],
|
||||
'jar' => [
|
||||
'application/java-archive',
|
||||
'application/x-java-application',
|
||||
'application/x-jar',
|
||||
'application/x-compressed',
|
||||
],
|
||||
'svg' => [
|
||||
'image/svg+xml',
|
||||
'image/svg',
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
],
|
||||
'vcf' => 'text/x-vcard',
|
||||
'srt' => [
|
||||
'text/srt',
|
||||
'text/plain',
|
||||
],
|
||||
'vtt' => [
|
||||
'text/vtt',
|
||||
'text/plain',
|
||||
],
|
||||
'ico' => [
|
||||
'image/x-icon',
|
||||
'image/x-ico',
|
||||
'image/vnd.microsoft.icon',
|
||||
],
|
||||
'stl' => [
|
||||
'application/sla',
|
||||
'application/vnd.ms-pki.stl',
|
||||
'application/x-navistyle',
|
||||
'model/stl',
|
||||
'application/octet-stream',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Attempts to determine the best mime type for the given file extension.
|
||||
*
|
||||
* @return string|null The mime type found, or none if unable to determine.
|
||||
*/
|
||||
public static function guessTypeFromExtension(string $extension)
|
||||
{
|
||||
$extension = trim(strtolower($extension), '. ');
|
||||
|
||||
if (! array_key_exists($extension, static::$mimes)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to determine the best file extension for a given mime type.
|
||||
*
|
||||
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type)
|
||||
*
|
||||
* @return string|null The extension determined, or null if unable to match.
|
||||
*/
|
||||
public static function guessExtensionFromType(string $type, ?string $proposedExtension = null)
|
||||
{
|
||||
$type = trim(strtolower($type), '. ');
|
||||
|
||||
$proposedExtension = trim(strtolower($proposedExtension ?? ''));
|
||||
|
||||
if (
|
||||
$proposedExtension !== ''
|
||||
&& array_key_exists($proposedExtension, static::$mimes)
|
||||
&& in_array($type, (array) static::$mimes[$proposedExtension], true)
|
||||
) {
|
||||
// The detected mime type matches with the proposed extension.
|
||||
return $proposedExtension;
|
||||
}
|
||||
|
||||
// Reverse check the mime type list if no extension was proposed.
|
||||
// This search is order sensitive!
|
||||
foreach (static::$mimes as $ext => $types) {
|
||||
if (in_array($type, (array) $types, true)) {
|
||||
return $ext;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
82
app/Config/Modules.php
Normal file
82
app/Config/Modules.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Modules\Modules as BaseModules;
|
||||
|
||||
/**
|
||||
* Modules Configuration.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*/
|
||||
class Modules extends BaseModules
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable Auto-Discovery?
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, then auto-discovery will happen across all elements listed in
|
||||
* $aliases below. If false, no auto-discovery will happen at all,
|
||||
* giving a slight performance boost.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $enabled = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable Auto-Discovery Within Composer Packages?
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, then auto-discovery will happen across all namespaces loaded
|
||||
* by Composer, as well as the namespaces configured locally.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $discoverInComposer = true;
|
||||
|
||||
/**
|
||||
* The Composer package list for Auto-Discovery
|
||||
* This setting is optional.
|
||||
*
|
||||
* E.g.:
|
||||
* [
|
||||
* 'only' => [
|
||||
* // List up all packages to auto-discover
|
||||
* 'codeigniter4/shield',
|
||||
* ],
|
||||
* ]
|
||||
* or
|
||||
* [
|
||||
* 'exclude' => [
|
||||
* // List up packages to exclude.
|
||||
* 'pestphp/pest',
|
||||
* ],
|
||||
* ]
|
||||
*
|
||||
* @var array{only?: list<string>, exclude?: list<string>}
|
||||
*/
|
||||
public $composerPackages = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Auto-Discovery Rules
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Aliases list of all discovery classes that will be active and used during
|
||||
* the current application request.
|
||||
*
|
||||
* If it is not listed, only the base application elements will be used.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $aliases = [
|
||||
'events',
|
||||
'filters',
|
||||
'registrars',
|
||||
'routes',
|
||||
'services',
|
||||
];
|
||||
}
|
||||
30
app/Config/Optimize.php
Normal file
30
app/Config/Optimize.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Optimization Configuration.
|
||||
*
|
||||
* NOTE: This class does not extend BaseConfig for performance reasons.
|
||||
* So you cannot replace the property values with Environment Variables.
|
||||
*/
|
||||
class Optimize
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Config Caching
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
|
||||
*/
|
||||
public bool $configCacheEnabled = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Config Caching
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
|
||||
*/
|
||||
public bool $locatorCacheEnabled = false;
|
||||
}
|
||||
37
app/Config/Pager.php
Normal file
37
app/Config/Pager.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Pager extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Templates
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pagination links are rendered out using views to configure their
|
||||
* appearance. This array contains aliases and the view names to
|
||||
* use when rendering the links.
|
||||
*
|
||||
* Within each view, the Pager object will be available as $pager,
|
||||
* and the desired group as $pagerGroup;
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $templates = [
|
||||
'default_full' => 'CodeIgniter\Pager\Views\default_full',
|
||||
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
|
||||
'default_head' => 'CodeIgniter\Pager\Views\default_head',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Items Per Page
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default number of results shown in a single page.
|
||||
*/
|
||||
public int $perPage = 20;
|
||||
}
|
||||
78
app/Config/Paths.php
Normal file
78
app/Config/Paths.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Paths
|
||||
*
|
||||
* Holds the paths that are used by the system to
|
||||
* locate the main directories, app, system, etc.
|
||||
*
|
||||
* Modifying these allows you to restructure your application,
|
||||
* share a system folder between multiple applications, and more.
|
||||
*
|
||||
* All paths are relative to the project's root folder.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*/
|
||||
class Paths
|
||||
{
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* SYSTEM FOLDER NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This must contain the name of your "system" folder. Include
|
||||
* the path if the folder is not in the same directory as this file.
|
||||
*/
|
||||
public string $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* APPLICATION FOLDER NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* If you want this front controller to use a different "app"
|
||||
* folder than the default one you can set its name here. The folder
|
||||
* can also be renamed or relocated anywhere on your server. If
|
||||
* you do, use a full server path.
|
||||
*
|
||||
* @see http://codeigniter.com/user_guide/general/managing_apps.html
|
||||
*/
|
||||
public string $appDirectory = __DIR__ . '/..';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* WRITABLE DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of your "writable" directory.
|
||||
* The writable directory allows you to group all directories that
|
||||
* need write permission to a single place that can be tucked away
|
||||
* for maximum security, keeping it out of the app and/or
|
||||
* system directories.
|
||||
*/
|
||||
public string $writableDirectory = __DIR__ . '/../../writable';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* TESTS DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of your "tests" directory.
|
||||
*/
|
||||
public string $testsDirectory = __DIR__ . '/../../tests';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* VIEW DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of the directory that
|
||||
* contains the view files used by your application. By
|
||||
* default this is in `app/Views`. This value
|
||||
* is used when no value is provided to `Services::renderer()`.
|
||||
*/
|
||||
public string $viewDirectory = __DIR__ . '/../Views';
|
||||
}
|
||||
28
app/Config/Publisher.php
Normal file
28
app/Config/Publisher.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Publisher as BasePublisher;
|
||||
|
||||
/**
|
||||
* Publisher Configuration
|
||||
*
|
||||
* Defines basic security restrictions for the Publisher class
|
||||
* to prevent abuse by injecting malicious files into a project.
|
||||
*/
|
||||
class Publisher extends BasePublisher
|
||||
{
|
||||
/**
|
||||
* A list of allowed destinations with a (pseudo-)regex
|
||||
* of allowed files for each destination.
|
||||
* Attempts to publish to directories not in this list will
|
||||
* result in a PublisherException. Files that do no fit the
|
||||
* pattern will cause copy/merge to fail.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $restrictions = [
|
||||
ROOTPATH => '*',
|
||||
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
|
||||
];
|
||||
}
|
||||
44
app/Config/Routes.php
Normal file
44
app/Config/Routes.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use CodeIgniter\Router\RouteCollection;
|
||||
|
||||
/**
|
||||
* @var RouteCollection $routes
|
||||
*/
|
||||
$routes->get('/', 'Home::index');
|
||||
|
||||
|
||||
//추가 Custom RULE 만들때 : ex)UUID형식
|
||||
$routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
|
||||
//authFilter는 추가적인 작업이 필요
|
||||
//1. app/Filters/AuthFilter.php
|
||||
//2. Config/Filters.php -> $aliases = ['authFilter' => AuthFilter::class]
|
||||
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
|
||||
});
|
||||
|
||||
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('auth', ['namespace' => 'App\Controllers\Auth'], function ($routes) {
|
||||
$routes->get('login', 'LocalController::login_form');
|
||||
$routes->post('login', 'LocalController::login');
|
||||
$routes->get('google_login', 'GoogleController::login');
|
||||
$routes->get('logout', 'LocalController::logout');
|
||||
});
|
||||
});
|
||||
//Admin 관련
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('user', function ($routes) {
|
||||
$routes->get('/', 'UserController::index');
|
||||
$routes->get('create', 'UserController::create_form');
|
||||
$routes->post('create', 'UserController::create');
|
||||
$routes->get('modify/(:num)', 'UserController::modify_form/$1');
|
||||
$routes->post('modify/(:num)', 'UserController::modify/$1');
|
||||
$routes->get('view/(:num)', 'UserController::view/$1');
|
||||
$routes->get('delete/(:num)', 'UserController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:any)', 'UserController::toggle/$1/$2', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob', 'UserController::batchjob', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob_delete', 'UserController::batchjob_delete', ['filter' => 'authFilter:master']);
|
||||
$routes->get('download/(:alpha)', 'UserController::download/$1');
|
||||
});
|
||||
});
|
||||
140
app/Config/Routing.php
Normal file
140
app/Config/Routing.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?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
|
||||
{
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* 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'
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $routeFiles = [
|
||||
APPPATH . 'Config/Routes.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* For Defined Routes and Auto Routing.
|
||||
* The default namespace to use for Controllers when no other
|
||||
* namespace has been specified.
|
||||
*
|
||||
* Default: 'App\Controllers'
|
||||
*/
|
||||
public string $defaultNamespace = 'App\Controllers';
|
||||
|
||||
/**
|
||||
* For Auto Routing.
|
||||
* The default controller to use when no other controller has been
|
||||
* specified.
|
||||
*
|
||||
* Default: 'Home'
|
||||
*/
|
||||
public string $defaultController = 'Home';
|
||||
|
||||
/**
|
||||
* For Defined Routes and Auto Routing.
|
||||
* The default method to call on the controller when no other
|
||||
* method has been set in the route.
|
||||
*
|
||||
* Default: 'index'
|
||||
*/
|
||||
public string $defaultMethod = 'index';
|
||||
|
||||
/**
|
||||
* For Auto Routing.
|
||||
* Whether to translate dashes in URIs for controller/method 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;
|
||||
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* If TRUE, will enable the use of the 'prioritize' option
|
||||
* when defining routes.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $prioritize = false;
|
||||
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* If TRUE, matched multiple URI segments will be passed as one parameter.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $multipleSegmentsOneParam = false;
|
||||
|
||||
/**
|
||||
* For Auto Routing (Improved).
|
||||
* Map of URI segments and namespaces.
|
||||
*
|
||||
* The key is the first URI segment. The value is the controller namespace.
|
||||
* E.g.,
|
||||
* [
|
||||
* 'blog' => 'Acme\Blog\Controllers',
|
||||
* ]
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $moduleRoutes = [];
|
||||
|
||||
/**
|
||||
* For Auto Routing (Improved).
|
||||
* Whether to translate dashes in URIs for controller/method to CamelCase.
|
||||
* E.g., blog-controller -> BlogController
|
||||
*
|
||||
* If you enable this, $translateURIDashes is ignored.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $translateUriToCamelCase = true;
|
||||
}
|
||||
86
app/Config/Security.php
Normal file
86
app/Config/Security.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Security extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Protection Method
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Protection Method for Cross Site Request Forgery protection.
|
||||
*
|
||||
* @var string 'cookie' or 'session'
|
||||
*/
|
||||
public string $csrfProtection = 'cookie';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Token Randomization
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Randomize the CSRF Token for added security.
|
||||
*/
|
||||
public bool $tokenRandomize = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Token Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Token name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $tokenName = 'csrf_test_name';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Header Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Header name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $headerName = 'X-CSRF-TOKEN';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Cookie Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $cookieName = 'csrf_cookie_name';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Expires
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Expiration time for Cross Site Request Forgery protection cookie.
|
||||
*
|
||||
* Defaults to two hours (in seconds).
|
||||
*/
|
||||
public int $expires = 7200;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Regenerate
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Regenerate CSRF Token on every submission.
|
||||
*/
|
||||
public bool $regenerate = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Redirect
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Redirect to previous page with error on failure.
|
||||
*
|
||||
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
|
||||
*/
|
||||
public bool $redirect = (ENVIRONMENT === 'production');
|
||||
}
|
||||
89
app/Config/Services.php
Normal file
89
app/Config/Services.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
use App\Services\Auth\GoogleService;
|
||||
use App\Services\Auth\LocalService;
|
||||
use App\Services\BoardService;
|
||||
use App\Services\UserService;
|
||||
|
||||
/**
|
||||
* Services Configuration file.
|
||||
*
|
||||
* Services are simply other classes/libraries that the system uses
|
||||
* to do its job. This is used by CodeIgniter to allow the core of the
|
||||
* framework to be swapped out easily without affecting the usage within
|
||||
* the rest of your application.
|
||||
*
|
||||
* This file holds any application-specific services, or service overrides
|
||||
* that you might need. An example has been included with the general
|
||||
* method format you should use for your service methods. For more examples,
|
||||
* see the core Services file at system/Config/Services.php.
|
||||
*/
|
||||
class Services extends BaseService
|
||||
{
|
||||
/*
|
||||
* public static function example($getShared = true)
|
||||
* {
|
||||
* if ($getShared) {
|
||||
* return static::getSharedInstance('example');
|
||||
* }
|
||||
*
|
||||
* return new \CodeIgniter\Example();
|
||||
* }
|
||||
*/
|
||||
|
||||
public static function myauth($getShared = true): LocalService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
} else {
|
||||
return new LocalService(
|
||||
new \App\Models\UserModel()
|
||||
);
|
||||
}
|
||||
}
|
||||
//로그인처리용
|
||||
public static function localauth($getShared = true): LocalService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
} else {
|
||||
return new LocalService(
|
||||
new \App\Models\UserModel()
|
||||
);
|
||||
}
|
||||
}
|
||||
public static function googleauth($getShared = true): GoogleService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new GoogleService(
|
||||
new \App\Models\USerModel(),
|
||||
new \App\Libraries\MySocket\GoogleSocket\CURL()
|
||||
);
|
||||
}
|
||||
//로그인처리용
|
||||
public static function userservice($getShared = true): UserService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new UserService(
|
||||
new \App\Models\USerModel()
|
||||
);
|
||||
}
|
||||
|
||||
public static function boardservice($getShared = true): BoardService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new BoardService(
|
||||
new \App\Models\BoardModel(),
|
||||
);
|
||||
}
|
||||
}
|
||||
127
app/Config/Session.php
Normal file
127
app/Config/Session.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Lock Retry Interval (microseconds)
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is used for RedisHandler.
|
||||
*
|
||||
* Time (microseconds) to wait if lock cannot be acquired.
|
||||
* The default is 100,000 microseconds (= 0.1 seconds).
|
||||
*/
|
||||
public int $lockRetryInterval = 100_000;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Lock Max Retries
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is used for RedisHandler.
|
||||
*
|
||||
* Maximum number of lock acquisition attempts.
|
||||
* The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
|
||||
* seconds.
|
||||
*/
|
||||
public int $lockMaxRetries = 300;
|
||||
}
|
||||
122
app/Config/Toolbar.php
Normal file
122
app/Config/Toolbar.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Database;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Events;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Files;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Views;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Debug Toolbar
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The Debug Toolbar provides a way to see information about the performance
|
||||
* and state of your application during that page display. By default it will
|
||||
* NOT be displayed under production environments, and will only display if
|
||||
* `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
|
||||
*/
|
||||
class Toolbar extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Toolbar Collectors
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* List of toolbar collectors that will be called when Debug Toolbar
|
||||
* fires up and collects data from.
|
||||
*
|
||||
* @var list<class-string>
|
||||
*/
|
||||
public array $collectors = [
|
||||
Timers::class,
|
||||
Database::class,
|
||||
Logs::class,
|
||||
Views::class,
|
||||
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
|
||||
Files::class,
|
||||
Routes::class,
|
||||
Events::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Collect Var Data
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If set to false var data from the views will not be collected. Useful to
|
||||
* avoid high memory usage when there are lots of data passed to the view.
|
||||
*/
|
||||
public bool $collectVarData = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Max History
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* `$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
|
||||
* 0 (zero) to not have any history stored, or -1 for unlimited history.
|
||||
*/
|
||||
public int $maxHistory = 20;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Toolbar Views Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The full path to the the views that are used by the toolbar.
|
||||
* This MUST have a trailing slash.
|
||||
*/
|
||||
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Max Queries
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If the Database Collector is enabled, it will log every query that the
|
||||
* the system generates so they can be displayed on the toolbar's timeline
|
||||
* and in the query log. This can lead to memory issues in some instances
|
||||
* with hundreds of queries.
|
||||
*
|
||||
* `$maxQueries` defines the maximum amount of queries that will be stored.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $watchedExtensions = [
|
||||
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
|
||||
];
|
||||
}
|
||||
252
app/Config/UserAgents.php
Normal file
252
app/Config/UserAgents.php
Normal file
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* User Agents
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* This file contains four arrays of user agent data. It is used by the
|
||||
* User Agent Class to help identify browser, platform, robot, and
|
||||
* mobile device data. The array keys are used to identify the device
|
||||
* and the array values are used to set the actual name of the item.
|
||||
*/
|
||||
class UserAgents extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* OS Platforms
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $platforms = [
|
||||
'windows nt 10.0' => 'Windows 10',
|
||||
'windows nt 6.3' => 'Windows 8.1',
|
||||
'windows nt 6.2' => 'Windows 8',
|
||||
'windows nt 6.1' => 'Windows 7',
|
||||
'windows nt 6.0' => 'Windows Vista',
|
||||
'windows nt 5.2' => 'Windows 2003',
|
||||
'windows nt 5.1' => 'Windows XP',
|
||||
'windows nt 5.0' => 'Windows 2000',
|
||||
'windows nt 4.0' => 'Windows NT 4.0',
|
||||
'winnt4.0' => 'Windows NT 4.0',
|
||||
'winnt 4.0' => 'Windows NT',
|
||||
'winnt' => 'Windows NT',
|
||||
'windows 98' => 'Windows 98',
|
||||
'win98' => 'Windows 98',
|
||||
'windows 95' => 'Windows 95',
|
||||
'win95' => 'Windows 95',
|
||||
'windows phone' => 'Windows Phone',
|
||||
'windows' => 'Unknown Windows OS',
|
||||
'android' => 'Android',
|
||||
'blackberry' => 'BlackBerry',
|
||||
'iphone' => 'iOS',
|
||||
'ipad' => 'iOS',
|
||||
'ipod' => 'iOS',
|
||||
'os x' => 'Mac OS X',
|
||||
'ppc mac' => 'Power PC Mac',
|
||||
'freebsd' => 'FreeBSD',
|
||||
'ppc' => 'Macintosh',
|
||||
'linux' => 'Linux',
|
||||
'debian' => 'Debian',
|
||||
'sunos' => 'Sun Solaris',
|
||||
'beos' => 'BeOS',
|
||||
'apachebench' => 'ApacheBench',
|
||||
'aix' => 'AIX',
|
||||
'irix' => 'Irix',
|
||||
'osf' => 'DEC OSF',
|
||||
'hp-ux' => 'HP-UX',
|
||||
'netbsd' => 'NetBSD',
|
||||
'bsdi' => 'BSDi',
|
||||
'openbsd' => 'OpenBSD',
|
||||
'gnu' => 'GNU/Linux',
|
||||
'unix' => 'Unknown Unix OS',
|
||||
'symbian' => 'Symbian OS',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Browsers
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* The order of this array should NOT be changed. Many browsers return
|
||||
* multiple browser types so we want to identify the subtype first.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $browsers = [
|
||||
'OPR' => 'Opera',
|
||||
'Flock' => 'Flock',
|
||||
'Edge' => 'Spartan',
|
||||
'Edg' => 'Edge',
|
||||
'Chrome' => 'Chrome',
|
||||
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
|
||||
'Opera.*?Version' => 'Opera',
|
||||
'Opera' => 'Opera',
|
||||
'MSIE' => 'Internet Explorer',
|
||||
'Internet Explorer' => 'Internet Explorer',
|
||||
'Trident.* rv' => 'Internet Explorer',
|
||||
'Shiira' => 'Shiira',
|
||||
'Firefox' => 'Firefox',
|
||||
'Chimera' => 'Chimera',
|
||||
'Phoenix' => 'Phoenix',
|
||||
'Firebird' => 'Firebird',
|
||||
'Camino' => 'Camino',
|
||||
'Netscape' => 'Netscape',
|
||||
'OmniWeb' => 'OmniWeb',
|
||||
'Safari' => 'Safari',
|
||||
'Mozilla' => 'Mozilla',
|
||||
'Konqueror' => 'Konqueror',
|
||||
'icab' => 'iCab',
|
||||
'Lynx' => 'Lynx',
|
||||
'Links' => 'Links',
|
||||
'hotjava' => 'HotJava',
|
||||
'amaya' => 'Amaya',
|
||||
'IBrowse' => 'IBrowse',
|
||||
'Maxthon' => 'Maxthon',
|
||||
'Ubuntu' => 'Ubuntu Web Browser',
|
||||
'Vivaldi' => 'Vivaldi',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Mobiles
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $mobiles = [
|
||||
// legacy array, old values commented out
|
||||
'mobileexplorer' => 'Mobile Explorer',
|
||||
// 'openwave' => 'Open Wave',
|
||||
// 'opera mini' => 'Opera Mini',
|
||||
// 'operamini' => 'Opera Mini',
|
||||
// 'elaine' => 'Palm',
|
||||
'palmsource' => 'Palm',
|
||||
// 'digital paths' => 'Palm',
|
||||
// 'avantgo' => 'Avantgo',
|
||||
// 'xiino' => 'Xiino',
|
||||
'palmscape' => 'Palmscape',
|
||||
// 'nokia' => 'Nokia',
|
||||
// 'ericsson' => 'Ericsson',
|
||||
// 'blackberry' => 'BlackBerry',
|
||||
// 'motorola' => 'Motorola'
|
||||
|
||||
// Phones and Manufacturers
|
||||
'motorola' => 'Motorola',
|
||||
'nokia' => 'Nokia',
|
||||
'palm' => 'Palm',
|
||||
'iphone' => 'Apple iPhone',
|
||||
'ipad' => 'iPad',
|
||||
'ipod' => 'Apple iPod Touch',
|
||||
'sony' => 'Sony Ericsson',
|
||||
'ericsson' => 'Sony Ericsson',
|
||||
'blackberry' => 'BlackBerry',
|
||||
'cocoon' => 'O2 Cocoon',
|
||||
'blazer' => 'Treo',
|
||||
'lg' => 'LG',
|
||||
'amoi' => 'Amoi',
|
||||
'xda' => 'XDA',
|
||||
'mda' => 'MDA',
|
||||
'vario' => 'Vario',
|
||||
'htc' => 'HTC',
|
||||
'samsung' => 'Samsung',
|
||||
'sharp' => 'Sharp',
|
||||
'sie-' => 'Siemens',
|
||||
'alcatel' => 'Alcatel',
|
||||
'benq' => 'BenQ',
|
||||
'ipaq' => 'HP iPaq',
|
||||
'mot-' => 'Motorola',
|
||||
'playstation portable' => 'PlayStation Portable',
|
||||
'playstation 3' => 'PlayStation 3',
|
||||
'playstation vita' => 'PlayStation Vita',
|
||||
'hiptop' => 'Danger Hiptop',
|
||||
'nec-' => 'NEC',
|
||||
'panasonic' => 'Panasonic',
|
||||
'philips' => 'Philips',
|
||||
'sagem' => 'Sagem',
|
||||
'sanyo' => 'Sanyo',
|
||||
'spv' => 'SPV',
|
||||
'zte' => 'ZTE',
|
||||
'sendo' => 'Sendo',
|
||||
'nintendo dsi' => 'Nintendo DSi',
|
||||
'nintendo ds' => 'Nintendo DS',
|
||||
'nintendo 3ds' => 'Nintendo 3DS',
|
||||
'wii' => 'Nintendo Wii',
|
||||
'open web' => 'Open Web',
|
||||
'openweb' => 'OpenWeb',
|
||||
|
||||
// Operating Systems
|
||||
'android' => 'Android',
|
||||
'symbian' => 'Symbian',
|
||||
'SymbianOS' => 'SymbianOS',
|
||||
'elaine' => 'Palm',
|
||||
'series60' => 'Symbian S60',
|
||||
'windows ce' => 'Windows CE',
|
||||
|
||||
// Browsers
|
||||
'obigo' => 'Obigo',
|
||||
'netfront' => 'Netfront Browser',
|
||||
'openwave' => 'Openwave Browser',
|
||||
'mobilexplorer' => 'Mobile Explorer',
|
||||
'operamini' => 'Opera Mini',
|
||||
'opera mini' => 'Opera Mini',
|
||||
'opera mobi' => 'Opera Mobile',
|
||||
'fennec' => 'Firefox Mobile',
|
||||
|
||||
// Other
|
||||
'digital paths' => 'Digital Paths',
|
||||
'avantgo' => 'AvantGo',
|
||||
'xiino' => 'Xiino',
|
||||
'novarra' => 'Novarra Transcoder',
|
||||
'vodafone' => 'Vodafone',
|
||||
'docomo' => 'NTT DoCoMo',
|
||||
'o2' => 'O2',
|
||||
|
||||
// Fallback
|
||||
'mobile' => 'Generic Mobile',
|
||||
'wireless' => 'Generic Mobile',
|
||||
'j2me' => 'Generic Mobile',
|
||||
'midp' => 'Generic Mobile',
|
||||
'cldc' => 'Generic Mobile',
|
||||
'up.link' => 'Generic Mobile',
|
||||
'up.browser' => 'Generic Mobile',
|
||||
'smartphone' => 'Generic Mobile',
|
||||
'cellphone' => 'Generic Mobile',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Robots
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* There are hundred of bots but these are the most common.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $robots = [
|
||||
'googlebot' => 'Googlebot',
|
||||
'msnbot' => 'MSNBot',
|
||||
'baiduspider' => 'Baiduspider',
|
||||
'bingbot' => 'Bing',
|
||||
'slurp' => 'Inktomi Slurp',
|
||||
'yahoo' => 'Yahoo',
|
||||
'ask jeeves' => 'Ask Jeeves',
|
||||
'fastcrawler' => 'FastCrawler',
|
||||
'infoseek' => 'InfoSeek Robot 1.0',
|
||||
'lycos' => 'Lycos',
|
||||
'yandex' => 'YandexBot',
|
||||
'mediapartners-google' => 'MediaPartners Google',
|
||||
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
|
||||
'adsbot-google' => 'AdsBot Google',
|
||||
'feedfetcher-google' => 'Feedfetcher Google',
|
||||
'curious george' => 'Curious George',
|
||||
'ia_archiver' => 'Alexa Crawler',
|
||||
'MJ12bot' => 'Majestic-12',
|
||||
'Uptimebot' => 'Uptimebot',
|
||||
];
|
||||
}
|
||||
45
app/Config/Validation.php
Normal file
45
app/Config/Validation.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Validation\StrictRules\CreditCardRules;
|
||||
use CodeIgniter\Validation\StrictRules\FileRules;
|
||||
use CodeIgniter\Validation\StrictRules\FormatRules;
|
||||
use CodeIgniter\Validation\StrictRules\Rules;
|
||||
|
||||
class Validation extends BaseConfig
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// Setup
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Stores the classes that contain the
|
||||
* rules that are available.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $ruleSets = [
|
||||
Rules::class,
|
||||
FormatRules::class,
|
||||
FileRules::class,
|
||||
CreditCardRules::class,
|
||||
\App\Validation\CustomRules::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Specifies the views that are used to display the
|
||||
* errors.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $templates = [
|
||||
'list' => 'CodeIgniter\Validation\Views\list',
|
||||
'single' => 'CodeIgniter\Validation\Views\single',
|
||||
];
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Rules
|
||||
// --------------------------------------------------------------------
|
||||
}
|
||||
62
app/Config/View.php
Normal file
62
app/Config/View.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\View as BaseView;
|
||||
use CodeIgniter\View\ViewDecoratorInterface;
|
||||
|
||||
/**
|
||||
* @phpstan-type parser_callable (callable(mixed): mixed)
|
||||
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
|
||||
*/
|
||||
class View extends BaseView
|
||||
{
|
||||
/**
|
||||
* When false, the view method will clear the data between each
|
||||
* call. This keeps your data safe and ensures there is no accidental
|
||||
* leaking between calls, so you would need to explicitly pass the data
|
||||
* to each view. You might prefer to have the data stick around between
|
||||
* calls so that it is available to all views. If that is the case,
|
||||
* set $saveData to true.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $saveData = true;
|
||||
|
||||
/**
|
||||
* Parser Filters map a filter name with any PHP callable. When the
|
||||
* Parser prepares a variable for display, it will chain it
|
||||
* through the filters in the order defined, inserting any parameters.
|
||||
* To prevent potential abuse, all filters MUST be defined here
|
||||
* in order for them to be available for use within the Parser.
|
||||
*
|
||||
* Examples:
|
||||
* { title|esc(js) }
|
||||
* { created_on|date(Y-m-d)|esc(attr) }
|
||||
*
|
||||
* @var array<string, string>
|
||||
* @phpstan-var array<string, parser_callable_string>
|
||||
*/
|
||||
public $filters = [];
|
||||
|
||||
/**
|
||||
* Parser Plugins provide a way to extend the functionality provided
|
||||
* by the core Parser by creating aliases that will be replaced with
|
||||
* any callable. Can be single or tag pair.
|
||||
*
|
||||
* @var array<string, callable|list<string>|string>
|
||||
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
|
||||
*/
|
||||
public $plugins = [];
|
||||
|
||||
/**
|
||||
* View Decorators are class methods that will be run in sequence to
|
||||
* have a chance to alter the generated output just prior to caching
|
||||
* the results.
|
||||
*
|
||||
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
|
||||
*
|
||||
* @var list<class-string<ViewDecoratorInterface>>
|
||||
*/
|
||||
public array $decorators = [];
|
||||
}
|
||||
196
app/Controllers/AbstractCRUDController.php
Normal file
196
app/Controllers/AbstractCRUDController.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Entities\CommonEntity;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* AbstractCRUDController
|
||||
* 단일 레코드 생성(C), 조회(R), 수정(U), 삭제(D) 로직을 담당합니다. (SRP: Single Record Management)
|
||||
*/
|
||||
abstract class AbstractCRUDController extends AbstractWebController
|
||||
{
|
||||
// 💡 핵심 1: 각 자식 클래스가 사용할 Entity 클래스 경로를 반환하도록 강제
|
||||
// 이 메서드는 자식 클래스에서 반드시 구현되어야 합니다.
|
||||
// --- 생성 (Create) ---
|
||||
protected function create_form_process(array $formDatas = []): array
|
||||
{
|
||||
//초기 기본 Default값 지정
|
||||
$formDatas = $this->request->getVar();
|
||||
return $formDatas;
|
||||
}
|
||||
|
||||
protected function create_form_result_process(string $action): string|RedirectResponse
|
||||
{
|
||||
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
|
||||
}
|
||||
|
||||
public function create_form(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$formDatas = $this->create_form_process();
|
||||
$this->action_init_process($action, $formDatas);
|
||||
$this->addViewDatas('formDatas', $formDatas);
|
||||
return $this->create_form_result_process($action);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 생성폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function create_process(array $formDatas): CommonEntity
|
||||
{
|
||||
// POST 데이터를 DTO 객체로 변환
|
||||
$dto = $this->service->createDTO($formDatas);
|
||||
// dd($dto->toArray());
|
||||
//DTO 타입 체크 로직을 일반화
|
||||
$dtoClass = $this->service->getDTOClass();
|
||||
if (!$dto instanceof $dtoClass) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
|
||||
}
|
||||
return $this->service->create($dto->toArray());
|
||||
}
|
||||
|
||||
protected function create_result_process($entity, ?string $redirect_url = null): string|RedirectResponse
|
||||
{
|
||||
return $this->action_redirect_process(
|
||||
'info',
|
||||
"{$this->getTitle()}에서 {$entity->getTitle()} 생성이 완료되었습니다.",
|
||||
$redirect_url ?? '/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
|
||||
);
|
||||
}
|
||||
|
||||
final public function create(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->create_process($this->request->getPost());
|
||||
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
|
||||
$entityClass = $this->service->getEntityClass();
|
||||
if (!$entity instanceof $entityClass) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 {$entityClass}만 가능");
|
||||
}
|
||||
return $this->create_result_process($entity);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 생성 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// --- 수정 (Modify) ---
|
||||
protected function modify_form_process($uid): CommonEntity
|
||||
{
|
||||
return $this->service->getEntity($uid);
|
||||
}
|
||||
|
||||
protected function modify_form_result_process(string $action): string|RedirectResponse
|
||||
{
|
||||
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
|
||||
}
|
||||
|
||||
final public function modify_form($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
if (!$uid) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()}에 번호가 정의 되지 않았습니다.");
|
||||
}
|
||||
$entity = $this->modify_form_process($uid);
|
||||
$this->addViewDatas('entity', $entity);
|
||||
$action = __FUNCTION__;
|
||||
//FormService에서 필요한 기존 데이터를 $entity에서 추출해서 넘김
|
||||
$this->action_init_process($action, $entity->toArray());
|
||||
return $this->modify_form_result_process($action);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 수정폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function modify_process($uid, array $formDatas): CommonEntity
|
||||
{
|
||||
// POST 데이터를 DTO 객체로 변환
|
||||
$formDatas[$this->service->getPKField()] = $uid;
|
||||
$dto = $this->service->createDTO($formDatas);
|
||||
//DTO 타입 체크 로직을 일반화
|
||||
$dtoClass = $this->service->getDTOClass();
|
||||
if (!$dto instanceof $dtoClass) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
|
||||
}
|
||||
return $this->service->modify($uid, $dto->toArray());
|
||||
}
|
||||
|
||||
protected function modify_result_process($entity, ?string $redirect_url = null): string|RedirectResponse
|
||||
{
|
||||
return $this->action_redirect_process(
|
||||
'info',
|
||||
"{$this->getTitle()}에서 {$entity->getTitle()} 수정이 완료되었습니다.",
|
||||
$redirect_url ?? '/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
|
||||
);
|
||||
}
|
||||
final public function modify($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
if (!$uid) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()}에 번호가 정의 되지 않았습니다.");
|
||||
}
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->modify_process($uid, $this->request->getPost());
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->modify_result_process($entity);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 수정 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// --- 삭제 (Delete) ---
|
||||
protected function delete_process($uid): CommonEntity
|
||||
{
|
||||
return $this->service->delete($uid);
|
||||
}
|
||||
protected function delete_result_process($entity, ?string $redirect_url = null): string|RedirectResponse
|
||||
{
|
||||
return $this->action_redirect_process('info', "{$this->getTitle()}에서 {$entity->getTitle()} 삭제가 완료되었습니다.", $redirect_url);
|
||||
}
|
||||
final public function delete($uid): RedirectResponse
|
||||
{
|
||||
try {
|
||||
if (!$uid) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()}에 번호가 정의 되지 않았습니다.");
|
||||
}
|
||||
$entity = $this->service->getEntity($uid);
|
||||
//Delete처리
|
||||
$entity = $this->delete_process($uid);
|
||||
return $this->delete_result_process($entity);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// --- 상세보기 (View) ---
|
||||
protected function view_process($uid): CommonEntity
|
||||
{
|
||||
return $this->service->getEntity($uid);
|
||||
}
|
||||
protected function view_result_process(string $action): string
|
||||
{
|
||||
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
|
||||
}
|
||||
final public function view($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
if (!$uid) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()}에 번호가 정의 되지 않았습니다.");
|
||||
}
|
||||
//View처리
|
||||
$entity = $this->view_process($uid);
|
||||
$action = __FUNCTION__;
|
||||
//FormService에서 필요한 기존 데이터를 $entity에서 추출해서 넘김
|
||||
$this->action_init_process($action, $entity->toArray());
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->view_result_process($action);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 상세보기 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
137
app/Controllers/AbstractWebController.php
Normal file
137
app/Controllers/AbstractWebController.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\AuthContext;
|
||||
use App\Traits\LogTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* CommonController
|
||||
*
|
||||
* 이 클래스를 상속받는 모든 자식 클래스(UserController 등)는
|
||||
* 반드시 'PATH' 상수를 가지고 있음을 IDE에 알려줍니다.
|
||||
* * @property-read string PATH // ⭐ 이 부분이 핵심입니다.
|
||||
*/
|
||||
abstract class AbstractWebController extends Controller
|
||||
{
|
||||
use LogTrait;
|
||||
|
||||
protected $service = null;
|
||||
private array $_action_paths = [];
|
||||
private array $_viewDatas = [];
|
||||
private ?string $_title = null;
|
||||
|
||||
// --- 초기화 및 DI ---
|
||||
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
final protected function getAuthContext(): AuthContext
|
||||
{
|
||||
return service('myauth')->getAuthContext();
|
||||
}
|
||||
|
||||
protected function getTitle(): string
|
||||
{
|
||||
if ($this->_title === null) {
|
||||
// 이 로직은 하위 클래스에서 service가 초기화되었다고 가정합니다.
|
||||
$this->_title = lang("{$this->service->getClassPaths(false)}.title");
|
||||
}
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
// --- 경로 및 뷰 데이터 관리 ---
|
||||
|
||||
final protected function addActionPaths(string $path)
|
||||
{
|
||||
$this->_action_paths[] = $path;
|
||||
}
|
||||
|
||||
final protected function getActionPaths($isArray = true, $delimeter = DIRECTORY_SEPARATOR): array|string
|
||||
{
|
||||
return $isArray ? $this->_action_paths : implode($delimeter, $this->_action_paths);
|
||||
}
|
||||
|
||||
final protected function addViewDatas(string $key, mixed $value)
|
||||
{
|
||||
$this->_viewDatas[$key] = $value;
|
||||
}
|
||||
|
||||
final protected function getViewDatas(?string $key = null): mixed
|
||||
{
|
||||
if ($key === null) {
|
||||
return $this->_viewDatas;
|
||||
}
|
||||
return $this->_viewDatas[$key] ?? null;
|
||||
}
|
||||
|
||||
// --- 공통 처리 로직 (Override 가능) ---
|
||||
|
||||
/**
|
||||
* 모든 액션 실행 전 공통 초기화 작업
|
||||
*/
|
||||
protected function action_init_process(string $action, array $formDatas = []): void
|
||||
{
|
||||
$this->addViewDatas('action', $action);
|
||||
$this->addViewDatas('authContext', $this->getAuthContext());
|
||||
$this->addViewDatas('classPath', $this->service->getClassPaths(false));
|
||||
$this->addViewDatas('uri', $this->request->getUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* 액션 성공 후 모달을 닫고 부모 창을 리로드하는 스크립트를 반환합니다.
|
||||
*/
|
||||
protected function action_redirect_process(string $type, string $message, ?string $redirect_url = null): RedirectResponse
|
||||
{
|
||||
switch ($type) {
|
||||
case 'warning':
|
||||
case 'error':
|
||||
case 'critical':
|
||||
case 'alert':
|
||||
case 'emergency':
|
||||
log_message($type, $message);
|
||||
$result = redirect()->back()->withInput()->with('message', $message);
|
||||
break;
|
||||
case 'debug':
|
||||
case 'info':
|
||||
case 'notice':
|
||||
default:
|
||||
$redirect_url = $redirect_url ?? $this->getAuthContext()->popPreviousUrl() ?? implode(DIRECTORY_SEPARATOR, $this->getActionPaths());
|
||||
$result = redirect()->to($redirect_url)->with('message', $message);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 뷰 경로와 데이터를 이용하여 최종 HTML을 렌더링합니다.
|
||||
*/
|
||||
protected function action_render_process(string $view_file, array $viewDatas, ?string $template_path = null): string
|
||||
{
|
||||
helper(['form', 'IconHelper', 'utility']);
|
||||
$config = config('Layout');
|
||||
$layoutConfig = $config->layouts[$viewDatas['layout']['path']] ?? [];
|
||||
|
||||
$viewDatas['layout'] = array_merge($layoutConfig, $viewDatas['layout']);
|
||||
$view_path = $viewDatas['layout']['path'];
|
||||
if ($template_path) {
|
||||
$view_path .= '/' . $template_path;
|
||||
}
|
||||
// dd($view_path);
|
||||
//최종 ViewPath
|
||||
$viewDatas['view_path'] = $view_path;
|
||||
helper([__FUNCTION__]);
|
||||
return view($view_path . '/' . $view_file, [
|
||||
'viewDatas' => [
|
||||
...$viewDatas,
|
||||
'forms' => ['attributes' => ['method' => "post",], 'hiddens' => []],
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
35
app/Controllers/Admin/AdminController.php
Normal file
35
app/Controllers/Admin/AdminController.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\CommonController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class AdminController extends CommonController
|
||||
{
|
||||
private $_layout = 'admin';
|
||||
protected $layouts = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->addActionPaths($this->_layout);
|
||||
$this->layouts = config('Layout')->layouts[$this->_layout] ?? [];
|
||||
}
|
||||
protected function action_init_process(string $action, array $formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$this->addViewDatas('layout', $this->layouts);
|
||||
$this->addViewDatas('title', $this->getTitle());
|
||||
$this->addViewDatas('helper', $this->service->getHelper());
|
||||
$this->service->getActionForm()->action_init_process($action, $formDatas);
|
||||
$this->addViewDatas('formFields', $this->service->getActionForm()->getFormFields());
|
||||
$this->addViewDatas('formRules', $this->service->getActionForm()->getFormRules());
|
||||
$this->addViewDatas('formFilters', $this->service->getActionForm()->getFormFilters());
|
||||
$this->addViewDatas('formOptions', $this->service->getActionForm()->getFormOptions());
|
||||
$this->addViewDatas('index_actionButtons', $this->service->getActionForm()->getActionButtons());
|
||||
$this->addViewDatas('index_batchjobFields', $this->service->getActionForm()->getBatchjobFilters());
|
||||
$this->addViewDatas('index_batchjobButtons', $this->service->getActionForm()->getBatchjobButtons());
|
||||
}
|
||||
}
|
||||
33
app/Controllers/Admin/BoardController.php
Normal file
33
app/Controllers/Admin/BoardController.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Entities\BoardEntity;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BoardController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('boardservice');
|
||||
}
|
||||
$this->addActionPaths('board');
|
||||
}
|
||||
//Action작업관련
|
||||
//기본 함수 작업
|
||||
//Custom 추가 함수
|
||||
public function latest(string $category): ResponseInterface
|
||||
{
|
||||
$this->action_init_process(__FUNCTION__);
|
||||
return $this->response->setJSON($this->service->getLatest($category));
|
||||
}
|
||||
public function reqeusttask(): ResponseInterface
|
||||
{
|
||||
$this->action_init_process(__FUNCTION__);
|
||||
return $this->response->setJSON($this->service->getRequestTaskCount($this->getAuthContext()->getUID()));
|
||||
}
|
||||
}
|
||||
58
app/Controllers/Admin/Home.php
Normal file
58
app/Controllers/Admin/Home.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\AbstractWebController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Home extends AbstractWebController
|
||||
{
|
||||
private $_layout = 'admin';
|
||||
protected $layouts = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('customer_serviceservice');
|
||||
}
|
||||
$this->addActionPaths($this->_layout);
|
||||
$this->layouts = config('Layout')->layouts[$this->_layout] ?? [];
|
||||
}
|
||||
protected function action_init_process(string $action, array $formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$this->addViewDatas('layout', $this->layouts);
|
||||
$this->addViewDatas('helper', $this->service->getHelper());
|
||||
$this->service->getActionForm()->action_init_process($action, $formDatas);
|
||||
$this->addViewDatas('formFields', $this->service->getActionForm()->getFormFields());
|
||||
$this->addViewDatas('formRules', $this->service->getActionForm()->getFormRules());
|
||||
$this->addViewDatas('formFilters', $this->service->getActionForm()->getFormFilters());
|
||||
$this->addViewDatas('formOptions', $this->service->getActionForm()->getFormOptions());
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
public function index(): string
|
||||
{
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
//요청업무
|
||||
$this->addViewDatas('boardRequestTaskCount', service('boardservice')->getRequestTaskCount($this->getAuthContext()->getUID()));
|
||||
//Total 서버 현황
|
||||
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
||||
$interval = intval($this->request->getVar('interval') ?? SERVICE['NEW_INTERVAL']);
|
||||
$this->addViewDatas('interval', $interval);
|
||||
$newServiceEntities = $this->service->getNewServiceEntities($interval);
|
||||
$this->addViewDatas('newServiceEntities', $newServiceEntities);
|
||||
$this->addViewDatas('newServiceCount', count($newServiceEntities));
|
||||
//서비스별 미납 Count
|
||||
$unPaidTotalCount = $unPaidTotalAmount = 0;
|
||||
foreach (array_values(service('paymentservice')->getUnPaids('serviceinfo_uid')) as $unPaid) {
|
||||
$unPaidTotalCount += $unPaid['cnt'];
|
||||
$unPaidTotalAmount += $unPaid['amount'];
|
||||
}
|
||||
$this->addViewDatas('unPaidTotalCount', $unPaidTotalCount);
|
||||
$this->addViewDatas('unPaidTotalAmount', $unPaidTotalAmount);
|
||||
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate') ?? "welcome");
|
||||
}
|
||||
}
|
||||
23
app/Controllers/Admin/UserController.php
Normal file
23
app/Controllers/Admin/UserController.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Entities\UserEntity;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class UserController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('userservice');
|
||||
}
|
||||
$this->addActionPaths('user');
|
||||
}
|
||||
//Action작업관련
|
||||
//기본 함수 작업
|
||||
//Custom 추가 함수
|
||||
}
|
||||
72
app/Controllers/Auth/AuthController.php
Normal file
72
app/Controllers/Auth/AuthController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Auth;
|
||||
|
||||
use App\Controllers\AbstractWebController;
|
||||
use App\Entities\UserEntity;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class AuthController extends AbstractWebController
|
||||
{
|
||||
private $_layout = 'auth';
|
||||
protected $layouts = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->addActionPaths($this->_layout);
|
||||
$this->layouts = config('Layout')->layouts[$this->_layout] ?? [];
|
||||
}
|
||||
protected function action_init_process(string $action, array $formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$this->addViewDatas('layout', $this->layouts);
|
||||
$this->addViewDatas('helper', $this->service->getHelper());
|
||||
//Fields,Rules,Filters,Options등 초기화
|
||||
$this->service->getActionForm()->action_init_process($action, $formDatas);
|
||||
$this->addViewDatas('formFields', $this->service->getActionForm()->getFormFields());
|
||||
$this->addViewDatas('formRules', $this->service->getActionForm()->getFormRules());
|
||||
$this->addViewDatas('formFilters', $this->service->getActionForm()->getFormFilters());
|
||||
$this->addViewDatas('formOptions', $this->service->getActionForm()->getFormOptions());
|
||||
}
|
||||
//로그인화면
|
||||
final public function login_form(): string|RedirectResponse
|
||||
{
|
||||
$action = __FUNCTION__;
|
||||
try {
|
||||
//초기화
|
||||
$this->action_init_process($action);
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', $e->getMessage());
|
||||
session()->setFlashdata('message', $e->getMessage());
|
||||
}
|
||||
return $this->action_render_process($action, $this->getViewDatas());
|
||||
}
|
||||
//로그인처리
|
||||
abstract protected function login_process(): UserEntity;
|
||||
final public function login(): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->login_process();
|
||||
$redirect_url = $this->getAuthContext()->popPreviousUrl() ?? implode(DIRECTORY_SEPARATOR, $this->getActionPaths());
|
||||
return redirect()->to($redirect_url)->with('message', MESSAGES['LOGIN']);
|
||||
} catch (\Throwable $e) {
|
||||
return redirect()->back()->withInput()->with('message', "로그인 중 오류발생:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
//로그아웃
|
||||
abstract protected function logout_process(): void;
|
||||
final public function logout(): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->logout_process();
|
||||
// 홈페이지로 리다이렉트
|
||||
$redirect_url = $this->getAuthContext()->popPreviousUrl() ?? "/";
|
||||
return redirect()->route($redirect_url)->with('message', MESSAGES['LOGOUT']);
|
||||
} catch (\Throwable $e) {
|
||||
return redirect()->back()->withInput()->with('message', "로그아웃 중 오류발생:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
35
app/Controllers/Auth/GoogleController.php
Normal file
35
app/Controllers/Auth/GoogleController.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Auth;
|
||||
|
||||
use App\DTOs\Auth\GoogleDTO;
|
||||
use App\Entities\UserEntity;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class GoogleController extends AuthController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('googleauth');
|
||||
}
|
||||
}
|
||||
public function login_form_process(): void
|
||||
{
|
||||
//구글 로그인 BUTTON용
|
||||
$this->addViewDatas('SNSButton', anchor($this->service->socket->createAuthUrl(), ICONS['GOOGLE'] . 'Google 로그인', ["class" => "btn-google"]));
|
||||
}
|
||||
//로그인처리
|
||||
protected function login_process(): UserEntity
|
||||
{
|
||||
//요청 데이터를 DTO 객체로 변환
|
||||
return $this->service->login(new GoogleDTO($this->request->getPost()));
|
||||
}
|
||||
protected function logout_process(): void
|
||||
{
|
||||
$this->service->logout();
|
||||
}
|
||||
}
|
||||
34
app/Controllers/Auth/LocalController.php
Normal file
34
app/Controllers/Auth/LocalController.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Auth;
|
||||
|
||||
use App\DTOs\Auth\LocalDTO;
|
||||
use App\Entities\UserEntity;
|
||||
use App\Services\Auth\LocalService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @property LocalService $service
|
||||
* IDE에게 protected $service 속성이 LocalService 타입임을 알려줍니다.
|
||||
*/
|
||||
class LocalController extends AuthController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('localauth');
|
||||
}
|
||||
}
|
||||
//로그인처리
|
||||
protected function login_process(): UserEntity
|
||||
{
|
||||
return $this->service->login(new LocalDTO($this->request->getPost()));
|
||||
}
|
||||
protected function logout_process(): void
|
||||
{
|
||||
$this->service->logout();
|
||||
}
|
||||
}
|
||||
45
app/Controllers/BaseController.php
Normal file
45
app/Controllers/BaseController.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* BaseController provides a convenient place for loading components
|
||||
* and performing functions that are needed by all your controllers.
|
||||
*
|
||||
* Extend this class in any new controllers:
|
||||
* ```
|
||||
* class Home extends BaseController
|
||||
* ```
|
||||
*
|
||||
* For security, be sure to declare any new methods as protected or private.
|
||||
*/
|
||||
abstract class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
// Load here all helpers you want to be available in your controllers that extend BaseController.
|
||||
// Caution: Do not put the this below the parent::initController() call below.
|
||||
// $this->helpers = ['form', 'url'];
|
||||
|
||||
// Caution: Do not edit this line.
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
// Preload any models, libraries, etc, here.
|
||||
// $this->session = service('session');
|
||||
}
|
||||
}
|
||||
291
app/Controllers/CommonController.php
Normal file
291
app/Controllers/CommonController.php
Normal file
@ -0,0 +1,291 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Html;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* CommonController
|
||||
* 목록(index), 일괄작업(batchjob), 일괄삭제, 다운로드 로직을 담당합니다. (SRP: Collection Management)
|
||||
*/
|
||||
abstract class CommonController extends AbstractCRUDController
|
||||
{
|
||||
// --- 일괄 작업 (Batch Job) ---
|
||||
protected function batchjob_pre_process(array $postDatas): array
|
||||
{
|
||||
// 1. postDatas에서 선택된 uids 정보 추출
|
||||
$uids = $postDatas['batchjob_uids'] ?? [];
|
||||
if (empty($uids)) {
|
||||
throw new RuntimeException("{$this->getTitle()}에서 일괄작업에 적용할 리스트을 선택하셔야합니다.");
|
||||
}
|
||||
// 2. 변경할 데이터 추출 및 정리
|
||||
unset($postDatas['batchjob_uids'], $postDatas['batchjob_submit']); //formDatas에 포함되지 않게하기위함
|
||||
$formDatas = array_filter($postDatas, fn($value) => $value !== "" && $value !== null);
|
||||
if (empty($formDatas)) {
|
||||
throw new RuntimeException(message: "{$this->getTitle()}에서 일괄작업에 변경할 조건항목을 선택하셔야합니다.");
|
||||
}
|
||||
// 3. 데이터가 있는 필드 추출
|
||||
return array($uids, $formDatas);
|
||||
}
|
||||
|
||||
protected function batchjob_process(array $uids, array $formDatas): array
|
||||
{
|
||||
return $this->service->batchjob($uids, $formDatas);
|
||||
}
|
||||
|
||||
protected function batchjob_result_process(array $uids, array $entities): string|RedirectResponse
|
||||
{
|
||||
return $this->action_redirect_process('info', sprintf(
|
||||
"%s에서 %s개 처리완료 총:%s개 수정이 완료되었습니다.",
|
||||
$this->getTitle(),
|
||||
count($entities),
|
||||
count($uids)
|
||||
));
|
||||
}
|
||||
final public function batchjob(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
// 사전작업 및 데이터 추출 초기화
|
||||
list($uids, $formDatas) = $this->batchjob_pre_process($this->request->getPost());
|
||||
$entities = $this->batchjob_process($uids, $formDatas);
|
||||
return $this->batchjob_result_process($uids, $entities);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 일괄수정 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
// --- 일괄 삭제 (Batch Job Delete) ---
|
||||
|
||||
protected function batchjob_delete_pre_process(array $postDatas): array
|
||||
{
|
||||
$uids = $postDatas['batchjob_uids'] ?? [];
|
||||
if (empty($uids)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 삭제할 리스트을 선택하셔야합니다.");
|
||||
}
|
||||
return $uids;
|
||||
}
|
||||
|
||||
protected function batchjob_delete_result_process(array $uids, array $entities): string|RedirectResponse
|
||||
{
|
||||
return $this->action_redirect_process('info', sprintf(
|
||||
"%s에서 %s개 처리완료, 총:%s개 일괄삭제가 완료되었습니다.",
|
||||
$this->getTitle(),
|
||||
count($entities),
|
||||
count($uids)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 삭제 로직을 재사용 (Override 가능)
|
||||
*/
|
||||
protected function batchjob_delete_process(array $uids): array
|
||||
{
|
||||
return $this->service->batchjob_delete($uids);
|
||||
}
|
||||
final public function batchjob_delete(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$uids = $this->batchjob_delete_pre_process($this->request->getPost());
|
||||
$entities = $this->batchjob_delete_process($uids);
|
||||
return $this->batchjob_delete_result_process($uids, $entities);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 일괄삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// --- 목록 (Index / List) 관련 ---
|
||||
|
||||
/**
|
||||
* 조건절(필터, 검색어, 날짜, 정렬)을 처리합니다. (Override 가능)
|
||||
*/
|
||||
protected function index_condition_process(string $action): void
|
||||
{
|
||||
// Filter조건절 처리
|
||||
$index_filters = [];
|
||||
// dd($this->service->getActionForm()->getIndexFilters($action));
|
||||
foreach ($this->service->getActionForm()->getIndexFilters($action) as $field) {
|
||||
$value = $this->request->getVar($field) ?? null;
|
||||
if ($value) {
|
||||
$this->service->setFilter($field, $value);
|
||||
}
|
||||
$index_filters[$field] = $value;
|
||||
}
|
||||
$this->addViewDatas('index_filters', $index_filters);
|
||||
|
||||
// 검색어조건절 처리
|
||||
$index_word = $this->request->getVar('index_word');
|
||||
if ($index_word !== null && $index_word !== '') {
|
||||
$this->service->setSearchWord($index_word);
|
||||
}
|
||||
$this->addViewDatas('index_word', $index_word);
|
||||
|
||||
// 날자검색
|
||||
$index_start = $this->request->getVar('index_start');
|
||||
$index_end = $this->request->getVar('index_end');
|
||||
if ($index_start !== null && $index_start !== '' && $index_end !== null && $index_end !== '') {
|
||||
$this->service->setDateFilter($index_start, $index_end);
|
||||
}
|
||||
$this->addViewDatas('index_start', $index_start);
|
||||
$this->addViewDatas('index_end', $index_end);
|
||||
|
||||
// OrderBy처리
|
||||
$order_field = $this->request->getVar('order_field');
|
||||
$order_value = $this->request->getVar('order_value');
|
||||
$this->service->setOrderBy($order_field, $order_value);
|
||||
$this->addViewDatas('order_field', $order_field);
|
||||
$this->addViewDatas('order_value', $order_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagenation Select Box 옵션을 생성합니다. (Override 가능)
|
||||
*/
|
||||
protected function pagenation_options_process(int $index_totalcount, int $perpage): array
|
||||
{
|
||||
$page_options = ["" => "줄수선택"];
|
||||
// 기존 로직 유지
|
||||
for ($i = $perpage; $i <= $index_totalcount; $i += $perpage) {
|
||||
$page_options[$i] = $i;
|
||||
}
|
||||
$page_options[$index_totalcount] = $index_totalcount;
|
||||
return $page_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* PageNation 링크를 생성하고 뷰 데이터에 추가합니다. (Override 가능)
|
||||
*/
|
||||
protected function pagenation_process(int $index_totalcount, int $page, int $perpage, $pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): mixed
|
||||
{
|
||||
$pager = service("pager");
|
||||
$pager->makeLinks($page, $perpage, $index_totalcount, $template, $segment, $pager_group);
|
||||
$this->addViewDatas('index_totalpage', $pager->getPageCount($pager_group));
|
||||
return $pager->links($pager_group, $template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Service에서 엔티티 목록을 가져와 처리합니다. (Override 가능)
|
||||
*/
|
||||
protected function index_entities_process(array $entities = []): array
|
||||
{
|
||||
foreach ($this->service->getEntities() as $entity) {
|
||||
$entities[] = $entity;
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
|
||||
protected function index_result_process(string $action): string
|
||||
{
|
||||
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 인덱스(목록) 페이지의 메인 로직입니다.
|
||||
*/
|
||||
protected function index_process(string $action): void
|
||||
{
|
||||
// 현재 URL을 이전 URL 스택에 저장
|
||||
$this->getAuthContext()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
|
||||
$this->addViewDatas('uri', $this->request->getUri());
|
||||
// Paging 설정
|
||||
$page = (int) $this->request->getVar('page') ?: 1;
|
||||
$perpage = (int) $this->request->getVar('perpage') ?: intval(DEFAULTS['INDEX_PERPAGE'] ?? 10);
|
||||
$this->addViewDatas('page', $page);
|
||||
$this->addViewDatas('perpage', $perpage);
|
||||
// 1. Total Count 계산을 위한 조건절 처리 (오버라이드 가능)
|
||||
$this->index_condition_process($action);
|
||||
$index_totalcount = $this->service->getTotalCount();
|
||||
$this->addViewDatas('index_totalcount', $index_totalcount);
|
||||
// Pagination 설정
|
||||
$this->addViewDatas('index_pagination', $this->pagenation_process($index_totalcount, $page, $perpage));
|
||||
$this->addViewDatas('index_pagination_options', $this->pagenation_options_process($index_totalcount, $perpage));
|
||||
// 2. 실제 리스트를 위한 조건절, LIMIT, OFFSET 처리 (오버라이드 가능)
|
||||
$this->index_condition_process($action); // 조건절을 다시 호출하여 필터/검색어 유지
|
||||
$this->service->setLimit($perpage);
|
||||
$this->service->setOffset(($page - 1) * $perpage);
|
||||
// Entities 처리
|
||||
$this->addViewDatas('entities', $this->index_entities_process());
|
||||
helper(['form']);
|
||||
$this->addViewDatas('formDatas', $this->request->getVar() ?? []);
|
||||
}
|
||||
|
||||
final public function index(): string
|
||||
{
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$this->index_process($action);
|
||||
return $this->index_result_process($action);
|
||||
}
|
||||
|
||||
// --- 문서 다운로드 (Download) ---
|
||||
protected function downloadByDocumentType(string $document_type, mixed $loaded_data): array
|
||||
{
|
||||
$full_path = WRITEPATH . DIRECTORY_SEPARATOR . "download";
|
||||
switch ($document_type) {
|
||||
case 'excel':
|
||||
$file_name = sprintf("%s_%s.xlsx", $this->service->getClassPaths(false, "_"), date('Y-m-d_Hm'));
|
||||
$writer = IOFactory::createWriter($loaded_data, 'Xlsx');
|
||||
$writer->save($full_path . DIRECTORY_SEPARATOR . $file_name);
|
||||
break;
|
||||
case 'pdf':
|
||||
$file_name = sprintf("%s_%s.pdf", $this->service->getClassPaths(false, "_"), date('Y-m-d_Hm'));
|
||||
$writer = new Mpdf($loaded_data);
|
||||
$writer->save($full_path . DIRECTORY_SEPARATOR . $file_name);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 지원하지 않는 다운로드 타입입니다: {$document_type}");
|
||||
}
|
||||
return array($full_path, $file_name);
|
||||
}
|
||||
|
||||
protected function download_process(string $action, string $output_type, mixed $uid = null): DownloadResponse|RedirectResponse|string
|
||||
{
|
||||
switch ($output_type) {
|
||||
case 'excel':
|
||||
case 'pdf':
|
||||
helper(['form']);
|
||||
// 전체 목록을 다운로드하므로, 목록 조건절을 처리합니다.
|
||||
$this->index_condition_process($action);
|
||||
$this->addViewDatas('entities', $this->index_entities_process());
|
||||
|
||||
// HTML로 렌더링된 내용을 가져옵니다.
|
||||
$html = $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
|
||||
|
||||
// HTML을 PhpSpreadsheet 객체로 로드합니다.
|
||||
$reader = new Html();
|
||||
$loaded_data = $reader->loadFromString($html);
|
||||
|
||||
// 파일 저장 및 정보 가져오기
|
||||
list($full_path, $file_name) = $this->downloadByDocumentType($output_type, $loaded_data);
|
||||
$full_path .= DIRECTORY_SEPARATOR . $file_name;
|
||||
break;
|
||||
default:
|
||||
// 개별 파일 다운로드 로직
|
||||
if (!$uid) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$output_type}은 반드시 uid의 값이 필요합니다.");
|
||||
}
|
||||
$entity = $this->service->getEntity($uid);
|
||||
if (!$entity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
list($file_name, $uploaded_filename) = $entity->getDownlaodFile();
|
||||
$full_path = WRITEPATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . $uploaded_filename;
|
||||
break;
|
||||
}
|
||||
return $this->response->download($full_path, null)->setFileName($file_name);
|
||||
}
|
||||
final public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
return $this->download_process($action, $output_type, $uid);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 다운로드 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
11
app/Controllers/Home.php
Normal file
11
app/Controllers/Home.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class Home extends BaseController
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
return view('welcome_message');
|
||||
}
|
||||
}
|
||||
13
app/DTOs/Auth/AuthDTO.php
Normal file
13
app/DTOs/Auth/AuthDTO.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Auth;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
abstract class AuthDTO extends CommonDTO
|
||||
{
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
13
app/DTOs/Auth/GoogleDTO.php
Normal file
13
app/DTOs/Auth/GoogleDTO.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Auth;
|
||||
|
||||
class GoogleDTO extends AuthDTO
|
||||
{
|
||||
|
||||
public $access_code = null;
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
14
app/DTOs/Auth/LocalDTO.php
Normal file
14
app/DTOs/Auth/LocalDTO.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Auth;
|
||||
|
||||
class LocalDTO extends AuthDTO
|
||||
{
|
||||
public ?string $id = null;
|
||||
public ?string $passwd = null;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
19
app/DTOs/BoardDTO.php
Normal file
19
app/DTOs/BoardDTO.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class BoardDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public ?int $worker_uid = null;
|
||||
public string $category = '';
|
||||
public string $title = '';
|
||||
public string $status = '';
|
||||
public string $content = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
72
app/DTOs/CommonDTO.php
Normal file
72
app/DTOs/CommonDTO.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionNamedType;
|
||||
|
||||
abstract class CommonDTO
|
||||
{
|
||||
protected function __construct(array $datas = [])
|
||||
{
|
||||
if (empty($datas))
|
||||
return;
|
||||
|
||||
$reflection = new ReflectionClass($this);
|
||||
|
||||
foreach ($datas as $key => $value) {
|
||||
if (!$reflection->hasProperty($key))
|
||||
continue;
|
||||
|
||||
$property = $reflection->getProperty($key);
|
||||
$type = $property->getType();
|
||||
$assignValue = $value;
|
||||
|
||||
// *_uid 규칙 처리
|
||||
if ($value === '' && preg_match('/_uid$/', $key)) {
|
||||
if ($type instanceof ReflectionNamedType && $type->allowsNull()) {
|
||||
$this->{$key} = null;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 1) 기존: 빈 문자열('') 처리
|
||||
if ($value === '') {
|
||||
if ($type instanceof ReflectionNamedType && $type->allowsNull()) {
|
||||
$assignValue = null;
|
||||
} else {
|
||||
$typeName = ($type instanceof ReflectionNamedType) ? $type->getName() : '';
|
||||
$assignValue = ($typeName === 'int' || $typeName === 'float') ? 0 : '';
|
||||
}
|
||||
}
|
||||
// 2) 기존: 타입별 캐스팅
|
||||
elseif ($type instanceof ReflectionNamedType) {
|
||||
$typeName = $type->getName();
|
||||
|
||||
if ($typeName === 'array' && is_string($value)) {
|
||||
$assignValue = explode(DEFAULTS["DELIMITER_COMMA"], $value);
|
||||
} elseif ($typeName === 'int' && is_numeric($value)) {
|
||||
$assignValue = (int) $value;
|
||||
} elseif ($typeName === 'float' && is_numeric($value)) {
|
||||
$assignValue = (float) $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->{$key} = $assignValue;
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$reflection = new ReflectionClass($this);
|
||||
$properties = $reflection->getProperties();
|
||||
$result = [];
|
||||
|
||||
foreach ($properties as $property) {
|
||||
$name = $property->getName();
|
||||
$result[$name] = $this->{$name};
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
40
app/DTOs/UserDTO.php
Normal file
40
app/DTOs/UserDTO.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class UserDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public string $id = '';
|
||||
public string $passwd = '';
|
||||
public string $confirmpassword = '';
|
||||
public string $name = '';
|
||||
public string $email = '';
|
||||
public string $mobile = '';
|
||||
public array $role = [];
|
||||
public string $status = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
// 1. [전처리] 입력값이 문자열(CSV)로 들어왔다면 배열로 변환
|
||||
if (isset($datas['role']) && is_string($datas['role'])) {
|
||||
$datas['role'] = explode(DEFAULTS["DELIMITER_COMMA"], $datas['role']);
|
||||
}
|
||||
|
||||
// 2. 만약 데이터가 없다면 빈 배열로 초기화
|
||||
if (!isset($datas['role'])) {
|
||||
$datas['role'] = [];
|
||||
}
|
||||
|
||||
// 3. 부모 생성자 호출
|
||||
parent::__construct($datas);
|
||||
}
|
||||
|
||||
/**
|
||||
* DB 저장용(Entity 전달용) CSV 문자열이 필요할 때 사용합니다.
|
||||
*/
|
||||
public function getRoleToString(): string
|
||||
{
|
||||
return implode(DEFAULTS["DELIMITER_COMMA"], $this->role);
|
||||
}
|
||||
}
|
||||
0
app/Database/Migrations/.gitkeep
Normal file
0
app/Database/Migrations/.gitkeep
Normal file
0
app/Database/Seeds/.gitkeep
Normal file
0
app/Database/Seeds/.gitkeep
Normal file
40
app/Entities/BoardEntity.php
Normal file
40
app/Entities/BoardEntity.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Models\BoardModel as Model;
|
||||
|
||||
class BoardEntity extends CommonEntity
|
||||
{
|
||||
const PK = Model::PK;
|
||||
const TITLE = Model::TITLE;
|
||||
protected array $nullableFields = [
|
||||
'user_uid',
|
||||
'worker_uid',
|
||||
];
|
||||
protected $attributes = [
|
||||
'user_uid' => null,
|
||||
'worker_uid' => null,
|
||||
'category' => '',
|
||||
'title' => '',
|
||||
'status' => '',
|
||||
'content' => ''
|
||||
];
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
public function getUserUid(): int|null
|
||||
{
|
||||
return $this->user_uid ?? null;
|
||||
}
|
||||
public function getWorkerUid(): int|null
|
||||
{
|
||||
return $this->worker_uid ?? null;
|
||||
}
|
||||
public function getCaregory(): string
|
||||
{
|
||||
return $this->category ?? "";
|
||||
}
|
||||
}
|
||||
92
app/Entities/CommonEntity.php
Normal file
92
app/Entities/CommonEntity.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
abstract class CommonEntity extends Entity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* 이 엔티티에서 "빈문자/공백 입력은 NULL로 저장"해야 하는 필드 목록.
|
||||
* 기본은 빈 배열이고, 각 Entity에서 필요한 것만 override해서 채우면 됨.
|
||||
*/
|
||||
protected array $nullableFields = [];
|
||||
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
final public function __get(string $key)
|
||||
{
|
||||
if (array_key_exists($key, $this->attributes)) {
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
return parent::__get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 중요: Entity에 값이 들어오는 "모든 경로" (new Entity($data), fill(), $entity->field=...)
|
||||
* 에서 공통 규칙을 적용하기 위해 __set을 정의.
|
||||
*/
|
||||
final public function __set(string $key, $value = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->attributes)) {
|
||||
|
||||
// 이 엔티티에서 NULL로 보정할 필드만 처리 (화이트리스트)
|
||||
if (!empty($this->nullableFields) && in_array($key, $this->nullableFields, true)) {
|
||||
if (is_string($value)) {
|
||||
$value = trim($value);
|
||||
}
|
||||
$this->attributes[$key] = ($value === '' || $value === null) ? null : $value;
|
||||
return;
|
||||
}
|
||||
|
||||
// 기본: 그대로 저장
|
||||
$this->attributes[$key] = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::__set($key, $value);
|
||||
}
|
||||
|
||||
final public function getPK(): int|string
|
||||
{
|
||||
$field = constant("static::PK");
|
||||
return $this->attributes[$field] ?? "";
|
||||
}
|
||||
|
||||
final public function getTitle(): string
|
||||
{
|
||||
$field = constant("static::TITLE");
|
||||
return $this->attributes[$field] ?? "";
|
||||
}
|
||||
|
||||
public function getCustomTitle(): string
|
||||
{
|
||||
return $this->getTitle();
|
||||
}
|
||||
|
||||
final public function getStatus(): string
|
||||
{
|
||||
return $this->status ?? "";
|
||||
}
|
||||
|
||||
final public function getUpdatedAt(): string
|
||||
{
|
||||
return $this->updated_at ?? "";
|
||||
}
|
||||
|
||||
final public function getCreatedAt(): string
|
||||
{
|
||||
return $this->created_at ?? "";
|
||||
}
|
||||
|
||||
final public function getDeletedAt(): string
|
||||
{
|
||||
return $this->deleted_at ?? "";
|
||||
}
|
||||
}
|
||||
127
app/Entities/UserEntity.php
Normal file
127
app/Entities/UserEntity.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Models\UserModel as Model;
|
||||
|
||||
class UserEntity extends CommonEntity
|
||||
{
|
||||
const PK = Model::PK;
|
||||
const TITLE = Model::TITLE;
|
||||
|
||||
protected array $nullableFields = [
|
||||
'mobile',
|
||||
// uid 같은 숫자 PK가 nullable이면 여기에 추가
|
||||
];
|
||||
|
||||
// ✅ role은 반드시 "문자열" 기본값 (DB 저장형)
|
||||
protected $attributes = [
|
||||
'id' => '',
|
||||
'passwd' => '',
|
||||
'name' => '',
|
||||
'email' => '',
|
||||
'mobile' => null,
|
||||
'role' => '', // ✅ array 금지
|
||||
'status' => '',
|
||||
];
|
||||
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
public function getID(): string
|
||||
{
|
||||
return (string) ($this->attributes['id'] ?? '');
|
||||
}
|
||||
|
||||
public function getPassword(): string
|
||||
{
|
||||
return (string) ($this->attributes['passwd'] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* role을 "배열"로 반환 (DB에는 CSV/JSON/배열 무엇이든 복구)
|
||||
*/
|
||||
public function getRole(): array
|
||||
{
|
||||
$role = $this->attributes['role'] ?? null;
|
||||
|
||||
if (is_array($role)) {
|
||||
return array_values(array_filter($role, fn($v) => (string) $v !== ''));
|
||||
}
|
||||
|
||||
if (is_string($role) && $role !== '') {
|
||||
// JSON 시도
|
||||
$decoded = json_decode($role, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
||||
$clean = array_map(
|
||||
fn($item) => trim((string) ($item ?? ''), " \t\n\r\0\x0B\""),
|
||||
$decoded
|
||||
);
|
||||
return array_values(array_filter($clean, fn($v) => $v !== ''));
|
||||
}
|
||||
|
||||
// CSV fallback
|
||||
$parts = explode(DEFAULTS["DELIMITER_COMMA"], $role);
|
||||
$clean = array_map(
|
||||
fn($item) => trim((string) ($item ?? ''), " \t\n\r\0\x0B\""),
|
||||
$parts
|
||||
);
|
||||
return array_values(array_filter($clean, fn($v) => $v !== ''));
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* ✅ CI4 뮤테이터: "return 값"이 attributes에 저장됨
|
||||
* - 빈값이면 기존값 유지 (create에서 required면 validate에서 걸러짐)
|
||||
*/
|
||||
public function setPasswd($password): string
|
||||
{
|
||||
// null/'' 이면 기존값 유지
|
||||
if (!is_string($password) || $password === '') {
|
||||
return (string) ($this->attributes['passwd'] ?? '');
|
||||
}
|
||||
|
||||
return password_hash($password, PASSWORD_BCRYPT);
|
||||
}
|
||||
|
||||
/**
|
||||
* ✅ role은 최종적으로 "CSV 문자열"로 저장 (DB 안전)
|
||||
*/
|
||||
public function setRole($role): string
|
||||
{
|
||||
$roleArray = [];
|
||||
|
||||
if (is_string($role)) {
|
||||
$clean = trim($role, " \t\n\r\0\x0B\"");
|
||||
if ($clean !== '') {
|
||||
// JSON 문자열 가능성도 있어서 먼저 JSON 시도
|
||||
$decoded = json_decode($clean, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
||||
$roleArray = $decoded;
|
||||
} else {
|
||||
$roleArray = explode(DEFAULTS["DELIMITER_COMMA"], $clean);
|
||||
}
|
||||
}
|
||||
} elseif (is_array($role)) {
|
||||
$roleArray = $role;
|
||||
} else {
|
||||
// 그 외 타입은 안전하게 빈값 처리
|
||||
$roleArray = [];
|
||||
}
|
||||
|
||||
$cleaned = array_map(
|
||||
fn($item) => trim((string) ($item ?? ''), " \t\n\r\0\x0B\""),
|
||||
$roleArray
|
||||
);
|
||||
|
||||
$roleArray = array_values(array_filter($cleaned, fn($v) => $v !== ''));
|
||||
|
||||
// ✅ 무조건 문자열 반환 (빈 배열이면 '')
|
||||
return implode(DEFAULTS["DELIMITER_COMMA"], $roleArray);
|
||||
}
|
||||
}
|
||||
0
app/Filters/.gitkeep
Normal file
0
app/Filters/.gitkeep
Normal file
60
app/Filters/AuthFilter.php
Normal file
60
app/Filters/AuthFilter.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
|
||||
class AuthFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Do whatever processing this filter needs to do.
|
||||
* By default it should not return anything during
|
||||
* normal execution. However, when an abnormal state
|
||||
* is found, it should return an instance of
|
||||
* CodeIgniter\HTTP\Response. If it does, script
|
||||
* execution will end and that Response will be
|
||||
* sent back to the client, allowing for error pages,
|
||||
* redirects, etc.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param array|null $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$authContext = service('myauth')->getAuthContext();
|
||||
// var_dump($arguments);
|
||||
// log_message("debug", var_export($arguments, true));
|
||||
// exit;
|
||||
// 로그인 않했으면
|
||||
if (!$authContext->isLoggedIn()) {
|
||||
$authContext->pushCurrentUrl($request->getUri()->getPath() . ($request->getUri()->getQuery() ? "?" . $request->getUri()->getQuery() : ""));
|
||||
return redirect()->to(URLS['LOGIN'])->with('message', '로그인을하셔야합니다.');
|
||||
}
|
||||
//User Role 비교 // 회원 ROLES이 필요ROLE($arguments) 목록에 존재하지 않으면(ACL)
|
||||
if (!$authContext->isAccessRole($arguments)) {
|
||||
return redirect()->back()->with('message', "회원[{$authContext->getName()}]님은 접속에 필요한 권한이 없습니다. ");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows After filters to inspect and modify the response
|
||||
* object as needed. This method does not allow any way
|
||||
* to stop execution of other after filters, short of
|
||||
* throwing an Exception or Error.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @param array|null $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
39
app/Forms/Auth/GoogleForm.php
Normal file
39
app/Forms/Auth/GoogleForm.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Auth;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class GoogleForm extends CommonForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
$fields = ['access_code'];
|
||||
$filters = [];
|
||||
switch ($action) {
|
||||
case 'login':
|
||||
case 'login_form':
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters);
|
||||
$this->setBatchjobFilters($filters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "access_code":
|
||||
$formRules[$field] = "required|trim|string";
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
}
|
||||
43
app/Forms/Auth/LocalForm.php
Normal file
43
app/Forms/Auth/LocalForm.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Auth;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class LocalForm extends CommonForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
$fields = ['id', 'passwd'];
|
||||
$filters = [];
|
||||
switch ($action) {
|
||||
case 'login':
|
||||
case 'login_form':
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters);
|
||||
$this->setBatchjobFilters($filters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "id":
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "passwd":
|
||||
$formRules[$field] = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
}
|
||||
107
app/Forms/BoardForm.php
Normal file
107
app/Forms/BoardForm.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class BoardForm extends CommonForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
$fields = [
|
||||
'category',
|
||||
'worker_uid',
|
||||
'title',
|
||||
'status',
|
||||
'content',
|
||||
];
|
||||
$filters = [
|
||||
'user_uid',
|
||||
'worker_uid',
|
||||
'category',
|
||||
'status',
|
||||
];
|
||||
$indexFilter = $filters;
|
||||
$batchjobFilters = ['user_uid', 'category', 'status'];
|
||||
switch ($action) {
|
||||
case 'view':
|
||||
$fields = [
|
||||
'category',
|
||||
'worker_uid',
|
||||
'title',
|
||||
'status',
|
||||
'created_at',
|
||||
'content'
|
||||
];
|
||||
break;
|
||||
case 'index':
|
||||
$fields = [
|
||||
'category',
|
||||
'worker_uid',
|
||||
'title',
|
||||
'status',
|
||||
'created_at'
|
||||
];
|
||||
break;
|
||||
case 'download':
|
||||
$fields = [
|
||||
'category',
|
||||
'worker_uid',
|
||||
'title',
|
||||
'status',
|
||||
'created_at',
|
||||
'content'
|
||||
];
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "category":
|
||||
case "title":
|
||||
$formRules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "user_uid":
|
||||
$formRules[$field] = "required|numeric";
|
||||
break;
|
||||
case "worker_uid":
|
||||
$formRules[$field] = "permit_empty|numeric";
|
||||
break;
|
||||
case "content":
|
||||
$formRules[$field] = "permit_empty|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'worker_uid':
|
||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
507
app/Forms/CommonForm.php
Normal file
507
app/Forms/CommonForm.php
Normal file
@ -0,0 +1,507 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* CommonForm
|
||||
* - 모든 Form의 공통 베이스
|
||||
* - 핵심 개선점:
|
||||
* 1) FK/숫자 필드 미입력('')을 NULL로 정규화 ('' -> null)
|
||||
* 2) 전역 null -> '' 변환 제거 (FK/숫자/날짜 타입 깨짐 방지)
|
||||
* 3) validate()에서 dynamicRules 누적 버그 수정 (마지막 규칙만 남는 문제 해결)
|
||||
* 4) "필드 존재 보장"으로 임의 '' 삽입 제거 (미입력 필드가 FK/숫자 규칙을 깨는 문제 방지)
|
||||
* 5) role.* 같은 배열 원소 규칙을 위해 부모 배열 보정 로직 유지/강화
|
||||
*/
|
||||
abstract class CommonForm
|
||||
{
|
||||
private $_validation = null;
|
||||
|
||||
private array $_attributes = [];
|
||||
private array $_formFields = [];
|
||||
private array $_formRules = [];
|
||||
private array $_formFilters = [];
|
||||
private array $_indexFilters = [];
|
||||
private array $_batchjobFilters = [];
|
||||
private array $_formOptions = [];
|
||||
private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||
private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제'];
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->_validation = service('validation');
|
||||
}
|
||||
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
$actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||
$batchjobButtons = [];
|
||||
$this->setActionButtons($actionButtons);
|
||||
$this->setBatchjobButtons($batchjobButtons);
|
||||
}
|
||||
|
||||
final public function setAttributes(array $attributes): void
|
||||
{
|
||||
$this->_attributes = $attributes;
|
||||
}
|
||||
|
||||
final public function getAttribute(string $key): string
|
||||
{
|
||||
if (!array_key_exists($key, $this->_attributes)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$key}에 해당하는 속성이 정의되지 않았습니다.");
|
||||
}
|
||||
return $this->_attributes[$key];
|
||||
}
|
||||
|
||||
final public function setFormFields(array $fields): void
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$this->_formFields[$field] = $this->getFormFieldLabel($field);
|
||||
}
|
||||
}
|
||||
|
||||
// $fields 매치된것만 반환, []->전체
|
||||
final public function getFormFields(array $fields = []): array
|
||||
{
|
||||
if (empty($fields)) {
|
||||
return $this->_formFields;
|
||||
}
|
||||
return array_intersect_key($this->_formFields, array_flip($fields));
|
||||
}
|
||||
|
||||
public function setFormRules(string $action, array $fields, $formRules = []): void
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$formRules = $this->getFormRule($action, $field, $formRules);
|
||||
}
|
||||
$this->_formRules = $formRules;
|
||||
}
|
||||
|
||||
final public function getFormRules(array $fields = []): array
|
||||
{
|
||||
if (empty($fields)) {
|
||||
return $this->_formRules;
|
||||
}
|
||||
return array_intersect_key($this->_formRules, array_flip($fields));
|
||||
}
|
||||
|
||||
final public function setFormOptions(string $action, array $fields, array $formDatas = [], $formOptions = []): void
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($action, $field, $formDatas);
|
||||
}
|
||||
$this->_formOptions = $formOptions;
|
||||
}
|
||||
|
||||
// $fields 매치된것만 반환, []->전체
|
||||
final public function getFormOptions(array $fields = []): array
|
||||
{
|
||||
if (empty($fields)) {
|
||||
return $this->_formOptions;
|
||||
}
|
||||
return array_intersect_key($this->_formOptions, array_flip($fields));
|
||||
}
|
||||
|
||||
final public function setFormFilters(array $fields): void
|
||||
{
|
||||
$this->_formFilters = $fields;
|
||||
}
|
||||
|
||||
final public function getFormFilters(): array
|
||||
{
|
||||
return $this->_formFilters;
|
||||
}
|
||||
|
||||
final public function setIndexFilters(array $fields): void
|
||||
{
|
||||
$this->_indexFilters = $fields;
|
||||
}
|
||||
|
||||
final public function getIndexFilters(): array
|
||||
{
|
||||
return $this->_indexFilters;
|
||||
}
|
||||
|
||||
final public function setBatchjobFilters(array $fields): void
|
||||
{
|
||||
$this->_batchjobFilters = $fields;
|
||||
}
|
||||
|
||||
final public function getBatchjobFilters(): array
|
||||
{
|
||||
return $this->_batchjobFilters;
|
||||
}
|
||||
|
||||
final public function setActionButtons(array $buttons): array
|
||||
{
|
||||
return $this->_actionButtons = $buttons;
|
||||
}
|
||||
|
||||
final public function getActionButtons(): array
|
||||
{
|
||||
return $this->_actionButtons;
|
||||
}
|
||||
|
||||
final public function setBatchjobButtons(array $buttons): array
|
||||
{
|
||||
return $this->_batchjobButtons = $buttons;
|
||||
}
|
||||
|
||||
final public function getBatchjobButtons(): array
|
||||
{
|
||||
return $this->_batchjobButtons;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Normalize / Sanitize
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* 1) 깊은 배열 구조 정리(배열은 유지)
|
||||
* - 여기서는 null -> '' 같은 변환을 절대 하지 않습니다.
|
||||
* - 이유: FK/숫자/날짜 필드가 ''로 변하면 validation/DB에서 문제가 발생함.
|
||||
*/
|
||||
protected function sanitizeFormDatas($data, string $path = '')
|
||||
{
|
||||
if (!is_array($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$data[$k] = $this->sanitizeFormDatas($v, ($path !== '' ? "{$path}.{$k}" : (string) $k));
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2) 숫자/FK 필드 정규화
|
||||
* - 폼에서 미선택은 보통 ''로 들어옴 -> NULL로 변환
|
||||
* - 숫자 문자열은 int 캐스팅 (선택)
|
||||
*
|
||||
* 주의:
|
||||
* - "빈값을 0으로 취급" 같은 정책이 있다면 여기에서 조정해야 함.
|
||||
*/
|
||||
protected function normalizeNumericEmptyToNull(array $data, array $numericFields): array
|
||||
{
|
||||
foreach ($numericFields as $f) {
|
||||
if (!array_key_exists($f, $data)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($data[$f] === '') {
|
||||
$data[$f] = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_string($data[$f]) && ctype_digit($data[$f])) {
|
||||
$data[$f] = (int) $data[$f];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 3) role.* 같은 배열 원소 규칙이 있을 때, 부모 배열 존재/타입 보정
|
||||
*/
|
||||
protected function ensureParentArrayForWildcardRules(array &$formDatas, array $formRules): void
|
||||
{
|
||||
foreach ($formRules as $fieldKey => $ruleDef) {
|
||||
$fieldName = (string) $fieldKey;
|
||||
|
||||
if (!str_contains($fieldName, '.*')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parent = str_replace('.*', '', $fieldName);
|
||||
|
||||
// 1) 부모가 없거나 ''/null 이면 빈 배열
|
||||
if (!array_key_exists($parent, $formDatas) || $formDatas[$parent] === '' || $formDatas[$parent] === null) {
|
||||
$formDatas[$parent] = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2) 문자열이면 CSV로 분해 (혹시 JSON 문자열이면 JSON 우선)
|
||||
if (is_string($formDatas[$parent])) {
|
||||
$raw = trim($formDatas[$parent]);
|
||||
if ($raw === '') {
|
||||
$formDatas[$parent] = [];
|
||||
} else {
|
||||
$decoded = json_decode($raw, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
||||
$formDatas[$parent] = $decoded;
|
||||
} else {
|
||||
$formDatas[$parent] = explode(DEFAULTS["DELIMITER_COMMA"], $raw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3) 배열이 아니면 강제 빈 배열
|
||||
if (!is_array($formDatas[$parent])) {
|
||||
$formDatas[$parent] = [];
|
||||
}
|
||||
|
||||
// ✅ 4) 핵심: 배열 원소의 null/'' 제거 + 문자열화(Trim이 null 받지 않도록)
|
||||
$clean = array_map(
|
||||
fn($v) => is_scalar($v) ? trim((string) $v) : '',
|
||||
$formDatas[$parent]
|
||||
);
|
||||
$clean = array_values(array_filter($clean, fn($v) => $v !== ''));
|
||||
|
||||
$formDatas[$parent] = $clean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 4) 검증 rule에 따라 "numeric(특히 FK)"로 취급할 필드를 수집
|
||||
* - getFormRule()에서 permit_empty|numeric 로 정의되는 필드를 공통 처리하기 위함
|
||||
*
|
||||
* 구현 전략:
|
||||
* - formRules에서 rule 문자열에 'numeric'가 포함된 필드를 모음
|
||||
* - wildcard(role.*) 제외
|
||||
*/
|
||||
protected function collectNumericFieldsFromRules(array $formRules): array
|
||||
{
|
||||
$numericFields = [];
|
||||
|
||||
foreach ($formRules as $field => $rule) {
|
||||
$fieldName = (string) $field;
|
||||
|
||||
if (str_contains($fieldName, '.*')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// getValidationRule hook 적용 (필드명/룰이 바뀔 수 있으니)
|
||||
[$fieldName, $ruleStr] = $this->getValidationRule($fieldName, (string) $rule);
|
||||
|
||||
if (is_string($ruleStr) && str_contains($ruleStr, 'numeric')) {
|
||||
$numericFields[] = $fieldName;
|
||||
}
|
||||
}
|
||||
|
||||
// 중복 제거
|
||||
return array_values(array_unique($numericFields));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Validation
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* 데이터를 검증하고 유효하지 않을 경우 예외를 발생시킵니다.
|
||||
* 2025 CI4 표준: 규칙 배열 내에 label을 포함하여 한글 메시지 출력을 보장합니다.
|
||||
*/
|
||||
final public function validate(array &$formDatas): void
|
||||
{
|
||||
log_message('debug', '>>> CommonForm::validate CALLED: ' . static::class);
|
||||
if ($this->_validation === null) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: Validation 서비스가 초기화되지 않았습니다.");
|
||||
}
|
||||
|
||||
try {
|
||||
// 0) 데이터 구조 정리 (null 변환 X)
|
||||
$formDatas = $this->sanitizeFormDatas($formDatas);
|
||||
|
||||
// 1) 필드 라벨/규칙
|
||||
$formFields = $this->getFormFields();
|
||||
$formRules = $this->getFormRules();
|
||||
|
||||
if (empty($formRules)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 지정된 Form RULE이 없습니다.");
|
||||
}
|
||||
|
||||
// 2) wildcard(role.*) 부모 배열 보정
|
||||
$this->ensureParentArrayForWildcardRules($formDatas, $formRules);
|
||||
|
||||
// 3) numeric(FK 포함) 필드: '' -> null, 숫자 문자열 -> int
|
||||
// (규칙 기반 자동 수집)
|
||||
$numericFields = $this->collectNumericFieldsFromRules($formRules);
|
||||
$formDatas = $this->normalizeNumericEmptyToNull($formDatas, $numericFields);
|
||||
|
||||
// 4) dynamicRules 누적 구성 (버그 수정: 루프마다 초기화 금지)
|
||||
$dynamicRules = [];
|
||||
foreach ($formRules as $field => $rule) {
|
||||
try {
|
||||
// 필드명/규칙 추출(확장 포인트)
|
||||
[$fieldName, $ruleStr] = $this->getValidationRule((string) $field, (string) $rule);
|
||||
|
||||
// label 결정
|
||||
if (isset($formFields[$fieldName])) {
|
||||
$label = $formFields[$fieldName];
|
||||
} elseif (str_contains($fieldName, '.*')) {
|
||||
$parentField = str_replace('.*', '', $fieldName);
|
||||
$label = ($formFields[$parentField] ?? $fieldName) . " 항목";
|
||||
} else {
|
||||
$label = $fieldName;
|
||||
}
|
||||
|
||||
$dynamicRules[$fieldName] = [
|
||||
'label' => $label,
|
||||
'rules' => $ruleStr,
|
||||
];
|
||||
|
||||
// ❌ 존재 보장으로 '' 삽입하지 않음
|
||||
// - required는 CI4가 "키 없음"도 실패 처리 가능(일반적으로)
|
||||
// - permit_empty는 키 없어도 통과 (강제로 '' 만들면 FK/숫자 문제 발생)
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
throw new RuntimeException("유효성 검사 규칙 준비 중 오류 발생 (필드: {$field}): " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->_validation->setRules($dynamicRules);
|
||||
|
||||
try {
|
||||
if (!$this->_validation->run($formDatas)) {
|
||||
$errors = $this->_validation->getErrors();
|
||||
throw new RuntimeException(implode("\n", $errors));
|
||||
}
|
||||
} catch (\TypeError $e) {
|
||||
throw new RuntimeException("검증 도중 타입 오류 발생: " . $e->getMessage());
|
||||
}
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
if ($e instanceof RuntimeException) {
|
||||
throw $e;
|
||||
}
|
||||
throw new RuntimeException("유효성 검사 중 시스템 오류 발생: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Overridable hooks
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
// 사용자 정의 hook: 필드/룰 커스터마이즈
|
||||
protected function getValidationRule(string $field, string $rule): array
|
||||
{
|
||||
return [$field, $rule];
|
||||
}
|
||||
|
||||
public function getFormFieldLabel(string $field, ?string $label = null): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$label = $label ?? lang("{$this->getAttribute('class_path')}.label.{$field}");
|
||||
break;
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form rule 정의
|
||||
* - permit_empty|numeric 인 FK들이 여기서 정의되면,
|
||||
* validate()에서 자동으로 ''->null 정규화 대상에 포함됩니다.
|
||||
*/
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case $this->getAttribute('pk_field'):
|
||||
if (!$this->getAttribute('useAutoIncrement')) {
|
||||
$formRules[$field] = sprintf(
|
||||
"required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]%s",
|
||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
} else {
|
||||
$formRules[$field] = "required|numeric";
|
||||
}
|
||||
break;
|
||||
case $this->getAttribute('title_field'):
|
||||
$formRules[$field] = sprintf(
|
||||
"required|trim|string%s",
|
||||
in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
break;
|
||||
case "code":
|
||||
$formRules[$field] = sprintf(
|
||||
"required|regex_match[/^[a-zA-Z0-9가-힣\-\_]+$/]|min_length[4]%s",
|
||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
break;
|
||||
case "user_uid":
|
||||
$formRules[$field] = "required|numeric";
|
||||
break;
|
||||
case "status":
|
||||
$formRules[$field] = "required|trim|string";
|
||||
break;
|
||||
case 'picture':
|
||||
$formRules[$field] = "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]";
|
||||
break;
|
||||
case "updated_at":
|
||||
case "created_at":
|
||||
case "deleted_at":
|
||||
$formRules[$field] = "permit_empty|trim|valid_date";
|
||||
break;
|
||||
default:
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
}
|
||||
|
||||
return $formRules;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Options
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
protected function getFormOption_process($service, string $action, string $field, array $formDatas = []): array
|
||||
{
|
||||
$entities = [];
|
||||
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($action, ['create_form', 'modify_form', 'alternative_create_form'])) {
|
||||
if (array_key_exists($field, $formDatas)) {
|
||||
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $formDatas[$field]);
|
||||
} else {
|
||||
$where = sprintf("status = '%s'", STATUS['AVAILABLE']);
|
||||
}
|
||||
$entities = $service->getEntities([$where => null]);
|
||||
} else {
|
||||
$entities = $service->getEntities();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $entity) {
|
||||
$tempOptions[$entity->getPK()] = $entity->getTitle();
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
|
||||
case 'clientinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $entity) {
|
||||
$tempOptions[$entity->getPK()] = $entity->getCustomTitle();
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
|
||||
default:
|
||||
$optionDatas = lang($this->getAttribute('class_path') . "." . strtoupper($field));
|
||||
if (!is_array($optionDatas)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:{$field}가 배열값이 아닙니다.");
|
||||
}
|
||||
foreach ($optionDatas as $key => $label) {
|
||||
$tempOptions[$key] = $label;
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
69
app/Forms/UserForm.php
Normal file
69
app/Forms/UserForm.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class UserForm extends CommonForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
$fields = [
|
||||
'id',
|
||||
'passwd',
|
||||
'confirmpassword',
|
||||
'name',
|
||||
'email',
|
||||
'mobile',
|
||||
'role',
|
||||
'status'
|
||||
];
|
||||
$filters = ['role', 'status'];
|
||||
$indexFilter = $filters;
|
||||
$batchjobFilters = ['status'];
|
||||
switch ($action) {
|
||||
case 'view':
|
||||
$fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at'];
|
||||
break;
|
||||
case 'index':
|
||||
case 'download':
|
||||
$fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at'];
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "id":
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "passwd":
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
|
||||
break;
|
||||
case "confirmpassword":
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
|
||||
break;
|
||||
case "email":
|
||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "role":
|
||||
$formRules[$field] = 'required|is_array|at_least_one';
|
||||
$formRules['role.*'] = 'permit_empty|trim|in_list[manager,cloudflare,firewall,security,director,master]';
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
}
|
||||
0
app/Helpers/.gitkeep
Normal file
0
app/Helpers/.gitkeep
Normal file
23
app/Helpers/AuthHelper.php
Normal file
23
app/Helpers/AuthHelper.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class AuthHelper extends CommonHelper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'passwd':
|
||||
$form = form_password($field, "", [...$extras]);
|
||||
break;
|
||||
default:
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
} //
|
||||
}
|
||||
11
app/Helpers/BoardHelper.php
Normal file
11
app/Helpers/BoardHelper.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class BoardHelper extends CommonHelper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
327
app/Helpers/CommonHelper.php
Normal file
327
app/Helpers/CommonHelper.php
Normal file
@ -0,0 +1,327 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Libraries\AuthContext;
|
||||
use App\Traits\UtilTrait;
|
||||
use RuntimeException;
|
||||
|
||||
abstract class CommonHelper
|
||||
{
|
||||
use UtilTrait;
|
||||
private array $_attributes = [];
|
||||
protected function __construct()
|
||||
{
|
||||
}
|
||||
final public function setAttributes(array $attributes): void
|
||||
{
|
||||
$this->_attributes = $attributes;
|
||||
}
|
||||
final protected function getAuthContext(): AuthContext
|
||||
{
|
||||
return service('myauth')->getAuthContext();
|
||||
}
|
||||
final public function getAttribute(string $key): string
|
||||
{
|
||||
if (!array_key_exists($key, $this->_attributes)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$key}에 해당하는 속성이 정의되지 않았습니다.");
|
||||
}
|
||||
return $this->_attributes[$key];
|
||||
}
|
||||
public function getFieldLabel(string $field, string $label, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$extras = (strpos($viewDatas['formRules'][$field], 'required') !== false) ? ["class" => "text-danger", "required" => "", ...$extras] : $extras;
|
||||
$label = form_label($label, $field, ['class' => 'form-label-sm', ...$extras]);
|
||||
break;
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
/**
|
||||
* CI4의 form_dropdown()을 확장하여 <option> 태그에 data-* 속성을 추가할 수 있도록 합니다.
|
||||
*
|
||||
* @param string $name 폼 필드 이름
|
||||
* @param array $options 드롭다운 옵션 배열.
|
||||
* 값은 문자열/정수, 또는 추가 속성을 포함하는 배열일 수 있습니다.
|
||||
* 예: ['value' => 'test1', 'text' => 'Test 1', 'data-price' => 1000]
|
||||
* @param string|array|null $selected 현재 선택된 값
|
||||
* @param string $extra <select> 태그에 추가할 속성
|
||||
* @return string HTML <select> 태그
|
||||
*/
|
||||
final public function form_dropdown_custom(string $name, array $options, mixed $selected, array $extras = []): string
|
||||
{
|
||||
//Extra처리
|
||||
$extra = "";
|
||||
foreach ($extras as $extras_key => $extras_value) {
|
||||
$extra .= " " . esc($extras_key) . '="' . esc($extras_value) . '"';
|
||||
}
|
||||
$select = '<select name="' . esc($name) . '"' . $extra . ">\n";
|
||||
foreach ($options as $key => $val) {
|
||||
// 💡$val이 배열인지 확인합니다.-->배열일경우 옵션 처리
|
||||
if (is_array($val)) {
|
||||
// $val이 배열인 경우: 복합 옵션 (value, text, data-* 속성 포함)
|
||||
$optionValue = $val['value'] ?? $key; // value가 없으면 키 사용
|
||||
$optionText = $val['text'] ?? $optionValue;
|
||||
$optionAttributes = '';
|
||||
// data-* 속성 추출 및 조합
|
||||
foreach ($val as $attrKey => $attrValue) {
|
||||
// 'value'와 'text'는 <option> 속성이 아니므로 제외
|
||||
if ($attrKey == 'value' || $attrKey == 'text') {
|
||||
continue;
|
||||
} else {
|
||||
$optionAttributes .= sprintf(" %s=\"%s\"", esc($attrKey), esc($attrValue));
|
||||
}
|
||||
}
|
||||
$optionSelected = $optionValue == $selected ? ' selected="selected"' : '';
|
||||
$select .= sprintf(
|
||||
"<option value=\"%s\" %s %s>%s</option>",
|
||||
$optionValue,
|
||||
$optionAttributes,
|
||||
$optionSelected,
|
||||
esc($optionText)
|
||||
);
|
||||
} else {
|
||||
// $val이 배열이 아닌 경우: 일반 옵션 (기존 form_dropdown() 방식)
|
||||
$optionSelected = $key == $selected ? ' selected="selected"' : '';
|
||||
$select .= sprintf(
|
||||
"<option value=\"%s\" %s></option>",
|
||||
$key,
|
||||
$optionSelected,
|
||||
esc($val)
|
||||
);
|
||||
}
|
||||
}
|
||||
$select .= "</select>\n";
|
||||
return $select;
|
||||
}
|
||||
protected function getFieldForm_process(string $field, array $viewDatas, string $form): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'email':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' form-control' : 'form-control';
|
||||
$extras['placeholder'] = '예)test@example.co.kr';
|
||||
$form = form_input($field, $value ?? "", $extras);
|
||||
break;
|
||||
case 'mobile':
|
||||
case 'phone':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' form-control' : 'form-control';
|
||||
$extras['placeholder'] = '예)010-0010-0010';
|
||||
$form = form_input($field, $value ?? "", $extras);
|
||||
break;
|
||||
case 'issue_at':
|
||||
case 'expired_at':
|
||||
case 'billing_at':
|
||||
case 'start_at':
|
||||
case 'end_at':
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
case 'deleted_at':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
|
||||
$form = form_input($field, $value ?? "", $extras);
|
||||
break;
|
||||
case 'description':
|
||||
case 'content':
|
||||
case 'detail':
|
||||
case 'history':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' form-control tinymce' : 'form-control tinymce';
|
||||
$form = form_textarea($field, html_entity_decode($value ?? "", ENT_QUOTES, 'UTF-8'), $extras);
|
||||
break;
|
||||
case 'status':
|
||||
$forms = [];
|
||||
// dd($viewDatas['formOptions']);
|
||||
array_shift($viewDatas['formOptions'][$field]['options']);
|
||||
foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label)
|
||||
$forms[] = form_radio($field, $key, $key == $value, $extras) . $label;
|
||||
$form = implode(" ", $forms);
|
||||
break;
|
||||
default:
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' form-control' : 'form-control';
|
||||
if (in_array($field, $viewDatas['formFilters'])) {
|
||||
if (array_key_exists('extras', $viewDatas['formOptions'][$field])) {
|
||||
$extras = array_merge($extras, $viewDatas['formOptions'][$field]['extras']);
|
||||
}
|
||||
$form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
|
||||
} else {
|
||||
$form = form_input($field, $value ?? "", $extras);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||
{
|
||||
switch ($field) {
|
||||
case 'clientinfo_uid':
|
||||
if (array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) {
|
||||
if (!array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$field}에서 {$value}에 해당하는 값이 존재하지 않습니다.");
|
||||
}
|
||||
$value = !$value ? "" : "<a href=\"/admin/customer/client/detail/{$value}\">{$viewDatas['formOptions'][$field]['options'][$value]}</a>";
|
||||
}
|
||||
break;
|
||||
case 'role':
|
||||
if (!is_array($value)) { //배열이 아니면
|
||||
$value = explode(DEFAULTS['DELIMITER_COMMA'], $value);
|
||||
}
|
||||
$roles = [];
|
||||
foreach ($value as $key) {
|
||||
$roles[] = $viewDatas['formOptions'][$field]['options'][$key];
|
||||
}
|
||||
$value = implode(" , ", $roles);
|
||||
break;
|
||||
case 'description':
|
||||
case 'content':
|
||||
case 'detail':
|
||||
case 'history':
|
||||
$value = $value != null ? html_entity_decode($value, ENT_QUOTES, 'UTF-8') : "";
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
case 'deleted_at':
|
||||
$value = $value ? date("Y-m-d", strtotime($value)) : "";
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['formFilters'])) {
|
||||
if ($value) {
|
||||
if (!array_key_exists($value, $viewDatas['formOptions'][$field]['options'])) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$field}에서 {$value}에 해당하는 값이 존재하지 않습니다.\n" . var_export($viewDatas['formOptions'][$field], true));
|
||||
}
|
||||
$value = $viewDatas['formOptions'][$field]['options'][$value];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
throw new RuntimeException(static::class . "->" . __FUNCTION__ . "에서 오류발생:{$field}에 해당하는 Return 값이 배열형식입니다.\n" . var_export($value, true));
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
public function getListFilter(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
case 'clientinfo_uid':
|
||||
case 'serverinfo_uid':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
$filter = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
|
||||
break;
|
||||
default:
|
||||
$filter = "";
|
||||
if (in_array($field, $viewDatas['formFilters'])) {
|
||||
$filter = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $filter;
|
||||
}
|
||||
public function getListLabel(string $field, string $label, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (isset($viewDatas['order_field']) && $viewDatas['order_field'] == $field) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
|
||||
}
|
||||
$query = $viewDatas['uri']->getQuery(['except' => ['order_field', 'order_value']]);
|
||||
$query .= empty($query) ? "" : "&";
|
||||
$query .= "order_field={$field}&order_value=";
|
||||
$query .= isset($viewDatas['order_value']) && $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$label = anchor(current_url() . "?" . $query, $label);
|
||||
form_dropdown('perpage', $viewDatas['index_pagination_options'], $viewDatas['perpage'], ['onChange' => 'this.form.submit()']);
|
||||
break;
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
|
||||
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
$action = form_label(
|
||||
$label,
|
||||
$action,
|
||||
[
|
||||
"data-src" => sprintf("%s/%s?%s", current_url(), $action, service('request')->getUri()->getQuery()),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#modal_action_form",
|
||||
"class" => "btn btn-sm btn-primary form-label-sm",
|
||||
...$extras
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'modify':
|
||||
$oldBatchJobUids = old("batchjob_uids", null);
|
||||
$oldBatchJobUids = is_array($oldBatchJobUids) ? $oldBatchJobUids : [$oldBatchJobUids];
|
||||
$checkbox = form_checkbox([
|
||||
"id" => "checkbox_uid_{$viewDatas['entity']->getPK()}",
|
||||
"name" => "batchjob_uids[]",
|
||||
"value" => $viewDatas['entity']->getPK(),
|
||||
"class" => "batchjobuids_checkboxs",
|
||||
"checked" => in_array($viewDatas['entity']->getPK(), $oldBatchJobUids)
|
||||
]);
|
||||
$action = $checkbox . form_label(
|
||||
$label,
|
||||
$action,
|
||||
[
|
||||
"data-src" => sprintf("%s/%s/%s?%s", current_url(), $action, $viewDatas['entity']->getPK(), service('request')->getUri()->getQuery()),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#modal_action_form",
|
||||
'class' => 'form-label-sm',
|
||||
...$extras
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'view':
|
||||
$action = form_label(
|
||||
$label,
|
||||
$action,
|
||||
[
|
||||
"data-src" => sprintf("%s/%s/%s?%s", current_url(), $action, $viewDatas['entity']->getPK(), service('request')->getUri()->getQuery()),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#modal_action_form",
|
||||
"class" => "btn btn-sm btn-primary form-label-sm",
|
||||
...$extras
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'delete':
|
||||
$action = anchor(
|
||||
current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(),
|
||||
$label,
|
||||
[
|
||||
"class" => "btn btn-sm btn-danger form-label-sm",
|
||||
...$extras
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'batchjob':
|
||||
$action = form_submit("batchjob_submit", $label, [
|
||||
"formaction" => current_url() . '/batchjob',
|
||||
"class" => "btn btn-sm btn-warning form-label-sm",
|
||||
...$extras,
|
||||
// "onclick" => "return submitBatchJob()"
|
||||
]);
|
||||
break;
|
||||
case 'batchjob_delete':
|
||||
$action = form_submit("batchjob_submit", $label, [
|
||||
"formaction" => current_url() . '/batchjob_delete',
|
||||
"class" => "btn btn-sm btn-danger form-label-sm",
|
||||
...$extras,
|
||||
// "onclick" => "return submitBatchJobDelete()"
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
$action = "";
|
||||
break;
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
41
app/Helpers/UserHelper.php
Normal file
41
app/Helpers/UserHelper.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class UserHelper extends CommonHelper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'passwd':
|
||||
case 'confirmpassword':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' form-control' : 'form-control';
|
||||
$extras['style'] = 'width:100%;';
|
||||
$form = form_password($field, "", $extras);
|
||||
break;
|
||||
case 'role':
|
||||
$currentRoles = is_array($value)
|
||||
? array_map('strtolower', array_map('trim', $value))
|
||||
: [];
|
||||
$form = '';
|
||||
//Form페이지에서는 맨앞에것 제외하기 위함
|
||||
array_shift($viewDatas['formOptions'][$field]['options']);
|
||||
foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) {
|
||||
$checked = in_array(strtolower(trim($key)), $currentRoles);
|
||||
$form .= '<label class="me-3">';
|
||||
$form .= form_checkbox('role[]', $key, $checked, ['id' => "role_{$key}", ...$extras]);
|
||||
$form .= " {$label}";
|
||||
$form .= '</label>';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
} //
|
||||
}
|
||||
0
app/Language/.gitkeep
Normal file
0
app/Language/.gitkeep
Normal file
4
app/Language/en/Validation.php
Normal file
4
app/Language/en/Validation.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// override core en language system validation or define your own en language validation message
|
||||
return [];
|
||||
8
app/Language/ko/Auth/Local.php
Normal file
8
app/Language/ko/Auth/Local.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
'title' => "고객정보",
|
||||
'label' => [
|
||||
'id' => "계정",
|
||||
'passwd' => "암호",
|
||||
],
|
||||
];
|
||||
25
app/Language/ko/Board.php
Normal file
25
app/Language/ko/Board.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
return [
|
||||
'title' => "게시판정보",
|
||||
'label' => [
|
||||
'uid' => "번호",
|
||||
'user_uid' => "요청자/작성자",
|
||||
'worker_uid' => "업무협조자",
|
||||
'category' => "구분",
|
||||
'title' => "제목",
|
||||
'content' => "내용",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
'created_at' => "작성일",
|
||||
'deleted_at' => "삭제일",
|
||||
],
|
||||
"CATEGORY" => [
|
||||
BOARD['CATEGORY']['NOTICE'] => '공지사항',
|
||||
BOARD['CATEGORY']['REQUESTTASK'] => '요청업무',
|
||||
],
|
||||
"STATUS" => [
|
||||
STATUS['AVAILABLE'] => "사용중",
|
||||
STATUS['PAUSE'] => "일시정지",
|
||||
STATUS['TERMINATED'] => "완료",
|
||||
],
|
||||
];
|
||||
31
app/Language/ko/User.php
Normal file
31
app/Language/ko/User.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
return [
|
||||
'title' => "계정정보",
|
||||
'label' => [
|
||||
'uid' => "번호",
|
||||
'id' => "계정",
|
||||
'passwd' => "암호",
|
||||
'confirmpassword' => "암호확인",
|
||||
'email' => "메일",
|
||||
'mobile' => "연락처",
|
||||
'role' => "권한",
|
||||
'name' => "이름",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
'created_at' => "작성일",
|
||||
'deleted_at' => "삭제일",
|
||||
],
|
||||
"ROLE" => [
|
||||
ROLE['USER']["MANAGER"] => "관리자",
|
||||
ROLE['USER']["CLOUDFLARE"] => "Cloudflare관리자",
|
||||
ROLE['USER']["FIREWALL"] => "firewall관리자",
|
||||
ROLE['USER']["SECURITY"] => "보안관리자",
|
||||
ROLE['USER']["DIRECTOR"] => "감독자",
|
||||
ROLE['USER']["MASTER"] => "마스터",
|
||||
],
|
||||
"STATUS" => [
|
||||
STATUS['AVAILABLE'] => "사용중",
|
||||
STATUS['PAUSE'] => "일시정지",
|
||||
STATUS['TERMINATED'] => "해지",
|
||||
],
|
||||
];
|
||||
36
app/Language/ko/Validation.php
Normal file
36
app/Language/ko/Validation.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// app/Language/kr/Validation.php
|
||||
|
||||
return [
|
||||
// 여기서부터 각 Validation rule에 대한 메시지를 정의합니다.
|
||||
// {field}나 {param} 같은 플레이스홀더는 그대로 유지해야 합니다.
|
||||
'required' => '[{field}] 필수 입력 항목입니다.',
|
||||
'isset' => '[{field}] 값이 반드시 있어야 합니다.',
|
||||
'valid_email' => '[{field}] 유효한 이메일 주소여야 합니다.',
|
||||
'valid_url' => '[{field}] 유효한 URL이어야 합니다.',
|
||||
'valid_date' => '[{field}] 유효한 날짜여야 합니다.',
|
||||
'valid_dates' => '[{field}] 유효한 날짜여야 합니다.',
|
||||
'valid_ip' => '[{field}] 유효한 IP 주소여야 합니다.',
|
||||
'valid_mac' => '[{field}] 유효한 MAC 주소여야 합니다.',
|
||||
'numeric' => '[{field}] 숫자만 포함해야 합니다.',
|
||||
'integer' => '[{field}] 정수여야 합니다.',
|
||||
'decimal' => '[{field}] 소수점 숫자여야 합니다.',
|
||||
'is_numeric' => '[{field}] 숫자 문자만 포함해야 합니다.',
|
||||
'regex_match' => '[{field}] 올바른 형식이어야 합니다.',
|
||||
'matches' => '{field} 필드가 {param} 필드와 일치하지 않습니다.',
|
||||
'differs' => '[{field}] {param} 필드와 달라야 합니다.',
|
||||
'is_unique' => '[{field}] 고유한 값이어야 합니다.',
|
||||
'is_natural' => '[{field}] 숫자여야 합니다.',
|
||||
'is_natural_no_zero' => '[{field}] 0보다 큰 숫자여야 합니다.',
|
||||
'less_than' => '[{field}] {param}보다 작아야 합니다.',
|
||||
'less_than_equal_to' => '[{field}] {param}보다 작거나 같아야 합니다.',
|
||||
'greater_than' => '[{field}] {param}보다 커야 합니다.',
|
||||
'greater_than_equal_to' => '[{field}] {param}보다 크거나 같아야 합니다.',
|
||||
'error_prefix' => '',
|
||||
'error_suffix' => '',
|
||||
'min_length' => '[{field}] 최소 {param}자 이상이어야 합니다.',
|
||||
'max_length' => '[{field}] 최대 {param}자 이하여야 합니다.',
|
||||
'exact_length' => '[{field}] 정확히 {param}자여야 합니다.',
|
||||
'in_list' => '[{field}] 다음 중 하나여야 합니다: {param}.',
|
||||
'at_least_one' => '{field} 최소 1개 이상 선택해야 합니다.',
|
||||
];
|
||||
0
app/Libraries/.gitkeep
Normal file
0
app/Libraries/.gitkeep
Normal file
143
app/Libraries/AuthContext.php
Normal file
143
app/Libraries/AuthContext.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Entities\UserEntity;
|
||||
use CodeIgniter\Session\Session;
|
||||
|
||||
/**
|
||||
* AuthContext
|
||||
* 인증 세션의 저장, 조회 및 파괴를 관리합니다.
|
||||
* AuthService의 세션 로직을 분리하여 SRP를 준수합니다.
|
||||
*/
|
||||
class AuthContext
|
||||
{
|
||||
private Session $session;
|
||||
private string $urlStackName = "url_stack";
|
||||
|
||||
// 환경 설정에서 정의된 상수라고 가정합니다.
|
||||
const SESSION_IS_LOGIN = 'ISLOGIN';
|
||||
const SESSION_AUTH_INFO = 'AUTH';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// 세션 서비스를 직접 사용합니다.
|
||||
$this->session = \Config\Services::session();
|
||||
}
|
||||
|
||||
private function getAuthInfo(string $key = ""): array|int|string|null
|
||||
{
|
||||
$authInfo = $this->session->get(self::SESSION_AUTH_INFO);
|
||||
if ($key) {
|
||||
return $authInfo[$key] ?? null;
|
||||
}
|
||||
return $authInfo;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Public Accessors (AuthService에서 이동)
|
||||
// ----------------------------------------------------
|
||||
|
||||
public function getUID(): int
|
||||
{
|
||||
$uid = $this->getAuthInfo('uid');
|
||||
|
||||
if ($uid === null || $uid === '') {
|
||||
throw new \RuntimeException('Not logged in');
|
||||
}
|
||||
|
||||
return (int) $uid;
|
||||
}
|
||||
|
||||
public function getID(): string|null
|
||||
{
|
||||
return $this->getAuthInfo('id');
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->getAuthInfo('name');
|
||||
}
|
||||
|
||||
public function getRole(): array|null
|
||||
{
|
||||
return $this->getAuthInfo('role');
|
||||
}
|
||||
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
return $this->session->has(self::SESSION_IS_LOGIN);
|
||||
}
|
||||
|
||||
public function isAccessRole(array $roles): bool
|
||||
{
|
||||
$userRoles = $this->getRole();
|
||||
if (empty($userRoles) || !is_array($userRoles)) {
|
||||
return false;
|
||||
}
|
||||
return !empty(array_intersect($userRoles, $roles));
|
||||
}
|
||||
|
||||
public function pushCurrentUrl(string $url): void
|
||||
{
|
||||
$this->session->set($this->urlStackName, $url);
|
||||
}
|
||||
|
||||
public function popPreviousUrl(): string
|
||||
{
|
||||
$url = $this->session->get($this->urlStackName) ?? "";
|
||||
if (!empty($url)) {
|
||||
$this->session->set($this->urlStackName, ""); // 세션에서 제거
|
||||
return $url;
|
||||
}
|
||||
return '/';
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Session Writers (Login/Logout Process)
|
||||
// ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* 인증 성공 후 세션에 사용자 정보를 기록합니다.
|
||||
*/
|
||||
public function setAuthSession(UserEntity $entity): void
|
||||
{
|
||||
$this->session->set(self::SESSION_IS_LOGIN, true);
|
||||
$this->session->set(self::SESSION_AUTH_INFO, [
|
||||
'uid' => (int) $entity->getPK(),
|
||||
'id' => $entity->getID(),
|
||||
'name' => $entity->getTitle(),
|
||||
'role' => $entity->getRole()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그아웃 시 세션 및 쿠키를 파괴합니다.
|
||||
*/
|
||||
public function destroyAuthSession(): void
|
||||
{
|
||||
// 세션 데이터 삭제
|
||||
$this->session->remove(self::SESSION_IS_LOGIN);
|
||||
$this->session->remove(self::SESSION_AUTH_INFO);
|
||||
|
||||
// 모든 세션 데이터 삭제
|
||||
$this->session->destroy();
|
||||
|
||||
// 세션 쿠키 삭제 (AuthService에서 가져온 로직)
|
||||
if (ini_get("session.use_cookies")) {
|
||||
$params = session_get_cookie_params();
|
||||
setcookie(
|
||||
session_name(),
|
||||
'',
|
||||
time() - 42000,
|
||||
$params["path"],
|
||||
$params["domain"],
|
||||
$params["secure"],
|
||||
$params["httponly"]
|
||||
);
|
||||
}
|
||||
// 세션 재생성
|
||||
session_start();
|
||||
$this->session->regenerate(true);
|
||||
}
|
||||
}
|
||||
23
app/Libraries/CommonLibrary.php
Normal file
23
app/Libraries/CommonLibrary.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
abstract class CommonLibrary
|
||||
{
|
||||
private $_libraryDatas = [];
|
||||
protected function __construct()
|
||||
{
|
||||
}
|
||||
final public function __get($name)
|
||||
{
|
||||
if (!array_key_exists($name, $this->_libraryDatas)) {
|
||||
return null;
|
||||
}
|
||||
return $this->_libraryDatas[$name];
|
||||
}
|
||||
|
||||
final public function __set($name, $value): void
|
||||
{
|
||||
$this->_libraryDatas[$name] = $value;
|
||||
}
|
||||
}
|
||||
128
app/Libraries/MySocket/GoogleSocket/API.php
Normal file
128
app/Libraries/MySocket/GoogleSocket/API.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\MySocket\GoogleSocket;
|
||||
|
||||
use App\Entities\UserSNSEntity as Entity;
|
||||
use CodeIgniter\Exceptions\ConfigException;
|
||||
use Google\Client;
|
||||
use Google\Service\Oauth2;
|
||||
|
||||
class API extends GoogleSocket
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getClient(): Client
|
||||
{
|
||||
if (!$this->_client) {
|
||||
$this->_client = new Client();
|
||||
$this->_client->setClientId(env('socket.google.client.id'));
|
||||
$this->_client->setClientSecret(env('socket.google.client.key'));
|
||||
$this->_client->setRedirectUri(base_url(env('socket.google.client.callback_url')));
|
||||
$this->_client->addScope(Oauth2::USERINFO_EMAIL);
|
||||
$this->_client->addScope(Oauth2::USERINFO_PROFILE);
|
||||
// $this->setPrompt('select_account consent');
|
||||
// $this->setAccessType('offline');
|
||||
// SSL 검증 비활성화
|
||||
$this->_client->setHttpClient(new \GuzzleHttp\Client(['verify' => false]));
|
||||
// 사용자 정의 CA 번들 사용
|
||||
// $this->setHttpClient(new \GuzzleHttp\Client(['verify' => '/path/to/cacert.pem']));
|
||||
}
|
||||
return $this->_client;
|
||||
}
|
||||
|
||||
public function createAuthUrl(): string
|
||||
{
|
||||
return $this->getClient()->createAuthUrl();
|
||||
}
|
||||
|
||||
//TokenInfo
|
||||
// (object) array(
|
||||
// 'access_token' => 'sdfsdfsdfsdf',
|
||||
// 'expires_in' => 3599,
|
||||
// 'refresh_token' => 'sdfsdf',
|
||||
// 'scope' => 'https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/userinfo.email',
|
||||
// 'token_type' => 'Bearer',
|
||||
// 'id_token' => 'fadfasdfsadf.sdfsdf.sdfsd',
|
||||
// )
|
||||
// id_token(.을기준으로 base64_decode):
|
||||
// DEBUG - 2024-10-10 07:25:01 --> array (
|
||||
// 'alg' => 'RS256',
|
||||
// 'kid' => 'a50f6e70ef4bsdfsdffb8f54dce9ee',
|
||||
// 'typ' => 'JWT',
|
||||
// )
|
||||
// DEBUG - 2024-10-10 07:25:01 --> array (
|
||||
// 'iss' => 'accounts.google.com',
|
||||
// 'azp' => '105607sdfsdfsdfsdfogleusercontent.com',
|
||||
// 'aud' => '1056073563687sdfsdfsdftent.com',
|
||||
// 'sub' => '103667492342341096838',
|
||||
// 'email' => 'sdfsdfsdf@gmail.com',
|
||||
// 'email_verified' => true,
|
||||
// 'at_hash' => 'RKDNDFSrkeZ_LWg',
|
||||
// 'iat' => 1728df545102,
|
||||
// 'exp' => 172854df8702,
|
||||
// )
|
||||
// DEBUG - 2024-10-10 07:25:01 --> NULL
|
||||
public function setToken(string $access_code): void
|
||||
{
|
||||
// 토큰 정보 가져오기
|
||||
$tokenInfo = $this->getClient()->fetchAccessTokenWithAuthCode($access_code);
|
||||
if (isset($tokenInfo['error'])) {
|
||||
throw new ConfigException($tokenInfo['error']);
|
||||
}
|
||||
// log_message("debug", var_export($tokenInfo, true));
|
||||
$this->_access_token = $tokenInfo[$this->_token_name];
|
||||
// Google Service에 접근하기 위해 Access Token 설정
|
||||
$this->getClient()->setAccessToken([
|
||||
'access_token' => $this->_access_token,
|
||||
'expires_in' => 3600,
|
||||
'created' => time(),
|
||||
]);
|
||||
if ($this->getClient()->isAccessTokenExpired()) {
|
||||
$this->getClient()->refreshToken($tokenInfo['refresh_token']);
|
||||
}
|
||||
// 세션에 Token 값 설정
|
||||
$this->getSession()->set($this->_token_name, $this->_access_token);
|
||||
}
|
||||
|
||||
// DEBUG - 2024-10-10 12:00:13 --> \Google\Service\Oauth2\Userinfo::__set_state(array(
|
||||
// 'internal_gapi_mappings' =>
|
||||
// array (
|
||||
// 'familyName' => 'family_name',
|
||||
// 'givenName' => 'given_name',
|
||||
// 'verifiedEmail' => 'verified_email',
|
||||
// ),
|
||||
// 'modelData' =>
|
||||
// array (
|
||||
// 'verified_email' => true,
|
||||
// 'given_name' => '길동',
|
||||
// 'family_name' => '홍',
|
||||
// ),
|
||||
// 'processed' =>
|
||||
// array (
|
||||
// ),
|
||||
// 'email' => 'sdfsdd@gmail.com',
|
||||
// 'familyName' => '홍',
|
||||
// 'gender' => NULL,
|
||||
// 'givenName' => '길동',
|
||||
// 'hd' => NULL,
|
||||
// 'id' => '103667499972324688341096838',
|
||||
// 'link' => NULL,
|
||||
// 'locale' => NULL,
|
||||
// 'name' => '홍길동',
|
||||
// 'picture' => 'https://lh3.googleusercontent.com/a/VDSJj3D925VP-pt9ppnwsPtm4pyYE6IO7bei-RyVM0Q=s96-c',
|
||||
// 'verifiedEmail' => true,
|
||||
// ))
|
||||
public function signup(): Entity
|
||||
{
|
||||
$this->getClient()->setAccessToken($this->getToken());
|
||||
$oauth = new Oauth2($this->getClient());
|
||||
$userInfo = $oauth->userinfo->get();
|
||||
$detail = var_export($userInfo, true);
|
||||
// log_message("debug", $detail);
|
||||
// 사용자정보 등록하기
|
||||
return $this->signup_process($userInfo->id, $userInfo->name, $userInfo->email, $detail);
|
||||
}
|
||||
}
|
||||
171
app/Libraries/MySocket/GoogleSocket/CURL.php
Normal file
171
app/Libraries/MySocket/GoogleSocket/CURL.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\MySocket\GoogleSocket;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use App\Entities\UserSNSEntity as Entity;
|
||||
|
||||
class CURL extends GoogleSocket
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getClient(): Client
|
||||
{
|
||||
if (!$this->_client) {
|
||||
$this->_client = new Client();
|
||||
}
|
||||
return $this->_client;
|
||||
}
|
||||
|
||||
public function createAuthUrl(): string
|
||||
{
|
||||
$options = http_build_query([
|
||||
'response_type' => 'code',
|
||||
'client_id' => env('socket.google.client.id'),
|
||||
'redirect_uri' => base_url(env('socket.google.client.callback_url')),
|
||||
'scope' => "https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/userinfo.email",
|
||||
'access_type' => 'offline',
|
||||
'prompt' => 'consent'
|
||||
]);
|
||||
//기본적으로 검색할 범위를 지정하고 사용자를 Google OAuth 동의 화면으로 리디렉션합니다
|
||||
return "https://accounts.google.com/o/oauth2/v2/auth?" . $options;
|
||||
}
|
||||
|
||||
//TokenInfo
|
||||
// (object) array(
|
||||
// 'access_token' => 'sdfsdfsdfsdf',
|
||||
// 'expires_in' => 3599,
|
||||
// 'refresh_token' => 'sdfsdf',
|
||||
// 'scope' => 'https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/userinfo.email',
|
||||
// 'token_type' => 'Bearer',
|
||||
// 'id_token' => 'fadfasdfsadf.sdfsdf.sdfsd',
|
||||
// )
|
||||
// id_token(.을기준으로 base64_decode):
|
||||
// DEBUG - 2024-10-10 07:25:01 --> array (
|
||||
// 'alg' => 'RS256',
|
||||
// 'kid' => 'a50f6e70ef4bsdfsdffb8f54dce9ee',
|
||||
// 'typ' => 'JWT',
|
||||
// )
|
||||
// DEBUG - 2024-10-10 07:25:01 --> array (
|
||||
// 'iss' => 'accounts.google.com',
|
||||
// 'azp' => '105607sdfsdfsdfsdfogleusercontent.com',
|
||||
// 'aud' => '1056073563687sdfsdfsdftent.com',
|
||||
// 'sub' => '103667492342341096838',
|
||||
// 'email' => 'sdfsdfsdf@gmail.com',
|
||||
// 'email_verified' => true,
|
||||
// 'at_hash' => 'RKDNDFSrkeZ_LWg',
|
||||
// 'iat' => 1728df545102,
|
||||
// 'exp' => 172854df8702,
|
||||
// )
|
||||
// DEBUG - 2024-10-10 07:25:01 --> NULL
|
||||
|
||||
public function setToken(string $access_code): void
|
||||
{
|
||||
$options = [
|
||||
'code' => $access_code,
|
||||
'client_id' => env('socket.google.client.id'),
|
||||
'client_secret' => env('socket.google.client.key'),
|
||||
'redirect_uri' => base_url(env('socket.google.client.callback_url')),
|
||||
'grant_type' => 'authorization_code',
|
||||
];
|
||||
$response = $this->post("https://accounts.google.com/o/oauth2/token", $options);
|
||||
if ($response->getStatusCode() != 200) {
|
||||
$message = sprintf(
|
||||
"Google: %s에서 API 호출 실패: \n--request options--\n%s\n--response--\n%s\n",
|
||||
__FUNCTION__,
|
||||
var_export($options, true),
|
||||
var_export($response, true)
|
||||
);
|
||||
log_message("error", $message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
$tokenInfo = json_decode($response->getBody(), true);
|
||||
// log_message("debug", var_export($tokenInfo, true));
|
||||
if (isset($tokenInfo['error']) || !isset($tokenInfo[$this->_token_name]) || empty($tokenInfo[$this->_token_name])) {
|
||||
$message = sprintf(
|
||||
"Google: Token 정보가 없습니다.\n--tokenInfo--\n%s\n",
|
||||
__FUNCTION__,
|
||||
var_export($tokenInfo, true)
|
||||
);
|
||||
log_message("error", $message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
//JWT값
|
||||
// $jwts = explode('.', $tokenInfo['id_token']);
|
||||
// foreach ($jwts as $jwt) {
|
||||
// $info = json_decode(base64_decode($jwt), true);
|
||||
// // log_message("debug", var_export($info, true));
|
||||
// }
|
||||
// 토큰 정보 가져오기
|
||||
$this->_access_token = $tokenInfo[$this->_token_name];
|
||||
// 세션에 Token 값 설정
|
||||
$this->getSession()->set($this->_token_name, $this->_access_token);
|
||||
}
|
||||
|
||||
// throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 데이터 처리 필요");
|
||||
// DEBUG - 2023-07-13 12:54:51 --> \Google\Service\Oauth2\Userinfo::__set_state(array(
|
||||
// 'internal_gapi_mappings' =>
|
||||
// 'familyName' => 'family_name',
|
||||
// 'givenName' => 'given_name',
|
||||
// 'verifiedEmail' => 'verified_email',
|
||||
// ),
|
||||
// 'modelData' =>
|
||||
// array (
|
||||
// 'verified_email' => true,
|
||||
// 'given_name' => '이름',
|
||||
// 'family_name' => '성',
|
||||
// ),
|
||||
// 'processed' =>
|
||||
// array (
|
||||
// ),
|
||||
// 'email' => 'twsdfsew342s@gmail.com',
|
||||
// 'familyName' => '성',
|
||||
// 'gender' => NULL,
|
||||
// 'givenName' => '이름',
|
||||
// 'hd' => NULL,
|
||||
// 'id' => '103667492432234234236838324',
|
||||
// 'link' => NULL,
|
||||
// 'locale' => 'ko',
|
||||
// 'name' => '성이름',
|
||||
// 'picture' => 'https://lh3.googleusercontent.com/a/AAcHTteFSgefsdfsdRJBkJA2tBEmg4PQrvI1Ta_5IXu5=s96-c',
|
||||
// 'verifiedEmail' => true,
|
||||
// ))
|
||||
public function signup(): Entity
|
||||
{
|
||||
$options = [
|
||||
"headers" => [
|
||||
"Authorization" => "Bearer {$this->getToken()}",
|
||||
"Accept" => "application/json",
|
||||
'User-Agent' => $this->getUserAgent()
|
||||
],
|
||||
];
|
||||
$response = $this->get("https://www.googleapis.com/oauth2/v3/userinfo", $options);
|
||||
if ($response->getStatusCode() != 200) {
|
||||
$message = sprintf(
|
||||
"Google: %s에서 API 호출 실패: \n--request options--\n%s\n--response--\n%s\n",
|
||||
__FUNCTION__,
|
||||
var_export($options, true),
|
||||
var_export($response, true)
|
||||
);
|
||||
log_message("error", $message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
$userInfo = json_decode($response->getBody(), true);
|
||||
$detail = var_export($userInfo, true);
|
||||
// log_message("debug", $detail);
|
||||
if (isset($userInfo['error']) || !isset($userInfo['email']) || empty($userInfo['email'])) {
|
||||
$message = sprintf(
|
||||
"Google: User 정보가 없습니다.\n--userInfo--\n%s\n",
|
||||
__FUNCTION__,
|
||||
var_export($userInfo, true)
|
||||
);
|
||||
log_message("error", $message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
// 사용자정보 등록하기
|
||||
return $this->signup_process($userInfo["id"], $userInfo["name"], $userInfo["email"], $detail);
|
||||
}
|
||||
}
|
||||
75
app/Libraries/MySocket/GoogleSocket/GoogleSocket.php
Normal file
75
app/Libraries/MySocket/GoogleSocket/GoogleSocket.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\MySocket\GoogleSocket;
|
||||
|
||||
use App\Entities\UserSNSEntity as Entity;
|
||||
use App\Libraries\MySocket\MySocket;
|
||||
use App\Models\UserSNSModel as Model;
|
||||
use App\Services\UserSNSService as Service;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\Session\Session;
|
||||
use Config\Services;
|
||||
|
||||
abstract class GoogleSocket extends MySocket
|
||||
{
|
||||
private string $_site = "GOOGLE";
|
||||
private ?Service $_service = null;
|
||||
protected $_client = null;
|
||||
private ?Session $_session = null;
|
||||
protected string $_access_token = "";
|
||||
protected string $_token_name = "access_token";
|
||||
public function __construct() {}
|
||||
abstract public function createAuthUrl(): string;
|
||||
abstract public function setToken(string $access_code): void;
|
||||
abstract public function signup(): Entity;
|
||||
final public function getSession(): Session
|
||||
{
|
||||
if ($this->_session == null) {
|
||||
$this->_session = Services::session();
|
||||
}
|
||||
return $this->_session;
|
||||
}
|
||||
final public function getToken(): string
|
||||
{
|
||||
return $this->getSession()->get($this->_token_name);
|
||||
}
|
||||
final public function getSite(): string
|
||||
{
|
||||
return $this->_site;
|
||||
}
|
||||
public function getService(): Service
|
||||
{
|
||||
if (!$this->_service) {
|
||||
$this->_service = new Service();
|
||||
}
|
||||
return $this->_service;
|
||||
}
|
||||
final protected function signup_process(string $id, string $name, string $email, string $detail): Entity
|
||||
{
|
||||
//이미 등록된 사용자인지 확인 후 없으면 등록 처리리
|
||||
$entity = $this->getService()->getEntity([Model::SITE => $this->getSite(), 'id' => $id], false);
|
||||
if (!$entity) {
|
||||
try {
|
||||
//없다면 새로 등록
|
||||
$formDatas = [
|
||||
'site' => $this->getSite(),
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'detail' => $detail,
|
||||
'status' => 'unuse',
|
||||
];
|
||||
$entity = $this->getService()->create($formDatas);
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
log_message("error", $e->getMessage());
|
||||
throw new \Exception(__FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
//상태가 use(승인완료)가 아니라면
|
||||
if ($entity->getStatus() !== DEFAULTS['STATUS']) {
|
||||
throw new PageNotFoundException(message: "{$entity->getSite()}의{$entity->getEmail()}:{$entity->getTitle()}님은 {$entity->status}입니다 ");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
91
app/Libraries/MySocket/MySocket.php
Normal file
91
app/Libraries/MySocket/MySocket.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\MySocket;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use Cloudflare\API\Adapter\ResponseException;
|
||||
|
||||
abstract class MySocket
|
||||
{
|
||||
private $_cookieJar = null;
|
||||
protected function __construct() {}
|
||||
abstract public function getClient(): mixed;
|
||||
final protected function getCookieJar(): CookieJar
|
||||
{
|
||||
if (!$this->_cookieJar) {
|
||||
$this->_cookieJar = new CookieJar();
|
||||
}
|
||||
return $this->_cookieJar;
|
||||
}
|
||||
protected function getUserAgent(): string
|
||||
{
|
||||
// User-Agent 목록 배열
|
||||
$userAgents = [
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0',
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1',
|
||||
'Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Mobile Safari/537.36'
|
||||
];
|
||||
return $userAgents[array_rand($userAgents)];
|
||||
}
|
||||
protected function getRequestOptions(string $method, array $options = [], array $headers = []): array
|
||||
{
|
||||
//cookies->쿠키값 , timeout->5초 안에 응답이 없으면 타임아웃
|
||||
//method가 get이면 $request['query'] = $options , 다른것이면 $request['json] = $options
|
||||
$options = [
|
||||
// 'cookies' => $this->getCookieJar(),
|
||||
'timeout' => env("socket.web.timeout") ?? 5,
|
||||
'headers' => $headers,
|
||||
in_array($method, ['get']) ? 'query' : 'json' => $options
|
||||
];
|
||||
return $options;
|
||||
}
|
||||
public function request(string $method, $uri = '', array $options = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) {
|
||||
throw new \InvalidArgumentException("{$method} => Request method must be get, post, put, patch, or delete");
|
||||
}
|
||||
try {
|
||||
$options = $this->getRequestOptions($method, $options, $headers);
|
||||
$response = $this->getClient()->$method($uri, $options);
|
||||
$body = json_decode(json: $response->getBody());
|
||||
if (!$body->success) {
|
||||
$message = sprintf(
|
||||
"%s에서 {$uri} 실패:\nrequest:%s\nresponse:%s",
|
||||
$method,
|
||||
$uri,
|
||||
var_export($options, true),
|
||||
var_export($response, true)
|
||||
);
|
||||
log_message("error", $message);
|
||||
throw new ResponseException($message);
|
||||
}
|
||||
return $response;
|
||||
} catch (RequestException $err) {
|
||||
throw ResponseException::fromRequestException($err);
|
||||
}
|
||||
}
|
||||
final public function get($uri, array $options = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request(__FUNCTION__, $uri, $options, $headers);
|
||||
}
|
||||
final public function post($uri, array $options = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request(__FUNCTION__, $uri, $options, $headers);
|
||||
}
|
||||
final public function put($uri, array $options = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request(__FUNCTION__, $uri, $options, $headers);
|
||||
}
|
||||
final public function patch($uri, array $options = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request(__FUNCTION__, $uri, $options, $headers);
|
||||
}
|
||||
final public function delete($uri, array $options = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request(__FUNCTION__, $uri, $options, $headers);
|
||||
}
|
||||
}
|
||||
47
app/Libraries/MySocket/WebSocket.php
Normal file
47
app/Libraries/MySocket/WebSocket.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\MySocket;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use RuntimeException;
|
||||
|
||||
class WebSocket extends MySocket
|
||||
{
|
||||
private ?Client $_client = null;
|
||||
private $_host = null;
|
||||
public function __construct(string $host)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_host = $host;
|
||||
}
|
||||
public function getClient(): Client
|
||||
{
|
||||
if (!$this->_client) {
|
||||
$this->_client = new Client();
|
||||
}
|
||||
return $this->_client;
|
||||
}
|
||||
final public function getURL($uri): string
|
||||
{
|
||||
// url에 http 나 https가 포함되어 있지않으면
|
||||
if (!preg_match('~^(http|https)://~i', $uri)) {
|
||||
$uri = "{$this->_host}{$uri}";
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
public function getResponse($uri, array $options = []): ResponseInterface
|
||||
{
|
||||
$response = $this->get($this->getURL($uri), $options);
|
||||
if ($response->getStatusCode() != 200) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 error {$uri} 접속실패: " . $response->getStatusCode());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
public function getContent(string $uri, array $options = []): string
|
||||
{
|
||||
$response = $this->getResponse($uri, $options);
|
||||
// return $response->getBody()->getContents();
|
||||
return $response->getBody();
|
||||
}
|
||||
}
|
||||
111
app/Libraries/MyStorage/FileStorage.php
Normal file
111
app/Libraries/MyStorage/FileStorage.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\MyStorage;
|
||||
|
||||
use App\Libraries\CommonLibrary;
|
||||
use App\Traits\FileTrait;
|
||||
|
||||
class FileStorage extends CommonLibrary
|
||||
{
|
||||
use FileTrait;
|
||||
private $_path = "";
|
||||
private $_originName = "";
|
||||
private $_originContent = "";
|
||||
private $_originMediaTag = "";
|
||||
private $_originSequence = "";
|
||||
private $_mimeType = "";
|
||||
private $_fileSize = 0;
|
||||
private $_imageLibrary = null;
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_path = $path;
|
||||
}
|
||||
final public function getPath(): string
|
||||
{
|
||||
return $this->_path;
|
||||
}
|
||||
public function getUploadPath(): string
|
||||
{
|
||||
return "uploads";
|
||||
}
|
||||
final public function getFullPath(): string
|
||||
{
|
||||
$full_path = WRITEPATH . $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getPath();
|
||||
$this->mkdir_FileTrait($full_path);
|
||||
return $full_path;
|
||||
}
|
||||
public function getUploadURL(): string
|
||||
{
|
||||
return "uploads";
|
||||
}
|
||||
final public function getOriginName(): string
|
||||
{
|
||||
return $this->_originName;
|
||||
}
|
||||
final public function setOriginName(string $originName): void
|
||||
{
|
||||
$this->_originName = $originName;
|
||||
}
|
||||
final public function getOriginContent(): string
|
||||
{
|
||||
return $this->_originContent;
|
||||
}
|
||||
final public function setOriginContent(string $originContent): void
|
||||
{
|
||||
$this->_originContent = $originContent;
|
||||
}
|
||||
final public function getOriginMediaTag(): string
|
||||
{
|
||||
return $this->_originMediaTag;
|
||||
}
|
||||
final public function setOriginMediaTag(string $originMediaTag): void
|
||||
{
|
||||
$this->_originMediaTag = $originMediaTag;
|
||||
}
|
||||
final public function getOriginSequence(): int
|
||||
{
|
||||
return $this->_originSequence;
|
||||
}
|
||||
final public function setOriginSequence(int $originSequence): void
|
||||
{
|
||||
$this->_originSequence = $originSequence;
|
||||
}
|
||||
final public function getMimeType(): string
|
||||
{
|
||||
return $this->_mimeType;
|
||||
}
|
||||
final public function getFileSize(): int
|
||||
{
|
||||
return $this->_fileSize;
|
||||
}
|
||||
public function save(): self
|
||||
{
|
||||
// log_message("notice", __FUNCTION__ . " 원본파일 {$this->getOriginName()} 작업 시작 2");
|
||||
$save_file = $this->getFullPath() . DIRECTORY_SEPARATOR . $this->getOriginName();
|
||||
log_message("debug", __FUNCTION__ . " {$save_file} 작업 시작");
|
||||
//중복된 파일명인지 확인후 새로운 이름으로 저장
|
||||
if (file_exists($save_file)) {
|
||||
switch (env("mangboard.uploads.file.collision")) {
|
||||
case "unique":
|
||||
$file_name = $this->getUniqueName_FileTrait($this->getFullPath(), $this->getOriginName());
|
||||
log_message("notice", __FUNCTION__ . " 파일명 변경 : 원본파일 {$this->getOriginName()}->저장파일 {$file_name}");
|
||||
$this->setOriginName($file_name);
|
||||
$save_file = $this->getFullPath() . DIRECTORY_SEPARATOR . $this->getOriginName();
|
||||
break;
|
||||
case "notallow":
|
||||
default:
|
||||
throw new \Exception(__FUNCTION__ . " {$this->getOriginName()} 는 이미 존재하는 파일입니다.");
|
||||
// break;
|
||||
}
|
||||
}
|
||||
//원본이미지 저장
|
||||
if (!file_put_contents($save_file, $this->getOriginContent())) {
|
||||
throw new \Exception(__FUNCTION__ . " 파일저장 실패:{$save_file}");
|
||||
}
|
||||
$this->_mimeType = mime_content_type($save_file);
|
||||
$this->_fileSize = filesize($save_file);
|
||||
log_message("notice", __FUNCTION__ . " 원본파일 {$this->getOriginName()} 작업 완료");
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
21
app/Libraries/OperationContext.php
Normal file
21
app/Libraries/OperationContext.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Libraries\AuthContext;
|
||||
|
||||
class OperationContext
|
||||
{
|
||||
public string $action;
|
||||
public AuthContext $auth;
|
||||
public array $datas;
|
||||
public array $pipelineDatas = []; // 파이프라인 단계별 데이터를 저장할 공간
|
||||
public ?\Throwable $error = null;
|
||||
|
||||
public function __construct(string $action, array $datas, AuthContext $auth)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->auth = $auth;
|
||||
$this->datas = $datas;
|
||||
}
|
||||
}
|
||||
51
app/Libraries/PipelineStep.php
Normal file
51
app/Libraries/PipelineStep.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Libraries\OperationContext;
|
||||
use App\Services\MylogService;
|
||||
use RuntimeException;
|
||||
|
||||
class PipelineStep
|
||||
{
|
||||
protected MylogService $logService;
|
||||
|
||||
// CI4의 DI (의존성 주입)를 통해 LogService만 받습니다.
|
||||
public function __construct(MylogService $logService)
|
||||
{
|
||||
$this->logService = $logService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 서비스 단계(Step) 배열을 받아 순차적으로 실행합니다.
|
||||
* @param array<PipelineStep> $steps 실행할 PipelineStep 객체들의 배열
|
||||
* @param OperationContext $context 초기 컨텍스트
|
||||
* @return OperationContext 최종 컨텍스트
|
||||
*/
|
||||
public function run(array $steps, OperationContext $context): OperationContext
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$db->transBegin();
|
||||
try {
|
||||
// 1. Log START: 파이프라인 시작 로깅
|
||||
$this->logService->log($context, 'START');
|
||||
// 2. 단계(Steps) 순차 실행
|
||||
foreach ($steps as $step) {
|
||||
if (!($step instanceof PipelineStepInterface)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 파이프라인 단계는 PipelineStep 인터페이스를 구현해야 합니다.");
|
||||
}
|
||||
$context = $step->handle($context);
|
||||
}
|
||||
// 3. Log SUCCESS: 모든 단계 성공 로깅
|
||||
$this->logService->log($context, 'SUCCESS');
|
||||
return $context;
|
||||
} catch (\Throwable $e) {
|
||||
$db->transRollback();
|
||||
// 4. Log FAILURE: 오류 발생 시 즉시 로깅
|
||||
$context->error = $e;
|
||||
$this->logService->log($context, 'FAILURE');
|
||||
// 5. 오류를 상위 계층으로 전파
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user