dbms_primeidc_init...1

This commit is contained in:
최준흠 2025-04-02 16:37:26 +09:00
parent 04287c3fad
commit 0182c61b21
25 changed files with 545 additions and 410 deletions

View File

@ -1,19 +1,22 @@
<?php
use Dotenv\Dotenv;
use lib\Configs\Route;
use lib\Configs\App;
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . "/lib/Configs/Route.php";
define("ROOT_PATH", __DIR__);
require_once ROOT_PATH . '/vendor/autoload.php';
require_once ROOT_PATH . "/lib/Configs/App.php";
try {
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv = Dotenv::createImmutable(ROOT_PATH);
$dotenv->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();
}

View File

@ -0,0 +1,26 @@
<?php
namespace lib\Configs;
use lib\Core\App as Core;
class App extends Core
{
public function __construct(string $url)
{
parent::__construct($url);
}
protected function routeMethod(string $route): string
{
switch ($route) {
case 'service':
$route = 'latest_service';
break;
case 'history':
$route = 'latest_history';
break;
}
return parent::routeMethod($route);
}
}

View File

@ -1,73 +0,0 @@
<?php
namespace lib\Configs;
use lib\Core\Config as Core;
class Config extends Core
{
public function __construct()
{
parent::__construct();
} //
public function getSiteInfo(string $sitekey): array|null
{
$siteinfo = [];
switch ($sitekey) {
case 'dbms.prime-idc.jp':
$siteinfo = [
"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" => "주)듀나미스"],
],
];
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;
}
}

View File

@ -0,0 +1,48 @@
<?php
//DBMS Site정보
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" => " (주)브엘라해로이"],
],
]
]);

View File

@ -1,35 +0,0 @@
<?php
namespace lib\Configs;
use lib\Core\Route as Core;
class Route extends Core
{
public function __construct(string $url)
{
parent::__construct($url);
}
protected function routeController(string $route): string
{
switch ($route) {
case 'site':
$route = 'SiteController';
break;
}
return parent::routeController($route);
}
protected function routeMethod(string $route): string
{
switch ($route) {
case 'service':
$route = 'newservices';
break;
case 'history':
$route = 'newhistorys';
break;
}
return parent::routeMethod($route);
}
}

View File

@ -12,64 +12,4 @@ class CommonController extends Core
{
parent::__construct();
} //
final protected function getClientModel(): ClientModel
{
if ($this->_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

View File

@ -0,0 +1,24 @@
<?php
namespace lib\Controllers\DBMS;
use lib\Controllers\CommonController;
use lib\Services\ServiceService;
abstract class BaseController extends CommonController
{
private ?ServiceService $_service = null;
public function __construct()
{
parent::__construct();
$this->getView()->setPath('dbms');
} //
final public function getService(): ServiceService
{
if ($this->_service === null) {
$this->_service = new ServiceService();
}
return $this->_service;
}
} //Class

View File

@ -0,0 +1,20 @@
<?php
namespace lib\Controllers\DBMS;
class CouponController extends BaseController
{
public function __construct()
{
parent::__construct();
$this->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

View File

@ -1,39 +1,80 @@
<?php
namespace lib\Controllers;
namespace lib\Controllers\DBMS;
use lib\Services\AddDbService;
use lib\Services\ClientService;
use lib\Services\HistoryService;
use lib\Services\KCSService;
use lib\Services\MemberService;
use lib\Services\ServiceService;
use lib\Services\ClientService;
use lib\Services\VPCService;
use lib\Helpers\ServiceHelper;
use lib\Services\KCSService;
use lib\Services\HistoryService;
class SiteController extends CommonController
class DashboardController extends BaseController
{
private ?ServiceService $_service = null;
private ?MemberService $_memberService = null;
private ?ClientService $_clientService = null;
private ?VPCService $_vpcService = null;
private ?KCSService $_kcsService = null;
private ?HistoryService $_historyService = null;
private ?AddDbService $_addDbService = null;
public function __construct()
{
parent::__construct();
$this->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

View File

@ -0,0 +1,41 @@
<?php
namespace lib\Controllers\DBMS;
use lib\Services\ClientService;
use lib\Services\AddDbService;
class NavigatorController extends BaseController
{
private ?ClientService $_clientService = null;
private ?AddDbService $_addDbService = null;
public function __construct()
{
parent::__construct();
$this->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

View File

@ -0,0 +1,52 @@
<?php
namespace lib\Controllers\DBMS;
use lib\Services\ClientService;
use lib\Services\AddDbService;
class PaymentController extends BaseController
{
public function __construct()
{
parent::__construct();
$this->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

View File

@ -0,0 +1,60 @@
<?php
namespace lib\Controllers\DBMS;
use lib\Services\ClientService;
use lib\Services\AddDbService;
class ExtraController extends BaseController
{
private ?ClientService $_clientService = null;
private ?AddDbService $_addDbService = null;
public function __construct()
{
parent::__construct();
$this->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

View File

@ -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) {

View File

@ -1,27 +0,0 @@
<?php
namespace lib\Core;
abstract class Config
{
private $_values = [];
private $_debug = false;
protected function __construct() {} //
final public function setDebug($debug)
{
$this->_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

View File

@ -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

View File

@ -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];

View File

@ -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

View File

@ -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');

View File

@ -0,0 +1,120 @@
<style>
table {
background: #f5f5f5;
border-collapse: separate;
box-shadow: inset 0 1px 0 #fff;
font-size: 12px;
line-height: 15px;
margin: 30px auto;
text-align: left;
width: 1000px;
}
th {
background: linear-gradient(#777, #444);
border-left: 1px solid #555;
border-right: 1px solid #777;
border-top: 1px solid #555;
border-bottom: 1px solid #333;
box-shadow: inset 0 1px 0 #999;
color: #fff;
font-weight: bold;
padding: 10px 15px;
position: relative;
text-shadow: 0 1px 0 #000;
}
th:after {
background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, .08));
content: '';
display: block;
height: 25%;
left: 0;
margin: 1px 0 0 0;
position: absolute;
top: 25%;
width: 100%;
}
th:first-child {
border-left: 1px solid #777;
box-shadow: inset 1px 1px 0 #999;
}
th:last-child {
box-shadow: inset -1px 1px 0 #999;
}
td {
border-right: 1px solid #fff;
border-left: 1px solid #e8e8e8;
border-top: 1px solid #fff;
border-bottom: 1px solid #e8e8e8;
padding: 10px 15px;
position: relative;
transition: all 300ms;
}
td:first-child {
box-shadow: inset 1px 0 0 #fff;
}
td:last-child {
border-right: 1px solid #e8e8e8;
box-shadow: inset -1px 0 0 #fff;
}
tr:nth-child(odd) td {
background: #f1f1f1;
}
tr:last-of-type td {
box-shadow: inset 0 -1px 0 #fff;
}
tr:last-of-type td:first-child {
box-shadow: inset 1px -1px 0 #fff;
}
tr:last-of-type td:last-child {
box-shadow: inset -1px -1px 0 #fff;
}
</style>
<div align="center">
[ <a href="http://<? $_SERVER['HTTP_HOST'] ?>:6752/DefaultPage.cli">돌아가기</a> ]
<form method=get>
IP 입력 : <input type=text name=data>
<input type=submit value="검색">
</form>
</div>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th style="text-align:center;width:40px;">CODE</th>
<th style="text-align:center;width:60px;">NAME</th>
<th style="text-align:center;width:60px;">SERVER</th>
<th style="text-align:center;width:80px;">IP</th>
<th style="text-align:center;width:80px;">SW</th>
<th style="text-align:center;">NOTE</th>
<th style="text-align:center;width:80px;">TEL</th>
<th style="text-align:center;width:80px;">MAIL</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->services as $service) { ?>
<tr>
<td><?= $service->getClientCode() ?></td>
<td><?= $this->clients[$service->getPK()]->getTitle() ?></td>
<td><?= $service->getServerCode() ?></td>
<td><?= $service->service_ip ?></td>
<td><?= $service->service_os ?></td>
<td><?= $service->service_sw ?></td>
<td><?= $this->clients[$service->getPK()]->Phone1 ?></td>
<td><?= $this->clients[$service->getPK()]->Email1 ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot></tfoot>
</table>