diff --git a/extdbms/index.php b/extdbms/index.php index 119a154..781ac05 100644 --- a/extdbms/index.php +++ b/extdbms/index.php @@ -1,19 +1,22 @@ load(); // 테스트 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; - $route = new Route(trim($url, '/')); - return $route->run(); + if (!$url) { + $url = isset($argv[1]) ? $argv[1] : false; + } + $app = new App($url); + return $app->run(); } 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..0911b53 --- /dev/null +++ b/extdbms/lib/Configs/App.php @@ -0,0 +1,26 @@ + "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/Constant.php b/extdbms/lib/Configs/Constant.php new file mode 100644 index 0000000..b62fb39 --- /dev/null +++ b/extdbms/lib/Configs/Constant.php @@ -0,0 +1,48 @@ + [ + "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/Configs/Route.php b/extdbms/lib/Configs/Route.php deleted file mode 100644 index 1cab044..0000000 --- a/extdbms/lib/Configs/Route.php +++ /dev/null @@ -1,35 +0,0 @@ -_clientModel === null) { - $this->_clientModel = new ClientModel(); - } - return $this->_clientModel; - } - final protected function getServiceModel(): ServiceModel - { - if ($this->_serviceModel === null) { - $this->_serviceModel = new ServiceModel(); - } - return $this->_serviceModel; - } - - final public function getSiteInfo(): array - { - $domain = array_key_exists("HTTP_HOST", $_SERVER) ? $_SERVER["HTTP_HOST"] : false; - switch ($domain) { - case 'dbms.prime-idc.jp': - $datas = [ - "id" => "PRIMEIDC", - "domain" => "dbms.prime-idc.jp", - "name" => "PrimeIDC", - "email" => "primeidc.jp@gmail.com", - "banks" => [ - ["id" => "331301-04-217387", "name" => '국민은행', "owner" => "주)듀나미스"] - ], - ]; - break; - case "dbms.itsolution-idc.jp": - $datas = [ - "id" => "ITSOLUTION", - "domain" => "dbms.itsolution-idc.jp", - "name" => "Itsolution", - "email" => "support@itsoution-idc.jp", - "banks" => [ - ["id" => "9002-1932-1654-1", "name" => '새마을금고', "owner" => "주식회사 르호봇"], - ["id" => "351-0995-6751-73", "name" => '농협', "owner" => "주식회사 르호봇"], - ], - ]; - break; - case 'dbms.gdidc.jp': - $datas = [ - "id" => "GDIDC", - "domain" => "dbms.gdidc.jp", - "name" => "GDIDC", - "email" => "support@gdidc.jp", - "banks" => [ - ["id" => "1005-204-100758", "name" => '우리은행', "owner" => " (주)브엘라해로이"], - ], - ]; - break; - default: - $datas = []; - break; - } - return $datas; - } } //Class diff --git a/extdbms/lib/Controllers/DBMS/BaseController.php b/extdbms/lib/Controllers/DBMS/BaseController.php new file mode 100644 index 0000000..12815da --- /dev/null +++ b/extdbms/lib/Controllers/DBMS/BaseController.php @@ -0,0 +1,24 @@ +getView()->setPath('dbms'); + } // + + final public function getService(): ServiceService + { + if ($this->_service === null) { + $this->_service = new ServiceService(); + } + return $this->_service; + } +} //Class diff --git a/extdbms/lib/Controllers/DBMS/CouponController.php b/extdbms/lib/Controllers/DBMS/CouponController.php new file mode 100644 index 0000000..e058a8b --- /dev/null +++ b/extdbms/lib/Controllers/DBMS/CouponController.php @@ -0,0 +1,20 @@ +getView()->setPath('coupon'); + } // + + //Dashboard , default_alert.php + //CLI 접속방법 : php index.php SiteController/dashboard + //WEB 접속방법 : http://localhost/SiteController/dashboard + public function index() + { + return $this->render(__FUNCTION__); + } +} //Class diff --git a/extdbms/lib/Controllers/SiteController.php b/extdbms/lib/Controllers/DBMS/DashboardController.php similarity index 62% rename from extdbms/lib/Controllers/SiteController.php rename to extdbms/lib/Controllers/DBMS/DashboardController.php index 6b43cb2..fbd8a60 100644 --- a/extdbms/lib/Controllers/SiteController.php +++ b/extdbms/lib/Controllers/DBMS/DashboardController.php @@ -1,39 +1,80 @@ helper = new ServiceHelper(); + $this->getView()->setPath('dashboard'); } // - public function getService(): ServiceService + //Dashboard , default_alert.php + //CLI 접속방법 : php index.php SiteController/dashboard + //WEB 접속방법 : http://localhost/SiteController/dashboard + public function topboard() { - if ($this->_service === null) { - $this->_service = new ServiceService(); - } - return $this->_service; + // 최근7일 신규서버수 + //예외,service_line = "test","substitution" + $excepts = ["test", "substitution"]; + $this->day = intval($_ENV['SITE_DASHBOARD_DAY'] ?? $_SERVER['SITE_DASHBOARD_DAY'] ?? 7); + $this->newServers = $this->getService()->getNewServerCount($this->day, $excepts); + // 금일기준 미납서버수 + //예외,service_line = "test","substitution",C012:게임윙,C116:WinIDC,C219:IDC-JP + $excepts = ["test", "substitution", 'C116', 'C012', 'C219']; + $this->unPayments = $this->getService()->getUnPaymentCount($excepts); + return $this->render(__FUNCTION__); } + //서비스카운팅 , total_counting.php + //CLI 접속방법 : php index.php site/totalcount/sitekey/dbms.prime-idc.jp + //WEB 접속방법 : http://localhost/site/totalcount/sitekey/dbms.prime-idc.jp + public function totalcount(mixed $sitekey = null) + { + if ($sitekey === null) { + $sitekey = $this->getSegments('sitekey'); + if ($sitekey === null) { + throw new \Exception("sitekey 값이 정의되지 않았습니다."); + } + } + //사이트 정보 가져오기 + $this->siteInfo = DBMS_SITEINFOS[$sitekey]; + $this->totalcount = $this->getService()->getTotalCount($this->siteInfo); + $summary = array(); + foreach ($this->siteInfo['totalcount_types'] as $type) { + $summary[$type] = array("Tokyo" => 0, "Chiba" => 0); + } + foreach ($this->totalcount as $company => $service) { + $summary[$company] = array("Tokyo" => 0, "Chiba" => 0); + foreach ($service as $name => $location) { + $summary[$company]['Tokyo'] += $location['Tokyo']; + $summary[$name]['Tokyo'] += $location['Tokyo']; + $summary[$company]['Chiba'] += $location['Chiba']; + $summary[$name]['Chiba'] += $location['Chiba']; + } + } + $total = array("Tokyo" => 0, "Chiba" => 0); + foreach ($this->siteInfo['totalcount_types'] as $type) { + $total['Tokyo'] += $summary[$type]['Tokyo']; + $total['Chiba'] += $summary[$type]['Chiba']; + } + $this->summary = $summary; + $this->total = $total; + return $this->render(__FUNCTION__); + } public function getMemberService(): MemberService { if ($this->_memberService === null) { @@ -71,77 +112,11 @@ class SiteController extends CommonController } 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일 신규서버수 - //예외,service_line = "test","substitution" - $excepts = ["test", "substitution"]; - $this->day = intval($_ENV['SITE_DASHBOARD_DAY'] ?? $_SERVER['SITE_DASHBOARD_DAY'] ?? 7); - $this->newServers = $this->getService()->getNewServerCount($this->day, $excepts); - // 금일기준 미납서버수 - //예외,service_line = "test","substitution",C012:게임윙,C116:WinIDC,C219:IDC-JP - $excepts = ["test", "substitution", 'C116', 'C012', 'C219']; - $this->unPayments = $this->getService()->getUnPaymentCount($excepts); - return $this->render(__FUNCTION__); - } - - //서비스카운팅 , total_counting.php - //CLI 접속방법 : php index.php site/totalcount/sitekey/dbms.prime-idc.jp - //WEB 접속방법 : http://localhost/site/totalcount/sitekey/dbms.prime-idc.jp - public function totalcount(mixed $sitekey = null): string - { - if ($sitekey === null) { - $sitekey = $this->getSegments('sitekey'); - if ($sitekey === null) { - throw new \Exception("sitekey 값이 정의되지 않았습니다."); - } - } - - $this->siteInfo = $this->getConfig()->getSiteInfo($sitekey); - if (!$this->siteInfo) { - throw new \Exception("[{$sitekey}] 값에 해당하는 사이트정보가 존재하지 않습니다."); - } - $this->totalcount = $this->getService()->getTotalCount($this->siteInfo); - // echo $sitekey; - // dd($this->siteInfo); - $summary = array(); - foreach ($this->siteInfo['totalcount_types'] as $type) { - $summary[$type] = array("Tokyo" => 0, "Chiba" => 0); - } - foreach ($this->totalcount as $company => $service) { - $summary[$company] = array("Tokyo" => 0, "Chiba" => 0); - foreach ($service as $name => $location) { - $summary[$company]['Tokyo'] += $location['Tokyo']; - $summary[$name]['Tokyo'] += $location['Tokyo']; - $summary[$company]['Chiba'] += $location['Chiba']; - $summary[$name]['Chiba'] += $location['Chiba']; - } - } - $total = array("Tokyo" => 0, "Chiba" => 0); - foreach ($this->siteInfo['totalcount_types'] as $type) { - $total['Tokyo'] += $summary[$type]['Tokyo']; - $total['Chiba'] += $summary[$type]['Chiba']; - } - $this->summary = $summary; - $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(mixed $limit = 5): string + public function latest_service(mixed $limit = 5) { //신규서버정보 $this->limit = intval($limit); @@ -175,7 +150,7 @@ class SiteController extends CommonController } //CLI 접속방법 : php index.php SiteController/newhistorys/limit/5 //WEB 접속방법 : http://localhost/SiteController/newhistorys/limit/5 - public function newhistorys(mixed $limit = 5): string + public function latest_history(mixed $limit = 5): string { //신규서버정보 $this->limit = intval($limit); @@ -199,57 +174,4 @@ class SiteController extends CommonController $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(mixed $sitekey = null, mixed $client_code = null): string - { - if ($sitekey === null) { - $sitekey = $this->getSegments('sitekey'); - if ($sitekey === null) { - throw new \Exception("sitekey 값이 정의되지 않았습니다."); - } - } - if ($client_code === null) { - $client_code = $this->getSegments('client_code'); - if ($client_code === null) { - throw new \Exception("client_code 값이 정의되지 않았습니다."); - } - } - $this->siteInfo = $this->getConfig()->getSiteInfo($sitekey); - if (!$this->siteInfo) { - throw new \Exception("[{$sitekey}] 값에 해당하는 사이트정보가 존재하지 않습니다."); - } - $this->client = $this->getClientService()->getEntitByCode($client_code); - if (!$this->client) { - throw new \Exception("[{$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(mixed $adddb_code = null): string - { - if ($adddb_code === null) { - $adddb_code = $this->getSegments('adddb_code'); - if ($adddb_code === null) { - throw new \Exception("adddb_code 값이 정의되지 않았습니다."); - } - } - //segment의 값이 한글인경우 urldecode가 필요 - $adddb_code = urldecode($adddb_code); - $service_codes = $this->getAddDbService()->getServiceCodesByCode($adddb_code); - if (!count($service_codes)) { - throw new \Exception("[{$adddb_code}] 값에 해당하는 부가서비스정보가 존재하지 않습니다."); - } - $clients = []; - $services = $this->getService()->getExtras($service_codes); - foreach ($services as $service) { - $clients[$service->getPK()] = $this->getClientService()->getEntitByCode($service->getClientCode()); - } - $this->services = $services; - $this->clients = $clients; - return $this->render(__FUNCTION__); - } } //Class diff --git a/extdbms/lib/Controllers/DBMS/NavigatorController.php b/extdbms/lib/Controllers/DBMS/NavigatorController.php new file mode 100644 index 0000000..e823a32 --- /dev/null +++ b/extdbms/lib/Controllers/DBMS/NavigatorController.php @@ -0,0 +1,41 @@ +getView()->setPath('navigator'); + } // + public function getClientService(): ClientService + { + if ($this->_clientService === null) { + $this->_clientService = new ClientService(); + } + return $this->_clientService; + } + + //부가서비스 : 닷디펜더,딥파인더 등, 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 ipseaerch(mixed $ip = null): string + { + $clients = []; + $services = $this->getService()->getServicesByIP($ip); + foreach ($services as $service) { + $clients[$service->getPK()] = $this->getClientService()->getEntitByCode($service->getClientCode()); + } + $this->services = $services; + $this->clients = $clients; + return $this->render(__FUNCTION__); + } +} //Class diff --git a/extdbms/lib/Controllers/DBMS/PaymentController.php b/extdbms/lib/Controllers/DBMS/PaymentController.php new file mode 100644 index 0000000..9755450 --- /dev/null +++ b/extdbms/lib/Controllers/DBMS/PaymentController.php @@ -0,0 +1,52 @@ +getView()->setPath('service'); + } // + public function getClientService(): ClientService + { + if ($this->_clientService === null) { + $this->_clientService = new ClientService(); + } + return $this->_clientService; + } + + //부가서비스 : 닷디펜더,딥파인더 등, 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 billpaper(mixed $sitekey = null, mixed $client_code = null): string + { + if ($sitekey === null) { + $sitekey = $this->getSegments('sitekey'); + if ($sitekey === null) { + throw new \Exception("sitekey 값이 정의되지 않았습니다."); + } + } + if ($client_code === null) { + $client_code = $this->getSegments('client_code'); + if ($client_code === null) { + throw new \Exception("client_code 값이 정의되지 않았습니다."); + } + } + $this->siteInfo = DBMS_SITEINFOS[$sitekey]; + if (!$this->siteInfo) { + throw new \Exception("[{$sitekey}] 값에 해당하는 사이트정보가 존재하지 않습니다."); + } + $this->client = $this->getClientService()->getEntitByCode($client_code); + if (!$this->client) { + throw new \Exception("[{$client_code}] 값에 해당하는 고객정보가 존재하지 않습니다."); + } + return $this->render(__FUNCTION__); + } +} //Class diff --git a/extdbms/lib/Controllers/DBMS/ServiceController.php b/extdbms/lib/Controllers/DBMS/ServiceController.php new file mode 100644 index 0000000..3256665 --- /dev/null +++ b/extdbms/lib/Controllers/DBMS/ServiceController.php @@ -0,0 +1,60 @@ +getView()->setPath('service'); + } // + public function getClientService(): ClientService + { + if ($this->_clientService === null) { + $this->_clientService = new ClientService(); + } + return $this->_clientService; + } + public function getAddDbService(): AddDbService + { + if ($this->_addDbService === null) { + $this->_addDbService = new AddDbService(); + } + return $this->_addDbService; + } + + //부가서비스 : 닷디펜더,딥파인더 등, 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 extra(mixed $adddb_code = null): string + { + if ($adddb_code === null) { + $adddb_code = $this->getSegments('adddb_code'); + if ($adddb_code === null) { + throw new \Exception("adddb_code 값이 정의되지 않았습니다."); + } + } + //segment의 값이 한글인경우 urldecode가 필요 + $adddb_code = urldecode($adddb_code); + $service_codes = $this->getAddDbService()->getServiceCodesByCode($adddb_code); + if (!count($service_codes)) { + throw new \Exception("[{$adddb_code}] 값에 해당하는 부가서비스정보가 존재하지 않습니다."); + } + $clients = []; + $services = $this->getService()->geServicesBytExtras($service_codes); + foreach ($services as $service) { + $clients[$service->getPK()] = $this->getClientService()->getEntitByCode($service->getClientCode()); + } + $this->services = $services; + $this->clients = $clients; + return $this->render(__FUNCTION__); + } +} //Class diff --git a/extdbms/lib/Core/Route.php b/extdbms/lib/Core/App.php similarity index 72% rename from extdbms/lib/Core/Route.php rename to extdbms/lib/Core/App.php index 147421d..ddd92bf 100644 --- a/extdbms/lib/Core/Route.php +++ b/extdbms/lib/Core/App.php @@ -4,9 +4,10 @@ namespace lib\Core; use lib\Core\Controller; -abstract class Route +abstract class App { private string $_url = ""; + private string $_module = ""; protected ?Controller $_controller; protected string $_method = ""; protected array $_segments = []; @@ -24,29 +25,49 @@ abstract class Route { $path = parse_url($this->getURL(), PHP_URL_PATH); $arguments = explode('/', trim($path, '/')); - - // 컨트롤러와 메서드를 설정 + // var_dump($arguments); + //컨트롤러와 메서드를 설정 + $this->setModule($arguments); $this->setController($arguments); $this->setMethod($arguments); - // 남은 세그먼트를 파라미터로 설정 $this->setSegments($arguments); } + protected function routeModule(string $route): string + { + return $route; + } + protected function routeController(string $route): string + { + return ucfirst($route . 'Controller'); + } + protected function routeMethod(string $route): string + { + return $route; + } + final protected function getModule(): string + { + return $this->_module; + } + private function setModule(array &$segments): void + { + $route = count($segments) ? $segments[0] : ''; + $route = $this->routeModule($route); + $module = "lib" . DIRECTORY_SEPARATOR . "Controllers" . DIRECTORY_SEPARATOR . $route; + if (is_dir(ROOT_PATH . DIRECTORY_SEPARATOR . $module)) { + array_shift($segments); + $this->_module = $module . DIRECTORY_SEPARATOR; + } + } final protected function getController(): Controller { return $this->_controller; } - - protected function routeController(string $route): string - { - return $route; - } private function setController(array &$segments): void { - $route = $segments[0] ? $segments[0] : 'HomeController'; - // echo $route; - // exit; - $controller = "lib\\Controllers\\" . ucfirst($this->routeController($route)); + $route = count($segments) ? $segments[0] : 'Home'; + $route = $this->routeController($route); + $controller = $this->getModule() . $route; if (class_exists($controller)) { $this->_controller = new $controller(); } else { @@ -58,20 +79,20 @@ abstract class Route { return $this->_method; } - protected function routeMethod(string $route): string - { - return $route; - } final protected function setMethod(array &$segments): void { //$segments[0]인이유는 setController에서 $segments를 array_shift했기때문 $route = count($segments) ? $segments[0] : 'index'; - // echo $route; - // exit; - $this->_method = strtolower($this->routeMethod($route)); - array_shift($segments); + // echo "METHOD:{$route}\n"; + $method = $this->routeMethod($route); + // echo get_class($this->getController()) . ",METHOD2:{$method}\n"; + if (method_exists($this->getController(), $method)) { + array_shift($segments); + } else { + throw new \Exception("해당 함수[{$method}]를 " . get_class($this->getController()) . "에서 찾을수 없습니다."); + } + $this->_method = $method; } - final public function getSegments(): array { return $this->_segments; @@ -91,22 +112,14 @@ abstract class Route { $controller = $this->getController(); $method = $this->getMethod(); - - if (!method_exists($controller, $method)) { - throw new \Exception("해당 함수[{$method}]를 " . get_class($this->_controller) . "에서 찾을수 없습니다."); - } - // 컨트롤러에 세그먼트 전달 $controller->setSegments($this->getSegments()); - // 키/값 형태로 세그먼트 처리 $params = []; $segments = $this->getSegments(); - // 메서드의 매개변수 정보 가져오기 $reflectionMethod = new \ReflectionMethod($controller, $method); $parameters = $reflectionMethod->getParameters(); - if (count($parameters) > 0) { // 매개변수가 존재하면 URL 세그먼트를 순서대로 매개변수에 매핑 foreach ($parameters as $i => $param) { diff --git a/extdbms/lib/Core/Config.php b/extdbms/lib/Core/Config.php deleted file mode 100644 index 268c603..0000000 --- a/extdbms/lib/Core/Config.php +++ /dev/null @@ -1,27 +0,0 @@ -_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/Controller.php b/extdbms/lib/Core/Controller.php index 05461b6..85f6dfe 100644 --- a/extdbms/lib/Core/Controller.php +++ b/extdbms/lib/Core/Controller.php @@ -2,22 +2,29 @@ namespace lib\Core; -use lib\Configs\Config; +require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Configs' . DIRECTORY_SEPARATOR . 'Constant.php'; + use lib\Configs\View; abstract class Controller { - private ?Config $_config = null; private ?View $_view = null; private $_segments = []; protected function __construct() { - $this->_config = new Config(); $this->_view = new View(); } // - final public function getConfig(): Config + final public function getView(): View { - return $this->_config; + return $this->_view; + } + final public function __get($name) + { + return $this->getView()->$name; + } + final public function __set($name, $value) + { + $this->getView()->$name = $value; } final public function setSegments(array $segments) { @@ -30,16 +37,8 @@ abstract class Controller } return array_key_exists($key, $this->_segments) ? $this->_segments[$key] : null; } - final public function __get($name) + public function render(string $path) { - return $this->_view->$name; - } - final public function __set($name, $value) - { - $this->_view->$name = $value; - } - public function render($file) - { - return $this->_view->render($file); + return $this->getView()->render($path); } } //Class diff --git a/extdbms/lib/Core/Entity.php b/extdbms/lib/Core/Entity.php index 35b7fa6..3dc68ec 100644 --- a/extdbms/lib/Core/Entity.php +++ b/extdbms/lib/Core/Entity.php @@ -5,20 +5,10 @@ namespace lib\Core; abstract class Entity { private $_values = []; - private $_debug = false; protected function __construct($datas) { $this->_values = $datas; } // - final public function setDebug($debug) - { - $this->_debug = $debug; - } - final public function getDebug() - { - return $this->_debug; - } - final public function __get($name) { return $this->_values[$name]; diff --git a/extdbms/lib/Core/View.php b/extdbms/lib/Core/View.php index 127348f..0800ca3 100644 --- a/extdbms/lib/Core/View.php +++ b/extdbms/lib/Core/View.php @@ -4,18 +4,9 @@ namespace lib\Core; abstract class View { + private $_paths = ["lib" . DIRECTORY_SEPARATOR . "Views"]; private $_values = []; - private $_debug = false; - protected function __construct() {} // - final public function setDebug($debug) - { - $this->_debug = $debug; - } - final public function getDebug() - { - return $this->_debug; - } - + protected function __construct() {} final public function __get($name) { return $this->_values[$name]; @@ -24,16 +15,27 @@ abstract class View { $this->_values[$name] = $value; } - + final public function setPath(string $path): void + { + $this->_paths[] = $path; + } + final public function setPaths(array $paths): void + { + $this->_paths[] = $paths; + } + final public function getPath(): array + { + return $this->_paths; + } public function render($file) { - $viewFileName = sprintf("lib/View/%s", $file); - $fullPathFile = "./" . $viewFileName . '.php'; + $path = count($this->getPath()) ? DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $this->getPath()) : ""; + $fullPathFile = ROOT_PATH . $path . DIRECTORY_SEPARATOR . $file . ".php"; if (!file_exists($fullPathFile)) { throw new \Exception(sprintf("%s 파일이 존재하지 않습니다.", $fullPathFile)); } ob_start(); - include $fullPathFile; + require_once $fullPathFile; return ob_end_flush(); } } //Class diff --git a/extdbms/lib/Services/ServiceService.php b/extdbms/lib/Services/ServiceService.php index de8dac5..eeb8332 100644 --- a/extdbms/lib/Services/ServiceService.php +++ b/extdbms/lib/Services/ServiceService.php @@ -88,7 +88,7 @@ class ServiceService extends CommonService } //foreach return $temps; } - final public function getExtras(array $service_codes): mixed + final public function geServicesBytExtras(array $service_codes): mixed { // 공백 값 제거 $service_codes = array_filter($service_codes, function ($value) { @@ -113,6 +113,16 @@ class ServiceService extends CommonService return $this->getModel()->getEntitys(); } + final public function getServicesByIP(string $ip): mixed + { + // 공백 값 제거 + $ip = trim($ip); + // $this->getModel()->select("clientdb.*,{$this->getModel()->getTable()}.*"); + // $this->getModel()->join('clientdb', "{$this->getModel()->getTable()}.client_code=clientdb.Client_Code"); + $this->getModel()->where('service_ip', $ip); + return $this->getModel()->getEntitys(); + } + public function getNews(int $limit): array { $this->getModel()->orderBy($this->getModel()->getPKField(), 'DESC'); diff --git a/extdbms/lib/View/newhistorys.php b/extdbms/lib/Views/dbms/dashboard/latest_history.php similarity index 100% rename from extdbms/lib/View/newhistorys.php rename to extdbms/lib/Views/dbms/dashboard/latest_history.php diff --git a/extdbms/lib/View/newservices.php b/extdbms/lib/Views/dbms/dashboard/latest_service.php similarity index 100% rename from extdbms/lib/View/newservices.php rename to extdbms/lib/Views/dbms/dashboard/latest_service.php diff --git a/extdbms/lib/View/dashboard.php b/extdbms/lib/Views/dbms/dashboard/topboard.php similarity index 100% rename from extdbms/lib/View/dashboard.php rename to extdbms/lib/Views/dbms/dashboard/topboard.php diff --git a/extdbms/lib/View/totalcount.php b/extdbms/lib/Views/dbms/dashboard/totalcount.php similarity index 100% rename from extdbms/lib/View/totalcount.php rename to extdbms/lib/Views/dbms/dashboard/totalcount.php diff --git a/extdbms/lib/Views/dbms/navigator/ipsearch.php b/extdbms/lib/Views/dbms/navigator/ipsearch.php new file mode 100644 index 0000000..00bcc65 --- /dev/null +++ b/extdbms/lib/Views/dbms/navigator/ipsearch.php @@ -0,0 +1,120 @@ + +
| CODE | +NAME | +SERVER | +IP | +SW | +NOTE | +TEL | +|
|---|---|---|---|---|---|---|---|
| = $service->getClientCode() ?> | += $this->clients[$service->getPK()]->getTitle() ?> | += $service->getServerCode() ?> | += $service->service_ip ?> | += $service->service_os ?> | += $service->service_sw ?> | += $this->clients[$service->getPK()]->Phone1 ?> | += $this->clients[$service->getPK()]->Email1 ?> | +