Automation init..3
This commit is contained in:
parent
2bb13ba47e
commit
d74dcd8e1d
42
app/Libraries/MySocket/Web/CloudflareLibrary.php
Normal file
42
app/Libraries/MySocket/Web/CloudflareLibrary.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Libraries\MySocket\Web;
|
||||||
|
|
||||||
|
use Cloudflare\API\Auth\APIKey;
|
||||||
|
use Cloudflare\API\Adapter\Guzzle;
|
||||||
|
use App\Libraries\MySocket\WebLibrary as MySocketLibrary;
|
||||||
|
|
||||||
|
class CloudflareLibrary extends MySocketLibrary
|
||||||
|
{
|
||||||
|
private static int $_request_count = 1;
|
||||||
|
private static int $_request_max = 100;
|
||||||
|
private static int $_request_timewait = 60;
|
||||||
|
private $_api_email = "";
|
||||||
|
private $_api_key = "";
|
||||||
|
private $_client = null;
|
||||||
|
public function __construct(string $host, string $api_email, string $api_key)
|
||||||
|
{
|
||||||
|
parent::__construct($host);
|
||||||
|
$this->_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -15,11 +15,11 @@ class GoogleLibrary extends MySocketLibrary
|
|||||||
$this->_session = \Config\Services::session();
|
$this->_session = \Config\Services::session();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Override
|
||||||
public function getClient()
|
public function getClient()
|
||||||
{
|
{
|
||||||
if (is_null($this->_client)) {
|
if (is_null($this->_client)) {
|
||||||
// $this->_client = new \Google_Client();
|
$this->_client = new \Google_Client();
|
||||||
$this->_client = new \GuzzleHttp\Client();
|
|
||||||
$this->_client->setClientId(getenv("socket.google.client.id"));
|
$this->_client->setClientId(getenv("socket.google.client.id"));
|
||||||
$this->_client->setClientSecret(getenv("socket.google.client.key"));
|
$this->_client->setClientSecret(getenv("socket.google.client.key"));
|
||||||
$this->_client->setRedirectUri(base_url() . getenv("socket.google.client.callback_url"));
|
$this->_client->setRedirectUri(base_url() . getenv("socket.google.client.callback_url"));
|
||||||
|
|||||||
@ -47,10 +47,18 @@ class FileLibrary extends MyStorageLibrary
|
|||||||
$saveFilePath = $fullPath . DIRECTORY_SEPARATOR . $this->getOriginName();
|
$saveFilePath = $fullPath . DIRECTORY_SEPARATOR . $this->getOriginName();
|
||||||
//중복된 파일명인지 확인후 새로운 이름으로 저장
|
//중복된 파일명인지 확인후 새로운 이름으로 저장
|
||||||
if (file_exists($saveFilePath)) {
|
if (file_exists($saveFilePath)) {
|
||||||
$saveFile = $this->getUniqueFilename($fullPath, $this->getOriginName());
|
switch (getenv("mangboard.uloads.file.collision")) {
|
||||||
$saveFilePath = $fullPath . DIRECTORY_SEPARATOR . $saveFile;
|
case "unique":
|
||||||
log_message("notice", __FUNCTION__ . "파일명 변경 : 원본파일 {$this->getOriginName()}->저장파일 {$saveFile}");
|
$saveFile = $this->getUniqueFilename($fullPath, $this->getOriginName());
|
||||||
$this->setOriginName($saveFile);
|
$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())) {
|
if (!file_put_contents($saveFilePath, $this->getOriginContent())) {
|
||||||
|
|||||||
@ -10,12 +10,14 @@
|
|||||||
"slack": "https://codeigniterchat.slack.com"
|
"slack": "https://codeigniterchat.slack.com"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.3",
|
||||||
"codeigniter4/framework": "^4.0",
|
"codeigniter4/framework": "^4.5",
|
||||||
"guzzlehttp/guzzle": "^7.9",
|
"guzzlehttp/guzzle": "^7.9",
|
||||||
"symfony/css-selector": "^7.1",
|
"symfony/css-selector": "^7.1",
|
||||||
"symfony/dom-crawler": "^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": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.9",
|
"fakerphp/faker": "^1.9",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user