Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Disabled update step and added complete step for update

givanz839c000c4cdb
diff --git a/admin/controller/tools/update.php b/admin/controller/tools/update.php
index 113e55e..925165e 100755
--- a/admin/controller/tools/update.php
+++ b/admin/controller/tools/update.php
@@ -30,7 +30,7 @@ use Vvveb\System\Update as UpdateSys;
use function Vvveb\url;
class Update extends Base {
- private $steps = ['download', 'unzip', 'backup', 'copySystem', 'copyApp', 'copyInstall', 'copyAdmin', 'copyCore', 'copyConfig', 'copyPublic', 'copyPublicAdmin', 'copyPublicMedia', 'setPermissions', 'cleanUp', 'clearCache'];
+ private $steps = ['download', 'unzip', /*'backup',*/ 'copySystem', 'copyApp', 'copyInstall', 'copyAdmin', 'copyCore', 'copyConfig', 'copyPublic', 'copyPublicAdmin', 'copyPublicMedia', 'setPermissions', 'cleanUp', 'clearCache', 'complete'];
function __construct() {
$this->update = new UpdateSys();
@@ -149,10 +149,10 @@ class Update extends Base {
}
function backup() {
+ $result = false;
+
try {
- //$result = $this->update->backup();
- //$install = $this->update->unzip($updateFile);
- $result = true;
+ $result = $this->update->backup();
} catch (\Exception $e) {
$this->view->errors[] = $e->getMessage();
}
@@ -166,6 +166,7 @@ class Update extends Base {
function unzip() {
$errorInstallMsg = __('Error unzipping update!');
+ $result = true;
try {
$updateFile = $this->session->get('updateFile');
@@ -185,6 +186,7 @@ class Update extends Base {
function copyCore() {
$errorInstallMsg = __('Error updating core');
+ $result = false;
try {
$result = $this->update->copyCore();
@@ -203,6 +205,7 @@ class Update extends Base {
function copyConfig() {
$errorInstallMsg = __('Error updating config');
+ $result = false;
try {
$result = $this->update->copyConfig();
@@ -221,6 +224,7 @@ class Update extends Base {
function copySystem() {
$errorInstallMsg = __('Error updating system');
+ $result = false;
try {
$result = $this->update->copySystem();
@@ -239,6 +243,7 @@ class Update extends Base {
function copyApp() {
$errorInstallMsg = __('Error updating app');
+ $result = false;
try {
$result = $this->update->copyApp();
@@ -257,6 +262,7 @@ class Update extends Base {
function copyAdmin() {
$errorInstallMsg = __('Error updating system');
+ $result = false;
try {
$result = $this->update->copyAdmin();
@@ -275,6 +281,7 @@ class Update extends Base {
function copyInstall() {
$errorInstallMsg = __('Error updating install');
+ $result = false;
try {
$result = $this->update->copyInstall();
@@ -293,6 +300,7 @@ class Update extends Base {
function copyPublic() {
$errorInstallMsg = __('Error updating public');
+ $result = false;
try {
$result = $this->update->copyPublic();
@@ -311,6 +319,7 @@ class Update extends Base {
function copyPublicAdmin() {
$errorInstallMsg = __('Error updating public admin');
+ $result = false;
try {
$result = $this->update->copyPublicAdmin();
@@ -329,6 +338,7 @@ class Update extends Base {
function copyPublicMedia() {
$errorInstallMsg = __('Error updating public media');
+ $result = false;
try {
$result = $this->update->copyPublicMedia();
@@ -347,6 +357,7 @@ class Update extends Base {
function setPermissions() {
$errorInstallMsg = __('Error setting permissions');
+ $result = false;
try {
$result = $this->update->setPermissions();
@@ -365,6 +376,7 @@ class Update extends Base {
function cleanUp() {
$errorInstallMsg = __('Error cleaning up');
+ $result = false;
try {
$result = $this->update->cleanup();
@@ -383,6 +395,7 @@ class Update extends Base {
function clearCache() {
$errorInstallMsg = __('Error clearing cache');
+ $result = false;
try {
$result = $this->update->clearCache();
@@ -399,6 +412,12 @@ class Update extends Base {
return $result;
}
+ function complete() {
+ $this->view->success[] = __('Update complete!');
+
+ return true;
+ }
+
function update() {
$this->request->get['step'] = $this->steps[0];
$info = __('Update in progress, do not close this page ...');
diff --git a/system/update.php b/system/update.php
index b94877d..330d91c 100755
--- a/system/update.php
+++ b/system/update.php
@@ -37,7 +37,7 @@ class Update {
protected $zipFile = false;
- function checkUpdates($type = 'core',$force = false) {
+ function checkUpdates($type = 'core', $force = false) {
if ($force) {
//delete update cache
$cacheKey = md5($this->url);
@@ -47,7 +47,7 @@ class Update {
//cache results for one week
try {
- $result = getUrl($this->url, true, 3600 * 24 * 7);
+ $result = getUrl($this->url, true, 604800, 1, false);
} catch (\Exception $e) {
$result = '{}';
}
@@ -101,76 +101,70 @@ class Update {
return true;
}
- function copyAdmin() {
+ private function copyFolder($src, $dest, $skipFolders = []) {
ignore_user_abort(true);
- //$skipFolders = ['plugins', 'public', 'storage'];
- rcopy($this->workDir . DS . 'admin', DIR_ROOT . DS . 'admin');
+
+ if (! is_writable($dest)) {
+ throw new \Exception(sprintf('Folder "%s" not writable!', $dest));
+ }
+ rcopy($src, $dest, $skipFolders);
return true;
}
- function copyApp() {
- ignore_user_abort(true);
+ function copyAdmin() {
//$skipFolders = ['plugins', 'public', 'storage'];
- rcopy($this->workDir . DS . 'app', DIR_ROOT . DS . 'app');
+ $this->copyFolder($this->workDir . DS . 'admin', DIR_ROOT . DS . 'admin');
return true;
}
- function copySystem() {
+ function copyApp() {
ignore_user_abort(true);
//$skipFolders = ['plugins', 'public', 'storage'];
- rcopy($this->workDir . DS . 'system', DIR_ROOT . DS . 'system');
+ $this->copyFolder($this->workDir . DS . 'app', DIR_ROOT . DS . 'app');
return true;
}
+ function copySystem() {
+ return $this->copyFolder($this->workDir . DS . 'system', DIR_ROOT . DS . 'system');
+ }
+
function copyInstall() {
- ignore_user_abort(true);
//$skipFolders = ['plugins', 'public', 'storage'];
- rcopy($this->workDir . DS . 'install', DIR_ROOT . DS . 'install');
-
- return true;
+ return $this->copyFolder($this->workDir . DS . 'install', DIR_ROOT . DS . 'install');
}
function copyCore() {
- ignore_user_abort(true);
$skipFolders = ['plugins', 'public', 'storage', 'system', 'app', 'admin', 'install', 'config', 'env.php'];
- rcopy($this->workDir, DIR_ROOT, $skipFolders);
- return true;
+ return $this->copyFolder($this->workDir, DIR_ROOT, $skipFolders);
}
function copyConfig() {
- ignore_user_abort(true);
$skip = ['plugins.php', 'mail.php', 'sites.php', 'app.php', 'admin.php', 'routes.php', 'env.php'];
- rcopy($this->workDir . DS . 'config', DIR_ROOT . DS . 'config', $skip);
- return true;
+ return $this->copyFolder($this->workDir . DS . 'config', DIR_ROOT . DS . 'config', $skip);
}
function copyPublic() {
- ignore_user_abort(true);
$skipFolders = ['plugins', 'themes', 'admin', 'media'];
- rcopy($this->workDir . DS . 'public', DIR_PUBLIC, $skipFolders);
- return true;
+ return $this->copyFolder($this->workDir . DS . 'public', DIR_PUBLIC, $skipFolders);
}
function copyPublicAdmin() {
ignore_user_abort(true);
$skipFolders = ['plugins'];
- rcopy($this->workDir . DS . 'public' . DS . 'admin', DIR_PUBLIC . DS . 'admin', $skipFolders);
- return true;
+ return $this->copyFolder($this->workDir . DS . 'public' . DS . 'admin', DIR_PUBLIC . DS . 'admin', $skipFolders);
}
function copyPublicMedia() {
- ignore_user_abort(true);
$skipFolders = ['plugins', 'themes', 'admin'];
- rcopy($this->workDir . DS . 'public' . DS . 'media', DIR_PUBLIC . DS . 'media', $skipFolders);
- return true;
+ return $this->copyFolder($this->workDir . DS . 'public' . DS . 'media', DIR_PUBLIC . DS . 'media', $skipFolders);
}
function clearCache() {