vhost init...1
This commit is contained in:
parent
2ecf200b1d
commit
ee58dcedef
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
#codeigniter 4
|
||||
!.htaccess
|
||||
!.writable/api/index.html
|
||||
!.writable/cache/index.html
|
||||
!.writable/download/index.html
|
||||
!.writable/excel/index.html
|
||||
!.writable/uploads/index.html
|
||||
!.writable/.htaccess
|
||||
.env
|
||||
writable/api/
|
||||
writable/cache/
|
||||
writable/debugbar/
|
||||
writable/download/
|
||||
writable/excel/
|
||||
writable/logs/
|
||||
writable/session/
|
||||
writable/uploads/
|
||||
vendor/
|
||||
vendors/
|
||||
composer.lock
|
||||
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-2023 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.
|
||||
67
README.md
Normal file
67
README.md
Normal file
@ -0,0 +1,67 @@
|
||||
#Tips
|
||||
#참고 : https://github.com/bundanining/Shopping-Cart-Solution-CodeIgniter
|
||||
vscode와 Git의 대소문자 구분시키기
|
||||
git config core.ignorecase false
|
||||
|
||||
# 1. CodeIgniter 4 Application Starter
|
||||
|
||||
`composer create-project codeigniter4/appstarter 프로젝트명`
|
||||
|
||||
## 2. Setup
|
||||
|
||||
php.ini에 extension=intl 필요
|
||||
apache의 DocumentRoot "패키지명/public" 수정 후 restart 필요
|
||||
Copy `env` to `.env` and tailor for your app, specifically the baseURL and any database settings.
|
||||
.env 수정
|
||||
CI_ENVIRONMENT = development
|
||||
|
||||
# 3. 필요한 추가 패키지
|
||||
|
||||
composer require saleh7/proxmox-ve_php_api
|
||||
|
||||
## 4. Running Development Server
|
||||
|
||||
php spark serve
|
||||
|
||||
## 5. Web접속
|
||||
|
||||
개발용 -> localhost:8080
|
||||
실서버 -> https://proxmox.idcjp.jp
|
||||
|
||||
## 6. new Controller추가시 Config\Routes.php에 Routing설정 필요
|
||||
|
||||
$routes->get('/ProxmoxAPI', 'ProxmoxAPI::index');
|
||||
|
||||
## 7. composer.json의 "psr-4" 수정시 reload
|
||||
|
||||
"psr-4": {
|
||||
"Tests\\Support\\": "tests/\_support"
|
||||
"APP\\": "app"
|
||||
}
|
||||
composer dump-autoload
|
||||
|
||||
## 8. php spark 사용법 (https://onlinewebtutorblog.com/how-to-work-with-codeigniter-4-model-and-entity-tutorial/)
|
||||
|
||||
- User Table 관련
|
||||
php spark migrate:create create_user_table --> table 생성
|
||||
php spark migrate --> table 적용
|
||||
php spark make:migration update_and_addfield_to_users_table --> 기존 table 내용변경없이 column변경시
|
||||
php spark migrate:refresh --> table 수정후 재생성
|
||||
php spark migrate:rollback
|
||||
php spark migrate:status --> 상태보기
|
||||
|
||||
- 초기 데이터 넣기
|
||||
php spark make:seeder user --suffix
|
||||
php spark db:seed UsersSeeder
|
||||
|
||||
- mvc 생성 --suffix 추가필요
|
||||
php spark make:model user --suffix
|
||||
php spark make:controller user --suffix
|
||||
php spark make:entity user --suffix
|
||||
|
||||
- auth용
|
||||
php spark make:filter AuthGuard
|
||||
|
||||
## 9. Login관련 참조
|
||||
|
||||
https://www.jurisic.org/post/2022/11/28/How-to-make-simple-Authentication-with-CodeIgniter-4
|
||||
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>
|
||||
26
app/Cells/BoardCell.php
Normal file
26
app/Cells/BoardCell.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cells;
|
||||
|
||||
use App\Models\BoardModel;
|
||||
|
||||
class BoardCell
|
||||
{
|
||||
private $_boardModel = null;
|
||||
private function getBoardModel(): BoardModel
|
||||
{
|
||||
return $this->_boardModel = $this->_boardModel ?: new BoardModel();
|
||||
}
|
||||
public function information(array $viewDatas): string
|
||||
{
|
||||
helper('Board');
|
||||
$viewDatas['cellDatas'] = array();
|
||||
$viewDatas['cellDatas']['entitys'] = $this->getBoardModel()->getEntitys([
|
||||
'category_uid' => __FUNCTION__
|
||||
]);
|
||||
return view(
|
||||
'Views/front/board/cell/' . __FUNCTION__,
|
||||
['viewDatas' => $viewDatas]
|
||||
);
|
||||
}
|
||||
}
|
||||
15
app/Cells/ProductCell.php
Normal file
15
app/Cells/ProductCell.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cells;
|
||||
|
||||
class ProductCell
|
||||
{
|
||||
public function virtual_calculator(array $viewDatas): string
|
||||
{
|
||||
$viewDatas['cellDatas']=array();
|
||||
return view(
|
||||
'Views/front/product/cell/' . __FUNCTION__,
|
||||
['viewDatas'=>$viewDatas]
|
||||
);
|
||||
}
|
||||
}
|
||||
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://codeigniter4.github.io/CodeIgniter4/
|
||||
*/
|
||||
450
app/Config/App.php
Normal file
450
app/Config/App.php
Normal file
@ -0,0 +1,450 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Session\Handlers\FileHandler;
|
||||
|
||||
class App extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Base Site URL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* URL to your CodeIgniter root. Typically this will be your base URL,
|
||||
* WITH a trailing slash:
|
||||
*
|
||||
* http://example.com/
|
||||
*
|
||||
* If this is not set then CodeIgniter will try guess the protocol, domain
|
||||
* and path to your installation. However, you should always configure this
|
||||
* explicitly and never rely on auto-guessing, especially in production
|
||||
* environments.
|
||||
*/
|
||||
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 string[]
|
||||
* @phpstan-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 are using mod_rewrite to remove the page set this
|
||||
* variable so that it is blank.
|
||||
*/
|
||||
//public string $indexPage = 'index.php';
|
||||
public string $indexPage = '';
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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.
|
||||
*
|
||||
* @var 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()
|
||||
*/
|
||||
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';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* URI PROTOCOL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* 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 header will be set.
|
||||
*/
|
||||
public bool $forceGlobalSecureRequests = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Driver
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session storage driver to use:
|
||||
* - `CodeIgniter\Session\Handlers\FileHandler`
|
||||
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
|
||||
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
|
||||
* - `CodeIgniter\Session\Handlers\RedisHandler`
|
||||
*
|
||||
* @deprecated use Config\Session::$driver instead.
|
||||
*/
|
||||
public string $sessionDriver = FileHandler::class;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Cookie Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session cookie name, must contain only [0-9a-z_-] characters
|
||||
*
|
||||
* @deprecated use Config\Session::$cookieName instead.
|
||||
*/
|
||||
public string $sessionCookieName = '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.
|
||||
*
|
||||
* @deprecated use Config\Session::$expiration instead.
|
||||
*/
|
||||
public int $sessionExpiration = 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!
|
||||
*
|
||||
* @deprecated use Config\Session::$savePath instead.
|
||||
*/
|
||||
public string $sessionSavePath = 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.
|
||||
*
|
||||
* @deprecated use Config\Session::$matchIP instead.
|
||||
*/
|
||||
public bool $sessionMatchIP = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Time to Update
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* How many seconds between CI regenerating the session ID.
|
||||
*
|
||||
* @deprecated use Config\Session::$timeToUpdate instead.
|
||||
*/
|
||||
public int $sessionTimeToUpdate = 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.
|
||||
*
|
||||
* @deprecated use Config\Session::$regenerateDestroy instead.
|
||||
*/
|
||||
public bool $sessionRegenerateDestroy = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Database Group
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* DB Group for the database session.
|
||||
*
|
||||
* @deprecated use Config\Session::$DBGroup instead.
|
||||
*/
|
||||
public ?string $sessionDBGroup = null;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Prefix
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Set a cookie name prefix if you need to avoid collisions.
|
||||
*
|
||||
* @deprecated use Config\Cookie::$prefix property instead.
|
||||
*/
|
||||
public string $cookiePrefix = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Domain
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Set to `.your-domain.com` for site-wide cookies.
|
||||
*
|
||||
* @deprecated use Config\Cookie::$domain property instead.
|
||||
*/
|
||||
public string $cookieDomain = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Typically will be a forward slash.
|
||||
*
|
||||
* @deprecated use Config\Cookie::$path property instead.
|
||||
*/
|
||||
public string $cookiePath = '/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Secure
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie will only be set if a secure HTTPS connection exists.
|
||||
*
|
||||
* @deprecated use Config\Cookie::$secure property instead.
|
||||
*/
|
||||
public bool $cookieSecure = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie HttpOnly
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie will only be accessible via HTTP(S) (no JavaScript).
|
||||
*
|
||||
* @deprecated use Config\Cookie::$httponly property instead.
|
||||
*/
|
||||
public bool $cookieHTTPOnly = 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`, `$cookieSecure` must also be set.
|
||||
*
|
||||
* @deprecated use Config\Cookie::$samesite property instead.
|
||||
*/
|
||||
public ?string $cookieSameSite = 'Lax';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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 = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Token Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The token name.
|
||||
*
|
||||
* @deprecated Use `Config\Security` $tokenName property instead of using this property.
|
||||
*/
|
||||
public string $CSRFTokenName = 'csrf_test_name';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Header Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The header name.
|
||||
*
|
||||
* @deprecated Use `Config\Security` $headerName property instead of using this property.
|
||||
*/
|
||||
public string $CSRFHeaderName = 'X-CSRF-TOKEN';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Cookie Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The cookie name.
|
||||
*
|
||||
* @deprecated Use `Config\Security` $cookieName property instead of using this property.
|
||||
*/
|
||||
public string $CSRFCookieName = 'csrf_cookie_name';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Expire
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The number in seconds the token should expire.
|
||||
*
|
||||
* @deprecated Use `Config\Security` $expire property instead of using this property.
|
||||
*/
|
||||
public int $CSRFExpire = 7200;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Regenerate
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Regenerate token on every submission?
|
||||
*
|
||||
* @deprecated Use `Config\Security` $regenerate property instead of using this property.
|
||||
*/
|
||||
public bool $CSRFRegenerate = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Redirect
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Redirect to previous page with error on failure?
|
||||
*
|
||||
* @deprecated Use `Config\Security` $redirect property instead of using this property.
|
||||
*/
|
||||
public bool $CSRFRedirect = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF SameSite
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Setting for CSRF SameSite cookie token. Allowed values are:
|
||||
* - None
|
||||
* - Lax
|
||||
* - Strict
|
||||
* - ''
|
||||
*
|
||||
* Defaults to `Lax` as recommended in this link:
|
||||
*
|
||||
* @see https://portswigger.net/web-security/csrf/samesite-cookies
|
||||
*
|
||||
* @deprecated `Config\Cookie` $samesite property is used.
|
||||
*/
|
||||
public string $CSRFSameSite = 'Lax';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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;
|
||||
}
|
||||
97
app/Config/Autoload.php
Normal file
97
app/Config/Autoload.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?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.
|
||||
*/
|
||||
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 '/app' and '/system' directories are already mapped for you.
|
||||
* you may change the name of the 'App' namespace if you wish,
|
||||
* but this should be done prior to creating any namespaced classes,
|
||||
* else you will need to modify all of those classes for this to work.
|
||||
*
|
||||
* Prototype:
|
||||
* $psr4 = [
|
||||
* 'CodeIgniter' => SYSTEMPATH,
|
||||
* 'App' => APPPATH
|
||||
* ];
|
||||
*
|
||||
* @var array<string, array<int, string>|string>
|
||||
* @phpstan-var array<string, string|list<string>>
|
||||
*/
|
||||
public $psr4 = [
|
||||
APP_NAMESPACE => APPPATH, // For custom app namespace
|
||||
'Config' => APPPATH . 'Config',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Class Map
|
||||
* -------------------------------------------------------------------
|
||||
* The class map provides a map of class names and their exact
|
||||
* location on the drive. Classes loaded in this manner will have
|
||||
* slightly faster performance because they will not have to be
|
||||
* searched for within one or more directories as they would if they
|
||||
* were being autoloaded through a namespace.
|
||||
*
|
||||
* Prototype:
|
||||
* $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 string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public $files = [];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Helpers
|
||||
* -------------------------------------------------------------------
|
||||
* Prototype:
|
||||
* $helpers = [
|
||||
* 'form',
|
||||
* ];
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public $helpers = [];
|
||||
}
|
||||
32
app/Config/Boot/development.php
Normal file
32
app/Config/Boot/development.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?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.
|
||||
*/
|
||||
error_reporting(-1);
|
||||
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);
|
||||
21
app/Config/Boot/production.php
Normal file
21
app/Config/Boot/production.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| Don't show ANY in production environments. Instead, let the system catch
|
||||
| it and display a generic error message.
|
||||
*/
|
||||
ini_set('display_errors', '0');
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode 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);
|
||||
32
app/Config/Boot/testing.php
Normal file
32
app/Config/Boot/testing.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?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.
|
||||
*/
|
||||
error_reporting(-1);
|
||||
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 = true;
|
||||
}
|
||||
169
app/Config/Cache.php
Normal file
169
app/Config/Cache.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
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';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cache Directory Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The path to where cache files should be stored, if using a file-based
|
||||
* system.
|
||||
*
|
||||
* @deprecated Use the driver-specific variant under $file
|
||||
*/
|
||||
public string $storePath = WRITEPATH . 'cache/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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.
|
||||
* array('q') = Enabled, but only take into account the specified list
|
||||
* of query parameters.
|
||||
*
|
||||
* @var bool|string[]
|
||||
*/
|
||||
public $cacheQueryString = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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<string, int|string|null>
|
||||
*/
|
||||
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<string, bool|int|string>
|
||||
*/
|
||||
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<string, int|string|null>
|
||||
*/
|
||||
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, string>
|
||||
*/
|
||||
public array $validHandlers = [
|
||||
'dummy' => DummyHandler::class,
|
||||
'file' => FileHandler::class,
|
||||
'memcached' => MemcachedHandler::class,
|
||||
'predis' => PredisHandler::class,
|
||||
'redis' => RedisHandler::class,
|
||||
'wincache' => WincacheHandler::class,
|
||||
];
|
||||
}
|
||||
303
app/Config/Constants.php
Normal file
303
app/Config/Constants.php
Normal file
@ -0,0 +1,303 @@
|
||||
<?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
|
||||
|
||||
/**
|
||||
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
|
||||
*/
|
||||
define('EVENT_PRIORITY_LOW', 200);
|
||||
|
||||
/**
|
||||
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
|
||||
*/
|
||||
define('EVENT_PRIORITY_NORMAL', 100);
|
||||
|
||||
/**
|
||||
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
|
||||
*/
|
||||
define('EVENT_PRIORITY_HIGH', 10);
|
||||
|
||||
define('LAYOUTS', [
|
||||
'empty' => [
|
||||
'path' => 'layouts' . DIRECTORY_SEPARATOR . 'empty',
|
||||
'stylesheets' => [
|
||||
'<link rel="icon" href="/favicon.ico">',
|
||||
'<link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">',
|
||||
'<link rel="stylesheet" href="/css/style.css" />',
|
||||
],
|
||||
'javascripts' => [
|
||||
'<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>',
|
||||
]
|
||||
],
|
||||
'front' => [
|
||||
'title' => '사용자화면',
|
||||
'path' => 'layouts' . DIRECTORY_SEPARATOR . 'front',
|
||||
'menus' => ['aboutus', 'hosting', 'service', 'support'],
|
||||
'stylesheets' => [
|
||||
'<link rel="icon" href="/favicon.ico">',
|
||||
'<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">',
|
||||
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">',
|
||||
'<link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">',
|
||||
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css">',
|
||||
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />',
|
||||
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/boxicons@latest/css/boxicons.min.css" />',
|
||||
'<link rel="stylesheet" href="/css/style.css" />',
|
||||
],
|
||||
'javascripts' => [
|
||||
'<script src="//cdn.jsdelivr.net/npm/jquery@3.7.0/dist/jquery.min.js"></script>',
|
||||
'<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>',
|
||||
'<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>',
|
||||
'<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>',
|
||||
'<script src="/vendors/tinymce/tinymce/tinymce.min.js" referrerpolicy="origin"></script>',
|
||||
],
|
||||
],
|
||||
'admin' => [
|
||||
'title' => '관리자화면',
|
||||
'path' => 'layouts' . DIRECTORY_SEPARATOR . 'admin',
|
||||
'stylesheets' => [
|
||||
'<link rel="icon" href="/favicon.ico">',
|
||||
'<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">',
|
||||
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">',
|
||||
'<link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">',
|
||||
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css">',
|
||||
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />',
|
||||
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/boxicons@latest/css/boxicons.min.css" />',
|
||||
'<link rel="stylesheet" href="/css/style.css" />',
|
||||
],
|
||||
'javascripts' => [
|
||||
'<script src="//cdn.jsdelivr.net/npm/jquery@3.7.0/dist/jquery.min.js"></script>',
|
||||
'<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>',
|
||||
'<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>',
|
||||
'<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>',
|
||||
'<script src="/vendors/tinymce/tinymce/tinymce.min.js" referrerpolicy="origin"></script>',
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
//URL
|
||||
define('URLS', [
|
||||
'LOGIN' => '/front/user/login',
|
||||
'SIGNUP' => '/front/user/signup',
|
||||
'LOGOUT' => '/front/user/logout',
|
||||
'Order' => '/front/order',
|
||||
'addCart' => '/front/order/addCart',
|
||||
'cancelCart' => '/front/order/cancelCart',
|
||||
'Billing' => '/front/billing',
|
||||
'card' => '/front/billing/card',
|
||||
'deposit' => '/front/billing/deposit',
|
||||
]);
|
||||
//SESSION 관련
|
||||
define('SESSION_NAMES', [
|
||||
'RETURN_URL' => "return_url",
|
||||
'ISLOGIN' => "islogined",
|
||||
'AUTH' => 'auth',
|
||||
'CART' => 'cart'
|
||||
]);
|
||||
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
|
||||
//월이용권 상품의 Category번호
|
||||
define('RENTAL_PRODUCT_CATEGORYS', [5, 8]);
|
||||
//인증 관련
|
||||
define('AUTH_ADAPTERS', [
|
||||
'Local' => [
|
||||
'DEBUG' => getenv("auth.loca.debug") ?: false,
|
||||
],
|
||||
'Google' => [
|
||||
'DEBUG' => getenv("auth.google.debug") ?: false,
|
||||
'ICON' => getenv("auth.google.icon") ?: '<img src="/images/auth/google_login_button.png"/>',
|
||||
'CLIENT_ID' => getenv("auth.google.client.id"),
|
||||
'CLIENT_KEY' => getenv("auth.google.client.key"),
|
||||
'CALLBACK_URL' => getenv("auth.google.client.callback_url"),
|
||||
'TOKEN_NAME' => getenv('auth.google.client.token_name') ?: "access_token",
|
||||
],
|
||||
]);
|
||||
|
||||
define("MALLS", [
|
||||
"support" => getenv("mall.support") ?: "support@idcjp.jp",
|
||||
"master" => getenv("mall.master") ?: "master@idcjp.jp",
|
||||
"title" => getenv("mall.title") ?: "Mall Master",
|
||||
'card' => getenv("mall.card") ?: "TEST",
|
||||
'payments' => [
|
||||
'CookiePayment' => [
|
||||
'token_url' => getenv("mall.payment.pay2pay.token_url") ?: "{TOKEN 발행 URL}",
|
||||
'token_id' => getenv("mall.payment.pay2pay.id") ?: 'cookiepayments에서 발급받은 ID',
|
||||
'token_key' => getenv("mall.payment.pay2pay.key") ?: 'cookiepayments에서 발급받은 연동키',
|
||||
'api_key' => getenv("mall.payment.pay2pay.apikey") ?: "COOKIEPAY에서 발급받은 연동키",
|
||||
'api_url' => getenv("mall.payment.pay2pay.url") ?: "{요청도메인}/keyin/payment",
|
||||
],
|
||||
],
|
||||
"banks" => [
|
||||
'BANK1' => [
|
||||
"name" => getenv("mall.bank.ibk.name") ?: "기업은행",
|
||||
"account" => getenv("mall.bank.ibk.account") ?: "525-05694804-012",
|
||||
"holder" => getenv("mall.bank.ibk.holder") ?: "주식회사 르호봇"
|
||||
],
|
||||
'BANK2' => [
|
||||
"name" => getenv("mall.bank.kookmin.name") ?: "우리은행",
|
||||
"account" => getenv("mall.bank.kookmin.account") ?: "1005-503-404205",
|
||||
"holder" => getenv("mall.bank.kookmin.holder") ?: "주식회사 르호봇"
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
//Upload , Download 관련
|
||||
define('PATHS', [
|
||||
'EXCEL' => WRITEPATH . "excel/",
|
||||
'BILLING' => WRITEPATH . "billing/",
|
||||
'UPLOAD' => WRITEPATH . "uploads/",
|
||||
'UPLOAD_IMAGE' => FCPATH . 'upload_images/',
|
||||
'DOWNLOAD' => WRITEPATH . "download/",
|
||||
'API' => WRITEPATH . "api/",
|
||||
]);
|
||||
foreach (PATHS as $key => $path) {
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path, 0755);
|
||||
}
|
||||
}
|
||||
|
||||
//아이콘 및 Sound관련
|
||||
define('ICONS', [
|
||||
'LOGIN' => '<i class="bi bi-shield-check"></i>',
|
||||
'LOGOUT' => '<i class="bi bi-sign-stop-fill"></i>',
|
||||
'LOCK' => '<i class="bi bi-shield-lock"></i>',
|
||||
'NEW' => '<i class="bi bi-database-add"></i>',
|
||||
'REPLY' => '<i class="bi bi-arrow-return-right"></i>',
|
||||
'DELETE' => '<i class="bi bi-trash"></i>',
|
||||
'RELOAD' => '<i class="bi bi-repeat"></i>',
|
||||
'SETUP' => '<i class="bi bi-gear"></i>',
|
||||
'FLAG' => '<i class="bi bi-send"></i>',
|
||||
'SEARCH' => '<i class="bi bi-search"></i>',
|
||||
'EXCEL' => '<img src="/images/common/excel.png"/>',
|
||||
'HOME' => '<i class="bi bi-house-door-fill"></i>',
|
||||
'PLAY' => '<i class="bi bi-play-fill"></i>',
|
||||
'CART' => '<i class="bi bi-cart4"></i>',
|
||||
'CARD' => '<i class="bi bi-credit-card"></i>',
|
||||
'DEPOSIT' => '<i class="bi bi-cash-coin"></i>',
|
||||
'UP' => '<i class="bi bi-arrow-up"></i>',
|
||||
'DOWN' => '<i class="bi bi-arrow-down"></i>',
|
||||
'LEFT' => '<i class="bi bi-arrow-left"></i>',
|
||||
'RIGHT' => '<i class="bi bi-arrow-right"></i>',
|
||||
'IMAGE_FILE' => '<i class="bi bi-file-earmark-image"></i>',
|
||||
]);
|
||||
define('CLASS_ICONS', [
|
||||
'USER' => '<i class="bi bi-person-vcard"></i>',
|
||||
'USERSNS' => '<i class="bi bi-globe"></i>',
|
||||
'BOARD' => '<i class="bi bi-pencil-square"></i>',
|
||||
'SITEPAGE' => '<i class="bi bi-body-text"></i>',
|
||||
'CATEGORY' => '<i class="bi bi-boxes"></i>',
|
||||
'PRODUCT' => '<i class="bi bi-box2"></i>',
|
||||
'ORDER' => '<i class="bi bi-clipboard-check"></i>',
|
||||
'BILLING' => '<i class="bi bi-clipboard-check"></i>',
|
||||
'CART' => '<i class="bi bi-cart4"></i>',
|
||||
'CARD' => '<i class="bi bi-credit-card"></i>',
|
||||
'DEPOSIT' => '<i class="bi bi-cash-coin"></i>',
|
||||
]);
|
||||
define('CLASS_TOP_BANNER', [
|
||||
'USER' => '<img src="/images/banner/sub_visual1.jpg"/>',
|
||||
'USERSNS' => '<img src="/images/banner/sub_visual1.jpg"/>',
|
||||
'ORDER' => '<img src="/images/banner/sub_visual1.jpg"/>',
|
||||
'BILLING' => '<img src="/images/banner/sub_visual1.jpg"/>',
|
||||
'CARD' => '<img src="/images/banner/sub_visual1.jpg"/>',
|
||||
'DEPOSIT' => '<img src="/images/banner/sub_visual1.jpg"/>',
|
||||
'PRODUCT' => '<img src="/images/banner/sub_visual2.jpg"/>',
|
||||
'SITEPAGE' => '<img src="/images/banner/sub_visual3.jpg"/>',
|
||||
'BOARD' => '<img src="/images/banner/sub_visual4.jpg"/>',
|
||||
]);
|
||||
define('AUDIOS', [
|
||||
'Alram_GetEmail' => '<object width=0 height=0 data="/sound/jarvis_email.mp3" type="audio/mpeg"></object>',
|
||||
]);
|
||||
|
||||
//Default값 정의
|
||||
define('DEFAULTS', [
|
||||
'CATEGORY_USER' => getenv('default.category.user') ?: 22,
|
||||
'CATEGORY_ORDER' => getenv('default.category.order') ?: 11,
|
||||
'CATEGORY_BILLING' => getenv('default.category.billing') ?: 28,
|
||||
'ROLE' => getenv('default.role') ?: "guest",
|
||||
'STATUS' => getenv('default.status') ?: "use",
|
||||
'EMPTY' => getenv('default.empty') ?: "",
|
||||
'PERPAGE' => getenv('default.perpage') ?: 20,
|
||||
'DELIMITER_FILE' => getenv('default.delimiter.file') ?: "||",
|
||||
'DELIMITER_ROLE' => getenv('default.delimiter.role') ?: ",",
|
||||
]);
|
||||
|
||||
//API Adapter초기갑 정의
|
||||
define('API', [
|
||||
'SSL_VERIFY' => getenv('api.ssl') == 'true' ? true : false,
|
||||
'COOKIE_FILE' => PATHS['API'] . getenv('api.cookie.file') ?: "api-cookie_" . date("Ymd") . ".log",
|
||||
'DEBUG_FILE' => PATHS['API'] . getenv('api.debug.file') ?: "api-debug_" . date("Ymd") . ".log",
|
||||
]);
|
||||
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 string|string[]|null
|
||||
*/
|
||||
public $defaultSrc;
|
||||
|
||||
/**
|
||||
* Lists allowed scripts' URLs.
|
||||
*
|
||||
* @var string|string[]
|
||||
*/
|
||||
public $scriptSrc = 'self';
|
||||
|
||||
/**
|
||||
* Lists allowed stylesheets' URLs.
|
||||
*
|
||||
* @var string|string[]
|
||||
*/
|
||||
public $styleSrc = 'self';
|
||||
|
||||
/**
|
||||
* Defines the origins from which images can be loaded.
|
||||
*
|
||||
* @var 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 string|string[]|null
|
||||
*/
|
||||
public $baseURI;
|
||||
|
||||
/**
|
||||
* Lists the URLs for workers and embedded frame contents
|
||||
*
|
||||
* @var string|string[]
|
||||
*/
|
||||
public $childSrc = 'self';
|
||||
|
||||
/**
|
||||
* Limits the origins that you can connect to (via XHR,
|
||||
* WebSockets, and EventSource).
|
||||
*
|
||||
* @var string|string[]
|
||||
*/
|
||||
public $connectSrc = 'self';
|
||||
|
||||
/**
|
||||
* Specifies the origins that can serve web fonts.
|
||||
*
|
||||
* @var string|string[]
|
||||
*/
|
||||
public $fontSrc;
|
||||
|
||||
/**
|
||||
* Lists valid endpoints for submission from `<form>` tags.
|
||||
*
|
||||
* @var 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 string|string[]|null
|
||||
*/
|
||||
public $frameAncestors;
|
||||
|
||||
/**
|
||||
* The frame-src directive restricts the URLs which may
|
||||
* be loaded into nested browsing contexts.
|
||||
*
|
||||
* @var array|string|null
|
||||
*/
|
||||
public $frameSrc;
|
||||
|
||||
/**
|
||||
* Restricts the origins allowed to deliver video and audio.
|
||||
*
|
||||
* @var string|string[]|null
|
||||
*/
|
||||
public $mediaSrc;
|
||||
|
||||
/**
|
||||
* Allows control over Flash and other plugins.
|
||||
*
|
||||
* @var string|string[]
|
||||
*/
|
||||
public $objectSrc = 'self';
|
||||
|
||||
/**
|
||||
* @var string|string[]|null
|
||||
*/
|
||||
public $manifestSrc;
|
||||
|
||||
/**
|
||||
* Limits the kinds of plugins a page may invoke.
|
||||
*
|
||||
* @var string|string[]|null
|
||||
*/
|
||||
public $pluginTypes;
|
||||
|
||||
/**
|
||||
* List of actions allowed.
|
||||
*
|
||||
* @var 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;
|
||||
}
|
||||
105
app/Config/Cookie.php
Normal file
105
app/Config/Cookie.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
84
app/Config/Database.php
Normal file
84
app/Config/Database.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?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.
|
||||
*/
|
||||
public array $default = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8',
|
||||
'DBCollat' => 'utf8_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
];
|
||||
|
||||
/**
|
||||
* This database connection is used when
|
||||
* running PHPUnit database tests.
|
||||
*/
|
||||
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' => 'utf8_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
117
app/Config/Email.php
Normal file
117
app/Config/Email.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?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 Address
|
||||
*/
|
||||
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. Either tls or ssl
|
||||
*/
|
||||
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;
|
||||
}
|
||||
83
app/Config/Encryption.php
Normal file
83
app/Config/Encryption.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?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 = '';
|
||||
}
|
||||
48
app/Config/Events.php
Normal file
48
app/Config/Events.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Events\Events;
|
||||
use CodeIgniter\Exceptions\FrameworkException;
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* 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 () {
|
||||
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');
|
||||
Services::toolbar()->respond();
|
||||
}
|
||||
});
|
||||
77
app/Config/Exceptions.php
Normal file
77
app/Config/Exceptions.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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']
|
||||
*/
|
||||
public array $sensitiveDataInTrace = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG DEPRECATIONS INSTEAD OF THROWING?
|
||||
* --------------------------------------------------------------------------
|
||||
* By default, CodeIgniter converts deprecations into exceptions. Also,
|
||||
* starting in PHP 8.1 will cause a lot of deprecated usage warnings.
|
||||
* Use this option to temporarily cease the warnings and instead log those.
|
||||
* This option also works for user deprecations.
|
||||
*/
|
||||
public bool $logDeprecations = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
|
||||
* --------------------------------------------------------------------------
|
||||
* If `$logDeprecations` is set to `true`, this sets the log level
|
||||
* to which the deprecation will be logged. This should be one of the log
|
||||
* levels recognized by PSR-3.
|
||||
*
|
||||
* The related `Config\Logger::$threshold` should be adjusted, if needed,
|
||||
* to capture logging the deprecations.
|
||||
*/
|
||||
public string $deprecationLogLevel = LogLevel::WARNING;
|
||||
}
|
||||
30
app/Config/Feature.php
Normal file
30
app/Config/Feature.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Enable/disable backward compatibility breaking features.
|
||||
*/
|
||||
class Feature extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Enable multiple filters for a route or not.
|
||||
*
|
||||
* If you enable this:
|
||||
* - CodeIgniter\CodeIgniter::handleRequest() uses:
|
||||
* - CodeIgniter\Filters\Filters::enableFilters(), instead of enableFilter()
|
||||
* - CodeIgniter\CodeIgniter::tryToRouteIt() uses:
|
||||
* - CodeIgniter\Router\Router::getFilters(), instead of getFilter()
|
||||
* - CodeIgniter\Router\Router::handle() uses:
|
||||
* - property $filtersInfo, instead of $filterInfo
|
||||
* - CodeIgniter\Router\RouteCollection::getFiltersForRoute(), instead of getFilterForRoute()
|
||||
*/
|
||||
public bool $multipleFilters = false;
|
||||
|
||||
/**
|
||||
* Use improved new auto routing instead of the default legacy version.
|
||||
*/
|
||||
public bool $autoRoutesImproved = false;
|
||||
}
|
||||
66
app/Config/Filters.php
Normal file
66
app/Config/Filters.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Filters\CSRF;
|
||||
use CodeIgniter\Filters\DebugToolbar;
|
||||
use CodeIgniter\Filters\Honeypot;
|
||||
use CodeIgniter\Filters\InvalidChars;
|
||||
use CodeIgniter\Filters\SecureHeaders;
|
||||
use App\Filters\AuthFilter;
|
||||
|
||||
class Filters extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Configures aliases for Filter classes to
|
||||
* make reading things nicer and simpler.
|
||||
*/
|
||||
public array $aliases = [
|
||||
'csrf' => CSRF::class,
|
||||
'toolbar' => DebugToolbar::class,
|
||||
'honeypot' => Honeypot::class,
|
||||
'invalidchars' => InvalidChars::class,
|
||||
'secureheaders' => SecureHeaders::class,
|
||||
'authFilter' => AuthFilter::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* List of filter aliases that are always
|
||||
* applied before and after every request.
|
||||
*/
|
||||
public array $globals = [
|
||||
'before' => [
|
||||
// 'honeypot',
|
||||
'csrf',
|
||||
// 'invalidchars',
|
||||
],
|
||||
'after' => [
|
||||
'toolbar',
|
||||
// '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.
|
||||
*/
|
||||
public array $methods = [];
|
||||
|
||||
/**
|
||||
* List of filter aliases that should run on any
|
||||
* before or after URI patterns.
|
||||
*
|
||||
* Example:
|
||||
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
||||
*/
|
||||
public array $filters = [];
|
||||
}
|
||||
9
app/Config/ForeignCharacters.php
Normal file
9
app/Config/ForeignCharacters.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
|
||||
|
||||
class ForeignCharacters extends BaseForeignCharacters
|
||||
{
|
||||
}
|
||||
77
app/Config/Format.php
Normal file
77
app/Config/Format.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Format\FormatterInterface;
|
||||
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 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,
|
||||
];
|
||||
|
||||
/**
|
||||
* A Factory method to return the appropriate formatter for the given mime type.
|
||||
*
|
||||
* @return FormatterInterface
|
||||
*
|
||||
* @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
|
||||
*/
|
||||
public function getFormatter(string $mime)
|
||||
{
|
||||
return Services::format()->getFormatter($mime);
|
||||
}
|
||||
}
|
||||
40
app/Config/Generators.php
Normal file
40
app/Config/Generators.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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, string>
|
||||
*/
|
||||
public array $views = [
|
||||
'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,
|
||||
];
|
||||
}
|
||||
51
app/Config/Kint.php
Normal file
51
app/Config/Kint.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use Kint\Renderer\AbstractRenderer;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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 extends BaseConfig
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
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;
|
||||
public int $richSort = AbstractRenderer::SORT_FULL;
|
||||
public $richObjectPlugins;
|
||||
public $richTabPlugins;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CLI Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public bool $cliColors = true;
|
||||
public bool $cliForceUTF8 = false;
|
||||
public bool $cliDetectWidth = true;
|
||||
public int $cliMinWidth = 40;
|
||||
}
|
||||
150
app/Config/Logger.php
Normal file
150
app/Config/Logger.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Log\Handlers\FileHandler;
|
||||
|
||||
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 array|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.
|
||||
*/
|
||||
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,
|
||||
// ],
|
||||
];
|
||||
}
|
||||
52
app/Config/Migrations.php
Normal file
52
app/Config/Migrations.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?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
|
||||
* level the system is at. It then compares the migration level in this
|
||||
* table to the $config['migration_version'] if they are not the same it
|
||||
* will migrate up. This must be set.
|
||||
*/
|
||||
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_';
|
||||
}
|
||||
530
app/Config/Mimes.php
Normal file
530
app/Config/Mimes.php
Normal file
@ -0,0 +1,530 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Mimes
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
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/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',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
76
app/Config/Modules.php
Normal file
76
app/Config/Modules.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Modules\Modules as BaseModules;
|
||||
|
||||
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
|
||||
*/
|
||||
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 string[]
|
||||
*/
|
||||
public $aliases = [
|
||||
'events',
|
||||
'filters',
|
||||
'registrars',
|
||||
'routes',
|
||||
'services',
|
||||
];
|
||||
}
|
||||
39
app/Config/Pager.php
Normal file
39
app/Config/Pager.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?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'.DIRECTORY_SEPARATOR .'Pager'.DIRECTORY_SEPARATOR .'Views'.DIRECTORY_SEPARATOR .'default_full',
|
||||
'default_simple' => 'CodeIgniter'.DIRECTORY_SEPARATOR .'Pager'.DIRECTORY_SEPARATOR .'Views'.DIRECTORY_SEPARATOR .'default_simple',
|
||||
'default_head' => 'CodeIgniter'.DIRECTORY_SEPARATOR .'Pager'.DIRECTORY_SEPARATOR .'Views'.DIRECTORY_SEPARATOR .'default_head',
|
||||
'bootstrap_full' => 'templates'.DIRECTORY_SEPARATOR .'Pagers'.DIRECTORY_SEPARATOR .'bootstrap_full',
|
||||
'bootstrap_simple' => 'templates'.DIRECTORY_SEPARATOR .'Pagers'.DIRECTORY_SEPARATOR .'bootstrap_simple',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Items Per Page
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default number of results shown in a single page.
|
||||
*/
|
||||
public int $perPage = 20;
|
||||
}
|
||||
75
app/Config/Paths.php
Normal file
75
app/Config/Paths.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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.
|
||||
*/
|
||||
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',
|
||||
];
|
||||
}
|
||||
203
app/Config/Routes.php
Normal file
203
app/Config/Routes.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Router\RouteCollection;
|
||||
|
||||
// Create a new instance of our RouteCollection class.
|
||||
$routes = Services::routes();
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Router Setup
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
$routes->setDefaultNamespace('App\Controllers');
|
||||
$routes->setDefaultController('Home');
|
||||
$routes->setDefaultMethod('index');
|
||||
$routes->setTranslateURIDashes(false);
|
||||
$routes->set404Override();
|
||||
$routes->setAutoRoute(false);
|
||||
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
|
||||
// where controller filters or CSRF protection are bypassed.
|
||||
// If you don't want to define all routes, please use the Auto Routing (Improved).
|
||||
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
|
||||
// $routes->setAutoRoute(false);
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Route Definitions
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// We get a performance increase by specifying the default
|
||||
// route since we don't have to scan directories.
|
||||
|
||||
//추가 RULE UUID형식
|
||||
$routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
|
||||
|
||||
$routes->get('/', 'Front\Home::index');
|
||||
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
|
||||
});
|
||||
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], static function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('user', static function ($routes) {
|
||||
$routes->get('', 'UserController::index');
|
||||
$routes->get('excel', 'UserController::excel');
|
||||
$routes->get('insert', 'UserController::insert_form');
|
||||
$routes->post('insert', 'UserController::insert');
|
||||
$routes->get('update/(:uuid)', 'UserController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'UserController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'UserController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'UserController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'UserController::toggle/$1/$2', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob', 'UserController::batchjob', ['filter' => 'authFilter:master']);
|
||||
});
|
||||
$routes->group('usersns', static function ($routes) {
|
||||
$routes->get('', 'UserSNSController::index');
|
||||
$routes->get('excel', 'UserSNSController::excel');
|
||||
$routes->get('view/(:num)', 'UserSNSController::view/$1');
|
||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob', 'UserSNSController::batchjob', ['filter' => 'authFilter:master']);
|
||||
});
|
||||
$routes->group('category', static function ($routes) {
|
||||
$routes->get('', 'CategoryController::index');
|
||||
$routes->get('excel', 'CategoryController::excel');
|
||||
$routes->get('insert', 'CategoryController::insert_form');
|
||||
$routes->post('insert', 'CategoryController::insert');
|
||||
$routes->get('update/(:num)', 'CategoryController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'CategoryController::update/$1');
|
||||
$routes->get('reply/(:num)', 'CategoryController::reply_form/$1');
|
||||
$routes->post('reply/(:num)', 'CategoryController::reply/$1');
|
||||
$routes->get('view/(:num)', 'CategoryController::view/$1');
|
||||
$routes->get('delete/(:num)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'CategoryController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'CategoryController::batchjob');
|
||||
});
|
||||
$routes->group('board', static function ($routes) {
|
||||
$routes->get('', 'BoardController::index');
|
||||
$routes->get('excel', 'BoardController::excel');
|
||||
$routes->get('insert', 'BoardController::insert_form');
|
||||
$routes->post('insert', 'BoardController::insert');
|
||||
$routes->get('update/(:num)', 'BoardController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'BoardController::update/$1');
|
||||
$routes->get('view/(:num)', 'BoardController::view/$1');
|
||||
$routes->get('reply/(:num)', 'BoardController::reply_form/$1');
|
||||
$routes->post('reply/(:num)', 'BoardController::reply/$1');
|
||||
$routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'BoardController::batchjob');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('sitepage', static function ($routes) {
|
||||
$routes->get('', 'SitepageController::index');
|
||||
$routes->get('excel', 'SitepageController::excel');
|
||||
$routes->get('insert', 'SitepageController::insert_form');
|
||||
$routes->post('insert', 'SitepageController::insert');
|
||||
$routes->get('update/(:num)', 'SitepageController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'SitepageController::update/$1');
|
||||
$routes->get('view/(:num)', 'SitepageController::view/$1');
|
||||
$routes->get('delete/(:num)', 'SitepageController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'SitepageController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'SitepageController::batchjob');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('excel', 'ProductController::excel');
|
||||
$routes->get('insert', 'ProductController::insert_form');
|
||||
$routes->post('insert', 'ProductController::insert');
|
||||
$routes->get('update/(:uuid)', 'ProductController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'ProductController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'ProductController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'ProductController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'ProductController::batchjob');
|
||||
$routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2');
|
||||
});
|
||||
$routes->group('order', static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
$routes->get('excel', 'OrderController::excel');
|
||||
$routes->get('update/(:uuid)', 'OrderController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'OrderController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'OrderController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'OrderController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'OrderController::batchjob`');
|
||||
});
|
||||
$routes->group('billing', static function ($routes) {
|
||||
$routes->get('', 'BillingController::index');
|
||||
$routes->get('excel', 'BillingController::excel');
|
||||
$routes->get('update/(:num)', 'BillingController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'BillingController::update/$1');
|
||||
$routes->get('view/(:num)', 'BillingController::view/$1');
|
||||
$routes->get('delete/(:num)', 'BillingController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'BillingController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'BillingController::batchjob`');
|
||||
$routes->get('download/(:any)/(:num)', 'BillingController::download/$1/$2');
|
||||
});
|
||||
});
|
||||
$routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) {
|
||||
$routes->group('user', static function ($routes) {
|
||||
$routes->get('', 'UserController::index', ['filter' => 'authFilter:user']);
|
||||
$routes->get('insert', 'UserController::insert_form');
|
||||
$routes->post('insert', 'UserController::insert');
|
||||
$routes->get('update/(:uuid)', 'UserController::update_form/$1', ['filter' => 'authFilter:user']);
|
||||
$routes->post('update/(:uuid)', 'UserController::update/$1', ['filter' => 'authFilter:user']);
|
||||
$routes->get('login', 'UserController::login_form');
|
||||
$routes->post('login', 'UserController::login/local');
|
||||
$routes->get('signup/(:alpha)', 'UserController::login/$1');
|
||||
$routes->get('logout', 'UserController::logout', ['filter' => 'authFilter:user']);
|
||||
});
|
||||
$routes->group('board', static function ($routes) {
|
||||
$routes->get('', 'BoardController::index');
|
||||
$routes->get('insert', 'BoardController::insert_form');
|
||||
$routes->post('insert', 'BoardController::insert');
|
||||
$routes->get('update/(:num)', 'BoardController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'BoardController::update/$1');
|
||||
$routes->get('view/(:num)', 'BoardController::view/$1');
|
||||
$routes->get('reply/(:num)', 'BoardController::reply_form/$1');
|
||||
$routes->post('reply/(:num)', 'BoardController::reply/$1');
|
||||
$routes->get('delete/(:num)', 'BoardController::delete/$1');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('sitepage', static function ($routes) {
|
||||
$routes->get('', 'SitepageController::index');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
});
|
||||
$routes->group('order', ['namespace' => 'App\Controllers\Front\Order'], static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
$routes->post('insert', 'OrderController::insert');
|
||||
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
||||
$routes->get('cancelCart/(:uuid)', 'CartController::delete/$1');
|
||||
});
|
||||
$routes->group('billing', ['namespace' => 'App\Controllers\Front\Billing', 'filter' => 'authFilter:user'], static function ($routes) {
|
||||
$routes->get('', 'BillingController::index');
|
||||
$routes->post('', 'BillingController::insert');
|
||||
$routes->get('view/(:num)', 'BillingController::view/$1');
|
||||
$routes->get('card/(:num)', 'CardController::update_form/$1');
|
||||
$routes->post('card/(:num)', 'CardController::update/$1');
|
||||
$routes->get('deposit/(:num)', 'DepositController::update_form/$1');
|
||||
$routes->post('deposit/(:num)', 'DepositController::update/$1');
|
||||
});
|
||||
});
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
* --------------------------------------------------------------------
|
||||
*
|
||||
* There will often be times that you need additional routing and you
|
||||
* need it to be able to override any defaults in this file. Environment
|
||||
* based routes is one such time. require() additional route files here
|
||||
* to make that happen.
|
||||
*
|
||||
* You will have access to the $routes object within that file without
|
||||
* needing to reload it.
|
||||
*/
|
||||
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
|
||||
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
|
||||
}
|
||||
201
app/Config/Routes_Shoppinmall.php
Normal file
201
app/Config/Routes_Shoppinmall.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
// Create a new instance of our RouteCollection class.
|
||||
$routes = Services::routes();
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Router Setup
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
$routes->setDefaultNamespace('App\Controllers');
|
||||
$routes->setDefaultController('Home');
|
||||
$routes->setDefaultMethod('index');
|
||||
$routes->setTranslateURIDashes(false);
|
||||
$routes->set404Override();
|
||||
$routes->setAutoRoute(false);
|
||||
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
|
||||
// where controller filters or CSRF protection are bypassed.
|
||||
// If you don't want to define all routes, please use the Auto Routing (Improved).
|
||||
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
|
||||
// $routes->setAutoRoute(false);
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Route Definitions
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// We get a performance increase by specifying the default
|
||||
// route since we don't have to scan directories.
|
||||
|
||||
//추가 RULE UUID형식
|
||||
$routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
|
||||
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
|
||||
});
|
||||
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], static function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('user', static function ($routes) {
|
||||
$routes->get('', 'UserController::index');
|
||||
$routes->get('excel', 'UserController::excel');
|
||||
$routes->get('insert', 'UserController::insert_form');
|
||||
$routes->post('insert', 'UserController::insert');
|
||||
$routes->get('update/(:uuid)', 'UserController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'UserController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'UserController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'UserController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'UserController::toggle/$1/$2', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob', 'UserController::batchjob', ['filter' => 'authFilter:master']);
|
||||
});
|
||||
$routes->group('usersns', static function ($routes) {
|
||||
$routes->get('', 'UserSNSController::index');
|
||||
$routes->get('excel', 'UserSNSController::excel');
|
||||
$routes->get('view/(:num)', 'UserSNSController::view/$1');
|
||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob', 'UserSNSController::batchjob', ['filter' => 'authFilter:master']);
|
||||
});
|
||||
$routes->group('category', static function ($routes) {
|
||||
$routes->get('', 'CategoryController::index');
|
||||
$routes->get('excel', 'CategoryController::excel');
|
||||
$routes->get('insert', 'CategoryController::insert_form');
|
||||
$routes->post('insert', 'CategoryController::insert');
|
||||
$routes->get('update/(:num)', 'CategoryController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'CategoryController::update/$1');
|
||||
$routes->get('reply/(:num)', 'CategoryController::reply_form/$1');
|
||||
$routes->post('reply/(:num)', 'CategoryController::reply/$1');
|
||||
$routes->get('view/(:num)', 'CategoryController::view/$1');
|
||||
$routes->get('delete/(:num)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'CategoryController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'CategoryController::batchjob');
|
||||
});
|
||||
$routes->group('board', static function ($routes) {
|
||||
$routes->get('', 'BoardController::index');
|
||||
$routes->get('excel', 'BoardController::excel');
|
||||
$routes->get('insert', 'BoardController::insert_form');
|
||||
$routes->post('insert', 'BoardController::insert');
|
||||
$routes->get('update/(:num)', 'BoardController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'BoardController::update/$1');
|
||||
$routes->get('view/(:num)', 'BoardController::view/$1');
|
||||
$routes->get('reply/(:num)', 'BoardController::reply_form/$1');
|
||||
$routes->post('reply/(:num)', 'BoardController::reply/$1');
|
||||
$routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'BoardController::batchjob');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('sitepage', static function ($routes) {
|
||||
$routes->get('', 'SitepageController::index');
|
||||
$routes->get('excel', 'SitepageController::excel');
|
||||
$routes->get('insert', 'SitepageController::insert_form');
|
||||
$routes->post('insert', 'SitepageController::insert');
|
||||
$routes->get('update/(:num)', 'SitepageController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'SitepageController::update/$1');
|
||||
$routes->get('view/(:num)', 'SitepageController::view/$1');
|
||||
$routes->get('delete/(:num)', 'SitepageController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'SitepageController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'SitepageController::batchjob');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('excel', 'ProductController::excel');
|
||||
$routes->get('insert', 'ProductController::insert_form');
|
||||
$routes->post('insert', 'ProductController::insert');
|
||||
$routes->get('update/(:uuid)', 'ProductController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'ProductController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'ProductController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'ProductController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'ProductController::batchjob');
|
||||
$routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2');
|
||||
});
|
||||
$routes->group('order', static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
$routes->get('excel', 'OrderController::excel');
|
||||
$routes->get('update/(:uuid)', 'OrderController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'OrderController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'OrderController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'OrderController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'OrderController::batchjob`');
|
||||
});
|
||||
$routes->group('billing', static function ($routes) {
|
||||
$routes->get('', 'BillingController::index');
|
||||
$routes->get('excel', 'BillingController::excel');
|
||||
$routes->get('update/(:num)', 'BillingController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'BillingController::update/$1');
|
||||
$routes->get('view/(:num)', 'BillingController::view/$1');
|
||||
$routes->get('delete/(:num)', 'BillingController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'BillingController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'BillingController::batchjob`');
|
||||
$routes->get('download/(:any)/(:num)', 'BillingController::download/$1/$2');
|
||||
});
|
||||
});
|
||||
$routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) {
|
||||
$routes->group('user', static function ($routes) {
|
||||
$routes->get('', 'UserController::index', ['filter' => 'authFilter:user']);
|
||||
$routes->get('insert', 'UserController::insert_form');
|
||||
$routes->post('insert', 'UserController::insert');
|
||||
$routes->get('update/(:uuid)', 'UserController::update_form/$1', ['filter' => 'authFilter:user']);
|
||||
$routes->post('update/(:uuid)', 'UserController::update/$1', ['filter' => 'authFilter:user']);
|
||||
$routes->get('login', 'UserController::login_form');
|
||||
$routes->post('login', 'UserController::login/local');
|
||||
$routes->get('signup/(:alpha)', 'UserController::login/$1');
|
||||
$routes->get('logout', 'UserController::logout', ['filter' => 'authFilter:user']);
|
||||
});
|
||||
$routes->group('board', static function ($routes) {
|
||||
$routes->get('', 'BoardController::index');
|
||||
$routes->get('insert', 'BoardController::insert_form');
|
||||
$routes->post('insert', 'BoardController::insert');
|
||||
$routes->get('update/(:num)', 'BoardController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'BoardController::update/$1');
|
||||
$routes->get('view/(:num)', 'BoardController::view/$1');
|
||||
$routes->get('reply/(:num)', 'BoardController::reply_form/$1');
|
||||
$routes->post('reply/(:num)', 'BoardController::reply/$1');
|
||||
$routes->get('delete/(:num)', 'BoardController::delete/$1');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('sitepage', static function ($routes) {
|
||||
$routes->get('', 'SitepageController::index');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
});
|
||||
$routes->group('order', ['namespace' => 'App\Controllers\Front\Order'], static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
||||
$routes->post('addCart', 'CartController::insert');
|
||||
$routes->get('cancelCart/(:uuid)', 'CartController::delete/$1');
|
||||
});
|
||||
$routes->group('billing', ['namespace' => 'App\Controllers\Front\Billing', 'filter' => 'authFilter:user'], static function ($routes) {
|
||||
$routes->get('', 'BillingController::index');
|
||||
$routes->post('', 'BillingController::insert');
|
||||
$routes->get('view/(:num)', 'BillingController::view/$1');
|
||||
$routes->get('card/(:num)', 'CardController::update_form/$1');
|
||||
$routes->post('card/(:num)', 'CardController::update/$1');
|
||||
$routes->get('deposit/(:num)', 'DepositController::update_form/$1');
|
||||
$routes->post('deposit/(:num)', 'DepositController::update/$1');
|
||||
});
|
||||
});
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
* --------------------------------------------------------------------
|
||||
*
|
||||
* There will often be times that you need additional routing and you
|
||||
* need it to be able to override any defaults in this file. Environment
|
||||
* based routes is one such time. require() additional route files here
|
||||
* to make that happen.
|
||||
*
|
||||
* You will have access to the $routes object within that file without
|
||||
* needing to reload it.
|
||||
*/
|
||||
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
|
||||
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
|
||||
}
|
||||
113
app/Config/Routing.php
Normal file
113
app/Config/Routing.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Routing as BaseRouting;
|
||||
|
||||
/**
|
||||
* Routing configuration
|
||||
*/
|
||||
class Routing extends BaseRouting
|
||||
{
|
||||
/**
|
||||
* An array of files that contain route definitions.
|
||||
* Route files are read in order, with the first match
|
||||
* found taking precedence.
|
||||
*
|
||||
* Default: APPPATH . 'Config/Routes.php'
|
||||
*/
|
||||
public array $routeFiles = [
|
||||
APPPATH . 'Config/Routes.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* The default namespace to use for Controllers when no other
|
||||
* namespace has been specified.
|
||||
*
|
||||
* Default: 'App\Controllers'
|
||||
*/
|
||||
public string $defaultNamespace = 'App\Controllers';
|
||||
|
||||
/**
|
||||
* The default controller to use when no other controller has been
|
||||
* specified.
|
||||
*
|
||||
* Default: 'Home'
|
||||
*/
|
||||
public string $defaultController = 'Home';
|
||||
|
||||
/**
|
||||
* The default method to call on the controller when no other
|
||||
* method has been set in the route.
|
||||
*
|
||||
* Default: 'index'
|
||||
*/
|
||||
public string $defaultMethod = 'index';
|
||||
|
||||
/**
|
||||
* Whether to translate dashes in URIs to underscores.
|
||||
* Primarily useful when using the auto-routing.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $translateURIDashes = false;
|
||||
|
||||
/**
|
||||
* Sets the class/method that should be called if routing doesn't
|
||||
* find a match. It can be either a closure or the controller/method
|
||||
* name exactly like a route is defined: 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
|
||||
* class constructor or the routes file by calling:
|
||||
*
|
||||
* $routes->set404Override(function() {
|
||||
* // Do something here
|
||||
* });
|
||||
*
|
||||
* Example:
|
||||
* public $override404 = 'App\Errors::show404';
|
||||
*/
|
||||
public ?string $override404 = null;
|
||||
|
||||
/**
|
||||
* If TRUE, the system will attempt to match the URI against
|
||||
* Controllers by matching each segment against folders/files
|
||||
* in APPPATH/Controllers, when a match wasn't found against
|
||||
* defined routes.
|
||||
*
|
||||
* If FALSE, will stop searching and do NO automatic routing.
|
||||
*/
|
||||
public bool $autoRoute = false;
|
||||
|
||||
/**
|
||||
* If TRUE, will enable the use of the 'prioritize' option
|
||||
* when defining routes.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $prioritize = false;
|
||||
|
||||
/**
|
||||
* Map of URI segments and namespaces. For Auto Routing (Improved).
|
||||
*
|
||||
* The key is the first URI segment. The value is the controller namespace.
|
||||
* E.g.,
|
||||
* [
|
||||
* 'blog' => 'Acme\Blog\Controllers',
|
||||
* ]
|
||||
*
|
||||
* @var array [ uri_segment => namespace ]
|
||||
*/
|
||||
public array $moduleRoutes = [];
|
||||
}
|
||||
101
app/Config/Security.php
Normal file
101
app/Config/Security.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?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.
|
||||
*/
|
||||
public bool $redirect = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF SameSite
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Setting for CSRF SameSite cookie token.
|
||||
*
|
||||
* Allowed values are: None - Lax - Strict - ''.
|
||||
*
|
||||
* Defaults to `Lax` as recommended in this link:
|
||||
*
|
||||
* @see https://portswigger.net/web-security/csrf/samesite-cookies
|
||||
*
|
||||
* @deprecated `Config\Cookie` $samesite property is used.
|
||||
*/
|
||||
public string $samesite = 'Lax';
|
||||
}
|
||||
32
app/Config/Services.php
Normal file
32
app/Config/Services.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
* }
|
||||
*/
|
||||
}
|
||||
102
app/Config/Session.php
Normal file
102
app/Config/Session.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Session\Handlers\BaseHandler;
|
||||
use CodeIgniter\Session\Handlers\FileHandler;
|
||||
|
||||
class Session extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Driver
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session storage driver to use:
|
||||
* - `CodeIgniter\Session\Handlers\FileHandler`
|
||||
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
|
||||
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
|
||||
* - `CodeIgniter\Session\Handlers\RedisHandler`
|
||||
*
|
||||
* @phpstan-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 = 0;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* 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;
|
||||
}
|
||||
91
app/Config/Toolbar.php
Normal file
91
app/Config/Toolbar.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?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 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 colleted. 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;
|
||||
}
|
||||
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',
|
||||
];
|
||||
}
|
||||
44
app/Config/Validation.php
Normal file
44
app/Config/Validation.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?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 string[]
|
||||
*/
|
||||
public array $ruleSets = [
|
||||
Rules::class,
|
||||
FormatRules::class,
|
||||
FileRules::class,
|
||||
CreditCardRules::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
|
||||
// --------------------------------------------------------------------
|
||||
}
|
||||
56
app/Config/View.php
Normal file
56
app/Config/View.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\View as BaseView;
|
||||
use CodeIgniter\View\ViewDecoratorInterface;
|
||||
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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 class-string<ViewDecoratorInterface>[]
|
||||
*/
|
||||
public array $decorators = [];
|
||||
}
|
||||
19
app/Controllers/Admin/AdminController.php
Normal file
19
app/Controllers/Admin/AdminController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class AdminController extends BaseController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath = 'admin/';
|
||||
$this->_viewDatas['control'] = 'admin';
|
||||
$this->_viewDatas['layout'] = LAYOUTS['admin'];
|
||||
}
|
||||
}
|
||||
91
app/Controllers/Admin/BillingController.php
Normal file
91
app/Controllers/Admin/BillingController.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Entities\BillingEntity;
|
||||
use App\Models\BillingModel;
|
||||
use App\Models\OrderBillingModel;
|
||||
use App\Models\OrderModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BillingController extends AdminController
|
||||
{
|
||||
private $_orderBillingModel = null;
|
||||
private $_orderModel = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new BillingModel();
|
||||
$this->_viewDatas['className'] = 'Billing';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
final protected function getOrderModel(): OrderModel
|
||||
{
|
||||
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
|
||||
}
|
||||
final protected function getOrderBillingModel(): OrderBillingModel
|
||||
{
|
||||
return $this->_orderBillingModel = $this->_orderBillingModel ?: new OrderBillingModel();
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case "insert":
|
||||
return ["price"];
|
||||
break;
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", "title", "price", "email", "phone", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["user_uid", "title", "price", "email", "phone", "status", "updated_at", "created_at", 'response'];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["user_uid", "status"];
|
||||
}
|
||||
|
||||
final protected function getOrdersByBillingEntity(BillingEntity $entity): array
|
||||
{
|
||||
//청구서 연결 주문정보 가져오기
|
||||
$orderBillings = $this->getOrderBillingModel()->getEntitys(['billing_uid' => $entity->getPrimaryKey()]);
|
||||
$orders = array();
|
||||
foreach ($orderBillings as $orderBilling) {
|
||||
array_push(
|
||||
$orders,
|
||||
$this->getOrderModel()->getEntity(
|
||||
[$this->getOrderModel()->getPrimaryKey() => $orderBilling->order_uid]
|
||||
)
|
||||
);
|
||||
}
|
||||
return $orders;
|
||||
}
|
||||
|
||||
//View 관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
$entity = parent::view_process($entity);
|
||||
//청구서 연결 주문정보 가져오기
|
||||
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
||||
if (!count($this->_viewDatas['orders'])) {
|
||||
throw new \Exception("해당하는 주문정보가 없습니다.");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
121
app/Controllers/Admin/BoardController.php
Normal file
121
app/Controllers/Admin/BoardController.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\Trait\UpDownloadTrait;
|
||||
use App\Models\BoardModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BoardController extends AdminController
|
||||
{
|
||||
use UpDownloadTrait;
|
||||
private $_category_notice = 3;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new BoardModel();
|
||||
$this->_viewDatas['className'] = 'Board';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);;
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["category_uid", 'title', "board_file", "passwd", "status", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["category_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'board_file':
|
||||
$file = $this->upload_file_procedure($field);
|
||||
if (!is_null($file)) {
|
||||
$this->_viewDatas['fieldDatas'][$field] = $file;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormData($field, $entity);
|
||||
break;
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
private function build_notice()
|
||||
{
|
||||
$entitys = $this->_model->getEntitys(['category_uid' => $this->_category_notice, 'status' => DEFAULTS['STATUS']]);
|
||||
$temps = array("<ul>");
|
||||
foreach ($entitys as $entity) {
|
||||
array_push($temps, sprintf(
|
||||
"<li><a href=\"/front/board/view/%s?category=3\">%s</a><span>%s</span></li>",
|
||||
$entity->getPrimaryKey(),
|
||||
$entity->getTitle(),
|
||||
$entity->created_at ? str_split($entity->created_at, 10)[0] : "",
|
||||
));
|
||||
}
|
||||
array_push($temps, "</ul>");
|
||||
// echo var_export($temps, true);
|
||||
// exit;
|
||||
file_put_contents(APPPATH . 'Views' . "/layouts/main/board.php", implode("\n", $temps));
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
protected function insert_process()
|
||||
{
|
||||
$entity = parent::insert_process();
|
||||
if ($entity->category_uid == $this->_category_notice) {
|
||||
$this->build_notice();
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//Update관련
|
||||
protected function update_process($entity)
|
||||
{
|
||||
$entity = parent::update_process($entity);
|
||||
if ($entity->category_uid == $this->_category_notice) {
|
||||
$this->build_notice();
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//Toggle관련
|
||||
protected function toggle_process($entity)
|
||||
{
|
||||
$entity = parent::toggle_process($entity);
|
||||
if ($entity->category_uid == $this->_category_notice) {
|
||||
$this->build_notice();
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//Delete 관련
|
||||
protected function delete_process($entity)
|
||||
{
|
||||
$entity = parent::delete_process($entity);
|
||||
if ($entity->category_uid->$this->_category_notice) {
|
||||
$this->build_notice();
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
126
app/Controllers/Admin/CategoryController.php
Normal file
126
app/Controllers/Admin/CategoryController.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\Trait\UpDownloadTrait;
|
||||
use App\Entities\CategoryEntity;
|
||||
use App\Models\CategoryModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CategoryController extends AdminController
|
||||
{
|
||||
use UpDownloadTrait;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new CategoryModel();
|
||||
$this->_viewDatas['className'] = 'Category';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [
|
||||
'name', "linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "head", "tail",
|
||||
];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [
|
||||
'name', "linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "created_at"
|
||||
];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
private function write_leftmenu($old_category, array $categorys)
|
||||
{
|
||||
//신규 대분류인경우 기존 카테고리 메뉴 만들기
|
||||
foreach ($categorys as $category) {
|
||||
$viewDatas = [
|
||||
'className' => $this->_viewDatas['className'],
|
||||
'category' => $category,
|
||||
'parent_category' => $old_category,
|
||||
'sibling_categorys' => $categorys
|
||||
];
|
||||
$leftmenu = view($this->_viewPath . '/leftmenu_template', ['viewDatas' => $viewDatas]);
|
||||
file_put_contents(APPPATH . 'Views' . "/layouts/common/left_menu/leftmenu_{$category->getPrimaryKey()}.php", $leftmenu);
|
||||
}
|
||||
}
|
||||
private function build_leftmenu()
|
||||
{
|
||||
$old_category = null;
|
||||
$categorys = array();
|
||||
foreach ($this->_model->getEntitys(['status' => DEFAULTS['STATUS']]) as $entity) {
|
||||
if ($entity->getHierarchy_Depth() == 1) {
|
||||
if (is_null($old_category)) {
|
||||
$old_category = $entity;
|
||||
} else if ($old_category->getPrimaryKey() != $entity->getPrimaryKey()) {
|
||||
$this->write_leftmenu($old_category, $categorys);
|
||||
$old_category = $entity;
|
||||
$categorys = array();
|
||||
}
|
||||
} else {
|
||||
array_push($categorys, $entity);
|
||||
}
|
||||
}
|
||||
$this->write_leftmenu($old_category, $categorys);
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
protected function insert_process()
|
||||
{
|
||||
$entity = parent::insert_process();
|
||||
$this->build_leftmenu();
|
||||
return $entity;
|
||||
}
|
||||
//Update관련
|
||||
protected function update_process($entity)
|
||||
{
|
||||
$entity = parent::update_process($entity);
|
||||
$this->build_leftmenu();
|
||||
return $entity;
|
||||
}
|
||||
//Toggle관련
|
||||
protected function toggle_process($entity)
|
||||
{
|
||||
$entity = parent::toggle_process($entity);
|
||||
$this->build_leftmenu();
|
||||
return $entity;
|
||||
}
|
||||
//Reply관련
|
||||
protected function reply_process($entity)
|
||||
{
|
||||
$entity = parent::reply_process($entity);
|
||||
$this->build_leftmenu();
|
||||
return $entity;
|
||||
}
|
||||
//Delete 관련
|
||||
protected function delete_process($entity)
|
||||
{
|
||||
$entity = parent::delete_process($entity);
|
||||
$this->build_leftmenu();
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
35
app/Controllers/Admin/Home.php
Normal file
35
app/Controllers/Admin/Home.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Home extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['className'] = 'Home';
|
||||
$this->_viewDatas['title'] = '관리자페이지';
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
}
|
||||
|
||||
public function getFields(string $action): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
//Index 관련
|
||||
public function index()
|
||||
{
|
||||
helper('form');
|
||||
$this->_session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: "");
|
||||
return view($this->_viewPath . 'welcome_message', ['viewDatas' => $this->_viewDatas]);
|
||||
}
|
||||
}
|
||||
60
app/Controllers/Admin/OrderController.php
Normal file
60
app/Controllers/Admin/OrderController.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\OrderModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class OrderController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new OrderModel();
|
||||
$this->_viewDatas['className'] = 'Order';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
final public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case 'update':
|
||||
return ["type", 'product_uid', "paymentday", "cost", "sale", "quantity", "status"];
|
||||
break;
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", "type", "name", "cost", "sale", "quantity", "price", "paymentday", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["user_uid", 'product_uid', "type", "name", "cost", "sale", "quantity", "type", "paymentday", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
final public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", 'product_uid', "type", "status"];
|
||||
}
|
||||
final public function getFieldBatchFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
//가격이나,할인가,수량 변경했을경우 다시 계산해서 Price에 넣기위해
|
||||
protected function update_process($entity)
|
||||
{
|
||||
//가격이나,할인가,수량 변경했을경우 다시 계산해서 결제금액(price)에 넣기위해
|
||||
$this->_viewDatas['fieldDatas']['price'] =
|
||||
($this->_viewDatas['fieldDatas']['cost'] -
|
||||
$this->_viewDatas['fieldDatas']['sale']) *
|
||||
$this->_viewDatas['fieldDatas']['quantity'];
|
||||
return parent::update_process($entity);
|
||||
}
|
||||
}
|
||||
93
app/Controllers/Admin/ProductController.php
Normal file
93
app/Controllers/Admin/ProductController.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\Trait\UpDownloadTrait;
|
||||
use App\Models\ProductModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ProductController extends AdminController
|
||||
{
|
||||
use UpDownloadTrait;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new ProductModel();
|
||||
$this->_viewDatas['className'] = 'Product';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["category_uid", 'type', 'name', "photo", "cost", "sale", "stock", "view_cnt", "status", "content",];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["category_uid", "user_uid", 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["category_uid", "user_uid", 'type', "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'photo':
|
||||
$file = $this->upload_image_procedure($field);
|
||||
if (!is_null($file)) {
|
||||
$this->_viewDatas['fieldDatas'][$field] = $file;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormData($field, $entity);
|
||||
break;
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
private function calculate_price(): int
|
||||
{
|
||||
if ($this->_viewDatas['fieldDatas']['cost'] < $this->_viewDatas['fieldDatas']['sale']) {
|
||||
throw new \Exception(sprintf(
|
||||
"%s가[%s] %s[%s]보다 작습니다.",
|
||||
lang($this->_viewDatas['className'] . '.label.cost'),
|
||||
number_format($this->_viewDatas['fieldDatas']['cost']),
|
||||
lang($this->_viewDatas['className'] . '.label.sale'),
|
||||
number_format($this->_viewDatas['fieldDatas']['sale']),
|
||||
));
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas']['cost'] - $this->_viewDatas['fieldDatas']['sale'];
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
protected function insert_process()
|
||||
{
|
||||
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();
|
||||
return parent::insert_process();
|
||||
}
|
||||
|
||||
//Update관련
|
||||
protected function update_process($entity)
|
||||
{
|
||||
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();
|
||||
return parent::update_process($entity);
|
||||
}
|
||||
}
|
||||
47
app/Controllers/Admin/SitepageController.php
Normal file
47
app/Controllers/Admin/SitepageController.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\SitepageModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class SitepageController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new SitepageModel();
|
||||
$this->_viewDatas['className'] = 'Sitepage';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["category_uid", 'title', "status", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["category_uid", "user_uid", 'title', "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["category_uid", "user_uid", 'title', "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["category_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
51
app/Controllers/Admin/UserController.php
Normal file
51
app/Controllers/Admin/UserController.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\UserModel;
|
||||
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);
|
||||
$this->_model = new UserModel();
|
||||
$this->_viewDatas['className'] = 'User';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case 'insert':
|
||||
return ["id", "passwd", 'name', "email", "phone", "mobile", "role", "status"];
|
||||
break;
|
||||
case 'update':
|
||||
return ["passwd", 'name', "email", "phone", "mobile", "role", "status"];
|
||||
break;
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["id", 'name', "email", "phone", "mobile", "role", "status", 'created_at'];
|
||||
break;
|
||||
case "view":
|
||||
return ["id", 'name', "email", "phone", "mobile", "role", "status", 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["role", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
46
app/Controllers/Admin/UserSNSController.php
Normal file
46
app/Controllers/Admin/UserSNSController.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\UserSNSModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class UserSNSController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new UserSNSModel();
|
||||
$this->_viewDatas['className'] = 'UserSNS';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["site", "id", 'name', "email", "detail", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", "site", "id", 'name', "email", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
696
app/Controllers/BaseController.php
Normal file
696
app/Controllers/BaseController.php
Normal file
@ -0,0 +1,696 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
*
|
||||
* 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
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['Common'];
|
||||
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
protected $_validation = null;
|
||||
protected $_model = null;
|
||||
protected $_session = null;
|
||||
protected $_viewPath = '';
|
||||
protected $_viewDatas = array();
|
||||
protected $_per_page = DEFAULTS['PERPAGE'];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
// Do Not Edit This Line
|
||||
parent::initController($request, $response, $logger);
|
||||
// Preload any models, libraries, etc, here.
|
||||
// E.g.: $this->session = \Config\Services::session();
|
||||
$this->_session = \Config\Services::session();
|
||||
$this->_validation = \Config\Services::validation();
|
||||
$this->_viewDatas['session'] = $this->_session;
|
||||
//사용자 기본 Role 지정
|
||||
$this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
|
||||
$this->_viewDatas['currentRoles'] = [DEFAULTS["ROLE"]];
|
||||
if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
|
||||
$this->_viewDatas[SESSION_NAMES['ISLOGIN']] = true;
|
||||
$this->_viewDatas['auth'] = $this->_session->get(SESSION_NAMES['AUTH']);
|
||||
$currentRoles = explode(DEFAULTS['DELIMITER_ROLE'], $this->_viewDatas['auth'][AUTH_FIELDS['ROLE']]);
|
||||
$this->_viewDatas['currentRoles'] = is_array($currentRoles) ? $currentRoles : [DEFAULTS["ROLE"]];
|
||||
}
|
||||
}
|
||||
|
||||
abstract public function getFields(string $action): array;
|
||||
abstract public function getFieldFilters(): array;
|
||||
//Field별 Rule용
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$rules = $this->_model->getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
final public function getFieldRules(array $fields, string $action = ""): array
|
||||
{
|
||||
$rules = array();
|
||||
foreach ($fields as $field) {
|
||||
$rules = $this->getFieldRule($field, $rules, $action);
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return $this->getFieldFilters();
|
||||
}
|
||||
//Field별 Form Option용
|
||||
public function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$options = $this->_model->getFieldFOrmOption($field);
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
final public function getFieldFormOptions(array $fields): array
|
||||
{
|
||||
$fieldFormOptions = array();
|
||||
foreach ($fields as $field) {
|
||||
if (!is_string($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
|
||||
}
|
||||
$fieldFormOptions[$field] = $this->getFieldFormOption($field);
|
||||
}
|
||||
return $fieldFormOptions;
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$value = $this->request->getVar($field);
|
||||
if (!is_null($value)) {
|
||||
$this->_viewDatas['fieldDatas'][$field] = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
//초기화
|
||||
final public function action_init(array $viewDatas)
|
||||
{
|
||||
switch ($viewDatas['action']) {
|
||||
case 'insert_form':
|
||||
$action = 'insert';
|
||||
break;
|
||||
case 'update_form':
|
||||
$action = 'update';
|
||||
break;
|
||||
default:
|
||||
$action = $viewDatas['action'];
|
||||
break;
|
||||
}
|
||||
$this->_viewDatas['fields'] = array_key_exists('fields', $viewDatas) ? $viewDatas['fields'] : $this->getFields($action);
|
||||
$this->_viewDatas['fieldRules'] = $this->getFieldRules($this->_viewDatas['fields'], $action);
|
||||
$this->_viewDatas['fieldFilters'] = $this->getFieldFilters();
|
||||
$this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters();
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
return $this->_viewDatas;
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
protected function insert_form_process()
|
||||
{
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
}
|
||||
public function insert_form()
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$this->insert_form_process();
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/insert', ['viewDatas' => $this->_viewDatas]);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function insert_validate()
|
||||
{
|
||||
//Upload된 파일 검증(photo)때문에 먼처 체크
|
||||
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||
if (!$this->_validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||
}
|
||||
|
||||
//fieldData 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
|
||||
}
|
||||
}
|
||||
protected function insert_process()
|
||||
{
|
||||
return $this->_model->create($this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
final public function insert()
|
||||
{
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$this->insert_validate();
|
||||
$entity = $this->insert_process();
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.");
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
//Update관련
|
||||
protected function update_form_process($entity)
|
||||
{
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $entity;
|
||||
}
|
||||
public function update_form($uid)
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->_viewDatas['entity'] = $this->update_form_process($entity);
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/update', ['viewDatas' => $this->_viewDatas]);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function update_validate($entity)
|
||||
{
|
||||
//Upload된 파일 검증(photo)때문에 먼처 체크
|
||||
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||
if (!$this->_validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||
}
|
||||
|
||||
//fieldData 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
}
|
||||
|
||||
//변견된 데이터 Log로 남기기
|
||||
foreach ($this->_viewDatas['fieldDatas'] as $field => $value) {
|
||||
if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다.
|
||||
log_message(
|
||||
"info",
|
||||
sprintf(
|
||||
"{$field} 변경: ---원본--\n%s\n---변경---\n%s",
|
||||
$entity->$field,
|
||||
var_export($value, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected function update_process($entity)
|
||||
{
|
||||
return $this->_model->modify($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
final public function update($uid)
|
||||
{
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->update_validate($entity);
|
||||
$entity = $this->update_process($entity);
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.");
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
//Reply관련
|
||||
protected function reply_form_process($entity)
|
||||
{
|
||||
$titleField = $this->_model->getTitleField();
|
||||
$entity->$titleField = "RE: " . $entity->$titleField;
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $entity;
|
||||
}
|
||||
public function reply_form($uid)
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->_viewDatas['entity'] = $this->reply_form_process($entity);
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/reply', ['viewDatas' => $this->_viewDatas]);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function reply_validate($entity)
|
||||
{
|
||||
//Upload된 파일 검증(photo)때문에 먼처 체크
|
||||
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||
if (!$this->_validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||
}
|
||||
|
||||
//fieldData 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
}
|
||||
}
|
||||
protected function reply_process($entity)
|
||||
{
|
||||
return $this->_model->reply($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
final public function reply($uid)
|
||||
{
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->reply_validate($entity);
|
||||
$entity = $this->reply_process($entity);
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.");
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
//Toggle 관련
|
||||
protected function toggle_validate($entity)
|
||||
{
|
||||
//Upload된 파일 검증(photo)때문에 먼처 체크
|
||||
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||
if (!$this->_validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||
}
|
||||
|
||||
//fieldData 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
}
|
||||
}
|
||||
protected function toggle_process($entity)
|
||||
{
|
||||
return $this->_model->modify($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
final public function toggle($uid, string $field)
|
||||
{
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__, 'fields' => [$field]]);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->toggle_validate($entity);
|
||||
$entity = $this->toggle_process($entity);
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.");
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
}
|
||||
}
|
||||
//Batchjob 관련
|
||||
protected function batchjob_validate($entity)
|
||||
{
|
||||
//Upload된 파일 검증(photo)때문에 먼처 체크
|
||||
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||
if (!$this->_validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||
}
|
||||
|
||||
//fieldData 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
}
|
||||
}
|
||||
protected function batchjob_process($entity)
|
||||
{
|
||||
return $this->_model->modify($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
final public function batchjob()
|
||||
{
|
||||
$uids = array();
|
||||
$entitys = array();
|
||||
$batchjobs = array();
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
try {
|
||||
//fields 해당하는 field중 선택된 값이 있는경우만 fields로 정의
|
||||
$fields = array();
|
||||
foreach ($this->getFieldBatchFilters() as $field) {
|
||||
if ($this->request->getVar($field)) {
|
||||
array_push($fields, $field);
|
||||
}
|
||||
}
|
||||
if (!is_array($fields) || count($fields) === 0) {
|
||||
throw new \Exception($this->_viewDatas['title'] . '에서 변경할 항목(field)이 선택되지 않았습니다.');
|
||||
}
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__, 'fields' => $fields]);
|
||||
$uids = $this->request->getVar('batchjob_uids') ?: throw new \Exception($this->_viewDatas['title'] . '에서 변경할 항목(uid)이 선택되지 않았습니다.');
|
||||
$cnt = 1;
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->batchjob_validate($entity);
|
||||
$entity = $this->batchjob_process($entity);
|
||||
array_push($entitys, $this->_model->modify($entity, $this->_viewDatas['fieldDatas']));
|
||||
array_push($batchjobs, "{$cnt}. {$uid}->{$entity->getTitle()}는 완료.");
|
||||
} catch (\Exception $e) {
|
||||
array_push($batchjobs, "{$cnt}. {$uid}는 실패.");
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$this->_session->setFlashdata(
|
||||
"return_message",
|
||||
sprintf("%s에서 총:%s개의 %s 완료하였습니다.", $this->_viewDatas['title'], count($entitys), __FUNCTION__,),
|
||||
);
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->_session->setFlashdata(
|
||||
"return_message",
|
||||
sprintf(
|
||||
"총:%s개의 작업중 %s개는 성공하였지만 , %s개가 실패하여 %s 취소되었습니다.\n%s",
|
||||
count($uids),
|
||||
count($entitys),
|
||||
count($uids) - count($entitys),
|
||||
__FUNCTION__,
|
||||
$e->getMessage(),
|
||||
),
|
||||
);
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} finally {
|
||||
log_message('error', sprintf("---------batchjob 작업결과--------\n%s\n", implode("\n", $batchjobs)));
|
||||
}
|
||||
}
|
||||
|
||||
//Delete 관련
|
||||
protected function delete_process($entity)
|
||||
{
|
||||
if (!$this->_model->delete($entity->getPrimaryKey())) {
|
||||
log_message("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
log_message("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
final public function delete($uid)
|
||||
{
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
try {
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->delete_process($entity);
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.");
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
}
|
||||
}
|
||||
|
||||
//View 관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $entity;
|
||||
}
|
||||
public function view($uid)
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->_viewDatas['entity'] = $this->view_process($entity);
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/view', ['viewDatas' => $this->_viewDatas]);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//Index 관련
|
||||
protected function index_process()
|
||||
{
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
}
|
||||
protected function index_setCondition()
|
||||
{
|
||||
//조건절 처리
|
||||
$filterFields = array();
|
||||
foreach ($this->_viewDatas['fieldFilters'] as $field) {
|
||||
if (!is_null($this->request->getVar($field))) {
|
||||
$filterFields[$field] = $this->request->getVar($field);
|
||||
}
|
||||
}
|
||||
$this->_viewDatas['word'] = $this->request->getVar('word') ?: '';
|
||||
$this->_viewDatas['start'] = $this->request->getVar('start') ?: '';
|
||||
$this->_viewDatas['end'] = $this->request->getVar('end') ?: '';
|
||||
$this->_viewDatas['order_field'] = $this->request->getVar('order_field') ?: 'created_at';
|
||||
$this->_viewDatas['order_value'] = $this->request->getVar('order_value') ?: 'DESC';
|
||||
$this->_model->setCondition(
|
||||
$filterFields,
|
||||
$this->_viewDatas['word'],
|
||||
$this->_viewDatas['start'],
|
||||
$this->_viewDatas['end'],
|
||||
$this->_viewDatas['order_field'],
|
||||
$this->_viewDatas['order_value']
|
||||
);
|
||||
}
|
||||
private function index_getPagination($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): string
|
||||
{
|
||||
// 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성
|
||||
// 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full',
|
||||
// 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가
|
||||
$pager = \Config\Services::pager();
|
||||
// $this->_model->paginate($this->_viewDatas['per_page'], $pager_group, $this->_viewDatas['page'], $segment);
|
||||
$pager->makeLinks(
|
||||
$this->_viewDatas['page'],
|
||||
$this->_viewDatas['per_page'],
|
||||
$this->_viewDatas['total_count'],
|
||||
$template,
|
||||
$segment,
|
||||
$pager_group
|
||||
);
|
||||
$this->_viewDatas['page'] = $pager->getCurrentPage($pager_group);
|
||||
$this->_viewDatas['total_page'] = $pager->getPageCount($pager_group);
|
||||
return $pager->links($pager_group, $template);
|
||||
}
|
||||
private function index_getEntitys(): array
|
||||
{
|
||||
$this->index_setCondition();
|
||||
if (array_key_exists('page', $this->_viewDatas)) {
|
||||
return $this->_model->findAll(
|
||||
$this->_viewDatas['per_page'],
|
||||
$this->_viewDatas['page'] * $this->_viewDatas['per_page'] - $this->_viewDatas['per_page']
|
||||
);
|
||||
}
|
||||
return $this->_model->findAll();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
foreach ($this->_viewDatas['fieldFilters'] as $field) {
|
||||
$this->_viewDatas[$field] = $this->request->getVar($field) ?: DEFAULTS['EMPTY'];
|
||||
}
|
||||
$this->index_process();
|
||||
//Totalcount 처리
|
||||
$this->index_setCondition();
|
||||
$this->_viewDatas['total_count'] = $this->_model->countAllResults();
|
||||
// echo $this->_model->getLastQuery();
|
||||
// echo "<HR>";
|
||||
// log_message("debug", __METHOD__ . "에서 TotalCount 호출:" . $this->_model->getLastQuery());
|
||||
//Page, Per_page필요부분
|
||||
$this->_viewDatas['page'] = (int)$this->request->getVar('page') ?: 1;
|
||||
$this->_viewDatas['per_page'] = (int)$this->request->getVar('per_page') ?: $this->_per_page;
|
||||
$this->_viewDatas['uri'] = $this->request->getUri();
|
||||
//줄수 처리용
|
||||
$this->_viewDatas['pageOptions'] = array("" => "줄수선택");
|
||||
for ($i = 10; $i <= $this->_viewDatas['total_count'] + $this->_viewDatas['per_page']; $i += 10) {
|
||||
$this->_viewDatas['pageOptions'][$i] = $i;
|
||||
}
|
||||
//pagenation 처리
|
||||
$this->_viewDatas['pagination'] = $this->index_getPagination();
|
||||
//모델 처리
|
||||
$this->_viewDatas['entitys'] = $this->index_getEntitys();
|
||||
// echo $this->_model->getLastQuery();
|
||||
// exit;
|
||||
// log_message("debug", __METHOD__ . "에서 findAll 호출:" . $this->_model->getLastQuery());
|
||||
//setting return_url to session flashdata
|
||||
helper(['form']);
|
||||
$this->_session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: "");
|
||||
return view($this->_viewPath . '/index' . $this->request->getVar('v') ?: '', ['viewDatas' => $this->_viewDatas]);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return alert_CommonHelper($e->getMessage(), "back");
|
||||
// return redirect()->back()->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//Excel 관련
|
||||
final protected function spreadSheet(string $html)
|
||||
{
|
||||
// //HTML저장
|
||||
// file_put_contents($fileName . '.html', $html);
|
||||
|
||||
//HTML Read
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Html();
|
||||
$spreadsheet = $reader->loadFromString($html);
|
||||
// from File의 경우
|
||||
// $spreadsheet = $reader->load($fileName . '.html');
|
||||
|
||||
//Excel저장
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
// $writer->save($fileName . '.xlsx');
|
||||
|
||||
// //PDF저장
|
||||
// $writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet);
|
||||
// $writer->save($fileName . '.pdf');
|
||||
return $writer;
|
||||
}
|
||||
final public function excel()
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||
$this->_viewDatas['Entitys'] = $this->index_getEntitys();
|
||||
$html = view(
|
||||
$this->_viewPath . '/excel',
|
||||
['viewDatas' => $this->_viewDatas]
|
||||
);
|
||||
//결과파일저장
|
||||
$fileName = sprintf(
|
||||
"%s/%s_%s",
|
||||
PATHS['EXCEL'],
|
||||
$this->_viewDatas['className'],
|
||||
date('Y-m-d_Hm')
|
||||
);
|
||||
$writer = $this->spreadSheet($html);
|
||||
$writer->save($fileName . '.xlsx');
|
||||
//Download시
|
||||
header("Content-Type: application/vnd.ms-excel");
|
||||
header(sprintf("Content-Disposition: attachment; filename=%s", urlencode($fileName)));
|
||||
header("Expires: 0");
|
||||
header("Cache-Control: must-revalidate");
|
||||
header("Pragma: public");
|
||||
header("Content-Length:" . filesize(PATHS['EXCEL'] . '/' . $fileName));
|
||||
// flush();
|
||||
// return readfile(PATHS['EXCEL'] . '/' . $fileName);
|
||||
return $writer->save('php://output');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
//File Download관련
|
||||
public function download_process($field, $entity)
|
||||
{
|
||||
list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field);
|
||||
if (!is_file(PATHS['UPLOAD'] . "/" . $uploaded_filename)) {
|
||||
throw new \Exception("첨부파일이 확인되지 않습니다.\n");
|
||||
}
|
||||
return $this->response->download(PATHS['UPLOAD'] . "/" . $uploaded_filename, null)->setFileName(date("Ymd") . '_' . $filename);
|
||||
}
|
||||
public function download(string $field, $uid)
|
||||
{
|
||||
try {
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
return $this->download_process($field, $entity);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
220
app/Controllers/Front/Billing/BillingController.php
Normal file
220
app/Controllers/Front/Billing/BillingController.php
Normal file
@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front\Billing;
|
||||
|
||||
use App\Controllers\Front\FrontController;
|
||||
use App\Entities\BillingEntity;
|
||||
use App\Entities\OrderEntity;
|
||||
use App\Models\BillingModel;
|
||||
use App\Models\OrderBillingModel;
|
||||
use App\Models\OrderModel;
|
||||
use App\Models\UserModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BillingController extends FrontController
|
||||
{
|
||||
private $_userModel = null;
|
||||
private $_orderModel = null;
|
||||
private $_orderBillingModel = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new BillingModel();
|
||||
$this->_viewDatas['className'] = 'Billing';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
|
||||
//Default 회원정보 Category
|
||||
$this->_category = DEFAULTS['CATEGORY_BILLING'];
|
||||
$this->isRole('index');
|
||||
|
||||
//사용자정보
|
||||
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
|
||||
}
|
||||
|
||||
final protected function getUserModel(): UserModel
|
||||
{
|
||||
return $this->_userModel = $this->_userModel ?: new UserModel();
|
||||
}
|
||||
|
||||
final protected function getOrderModel(): OrderModel
|
||||
{
|
||||
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
|
||||
}
|
||||
final protected function getOrderBillingModel(): OrderBillingModel
|
||||
{
|
||||
return $this->_orderBillingModel = $this->_orderBillingModel ?: new OrderBillingModel();
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case "insert":
|
||||
return ["price"];
|
||||
break;
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["title", "price", "email", "phone", "type", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["title", "price", "email", "phone", "type", "status", "updated_at", "created_at", 'response'];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
|
||||
final protected function getOrdersByBillingEntity(BillingEntity $entity): array
|
||||
{
|
||||
//청구서 연결 주문정보 가져오기
|
||||
$orderBillings = $this->getOrderBillingModel()->getEntitys(['billing_uid' => $entity->getPrimaryKey()]);
|
||||
$orders = array();
|
||||
foreach ($orderBillings as $orderBilling) {
|
||||
array_push(
|
||||
$orders,
|
||||
$this->getOrderModel()->getEntity(
|
||||
[$this->getOrderModel()->getPrimaryKey() => $orderBilling->order_uid]
|
||||
)
|
||||
);
|
||||
}
|
||||
return $orders;
|
||||
}
|
||||
|
||||
//Insert관련 (결제처리용)
|
||||
protected function insert_form_process()
|
||||
{
|
||||
parent::insert_form_process();
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
private function linkOrderBilling(BillingEntity $entity, array $orders)
|
||||
{
|
||||
foreach ($orders as $order) {
|
||||
$this->getOrderBillingModel()->create([
|
||||
"billing_uid" => $entity->getPrimaryKey(),
|
||||
'order_uid' => $order->getPrimaryKey()
|
||||
]);
|
||||
$this->getOrderModel()->modify($order, ['status' => DEFAULTS['STATUS']]);
|
||||
}
|
||||
}
|
||||
protected function insert_process()
|
||||
{
|
||||
//title지정하기
|
||||
$this->_viewDatas['fieldDatas']['title'] = date("Y년m월") . " 청구서입니다.";
|
||||
//사용자정보
|
||||
$this->_viewDatas['fieldDatas']['email'] = $this->_viewDatas['user']->email;
|
||||
$this->_viewDatas['fieldDatas']['phone'] = $this->_viewDatas['user']->phone;
|
||||
return parent::insert_process();
|
||||
}
|
||||
final public function insert()
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$this->insert_validate();
|
||||
//주문정보 가져오기
|
||||
$order_uids = $this->request->getVar('order_uids') ?: throw new \Exception("주문정보가 지정되지 않았습니다.");
|
||||
$orders = array();
|
||||
foreach ($order_uids as $order_uid) {
|
||||
array_push($orders, $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $order_uid]));
|
||||
}
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
//Billing 생성
|
||||
$entity = $this->insert_process();
|
||||
//DB연결용
|
||||
$this->linkOrderBilling($entity, $orders);
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.";
|
||||
//기존 return_url 무시
|
||||
$this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->to(URLS['Billing']);
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
|
||||
$msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage();
|
||||
log_message("error", $e->getMessage());
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->back()->withInput();
|
||||
} finally {
|
||||
$this->_session->setFlashdata("return_message", $msg);
|
||||
}
|
||||
}
|
||||
|
||||
//Update관련
|
||||
final public function update_form($uid)
|
||||
{
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
//청구서정보 가져오기
|
||||
$this->_viewDatas['entity'] = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
//청구서 연결 주문정보 가져오기
|
||||
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
||||
if (!count($this->_viewDatas['orders'])) {
|
||||
throw new \Exception("해당하는 주문정보가 없습니다.");
|
||||
}
|
||||
$this->update_form_process($entity);
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/update', ['viewDatas' => $this->_viewDatas]);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//View 관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
$entity = parent::view_process($entity);
|
||||
//청구서 연결 주문정보 가져오기
|
||||
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
||||
if (!count($this->_viewDatas['orders'])) {
|
||||
throw new \Exception("해당하는 주문정보가 없습니다.");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_setCondition()
|
||||
{
|
||||
//사용자정보(user_uid)에 맞는 Biiling정보 가져오기
|
||||
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
|
||||
parent::index_setCondition();
|
||||
}
|
||||
|
||||
//추가기능
|
||||
//메일발송
|
||||
final protected function sendMail(BillingEntity $entity): bool
|
||||
{
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$this->_viewDatas['entity'] = $entity;
|
||||
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
||||
|
||||
$mail = \Config\Services::email();
|
||||
$mail->setFrom(MALLS['support'], MALLS['title'], MALLS['master']);
|
||||
$mail->setTo($entity->email);
|
||||
$mail->setCC(MALLS['master']);
|
||||
$mail->setSubject($entity->getTitle());
|
||||
$mail->setMessage(view(
|
||||
$this->_viewPath . '/billing',
|
||||
['viewDatas' => $this->_viewDatas]
|
||||
));
|
||||
return $mail->send();
|
||||
}
|
||||
}
|
||||
148
app/Controllers/Front/Billing/CardController.php
Normal file
148
app/Controllers/Front/Billing/CardController.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front\Billing;
|
||||
|
||||
use App\Libraries\Adapter\Payment\CookiePayment as PaymentAdapter;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CardController extends BillingController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['className'] = 'Card';
|
||||
$this->_viewPath .= '/' . strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case 'update':
|
||||
return ["card_quota", "card_number", "card_expiration", "email", "phone"];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "order_uid":
|
||||
$rules[$field] = 'required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]';
|
||||
break;
|
||||
case "card_quota":
|
||||
$rules[$field] = 'required|in_list[00,01]';
|
||||
break;
|
||||
case "card_number":
|
||||
$rules[$field] = 'required|regex_match[/^[0-9]{4}[\/-][0-9]{4}[\/-][0-9]{4}[\/-][0-9]{4}/]';
|
||||
break;
|
||||
case "card_expiration":
|
||||
$rules[$field] = 'required|regex_match[/^[0-9]{4}[\/-](0[0-9]|1[0-2])/]';
|
||||
break;
|
||||
case "email":
|
||||
$rules[$field] = 'required|valid_email';
|
||||
break;
|
||||
case "phone":
|
||||
$rules[$field] = 'required|regex_match[/^[0-9]{3}[\/-][0-9]{4}[\/-][0-9]{4}/]';
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ['card_quota'];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Option용
|
||||
public function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'card_quota':
|
||||
$options = lang($this->_viewDatas['className'] . '.CARD_QUOTA');
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFieldFormOption($field);
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'card_number':
|
||||
case 'card_expiration':
|
||||
$temps = array();
|
||||
foreach ($this->request->getVar($field) as $value) {
|
||||
array_push($temps, $value);
|
||||
}
|
||||
$this->_viewDatas['fieldDatas'][$field] = implode("-", $temps);
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormData($field, $entity);
|
||||
break;
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
|
||||
//Update관련
|
||||
//카드결제처리
|
||||
private function pg_process(): string
|
||||
{
|
||||
$response = "";
|
||||
if (MALLS['card'] == "REAL") {
|
||||
//PG사 결제후 정보저장
|
||||
$adapter = new PaymentAdapter();
|
||||
$adapter->setDatas($this->_viewDatas['fieldDatas']);
|
||||
$result = $adapter->execute();
|
||||
foreach ($result as $key => $value) {
|
||||
$response .= "{$key}:{$value}\n";
|
||||
}
|
||||
} else {
|
||||
foreach ($this->_viewDatas['fieldDatas'] as $key => $value) {
|
||||
$response .= "{$key}:{$value}\n";
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
//특수한형태의 Field(card_number,card_expiration) 때문에 먼저 데이터를 받아서 변환한후 validation 체크를 하기위해
|
||||
protected function update_validate($entity)
|
||||
{
|
||||
//fieldData 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
}
|
||||
|
||||
$this->_validation->setRules($this->_viewDatas['fieldRules']);
|
||||
if (!$this->_validation->run($this->_viewDatas['fieldDatas'])) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->_validation->getErrors()));
|
||||
}
|
||||
}
|
||||
protected function update_process($entity)
|
||||
{
|
||||
//카드결제
|
||||
$this->_viewDatas['fieldDatas']["response"] = $this->pg_process();
|
||||
//Card 결제처리
|
||||
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
||||
$this->_viewDatas['fieldDatas']["status"] = DEFAULTS['STATUS'];
|
||||
return parent::update_process($entity);
|
||||
}
|
||||
}
|
||||
64
app/Controllers/Front/Billing/DepositController.php
Normal file
64
app/Controllers/Front/Billing/DepositController.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front\Billing;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class DepositController extends BillingController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['className'] = 'Deposit';
|
||||
$this->_viewPath .= '/' . strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case 'update':
|
||||
return ["email", "phone"];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "email":
|
||||
$rules[$field] = 'required|valid_email';
|
||||
break;
|
||||
case "phone":
|
||||
$rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]';
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
//Update관련
|
||||
//무통장입금결제처리
|
||||
protected function update_process($entity)
|
||||
{
|
||||
//Deposit 결제처리
|
||||
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
||||
return parent::update_process($entity);
|
||||
}
|
||||
}
|
||||
160
app/Controllers/Front/BoardController.php
Normal file
160
app/Controllers/Front/BoardController.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Models\BoardModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BoardController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new BoardModel();
|
||||
$this->_viewDatas['className'] = 'Board';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
// echo var_export($this->_viewDatas['layout'], true);
|
||||
// exit;
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ['title', "passwd", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ['title', "board_file", "created_at", "view_cnt"];
|
||||
break;
|
||||
case "view":
|
||||
return ['title', "board_file", "view_cnt", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
//권한체크
|
||||
protected function isRole($action)
|
||||
{
|
||||
$this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
|
||||
parent::isRole($action);
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
protected function insert_form_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('insert');
|
||||
parent::insert_form_process();
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
|
||||
'category_uid' => $this->_category,
|
||||
'category' => $this->_category
|
||||
]];
|
||||
}
|
||||
protected function insert_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('insert');
|
||||
return parent::insert_process();
|
||||
}
|
||||
//Update관련
|
||||
protected function update_form_process($entity)
|
||||
{
|
||||
//본인이 작성한글인지 최종확인용 정상접속이 아닌 위회해서 수정을 시도방지용
|
||||
if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->user_uid != $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
|
||||
throw new \Exception("작성자 본인글인지 여부가 확인되지 않습니다.");
|
||||
}
|
||||
//권한체크
|
||||
$this->isRole('update');
|
||||
$entity = parent::update_form_process($entity);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
|
||||
'category' => $this->_category
|
||||
]];
|
||||
return $entity;
|
||||
}
|
||||
protected function update_process($entity)
|
||||
{
|
||||
//본인이 작성한글인지 최종확인용 정상접속이 아닌 위회해서 수정을 시도방지용
|
||||
if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->user_uid != $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
|
||||
throw new \Exception("작성자 본인글인지 여부가 확인되지 않습니다.");
|
||||
}
|
||||
return parent::update_process($entity);
|
||||
}
|
||||
//Reply관련($entity는 부모의것임을 주의)
|
||||
protected function reply_form_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('reply');
|
||||
$entity = parent::reply_form_process($entity);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
|
||||
'category_uid' => $entity->category_uid,
|
||||
'category' => $this->_category
|
||||
]];
|
||||
return $entity;
|
||||
}
|
||||
//Delete 관련
|
||||
protected function delete_process($entity)
|
||||
{
|
||||
//본인이 작성한글인지 최종확인용 정상접속이 아닌 위회해서 삭제 시도 방지용
|
||||
if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->user_uid == $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
|
||||
throw new \Exception("작성자 본인글인지 여부가 확인되지 않습니다.");
|
||||
}
|
||||
return parent::delete_process($entity);
|
||||
}
|
||||
//View관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('view');
|
||||
//조회수 올리기
|
||||
$entity = $this->_model->addViewCount($entity);
|
||||
$entity = parent::view_process($entity);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
|
||||
'category' => $this->_category
|
||||
]];
|
||||
return $entity;
|
||||
}
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('index');
|
||||
parent::index_process();
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
|
||||
'category' => $this->_category
|
||||
]];
|
||||
}
|
||||
//Category 및 Status 조건추가
|
||||
protected function index_setCondition()
|
||||
{
|
||||
$this->_model->where("category_uid", $this->_viewDatas['category']->getPrimaryKey());
|
||||
$this->_model->where("status", DEFAULTS['STATUS']);
|
||||
parent::index_setCondition();
|
||||
}
|
||||
//Download관련
|
||||
public function download_process($field, $entity): array
|
||||
{
|
||||
$entity = parent::download_process($field, $entity);
|
||||
//권한체크
|
||||
$this->isRole('download', $entity);
|
||||
list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field);
|
||||
if (!is_file(PATHS['UPLOAD'] . "/" . $uploaded_filename)) {
|
||||
throw new \Exception("파일이 확인되지 않습니다.\n" . PATHS['UPLOAD'] . "/" . $uploaded_filename);
|
||||
}
|
||||
return array($filename, $uploaded_filename);
|
||||
return parent::download_process($field, $entity);
|
||||
}
|
||||
}
|
||||
80
app/Controllers/Front/FrontController.php
Normal file
80
app/Controllers/Front/FrontController.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Entities\CategoryEntity;
|
||||
use App\Models\CategoryModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class FrontController extends BaseController
|
||||
{
|
||||
private $_categoryModel = null;
|
||||
private $_currentCategory = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath = 'front/';
|
||||
$this->_viewDatas['control'] = 'front';
|
||||
$this->_viewDatas['layout'] = LAYOUTS['front'];
|
||||
$this->_viewDatas['title'] = LAYOUTS['front']['title'];
|
||||
$this->_viewDatas['menus'] = $this->getCategoryModel()->getMenus();
|
||||
$this->_viewDatas['category'] = false;
|
||||
}
|
||||
|
||||
final protected function getCategoryModel(): CategoryModel
|
||||
{
|
||||
return $this->_categoryModel = $this->_categoryModel ?: new CategoryModel();
|
||||
}
|
||||
final protected function getCurrentCategory(): CategoryEntity
|
||||
{
|
||||
if ($this->_currentCategory === null) {
|
||||
$this->_viewDatas['category'] = $this->request->getVar('category');
|
||||
$this->_viewDatas['category'] ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
|
||||
$this->_currentCategory = $this->_viewDatas['currentCategory'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']]);
|
||||
//$this->_viewDatas['parent_category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']->getHierarchy_ParentUID()]);
|
||||
}
|
||||
return $this->_currentCategory;
|
||||
}
|
||||
|
||||
//권한체크
|
||||
protected function isRole($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case 'insert':
|
||||
$category_field = 'iswrite';
|
||||
break;
|
||||
case 'reply':
|
||||
$category_field = 'isreply';
|
||||
break;
|
||||
case 'view':
|
||||
$category_field = 'isread';
|
||||
break;
|
||||
case 'upload':
|
||||
$category_field = 'isupload';
|
||||
break;
|
||||
case 'download':
|
||||
$category_field = 'isdownload';
|
||||
break;
|
||||
default:
|
||||
$category_field = 'isdaccess';
|
||||
break;
|
||||
}
|
||||
//사용자가 Category에서 해당 게시판의 해당권한이 있는지 확인
|
||||
if (!isRole_CommonHelper(
|
||||
$this->_viewDatas['currentRoles'],
|
||||
$this->getCurrentCategory(),
|
||||
$category_field,
|
||||
)) {
|
||||
// echo var_export($this->_viewDatas['currentRoles'], true);
|
||||
// echo "<HR>";
|
||||
// echo var_export($this->_viewDatas['category'], true);
|
||||
// echo "<HR>";
|
||||
// echo "field->", $action . ":" . $category_field;
|
||||
// exit;
|
||||
throw new \Exception("고객님은 " . lang("Category.label." . $category_field) . "이 없습니다.");
|
||||
}
|
||||
}
|
||||
}
|
||||
34
app/Controllers/Front/Home.php
Normal file
34
app/Controllers/Front/Home.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Home extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
public function getFields(string $action): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
//Index 관련
|
||||
public function index()
|
||||
{
|
||||
helper('form');
|
||||
//$this->_viewDatas['parts'] = Product['parts'];
|
||||
// dd($this->_viewDatas);
|
||||
$this->_session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: "");
|
||||
return view($this->_viewPath . 'welcome_message', ['viewDatas' => $this->_viewDatas]);
|
||||
}
|
||||
}
|
||||
171
app/Controllers/Front/Order/CartController.php
Normal file
171
app/Controllers/Front/Order/CartController.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front\Order;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CartController extends OrderController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['className'] = 'Cart';
|
||||
$this->_viewPath .= '/' . strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case 'insert':
|
||||
return ["product_uid", "quantity", "price", 'paymentday'];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'product_uid':
|
||||
$rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
|
||||
break;
|
||||
case 'quantity':
|
||||
case 'price':
|
||||
$rules[$field] = "required|numeric";
|
||||
break;
|
||||
case 'paymentday':
|
||||
$rules[$field] = "if_exist|numeric";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
//insert관련
|
||||
public function insert()
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
//장바구니정보 검증
|
||||
$this->insert_validate();
|
||||
//상품정보가져오기
|
||||
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]);
|
||||
//상품갯수확인
|
||||
if (!$this->_viewDatas['fieldDatas']['quantity']) {
|
||||
throw new \Exception("상품갯수가 지정되지 않았습니다.");
|
||||
}
|
||||
//구매금액확인
|
||||
if (!$this->_viewDatas['fieldDatas']['price']) {
|
||||
throw new \Exception("구매금액이 지정되지 않았습니다.");
|
||||
}
|
||||
//결제방식이 월이용권이면 결제일 확인
|
||||
$paymentDay = null;
|
||||
$type = $product->type;
|
||||
if ($type == 'rental') {
|
||||
$paymentDay = $this->request->getVar('paymentday') ?: throw new \Exception("월이용권 상품의 경우는 매월 결제일을 지정해주셔야합니다.");
|
||||
}
|
||||
//재고수 비교
|
||||
if ($product->stock < $this->_viewDatas['fieldDatas']['quantity']) {
|
||||
throw new \Exception("구매수량이 너무 많습니다.\n구매수량:{$this->_viewDatas['fieldDatas']['quantity']}개, 남은 재고수량:{$product->stock}개");
|
||||
}
|
||||
//구매 금액 비교
|
||||
$price = $product->price * $this->_viewDatas['fieldDatas']['quantity'];
|
||||
if ($price != $this->_viewDatas['fieldDatas']['price']) {
|
||||
throw new \Exception("실 상품금액{$price} 와 구매금액{$this->_viewDatas['fieldDatas']['price']}이 서로 다릅니다.");
|
||||
}
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
//주문추가
|
||||
$entity = $this->_model->addCart($product, $this->_viewDatas['fieldDatas']['quantity'], $type, $paymentDay);
|
||||
//상품재고감소
|
||||
$product = $this->getProductModel()->addCart($product, $this->_viewDatas['fieldDatas']['quantity']);
|
||||
//주문정보 세션에 넣기
|
||||
$order_uids = $this->_session->get(SESSION_NAMES['CART']) ?: array();
|
||||
$this->_session->set(SESSION_NAMES['CART'], [...$order_uids, $entity->getPrimaryKey()]);
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$msg = sprintf(
|
||||
"%s\n 상품명:%s\n 상품갯수:%s개, 구매금액:%s원\n 장바구니에 담았습니다.",
|
||||
$this->_viewDatas['title'],
|
||||
$entity->getTitle(),
|
||||
$entity->quantity,
|
||||
number_format($entity->price)
|
||||
);
|
||||
//Return URL clear -> 장바구니로 바로 이동
|
||||
$this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->to(URLS['Order']);
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
$msg = sprintf(
|
||||
"%s에서 다음 오류로 인해 장바구니에 담기를 실패하였습니다.\n%s",
|
||||
$this->_viewDatas['title'],
|
||||
$e->getMessage()
|
||||
);
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} finally {
|
||||
$this->_session->setFlashdata("return_message", $msg);
|
||||
}
|
||||
}
|
||||
|
||||
//주문취소(uid -> order_uid)
|
||||
public function delete($uid)
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
//주문정보 가져오기
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
//상품정보 가져오기
|
||||
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $entity->product_uid]);
|
||||
//Transaction 시작
|
||||
$this->_model->transStart();
|
||||
//주문취소
|
||||
$entity = $this->delete_process($entity);
|
||||
//상품반환
|
||||
$product = $this->getProductModel()->cancelCart($product, $entity->quantity);
|
||||
//주문정보 세션에서 빼기
|
||||
$order_uids = $this->_session->get(SESSION_NAMES['CART']) ?: array();
|
||||
$temps = array();
|
||||
foreach ($order_uids as $order_uid) {
|
||||
if ($order_uid != $entity->getPrimaryKey()) {
|
||||
array_push($temps, $order_uid);
|
||||
}
|
||||
}
|
||||
$this->_session->set(SESSION_NAMES['CART'], $temps);
|
||||
//Transaction Commit
|
||||
$this->_model->transComplete();
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()} {$entity->quantity}개의 주문을 취소하였습니다.";
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_model->transRollback();
|
||||
$msg = sprintf(
|
||||
"%s에서 다음 오류로 인해 주문취소를 실패하였습니다.\n%s",
|
||||
$this->_viewDatas['title'],
|
||||
$e->getMessage()
|
||||
);
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} finally {
|
||||
$this->_session->setFlashdata("return_message", $msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
89
app/Controllers/Front/Order/OrderController.php
Normal file
89
app/Controllers/Front/Order/OrderController.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front\Order;
|
||||
|
||||
use App\Controllers\Front\FrontController;
|
||||
use App\Models\OrderModel;
|
||||
use App\Models\ProductModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class OrderController extends FrontController
|
||||
{
|
||||
private $_productModel = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new OrderModel();
|
||||
$this->_viewDatas['className'] = 'Order';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
|
||||
//Default 회원정보 Category
|
||||
$this->_category = DEFAULTS['CATEGORY_ORDER'];
|
||||
$this->isRole('index');
|
||||
}
|
||||
|
||||
final protected function getProductModel(): ProductModel
|
||||
{
|
||||
return $this->_productModel = $this->_productModel ?: new ProductModel();
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["type", 'name', "cost", "sale", "quantity", "price", "status"];
|
||||
break;
|
||||
case "view":
|
||||
return ["type", 'name', "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ['product_uid', "type", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
|
||||
//View관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('view', $entity);
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('index');
|
||||
return parent::index_process();
|
||||
}
|
||||
protected function index_setCondition()
|
||||
{
|
||||
//세션에 Cart정보(order_uids)가 있으면
|
||||
$uids = $this->_session->get(SESSION_NAMES['CART']) ?: array('NONE');
|
||||
//또는 Login했으면 사용자정보(user_uid)에 맞는 Order정보 가져오기
|
||||
if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
|
||||
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
|
||||
if (count($uids)) {
|
||||
$this->_model->orWhereIn('uid', $uids);
|
||||
}
|
||||
} elseif (count($uids)) {
|
||||
$this->_model->whereIn('uid', $uids);
|
||||
}
|
||||
parent::index_setCondition();
|
||||
}
|
||||
}
|
||||
77
app/Controllers/Front/ProductController.php
Normal file
77
app/Controllers/Front/ProductController.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Models\ProductModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ProductController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new ProductModel();
|
||||
$this->_viewDatas['className'] = 'Product';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
$this->_per_page = 10;
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["photo", 'user_uid', 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "content",];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", 'type', "photo", "cost", "sale", "price", "stock", "view_cnt"];
|
||||
break;
|
||||
case "view":
|
||||
return ["photo", 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", 'type'];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
//권한체크
|
||||
protected function isRole($action)
|
||||
{
|
||||
$this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
|
||||
parent::isRole($action);
|
||||
}
|
||||
//View관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('view', $entity);
|
||||
//조회수 올리기
|
||||
$entity = $this->_model->addViewCount($entity);
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('index');
|
||||
return parent::index_process();
|
||||
}
|
||||
//Category 및 Status 조건추가
|
||||
protected function index_setCondition()
|
||||
{
|
||||
$this->_model->where("category_uid", $this->_viewDatas['category']->getPrimaryKey());
|
||||
// $this->_model->where("status", DEFAULTS['STATUS']);
|
||||
parent::index_setCondition();
|
||||
}
|
||||
}
|
||||
61
app/Controllers/Front/SitepageController.php
Normal file
61
app/Controllers/Front/SitepageController.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Models\SitepageModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class SitepageController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new SitepageModel();
|
||||
$this->_viewDatas['className'] = 'Sitepage';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ['title', "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ['title', "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('index');
|
||||
return parent::index_process();
|
||||
}
|
||||
//Category 및 Status 조건추가
|
||||
protected function index_setCondition()
|
||||
{
|
||||
$this->_model->where("category_uid", $this->getCurrentCategory()->getPrimaryKey());
|
||||
$this->_model->where("status", DEFAULTS['STATUS']);
|
||||
parent::index_setCondition();
|
||||
}
|
||||
}
|
||||
138
app/Controllers/Front/UserController.php
Normal file
138
app/Controllers/Front/UserController.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Libraries\Adapter\Auth\Auth as AuthAdapter;
|
||||
use App\Models\UserModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class UserController extends FrontController
|
||||
{
|
||||
private $_adapters = array();
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new UserModel();
|
||||
$this->_viewDatas['className'] = 'User';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
|
||||
$this->initAdapters();
|
||||
}
|
||||
|
||||
private function initAdapters()
|
||||
{
|
||||
foreach (array_keys(AUTH_ADAPTERS) as $adapter) {
|
||||
$this->getAdapter($adapter);
|
||||
}
|
||||
}
|
||||
private function getAdapter(string $site): AuthAdapter
|
||||
{
|
||||
$site = ucfirst($site);
|
||||
if (!array_key_exists($site, $this->_adapters)) {
|
||||
$adapterClass = sprintf("\App\Libraries\Adapter\Auth\%sAuth", $site);
|
||||
$this->_adapters[$site] = new $adapterClass($site, AUTH_ADAPTERS[$site]['DEBUG']);
|
||||
}
|
||||
return $this->_adapters[$site];
|
||||
}
|
||||
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'passwd':
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
|
||||
$this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormData($field, $entity);
|
||||
break;
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
switch ($action) {
|
||||
case 'insert':
|
||||
return ["id", "passwd", 'name', "email", "phone", "mobile"];
|
||||
break;
|
||||
case 'update':
|
||||
return ["passwd", 'name', "email", "phone", "mobile"];
|
||||
break;
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["id", 'name', "email", "phone", "mobile", 'created_at'];
|
||||
break;
|
||||
case "view":
|
||||
return ["id", 'name', "email", "phone", "mobile", 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
protected function insert_process()
|
||||
{
|
||||
//Role이 반드시 있어야 하기때문에
|
||||
$this->_viewDatas['fieldDatas']['role'] = DEFAULTS['ROLE'] . ',user';
|
||||
return parent::insert_process();
|
||||
}
|
||||
|
||||
//Index관련
|
||||
//사용자 UID 조건추가
|
||||
protected function index_setCondition()
|
||||
{
|
||||
$this->_model->where("uid", $this->_viewDatas['auth'][AUTH_FIELDS['ID']]);
|
||||
parent::index_setCondition();
|
||||
}
|
||||
|
||||
//추가기능
|
||||
public function login_form()
|
||||
{
|
||||
foreach ($this->_adapters as $key => $adapter) {
|
||||
$this->_viewDatas['login_buttons'][$key] = $adapter->getAuthButton();
|
||||
}
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/login' . $this->request->getVar('v') ?: '', ['viewDatas' => $this->_viewDatas]);
|
||||
}
|
||||
|
||||
public function login(string $site)
|
||||
{
|
||||
try {
|
||||
//각 Adapter별 인층체크 후 Session에 인증정보 설정
|
||||
$this->getAdapter($site)->setFormDatas($this->request->getVar());
|
||||
$this->getAdapter($site)->execute();
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||
} catch (\Exception $e) {
|
||||
$this->_session->setFlashdata('return_message', $e->getMessage());
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
//로그인 여부 확인후 Session에 Login 정보 삭제
|
||||
if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
|
||||
session_destroy();
|
||||
}
|
||||
return redirect()->route('/');
|
||||
}
|
||||
}
|
||||
66
app/Controllers/Trait/CartTrait.php
Normal file
66
app/Controllers/Trait/CartTrait.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Trait;
|
||||
|
||||
use App\Entities\OrderEntity;
|
||||
use App\Entities\ProductEntity;
|
||||
use App\Models\OrderModel;
|
||||
use App\Models\ProductModel;
|
||||
|
||||
trait CartTrait
|
||||
{
|
||||
private $_serverModel = null;
|
||||
private $_orderModel = null;
|
||||
private function getOrderModel(): OrderModel
|
||||
{
|
||||
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
|
||||
}
|
||||
private function getProductModel(): ProductModel
|
||||
{
|
||||
return $this->_serverModel = $this->_serverModel ?: new ProductModel();
|
||||
}
|
||||
|
||||
public function add_procedure(ProductEntity $product, int $quantity, int $paymentDay = null): OrderEntity
|
||||
{
|
||||
//상품재고감소
|
||||
$product = $this->getProductModel()->addCart($product, $quantity);
|
||||
//주문추가
|
||||
$entity = $this->getOrderModel()->addCart($product, $quantity, $product->type, $paymentDay);
|
||||
//주문정보 세션에 넣기
|
||||
$order_uids = $this->_session->get(SESSION_NAMES['CART']) ?: array();
|
||||
$this->_session->set(SESSION_NAMES['CART'], [...$order_uids, $entity->getPrimaryKey()]);
|
||||
$this->_session->setFlashdata(
|
||||
"return_message",
|
||||
sprintf(
|
||||
"%s\n 상품명:%s\n 상품갯수:%s개, 구매금액:%s원\n 장바구니에 담았습니다.",
|
||||
$this->_viewDatas['title'],
|
||||
$entity->getTitle(),
|
||||
$entity->quantity,
|
||||
number_format($entity->price),
|
||||
),
|
||||
);
|
||||
return $entity;
|
||||
}
|
||||
|
||||
public function cancel_procedure($uid)
|
||||
{
|
||||
//주문정보 가져오기
|
||||
$entity = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $uid]);
|
||||
//상품정보 가져오기
|
||||
$product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $entity->product_uid]);
|
||||
//주문취소
|
||||
$entity = $this->getOrderModel()->cancelCart($entity);
|
||||
//상품반환
|
||||
$product = $this->getProductModel()->cancelCart($product, $entity->quantity);
|
||||
//주문정보 세션에서 빼기
|
||||
$order_uids = $this->_session->get(SESSION_NAMES['CART']) ?: array();
|
||||
$temps = array();
|
||||
foreach ($order_uids as $order_uid) {
|
||||
if ($order_uid != $entity->getPrimaryKey()) {
|
||||
array_push($temps, $order_uid);
|
||||
}
|
||||
}
|
||||
$this->_session->set(SESSION_NAMES['CART'], $temps);
|
||||
$this->_session->setFlashdata("return_message", "{$this->_viewDatas['title']}에서 {$entity->getTitle()} {$entity->quantity}개의 주문을 취소하였습니다.");
|
||||
}
|
||||
}
|
||||
95
app/Controllers/Trait/UpDownloadTrait.php
Normal file
95
app/Controllers/Trait/UpDownloadTrait.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Trait;
|
||||
|
||||
use CodeIgniter\HTTP\Files\UploadedFile;
|
||||
|
||||
trait UpDownloadTrait
|
||||
{
|
||||
//Upload FIle관련
|
||||
private function upDownload_file_process(UploadedFile $upfile): ?string
|
||||
{
|
||||
$filename = null;
|
||||
$uploaded_filename = null;
|
||||
if ($upfile->isValid() && !$upfile->hasMoved()) {
|
||||
$filename = $upfile->getName();
|
||||
$uploaded_filename = $upfile->getRandomName();
|
||||
$upfile->move(PATHS['UPLOAD'], $uploaded_filename);
|
||||
//move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요
|
||||
$uploaded_filename = $upfile->getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return $filename . DEFAULTS['DELIMITER_FILE'] . $uploaded_filename;
|
||||
}
|
||||
public function upload_file_procedure(string $field): ?string
|
||||
{
|
||||
return $this->upload_file_process($this->request->getFile($field));
|
||||
}
|
||||
public function upload_multiple_file_procedure(string $field): array
|
||||
{
|
||||
//Multiple파일의경우 html에서는 필드명[]를 넣어야하며
|
||||
//rule에서 "uploaded[필드명.0]|is_image[필드명]~~" 이런식으로 넣어야함
|
||||
$files = array();
|
||||
if ($upfiles = $this->request->getFiles()) {
|
||||
foreach ($upfiles[$field] as $upfile) {
|
||||
if ($upfile->isValid() && !$upfile->hasMoved()) {
|
||||
$file = $this->upload_file_process($upfile);
|
||||
if (!is_null($file)) {
|
||||
array_push($files, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
private function image_resize_process(UploadedFile $upfile, $uploaded_filename, $x = 25, $y = 25)
|
||||
{
|
||||
$image = \Config\Services::image();
|
||||
$image->withFile($upfile)
|
||||
->resize($x, $y, true, 'height')
|
||||
->save(PATHS['UPLOAD_IMAGE'] . $uploaded_filename);
|
||||
}
|
||||
private function upload_image_process(UploadedFile $upfile): ?string
|
||||
{
|
||||
//참고:https://www.positronx.io/codeigniter-resize-image-with-image-manipulation-tutorial/
|
||||
$filename = null;
|
||||
$uploaded_filename = null;
|
||||
if ($upfile->isValid() && !$upfile->hasMoved()) {
|
||||
$filename = $upfile->getName();
|
||||
$uploaded_filename = $upfile->getRandomName();
|
||||
$this->image_resize_process($upfile, "small_" . $uploaded_filename);
|
||||
$this->image_resize_process($upfile, "middle_" . $uploaded_filename, 50, 50);
|
||||
$this->image_resize_process($upfile, "large_" . $uploaded_filename, 100, 100);
|
||||
$upfile->move(PATHS['UPLOAD_IMAGE'], $uploaded_filename);
|
||||
//move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요
|
||||
$uploaded_filename = $upfile->getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return $filename . DEFAULTS['DELIMITER_FILE'] . $uploaded_filename;
|
||||
}
|
||||
|
||||
public function upload_image_procedure(string $field): ?string
|
||||
{
|
||||
return $this->upload_image_process($this->request->getFile($field));
|
||||
}
|
||||
public function upload_multiple_image_procedure(string $field): array
|
||||
{
|
||||
//Multiple파일의경우 html에서는 필드명[]를 넣어야하며
|
||||
//rule에서 "uploaded[필드명.0]|is_image[필드명]~~" 이런식으로 넣어야함
|
||||
$filenames = array();
|
||||
if ($upfiles = $this->request->getFiles()) {
|
||||
foreach ($upfiles[$field] as $upfile) {
|
||||
if ($upfile->isValid() && !$upfile->hasMoved()) {
|
||||
$file = $this->upload_image_process($upfile);
|
||||
if (!is_null($file)) {
|
||||
array_push($files, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $filenames;
|
||||
}
|
||||
}
|
||||
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
41
app/Database/Seeds/UserSeeder.php
Normal file
41
app/Database/Seeds/UserSeeder.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
use CodeIgniter\Database\Seeder;
|
||||
use Faker\Factory;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$data = [
|
||||
'id' => 'choi.jh',
|
||||
'passwd' => password_hash('1234', PASSWORD_DEFAULT),
|
||||
'name' => '최준흠',
|
||||
'email' => 'choi.jh@prime-idc.jp',
|
||||
'role' => 'master',
|
||||
'status' => DEFAULT_STATUS,
|
||||
];
|
||||
// Using Query Builder
|
||||
$this->db->table('user')->insert($data);
|
||||
|
||||
$datas = array();
|
||||
for($i=0; $i<50; $i++){
|
||||
$datas[] = $this->generate_data();
|
||||
}
|
||||
// $this->db->table('user')->insertBatch($datas);
|
||||
}
|
||||
|
||||
public function generate_data(){
|
||||
$faker = Factory::create();
|
||||
return [
|
||||
"id" => $faker->userName(),
|
||||
"passwd" => $faker->password(4,10),
|
||||
"name" => $faker->name(),
|
||||
"email" => $faker->email(),
|
||||
"role" => $faker->randomElement(["guest","member","manager","cloudflare","director","master"]),
|
||||
"status" => $faker->randomElement(['use','unuse']),
|
||||
];
|
||||
}
|
||||
}
|
||||
113
app/Database/base.sql
Normal file
113
app/Database/base.sql
Normal file
@ -0,0 +1,113 @@
|
||||
DROP TABLE IF EXISTS vhost.tw_user;
|
||||
|
||||
CREATE TABLE vhost.tw_user (
|
||||
uid varchar(36) NOT NULL COMMENT "사용자 UUID",
|
||||
id varchar(30) NOT NULL,
|
||||
passwd varchar(100) NOT NULL,
|
||||
name varchar(20) NOT NULL COMMENT "사용자명",
|
||||
email varchar(50) NOT NULL,
|
||||
phone varchar(20) NULL COMMENT '연락처',
|
||||
mobile varchar(20) NULL COMMENT '핸드폰',
|
||||
role varchar(255) NOT NULL DEFAULT 'user' COMMENT '사용자등급',
|
||||
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,unuse: 사용않함',
|
||||
updated_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (uid),
|
||||
UNIQUE KEY (id),
|
||||
UNIQUE KEY (email)
|
||||
) ENGINE = InnoDB COMMENT = '사용자 정보';
|
||||
-- insert into tw_user (uid,id,passwd,name,email,role,status) select uuid(),id,passwd,name,email,role,status from cfmgr.user;
|
||||
DROP TABLE IF EXISTS vhost.tw_user_profile;
|
||||
|
||||
DROP TABLE IF EXISTS vhost.tw_user_sns;
|
||||
|
||||
CREATE TABLE vhost.tw_user_sns (
|
||||
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
user_uid varchar(36) NULL COMMENT '사용자 정보',
|
||||
site varchar(20) NOT NULL COMMENT 'Site: GOOGLE,FACEBOOK 등등',
|
||||
id varchar(255) NOT NULL COMMENT 'sns 로그인 인중후 Return ID값',
|
||||
name varchar(50) NOT NULL,
|
||||
email varchar(50) NOT NULL,
|
||||
detail text NOT NULL COMMENT 'JSON형식 원본값',
|
||||
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,unuse: 사용않함',
|
||||
updated_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (uid),
|
||||
UNIQUE KEY (site, id),
|
||||
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid) ON DELETE CASCADE
|
||||
) ENGINE = InnoDB COMMENT = 'SNS 로그인 후 정보';
|
||||
|
||||
DROP TABLE IF EXISTS vhost.tw_category;
|
||||
|
||||
CREATE TABLE vhost.tw_category (
|
||||
uid varchar(50) NOT NULL,
|
||||
grpno int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함',
|
||||
grporder int(5) unsigned NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
|
||||
grpdepth int(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
|
||||
parent varchar(50) DEFAULT NULL COMMENT '부모UID',
|
||||
name varchar(255) NOT NULL COMMENT '범주명',
|
||||
linkurl varchar(100) NOT NULL DEFAULT '/front/board' COMMENT 'Front Link URL',
|
||||
isaccess varchar(30) NOT NULL DEFAULT 'guest' COMMENT '접근권한',
|
||||
isread varchar(30) NOT NULL DEFAULT 'guest' COMMENT '읽기권한',
|
||||
iswrite varchar(30) NOT NULL DEFAULT 'guest' COMMENT '쓰기권한',
|
||||
isreply varchar(30) NOT NULL DEFAULT 'guest' COMMENT '답글권한',
|
||||
isupload varchar(30) NOT NULL DEFAULT 'guest' COMMENT 'Upload권한',
|
||||
isdownload varchar(30) NOT NULL DEFAULT 'guest' COMMENT 'Download권한',
|
||||
head text DEFAULT NULL COMMENT '위 내용',
|
||||
tail text DEFAULT NULL COMMENT '아래 내용',
|
||||
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 표시,unuse: 표시않함',
|
||||
updated_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (uid)
|
||||
) ENGINE = InnoDB COMMENT = '범주';
|
||||
|
||||
DROP TABLE IF EXISTS vhost.tw_board;
|
||||
-- 1. 게시물 추가전 grpno에 해당하는 max(grporder)+1씩증가 작업
|
||||
-- update tw_board set grporder=grporder+1 where grpno=그룹번호 and grporder > 선택한 grpno
|
||||
-- 2. 게시물 추가시 작업
|
||||
-- insert tw_board grpno=그룹번호,grporder=grporder+1,grpdepth=grpdepth+1
|
||||
-- 3. 게시물 조회시 작업
|
||||
-- select * from tw_board order by grpno desc,grporder asc
|
||||
CREATE TABLE vhost.tw_board (
|
||||
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함',
|
||||
grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
|
||||
grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
|
||||
parent int(10) UNSIGNED NULL COMMENT '부모UID',
|
||||
category_uid varchar(50) NOT NULL COMMENT '범주_UID',
|
||||
user_uid varchar(36) NULL COMMENT '작성자 정보',
|
||||
title varchar(255) NOT NULL COMMENT '제목',
|
||||
content text NOT NULL COMMENT '내용',
|
||||
passwd varchar(20) NULL COMMENT '작성자 암호',
|
||||
board_file varchar(255) NULL COMMENT '파일명',
|
||||
view_cnt int(5) NOT NULL DEFAULT 0 COMMENT '조회수',
|
||||
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용, unuse: 사용않함 등등',
|
||||
updated_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (uid),
|
||||
CONSTRAINT FOREIGN KEY (category_uid) REFERENCES tw_category (uid),
|
||||
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
|
||||
) ENGINE = InnoDB COMMENT = '게시물 정보';
|
||||
|
||||
DROP TABLE IF EXISTS vhost.tw_sitepage;
|
||||
|
||||
CREATE TABLE vhost.tw_sitepage (
|
||||
uid int(10) unsigned NOT NULL,
|
||||
category_uid varchar(50) NOT NULL COMMENT '범주_UID',
|
||||
user_uid varchar(36) DEFAULT NULL COMMENT '작성자 정보',
|
||||
title varchar(255) NOT NULL COMMENT '제목',
|
||||
content text NOT NULL COMMENT '내용',
|
||||
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,
|
||||
unuse: 사용않함 등등',
|
||||
updated_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (uid),
|
||||
KEY category_uid (category_uid),
|
||||
KEY user_uid (user_uid),
|
||||
CONSTRAINT tw_sitepage_ibfk_1 FOREIGN KEY (category_uid) REFERENCES tw_category (uid),
|
||||
CONSTRAINT tw_sitepage_ibfk_2 FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
|
||||
) ENGINE = InnoDB COMMENT '사이트페이지';
|
||||
361
app/Database/shoppingmall-20240423.sql
Normal file
361
app/Database/shoppingmall-20240423.sql
Normal file
File diff suppressed because one or more lines are too long
361
app/Database/shoppingmall-20240506.sql
Normal file
361
app/Database/shoppingmall-20240506.sql
Normal file
File diff suppressed because one or more lines are too long
19
app/Entities/BaseEntity.php
Normal file
19
app/Entities/BaseEntity.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
abstract class BaseEntity extends Entity
|
||||
{
|
||||
abstract public function getTitle(): string;
|
||||
final public function getPrimaryKey()
|
||||
{
|
||||
return $this->attributes['uid'];
|
||||
}
|
||||
//조화수관련 Field전용
|
||||
final public function getViews($field = 'view_cnt')
|
||||
{
|
||||
return $this->attributes[$field];
|
||||
}
|
||||
}
|
||||
23
app/Entities/BaseHierarchyEntity.php
Normal file
23
app/Entities/BaseHierarchyEntity.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
abstract class BaseHierarchyEntity extends BaseEntity
|
||||
{
|
||||
final public function getHierarchy_No()
|
||||
{
|
||||
return $this->attributes['grpno'];
|
||||
}
|
||||
final public function getHierarchy_Order()
|
||||
{
|
||||
return $this->attributes['grporder'];
|
||||
}
|
||||
final public function getHierarchy_Depth()
|
||||
{
|
||||
return $this->attributes['grpdepth'];
|
||||
}
|
||||
final public function getHierarchy_ParentUID()
|
||||
{
|
||||
return $this->attributes['parent_uid'];
|
||||
}
|
||||
}
|
||||
19
app/Entities/BillingEntity.php
Normal file
19
app/Entities/BillingEntity.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class BillingEntity extends BaseEntity
|
||||
{
|
||||
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
final public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['title'];
|
||||
}
|
||||
//추가기능
|
||||
|
||||
}
|
||||
34
app/Entities/BoardEntity.php
Normal file
34
app/Entities/BoardEntity.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class BoardEntity extends BaseHierarchyEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['title'];
|
||||
}
|
||||
//추가기능
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->attributes['passwd'];
|
||||
}
|
||||
//파일관련 Field전용
|
||||
final public function getFileDownload($url, $field = "upload_file")
|
||||
{
|
||||
if (is_null($this->attributes[$field])) {
|
||||
return "";
|
||||
}
|
||||
$files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]);
|
||||
return anchor(
|
||||
$url,
|
||||
ICONS['IMAGE_FILE'] . $files[0],
|
||||
["target" => "_self"]
|
||||
);
|
||||
}
|
||||
}
|
||||
25
app/Entities/CategoryEntity.php
Normal file
25
app/Entities/CategoryEntity.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class CategoryEntity extends BaseHierarchyEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
//추가기능
|
||||
//CommonHelper에서 사용
|
||||
public function getRole($field = 'isaccess')
|
||||
{
|
||||
return array_key_exists(
|
||||
$field,
|
||||
$this->attributes
|
||||
) ? $this->attributes[$field] : DEFAULTS['ROLE'];
|
||||
}
|
||||
}
|
||||
19
app/Entities/OrderBillingEntity.php
Normal file
19
app/Entities/OrderBillingEntity.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class OrderBillingEntity extends BaseEntity
|
||||
{
|
||||
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
final public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['order_uid'];
|
||||
}
|
||||
//추가기능
|
||||
|
||||
}
|
||||
27
app/Entities/OrderEntity.php
Normal file
27
app/Entities/OrderEntity.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class OrderEntity extends BaseEntity
|
||||
{
|
||||
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
final public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
//추가기능
|
||||
public function getOrderHint()
|
||||
{
|
||||
$hints = explode("-", $this->getPrimaryKey());
|
||||
return sprintf(
|
||||
"%s-**-%s",
|
||||
str_split($hints[0], 3)[0],
|
||||
str_split($hints[count($hints) - 1], 5)[0]
|
||||
);
|
||||
}
|
||||
}
|
||||
31
app/Entities/ProductEntity.php
Normal file
31
app/Entities/ProductEntity.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class ProductEntity extends BaseEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
//추가기능
|
||||
//이미지관련 Field전용
|
||||
final public function getFileImage($size = false, $field = "photo")
|
||||
{
|
||||
if (is_null($this->attributes[$field])) {
|
||||
return "";
|
||||
}
|
||||
$files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]);
|
||||
return sprintf(
|
||||
"<img src=\"/upload_images/%s%s\" alt=\"%s\">",
|
||||
$size ? $size . '_' : '',
|
||||
$files[1],
|
||||
$files[0]
|
||||
);
|
||||
}
|
||||
}
|
||||
17
app/Entities/SitepageEntity.php
Normal file
17
app/Entities/SitepageEntity.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class SitepageEntity extends BaseEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['title'];
|
||||
}
|
||||
//추가기능
|
||||
}
|
||||
21
app/Entities/UserEntity.php
Normal file
21
app/Entities/UserEntity.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class UserEntity extends BaseEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
//추가기능
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->attributes['passwd'];
|
||||
}
|
||||
}
|
||||
17
app/Entities/UserSNSEntity.php
Normal file
17
app/Entities/UserSNSEntity.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class UserSNSEntity extends BaseEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
//추가기능
|
||||
}
|
||||
0
app/Filters/.gitkeep
Normal file
0
app/Filters/.gitkeep
Normal file
65
app/Filters/AuthFilter.php
Normal file
65
app/Filters/AuthFilter.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
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)
|
||||
{
|
||||
// 로그인을 했으면
|
||||
if (session()->get(SESSION_NAMES['ISLOGIN'])) {
|
||||
$auth = session()->get(SESSION_NAMES['AUTH']);
|
||||
// 회원 ROLES이 필요ROLE($arguments[0]) 목록에 존재하지 않으면(ACL)
|
||||
if (!in_array($arguments[0], explode(DEFAULTS['DELIMITER_ROLE'], $auth[AUTH_FIELDS['ROLE']]))) {
|
||||
return redirect()->to(URLS['LOGIN'])->with(
|
||||
'return_message',
|
||||
sprintf(
|
||||
"%s,%s회원님은 접속에 필요한 권한[%s]이 없습니다. ",
|
||||
$auth[AUTH_FIELDS['ROLE']],
|
||||
$auth[AUTH_FIELDS['TITLE']],
|
||||
implode(",", $arguments)
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
session()->setFlashdata(SESSION_NAMES['RETURN_URL'], $request->getUri()->getPath() . '?' . $request->getUri()->getQuery());
|
||||
return redirect()->to(URLS['LOGIN'])->with('return_message', '로그인을하셔야합니다.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
0
app/Helpers/.gitkeep
Normal file
0
app/Helpers/.gitkeep
Normal file
209
app/Helpers/Billing_helper.php
Normal file
209
app/Helpers/Billing_helper.php
Normal file
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
function getFieldLabel_BillingHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_BillingHelper($field, $value, array $viewDatas, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'order_uid':
|
||||
case 'user_uid':
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
|
||||
// // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
|
||||
// foreach ($viewDatas['fieldFormOptions'][$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
break;
|
||||
case 'title':
|
||||
case 'name':
|
||||
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
|
||||
break;
|
||||
case 'passwd':
|
||||
return sprintf(
|
||||
"%s %s %s",
|
||||
form_password($field, DEFAULTS['EMPTY']),
|
||||
lang("{$viewDatas['className']}.label.confirmpassword"),
|
||||
form_password('confirmpassword', DEFAULTS['EMPTY']),
|
||||
);
|
||||
break;
|
||||
case 'content':
|
||||
case 'head':
|
||||
case 'tail':
|
||||
return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
break;
|
||||
case 'upload_file':
|
||||
case 'board_file':
|
||||
return form_upload($field);
|
||||
break;
|
||||
case 'view_cnt':
|
||||
return form_input($field, $value, ['type' => 'number']);
|
||||
break;
|
||||
case "status":
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_BillingHelper($field, $entity, array $viewDatas)
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'cost':
|
||||
case 'sale':
|
||||
return number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'price':
|
||||
return number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'response':
|
||||
return nl2br($value);
|
||||
break;
|
||||
case 'content':
|
||||
return html_entity_decode($value);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return $value ? str_split($value, 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_BillingHelper($field, $value, array $viewDatas)
|
||||
{
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_BillingHelper($field, array $viewDatas)
|
||||
{
|
||||
$label = lang("{$viewDatas['className']}.label.{$field}");
|
||||
if ($field == $viewDatas['order_field']) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
|
||||
}
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$viewDatas['uri']->addQuery('order_field', $field);
|
||||
$viewDatas['uri']->addQuery('order_value', $value);
|
||||
$columnData = anchor($viewDatas['uri'], $label);
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return sprintf("<th class='col-3'>%s</th>", $columnData);
|
||||
break;
|
||||
default:
|
||||
return sprintf("<th>%s</th>", $columnData);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Front용
|
||||
function getFieldIndex_Row_BillingHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
break;
|
||||
case 'order_uid':
|
||||
case 'user_uid':
|
||||
return getFieldView_BillingHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
case 'board_file':
|
||||
case 'upload_file':
|
||||
// echo var_export($entity, true);
|
||||
// exit;
|
||||
return $entity->getFileDownload(
|
||||
base_url() .
|
||||
$viewDatas['control'] .
|
||||
"/billing/download/{$field}/{$entity->getPrimaryKey()}",
|
||||
$field
|
||||
);
|
||||
break;
|
||||
case 'type':
|
||||
if ($entity->status != DEFAULTS['STATUS']) {
|
||||
// $card = anchor(
|
||||
// URLS['card'] . '/' . $entity->getPrimaryKey(),
|
||||
// ICONS['CARD'] . lang("{$viewDatas['className']}.TYPE.CARD"),
|
||||
// ["class" => "btn btn-sm btn-primary btn-circle", "style" => "color:white", "target" => "_self"]
|
||||
// );
|
||||
$deposit = anchor(
|
||||
URLS['deposit'] . '/' . $entity->getPrimaryKey(),
|
||||
ICONS['DEPOSIT'] . lang("{$viewDatas['className']}.TYPE.DEPOSIT"),
|
||||
["class" => "btn btn-sm btn-info btn-circle", "style" => "color:white", "target" => "_self"]
|
||||
);
|
||||
return $deposit;
|
||||
} else {
|
||||
//결제처리가된경우
|
||||
$value = strtoupper($value);
|
||||
return ICONS[$value] . lang("{$viewDatas['className']}.TYPE.{$value}");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return getFieldView_BillingHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
//Admin용
|
||||
function getFieldIndex_Row_BillingHelper_Admin($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
break;
|
||||
case 'board_file':
|
||||
case 'upload_file':
|
||||
return $entity->getFileDownload(
|
||||
base_url() .
|
||||
$viewDatas['control'] .
|
||||
"/billing/download/{$field}/{$entity->getPrimaryKey()}",
|
||||
$field
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['fieldFilters'])) {
|
||||
$attributes["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPrimaryKey(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
return getFieldForm_BillingHelper($field, $entity->$field, $viewDatas, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_BillingHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
206
app/Helpers/Board_helper.php
Normal file
206
app/Helpers/Board_helper.php
Normal file
@ -0,0 +1,206 @@
|
||||
<?php
|
||||
function getFieldLabel_BoardHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_BoardHelper($field, $value, array $viewDatas, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case "category_uid":
|
||||
case "user_uid":
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
|
||||
break;
|
||||
case 'title':
|
||||
case 'name':
|
||||
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
|
||||
break;
|
||||
case 'passwd':
|
||||
return sprintf(
|
||||
"%s %s %s",
|
||||
form_password($field, DEFAULTS['EMPTY']),
|
||||
lang("{$viewDatas['className']}.label.confirmpassword"),
|
||||
form_password('confirmpassword', DEFAULTS['EMPTY']),
|
||||
);
|
||||
break;
|
||||
case 'content':
|
||||
case 'head':
|
||||
case 'tail':
|
||||
return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
break;
|
||||
case 'upload_file':
|
||||
case 'board_file':
|
||||
return form_upload($field);
|
||||
break;
|
||||
case 'view_cnt':
|
||||
return form_input($field, $value, ['type' => 'number']);
|
||||
break;
|
||||
case "status":
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_BoardHelper($field, $entity, array $viewDatas)
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'category_uid':
|
||||
foreach (array_values($viewDatas['fieldFormOptions'][$field]) as $category_2depths) {
|
||||
foreach ($category_2depths as $key => $label) {
|
||||
if ($key == $value) {
|
||||
return $label;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
break;
|
||||
case 'photo':
|
||||
return $entity->getFileImage('middle', $field);
|
||||
break;
|
||||
case 'view_cnt':
|
||||
return number_format(!$value ? 0 : $value);
|
||||
break;
|
||||
case 'content':
|
||||
return html_entity_decode($value);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return $value ? str_split($value, 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_BoardHelper($field, $value, array $viewDatas)
|
||||
{
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_BoardHelper($field, array $viewDatas)
|
||||
{
|
||||
$label = lang("{$viewDatas['className']}.label.{$field}");
|
||||
if ($field == $viewDatas['order_field']) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
|
||||
}
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$viewDatas['uri']->addQuery('order_field', $field);
|
||||
$viewDatas['uri']->addQuery('order_value', $value);
|
||||
$columnData = anchor($viewDatas['uri'], $label);
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return sprintf("<th class='col-4'>%s</th>", $columnData);
|
||||
break;
|
||||
default:
|
||||
return sprintf("<th>%s</th>", $columnData);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
//Front용
|
||||
function getFieldIndex_Row_BoardHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
$depth = " ";
|
||||
for ($i = 1; $i < $entity->getHierarchy_Depth(); $i++) {
|
||||
$depth .= " ";
|
||||
}
|
||||
$reply = anchor(
|
||||
current_url() . '/reply/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
|
||||
ICONS['REPLY'],
|
||||
["target" => "_self"]
|
||||
);
|
||||
$view = anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
return sprintf("%s%s %s", $depth, $reply, $view);
|
||||
break;
|
||||
case 'board_file':
|
||||
case 'upload_file':
|
||||
return $entity->getFileDownload(
|
||||
base_url() .
|
||||
$viewDatas['control'] .
|
||||
"/board/download/{$field}/{$entity->getPrimaryKey()}" .
|
||||
'?category=' . $viewDatas['category']->getPrimaryKey(),
|
||||
$field
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return getFieldView_BoardHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Admin용
|
||||
function getFieldIndex_Row_BoardHelper_Admin($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
$depth = " ";
|
||||
for ($i = 1; $i < $entity->getHierarchy_Depth(); $i++) {
|
||||
$depth .= " ";
|
||||
}
|
||||
$reply = anchor(
|
||||
current_url() . '/reply/' . $entity->getPrimaryKey(),
|
||||
ICONS['REPLY'],
|
||||
["target" => "_self"]
|
||||
);
|
||||
$view = anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
return sprintf("%s%s %s", $depth, $reply, $view);
|
||||
break;
|
||||
case 'board_file':
|
||||
case 'upload_file':
|
||||
return $entity->getFileDownload(
|
||||
base_url() .
|
||||
$viewDatas['control'] .
|
||||
"/board/download/{$field}/{$entity->getPrimaryKey()}",
|
||||
$field
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['fieldFilters'])) {
|
||||
$attributes["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPrimaryKey(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
return getFieldForm_BoardHelper($field, $entity->$field, $viewDatas, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_BoardHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
100
app/Helpers/Card_helper.php
Normal file
100
app/Helpers/Card_helper.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
function getFieldLabel_CardHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_CardHelper($field, $value, array $viewDatas, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'card_quota':
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'card_number':
|
||||
return sprintf(
|
||||
"%s- %s- %s- %s",
|
||||
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
|
||||
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
|
||||
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
|
||||
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4])
|
||||
);
|
||||
break;
|
||||
case 'card_expiration':
|
||||
$start = date('Y');
|
||||
$end = date('Y', strtotime(date("Y") . ' + 10 year'));
|
||||
$years = [];
|
||||
for ($i = $start; $i <= $end; $i++) {
|
||||
$years[$i] = "{$i}년";
|
||||
}
|
||||
$months = [];
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$months[sprintf("%02d", $i)] = "{$i}월";
|
||||
}
|
||||
return form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']) . '/ ' .
|
||||
form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']);
|
||||
break;
|
||||
case 'email':
|
||||
return form_input($field, $viewDatas['user']->email);
|
||||
break;
|
||||
case 'phone':
|
||||
return form_input($field, $viewDatas['user']->phone);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_CardHelper($field, $entity, array $viewDatas)
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
default:
|
||||
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_CardHelper($field, $value, array $viewDatas)
|
||||
{
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_CardHelper($field, array $viewDatas)
|
||||
{
|
||||
$label = lang("{$viewDatas['className']}.label.{$field}");
|
||||
if ($field == $viewDatas['order_field']) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
|
||||
}
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$viewDatas['uri']->addQuery('order_field', $field);
|
||||
$viewDatas['uri']->addQuery('order_value', $value);
|
||||
$columnData = anchor($viewDatas['uri'], $label);
|
||||
switch ($field) {
|
||||
default:
|
||||
return sprintf("<th>%s</th>", $columnData);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Front용
|
||||
function getFieldIndex_Row_CardHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
default:
|
||||
return getFieldView_CardHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
164
app/Helpers/Category_helper.php
Normal file
164
app/Helpers/Category_helper.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
function getFieldLabel_CategoryHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_CategoryHelper($field, $value, array $viewDatas, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'isaccess':
|
||||
case 'isread':
|
||||
case 'iswrite':
|
||||
case 'isreply':
|
||||
case 'isupload':
|
||||
case 'isdownload':
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
|
||||
break;
|
||||
case 'title':
|
||||
case 'name':
|
||||
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
|
||||
break;
|
||||
case 'passwd':
|
||||
return sprintf(
|
||||
"%s %s %s",
|
||||
form_password($field, DEFAULTS['EMPTY']),
|
||||
lang("{$viewDatas['className']}.label.confirmpassword"),
|
||||
form_password('confirmpassword', DEFAULTS['EMPTY']),
|
||||
);
|
||||
break;
|
||||
case 'content':
|
||||
case 'head':
|
||||
case 'tail':
|
||||
return form_textarea(
|
||||
$field,
|
||||
html_entity_decode($value),
|
||||
['class' => 'editor', 'rows' => '20', 'cols' => '100']
|
||||
);
|
||||
break;
|
||||
case 'upload_file':
|
||||
case 'board_file':
|
||||
case 'photo':
|
||||
return form_upload($field);
|
||||
break;
|
||||
case 'view_cnt':
|
||||
return form_input($field, $value, ['type' => 'number']);
|
||||
break;
|
||||
case "status":
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_CategoryHelper($field, $entity, array $viewDatas)
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'view_cnt':
|
||||
return number_format(!$value ? 0 : $value);
|
||||
break;
|
||||
case 'content':
|
||||
return html_entity_decode($value);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return $value ? str_split($value, 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_CategoryHelper($field, $value, array $viewDatas)
|
||||
{
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_CategoryHelper($field, array $viewDatas)
|
||||
{
|
||||
$label = lang("{$viewDatas['className']}.label.{$field}");
|
||||
if ($field == $viewDatas['order_field']) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
|
||||
}
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$viewDatas['uri']->addQuery('order_field', $field);
|
||||
$viewDatas['uri']->addQuery('order_value', $value);
|
||||
$columnData = anchor($viewDatas['uri'], $label);
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return sprintf("<th class='col-2'>%s</th>", $columnData);
|
||||
break;
|
||||
default:
|
||||
return sprintf("<th>%s</th>", $columnData);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Front용
|
||||
function getFieldIndex_Row_CategoryHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
return getFieldView_CategoryHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
//Admin용
|
||||
function getFieldIndex_Row_CategoryHelper_Admin($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
$depth = " ";
|
||||
for ($i = 1; $i < $entity->getHierarchy_Depth(); $i++) {
|
||||
$depth .= " ";
|
||||
}
|
||||
$reply = anchor(
|
||||
current_url() . '/reply/' . $entity->getPrimaryKey(),
|
||||
ICONS['REPLY'],
|
||||
["target" => "_self"]
|
||||
);
|
||||
$view = anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
return sprintf("%s%s %s", $depth, $reply, $view);
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['fieldFilters'])) {
|
||||
$attributes["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPrimaryKey(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
return getFieldForm_CategoryHelper($field, $entity->$field, $viewDatas, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_CategoryHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
223
app/Helpers/Common_helper.php
Normal file
223
app/Helpers/Common_helper.php
Normal file
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
//로그인체크 한후 권한체크
|
||||
function isRole_CommonHelper(array $userRoles, $categoryEntity, $roleField = 'isaccess')
|
||||
{
|
||||
return in_array($categoryEntity->getRole($roleField), $userRoles);
|
||||
}
|
||||
|
||||
function getValueByKey_CommonHelper($key, array $attributes)
|
||||
{
|
||||
$options = array();
|
||||
$replace_attributes = array();
|
||||
foreach ($attributes as $idx => $value) {
|
||||
if ($idx == $key) {
|
||||
$replace_attributes[$idx] = $value;
|
||||
} else {
|
||||
array_push($options, $value);
|
||||
}
|
||||
}
|
||||
return array($replace_attributes, $options);
|
||||
}
|
||||
|
||||
function getRandomString_CommonHelper($length = 10, $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||
{
|
||||
return substr(str_shuffle($characters), 0, $length);
|
||||
}
|
||||
function getPasswordString_CommonHelper($length = 8)
|
||||
{
|
||||
return getRandomString_CommonHelper($length, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?");
|
||||
} //
|
||||
|
||||
//byte값을 알아보기 쉽게 변환
|
||||
function getSizeForHuman_CommonHelper($bytes)
|
||||
{
|
||||
$ext = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
||||
$unitCount = 0;
|
||||
for (; $bytes > 1024; $unitCount++) {
|
||||
$bytes /= 1024;
|
||||
}
|
||||
return floor($bytes) . $ext[$unitCount];
|
||||
} //
|
||||
|
||||
//Proxy등을 통하여 Client_IP가 알수없는경우 실제사용자의 IP를 가져오기 위한것
|
||||
function getClientIP_CommonHelper($clientIP = false)
|
||||
{
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$clientIP = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else if (isset($_SERVER['HTTP_X_FORWARDED'])) {
|
||||
$clientIP = $_SERVER['HTTP_X_FORWARDED'];
|
||||
} else if (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
|
||||
$clientIP = $_SERVER['HTTP_FORWARDED_FOR'];
|
||||
} else if (isset($_SERVER['HTTP_FORWARDED'])) {
|
||||
$clientIP = $_SERVER['HTTP_FORWARDED'];
|
||||
} else if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
$clientIP = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
return $clientIP;
|
||||
} //
|
||||
|
||||
function isDomain_CommonHelper(string $domain): bool
|
||||
{
|
||||
$parttern_validation = '/((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])*/';
|
||||
return preg_match("$parttern_validation", $domain);
|
||||
}
|
||||
|
||||
function isIPAddress_CommonHelper(string $ip, $type = false): bool
|
||||
{
|
||||
switch ($type) {
|
||||
case 'ipv4':
|
||||
return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
break;
|
||||
case 'ipv6':
|
||||
return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
||||
break;
|
||||
case 'all':
|
||||
return filter_var($ip, FILTER_VALIDATE_IP);
|
||||
break;
|
||||
default:
|
||||
return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function isHost_CommonHelper(string $host): bool
|
||||
{
|
||||
$parttern_validation = '/[a-zA-Z0-9\.\/\?\:@\*\-_=#]/';
|
||||
return preg_match($parttern_validation, $host);
|
||||
}
|
||||
//(EX:192.168.1.0 -> 192.168.001.000)
|
||||
function convertIPV4toCIDR_CommonHelper($cidr)
|
||||
{
|
||||
$temps = explode(".", $cidr);
|
||||
return sprintf("%03d.%03d.%03d.%03d", $temps[0], $temps[1], $temps[2], $temps[3]);
|
||||
} //
|
||||
//(EX:192.168.001.0000 -> 192.168.1.0)
|
||||
function convertCIDRtoIPV4_CommonHelper($ipv4)
|
||||
{
|
||||
$temps = explode(".", $ipv4);
|
||||
return sprintf("%d.%d.%d.%d", $temps[0], $temps[1], $temps[2], $temps[3]);
|
||||
} //
|
||||
function isMobile_CommonHelper()
|
||||
{
|
||||
// Check the server headers to see if they're mobile friendly
|
||||
if (isset($_SERVER["HTTP_X_WAP_PROFILE"])) {
|
||||
return true;
|
||||
}
|
||||
// If the http_accept header supports wap then it's a mobile too
|
||||
if (preg_match("/wap\.|\.wap/i", $_SERVER["HTTP_ACCEPT"])) {
|
||||
return true;
|
||||
}
|
||||
// Still no luck? Let's have a look at the user agent on the browser. If it contains
|
||||
// any of the following, it's probably a mobile device. Kappow!
|
||||
if (isset($_SERVER["HTTP_USER_AGENT"])) {
|
||||
$user_agents = array("midp", "j2me", "avantg", "docomo", "novarra", "palmos", "palmsource", "240x320", "opwv", "chtml", "pda", "windows\ ce", "mmp\/", "blackberry", "mib\/", "symbian", "wireless", "nokia", "hand", "mobi", "phone", "cdm", "up\.b", "audio", "SIE\-", "SEC\-", "samsung", "HTC", "mot\-", "mitsu", "sagem", "sony", "alcatel", "lg", "erics", "vx", "NEC", "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover", "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal", "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "\d\d\di", "moto");
|
||||
foreach ($user_agents as $user_string) {
|
||||
if (preg_match("/" . $user_string . "/i", $_SERVER["HTTP_USER_AGENT"])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Let's NOT return "mobile" if it's an iPhone, because the iPhone can render normal pages quite well.
|
||||
if (preg_match("/iphone/i", $_SERVER["HTTP_USER_AGENT"])) {
|
||||
return false;
|
||||
}
|
||||
// None of the above? Then it's probably not a mobile device.
|
||||
return false;
|
||||
} //
|
||||
|
||||
function alert_CommonHelper(string $msg, $url = null)
|
||||
{
|
||||
$msg = preg_replace("/\r/", "\\r", $msg);
|
||||
$msg = preg_replace("/\n/", "\\n", $msg);
|
||||
$msg = preg_replace("/\'/", "\'", $msg);
|
||||
$msg = preg_replace("/\"/", "\'", $msg);
|
||||
$msg = "alert(\"{$msg}\");";
|
||||
switch ($url) {
|
||||
case 'close':
|
||||
$msg .= "window.close();";
|
||||
break;
|
||||
case 'back':
|
||||
$msg .= "history.back();";
|
||||
break;
|
||||
default:
|
||||
$msg .= $url ? "location.href=\"{$url}\";" : "";
|
||||
break;
|
||||
}
|
||||
return "<script type=\"text/javascript\">{$msg}</script>";
|
||||
} //
|
||||
|
||||
// STATUS가 use가 아닐때 option을 disabled되게 하기위함 (override form_dropdown)
|
||||
function form_dropdown_test($data = '', $options = [], $selected = [], $extra = ''): string
|
||||
{
|
||||
$defaults = [];
|
||||
if (is_array($data)) {
|
||||
if (isset($data['selected'])) {
|
||||
$selected = $data['selected'];
|
||||
unset($data['selected']); // select tags don't have a selected attribute
|
||||
}
|
||||
if (isset($data['options'])) {
|
||||
$options = $data['options'];
|
||||
unset($data['options']); // select tags don't use an options attribute
|
||||
}
|
||||
} else {
|
||||
$defaults = ['name' => $data];
|
||||
}
|
||||
|
||||
if (!is_array($selected)) {
|
||||
$selected = [$selected];
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
$options = [$options];
|
||||
}
|
||||
|
||||
// If no selected state was submitted we will attempt to set it automatically
|
||||
if (empty($selected)) {
|
||||
if (is_array($data)) {
|
||||
if (isset($data['name'], $_POST[$data['name']])) {
|
||||
$selected = [$_POST[$data['name']]];
|
||||
}
|
||||
} elseif (isset($_POST[$data])) {
|
||||
$selected = [$_POST[$data]];
|
||||
}
|
||||
}
|
||||
|
||||
// Standardize selected as strings, like the option keys will be
|
||||
foreach ($selected as $key => $item) {
|
||||
$selected[$key] = (string) $item;
|
||||
}
|
||||
|
||||
$extra = stringify_attributes($extra);
|
||||
$multiple = (count($selected) > 1 && stripos($extra, 'multiple') === false) ? ' multiple="multiple"' : '';
|
||||
$form = '<select ' . rtrim(parse_form_attributes($data, $defaults)) . $extra . $multiple . ">\n";
|
||||
|
||||
foreach ($options as $key => $val) {
|
||||
// Keys should always be strings for strict comparison
|
||||
$key = (string) $key;
|
||||
|
||||
if (is_array($val)) {
|
||||
if (empty($val)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$form .= '<optgroup label="' . $key . "\">\n";
|
||||
|
||||
foreach ($val as $optgroupKey => $optgroupVal) {
|
||||
// Keys should always be strings for strict comparison
|
||||
$optgroupKey = (string) $optgroupKey;
|
||||
|
||||
$sel = in_array($optgroupKey, $selected, true) ? ' selected="selected"' : '';
|
||||
$form .= '<option value="' . $optgroupKey . '"' . $sel . '>' . $optgroupVal . "</option>\n";
|
||||
}
|
||||
|
||||
$form .= "</optgroup>\n";
|
||||
} else {
|
||||
$form .= '<option value="' . $key . '"'
|
||||
. (in_array($key, $selected, true) ? ' selected="selected"' : '') . '>'
|
||||
. $val . "</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $form . "</select>\n";
|
||||
}
|
||||
77
app/Helpers/Deposit_helper.php
Normal file
77
app/Helpers/Deposit_helper.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
function getFieldLabel_DepositHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_DepositHelper($field, $value, array $viewDatas, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
|
||||
case 'email':
|
||||
return form_input($field, $viewDatas['user']->email);
|
||||
break;
|
||||
case 'phone':
|
||||
return form_input($field, $viewDatas['user']->phone);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_DepositHelper($field, $entity, array $viewDatas)
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
default:
|
||||
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_DepositHelper($field, $value, array $viewDatas)
|
||||
{
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_DepositHelper($field, array $viewDatas)
|
||||
{
|
||||
$label = lang("{$viewDatas['className']}.label.{$field}");
|
||||
if ($field == $viewDatas['order_field']) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
|
||||
}
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$viewDatas['uri']->addQuery('order_field', $field);
|
||||
$viewDatas['uri']->addQuery('order_value', $value);
|
||||
$columnData = anchor($viewDatas['uri'], $label);
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return sprintf("<th class='col-4'>%s</th>", $columnData);
|
||||
break;
|
||||
default:
|
||||
return sprintf("<th>%s</th>", $columnData);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Front용
|
||||
function getFieldIndex_Row_DepositHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
return getFieldView_DepositHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
183
app/Helpers/Order_helper.php
Normal file
183
app/Helpers/Order_helper.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
function getFieldLabel_OrderHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_OrderHelper($field, $value, array $viewDatas, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'product_uid':
|
||||
case 'user_uid':
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
|
||||
// // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
|
||||
// foreach ($viewDatas['fieldFormOptions'][$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
break;
|
||||
case 'title':
|
||||
case 'name':
|
||||
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
|
||||
break;
|
||||
case 'passwd':
|
||||
return sprintf(
|
||||
"%s %s %s",
|
||||
form_password($field, DEFAULTS['EMPTY']),
|
||||
lang("{$viewDatas['className']}.label.confirmpassword"),
|
||||
form_password('confirmpassword', DEFAULTS['EMPTY']),
|
||||
);
|
||||
break;
|
||||
case 'content':
|
||||
case 'head':
|
||||
case 'tail':
|
||||
return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
break;
|
||||
case 'upload_file':
|
||||
case 'board_file':
|
||||
return form_upload($field);
|
||||
break;
|
||||
case 'view_cnt':
|
||||
return form_input($field, $value, ['type' => 'number']);
|
||||
break;
|
||||
case "status":
|
||||
case "type":
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_OrderHelper($field, $entity, array $viewDatas)
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'type':
|
||||
$paymentday = $value == 'rental' ? sprintf(
|
||||
"<BR>%s %s일",
|
||||
lang("{$viewDatas['className']}.label.paymentday"),
|
||||
$entity->paymentday
|
||||
) : "";
|
||||
return $viewDatas['fieldFormOptions'][$field][$value] . $paymentday;
|
||||
break;
|
||||
case 'cost':
|
||||
case 'sale':
|
||||
return number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'price':
|
||||
return number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'stock':
|
||||
case 'view_cnt':
|
||||
return number_format(!$value ? 0 : $value);
|
||||
break;
|
||||
case 'content':
|
||||
return html_entity_decode($value);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return $value ? str_split($value, 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_OrderHelper($field, $value, array $viewDatas)
|
||||
{
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_OrderHelper($field, array $viewDatas)
|
||||
{
|
||||
$label = lang("{$viewDatas['className']}.label.{$field}");
|
||||
if ($field == $viewDatas['order_field']) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
|
||||
}
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$viewDatas['uri']->addQuery('order_field', $field);
|
||||
$viewDatas['uri']->addQuery('order_value', $value);
|
||||
$columnData = anchor($viewDatas['uri'], $label);
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return sprintf("<th class='col-4'>%s</th>", $columnData);
|
||||
break;
|
||||
default:
|
||||
return sprintf("<th>%s</th>", $columnData);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Front용
|
||||
function getFieldIndex_Row_OrderHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
$uid = lang("{$viewDatas['className']}.label.uid") . ' : ' . str_split($entity->getPrimaryKey(), 4)[0] . '-xx-' . str_split($entity->getPrimaryKey(), 4)[1];
|
||||
$title = anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
return sprintf("%s<BR>%s", $uid, $title);
|
||||
break;
|
||||
default:
|
||||
return getFieldView_OrderHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
//Admin용
|
||||
function getFieldIndex_Row_OrderHelper_Admin($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
$uid = lang("{$viewDatas['className']}.label.uid") . ' : ' . str_split($entity->getPrimaryKey(), 4)[0] . '-xx-' . str_split($entity->getPrimaryKey(), 4)[1];
|
||||
$title = anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
return sprintf("%s<BR>%s", $uid, $title);
|
||||
break;
|
||||
case 'user_uid':
|
||||
return getFieldView_OrderHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['fieldFilters'])) {
|
||||
$attributes["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPrimaryKey(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
return getFieldForm_OrderHelper($field, $entity->$field, $viewDatas, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_OrderHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
186
app/Helpers/Product_helper.php
Normal file
186
app/Helpers/Product_helper.php
Normal file
@ -0,0 +1,186 @@
|
||||
<?php
|
||||
function getFieldLabel_ProductHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_ProductHelper($field, $value, array $viewDatas, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'category_uid':
|
||||
case 'user_uid':
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
|
||||
// // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
|
||||
// foreach ($viewDatas['fieldFormOptions'][$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
break;
|
||||
case 'title':
|
||||
case 'name':
|
||||
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
|
||||
break;
|
||||
case 'passwd':
|
||||
return sprintf(
|
||||
"%s %s %s",
|
||||
form_password($field, DEFAULTS['EMPTY']),
|
||||
lang("{$viewDatas['className']}.label.confirmpassword"),
|
||||
form_password('confirmpassword', DEFAULTS['EMPTY']),
|
||||
);
|
||||
break;
|
||||
case 'content':
|
||||
case 'head':
|
||||
case 'tail':
|
||||
return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
break;
|
||||
case 'upload_file':
|
||||
case 'board_file':
|
||||
case 'photo':
|
||||
return form_upload($field);
|
||||
break;
|
||||
case 'view_cnt':
|
||||
return form_input($field, $value, ['type' => 'number']);
|
||||
break;
|
||||
case "status":
|
||||
case "type":
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_ProductHelper($field, $entity, array $viewDatas)
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'category_uid':
|
||||
foreach (array_values($viewDatas['fieldFormOptions'][$field]) as $category_2depths) {
|
||||
foreach ($category_2depths as $key => $label) {
|
||||
if ($key == $value) {
|
||||
return $label;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
break;
|
||||
case 'photo':
|
||||
return $entity->getFileImage('middle', $field);
|
||||
break;
|
||||
case 'cost':
|
||||
case 'price':
|
||||
case 'sale':
|
||||
return number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'stock':
|
||||
case 'view_cnt':
|
||||
return number_format(!$value ? 0 : $value);
|
||||
break;
|
||||
case 'content':
|
||||
return html_entity_decode($value);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return $value ? str_split($value, 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_ProductHelper($field, $value, array $viewDatas)
|
||||
{
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_ProductHelper($field, array $viewDatas)
|
||||
{
|
||||
$label = lang("{$viewDatas['className']}.label.{$field}");
|
||||
if ($field == $viewDatas['order_field']) {
|
||||
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
|
||||
}
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
$viewDatas['uri']->addQuery('order_field', $field);
|
||||
$viewDatas['uri']->addQuery('order_value', $value);
|
||||
$columnData = anchor($viewDatas['uri'], $label);
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return sprintf("<th class='col-4'>%s</th>", $columnData);
|
||||
break;
|
||||
default:
|
||||
return sprintf("<th>%s</th>", $columnData);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Front용
|
||||
function getFieldIndex_Row_ProductHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
//front는 table을 사용하지 않는 점 주의
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return getFieldView_ProductHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
//Admin용
|
||||
function getFieldIndex_Row_ProductHelper_Admin($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return sprintf(
|
||||
"%s<BR>%s",
|
||||
$entity->getFileImage("middle", 'photo'),
|
||||
anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['fieldFilters'])) {
|
||||
$attributes["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPrimaryKey(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
return getFieldForm_ProductHelper($field, $entity->$field, $viewDatas, $attributes);
|
||||
}
|
||||
//front는 table을 사용하지 않는 점 주의
|
||||
return getFieldIndex_Row_ProductHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user