0: php_network_getaddresses: getaddrinfo failed: Name or service not knownid = $id; if (is_dir('database/'.Topic::PATH.'/'.$id)) { $isExists = true; $content = new String(file_get_contents('database/'.Topic::PATH.'/'.$this->id.'/content')); $author = new User(file_get_contents('database/'.Topic::PATH.'/'.$this->id.'/author')); $title = new String(file_get_contents('database/'.Topic::PATH.'/'.$this->id.'/title')); $lastedit = file_get_contents('database/'.Topic::PATH.'/'.$this->id.'/lastedit'); $posttime = file_get_contents('database/'.Topic::PATH.'/'.$this->id.'/posttime'); } } function isExists() { return $this->isExists; } static function isValid(String $title, String $content, User $author) { if (strlen($title->getText()) < Topic::MIN_TITLE_LENGTH) return Topic::TITLE_TOO_SHORT; if (strlen($title->getText()) > Topic::MAX_TITLE_LENGTH) return Topic::TITLE_TOO_LONG; return Comment::isValid($content, $author); } function getCommentsNumber() { if ($this->isExists()) return count(scandir('database/'.Topic::PATH.'/'.$this->id.'/comment')); return -1; } function getListComments() { $list[] = new Comment(); if ($this->getCommentsNumber() > 0) { $cmid = scandir('database/'.Topic::PATH.'/'.$this->id.'/comment'); for ($i = 0; $i < $this->getCommentsNumber(); $i++) $list[i] = new Comment($cmid[$i]); return $list; } return null; } function getTitle() { return $this->title; } function getID() { return $this->id; } function getContent() { return $this->content; } function getAuthor() { return $this->author; } function getLastEdit() { return $this->lastedit; } function getPostTime() { return $this->posttime; } function setTitle(String $title) { if ($this->isExists()) { Functional::writeFile('database/'.Topic::PATH.'/'.$this->id.'/title', $title->getText(), 'w'); return true; } return false; } function setContent(String $content) { if ($this->isExists()) { if ($this->setLastEdit(time())) { Functional::writeFile('database/'.Topic::PATH.'/'.$this->id.'/content', $content->getText(), 'w'); return true; } } return false; } private function setLastEdit($time) { if ($this->isExists()) { Functional::writeFile('database/'.Topic::PATH.'/'.$this->id.'/lastedit', $time, 'w'); return true; } return false; } private function setAuthor(User $author) { Functional::writeFile('database/'.Topic::PATH.'/'.$this->id.'/author', $author->getID(), 'w'); } static function createTopic(Category $cat, String $title, String $content, User $author) { if (Topic::isValid($title, $content, $author) != NotificationCode::VALID) return Topic::isValid($title, $content, $author); $id = count(scandir('database/'.Topic::PATH)) + 1; $topic = new Topic($id); if ($topic->isExists()) return NotificationCode::CREATE_ERROR; //Tạo topic id mkdir('database/'.Topic::PATH.'/'.$id); //Tạo folder comments cho mỗi topic mkdir('database/'.Topic::PATH.'/'.$id.'/comment'); //Add topic vào category Functional::writeFile('database/'.Category::PATH.'/'.$cat->getID().'/topic/'.$id, '', 'w'); //Create topic $posttime = time(); Functional::writeFile('database/'.Topic::PATH.'/'.$id.'/title', $title->getText(), 'w'); //Ghi title Functional::writeFile('database/'.Topic::PATH.'/'.$id.'/content', $content->getText(), 'w'); //Ghi content Functional::writeFile('database/'.Topic::PATH.'/'.$id.'/author', $author->getID(), 'w'); //Ghi author Functional::writeFile('database/'.Topic::PATH.'/'.$id.'/posttime', $posttime, 'w'); //Ghi posttime Functional::writeFile('database/'.Topic::PATH.'/'.$id.'/lastedit', $posttime, 'w'); //Ghi getLastEdit return NotificationCode::CREATE_SUCCESS; } } ?>0: php_network_getaddresses: getaddrinfo failed: Name or service not known