diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 59572a4..3b13842 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -18,20 +18,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->get('/', 'UserController::index');
});
});
-$routes->group('mangboard', ['namespace' => 'App\Controllers\Mangboard'], function ($routes) {
- $routes->group('user', function ($routes) {
- $routes->get('/', 'UserController::index');
- $routes->cli('point/(:alpha)/(:num)', 'UserController::point/$1/$2');
- $routes->cli('point/(:alpha)/(:num)/(:any)', 'UserController::point/$1/$2/$3');
- $routes->cli('level/(:alpha)/(:num)', 'UserController::level/$1/$2');
- $routes->cli('check_level', 'UserController::check_level');
- $routes->cli('check_level/(:alpha)', 'UserController::check_level/$1');
- });
- $routes->group('crawler', function ($routes) {
- $routes->cli('(:alpha)/(:any)', 'CrawlerController::$1/$2');
- $routes->cli('(:alpha)/(:any)/(:any)', 'CrawlerController::$1/$2');
- });
-});
$routes->group('cloudflare', ['namespace' => 'App\Controllers\Cloudflare'], function ($routes) {
$routes->group('account', function ($routes) {
$routes->get('/', 'AccountController::index');
diff --git a/app/Controllers/Mangboard/CrawlerController.php b/app/Controllers/Mangboard/CrawlerController.php
deleted file mode 100644
index 1c12a08..0000000
--- a/app/Controllers/Mangboard/CrawlerController.php
+++ /dev/null
@@ -1,131 +0,0 @@
-_user_model === null) {
- return $this->_user_model = new UserModel();
- }
- return $this->_user_model;
- }
- final protected function login_process(string $user_id = null): UserEntity
- {
- $user_id = $user_id ?? getenv("mangboard.login.default.id");
- $password = getenv("mangboard.login.default.password");
- // $response = $this->getWebLibrary($host)->getResponse(
- // getenv("mangboard.host.url") . getenv("mangboard.login.url"),
- // "post",
- // [
- // 'form_params' => [
- // 'user_id' => $id,
- // 'password' => $password,
- // ],
- // ]
- // );
- // if ($response->getStatusCode() == 200) {
- // $entity = $this->getUserModel()->getEntityByLoginCheck($id, $password);
- // if ($entity === null) {
- // throw new \Exception("{$id}는 회원이 아니거나 암호가 맞지 않습니다.");
- // }
- // } else {
- // throw new \Exception("연결실패:" . $response->getStatusCode());
- // }
- $entity = $this->getUserModel()->getEntityByID($user_id);
- if ($entity === null) {
- throw new \Exception("{$user_id}로 로그인 실패");
- }
- log_message("notice", "{$user_id}로 로그인 성공");
- return $entity;
- }
-
- public function yamap(string $board_name, string $user_id = null, ...$params): void
- {
- try {
- $user_entity = $this->login_process($user_id);
- $myCrawler = new Yamap(getenv("yamap.host.url"), $board_name, $user_entity);
- //추가옵션
- $myCrawler->isDebug = in_array('debug', $params);
- $myCrawler->isCopy = in_array('copy', $params);
- $myCrawler->execute();
- } catch (\Exception $e) {
- log_message("warning", sprintf(
- "\n---%s 오류---\n%s\n-----------------------------------------\n",
- __FUNCTION__,
- $e->getMessage()
- ));
- }
- }
- public function yamoon(string $board_name, string $user_id = null, ...$params): void
- {
- try {
- $user_entity = $this->login_process($user_id);
- $myCrawler = new Yamoon(getenv("yamoon.host.url"), $board_name, $user_entity);
- //추가옵션
- $myCrawler->isDebug = in_array('debug', $params);
- $myCrawler->isCopy = in_array('copy', $params);
- $myCrawler->execute();
- } catch (\Exception $e) {
- log_message("warning", sprintf(
- "\n---%s 오류---\n%s\n-----------------------------------------\n",
- __FUNCTION__,
- $e->getMessage()
- ));
- }
- }
- public function sir(string $board_name, string $user_id = null, ...$params): void
- {
- try {
- $user_entity = $this->login_process($user_id);
- $myCrawler = new Sir(getenv("sir.host.url"), $board_name, $user_entity);
- //추가옵션
- $myCrawler->isDebug = in_array('debug', $params);
- $myCrawler->isCopy = in_array('copy', $params);
- $myCrawler->execute();
- } catch (\Exception $e) {
- log_message("warning", sprintf(
- "\n---%s 오류---\n%s\n-----------------------------------------\n",
- __FUNCTION__,
- $e->getMessage()
- ));
- }
- }
- public function inven(string $board_name, string $user_id = null, ...$params): void
- {
- // echo "{$board_name}|{$user_id}|", implode("|", $params);
- // exit;
- try {
- $user_entity = $this->login_process($user_id);
- $myCrawler = new Inven(getenv("inven.host.url"), $board_name, $user_entity);
- //추가옵션
- $myCrawler->isDebug = in_array('debug', $params);
- $myCrawler->isCopy = in_array('copy', $params);
- $myCrawler->execute();
- } catch (\Exception $e) {
- log_message("warning", sprintf(
- "\n---%s 오류---\n%s\n-----------------------------------------\n",
- __FUNCTION__,
- $e->getMessage()
- ));
- }
- }
-}
diff --git a/app/Controllers/Mangboard/UserController.php b/app/Controllers/Mangboard/UserController.php
deleted file mode 100644
index 008d514..0000000
--- a/app/Controllers/Mangboard/UserController.php
+++ /dev/null
@@ -1,80 +0,0 @@
-_model === null) {
- $this->_model = new UserModel();
- }
- return $this->_model;
- }
-
- public function point(string $id, string $point, string $sign = "+"): string
- {
- try {
- $entity = is_numeric($id) ? $this->getModel()->getEntityByPK(intval($id)) : $this->getModel()->getEntityByID($id);
- if (!$entity) {
- throw new \Exception("해당 {$id}의 회원이 없습니다.");
- }
- $this->getModel()->setPoint($entity, intval($point), $sign);
- return __FUNCTION__ . " 작업이 완료되었습니다.";
- } catch (\Exception $e) {
- log_message("error", $e->getMessage());
- return $e->getMessage();
- }
- }
- public function level(string $id, string $level): string
- {
- try {
- $entity = is_numeric($id) ? $this->getModel()->getEntityByPK(intval($id)) : $this->getModel()->getEntityByID($id);
- if (!$entity) {
- throw new \Exception("해당 {$id}의 회원이 없습니다.");
- }
- $this->getModel()->setLevel($entity, intval($level));
- log_message("notice", "Mangboard->level 작업이 완료되었습니다.");
- return __FUNCTION__ . " 작업이 완료되었습니다.";
- } catch (\Exception $e) {
- log_message("error", $e->getMessage());
- return $e->getMessage();
- }
- }
-
- public function check_level($id = false): string
- {
- try {
- if (!$id) {
- foreach ($this->getModel()->getEntitys() as $entity) {
- $level = $this->getModel->checkLevel($entity);
- $this->getModel()->setLevel($entity, intval($level));
- }
- } else {
- $entity = is_numeric($id) ? $this->getModel()->getEntityByPK(intval($id)) : $this->getModel()->getEntityByID($id);
- if (!$entity) {
- throw new \Exception("해당 {$id}의 회원이 없습니다.");
- }
- $level = $this->getModel->checkLevel($entity);
- $this->getModel()->setLevel($entity, intval($level));
- }
- return __FUNCTION__ . " 작업이 완료되었습니다.";
- } catch (\Exception $e) {
- log_message("error", $e->getMessage());
- return $e->getMessage();
- }
- }
-}
diff --git a/app/Entities/Mangboard/BoardEntity.php b/app/Entities/Mangboard/BoardEntity.php
deleted file mode 100644
index c408115..0000000
--- a/app/Entities/Mangboard/BoardEntity.php
+++ /dev/null
@@ -1,44 +0,0 @@
-getPK()}|{$this->getTitle()}";
- }
- public function getTitle(): string
- {
- return $this->attributes[BoardModel::TITLE];
- }
- public function setTitle(string $title): void
- {
- $this->attributes[BoardModel::TITLE] = $title;
- }
- //Common Function
-
- public function getPK(): int
- {
- return $this->attributes[BoardModel::PK];
- }
- public function getImagePath(): string
- {
- return $this->attributes['image_path'];
- }
- public function setImagePath(string $image_path): void
- {
- $this->attributes['image_path'] = $image_path;
- }
- public function getContent(): string
- {
- return $this->attributes['content'];
- }
- public function setContent(string $content): void
- {
- $this->attributes['content'] = $content;
- }
-}
diff --git a/app/Entities/Mangboard/BoardsEntity.php b/app/Entities/Mangboard/BoardsEntity.php
deleted file mode 100644
index 6f45045..0000000
--- a/app/Entities/Mangboard/BoardsEntity.php
+++ /dev/null
@@ -1,32 +0,0 @@
-getPK()}|{$this->getTitle()}";
- }
- public function getTitle(): string
- {
- return $this->attributes[BoardsModel::TITLE];
- }
- public function setTitle(string $board_name): void
- {
- $this->attributes[BoardsModel::TITLE] = $board_name;
- }
- //Common Function
-
- public function getPK(): int
- {
- return $this->attributes[BoardsModel::PK];
- }
- public function getListLevel(): int
- {
- return $this->attributes['list_level'];
- }
-}
diff --git a/app/Entities/Mangboard/FileEntity.php b/app/Entities/Mangboard/FileEntity.php
deleted file mode 100644
index 0e908c9..0000000
--- a/app/Entities/Mangboard/FileEntity.php
+++ /dev/null
@@ -1,60 +0,0 @@
-getPK()}|{$this->getPath()}|{$this->getTitle()}|{$this->getMimeType()}}|{$this->getSequence()}번째";
- }
- public function getTitle(): string
- {
- return $this->attributes[FileModel::TITLE];
- }
- public function setTitle(string $file_name): void
- {
- $this->attributes[FileModel::TITLE] = $file_name;
- }
- //Common Function
- public function getPK(): int
- {
- return $this->attributes[FileModel::PK];
- }
- public function getPath(): string
- {
- return $this->attributes['file_path'];
- }
- public function setPath(string $file_path): void
- {
- $this->attributes['file_path'] = $file_path;
- }
- final public function getMimeType(): string
- {
- return $this->attributes['file_type'];
- }
- public function setMimeType(string $mimetype): void
- {
- $this->attributes['file_type'] = $mimetype;
- }
- final public function getSize(): int
- {
- return $this->attributes['file_size'];
- }
- public function setSize(int $file_size): void
- {
- $this->attributes['file_size'] = $file_size;
- }
- //한게시물에 여러개가 있을경우 번호
- final public function getSequence(): int
- {
- return $this->attributes['file_sequence'];
- }
- public function setSequence(int $file_sequence): void
- {
- $this->attributes['file_sequence'] = $file_sequence;
- }
-}
diff --git a/app/Entities/Mangboard/UserEntity.php b/app/Entities/Mangboard/UserEntity.php
deleted file mode 100644
index 561feea..0000000
--- a/app/Entities/Mangboard/UserEntity.php
+++ /dev/null
@@ -1,50 +0,0 @@
-getPK()}|{$this->getID()}|{$this->getTitle()}|lvl:{$this->getLevel()},point:{$this->getPoint()}";
- }
- public function getTitle(): string
- {
- return $this->attributes[UserModel::TITLE];
- }
- public function setTitle(string $title): void
- {
- $this->attributes[UserModel::TITLE] = $title;
- }
- //Common Function
-
- public function getPK(): int
- {
- return $this->attributes[UserModel::PK];
- }
- public function getID(): string
- {
- return $this->attributes['user_id'];
- }
- public function getPoint(): int
- {
- return $this->attributes['user_point'];
- }
- public function setPoint(int $point): void
- {
-
- $this->attributes['user_point'] = $point;
- }
-
- public function getLevel(): int
- {
- return $this->attributes['user_level'];
- }
- public function setLevel(int $value): void
- {
- $this->attributes['user_level'] = $value;
- }
-}
diff --git a/app/Libraries/MyCrawler/Inven.php b/app/Libraries/MyCrawler/Inven.php
deleted file mode 100644
index f3329e0..0000000
--- a/app/Libraries/MyCrawler/Inven.php
+++ /dev/null
@@ -1,120 +0,0 @@
-extract(['data-src']);
- if (count($attributes)) {
- $url = $attributes[0];
- }
- }
- break;
- case 'img':
- default:
- $url = parent::getUrlByMediaType($node, $media_type, $attr);
- break;
- }
- return $url;
- }
- //작성내용
- //
- //
- //
- //
- //
- //

- //

- //

- //

- //

- //
- //
- //
^^
- //
- //
- //
- protected function getDetailSelector(array $listInfo): array
- {
- $response = $this->getMySocket()->getContent($listInfo['detail_url']);
- return array($this->getSelector($response, getenv("inven.view.content.tag")), $listInfo);
- }
- //리스트내용
- //
- //
- //
- // | 1589 |
- //
- //
- // |
- //
- //
- // 배수민
- // |
- // 09-15 |
- // 1,502 |
- // 1 |
- //
- //
- //
- public function execute(): void
- {
- $listInfos = [];
- if ($this->isDebug) {
- $listInfo = [];
- $listInfo['title'] = 'test_title';
- $listInfo['nickname'] = 'test_name';
- $listInfo['hit'] = 1;
- $listInfo['date'] = date("Y-m-d H:i:s");
- $listInfo['detail_url'] = getenv("inven.view.test.url.{$this->getMyStorage()->getBoardName()}");
- $listInfos[] = $listInfo;
- } else {
- $response = $this->getMySocket()->getContent(getenv("inven.list.url.{$this->getMyStorage()->getBoardName()}"));
- $this->getSelector($response, getenv("inven.list.tag.{$this->getMyStorage()->getBoardName()}"))->each(
- function (Crawler $node) use (&$listInfos): void {
- $nickname = $node->filter(getenv("inven.list.item.nickname.tag"))->text();
- $hit = $node->filter(getenv("inven.list.item.hit.tag"))->text();
- $date = date("Y") . "-" . $node->filter(getenv("inven.list.item.date.tag"))->text();
- //title및 detail url
- $link_node = $node->filter(getenv("inven.list.item.link.tag"));
- $detail_url = $link_node->attr("href");
- $title = $link_node->text();
- //title에서 예외사항비교
- if (strpos($title, getenv("inven.list.tag.except.{$this->getMyStorage()->getBoardName()}")) === false) {
- $listInfos[] = ['title' => $title, 'nickname' => $nickname, 'detail_url' => $detail_url, 'date' => $date, 'hit' => $hit];
- }
- }
- );
- }
- if (!count($listInfos)) {
- throw new \Exception("Target URL이 없습니다.");
- }
- $this->list_process(intval(getenv("inven.list.max_limit.{$this->getMyStorage()->getBoardName()}")), $listInfos);
- log_message("notice", __FUNCTION__ . " 작업이 완료되었습니다.");
- }
-}
diff --git a/app/Libraries/MyCrawler/MyCrawler.php b/app/Libraries/MyCrawler/MyCrawler.php
deleted file mode 100644
index bef79b4..0000000
--- a/app/Libraries/MyCrawler/MyCrawler.php
+++ /dev/null
@@ -1,310 +0,0 @@
-_host = $host;
- $this->_board_name = $board_name;
- $this->_user_entity = $user_entity;
- }
- abstract protected function getDetailSelector(array $listInfo): array;
- //-----------------------필수항목-------------------//
- final protected function getMySocket(): WebSocket
- {
- if ($this->_mySocket === null) {
- $this->_mySocket = new WebSocket($this->_host);
- }
- return $this->_mySocket;
- }
- final protected function getMyStorage(): Storage
- {
- if ($this->_myStorage === null) {
- $this->_myStorage = new Storage($this->_board_name, $this->_user_entity);
- }
- return $this->_myStorage;
- }
- final protected function getBoardsEntity(): BoardsEntity
- {
- if ($this->_boards_entity === null) {
- $boardsModel = new BoardsModel();
- $this->_boards_entity = $boardsModel->getEntityByID($this->getMyStorage()->getBoardName());
- if ($this->_boards_entity === null) {
- throw new \Exception(__FUNCTION__ . "=> {$this->getMyStorage()->getBoardName()}에 해당 Board 정보가 존재하지 않습니다.");
- }
- }
- return $this->_boards_entity;
- }
- final protected function getBoardModel(): BoardModel
- {
- if ($this->_board_model === null) {
- $this->_board_model = new BoardModel("mb_" . $this->getMyStorage()->getBoardName());
- }
- return $this->_board_model;
- }
- final protected function getSelector(string $content, string $tag): Crawler
- {
- $crawler = new Crawler($content);
- if ($this->isDebug) {
- log_message("debug", __FUNCTION__ . "=> " . $tag);
- }
- $crawler->filter($tag);
- if ($this->isDebug) {
- log_message("debug", sprintf(
- "\n------------%s HTML-------------\n%s\n-----------------------------------------------------\n",
- __FUNCTION__,
- $crawler->filter($tag)->html()
- ));
- }
- return $crawler->filter($tag);
- }
- protected function changeURLByCrawler(string $url): string
- {
- return preg_match('/^[^?]+/', $url, $matches) ? $matches[0] : null;
- }
- protected function getUrlByMediaType(Crawler $node, string $media_tag, string $attr): null|string
- {
- switch ($media_tag) {
- case 'video':
- $url = $node->attr($attr); //
또는
- if ($url === null) {
- $url = $node->children()->attr("src"); //