cfmgrv4 init...1
This commit is contained in:
parent
e9c77cf39b
commit
d44c0bf8aa
@ -55,12 +55,14 @@ class Cloudflare extends BaseController
|
|||||||
// $this->_db->transStart();
|
// $this->_db->transStart();
|
||||||
try {
|
try {
|
||||||
$auths = $this->auth_process($uid);
|
$auths = $this->auth_process($uid);
|
||||||
|
$accounts = [];
|
||||||
foreach ($auths as $auth) {
|
foreach ($auths as $auth) {
|
||||||
$accounts = $this->account_process($auth);
|
$accounts += $this->account_process($auth);
|
||||||
}
|
}
|
||||||
log_message("debug", "\n-------------총 Accounts:" . count($accounts) . "--------------------\n");
|
log_message("debug", "\n-------------총 Accounts:" . count($accounts) . "--------------------\n");
|
||||||
|
$zones = [];
|
||||||
foreach ($accounts as $key => $account) {
|
foreach ($accounts as $key => $account) {
|
||||||
$zones = $this->zone_process($account);
|
$zones += $this->zone_process($account);
|
||||||
}
|
}
|
||||||
log_message("debug", "\n-------------총 Zones:" . count($zones) . "--------------------\n");
|
log_message("debug", "\n-------------총 Zones:" . count($zones) . "--------------------\n");
|
||||||
foreach ($zones as $key => $zone) {
|
foreach ($zones as $key => $zone) {
|
||||||
|
|||||||
@ -88,7 +88,9 @@ abstract class MVController extends CommonController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function create_form_process(): void {}
|
protected function create_form_process(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
final protected function create_form_procedure(): RedirectResponse|string
|
final protected function create_form_procedure(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -302,7 +304,7 @@ abstract class MVController extends CommonController
|
|||||||
{
|
{
|
||||||
//Page, Per_page필요부분
|
//Page, Per_page필요부분
|
||||||
$this->page = (int) $this->request->getVar('page') ?: 1;
|
$this->page = (int) $this->request->getVar('page') ?: 1;
|
||||||
$this->per_page = (int) $this->request->getVar('per_page') ?: intval(getenv("mvc.default.list.per_page"));
|
$this->per_page = (int) $this->request->getVar('per_page') ?: intval(env("mvc.default.list.per_page") ?? 10);
|
||||||
//줄수 처리용
|
//줄수 처리용
|
||||||
$page_options = array("" => "줄수선택");
|
$page_options = array("" => "줄수선택");
|
||||||
for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) {
|
for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) {
|
||||||
@ -334,7 +336,7 @@ abstract class MVController extends CommonController
|
|||||||
$this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY'];
|
$this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY'];
|
||||||
$this->getModel()->setList_OrderBy(
|
$this->getModel()->setList_OrderBy(
|
||||||
$this->order_field !== DEFAULTS['EMPTY'] &&
|
$this->order_field !== DEFAULTS['EMPTY'] &&
|
||||||
$this->order_value !== DEFAULTS['EMPTY'] ? "{$this->order_field} {$this->order_value}" : ""
|
$this->order_value !== DEFAULTS['EMPTY'] ? "{$this->order_field} {$this->order_value}" : ""
|
||||||
);
|
);
|
||||||
if ($this->page) {
|
if ($this->page) {
|
||||||
$this->getModel()->limit(
|
$this->getModel()->limit(
|
||||||
|
|||||||
@ -48,13 +48,19 @@ abstract class Cloudflare extends CommonLibrary
|
|||||||
return $this->_accountModel;
|
return $this->_accountModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function reload_page(string $uri, int $page, int $per_page = 50): mixed
|
private function reload_page(string $uri, int $page, int $per_page = 20): mixed
|
||||||
{
|
{
|
||||||
$query = [
|
$query = [
|
||||||
|
'name' => '',
|
||||||
|
'status' => '',
|
||||||
|
'order' => 'name',
|
||||||
|
'direction' => 'asc',
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
'match' => 'all',
|
'match' => 'all',
|
||||||
|
'cache_buster' => time(), // 캐시 무효화를 위한 파라미터 추가
|
||||||
];
|
];
|
||||||
|
// log_message("debug", var_export($query, true));
|
||||||
$response = $this->getMySocket()->get($uri, $query);
|
$response = $this->getMySocket()->get($uri, $query);
|
||||||
$cf = json_decode($response->getBody());
|
$cf = json_decode($response->getBody());
|
||||||
if (!$cf->success) {
|
if (!$cf->success) {
|
||||||
@ -62,6 +68,7 @@ abstract class Cloudflare extends CommonLibrary
|
|||||||
log_message("error", $message);
|
log_message("error", $message);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
|
// log_message("debug", "Page {$page} response: " . var_export($cf->result_info, true));
|
||||||
return $cf;
|
return $cf;
|
||||||
}
|
}
|
||||||
final protected function reload_procedure(string $uri): array
|
final protected function reload_procedure(string $uri): array
|
||||||
@ -71,8 +78,8 @@ abstract class Cloudflare extends CommonLibrary
|
|||||||
$cf = $this->reload_page($uri, $page);
|
$cf = $this->reload_page($uri, $page);
|
||||||
$per_page = $cf->result_info->per_page;
|
$per_page = $cf->result_info->per_page;
|
||||||
$total_page = $cf->result_info->total_pages;
|
$total_page = $cf->result_info->total_pages;
|
||||||
$results = $cf->result;
|
$results = $cf->result;
|
||||||
for ($i = $page + 1; $i <= $total_page; $i++) {
|
for ($i = $page + 1; $i < $total_page; $i++) {
|
||||||
$cf = $this->reload_page($uri, $i, $per_page);
|
$cf = $this->reload_page($uri, $i, $per_page);
|
||||||
$results = array_merge($results, $cf->result);
|
$results = array_merge($results, $cf->result);
|
||||||
log_message("debug", "현재: page[{$i}/{$total_page}] , result수[" . count($results) . "]");
|
log_message("debug", "현재: page[{$i}/{$total_page}] , result수[" . count($results) . "]");
|
||||||
|
|||||||
@ -17,12 +17,12 @@ class CloudflareSocket extends MySocket
|
|||||||
'headers' => [
|
'headers' => [
|
||||||
'X-Auth-Email' => $auth_entity->getID(),
|
'X-Auth-Email' => $auth_entity->getID(),
|
||||||
'X-Auth-Key' => $auth_entity->getAuthKey(),
|
'X-Auth-Key' => $auth_entity->getAuthKey(),
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json'
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
//override
|
//override
|
||||||
final public function request(string $method, $uri = '', array $options = []): ResponseInterface
|
public function request(string $method, $uri = '', array $options = []): ResponseInterface
|
||||||
{
|
{
|
||||||
if (self::$_request >= self::$_request_max) {
|
if (self::$_request >= self::$_request_max) {
|
||||||
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait));
|
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait));
|
||||||
|
|||||||
@ -12,7 +12,8 @@ class MySocket extends Client
|
|||||||
public function __construct(array $config = [])
|
public function __construct(array $config = [])
|
||||||
{
|
{
|
||||||
// SSL 인증서 검증을 비활성화
|
// SSL 인증서 검증을 비활성화
|
||||||
$config['verify'] = getenv("socket.web.ssl.verify") == "true" ? true : false;
|
$config['verify'] = env("socket.web.ssl.verify") ?? false;
|
||||||
|
$config['User-Agent'] = $config['User-Agent'] ?? $this->getUserAgent();
|
||||||
parent::__construct($config);
|
parent::__construct($config);
|
||||||
}
|
}
|
||||||
final protected function getCookieJar(): CookieJar
|
final protected function getCookieJar(): CookieJar
|
||||||
@ -37,44 +38,42 @@ class MySocket extends Client
|
|||||||
protected function getRequestOptions(string $method, array $options = []): array
|
protected function getRequestOptions(string $method, array $options = []): array
|
||||||
{
|
{
|
||||||
//cookies->쿠키값 , timeout->5초 안에 응답이 없으면 타임아웃
|
//cookies->쿠키값 , timeout->5초 안에 응답이 없으면 타임아웃
|
||||||
$requestOptions = [
|
//method가 get이면 $request['query'] = $options , 다른것이면 $request['json] = $options
|
||||||
'cookies' => $this->getCookieJar(),
|
$options = [
|
||||||
'timeout' => getenv("socket.web.timeout"),
|
// 'cookies' => $this->getCookieJar(),
|
||||||
'headers' => [
|
'timeout' => env("socket.web.timeout") ?? 5,
|
||||||
'User-Agent' => $this->getUserAgent(),
|
in_array($method, ['get']) ? 'query' : 'json' => $options
|
||||||
],
|
|
||||||
];
|
];
|
||||||
return $requestOptions;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($uri, array $options = []): ResponseInterface
|
final public function get($uri, array $options = []): ResponseInterface
|
||||||
{
|
{
|
||||||
return $this->request('GET', $uri, $options);
|
return $this->request('GET', $uri, $options);
|
||||||
}
|
}
|
||||||
public function post($uri, array $options = []): ResponseInterface
|
final public function post($uri, array $options = []): ResponseInterface
|
||||||
{
|
{
|
||||||
return $this->request('POST', $uri, $options);
|
return $this->request('POST', $uri, $options);
|
||||||
}
|
}
|
||||||
public function put($uri, array $options = []): ResponseInterface
|
final public function put($uri, array $options = []): ResponseInterface
|
||||||
{
|
{
|
||||||
return $this->request('PUT', $uri, $options);
|
return $this->request('PUT', $uri, $options);
|
||||||
}
|
}
|
||||||
public function patch($uri, array $options = []): ResponseInterface
|
final public function patch($uri, array $options = []): ResponseInterface
|
||||||
{
|
{
|
||||||
return $this->request('PATCH', $uri, $options);
|
return $this->request('PATCH', $uri, $options);
|
||||||
}
|
}
|
||||||
public function delete($uri, array $options = []): ResponseInterface
|
final public function delete($uri, array $options = []): ResponseInterface
|
||||||
{
|
{
|
||||||
return $this->request('DELETE', $uri, $options);
|
return $this->request('DELETE', $uri, $options);
|
||||||
}
|
}
|
||||||
public function request(string $method, $uri = '', array $options = []): ResponseInterface
|
public function request(string $method, $uri = '', array $options = []): ResponseInterface
|
||||||
{
|
{
|
||||||
$requestOptions = $this->getRequestOptions($method, $options);
|
$options = $this->getRequestOptions($method, $options);
|
||||||
$requestOptions[in_array($method, ['get', 'getAsync']) ? 'query' : 'json'] = $options;
|
log_message("debug", __FUNCTION__ .
|
||||||
// log_message("debug", __FUNCTION__ .
|
"=> 호출 Socket URL:{$uri}\n--------------\n" .
|
||||||
// "=> 호출 Socket URL:{$uri}\n--------------\n" .
|
var_export($options, true) .
|
||||||
// var_export($options, true) .
|
"\n--------------\n");
|
||||||
// "\n--------------\n");
|
return parent::request($method, $uri, $options);
|
||||||
return parent::request($method, $uri, $requestOptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,7 @@ class FileStorage extends CommonLibrary
|
|||||||
log_message("debug", __FUNCTION__ . " {$save_file} 작업 시작");
|
log_message("debug", __FUNCTION__ . " {$save_file} 작업 시작");
|
||||||
//중복된 파일명인지 확인후 새로운 이름으로 저장
|
//중복된 파일명인지 확인후 새로운 이름으로 저장
|
||||||
if (file_exists($save_file)) {
|
if (file_exists($save_file)) {
|
||||||
switch (getenv("mangboard.uploads.file.collision")) {
|
switch (env("mangboard.uploads.file.collision")) {
|
||||||
case "unique":
|
case "unique":
|
||||||
$file_name = $this->getUniqueName_FileTrait($this->getFullPath(), $this->getOriginName());
|
$file_name = $this->getUniqueName_FileTrait($this->getFullPath(), $this->getOriginName());
|
||||||
log_message("notice", __FUNCTION__ . " 파일명 변경 : 원본파일 {$this->getOriginName()}->저장파일 {$file_name}");
|
log_message("notice", __FUNCTION__ . " 파일명 변경 : 원본파일 {$this->getOriginName()}->저장파일 {$file_name}");
|
||||||
@ -96,7 +96,7 @@ class FileStorage extends CommonLibrary
|
|||||||
case "notallow":
|
case "notallow":
|
||||||
default:
|
default:
|
||||||
throw new \Exception(__FUNCTION__ . " {$this->getOriginName()} 는 이미 존재하는 파일입니다.");
|
throw new \Exception(__FUNCTION__ . " {$this->getOriginName()} 는 이미 존재하는 파일입니다.");
|
||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//원본이미지 저장
|
//원본이미지 저장
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user