public function update()
{
$filename = $this->getTmpPath() . '/v' . $this->getLatestVersion() . '.zip';
if (file_exists($filename)) {
unlink($filename);
}
file_put_contents($filename, fopen('https://github.com/GotCms/GotCms/archive/' . $this->getLatestVersion() . '.zip', 'r'));
$zip = new ZipArchive();
if ($zip->open($filename)) {
$directoryName = $zip->getNameIndex(0);
$zip->extractTo($this->getTmpPath());
$zip->close();
if (is_dir($this->getTmpPath() . '/v' . $this->getLatestVersion())) {
File::removeDirectory($this->getTmpPath() . '/v' . $this->getLatestVersion());
}
rename($this->getTmpPath() . '/' . $directoryName, $this->getTmpPath() . '/v' . $this->getLatestVersion());
unlink($filename);
return true;
}
return false;
}