본문으로 건너뛰기

무통장 입금은행 보안 강화.

PHP 8 · GODO26
변경 파일 수: 4개
변경 파일 목록
총 4개
변경 파일 코드
추가삭제
Component/Order/OrderAdminNew.php+40-31
변경 전OrderAdminNew.php
use Framework\Debug\Exception\LayerNotReloadException;
use Framework\Debug\Exception\AlertRedirectException;
use Framework\Debug\Exception\WarningException;
 
use Framework\StaticProxy\Proxy\UserFilePath;
use Framework\Utility\ArrayUtils;
use Framework\Utility\DateTimeUtils;
 
$this->checked['useFl'][$this->search['useFl']] = 'checked="checked"';
 
// 키워드 검색
if ($this->search['keyword']) {
if ($this->search['key'] == '') {
$tmpWhere = [
'bankName',
'accountNumber',
'depositor',
];
$arrWhereAll = [];
foreach ($tmpWhere as $keyNm) {
$arrWhereAll[] = '(' . $keyNm . ' LIKE concat(\'%\',?,\'%\'))';
$this->db->bind_param_push($this->arrBind, 's', $this->search['keyword']);
}
$this->arrWhere[] = '(' . gd_implode(' OR ', $arrWhereAll) . ')';
} else {
$this->arrWhere[] = '' . $this->search['key'] . ' LIKE concat(\'%\',?,\'%\')';
$this->db->bind_param_push($this->arrBind, 's', $this->search['keyword']);
}
}
 
// 사용 여부 검색
if ($this->search['useFl']) {
$this->arrWhere[] = 'useFl = ?';
$page->setPage();
$page->setUrl(\Request::getQueryString());
 
// 현 페이지 결과
$this->db->strField = '*';
$this->db->strWhere = gd_implode(' AND ', gd_isset($this->arrWhere));
$this->db->strOrder = "defaultFl desc," . $this->search['sort'];
$this->db->strLimit = $page->recode['start'] . ',' . $request['pageNum'];
 
$query = $this->db->query_complete();
$strSQL = 'SELECT ' . array_shift($query) . ' FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$data = $this->db->query_fetch($strSQL, $this->arrBind);
 
 
 
 
// 레코드 수
unset($query['group'], $query['order'], $query['limit']);
$strCntSQL = 'SELECT COUNT(*) AS total FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$page->recode['total'] = $this->db->query_fetch($strCntSQL, $this->arrBind, false)['total'];
//list($page->recode['total']) = $this->db->fetch('SELECT FOUND_ROWS()', 'row');
$page->setPage();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// 각 데이터 배열화
$getData['data'] = gd_htmlspecialchars_stripslashes(gd_isset($data));
throw new Exception(__('예금주은(는) 필수 항목 입니다.'));
}
 
 
 
 
if (empty($arrData['defaultFl']) === true) {
$arrData['defaultFl'] = "n";
}
 
변경 후OrderAdminNew.php
use Framework\Debug\Exception\LayerNotReloadException;
use Framework\Debug\Exception\AlertRedirectException;
use Framework\Debug\Exception\WarningException;
use Framework\Security\ManageBankCryptor;
use Framework\StaticProxy\Proxy\UserFilePath;
use Framework\Utility\ArrayUtils;
use Framework\Utility\DateTimeUtils;
 
$this->checked['useFl'][$this->search['useFl']] = 'checked="checked"';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// 사용 여부 검색
if ($this->search['useFl']) {
$this->arrWhere[] = 'useFl = ?';
$page->setPage();
$page->setUrl(\Request::getQueryString());
 
 
$this->db->strField = '*';
$this->db->strWhere = gd_implode(' AND ', gd_isset($this->arrWhere));
$this->db->strOrder = "defaultFl desc," . $this->search['sort'];
 
 
$keyword = (string) $this->search['keyword'];
if ($keyword !== '') {
// 계좌번호는 암호화 저장되어 SQL 조건 검색이 불가하므로, 전체 목록을 조회·복호화 후 검색 항목(은행명·계좌번호·예금주) 기준으로 필터한다.
$query = $this->db->query_complete();
$strSQL = 'SELECT ' . array_shift($query) . ' FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$data = gd_isset($this->db->query_fetch($strSQL, $this->arrBind), []);
 
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
 
// 검색 항목 기준으로 키워드 부분검색 필터
$data = $this->filterBankListByKeyword($data, $keyword, (string) $this->search['key'], false);
 
$page->recode['total'] = count($data);
$page->setPage();
$data = array_slice($data, $page->recode['start'], (int) $request['pageNum']);
} else {
$this->db->strLimit = $page->recode['start'] . ',' . $request['pageNum'];
 
$query = $this->db->query_complete();
$strSQL = 'SELECT ' . array_shift($query) . ' FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$data = $this->db->query_fetch($strSQL, $this->arrBind);
 
// 계좌번호 복호화
if (!empty($data)) {
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
}
 
// 레코드 수
unset($query['group'], $query['order'], $query['limit']);
$strCntSQL = 'SELECT COUNT(*) AS total FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$page->recode['total'] = $this->db->query_fetch($strCntSQL, $this->arrBind, false)['total'];
$page->setPage();
}
 
// 각 데이터 배열화
$getData['data'] = gd_htmlspecialchars_stripslashes(gd_isset($data));
throw new Exception(__('예금주은(는) 필수 항목 입니다.'));
}
 
// 계좌번호 암호화 저장
$arrData['accountNumber'] = ManageBankCryptor::encrypt($arrData['accountNumber']);
 
if (empty($arrData['defaultFl']) === true) {
$arrData['defaultFl'] = "n";
}
 
Component/Order/OrderAdmin.php+65-39
변경 전OrderAdmin.php
use Framework\Debug\Exception\LayerNotReloadException;
use Framework\Debug\Exception\AlertRedirectException;
use Framework\Debug\Exception\WarningException;
 
use Framework\StaticProxy\Proxy\UserFilePath;
use Framework\Utility\ArrayUtils;
use Framework\Utility\DateTimeUtils;
 
$this->checked['useFl'][$this->search['useFl']] = 'checked="checked"';
 
// 키워드 검색
if ($this->search['keyword']) {
if ($this->search['key'] == '') {
$tmpWhere = [
'bankName',
'accountNumber',
'depositor',
];
$arrWhereAll = [];
foreach ($tmpWhere as $keyNm) {
if ($this->search['searchKind'] == 'equalSearch') {
$arrWhereAll[] = '(' . $keyNm . ' = ? )';
} else {
$arrWhereAll[] = '(' . $keyNm . ' LIKE concat(\'%\',?,\'%\'))';
}
$this->db->bind_param_push($this->arrBind, 's', $this->search['keyword']);
}
$this->arrWhere[] = '(' . gd_implode(' OR ', $arrWhereAll) . ')';
} else {
if ($this->search['searchKind'] == 'equalSearch') {
$this->arrWhere[] = '' . $this->search['key'] . ' = ? ';
} else {
$this->arrWhere[] = '' . $this->search['key'] . ' LIKE concat(\'%\',?,\'%\')';
}
$this->db->bind_param_push($this->arrBind, 's', $this->search['keyword']);
}
}
 
// 사용 여부 검색
if ($this->search['useFl']) {
$this->arrWhere[] = 'useFl = ?';
$page->setPage();
$page->setUrl(\Request::getQueryString());
 
// 현 페이지 결과
$this->db->strField = '*';
$this->db->strWhere = gd_implode(' AND ', gd_isset($this->arrWhere));
$this->db->strOrder = "defaultFl desc," . $this->search['sort'];
$this->db->strLimit = $page->recode['start'] . ',' . $request['pageNum'];
 
$query = $this->db->query_complete();
$strSQL = 'SELECT ' . array_shift($query) . ' FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$data = $this->db->query_fetch($strSQL, $this->arrBind);
 
 
 
 
// 레코드 수
unset($query['group'], $query['order'], $query['limit']);
$strCntSQL = 'SELECT COUNT(*) AS total FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$page->recode['total'] = $this->db->query_fetch($strCntSQL, $this->arrBind, false)['total'];
//list($page->recode['total']) = $this->db->fetch('SELECT FOUND_ROWS()', 'row');
$page->setPage();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// 각 데이터 배열화
$getData['data'] = gd_htmlspecialchars_stripslashes(gd_isset($data));
return $getData;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**
* 주문정책내 무통장 입금은행 등록 / 수정
*
throw new Exception(__('예금주은(는) 필수 항목 입니다.'));
}
 
 
 
 
if (empty($arrData['defaultFl']) === true) {
$arrData['defaultFl'] = "n";
}
 
변경 후OrderAdmin.php
use Framework\Debug\Exception\LayerNotReloadException;
use Framework\Debug\Exception\AlertRedirectException;
use Framework\Debug\Exception\WarningException;
use Framework\Security\ManageBankCryptor;
use Framework\StaticProxy\Proxy\UserFilePath;
use Framework\Utility\ArrayUtils;
use Framework\Utility\DateTimeUtils;
 
$this->checked['useFl'][$this->search['useFl']] = 'checked="checked"';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// 사용 여부 검색
if ($this->search['useFl']) {
$this->arrWhere[] = 'useFl = ?';
$page->setPage();
$page->setUrl(\Request::getQueryString());
 
 
$this->db->strField = '*';
$this->db->strWhere = gd_implode(' AND ', gd_isset($this->arrWhere));
$this->db->strOrder = "defaultFl desc," . $this->search['sort'];
 
 
$keyword = (string) $this->search['keyword'];
if ($keyword !== '') {
// 계좌번호는 암호화 저장되어 SQL 조건 검색이 불가하므로, 전체 목록을 조회·복호화 후 검색 항목(은행명·계좌번호·예금주) 기준으로 필터한다.
$query = $this->db->query_complete();
$strSQL = 'SELECT ' . array_shift($query) . ' FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$data = gd_isset($this->db->query_fetch($strSQL, $this->arrBind), []);
 
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
 
// 검색 항목 기준으로 키워드 필터
$data = $this->filterBankListByKeyword($data, $keyword, (string) $this->search['key'], $this->search['searchKind'] == 'equalSearch');
 
$page->recode['total'] = count($data);
$page->setPage();
$data = array_slice($data, $page->recode['start'], (int) $request['pageNum']);
} else {
$this->db->strLimit = $page->recode['start'] . ',' . $request['pageNum'];
 
$query = $this->db->query_complete();
$strSQL = 'SELECT ' . array_shift($query) . ' FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$data = $this->db->query_fetch($strSQL, $this->arrBind);
 
// 계좌번호 복호화
if (!empty($data)) {
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
}
 
// 레코드 수
unset($query['group'], $query['order'], $query['limit']);
$strCntSQL = 'SELECT COUNT(*) AS total FROM ' . DB_MANAGE_BANK . gd_implode(' ', $query);
$page->recode['total'] = $this->db->query_fetch($strCntSQL, $this->arrBind, false)['total'];
$page->setPage();
}
 
// 각 데이터 배열화
$getData['data'] = gd_htmlspecialchars_stripslashes(gd_isset($data));
return $getData;
}
 
/**
* 무통장 입금은행 목록을 검색어(은행명·계좌번호·예금주) 기준으로 필터링
*
* @param array $data 복호화 완료된 은행 목록
* @param string $keyword 검색어
* @param string $key 검색 항목 (빈 값이면 통합검색: 은행명·계좌번호·예금주)
* @param bool $isEqual 완전일치 여부 (false 면 부분검색)
*
* @return array 필터링된 목록 (인덱스 재정렬)
*/
protected function filterBankListByKeyword(array $data, string $keyword, string $key, bool $isEqual): array
{
$fields = $key === '' ? ['bankName', 'accountNumber', 'depositor'] : [$key];
 
return array_values(array_filter($data, function ($row) use ($fields, $keyword, $isEqual) {
foreach ($fields as $field) {
$target = (string) $row[$field];
if ($isEqual ? $target === $keyword : mb_strpos($target, $keyword) !== false) {
return true;
}
}
return false;
}));
}
 
/**
* 주문정책내 무통장 입금은행 등록 / 수정
*
throw new Exception(__('예금주은(는) 필수 항목 입니다.'));
}
 
// 계좌번호 암호화 저장
$arrData['accountNumber'] = ManageBankCryptor::encrypt($arrData['accountNumber']);
 
if (empty($arrData['defaultFl']) === true) {
$arrData['defaultFl'] = "n";
}
 
Component/Order/OrderNew.php+19
변경 전OrderNew.php
use Framework\Helper\MallHelper;
use Framework\SimpleCache\SimpleCache;
use Framework\SimpleCache\SimpleCacheException;
 
use Framework\Utility\ArrayUtils;
use Framework\Utility\ComponentUtils;
use Framework\Utility\KafkaUtils;
if (empty($data) === true) {
return false;
} else {
 
 
 
 
 
return gd_htmlspecialchars_stripslashes($data);
}
}
$strSQL = 'SELECT sno, ' . gd_implode(', ', DBTableField::setTableField('tableManageBank')) . ' FROM ' . DB_MANAGE_BANK . ' WHERE ' . gd_implode(' AND ', $arrWhere);
$data = $this->db->query_fetch($strSQL, $arrBind, $boolFetch);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
return gd_htmlspecialchars_stripslashes($data);
}
 
 
변경 후OrderNew.php
use Framework\Helper\MallHelper;
use Framework\SimpleCache\SimpleCache;
use Framework\SimpleCache\SimpleCacheException;
use Framework\Security\ManageBankCryptor;
use Framework\Utility\ArrayUtils;
use Framework\Utility\ComponentUtils;
use Framework\Utility\KafkaUtils;
if (empty($data) === true) {
return false;
} else {
// 계좌번호 복호화
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
 
return gd_htmlspecialchars_stripslashes($data);
}
}
$strSQL = 'SELECT sno, ' . gd_implode(', ', DBTableField::setTableField('tableManageBank')) . ' FROM ' . DB_MANAGE_BANK . ' WHERE ' . gd_implode(' AND ', $arrWhere);
$data = $this->db->query_fetch($strSQL, $arrBind, $boolFetch);
 
// 계좌번호 복호화
if ($boolFetch) {
if (!empty($data)) {
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
}
} else {
if (!empty($data['accountNumber'])) {
$data['accountNumber'] = ManageBankCryptor::decrypt($data['accountNumber']);
}
}
 
return gd_htmlspecialchars_stripslashes($data);
}
 
 
Component/Order/Order.php+19
변경 전Order.php
use Framework\Debug\Exception\AlertRedirectException;
use Framework\Debug\Exception\DatabaseException;
use Framework\Helper\MallHelper;
 
use Framework\Utility\ArrayUtils;
use Framework\Utility\ComponentUtils;
use Framework\Utility\NumberUtils;
if (empty($data) === true) {
return false;
} else {
 
 
 
 
 
return gd_htmlspecialchars_stripslashes($data);
}
}
$strSQL = 'SELECT sno, ' . gd_implode(', ', DBTableField::setTableField('tableManageBank')) . ' FROM ' . DB_MANAGE_BANK . ' WHERE ' . gd_implode(' AND ', $arrWhere);
$data = $this->db->secondary()->query_fetch($strSQL, $arrBind, $boolFetch);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
return gd_htmlspecialchars_stripslashes($data);
}
 
 
변경 후Order.php
use Framework\Debug\Exception\AlertRedirectException;
use Framework\Debug\Exception\DatabaseException;
use Framework\Helper\MallHelper;
use Framework\Security\ManageBankCryptor;
use Framework\Utility\ArrayUtils;
use Framework\Utility\ComponentUtils;
use Framework\Utility\NumberUtils;
if (empty($data) === true) {
return false;
} else {
// 계좌번호 복호화
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
 
return gd_htmlspecialchars_stripslashes($data);
}
}
$strSQL = 'SELECT sno, ' . gd_implode(', ', DBTableField::setTableField('tableManageBank')) . ' FROM ' . DB_MANAGE_BANK . ' WHERE ' . gd_implode(' AND ', $arrWhere);
$data = $this->db->secondary()->query_fetch($strSQL, $arrBind, $boolFetch);
 
// 계좌번호 복호화
if ($boolFetch) {
if (!empty($data)) {
foreach ($data as $index => $bankInfo) {
$data[$index]['accountNumber'] = ManageBankCryptor::decrypt($bankInfo['accountNumber']);
}
}
} else {
if (!empty($data['accountNumber'])) {
$data['accountNumber'] = ManageBankCryptor::decrypt($data['accountNumber']);
}
}
 
return gd_htmlspecialchars_stripslashes($data);
}