_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); $mySocket = new WebSocket(getenv("yamap.host.url")); $myStorage = new MangboardStorage($board_name, $user_entity); $myCrawler = new Yamap($mySocket, $myStorage); //추가옵션 $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); $mySocket = new WebSocket(getenv("yamoon.host.url")); $myStorage = new MangboardStorage($board_name, $user_entity); $myCrawler = new Yamap($mySocket, $myStorage); //추가옵션 $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); $mySocket = new WebSocket(getenv("sir.host.url")); $myStorage = new MangboardStorage($board_name, $user_entity); $myCrawler = new Yamap($mySocket, $myStorage); //추가옵션 $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); $mySocket = new WebSocket(getenv("inven.host.url")); $myStorage = new MangboardStorage($board_name, $user_entity); $myCrawler = new Yamap($mySocket, $myStorage); //추가옵션 $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() )); } } }