Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Install allows configuration for custom random /admin-0j57bgw login page for admin to protect against password brute force attacks
givanz3037182ba994
diff --git a/index.php b/index.phpindex e624cc7..50fb7ec 100755--- a/index.php+++ b/index.php@@ -39,7 +39,7 @@ function is_installed() {return file_exists(DIR_ROOT . 'config' . DS . 'db.php');}-$installPathRedirect = '/install/index.php';+$installPathRedirect = (V_SUBDIR_INSTALL ? V_SUBDIR_INSTALL : '') . '/install/index.php';if (! defined('APP')) {if (is_installed()) {@@ -52,7 +52,7 @@ if (! defined('APP')) {die(header("Location: $installPathRedirect"));}}-} elseif (! is_installed() && (!defined('APP') || APP != 'install')) {+} elseif (! is_installed() && (! defined('APP') || APP != 'install')) {defined('APP') || define('APP', 'install');if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], 'install') === false) {diff --git a/install/controller/index.php b/install/controller/index.phpindex 8b48cf0..0d088a6 100755--- a/install/controller/index.php+++ b/install/controller/index.php@@ -232,6 +232,9 @@ class Index extends Base {$this->view->count = count($themes);}+ $isRootPublic = (constant('PUBLIC_PATH') == DIRECTORY_SEPARATOR) ? 'true' : 'false';+ $this->view->isRootPublic = $isRootPublic;+if ($this->request->post) {//set admin password$user = $this->request->post['admin'] ?? [];@@ -239,6 +242,7 @@ class Index extends Base {$theme = $this->request->post['theme'] ?? 'landing';$noecommerce = $this->request->post['noecommerce'] ?? false;$hostname = $this->request->post['hostname'] ?? null;+ $adminPath = $this->request->post['admin-path'] ?? false;$user['status'] = 1;$result = Admin::update($user, ['username' => 'admin']);@@ -331,6 +335,22 @@ class Index extends Base {}}+ $error = '';++ if ($isRootPublic && $adminPath &&+ ($adminPath != 'admin' && $adminPath != 'vadmin')) {+ $from = DIR_PUBLIC . 'vadmin';+ $to = DIR_PUBLIC . $adminPath;++ if (@rename($from, $to)) {+ @\Vvveb\set_config('admin.path', $adminPath);+ //if succesful remove failsafe /admin login option+ @unlink(DIR_PUBLIC . 'admin' . DS . 'index.php');+ } else {+ $error = sprintf(__('Renaming admin login path from %s to %s failed! use /admin/index.php path to login'), 'vadmin', $adminPath);+ }+ }+@\Vvveb\set_config('app.cronkey', Str::random(32));@\Vvveb\set_config('app.key', Str::random(32));@@ -339,10 +359,14 @@ class Index extends Base {@\Vvveb\set_config('app.cache.driver', 'APCu');}+ if ($error) {+ $this->view->error[] = $error;+ }+$success = __('Installation succesful!');$this->view->success[] = $success;$admin_path = \Vvveb\adminPath();- $location = preg_replace('@/install.*$@', $admin_path . "?success=$success", ($_SERVER['REQUEST_URI'] ?? ''));+ $location = preg_replace('@/install.*$@', $admin_path . "/index.php?success=$success&errors=$error", ($_SERVER['REQUEST_URI'] ?? ''));header("Location: $location");}diff --git a/install/index.php b/install/index.phpindex f0a2aab..ad4256e 100755--- a/install/index.php+++ b/install/index.php@@ -29,9 +29,9 @@ define('DEBUG', true);define('APP', 'install');-if (! defined('PUBLIC_PATH')) {- define('PUBLIC_PATH', '/public/');- define('PUBLIC_THEME_PATH', '/public/install/');+if (! isset($PUBLIC_PATH)) {+ $PUBLIC_PATH = '/public/';+ $PUBLIC_THEME_PATH = '/public/install/';}define('CRITICAL_EXTENSIONS', ['xml', 'libxml', 'dom', 'pcre']);diff --git a/install/template/common.tpl b/install/template/common.tplindex 03fcc6b..6e195dc 100755--- a/install/template/common.tpl+++ b/install/template/common.tpl@@ -1,4 +1,3 @@-/*body|prepend = <?php var_dump($this);?>*/head base|href = <?php echo Vvveb\themeUrlPath()?>;@@ -95,3 +94,11 @@ if (isset($this->message)) foreach($this->message as $message) {?>@message|after = <?php}?>++++html|addNewAttribute = <?php if (isset($_COOKIE['theme'])) {+ echo 'data-bs-theme="';+ if ($_COOKIE['theme'] == 'dark') echo 'dark'; else if ($_COOKIE['theme'] == 'light') echo 'light';else echo 'auto';+ echo '"';+} ?>\ No newline at end of filediff --git a/public/admin/index.php b/public/admin/index.phpindex 1f07b1b..43b2a00 100755--- a/public/admin/index.php+++ b/public/admin/index.php@@ -20,8 +20,6 @@**/-//define('PUBLIC_PATH', '/');-//define('PUBLIC_THEME_PATH', '/admin/');$PUBLIC_PATH = '/';$PUBLIC_THEME_PATH = '/admin/';diff --git a/public/install/default/css/install.css b/public/install/default/css/install.cssindex be0dc3e..241ea31 100755--- a/public/install/default/css/install.css+++ b/public/install/default/css/install.css@@ -77,6 +77,12 @@ body {border-color:var(--bs-border-color);}+.btn-toggle:hover+{+ border-color:var(--bs-border-color);+ background-color:rgba(var(--bs-body-color-rgb), 0.05);+}+input.form-control{diff --git a/public/install/default/index.html b/public/install/default/index.htmlindex 6481b0a..d0a1066 100755--- a/public/install/default/index.html+++ b/public/install/default/index.html@@ -11,6 +11,7 @@<link href="css/bootstrap.min.css" rel="stylesheet"><link href="css/install.css" rel="stylesheet">+ <link href="../../admin/default/scss/ionicons.css" rel="stylesheet"><style></style>@@ -144,8 +145,11 @@<div class="col-sm-9"><div class="input-group">- <input type="password" class="form-control" id="password" placeholder="Database password" name="password" value="" aria-label="Database password">- <button class="btn btn-sm px-3 btn-toggle" type="button" onclick="togglePasswordInput(this)">🔒</button>+ <input type="password" class="form-control" id="password" placeholder="Database password" name="password" value="" aria-label="Database password">+ <button class="btn btn-sm px-3 btn-toggle fs-5" type="button" onclick="togglePasswordInput(this,'password')">+ <i class="icon-eye-off-outline"></i>+ <!-- 🔒 -->+ </button></div></div></div>@@ -201,19 +205,21 @@document.querySelectorAll('.db-field').forEach(el => el.style.display = display);}- function togglePasswordInput(element) {- var password = document.getElementById("password");+ function togglePasswordInput(element, id) {+ let password = document.getElementById(id);if (password.type == "password") {password.type = "text";- element.innerHTML = "🔓";+ //element.innerHTML = "🔓";+ element.firstElementChild.className = "icon-eye-outline";} else {password.type = "password";- element.innerHTML = "🔒";+ //element.innerHTML = "🔒";+ element.firstElementChild.className = "icon-eye-off-outline";}}</script><script src="../../js/jquery.min.js"></script>- <script type="module" src="../../js/admin.js"></script>+ <script src="../../admin/default/js/theme.js"></script></body></html>diff --git a/public/install/default/install.html b/public/install/default/install.htmlindex 34fe4e6..7882025 100755--- a/public/install/default/install.html+++ b/public/install/default/install.html@@ -11,6 +11,7 @@<link href="css/bootstrap.min.css" rel="stylesheet"><link href="css/install.css" rel="stylesheet">+ <link href="../../admin/default/scss/ionicons.css" rel="stylesheet"><style></style>@@ -126,28 +127,48 @@</div></div><div class="mb-3 row">- <label for="password" class="col-sm-3 col-form-label">Password<br/><span class="small text-muted">Store your password in a safe place</span></label>+ <label for="password" class="col-sm-3 col-form-label">Password</label><div class="col-sm-9">--<div class="input-group mb-3"><input type="text" class="form-control" id="password" placeholder="User password" name="admin[password]" value="" aria-label="User password" autocomplete="new-password">- <button class="btn btn-sm py-0 btn-toggle" type="button" onclick="togglePasswordInput(this)">🔒</button>+ <button class="btn btn-sm py-0 btn-toggle fs-5" type="button" onclick="randomizePassword(this, 'password')">+ <i class="icon-shuffle-outline"></i>+ <!-- 🎲 -->+ </button>+ <button class="btn btn-sm py-0 btn-toggle fs-5" type="button" onclick="togglePasswordInput(this, 'password')">+ <i class="icon-eye-off-outline"></i>+ <!-- 🔒 -->+ </button></div>--</div></div>- <div class="mb-3">- <div class="form-check">- <input type="checkbox" class="form-check-input" name="noecommerce" value="1" id="noecommerce">- <label class="form-check-label" for="noecommerce">- Disable ecommerce- <span class="form-text">(It can be enabled later)</span>- </label>-- </div>- </div>+ <div class="mb-3 row disabled">+ <label for="display_name" class="col-sm-3 col-form-label">Admin login path</label>+ <div class="col-sm-9">+ <div class="input-group">+ <input type="text" class="form-control" id="admin-path" placeholder="Username" name="admin-path" value="admin" required>+ <button class="btn btn-sm py-0 btn-toggle fs-5" id="rand-path-btn" type="button" onclick="randomizeAdminPath()">+ <i class="icon-shuffle-outline"></i>+ <!-- 🎲 -->+ </button>+ </div>+ <span class="small text-muted">Works only if web server document root is /public otherwise the login path is always /admin</span>+ <div class="small text-muted" id="not-public-notice">+ <span>If possible set your document root to /public for better security<span>+ <a href="https://docs.vvveb.com/installation#secure-install">Secure install documentation</a>+ </div>+ </div>+ </div>+ <div class="mb-3">+ <div class="form-check">+ <input type="checkbox" class="form-check-input" name="noecommerce" value="1" id="noecommerce">+ <label class="form-check-label" for="noecommerce">+ Disable ecommerce+ <span class="form-text">(It can be enabled later)</span>+ </label>++ </div>+ </div><div>@@ -218,19 +239,20 @@</div><script>- function togglePasswordInput(element) {- var password = document.getElementById("password");+ function togglePasswordInput(element, id) {+ let password = document.getElementById(id);if (password.type == "password") {password.type = "text";- element.innerHTML = "🔓";+ //element.innerHTML = "🔓";+ element.firstElementChild.className = "icon-eye-outline";} else {password.type = "password";- element.innerHTML = "🔒";+ //element.innerHTML = "🔒";+ element.firstElementChild.className = "icon-eye-off-outline";}}- function randomPassword(length) {- var chars = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+<>ABCDEFGHIJKLMNOP1234567890";+ function randomPassword(length, chars = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+<>ABCDEFGHIJKLMNOP1234567890") {var pass = "";for (var x = 0; x < length; x++) {var i = Math.floor(Math.random() * chars.length);@@ -238,12 +260,29 @@}return pass;}++ function randomizePassword() {+ document.getElementById("password").value = randomPassword(42);+ }++ function randomizeAdminPath() {+ document.getElementById("admin-path").value = 'vadmin-' + randomPassword(8, "abcdefghijklmnopqrstuvwxyz1234567890");+ };- document.getElementById("password").value = randomPassword(24);+ randomizePassword();++ let isRootPublic = {$this->isRootPublic};+ if (isRootPublic) {+ randomizeAdminPath();+ document.getElementById("not-public-notice").remove();+ } else {+ document.getElementById("rand-path-btn").remove();+ document.getElementById("admin-path").disabled = true;+ }</script><script src="../../js/jquery.min.js"></script>- <script type="module" src="../../js/admin.js"></script>+ <script src="../../admin/default/js/theme.js"></script></body></html>diff --git a/public/install/index.php b/public/install/index.phpindex b2949e7..e5d23ba 100755--- a/public/install/index.php+++ b/public/install/index.php@@ -20,7 +20,7 @@**/-define('PUBLIC_PATH', DIRECTORY_SEPARATOR);-define('PUBLIC_THEME_PATH', DIRECTORY_SEPARATOR . 'install/');+$PUBLIC_PATH = '/';+$PUBLIC_THEME_PATH = '/install/';include __DIR__ . '/../../install/index.php';diff --git a/public/vadmin/.htaccess b/public/vadmin/.htaccessnew file mode 100755index 0000000..cd51a1f--- /dev/null+++ b/public/vadmin/.htaccess@@ -0,0 +1,9 @@+<IfModule mod_rewrite.c>+RewriteEngine On++RewriteBase /+RewriteCond %{REQUEST_FILENAME} !-d+RewriteCond %{REQUEST_FILENAME} !-f+RewriteRule ^ index.php [L]+</IfModule>+diff --git a/public/vadmin/index.php b/public/vadmin/index.phpnew file mode 100755index 0000000..43b2a00--- /dev/null+++ b/public/vadmin/index.php@@ -0,0 +1,26 @@+<?php++/**+ * Vvveb+ *+ * Copyright (C) 2022 Ziadin Givan+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++$PUBLIC_PATH = '/';+$PUBLIC_THEME_PATH = '/admin/';++include __DIR__ . '/../../admin/index.php';