Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Subdirectory install support

givanz72f61c229343
diff --git a/admin/controller/editor/code.php b/admin/controller/editor/code.php
index 235d622..3224d70 100755
--- a/admin/controller/editor/code.php
+++ b/admin/controller/editor/code.php
@@ -73,6 +73,10 @@ class Code extends Base {
}
function sanitizeFileName($file, $type) {
+ if (V_SUBDIR_INSTALL && strpos($file, V_SUBDIR_INSTALL) === 0) {
+ $file = substr_replace($file, '', 0, strlen(V_SUBDIR_INSTALL));
+ }
+
$file = preg_replace("@^[\/]public@", '', $file);
if ($type == 'plugins') {
diff --git a/system/traits/media.php b/system/traits/media.php
index 58b7719..7a90a05 100644
--- a/system/traits/media.php
+++ b/system/traits/media.php
@@ -76,7 +76,12 @@ trait Media {
for ($count = 0; $count < $length; $count++) {
$path = sanitizeFileName($this->request->post['mediaPath'] ?? '');
$fileName = sanitizeFileName($files['name'][$count]);
- $path = preg_replace('@^[\\\/]public[\\\/]media|^[\\\/]media|^[\\\/]public@', '', $path);
+
+ if (V_SUBDIR_INSTALL && strpos($path, V_SUBDIR_INSTALL) === 0) {
+ $path = substr_replace($path, '', 0, strlen(V_SUBDIR_INSTALL));
+ }
+
+ $path = preg_replace('@.*[\\\/]public[\\\/]media|.*[\\\/]media|.*[\\\/]public@', '', $path);
$extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1));
if ($files['error'][$count] == UPLOAD_ERR_OK) {