Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Code editor theme path fix

givanz683c250de7c7
diff --git a/admin/controller/base.php b/admin/controller/base.php
index 652c17a..90ce623 100755
--- a/admin/controller/base.php
+++ b/admin/controller/base.php
@@ -490,12 +490,20 @@ class Base {
}
if ($errors = $this->session->get('errors')) {
- $view->errors['session'] = $errors;
+ if (is_array($errors)) {
+ $view->errors = ($view->errors ?? []) + $errors;
+ } else {
+ $view->errors['session'] = $errors;
+ }
$this->session->delete('errors');
}
if ($success = $this->session->get('success')) {
- $view->success['session'] = $success;
+ if (is_array($success)) {
+ $view->success = ($view->success ?? []) + $success;
+ } else {
+ $view->success['session'] = $success;
+ }
$this->session->delete('success');
}
@@ -561,9 +569,10 @@ class Base {
protected function requireLogin() {
//return \Vvveb\System\Core\FrontController::redirect('user/login');
//$view = view :: getInstance();
- $admin_path = \Vvveb\adminPath();
- $this->view->redir = $_SERVER['REQUEST_URI'] ?? '';
- $this->view->action = "{$admin_path}index.php?module=user/login";
+ $admin_path = \Vvveb\adminPath();
+ $this->view->redir = $_SERVER['REQUEST_URI'] ?? '';
+ $this->view->adminPath = $admin_path;
+ $this->view->action = "{$admin_path}index.php?module=user/login";
$this->view->template('user/login.html');
die($this->view->render());
diff --git a/admin/controller/editor/code.php b/admin/controller/editor/code.php
index 679ace5..527fa7f 100755
--- a/admin/controller/editor/code.php
+++ b/admin/controller/editor/code.php
@@ -70,11 +70,13 @@ class Code extends Base {
}
function sanitizeFileName($file, $type) {
+ $file = preg_replace("@^[\/]public@", '', $file);
+
if ($type == 'plugins') {
$file = DIR_PLUGINS . preg_replace("@^[\/]plugins[\/]@", '', $file);
} else {
if ($type == 'themes') {
- $file = DIR_THEMES . $file;
+ $file = DIR_THEMES . preg_replace("@^[\/]themes[\/]@", '', $file);
} else {
$file = DIR_PUBLIC . $file;
}
diff --git a/admin/controller/localization/translations.php b/admin/controller/localization/translations.php
index 2c03c8b..af709e8 100755
--- a/admin/controller/localization/translations.php
+++ b/admin/controller/localization/translations.php
@@ -63,7 +63,6 @@ class Translations extends Base {
//use common check po file and parse
$this->domain();
- //var_dump($this->view->translations);
$folder = DIR_ROOT . 'locale' . DS . $view->lang . DS . 'LC_MESSAGES' . DS;
foreach ($translations as $text => $translation) {
diff --git a/admin/controller/media/media.php b/admin/controller/media/media.php
index 3e74aeb..f34e688 100755
--- a/admin/controller/media/media.php
+++ b/admin/controller/media/media.php
@@ -91,12 +91,13 @@ class Media extends Base {
default:
die(__('Unknown errors.'));
}
-
+
$origFilename = $fileName;
- $i = 1;
+ $i = 1;
+
while (file_exists($destination = DIR_MEDIA . $path . DS . $fileName) && ($i++ < 5)) {
$fileName = rand(0, 10000) . '-' . $origFilename;
- };
+ }
if (move_uploaded_file($file['tmp_name'], $destination)) {
if (isset($this->request->post['onlyFilename'])) {
diff --git a/admin/controller/user/login.php b/admin/controller/user/login.php
index dde4363..4ce30fd 100755
--- a/admin/controller/user/login.php
+++ b/admin/controller/user/login.php
@@ -49,7 +49,7 @@ class Login {
}
//$this->checkAlreadyLoggedIn();
- $view = $this->view;
+ $view = $this->view;
$admin = Admin::current();
$admin_path = \Vvveb\adminPath();
@@ -57,28 +57,37 @@ class Login {
return $this->redirect($admin_path);
}
- $this->view->action = $admin_path . 'index.php?module=user/login';
- $this->view->modal = $this->request->get['modal'] ?? false;
+ $this->view->adminPath = $admin_path;
+ $this->view->action = $admin_path . 'index.php?module=user/login';
+ $this->view->modal = $this->request->get['modal'] ?? false;
//$this->session = Session::getInstance();
$language = $this->session->get('language') ?? 'en_US';
setLanguage($language);
+ if (isset($this->request->get['success'])) {
+ $view->success['get'] = htmlentities($this->request->get['success']);
+ }
+
if (isset($this->request->get['errors'])) {
$view->errors['get'] = htmlentities($this->request->get['errors']);
}
if ($errors = $this->session->get('errors')) {
- $view->errors['session'] = $errors;
+ if (is_array($errors)) {
+ $view->errors = ($view->errors ?? []) + $errors;
+ } else {
+ $view->errors['session'] = $errors;
+ }
$this->session->delete('errors');
}
- if (isset($this->request->get['success'])) {
- $view->success['get'] = htmlentities($this->request->get['success']);
- }
-
if ($success = $this->session->get('success')) {
- $view->success['session'] = $success;
+ if (is_array($success)) {
+ $view->success = ($view->success ?? []) + $success;
+ } else {
+ $view->success['session'] = $success;
+ }
$this->session->delete('success');
}
diff --git a/admin/controller/user/reset.php b/admin/controller/user/reset.php
index 8bf6dd3..9a46262 100755
--- a/admin/controller/user/reset.php
+++ b/admin/controller/user/reset.php
@@ -46,7 +46,7 @@ class Reset {
$success = __('Password was reset!');
$this->view->success['login'] = $success;
$this->session->set('success', ['login' => $success]);
- header('Location: ' . url(['module' => 'user/login', 'success' => $success]));
+ header('Location: ' . url(['module' => 'user/login'/*, 'success' => $success*/]));
} else {
$errors = __('Update failed!');
$this->view->errors['login'] = $errors;
@@ -97,7 +97,7 @@ class Reset {
$success = __('A reset email was sent, please use it to reset your password!');
$this->view->success[] = $success;
$this->session->set('success', $success);
- header('Location: ' . url(['module' => 'user/login', 'success' => $success]));
+ header('Location: ' . url(['module' => 'user/login'/* 'success' => $success*/]));
} else {
$this->view->errors['login'] = __('Error sending reset email!');
}