Skip to content

Commit

Permalink
various html and js fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Maurice Preuß (envoyr) <[email protected]>
  • Loading branch information
envoyr committed Nov 11, 2023
1 parent 3f1b792 commit 287ad84
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 19 deletions.
3 changes: 2 additions & 1 deletion actions/admin/settings/185.spf.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
'settinggroup' => 'spf',
'varname' => 'spf_entry',
'type' => 'text',
'default' => '"v=spf1 a mx -all"',
'string_regexp' => '/^v=spf[a-z0-9:~?\s\.-]+$/i',
'default' => 'v=spf1 a mx -all',
'save_method' => 'storeSettingField'
]
]
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/Install/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public function checkSystem(array $validatedData): void
throw new Exception(lng('error.invalidip', [$serveripv4]));
} elseif (!empty($serveripv6) && (!Validate::validate_ip2($serveripv6, true, '', false, true) || IPTools::is_ipv6($serveripv6) == false)) {
throw new Exception(lng('error.invalidip', [$serveripv6]));
} elseif (!Validate::validateDomain($servername) && !Validate::validateLocalHostname($servername)) {
} elseif (!Validate::validateDomain($servername)) {
throw new Exception(lng('install.errors.servernameneedstobevalid'));
} elseif (posix_getpwnam($httpuser) === false) {
throw new Exception(lng('install.errors.websrvuserdoesnotexist'));
Expand Down
4 changes: 4 additions & 0 deletions lib/Froxlor/UI/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,14 @@ public static function getFormFieldOutput($fieldname, $fielddata): array
if (!$do_show) {
$fielddata['note'] = lng('serversettings.option_requires_otp');
if (!$otp_enabled_system) {
$fielddata['disabled'] = true;
$fielddata['note'] .= '<br>' . lng('2fa.2fa_not_activated');
} elseif (!$otp_enabled_user) {
$fielddata['disabled'] = true;
$fielddata['note'] .= '<br>' . lng('2fa.2fa_not_activated_for_user');
}
// show field in any case
$do_show = true;
}
}

Expand Down
7 changes: 4 additions & 3 deletions lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
/**
* Show nice note if requested domain is "unknown" to froxlor and thus is being lead to its vhost
*/
if ($_SERVER['HTTP_HOST'] != Settings::Get('system.hostname') &&
!filter_var($_SERVER['HTTP_HOST'], FILTER_VALIDATE_IP) && (
if ($_SERVER['SERVER_NAME'] != Settings::Get('system.hostname') &&
!filter_var($_SERVER['SERVER_NAME'], FILTER_VALIDATE_IP) && (
empty(Settings::Get('system.froxloraliases')) ||
(!empty(Settings::Get('system.froxloraliases')) && !in_array($_SERVER['HTTP_HOST'], array_map('trim', explode(',', Settings::Get('system.froxloraliases')))))
(!empty(Settings::Get('system.froxloraliases')) && !in_array($_SERVER['SERVER_NAME'], array_map('trim', explode(',', Settings::Get('system.froxloraliases')))))
)) {
// not the froxlor system-hostname, show info page for domains not configured in froxlor
$unconfiguredPath = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/templates/misc/unconfigured/index.html');
Expand Down Expand Up @@ -346,6 +346,7 @@
if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT', 'PATCH', 'DELETE'])) {
$current_token = $_POST['csrf_token'] ?? $_SERVER['HTTP_X_CSRF_TOKEN'] ?? null;
if ($current_token != CurrentUser::getField('csrf_token')) {
http_response_code(403);
Response::dynamicError('CSRF validation failed');
}
}
Expand Down
1 change: 1 addition & 0 deletions templates/Froxlor/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ window.Chart = Chart;
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
3 changes: 3 additions & 0 deletions templates/Froxlor/assets/js/jquery/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export default function () {
planid: pid
},
dataType: "json",
beforeSend: function(request) {
request.setRequestHeader('X-CSRF-TOKEN', document.querySelector('meta[name="csrf-token"]').getAttribute('content'));
},
success: function (json) {
for (var i in json) {
if (i == 'email_imap' || i == 'email_pop3' || i == 'perlenabled' || i == 'phpenabled' || i == 'dnsenabled' || i == 'logviewenabled') {
Expand Down
6 changes: 3 additions & 3 deletions templates/Froxlor/form/formfields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
{% endmacro %}

{% macro plain(id, field) %}
<input type="text" readonly class="form-control-plaintext" id="{{ id }}" name="{{ id }}" value="{{ field.value|raw|e }}">
<input type="text" readonly class="form-control-plaintext" id="{{ id }}" name="{{ id }}" value="{{ field.value|raw }}">
{% if field.next_to is defined %}
{% for nid, nfield in field.next_to %}
{% if nfield.next_to_prefix is defined %}
Expand All @@ -159,9 +159,9 @@
{% if field.next_to is defined %}
<div class="input-group">
{% endif %}
<input type="{{ field.type }}" {% if field.visible is defined and field.visible == false %} disabled {% endif %} {% if field.type == 'number' and field.min is defined %} min="{{ field.min }}" {% endif %} {% if field.type == 'number' and field.max is defined %} max="{{ field.max }}" {% endif %} {% if field.type != 'number' and field.maxlength is defined %} maxlength="{{ field.maxlength }}" {% endif %} id="{{ id }}" name="{{ id }}" value="{{ field.value|raw|e }}" class="form-control {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.mandatory is defined and field.mandatory %} required {% endif %} {% if field.readonly is defined and field.readonly %} readonly {% endif %} {% if field.autocomplete is defined %} autocomplete="{{ field.autocomplete }}" {% endif %} {% if field.placeholder is defined %} placeholder="{{ field.placeholder }}" {% endif %} {% if field.type == 'file' and field.accept is defined %} accept="{{ field.accept }}" {% endif %} {% if field.pattern is defined %} pattern="{{ field.pattern }}" {% endif %}/>
<input type="{{ field.type }}" {% if field.visible is defined and field.visible == false %} disabled {% endif %} {% if field.type == 'number' and field.min is defined %} min="{{ field.min }}" {% endif %} {% if field.type == 'number' and field.max is defined %} max="{{ field.max }}" {% endif %} {% if field.type != 'number' and field.maxlength is defined %} maxlength="{{ field.maxlength }}" {% endif %} id="{{ id }}" name="{{ id }}" value="{{ field.value|raw }}" class="form-control {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.mandatory is defined and field.mandatory %} required {% endif %} {% if field.readonly is defined and field.readonly %} readonly {% endif %} {% if field.autocomplete is defined %} autocomplete="{{ field.autocomplete }}" {% endif %} {% if field.placeholder is defined %} placeholder="{{ field.placeholder }}" {% endif %} {% if field.type == 'file' and field.accept is defined %} accept="{{ field.accept }}" {% endif %} {% if field.pattern is defined %} pattern="{{ field.pattern }}" {% endif %}/>
{% if field.type == 'hidden' and field.display is defined %}
<input type="text" readonly class="form-control-plaintext" value="{{ field.display|raw|e }}">
<input type="text" readonly class="form-control-plaintext" value="{{ field.display|raw }}">
{% endif %}
{% if field.next_to is defined %}
{% for nid, nfield in field.next_to %}
Expand Down
2 changes: 1 addition & 1 deletion templates/Froxlor/login/enter2fa.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="card-body d-grid gap-2">
<input type="hidden" name="action" value="2fa_verify"/>
<input type="hidden" name="send" value="send"/>
<button class="btn btn-primary rounded-top-0" type="submit" name="2faverify">{{ lng('2fa.2fa_verify') }}</button>
<button class="btn btn-primary" type="submit" name="2faverify">{{ lng('2fa.2fa_verify') }}</button>
</div>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion templates/Froxlor/login/fpwd.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div>

<div class="card-body d-grid gap-2">
<button class="btn btn-primary rounded-top-0" type="submit" name="doremind">{{ lng('login.remind') }}</button>
<button class="btn btn-primary" type="submit" name="doremind">{{ lng('login.remind') }}</button>
</div>

<div class="card-footer">
Expand Down
2 changes: 1 addition & 1 deletion templates/Froxlor/login/login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</div>

<div class="card-body d-grid gap-2">
<button class="btn btn-primary rounded-top-0" type="submit" name="dologin">{{ lng('login.login') }}</button>
<button class="btn btn-primary" type="submit" name="dologin">{{ lng('login.login') }}</button>
</div>

{% if get_setting('panel.allow_preset') == '1' %}
Expand Down
2 changes: 1 addition & 1 deletion templates/Froxlor/login/rpwd.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>

<div class="card-body d-grid gap-2">
<button class="btn btn-primary rounded-top-0" type="submit" name="doremind">{{ lng('login.remind') }}</button>
<button class="btn btn-primary" type="submit" name="doremind">{{ lng('login.remind') }}</button>
</div>

<div class="card-footer">
Expand Down
6 changes: 3 additions & 3 deletions templates/Froxlor/user/2fa.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
<input type="hidden" name="page" value="{{ page }}"/>
<input type="hidden" name="send" value="send"/>
{% if userinfo.type_2fa == 0 %}
<button class="btn btn-primary rounded-top-0" type="submit" name="preadd">
<button class="btn btn-primary" type="submit" name="preadd">
{{ lng('2fa.2fa_add') }}</button>
{% elseif userinfo['2fa_unsaved'] is defined and userinfo['2fa_unsaved'] %}
<button class="btn btn-primary rounded-top-0" type="submit" name="add">
<button class="btn btn-primary" type="submit" name="add">
{{ lng('2fa.2fa_add') }}</button>
{% else %}
<button class="btn btn-warning rounded-top-0" type="submit" name="delete">
<button class="btn btn-warning" type="submit" name="delete">
{{ lng('2fa.2fa_delete') }}</button>
{% endif %}
</div>
Expand Down
6 changes: 3 additions & 3 deletions templates/Froxlor/user/profile.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"/>
<input type="hidden" name="page" value="{{ page }}"/>
<input type="hidden" name="send" value="changepassword"/>
<button class="btn btn-primary rounded-top-0" type="submit" name="dosave">
<button class="btn btn-primary" type="submit" name="dosave">
<i class="fa-regular fa-floppy-disk"></i>
{{ lng('menue.main.changepassword') }}</button>
</div>
Expand Down Expand Up @@ -96,7 +96,7 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"/>
<input type="hidden" name="page" value="{{ page }}"/>
<input type="hidden" name="send" value="changetheme"/>
<button class="btn btn-primary rounded-top-0" type="submit" name="dosave">
<button class="btn btn-primary" type="submit" name="dosave">
<i class="fa-regular fa-floppy-disk"></i>
{{ lng('menue.main.changetheme') }}
</button>
Expand Down Expand Up @@ -130,7 +130,7 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"/>
<input type="hidden" name="page" value="{{ page }}"/>
<input type="hidden" name="send" value="changelanguage"/>
<button class="btn btn-primary rounded-top-0" type="submit" name="dosave">
<button class="btn btn-primary" type="submit" name="dosave">
<i class="fa-regular fa-floppy-disk"></i>
{{ lng('menue.main.changelanguage') }}</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/misc/unconfigured/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>froxlor - Deactivated page</title>
<title>froxlor - Domain not configured</title>
<style>
:root{--primary:#1872a2;--fonts:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"}
body{display:flex;flex-direction:column;background:#f8f9fa;color:#4b5563;align-items:center;justify-content:center;font-family:var(--fonts)}
Expand Down

0 comments on commit 287ad84

Please sign in to comment.