<?php
//Application 관련
define('APP_URL', $_ENV['APP_URL'] ?? 'http://localhost');
define('APP_NAME', $_ENV['APP_NAME'] ?? 'DBMS');
define('APP_AUTHOR', $_ENV['APP_AUTHOR'] ?? 'Prime IDC');
define('APP_AUTHOR_EMAIL', $_ENV['APP_AUTHOR_EMAIL'] ?? 'choi.jh@prime-idc.jp');
define('APP_VERSION', $_ENV['APP_VERSION'] ?? '1.0.0');

//환경변수
define('APP_ENV', $_ENV['APP_ENV'] ?? 'production');
define('APP_TIMEZONE', $_ENV['APP_TIMEZONE'] ?? 'Asia/Seoul');
define('APP_LOCALE', $_ENV['APP_LOCALE'] ?? 'en');
define('APP_CHARSET', $_ENV['APP_CHARSET'] ?? 'UTF-8');
define('APP_DEBUG', $_ENV['APP_DEBUG'] ?? false);
define('APP_DEBUG_LEVEL', $_ENV['APP_DEBUG_LEVEL'] ?? 'error');
define('APP_WRITEABLE_PATH', $_ENV['APP_WRITEABLE_PATH'] ?? ROOT_PATH . 'writeable' . DIRECTORY_SEPARATOR);

//View 관련
define('APP_VIEW_PATH', $_ENV['APP_VIEW_PATH'] ?? APP_PATH . 'Views');
define('APP_VIEW_PATH_PERMISSION', $_ENV['APP_VIEW_PATH_PERMISSION'] ?? 0775);
define('APP_VIEW_CACHE_PATH', $_ENV['APP_VIEW_CACHE_PATH'] ?? APP_WRITEABLE_PATH . 'cache');
define('APP_VIEW_CACHE_PATH_PERMISSION', $_ENV['APP_VIEW_CACHE_PATH_PERMISSION'] ?? 0775);
define('APP_VIEW_LIST_PERPAGE', $_ENV['APP_VIEW_LIST_PERPAGE'] ?? $_SERVER['APP_VIEW_LIST_PERPAGE'] ?? 20);
define('APP_VIEW_LIST_PAGINATION_GROUPSIZE', $_ENV['APP_VIEW_LIST_PAGINATION_GROUPSIZE'] ?? $_SERVER['APP_VIEW_LIST_PAGINATION_GROUPSIZE'] ?? 10);
define('APP_VIEW_DEBUG', $_ENV['APP_VIEW_DEBUG'] ?? false);
define('APP_VIEW_DEBUG_LEVEL', $_ENV['APP_VIEW_DEBUG_LEVEL'] ?? 'error');

//Log관련
define('APP_LOG_PATH', $_ENV['APP_LOG_PATH'] ?? APP_WRITEABLE_PATH . 'logs');
define('APP_LOG_PERMISSION', $_ENV['APP_LOG_PERMISSION'] ?? 0775);
define('APP_LOG_FORMAT', $_ENV['APP_LOG_FORMAT'] ?? 'text');
define('APP_LOG_MAX_SIZE', $_ENV['APP_LOG_MAX_SIZE'] ?? 1048576); // 1MB
define('APP_LOG_MAX_FILES', $_ENV['APP_LOG_MAX_FILES'] ?? 5);
define('APP_LOG_DATE_FORMAT', $_ENV['APP_LOG_DATE_FORMAT'] ?? 'Y-m-d H:i:s');
define('APP_LOG_CHANNEL', $_ENV['APP_LOG_CHANNEL'] ?? 'default');
define('APP_LOG_LEVELS', $_ENV['APP_LOG_LEVELS'] ?? [
  'emergency' => 0,
  'alert' => 1,
  'critical' => 2,
  'error' => 3,
  'warning' => 4,
  'notice' => 5,
  'info' => 6,
  'debug' => 7,
]);

//Session 관련
define('APP_SESSION_DRIVER', $_ENV['APP_SESSION_DRIVER'] ?? 'file');
define('APP_SESSION_NAME', $_ENV['APP_SESSION_NAME'] ?? 'PHPSESSID');
define('APP_SESSION_LIFETIME', $_ENV['APP_SESSION_LIFETIME'] ?? 120);
define('APP_SESSION_PATH', $_ENV['APP_SESSION_PATH'] ?? APP_WRITEABLE_PATH . 'sessions');
define('APP_SESSION_PERMISSION', $_ENV['APP_SESSION_PERMISSION'] ?? 0775);

//Cookie 관련
define('APP_SESSION_COOKIE_PATH', $_ENV['APP_SESSION_COOKIE_PATH'] ?? '/');
define('APP_SESSION_COOKIE_EXPIRE', $_ENV['APP_SESSION_COOKIE_EXPIRE'] ?? 3600);
define('APP_SESSION_COOKIE_DOMAIN', $_ENV['APP_SESSION_COOKIE_DOMAIN'] ?? null);
define('APP_SESSION_COOKIE_SECURE', $_ENV['APP_SESSION_COOKIE_SECURE'] ?? false);
define('APP_SESSION_COOKIE_HTTPONLY', $_ENV['APP_SESSION_COOKIE_HTTPONLY'] ?? true);
define('APP_SESSION_USE_ONLY_COOKIES', $_ENV['APP_SESSION_USE_ONLY_COOKIES'] ?? true);
define('APP_SESSION_USE_STRICT_MODE', $_ENV['APP_SESSION_USE_STRICT_MODE'] ?? true);
define('APP_SESSION_USE_UNIQUE_ID', $_ENV['APP_SESSION_USE_UNIQUE_ID'] ?? false);
define('APP_SESSION_USE_FLASH', $_ENV['APP_SESSION_USE_FLASH'] ?? true);
define('APP_SESSION_USE_INPUT', $_ENV['APP_SESSION_USE_INPUT'] ?? true);

//CSRF 관련
define('APP_SESSION_USE_CSRF', $_ENV['APP_SESSION_USE_CSRF'] ?? true);
define('APP_SESSION_USE_CSRF_TOKEN', $_ENV['APP_SESSION_USE_CSRF_TOKEN'] ?? true);
define('APP_SESSION_USE_CSRF_NAME', $_ENV['APP_SESSION_USE_CSRF_NAME'] ?? 'csrf_token');
define('APP_SESSION_USE_CSRF_EXPIRE', $_ENV['APP_SESSION_USE_CSRF_EXPIRE'] ?? 3600);
define('APP_SESSION_USE_CSRF_EXCLUDE', $_ENV['APP_SESSION_USE_CSRF_EXCLUDE'] ?? []);
define('APP_SESSION_USE_CSRF_EXCLUDE_METHOD', $_ENV['APP_SESSION_USE_CSRF_EXCLUDE_METHOD'] ?? ['GET', 'HEAD', 'OPTIONS']);
define('APP_SESSION_USE_CSRF_EXCLUDE_URI', $_ENV['APP_SESSION_USE_CSRF_EXCLUDE_URI'] ?? []);

//Database 관련
define('DATABASE_DRIVER', $_ENV['DATABASE_DRIVER'] ?? $_SERVER['DATABASE_DRIVER'] ?? 'mysql');
define('DATABASE_HOST', $_ENV['DATABASE_HOST'] ?? $_SERVER['DATABASE_HOST'] ?? 'localhost');
define('DATABASE_DB', $_ENV['DATABASE_DB'] ?? $_SERVER['DATABASE_DB'] ?? 'test');
define('DATABASE_CHARSET', $_ENV['DATABASE_CHARSET'] ?? $_SERVER['DATABASE_CHARSET'] ?? 'utf8');
define('DATABASE_ID', $_ENV['DATABASE_ID'] ?? $_SERVER['DATABASE_ID'] ?? 'test');
define('DATABASE_PASSWORD', $_ENV['DATABASE_PASSWORD'] ?? $_SERVER['DATABASE_PASSWORD'] ?? 'test');
define('DATABASE_QUERY_DEBUG', $_ENV['DATABASE_QUERY_DEBUG'] ?? $_SERVER['DATABASE_QUERY_DEBUG'] ?? false);

//DBMS 관련정보보
define('DBMS_SITE_DASHBOARD_DAY', $_ENV['DBMS_SITE_DASHBOARD_DAY'] ?? $_SERVER['DBMS_SITE_DASHBOARD_DAY'] ?? 7);
define('DBMS_SITE_HOST', $_ENV['DBMS_SITE_HOST'] ?? $_SERVER['DBMS_SITE_HOST'] ?? "http://dbms.prime-idc.jp");
define('DBMS_SITE_JAVA_PORT', $_ENV['DBMS_SITE_JAVA_PORT'] ?? $_SERVER['DBMS_SITE_JAVA_PORT'] ?? 6752);
define('DBMS_SITE_URL', DBMS_SITE_HOST . ":" . DBMS_SITE_JAVA_PORT);

define('DBMS_SITEINFOS', [
  'dbms.prime-idc.jp' => [
    "id" => "PRIMEIDC",
    "domain" => "dbms.prime-idc.jp",
    "name" => "PrimeIDC",
    "email" => "primeidc.jp@gmail.com",
    "totalcount_types" => ["normal", "defence", "solo", "substitution", "test"],
    "totalcount_customers" => [
      "idcjp" => "Client_Code NOT IN ('C116','C012','C636')",
      "winidc" => "Client_Code='C116'",
      "gamewing" => "Client_Code='C012'",
      "GDIDC" => "Client_Code='C636'",
    ],
    "banks" => [
      ["id" => "331301-04-217387", "name" => '국민은행', "owner" => "주)듀나미스"]
    ]
  ],
  'dbms.itsolution-idc.jp' => [
    "id"     => "ITSOLUTION",
    "domain" => "dbms.itsolution-idc.jp",
    "name"   => "Itsolution",
    "email"  => "support@itsoution-idc.jp",
    "totalcount_types" => ["normal", "defence", "solo", "substitution", "test"],
    "totalcount_customers" => [
      "winidc" => "Client_Code NOT IN ('C237')",
      "bosch" => "Client_Code='C237'",
    ],
    "banks"  => [
      ["id" => "9002-1932-1654-1", "name" => '새마을금고', "owner" => "주식회사 르호봇"],
      ["id" => "351-0995-6751-73", "name" => '농협', "owner" => "주식회사 르호봇"],
    ],
  ],
  'dbms.gdidc.jp' =>  [
    "id" => "GDIDC",
    "domain" => "dbms.gdidc.jp",
    "name" => "GDIDC",
    "email" => "support@gdidc.jp",
    "totalcount_types" => ["normal", "defence", "solo", "substitution", "test"],
    "totalcount_customers" => [
      "gdidc" => "",
    ],
    "banks" => [
      ["id" => "1005-204-100758", "name" => '우리은행', "owner" => " (주)브엘라해로이"],
    ],
  ]
]);
define('DBMS_SERVICE_SWITCHCODE', [
  'Chiba' => ['begin' => 'C00%', 'end' => 'C64%'],
  'Tokyo' => ['begin' => 'C80%', 'end' => 'C99%']
]);
define('DBMS_SERVICE_LINE_ALL', [
  'normal' => '일반',
  'defence' => '방어',
  'solo' => '전용',
  'substitution' => '대체',
  'test' => '테스트',
  'vpn' => 'VPN',
  'event' => '이벤트',
]);
define('DBMS_GEARLIST_PROCESS_TYPES', [
  '',
  'COLOCATION',
  'XEON Single',
  'CUSTOM',
  'INS-일회성',
  'NEHALEM',
  'Cisco Router',
]);
define('DBMS_GEARLIST_CPU_TYPES', [
  '',
  'X6-Q',
  'C2800',
  'C2600',
  'COL',
  'CUS',
  'NX227',
  'NX20',
  'NX21',
  'DQ28',
  'DQ26',
  'DQ31',
  'DQ18',
  'DQ23',
  'DQ20',
  'DX34',
  'DX38',
  'DX28',
  'DX32',
  'DX36',
  'DX30',
  'MD32',
  'MD30',
  'Q16R',
  'Q316',
  'Q310',
  'Q283',
  'Q266',
  'Q25R',
  'Q213',
  'Q20R',
  'Q186',
  'Q24',
  'Q20',
  'Q240',
  'DX3',
  'DQ233'
]);
define('DBMS_CLIENT_POINT_TYPE', [
  'deposit' => '입금',
  'withdrawal' => '출금',
]);
