<?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' => [
    'path' => 'layouts' . DIRECTORY_SEPARATOR . 'front',
    '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' => [
    '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>',
    ]
  ],
  'main' => [
    'path' => 'layouts' . DIRECTORY_SEPARATOR . 'main',
    '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",
]);
