diff --git a/app/Controllers/CLI/Cloudflare.php b/app/Controllers/CLI/Cloudflare.php index 62582eb..3bc9706 100644 --- a/app/Controllers/CLI/Cloudflare.php +++ b/app/Controllers/CLI/Cloudflare.php @@ -55,12 +55,14 @@ class Cloudflare extends BaseController // $this->_db->transStart(); try { $auths = $this->auth_process($uid); + $accounts = []; foreach ($auths as $auth) { - $accounts = $this->account_process($auth); + $accounts += $this->account_process($auth); } log_message("debug", "\n-------------총 Accounts:" . count($accounts) . "--------------------\n"); + $zones = []; foreach ($accounts as $key => $account) { - $zones = $this->zone_process($account); + $zones += $this->zone_process($account); } log_message("debug", "\n-------------총 Zones:" . count($zones) . "--------------------\n"); foreach ($zones as $key => $zone) { diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index 88877b9..3d9defb 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -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 { try { @@ -302,7 +304,7 @@ abstract class MVController extends CommonController { //Page, Per_page필요부분 $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("" => "줄수선택"); 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->getModel()->setList_OrderBy( $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) { $this->getModel()->limit( diff --git a/app/Libraries/Cloudflare/Cloudflare.php b/app/Libraries/Cloudflare/Cloudflare.php index 40be6c6..dfd2d45 100644 --- a/app/Libraries/Cloudflare/Cloudflare.php +++ b/app/Libraries/Cloudflare/Cloudflare.php @@ -48,13 +48,19 @@ abstract class Cloudflare extends CommonLibrary 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 = [ + 'name' => '', + 'status' => '', + 'order' => 'name', + 'direction' => 'asc', 'page' => $page, 'per_page' => $per_page, 'match' => 'all', + 'cache_buster' => time(), // 캐시 무효화를 위한 파라미터 추가 ]; + // log_message("debug", var_export($query, true)); $response = $this->getMySocket()->get($uri, $query); $cf = json_decode($response->getBody()); if (!$cf->success) { @@ -62,6 +68,7 @@ abstract class Cloudflare extends CommonLibrary log_message("error", $message); throw new \Exception($message); } + // log_message("debug", "Page {$page} response: " . var_export($cf->result_info, true)); return $cf; } final protected function reload_procedure(string $uri): array @@ -71,8 +78,8 @@ abstract class Cloudflare extends CommonLibrary $cf = $this->reload_page($uri, $page); $per_page = $cf->result_info->per_page; $total_page = $cf->result_info->total_pages; - $results = $cf->result; - for ($i = $page + 1; $i <= $total_page; $i++) { + $results = $cf->result; + for ($i = $page + 1; $i < $total_page; $i++) { $cf = $this->reload_page($uri, $i, $per_page); $results = array_merge($results, $cf->result); log_message("debug", "현재: page[{$i}/{$total_page}] , result수[" . count($results) . "]"); diff --git a/app/Libraries/MySocket/CloudflareSocket.php b/app/Libraries/MySocket/CloudflareSocket.php index 7350f8f..bc040b1 100644 --- a/app/Libraries/MySocket/CloudflareSocket.php +++ b/app/Libraries/MySocket/CloudflareSocket.php @@ -17,12 +17,12 @@ class CloudflareSocket extends MySocket 'headers' => [ 'X-Auth-Email' => $auth_entity->getID(), 'X-Auth-Key' => $auth_entity->getAuthKey(), - 'Content-Type' => 'application/json', + 'Content-Type' => 'application/json' ] ]); } //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) { log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait)); diff --git a/app/Libraries/MySocket/MySocket.php b/app/Libraries/MySocket/MySocket.php index 53fd4b3..bbf8457 100644 --- a/app/Libraries/MySocket/MySocket.php +++ b/app/Libraries/MySocket/MySocket.php @@ -12,7 +12,8 @@ class MySocket extends Client public function __construct(array $config = []) { // 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); } final protected function getCookieJar(): CookieJar @@ -37,44 +38,42 @@ class MySocket extends Client protected function getRequestOptions(string $method, array $options = []): array { //cookies->쿠키값 , timeout->5초 안에 응답이 없으면 타임아웃 - $requestOptions = [ - 'cookies' => $this->getCookieJar(), - 'timeout' => getenv("socket.web.timeout"), - 'headers' => [ - 'User-Agent' => $this->getUserAgent(), - ], + //method가 get이면 $request['query'] = $options , 다른것이면 $request['json] = $options + $options = [ + // 'cookies' => $this->getCookieJar(), + 'timeout' => env("socket.web.timeout") ?? 5, + 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); } - public function post($uri, array $options = []): ResponseInterface + final public function post($uri, array $options = []): ResponseInterface { 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); } - public function patch($uri, array $options = []): ResponseInterface + final public function patch($uri, array $options = []): ResponseInterface { 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); } public function request(string $method, $uri = '', array $options = []): ResponseInterface { - $requestOptions = $this->getRequestOptions($method, $options); - $requestOptions[in_array($method, ['get', 'getAsync']) ? 'query' : 'json'] = $options; - // log_message("debug", __FUNCTION__ . - // "=> 호출 Socket URL:{$uri}\n--------------\n" . - // var_export($options, true) . - // "\n--------------\n"); - return parent::request($method, $uri, $requestOptions); + $options = $this->getRequestOptions($method, $options); + log_message("debug", __FUNCTION__ . + "=> 호출 Socket URL:{$uri}\n--------------\n" . + var_export($options, true) . + "\n--------------\n"); + return parent::request($method, $uri, $options); } } diff --git a/app/Libraries/MyStorage/FileStorage.php b/app/Libraries/MyStorage/FileStorage.php index 6d43dc3..167f9b4 100644 --- a/app/Libraries/MyStorage/FileStorage.php +++ b/app/Libraries/MyStorage/FileStorage.php @@ -86,7 +86,7 @@ class FileStorage extends CommonLibrary log_message("debug", __FUNCTION__ . " {$save_file} 작업 시작"); //중복된 파일명인지 확인후 새로운 이름으로 저장 if (file_exists($save_file)) { - switch (getenv("mangboard.uploads.file.collision")) { + switch (env("mangboard.uploads.file.collision")) { case "unique": $file_name = $this->getUniqueName_FileTrait($this->getFullPath(), $this->getOriginName()); log_message("notice", __FUNCTION__ . " 파일명 변경 : 원본파일 {$this->getOriginName()}->저장파일 {$file_name}"); @@ -96,7 +96,7 @@ class FileStorage extends CommonLibrary case "notallow": default: throw new \Exception(__FUNCTION__ . " {$this->getOriginName()} 는 이미 존재하는 파일입니다."); - // break; + // break; } } //원본이미지 저장