diff --git a/extdbms/default_alert.php b/extdbms/default_alert.php index 1f948be..3b9eab9 100644 --- a/extdbms/default_alert.php +++ b/extdbms/default_alert.php @@ -1,240 +1,20 @@ - - -
- -
+require_once __DIR__ . '/vendor/autoload.php'; +$dotenv = Dotenv::createImmutable(__DIR__); +$dotenv->load(); - - -$function($sitekey); +} catch (\Exception $e) { + echo $e->getMessage(); } - -//$query="select * from commentdb where receiver like '$_GET[name]' $option2 or receiver like '전체' and read_check like '0' order by num desc"; -//$query2="select * from commentdb where receiver like '$_GET[name]' or receiver like '2팀' or receiver like '팀장' or receiver like '시스템' or receiver like '전체' and read_check like '0' order by num desc"; -//$query2="select * from commentdb where (receiver like '$_GET[name]' and read_check like '0') or (receiver like '2팀'and read_check not like ('%,$_GET[name]%')) or (receiver like '팀장'and read_check not like ('%,$_GET[name]%')) or (receiver like '시스템'and read_check not like ('%,$_GET[name]%')) or (receiver like '전체' and read_check not like ('%,$_GET[name]%')) or (receiver like '알바' and read_check not like ('%,$_GET[name]%')) or (receiver like '네트워크' and read_check not like ('%,$_GET[name]%')) or (receiver like '1팀' and read_check not like ('%,$_GET[name]%')) order by num desc"; -$query2 = "select * from commentdb where (receiver like '$_GET[name]' and read_check like '0') $option2 order by num desc"; -$total = mysql_num_rows(mysql_query($query2, $db_connect)); -$total == "0" ? $newicon = "" : $newicon = "" -//if (isset($_SERVER['HTTP_REFERER']) && preg_match('@^[^/]+://[^/]+@', $_SERVER['HTTP_REFERER'], $match)) {} -// var_dump($match[0]); - -?> - - - -
-
-
-
-
-
- -
-
-
-
새 쪽지 알림
-
-
-
- - - -
-
- - DATE_ADD(now(), INTERVAL -7 DAY) and service_status = 'o' and service_line not in ('test','substitution')"; -$day7_server = mysql_num_rows(mysql_query($day7_server_query, $db_connect)); -?> - -
-
-
-
-
- -
-
-
-
최근 7일간 신규서버 대수
-
-
-
- - - -
-
- - -
-
-
-
-
- -
-
-
0
-
요청업무 알림
-
-
-
- - - -
-
- - - - -
-
-
-
-
- -
-
-
-
금일 기준 미납 서버
-
-
-
- - - -
-
-
- - - - - - - - - - -
- - - - -
- - diff --git a/extdbms/index.php b/extdbms/index.php index fbd8c4c..27cc3e2 100644 --- a/extdbms/index.php +++ b/extdbms/index.php @@ -1,17 +1,23 @@ load(); - $control = new $control(); - return $control->$function(isset($arvg[3]) ? $argv[3] : "dbms.prime-idc.jp"); + // 테스트 URL : "http://test.com/Control/Method/arg1/arg2"; + // 요청된 URL 경로 가져오기 + $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false; + $url = !$url && isset($argv[1]) ? $argv[1] : false; + $app = new App(trim($url, '/')); + $controller = $app->getController(); + $method = $app->getMethod(); + return $controller->$method(); } catch (\Exception $e) { echo $e->getMessage(); } diff --git a/extdbms/lib/Configs/App.php b/extdbms/lib/Configs/App.php new file mode 100644 index 0000000..9e9c9aa --- /dev/null +++ b/extdbms/lib/Configs/App.php @@ -0,0 +1,13 @@ + "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" => "주)듀나미스"], + ], + ]; + break; + case 'dbms.itsolution-idc.jp': + $siteinfo = [ + "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" => "주식회사 르호봇"], + ], + ]; + break; + case 'dbms.gdidc.jp': + $siteinfo = [ + "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" => " (주)브엘라해로이"], + ], + ]; + break; + default: + $siteinfo = null; + break; + } + return $siteinfo; + } +} diff --git a/extdbms/lib/Configs/View.php b/extdbms/lib/Configs/View.php new file mode 100644 index 0000000..a741760 --- /dev/null +++ b/extdbms/lib/Configs/View.php @@ -0,0 +1,13 @@ +helper = new ServiceHelper(); } // public function getService(): ServiceService @@ -20,6 +34,54 @@ class SiteController extends CommonController return $this->_service; } + public function getMemberService(): MemberService + { + if ($this->_memberService === null) { + $this->_memberService = new MemberService(); + } + return $this->_memberService; + } + + public function getClientService(): ClientService + { + if ($this->_clientService === null) { + $this->_clientService = new ClientService(); + } + return $this->_clientService; + } + + public function getVPCService(): VPCService + { + if ($this->_vpcService === null) { + $this->_vpcService = new VPCService(); + } + return $this->_vpcService; + } + public function getKCSService(): KCSService + { + if ($this->_kcsService === null) { + $this->_kcsService = new KCSService(); + } + return $this->_kcsService; + } + public function getHistoryService(): HistoryService + { + if ($this->_historyService === null) { + $this->_historyService = new HistoryService(); + } + return $this->_historyService; + } + public function getAddDbService(): AddDbService + { + if ($this->_addDbService === null) { + $this->_addDbService = new AddDbService(); + } + return $this->_addDbService; + } + + //Dashboard , default_alert.php + //CLI 접속방법 : php index.php SiteController/dashboard + //WEB 접속방법 : http://localhost/SiteController/dashboard public function dashboard() { // 최근7일 신규서버수 @@ -35,9 +97,18 @@ class SiteController extends CommonController } //서비스카운팅 , total_counting.php - public function totalcount(string $sitekey): string + //CLI 접속방법 : php index.php SiteController/totalcount/sitekey/dbms.prime-idc.jp + //WEB 접속방법 : http://localhost/SiteController/totalcount/sitekey/dbms.prime-idc.jp + public function totalcount(): string { - $this->siteInfo = DBMS_SITEINFOS[$sitekey]; + $sitekey = $this->getSegments('sitekey'); + if ($sitekey === null) { + throw new \Exception("sitekey 값이 정의되지 않았습니다."); + } + $this->siteInfo = $this->getConfig()->getSiteInfo($sitekey); + if ($this->siteInfo === null) { + throw new \Exception("[{$sitekey}] 값에 해당하는 사이트정보가 존재하지 않습니다."); + } $this->totalcount = $this->getService()->getTotalCount($this->siteInfo); // echo $sitekey; // dd($this->siteInfo); @@ -63,4 +134,98 @@ class SiteController extends CommonController $this->total = $total; return $this->render(__FUNCTION__); } + + //신규서버현황 new_server_list.php + //CLI 접속방법 : php index.php SiteController/newservices/limit/5 + //WEB 접속방법 : http://localhost/SiteController/newservices/limit/5 + public function newservices(): string + { + //신규서버정보 + $this->limit = intval($this->getSegments('limit') ?? 5); + $this->entitys = $this->getService()->getNews($this->limit); + // echo $this->getService()->getModel()->getLastQuery(); + // 배열 초기화를 명시적으로 수행 + $users = []; + $clients = []; + $vpcs = []; + $kcss = []; + $cnt = 1; + foreach ($this->entitys as $entity) { + $serviceCode = $entity->getServiceCode(); + //관리자정보(등록자) + $users[$serviceCode] = $entity->getMemberCode() ? $this->getMemberService()->getEntitById($entity->getMemberCode()) : ""; + //고객정보 + $clients[$serviceCode] = $this->getClientService()->getEntitByCode($entity->getClientCode()); + //VPC정보 + $vpcs[$serviceCode] = $this->getVPCService()->getCountByServiceCode($serviceCode); + //KCS정보 + $kcss[$serviceCode] = $this->getKCSService()->getCountByServiceCode($serviceCode); + $cnt++; + } + // dd($this->entitys); + // 루프가 끝난 후 한번에 속성 할당 + $this->users = $users; + $this->clients = $clients; + $this->vpcs = $vpcs; + $this->kcss = $kcss; + return $this->render(__FUNCTION__); + } + //CLI 접속방법 : php index.php SiteController/newhistorys/limit/5 + //WEB 접속방법 : http://localhost/SiteController/newhistorys/limit/5 + public function newhistorys(): string + { + //신규서버정보 + $this->limit = intval($this->getSegments('limit') ?? 5); + $this->entitys = $this->getHistoryService()->getNews($this->limit); + // 배열 초기화를 명시적으로 수행 + $services = []; + $clients = []; + foreach ($this->entitys as $entity) { + $pk = $entity->getPK(); + //서비스정보가져오기 + $service = $this->getService()->getServiceByServiceCode($entity->getServiceCode()); + if ($service) { + //고객정보 + $clients[$pk] = $this->getClientService()->getEntitByCode($entity->getClientCode()); + //서비스정보 + $services[$pk] = $service; + } + } + // 루프가 끝난 후 한번에 속성 할당 + $this->services = $services; + $this->clients = $clients; + return $this->render(__FUNCTION__); + } + //청구서페이지, depositbillpaper.php + //CLI 접속방법 : php index.php SiteController/billpaper/sitekey/dbms.prime-idc.jp/client_code/코드번호 + //WEB 접속방법 : http://localhost/SiteController/billpaper/sitekey/dbms.prime-idc.jp/client_code/코드번호 + public function billpaper(): string + { + $sitekey = $this->getSegments('sitekey'); + if ($sitekey === null) { + throw new \Exception("sitekey 값이 정의되지 않았습니다."); + } + $client_code = $this->getSegments('client_code'); + if ($client_code === null) { + throw new \Exception("client_code 값이 정의되지 않았습니다."); + } + $this->siteInfo = $this->getConfig()->getSiteInfo($sitekey); + $this->client = $this->getClientService()->getEntitByCode($client_code); + return $this->render(__FUNCTION__); + } + //부가서비스 : 닷디펜더,딥파인더 등, deepfinder_list.php,dotdefender_list.php + //CLI 접속방법 : php index.php SiteController/extraservice/client_code/코드번호 + //WEB 접속방법 : http://localhost/SiteController/extraservice/sitekey/dbms.prime-idc.jp/client_code/코드번호 + public function extraservice(): string + { + $addb_code = $this->getSegments('addb_code'); + if ($addb_code === null) { + throw new \Exception("addb_code 값이 정의되지 않았습니다."); + } + //segment의 값이 한글인경우 urldecode가 필요 + $adddb_code = urldecode($addb_code); + $service_codes = $this->getAddDbService()->getServiceCodesByCode($adddb_code); + $this->services = $this->getService()->getExtras($service_codes); + return $this->render(__FUNCTION__); + } } //Class diff --git a/extdbms/lib/Core/App.php b/extdbms/lib/Core/App.php new file mode 100644 index 0000000..855fb11 --- /dev/null +++ b/extdbms/lib/Core/App.php @@ -0,0 +1,78 @@ +_controller = new $control(); + } + //Method추출 + if (isset($arguments[1])) { + $route = ""; + switch ($arguments[1]) { + case 'service': + $route = "newservices"; + break; + case 'history': + $route = "newhistorys"; + break; + default: + $route = $arguments[1]; + break; + } + $this->_method = $route; + } + //세그먼트 추출 + $segments = []; + if (count($arguments) > 2) { + $isKey = true; + $key = ""; + foreach (array_slice($arguments, 2) as $argument) { + if ($isKey) { + $segments[$argument] = null; + $key = $argument; + $isKey = false; //Value값을 넣어야하므로 + } else { + $segments[$key] = $argument; + $isKey = true; //Key로 설정해야하므로 + } + } + } + $this->_controller->setSegments($segments); + } // + + final public function getController(): Controller + { + if ($this->_controller === null) { + throw new \Exception("Method 사용법 : 'http://test.com/Control/Method/arg1/arg2' 혹은 php index.php Control/Method/arg1/arg2"); + } + return $this->_controller; + } + final public function getMethod(): string + { + if ($this->_method === null) { + throw new \Exception("Method 사용법 : 'http://test.com/Control/Method/arg1/arg2' 혹은 php index.php Control/Method/arg1/arg2"); + } + return $this->_method; + } +} //Class diff --git a/extdbms/lib/Core/Config.php b/extdbms/lib/Core/Config.php new file mode 100644 index 0000000..268c603 --- /dev/null +++ b/extdbms/lib/Core/Config.php @@ -0,0 +1,27 @@ +_debug = $debug; + } + final public function getDebug() + { + return $this->_debug; + } + + final public function __get($name) + { + return $this->_values[$name]; + } + final public function __set($name, $value) + { + $this->_values[$name] = $value; + } +} //Class diff --git a/extdbms/lib/Core/Constants.php b/extdbms/lib/Core/Constants.php deleted file mode 100644 index e07f751..0000000 --- a/extdbms/lib/Core/Constants.php +++ /dev/null @@ -1,49 +0,0 @@ - [ - "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" => " (주)브엘라해로이"], - ], - ] -]); diff --git a/extdbms/lib/Core/Controller.php b/extdbms/lib/Core/Controller.php index 658d487..05461b6 100644 --- a/extdbms/lib/Core/Controller.php +++ b/extdbms/lib/Core/Controller.php @@ -2,34 +2,44 @@ namespace lib\Core; -use lib\Core\View; +use lib\Configs\Config; +use lib\Configs\View; abstract class Controller { - private $_debug = false; - protected $view = null; + private ?Config $_config = null; + private ?View $_view = null; + private $_segments = []; protected function __construct() { - $this->view = new View(); + $this->_config = new Config(); + $this->_view = new View(); } // - final public function setDebug($debug) + final public function getConfig(): Config { - $this->_debug = $debug; + return $this->_config; } - final public function getDebug() + final public function setSegments(array $segments) { - return $this->_debug; + $this->_segments = $segments; + } + final public function getSegments(string $key = ""): mixed + { + if ($key === "") { + return $this->_segments; + } + return array_key_exists($key, $this->_segments) ? $this->_segments[$key] : null; } final public function __get($name) { - return $this->view->$name; + return $this->_view->$name; } final public function __set($name, $value) { - $this->view->$name = $value; + $this->_view->$name = $value; } public function render($file) { - return $this->view->render($file); + return $this->_view->render($file); } } //Class diff --git a/extdbms/lib/Core/Entity.php b/extdbms/lib/Core/Entity.php index 39bfc3a..35b7fa6 100644 --- a/extdbms/lib/Core/Entity.php +++ b/extdbms/lib/Core/Entity.php @@ -2,13 +2,13 @@ namespace lib\Core; -class Entity +abstract class Entity { private $_values = []; private $_debug = false; - public function __construct($datas) + protected function __construct($datas) { - $this->values = $datas; + $this->_values = $datas; } // final public function setDebug($debug) { diff --git a/extdbms/lib/Core/Helper.php b/extdbms/lib/Core/Helper.php new file mode 100644 index 0000000..83c4a4e --- /dev/null +++ b/extdbms/lib/Core/Helper.php @@ -0,0 +1,8 @@ +_querys["JOIN"] = " {$type} JOIN {$table} ON {$match}"; } - final public function orderBy(mixed $columns, mixed $direction = null): void + final public function orderBy(string $column, string $direction = "DESC"): void { - $this->_querys["ORDERBY"] = " ORDERBY " . $this->makeQuery($columns, $direction, " "); + $this->_querys["ORDERBY"] = " ORDER BY {$column} {$direction}"; } - final public function limit(int $start, mixed $end = "", bool $offset = false): void + final public function limit(int $start, int $offset = 0): void { - $this->_querys["LIMIT"] = " LIMIT {$start} " . $offset ? "OFFSET " : "," . $end; + $offset = $offset > 0 ? ",{$offset}" : ""; + $this->_querys["LIMIT"] = " LIMIT {$start} {$offset}"; } //Result protected function getResult($mode = PDO::FETCH_ASSOC): mixed { - $query = "{$this->_querys['SELECT']} FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']} {$this->_querys['ORDERBY']}"; + $query = "{$this->_querys['SELECT']} FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']} {$this->_querys['LIMIT']} {$this->_querys['ORDERBY']}"; $stmt = $this->execute($query); return $stmt->fetch($mode); } protected function getResults($mode = PDO::FETCH_ASSOC): mixed { - $query = "{$this->_querys["SELECT"]} FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']} {$this->_querys['ORDERBY']}"; - $query = "{$this->_querys['SELECT']} {$this->_querys['JOIN']} {$this->_querys['ORDERBY']}"; + $query = "{$this->_querys["SELECT"]} FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']} {$this->_querys['ORDERBY']} {$this->_querys['LIMIT']}"; $stmt = $this->execute($query); return $stmt->fetchAll($mode); } final public function countAllResults(string $column = "*", $reset = true): int { $this->_reset = $reset; - $query = "SELECT COUNT({$column}) FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']} {$this->_querys['ORDERBY']}"; + $query = "SELECT COUNT({$column}) FROM {$this->getTable()} {$this->getWhere()} {$this->_querys['JOIN']}"; $stmt = $this->execute($query); $count = $stmt->fetchColumn(0); $this->_reset = true; diff --git a/extdbms/lib/Core/View.php b/extdbms/lib/Core/View.php index 1ac0cb2..127348f 100644 --- a/extdbms/lib/Core/View.php +++ b/extdbms/lib/Core/View.php @@ -1,13 +1,12 @@ _debug = $debug; diff --git a/extdbms/lib/Entities/ClientEntity.php b/extdbms/lib/Entities/ClientEntity.php index b4ab5c8..d5dfaa2 100644 --- a/extdbms/lib/Entities/ClientEntity.php +++ b/extdbms/lib/Entities/ClientEntity.php @@ -10,4 +10,8 @@ class ClientEntity extends Entity { parent::__construct($datas); } // + public function getTitle() + { + $this->Client_Name; + } } //Class diff --git a/extdbms/lib/Entities/CommonEntity.php b/extdbms/lib/Entities/CommonEntity.php index c374192..c5a3dbe 100644 --- a/extdbms/lib/Entities/CommonEntity.php +++ b/extdbms/lib/Entities/CommonEntity.php @@ -2,10 +2,14 @@ namespace lib\Core; -abstract class CommonEntity extends Entity +use lib\Core\Entity as Core; + +abstract class CommonEntity extends Core { public function __construct($datas) { parent::__construct($datas); } // + abstract public function getTitle(); + abstract public function getPK(); } //Class diff --git a/extdbms/lib/Entities/HistoryEntity.php b/extdbms/lib/Entities/HistoryEntity.php new file mode 100644 index 0000000..9b13cde --- /dev/null +++ b/extdbms/lib/Entities/HistoryEntity.php @@ -0,0 +1,13 @@ +getName(); + } + //공통부분 + public function getId(): string + { + return $this->id; + } + public function getPassword(): string + { + return $this->pass; + } + public function getName(): string + { + return $this->name; + } + public function getRole(): string + { + return $this->role; + } +} //Class diff --git a/extdbms/lib/Entities/ServiceEntity.php b/extdbms/lib/Entities/ServiceEntity.php index 78cb02a..4b1b758 100644 --- a/extdbms/lib/Entities/ServiceEntity.php +++ b/extdbms/lib/Entities/ServiceEntity.php @@ -10,4 +10,17 @@ class ServiceEntity extends Entity { parent::__construct($datas); } // + + public function getServiceCode(): mixed + { + return $this->service_code; + } + public function getMemberCode(): mixed + { + return $this->service_manager; + } + public function getClientCode(): mixed + { + return $this->client_code; + } } //Class diff --git a/extdbms/lib/Entities/VPCEntity.php b/extdbms/lib/Entities/VPCEntity.php new file mode 100644 index 0000000..d27d549 --- /dev/null +++ b/extdbms/lib/Entities/VPCEntity.php @@ -0,0 +1,13 @@ +getRandomString($length, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?"); + } + + final function truncateString(string $text, int $maxLength = 10): string + { + if (mb_strlen($text, 'UTF-8') > $maxLength) { + return mb_substr($text, 0, $maxLength, 'UTF-8') . "..."; + } + return $text; + } + + // byte값을 알아보기 쉽게 변환 + final public function getSizeForHuman($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를 가져오기 위한것 + final public function getClientIP($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; + } + + final public function isDomain(string $domain): bool + { + $pattern_validation = '/((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])*/'; + return preg_match($pattern_validation, $domain); + } + + final public function isIPAddress(string $ip, $type = false): bool + { + switch ($type) { + case 'ipv4': + $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); + break; + case 'ipv6': + $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); + break; + case 'all': + $result = filter_var($ip, FILTER_VALIDATE_IP); + break; + default: + $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE); + break; + } + return $result; + } + + final public function isHost(string $host): bool + { + $pattern_validation = '/[a-zA-Z0-9\.\/\?\:@\*\-_=#]/'; + return preg_match($pattern_validation, $host); + } + + // (EX:192.168.1.0 -> 192.168.001.000) + final public function convertIPV4toCIDR($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) + final public function convertCIDRtoIPV4($ipv4) + { + $temps = explode(".", $ipv4); + return sprintf("%d.%d.%d.%d", $temps[0], $temps[1], $temps[2], $temps[3]); + } + + final public function isMobile() + { + // 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; + } +} //Class diff --git a/extdbms/lib/Helpers/ServiceHelper.php b/extdbms/lib/Helpers/ServiceHelper.php new file mode 100644 index 0000000..2433767 --- /dev/null +++ b/extdbms/lib/Helpers/ServiceHelper.php @@ -0,0 +1,11 @@ +getResult()); + } // + final public function getEntitys(): array + { + $entitys = []; + foreach ($this->getResults() as $result) { + $entitys[] = new Entity($result); + } + return $entitys; + } // +} //Class diff --git a/extdbms/lib/Models/KCSModel.php b/extdbms/lib/Models/KCSModel.php new file mode 100644 index 0000000..73bf404 --- /dev/null +++ b/extdbms/lib/Models/KCSModel.php @@ -0,0 +1,42 @@ +getResult()); + } // + final public function getEntitys(): array + { + $entitys = []; + foreach ($this->getResults() as $result) { + $entitys[] = new Entity($result); + } + return $entitys; + } // +} //Class diff --git a/extdbms/lib/Models/MemberModel.php b/extdbms/lib/Models/MemberModel.php new file mode 100644 index 0000000..add886b --- /dev/null +++ b/extdbms/lib/Models/MemberModel.php @@ -0,0 +1,42 @@ +getResult()); + } // + final public function getEntitys(): array + { + $entitys = []; + foreach ($this->getResults() as $result) { + $entitys[] = new Entity($result); + } + return $entitys; + } // +} //Class diff --git a/extdbms/lib/Models/VPCModel.php b/extdbms/lib/Models/VPCModel.php new file mode 100644 index 0000000..d5010d4 --- /dev/null +++ b/extdbms/lib/Models/VPCModel.php @@ -0,0 +1,42 @@ +getResult()); + } // + final public function getEntitys(): array + { + $entitys = []; + foreach ($this->getResults() as $result) { + $entitys[] = new Entity($result); + } + return $entitys; + } // +} //Class diff --git a/extdbms/lib/Services/AddDbService.php b/extdbms/lib/Services/AddDbService.php new file mode 100644 index 0000000..99947cc --- /dev/null +++ b/extdbms/lib/Services/AddDbService.php @@ -0,0 +1,43 @@ +getClassName(); + } + protected function getModel(): Model + { + if ($this->_model === null) { + $this->_model = new Model(); + $this->_model->setDebug(true); + } + return $this->_model; + } + + public function getServiceCodesByCode(string $adddb_code): array + { + //AddDBService에서 해당코드의(닷디펜더,딥파인더 등) Service_Code를 가져와서 배열에 저장 + $this->getModel()->select('DISTINCT(service_code) AS service_code'); + $this->getModel()->where('AddDB_code', $adddb_code); + $service_codes = []; + foreach ($this->getModel()->getEntitys() as $entity) { + $service_codes = $entity->getServiceCode(); + } + return $service_codes; + } +} diff --git a/extdbms/lib/Services/ClientService.php b/extdbms/lib/Services/ClientService.php new file mode 100644 index 0000000..1c92b0f --- /dev/null +++ b/extdbms/lib/Services/ClientService.php @@ -0,0 +1,36 @@ +getClassName(); + } + protected function getModel(): Model + { + if ($this->_model === null) { + $this->_model = new Model(); + $this->_model->setDebug(true); + } + return $this->_model; + } + public function getEntitByCode(string $code): Entity + { + $this->getModel()->where("Client_Code", $code); + return $this->getModel()->getEntity(); + } +} diff --git a/extdbms/lib/Services/CommonService.php b/extdbms/lib/Services/CommonService.php index e4d8abc..a26b6d5 100644 --- a/extdbms/lib/Services/CommonService.php +++ b/extdbms/lib/Services/CommonService.php @@ -2,12 +2,14 @@ namespace lib\Services; -use lib\Core\Service as Service; +use lib\Core\Service as Core; +use lib\Core\Model as Model; -abstract class CommonService extends Service +abstract class CommonService extends Core { public function __construct() { parent::__construct(); } // + abstract protected function getModel(): Model; } //Class diff --git a/extdbms/lib/Services/HistoryService.php b/extdbms/lib/Services/HistoryService.php new file mode 100644 index 0000000..64f114d --- /dev/null +++ b/extdbms/lib/Services/HistoryService.php @@ -0,0 +1,38 @@ +getClassName(); + } + protected function getModel(): Model + { + if ($this->_model === null) { + $this->_model = new Model(); + $this->_model->setDebug(true); + } + return $this->_model; + } + + public function getNews(int $limit = 5): array + { + $this->getModel()->orderBy($this->getModel()->getPKField(), 'DESC'); + $this->getModel()->limit($limit); + return $this->getModel()->getEntitys(); + } +} diff --git a/extdbms/lib/Services/KCSService.php b/extdbms/lib/Services/KCSService.php new file mode 100644 index 0000000..6ff2ce7 --- /dev/null +++ b/extdbms/lib/Services/KCSService.php @@ -0,0 +1,39 @@ +getClassName(); + } + protected function getModel(): Model + { + if ($this->_model === null) { + $this->_model = new Model(); + $this->_model->setDebug(true); + } + return $this->_model; + } + + public function getCountByServiceCode(string $service_code): int + { + $this->getModel()->where("service_code", $service_code); + $count = $this->getModel()->countAllResults(); + // echo "
" . $this->getModel()->getLastQuery(); + return $count; + } +} diff --git a/extdbms/lib/Services/MemberService.php b/extdbms/lib/Services/MemberService.php new file mode 100644 index 0000000..b229bf4 --- /dev/null +++ b/extdbms/lib/Services/MemberService.php @@ -0,0 +1,36 @@ +getClassName(); + } + public function getModel(): Model + { + if ($this->_model === null) { + $this->_model = new Model(); + $this->_model->setDebug(true); + } + return $this->_model; + } + public function getEntitById(string $id): Entity + { + $this->getModel()->where($this->getModel()->getPKField(), $id); + return $this->getModel()->getEntity(); + } +} diff --git a/extdbms/lib/Services/ServiceService.php b/extdbms/lib/Services/ServiceService.php index b18e052..23d2f5b 100644 --- a/extdbms/lib/Services/ServiceService.php +++ b/extdbms/lib/Services/ServiceService.php @@ -2,15 +2,15 @@ namespace lib\Services; -use lib\Entities\ServiceEntity; +use lib\Entities\ServiceEntity as Entity; use lib\Models\AdddbModel; use lib\Models\ClientModel; -use lib\Models\ServiceModel; +use lib\Models\ServiceModel as Model; class ServiceService extends CommonService { private ?ClientModel $_clientModel = null; - private ?ServiceModel $_model = null; + private ?Model $_model = null; private ?AdddbModel $_adddbModel = null; public function __construct() { @@ -24,10 +24,10 @@ class ServiceService extends CommonService { return $this->getClassName(); } - public function getModel(): ServiceModel + public function getModel(): Model { if ($this->_model === null) { - $this->_model = new ServiceModel(); + $this->_model = new Model(); $this->_model->setDebug(true); } return $this->_model; @@ -90,14 +90,8 @@ class ServiceService extends CommonService } //foreach return $temps; } - final public function getExtras(string $addDB_code): mixed + final public function getExtras(array $service_codes): mixed { - $this->getAdddbModel()->select('DISTINCT(service_code) AS service_code'); - $this->getAdddbModel()->where('addDB_code', $addDB_code); - $service_codes = []; - foreach ($this->getAdddbModel()->getEntitys() as $entity) { - $service_codes = $entity->getServiceCode(); - } // 공백 값 제거 $service_codes = array_filter($service_codes, function ($value) { return !empty(trim($value)); // 공백 제거 후 비어있지 않은 값만 필터링 @@ -120,14 +114,14 @@ class ServiceService extends CommonService return $this->getModel()->getEntitys(); } - public function getNews(int $limit = 5): array + public function getNews(int $limit): array { - $this->getModel()->orderBy($this->getModel()->getPKField(), direction: 'DESC'); + $this->getModel()->orderBy($this->getModel()->getPKField(), 'DESC'); $this->getModel()->limit($limit); return $this->getModel()->getEntitys(); } - public function getServiceByServiceCode(string $service_code): ServiceEntity|null + public function getServiceByServiceCode(string $service_code): Entity|null { $this->getModel()->where("service_code", $service_code); return $this->getModel()->getEntity(); diff --git a/extdbms/lib/Services/VPCService.php b/extdbms/lib/Services/VPCService.php new file mode 100644 index 0000000..7393255 --- /dev/null +++ b/extdbms/lib/Services/VPCService.php @@ -0,0 +1,39 @@ +getClassName(); + } + public function getModel(): VPCModel + { + if ($this->_model === null) { + $this->_model = new VPCModel(); + $this->_model->setDebug(true); + } + return $this->_model; + } + + public function getCountByServiceCode(string $service_code): int + { + $this->getModel()->where("service_code", $service_code); + $count = $this->getModel()->countAllResults(); + // echo "
" . $this->getModel()->getLastQuery(); + return $count; + } +} diff --git a/extdbms/lib/View/depositbillpaper.php b/extdbms/lib/View/billpaper.php similarity index 100% rename from extdbms/lib/View/depositbillpaper.php rename to extdbms/lib/View/billpaper.php diff --git a/extdbms/lib/View/newservices.php b/extdbms/lib/View/newservices.php new file mode 100644 index 0000000..8726ae4 --- /dev/null +++ b/extdbms/lib/View/newservices.php @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + entitys as $entity): ?> + entity = $entity ?> + + + + + + + + + + + + + +
서비스코드업체명구분장비번호스위치정보IP정보CS등록자비고
service_code ?> + clients[$entity->getServiceCode()]->getTitle() ?> + service_line ?> + service_code ?> + + service_sw ?> + service_ip ?> + vpcs[$entity->getServiceCode()] ?> + / + kcss[$entity->getServiceCode()] ?> + users[$entity->getServiceCode()] ? "" : $this->users[$entity->getServiceCode()]->getTitle() ?> + helper->truncateString($entity->service_note, 20) ?> +
\ No newline at end of file diff --git a/extdbms/total_counting.php b/extdbms/total_counting.php index 3e86912..ce6bfa8 100644 --- a/extdbms/total_counting.php +++ b/extdbms/total_counting.php @@ -1,11 +1,20 @@ load(); + +require_once "lib/Configs/Config.php"; try { - $control = new DashboardController(); - return $control->mainPage(); + $control = isset($argv[1]) ? $argv[1] : "lib\\Controllers\\SiteController"; + $control = new $control(); + $function = isset($argv[2]) ? $argv[2] : "totalcount"; + $key_name = "sitekey"; + $sitekey = array_key_exists($key_name, $_GET) ? $_GET[$key_name] : false; + $sitekey = isset($arvg[3]) ? $argv[1] : "dbms.prime-idc.jp"; + return $control->$function($sitekey); } catch (\Exception $e) { - die($e->getMessage()); + echo $e->getMessage(); }