_user_model === null) { return $this->_user_model = new UserModel(); } return $this->_user_model; } public function login(string $id = ""): bool|UserEntity { $host = getenv("mangboard.host.url"); $id = $id == "" ? getenv("mangboard.login.default.id") : $id; $password = getenv("mangboard.login.default.password"); $user_entity = $this->getUserModel()->getEntityByID($id); // $response = $this->getWebLibrary($host)->getResponse( // $host . 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()); // } log_message("notice", "{$id}로 로그인 성공"); return $user_entity; } public function yamap(string $board_name, ...$params): string { try { //1. 사이트 로그인 처리 $user_entity = $this->login(in_array('id', $params) ? $params['id'] : ""); //2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달. $crawler = new YamapCrawler(getenv('yamap.host.url'), $board_name, $user_entity); $crawler->isDebug = in_array('debug', $params); $crawler->isCopy = in_array('copy', $params); $crawler->execute(intval(getenv("yamap.list.max_limit"))); return "완료되었습니다."; } catch (\Exception $e) { log_message("error", $e->getMessage()); return $e->getMessage(); } } public function yamoon(string $board_name, ...$params): string { try { //1. 사이트 로그인 처리 $user_entity = $this->login(in_array('id', $params) ? $params['id'] : ""); //2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달. $crawler = new YamoonCrawler(getenv("yamoon.host.url"), $board_name, $user_entity); $crawler->isDebug = in_array('debug', $params); $crawler->isCopy = in_array('copy', $params); $crawler->execute(intval(getenv("yamoon.list.max_limit"))); return "완료되었습니다."; } catch (\Exception $e) { log_message("error", $e->getMessage()); return $e->getMessage(); } } public function sir(string $board_name, ...$params): string { try { //1. 사이트 로그인 처리 $user_entity = $this->login(in_array('id', $params) ? $params['id'] : ""); //2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달. $crawler = new SirCrawler(getenv("sir.host.url"), $board_name, $user_entity); $crawler->isDebug = in_array('debug', $params); $crawler->isCopy = in_array('copy', $params); $crawler->execute(intval(getenv("sir.list.max_limit"))); return "완료되었습니다."; } catch (\Exception $e) { log_message("error", $e->getMessage()); return $e->getMessage(); } } public function inven(string $board_name, ...$params): string { try { //1. 사이트 로그인 처리 $user_entity = $this->login(in_array('id', $params) ? $params['id'] : ""); //2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달. $crawler = new InvenCrawler(getenv("inven.host.url"), $board_name, $user_entity); $crawler->isDebug = in_array('debug', $params); $crawler->isCopy = in_array('copy', $params); $crawler->execute(); return "완료되었습니다."; } catch (\Exception $e) { log_message("error", $e->getMessage()); return $e->getMessage(); } } }