From d74dcd8e1dac1039504ff1efa56f2c20bdd5aa3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sun, 15 Sep 2024 04:59:22 +0900 Subject: [PATCH] Automation init..3 --- .../MySocket/Web/CloudflareLibrary.php | 42 +++++++++++++++++++ app/Libraries/MySocket/Web/GoogleLibrary.php | 4 +- app/Libraries/MyStorage/FileLibrary.php | 16 +++++-- composer.json | 8 ++-- 4 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 app/Libraries/MySocket/Web/CloudflareLibrary.php diff --git a/app/Libraries/MySocket/Web/CloudflareLibrary.php b/app/Libraries/MySocket/Web/CloudflareLibrary.php new file mode 100644 index 0000000..64521b9 --- /dev/null +++ b/app/Libraries/MySocket/Web/CloudflareLibrary.php @@ -0,0 +1,42 @@ +_api_email = $api_email; + $this->_api_key = $api_key; + } + + //Override + public function getClient() + { + if (is_null($this->_client)) { + $apikey = new APIKey($this->_api_email, $this->_api_key); + $this->_client = new Guzzle($apikey); + self::$_request_max = intval(getenv("cfmgr.request.max")); + self::$_request_timewait = intval(getenv("cfmgr.request.timewait")); + } + if (self::$_request_max <= self::$_request_count) { + log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait)); + sleep(intval(getenv("cf.mgr.request.time.wait"))); + self::$_request_count = 0; + log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait)); + } + self::$_request_count++; + return $this->_client; + } +} diff --git a/app/Libraries/MySocket/Web/GoogleLibrary.php b/app/Libraries/MySocket/Web/GoogleLibrary.php index f670222..3acf3f6 100644 --- a/app/Libraries/MySocket/Web/GoogleLibrary.php +++ b/app/Libraries/MySocket/Web/GoogleLibrary.php @@ -15,11 +15,11 @@ class GoogleLibrary extends MySocketLibrary $this->_session = \Config\Services::session(); } + //Override public function getClient() { if (is_null($this->_client)) { - // $this->_client = new \Google_Client(); - $this->_client = new \GuzzleHttp\Client(); + $this->_client = new \Google_Client(); $this->_client->setClientId(getenv("socket.google.client.id")); $this->_client->setClientSecret(getenv("socket.google.client.key")); $this->_client->setRedirectUri(base_url() . getenv("socket.google.client.callback_url")); diff --git a/app/Libraries/MyStorage/FileLibrary.php b/app/Libraries/MyStorage/FileLibrary.php index 379a149..f2bd9d7 100644 --- a/app/Libraries/MyStorage/FileLibrary.php +++ b/app/Libraries/MyStorage/FileLibrary.php @@ -47,10 +47,18 @@ class FileLibrary extends MyStorageLibrary $saveFilePath = $fullPath . DIRECTORY_SEPARATOR . $this->getOriginName(); //중복된 파일명인지 확인후 새로운 이름으로 저장 if (file_exists($saveFilePath)) { - $saveFile = $this->getUniqueFilename($fullPath, $this->getOriginName()); - $saveFilePath = $fullPath . DIRECTORY_SEPARATOR . $saveFile; - log_message("notice", __FUNCTION__ . "파일명 변경 : 원본파일 {$this->getOriginName()}->저장파일 {$saveFile}"); - $this->setOriginName($saveFile); + switch (getenv("mangboard.uloads.file.collision")) { + case "unique": + $saveFile = $this->getUniqueFilename($fullPath, $this->getOriginName()); + $saveFilePath = $fullPath . DIRECTORY_SEPARATOR . $saveFile; + log_message("notice", __FUNCTION__ . "파일명 변경 : 원본파일 {$this->getOriginName()}->저장파일 {$saveFile}"); + $this->setOriginName($saveFile); + break; + case "notallow": + default: + throw new \Exception(__FUNCTION__ . "{$saveFilePath}는 이미 존재하는 파일입니다."); + // break; + } } //원본이미지 저장 if (!file_put_contents($saveFilePath, $this->getOriginContent())) { diff --git a/composer.json b/composer.json index 9d4f53a..39fcb72 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,14 @@ "slack": "https://codeigniterchat.slack.com" }, "require": { - "php": "^8.1", - "codeigniter4/framework": "^4.0", + "php": "^8.3", + "codeigniter4/framework": "^4.5", "guzzlehttp/guzzle": "^7.9", "symfony/css-selector": "^7.1", "symfony/dom-crawler": "^7.1", - "tinymce/tinymce": "^7.3" + "tinymce/tinymce": "^7.3", + "phpoffice/phpspreadsheet": "^1.27", + "cloudflare/sdk": "^1.3" }, "require-dev": { "fakerphp/faker": "^1.9",