Compare commits

..

34 Commits

Author SHA1 Message Date
Michael Kaufmann
2c8bdfbbbc set version to 0.10.38 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-09-02 13:23:51 +02:00
Michael Kaufmann
bbe82286aa add security question for deleting api-keys to avoid accidental deletion
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-08-27 15:02:48 +02:00
Michael Kaufmann
13571f1f16 correct Dropdown directory selection; fixes #1044
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-08-16 08:32:43 +02:00
Michael Kaufmann
d6b34cc8f8 set version to 0.10.37 for upcoming release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-08-05 14:36:02 +02:00
Michael Kaufmann
cfda35a36b update sql-users with their corresponding password-hash-algorithm; remove a few notices for empty values in str_replace and others
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-07-17 12:03:37 +02:00
Michael Kaufmann
57ae625d38 use correct version_compare as PHP8+ does not compare correctly
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-07-11 12:35:07 +02:00
Michael Kaufmann
65ab064289 re-enable quota and sieve plugins for dovecot in buster and bullseye config-templates, fixes #1042
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-07-07 15:13:32 +02:00
Michael Kaufmann
e6a6f6f9de rework FileDir::makePathfield() is mode is 'dropdown' to show all directories correctly (depth limited); fixes #1044
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-07-07 14:45:50 +02:00
Michael Kaufmann
a7b91eb1ed fix missing namespace in BackupCron
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-07-05 17:03:45 +02:00
Michael Kaufmann
a2342ad1d2 set version to 0.10.36 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-07-01 10:16:47 +02:00
Michael Kaufmann
add1818723 fix missing mapping for recently added loginname placeholder in ReportsCron; fixes #1039
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-06-29 08:23:40 +02:00
Michael Kaufmann
51c1d648b2 fix passing complex passwords with special characters to mysqldump in backup-cron; fixes #1038
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-06-28 20:06:52 +02:00
Daniel
0fca98c652 Add login header image max-width (#1036) 2022-06-16 07:36:12 +02:00
Michael Kaufmann
3682116ba2 set version to 0.10.35.1 for bugfix release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-06-03 08:58:31 +02:00
Michael Kaufmann
3b99070496 argh, typo in the version to update to
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-06-03 08:57:01 +02:00
Michael Kaufmann
25f20e4a7d set version to 0.10.35 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-06-03 08:28:15 +02:00
Michael Kaufmann
d46b2d1d80 add USERNAME replacer to all email templates; fixes #1032
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-05-31 10:43:39 +02:00
Michael Kaufmann
4750dad9e2 fix wrong number of bound variables when customers_see_all == 0
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-05-25 18:54:15 +02:00
Michael Kaufmann
c6830d8e7a set default-ca for acme.sh after updating acme.sh
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-05-09 08:34:38 +02:00
Michael Kaufmann
10b4de4cf9 remove unused IgnorantRecursiveDirectoryIterator and fix uninitialized variables
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-04-20 15:11:48 +02:00
FliegenKLATSCH
ae39a1759a Silence some php 8.1 warnings (#1029) 2022-04-20 15:09:19 +02:00
Michael Kaufmann
989b4fee0e set version to 0.10.34.1 for upcoming bugfix release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-04-13 12:46:16 +02:00
Michael Kaufmann
7f6810c5bd remove accidentally added character
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-04-03 14:43:37 +02:00
Michael Kaufmann
3fbc9815ea respect domain.writeerrorlog and domain.writeaccesslog when using log-to-pipe
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-04-03 14:34:20 +02:00
Michael Kaufmann
11533c2d75 fix exit statement in cli scripts
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-04-02 18:07:36 +02:00
Michael Kaufmann
652a998188 don't rely on executable flag for php-sessionclean script
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-04-01 12:01:06 +02:00
Michael Kaufmann
4546c00adb validate sql_search and sql_orderby API parameters, set version to 0.10.34 for security release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-04-01 09:27:45 +02:00
FliegenKLATSCH
3c16fab92c Fix distro in postfix smtpd banner (#1014) 2022-03-27 11:10:43 +02:00
FliegenKLATSCH
c8c1f7e691 Set RC 1 if an exception occured (#1013) 2022-03-26 13:54:32 +01:00
Michael Kaufmann
02d0194b9f add empty index.html file to all folders to avoid accidental folder-content disclosure if 'Options Indexes' is set for a (parent)folder containing froxlor in webserver-config
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-03-24 14:30:34 +01:00
Michael Kaufmann
54876efc8c fix sh command in install howto
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-03-08 07:55:31 +01:00
Michael Kaufmann
a2f8d02b16 fix installation for mariadb-10.5; fix warnings for not used feature; thx to Akecheta for the hints and testing
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-03-07 18:40:31 +01:00
Michael Kaufmann
0d45e03f19 fix missing $ for a variable in Lighttpd-class
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-03-07 16:37:40 +01:00
Michael Kaufmann
ae74cdda53 update debian/ubuntu instructions
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2022-03-07 09:28:01 +01:00
866 changed files with 68652 additions and 77791 deletions

View File

@@ -1,19 +0,0 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_style = space
indent_size = 2
[docker-compose.yml]
indent_size = 4

View File

@@ -1,31 +1,57 @@
# Contribution # Contributing
Before you start working on a PR, contact us via IRC in #froxlor on Freenode or
the forum at https://forum.froxlor.org to get a clue whether someone else isn't
already working on it or if we don not want/need this certain change.
Of course, bugfixes are always welcome.
However, at this stage of the 0.9.x branch, we are not looking for new
features or refactoring, especially not the kind which requires changes to a
lot of files.
Please focus on our API based version 0.10.x (current master).
Before you start working on a PR, contact us via [Discord](https://discord.froxlor.org) or the forum at [https://forum.froxlor.org](https://forum.froxlor.org) to get a clue whether someone else isn't already working on it or if we don not want/need this certain change. Of course, bugfixes are always welcome.
Please always focus on the **main** branch of our [Github repository](https://github.com/Froxlor/Froxlor).
## Checklist ## Checklist
General rules for PRs are: General rules for PRs are:
* Please save us all some trouble and unnecessary round-trips by _testing_ your
changes.
* Please save us all some trouble and unnecessary round-trips by _testing_ your changes.
* Re-write your commit history to provide a CLEAN history! * Re-write your commit history to provide a CLEAN history!
* i.e. do not provide PRs which contain a commit that changes something, the next changes it back, a third one changes it again, only a little differently...
* i.e. do not provide PRs which contain a commit that changes something,
the next changes it back, a third one changes it again, only a little
differently...
Thanks! Thanks!
### Service changes
If you make changes to the functionality of service configurations, please make sure your implementation covers all supported services and distributions.
### Webserver changes
If you make changes to the functionality of webserver configuration, please
make sure your implementation covers all supported webservers.
### l10n ### l10n
If you add new language strings, please make sure you add the english fallback strings in `lng/en.php`. If you add new language strings, please make sure you add the english fallback
strings in
* `lng/english.lng.php`
* `install/lng/english.lng.php` (if applicable)
### New settings and database-layout changes ### New settings and database-layout changes
If you add new settings or layout changes, please make sure you add these to
If you add new settings or implement database-changes, please make sure you add these to * `install/froxlor.sql`
* and handle the update (see `install/updates/froxlor/0.10/update_0.10.inc.php`)
* `install/froxlor.sql.php`
* handle the update (see [`install/updates/froxlor/update_2.x.inc.php`](https://github.com/Froxlor/Froxlor/blob/main/install/updates/froxlor/update_2.x.inc.php))
* if you have any question on how update-process works, please contact us * if you have any question on how update-process works, please contact us

View File

@@ -1,20 +1,24 @@
# Bug report vs. support request # Bug report vs. support request
If you're unsure of whether your problem is a bug or a configuration error If you're unsure of whether your problem is a bug or a configuration error
* contact us via IRC in #froxlor on irc.libera.chat * contact us via IRC in #froxlor on irc.libera.chat
* or post a thread in our forum at https://forum.froxlor.org * or post a thread in our forum at https://forum.froxlor.org
As a rule of thumb: before reporting an issue As a rule of thumb: before reporting an issue
* see if it hasn't been [reported](https://github.com/Froxlor/froxlor/issues) (and possibly already been [fixed](https://github.com/Froxlor/froxlor/issues?utf8=✓&q=is:issue%20is:closed)) first * see if it hasn't been [reported](https://github.com/Froxlor/froxlor/issues) (and possibly already been [fixed](https://github.com/Froxlor/froxlor/issues?utf8=✓&q=is:issue%20is:closed)) first
* try with the git master * try with the git master
# Summary # Summary
Please provide a concise summary of the problem you're experiencing... Please provide a concise summary of the problem you're experiencing...
# System information
# System information
* Froxlor version: $version/$gitSHA1 * Froxlor version: $version/$gitSHA1
* Web server: apache2/nginx/lighttpd * Web server: apache2/nginx/lighttpd
* DNS server: Bind/PowerDNS (standalone)/PowerDNS (Bind-backend) * DNS server: Bind/PowerDNS (standalone)/PowerDNS (Bind-backend)
@@ -23,26 +27,37 @@ Please provide a concise summary of the problem you're experiencing...
* FTP server: proftpd/pureftpd * FTP server: proftpd/pureftpd
* OS/Version: ... * OS/Version: ...
# Steps to reproduce # Steps to reproduce
1. 1.
2. 2.
3. 3.
# Expected behavior # Expected behavior
1. 1.
2. 2.
3. 3.
# Actual behavior # Actual behavior
1. 1.
2. 2.
3. 3.
# Log files/log entries
# Log files/log entries
syslog: syslog:
<pre> <pre>
example example

View File

@@ -1,22 +0,0 @@
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/

View File

@@ -35,3 +35,4 @@ Please describe the tests that you ran to verify your changes. Provide instructi
- [ ] My changes generate no new warnings - [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes - [ ] New and existing unit tests pass locally with my changes

View File

@@ -1,4 +1,4 @@
name: build-documentation name: build-docs
on: on:
release: release:
@@ -11,4 +11,4 @@ jobs:
- env: - env:
GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }}
run: | run: |
gh workflow run --repo Froxlor/Documentation build-and-deploy -f type=tags ref=${{github.ref_name}} gh workflow run --repo Froxlor/Documentation build-docs -f ref=${{github.ref_name}}

View File

@@ -8,18 +8,18 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.1'] php-versions: ['7.4', '8.0']
mariadb-version: [10.5, 10.4] mariadb-version: [10.5, 10.4]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
tools: composer:v2 tools: composer:v2
extensions: mbstring, xml, ctype, pdo_mysql, mysql, curl, json, zip, session, filter, posix, openssl, fileinfo, bcmath, gmp extensions: mbstring, xml, ctype, pdo_mysql, mysql, curl, json, zip, session, filter, posix, openssl, fileinfo, bcmath
- name: Install tools - name: Install tools
run: sudo apt-get install -y ant run: sudo apt-get install -y ant
@@ -43,8 +43,7 @@ jobs:
run: | run: |
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE USER 'froxlor010'@'%' IDENTIFIED BY 'fr0xl0r.TravisCI';" mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE USER 'froxlor010'@'%' IDENTIFIED BY 'fr0xl0r.TravisCI';"
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "GRANT ALL ON froxlor010.* TO 'froxlor010'@'%';" mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "GRANT ALL ON froxlor010.* TO 'froxlor010'@'%';"
php -r "echo include('install/froxlor.sql.php');" > /tmp/froxlor.sql mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/froxlor.sql
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < /tmp/froxlor.sql
- name: Run testing - name: Run testing
run: ant quick-build run: ant quick-build

View File

@@ -8,18 +8,18 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.1'] php-versions: ['7.4', '8.0']
mysql-version: [8.0, 5.7] mysql-version: [8.0, 5.7]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
tools: composer:v2 tools: composer:v2
extensions: mbstring, xml, ctype, pdo_mysql, mysql, curl, json, zip, session, filter, posix, openssl, fileinfo, bcmath, gmp extensions: mbstring, xml, ctype, pdo_mysql, mysql, curl, json, zip, session, filter, posix, openssl, fileinfo, bcmath
- name: Install tools - name: Install tools
run: sudo apt-get install -y ant run: sudo apt-get install -y ant
@@ -44,16 +44,14 @@ jobs:
run: | run: |
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE USER 'froxlor010'@'%' IDENTIFIED WITH mysql_native_password BY 'fr0xl0r.TravisCI';" mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE USER 'froxlor010'@'%' IDENTIFIED WITH mysql_native_password BY 'fr0xl0r.TravisCI';"
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "GRANT ALL ON froxlor010.* TO 'froxlor010'@'%';" mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "GRANT ALL ON froxlor010.* TO 'froxlor010'@'%';"
php -r "echo include('install/froxlor.sql.php');" > /tmp/froxlor.sql mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/froxlor.sql
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < /tmp/froxlor.sql
- name: Setup database (5.7) - name: Setup database (5.7)
if: matrix.mysql-version == '5.7' if: matrix.mysql-version == '5.7'
run: | run: |
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE USER 'froxlor010'@'%' IDENTIFIED BY 'fr0xl0r.TravisCI';" mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE USER 'froxlor010'@'%' IDENTIFIED BY 'fr0xl0r.TravisCI';"
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "GRANT ALL ON froxlor010.* TO 'froxlor010'@'%';" mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "GRANT ALL ON froxlor010.* TO 'froxlor010'@'%';"
php -r "echo include('install/froxlor.sql.php');" > /tmp/froxlor.sql mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/froxlor.sql
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < /tmp/froxlor.sql
- name: Run testing - name: Run testing
run: ant quick-build run: ant quick-build

17
.gitignore vendored
View File

@@ -1,28 +1,21 @@
install/update.log install/update.log
install/*.json templates/*
lib/userdata.inc.php lib/userdata.inc.php
lib/userdata.inc.php.bak lib/userdata.inc.php.bak
lib/config.inc.php
logs/* logs/*
!logs/index.html !logs/index.html
.buildpath .buildpath
.project .project
.settings/ .settings/
.test/
*.diff *.diff
*~ *~
.well-known .well-known
.idea .idea
*.iml *.iml
img/ img/
vendor/
node_modules/
fonts/
templates/*
!templates/index.html
!templates/Froxlor/ !templates/Froxlor/
templates/Froxlor/assets/mix-manifest.json !templates/Sparkle/
templates/Froxlor/assets/css/
templates/Froxlor/assets/js/
templates/Froxlor/assets/webfonts/
!templates/misc/ !templates/misc/
templates/Sparkle/assets/css/custom.css
vendor/

64
.travis.yml Normal file
View File

@@ -0,0 +1,64 @@
language: php
dist: bionic
services:
- docker
php:
- 7.3
branches:
only:
- master
- namespaces
matrix:
include:
- php: 7.3
env: "DOCKER_MYSQL_TYPE=mysql DOCKER_MYSQL_VERSION=5.6"
- php: 7.3
env: "DOCKER_MYSQL_TYPE=mysql DOCKER_MYSQL_VERSION=5.7"
- php: 7.3
env: "DOCKER_MYSQL_TYPE=mysql DOCKER_MYSQL_VERSION=8.0 STARTCMD='mysqld --default-authentication-plugin=mysql_native_password'"
- php: 7.3
env: "DOCKER_MYSQL_TYPE=mariadb DOCKER_MYSQL_VERSION=10.3"
- php: 7.3
env: "DOCKER_MYSQL_TYPE=mariadb DOCKER_MYSQL_VERSION=10.4"
addons:
apt:
update: true
before_install:
- export MYSQL_DATABASE=froxlor010
- docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=fr0xl0r.TravisCI -e MYSQL_DATABASE=$MYSQL_DATABASE -p 3306:3306 $DOCKER_MYSQL_TYPE:$DOCKER_MYSQL_VERSION $STARTCMD
- sudo apt-get install -y ant
- >
export tries=0;
export max_tries=20;
while [[ true ]]; do
tries=$((tries + 1));
echo "waiting for database server to start up... [$tries]";
sleep 5;
# Now see that today's table is there, which would indicate that the cron job ran.
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -s -e 'SHOW VARIABLES LIKE "%version%";'
look_exit=$?;
if [[ "$look_exit" = "0" ]]; then echo "Database server successfully started"; break; fi;
if [[ "$tries" -ge "$max_tries" ]]; then echo "Database server did not start in time"; exit 1; break; fi;
done;
install:
- mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE DATABASE IF NOT EXISTS froxlor010;"
- mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "CREATE USER 'froxlor010'@'%' IDENTIFIED BY 'fr0xl0r.TravisCI';"
- mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI -e "GRANT ALL ON froxlor010.* TO 'froxlor010'@'%';"
- mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/froxlor.sql
script:
- ant phpunit-no-coverage
notifications:
irc: "irc.libera.chat#froxlor"
webhooks:
urls:
- https://webhooks.gitter.im/e/bdf91d1c3f745e51f796
on_success: always
on_failure: always
on_start: never

150
2fa.php
View File

@@ -1,46 +1,32 @@
<?php <?php
if (! defined('AREA')) {
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
if (!defined('AREA')) {
header("Location: index.php"); header("Location: index.php");
exit(); exit();
} }
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\FroxlorTwoFactorAuth;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
use Froxlor\PhpHelper;
use Froxlor\User;
if (Settings::Get('2fa.enabled') != '1') { if (Settings::Get('2fa.enabled') != '1') {
Response::dynamicError('2fa.2fa_not_activated'); \Froxlor\UI\Response::dynamic_error("2FA not activated");
} }
/**
* This file is part of the Froxlor project.
* Copyright (c) 2018 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2018-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* @since 0.10.0
*
*/
// This file is being included in admin_index and customer_index // This file is being included in admin_index and customer_index
// and therefore does not need to require lib/init.php // and therefore does not need to require lib/init.php
if (AREA == 'admin') { if (AREA == 'admin') {
@@ -52,103 +38,53 @@ if (AREA == 'admin') {
} }
$success_message = ""; $success_message = "";
$tfa = new FroxlorTwoFactorAuth('Froxlor ' . Settings::Get('system.hostname')); $tfa = new \Froxlor\FroxlorTwoFactorAuth('Froxlor ' . Settings::Get('system.hostname'));
// do the delete and then just show a success-message // do the delete and then just show a success-message
if ($action == 'delete') { if ($action == 'delete') {
Database::pexecute($upd_stmt, [ Database::pexecute($upd_stmt, array(
't2fa' => 0, 't2fa' => 0,
'd2fa' => "", 'd2fa' => "",
'id' => $uid 'id' => $uid
]); ));
Response::standardSuccess('2fa.2fa_removed'); \Froxlor\UI\Response::standard_success($lng['2fa']['2fa_removed']);
} elseif ($action == 'preadd') {
$type = isset($_POST['type_2fa']) ? $_POST['type_2fa'] : '0';
$data = "";
if ($type > 0) {
// generate secret for TOTP
$data = $tfa->createSecret();
$userinfo['type_2fa'] = $type;
$userinfo['data_2fa'] = $data;
$userinfo['2fa_unsaved'] = true;
// if type = email, send a code there for confirmation
if ($type == 1) {
$code = $tfa->getCode($data);
$_mailerror = false;
$mailerr_msg = "";
$replace_arr = [
'CODE' => $code
];
$mail_body = html_entity_decode(PhpHelper::replaceVariables(lng('mails.2fa.mailbody'), $replace_arr));
try {
$mail->Subject = lng('mails.2fa.subject');
$mail->AltBody = $mail_body;
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$mail->AddAddress($userinfo['email'], User::getCorrectUserSalutation($userinfo));
$mail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
Response::dynamicError($mailerr_msg);
}
}
UI::twig()->addGlobal('userinfo', $userinfo);
} else {
Response::dynamicError('Select one of the possible values for 2FA');
}
} elseif ($action == 'add') { } elseif ($action == 'add') {
$type = isset($_POST['type_2fa']) ? $_POST['type_2fa'] : '0'; $type = isset($_POST['type_2fa']) ? $_POST['type_2fa'] : '0';
$data = isset($_POST['data_2fa']) ? $_POST['data_2fa'] : '';
$code = isset($_POST['codevalidation']) ? $_POST['codevalidation'] : '';
// validate if ($type == 0 || $type == 1) {
$result = $tfa->verifyCode($data, $code, 3); $data = "";
if ($result) {
if ($type == 0 || $type == 1) {
// no fixed secret for email validation, the validation code will be set on the fly
$data = "";
}
Database::pexecute($upd_stmt, [
't2fa' => $type,
'd2fa' => $data,
'id' => $uid
]);
Response::standardSuccess('2fa.2fa_added', $filename);
} }
Response::dynamicError('Invalid/wrong code'); if ($type == 2) {
// generate secret for TOTP
$data = $tfa->createSecret();
}
Database::pexecute($upd_stmt, array(
't2fa' => $type,
'd2fa' => $data,
'id' => $uid
));
\Froxlor\UI\Response::standard_success(sprintf($lng['2fa']['2fa_added'], $filename, $s));
} }
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed 2fa::overview"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed 2fa::overview");
$type_select_values = [];
$ga_qrcode = '';
if ($userinfo['type_2fa'] == '0') { if ($userinfo['type_2fa'] == '0') {
// available types // available types
$type_select_values = [ $type_select_values = array(
0 => '-', 0 => '-',
1 => 'E-Mail', 1 => 'E-Mail',
2 => 'Authenticator' 2 => 'Authenticator'
]; );
asort($type_select_values); asort($type_select_values);
$type_select = "";
foreach ($type_select_values as $_val => $_type) {
$type_select .= \Froxlor\UI\HTML::makeoption($_type, $_val);
}
} elseif ($userinfo['type_2fa'] == '1') { } elseif ($userinfo['type_2fa'] == '1') {
// email 2fa enabled // email 2fa enabled
} elseif ($userinfo['type_2fa'] == '2') { } elseif ($userinfo['type_2fa'] == '2') {
// authenticator 2fa enabled // authenticator 2fa enabled
$ga_qrcode = $tfa->getQRCodeImageAsDataUri($userinfo['loginname'], $userinfo['data_2fa']); $ga_qrcode = $tfa->getQRCodeImageAsDataUri($userinfo['loginname'], $userinfo['data_2fa']);
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("2fa/overview", true) . "\";");
UI::view('user/2fa.html.twig', [
'type_select_values' => $type_select_values,
'ga_qrcode' => $ga_qrcode
]);

View File

@@ -1,5 +1,5 @@
[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml/badge.svg?branch=main)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml) [![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml/badge.svg?branch=master)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml)
[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml/badge.svg?branch=main)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml) [![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml/badge.svg?branch=master)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.froxlor.org) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.froxlor.org)
# Froxlor # Froxlor
@@ -10,21 +10,18 @@ Developed by experienced server administrators, this panel simplifies the effort
## Installation ## Installation
### Fast install ### Fast install
1. Ensure that your webserver serves /var/www/html 1. Ensure that your webserver serves /var/www
2. Extract froxlor into /var/www/html 2. Extract froxlor into /var/www
3. Point your browser to http://[ip-of-webserver]/froxlor 3. Point your browser to http://[ip-of-webserver]/froxlor
4. Follow the installer 4. Follow the installer
5. Login as administrator 5. Login as administrator
6. Have fun! 6. Adjust "System > Settings" according to your needs
7. Choose your distribution under "System > Configuration"
If you have chosen to do the configuration by hand during the installation, you have to complete some more steps: 8. Follow the steps for your services
9. Have fun!
1. Adjust "System > Settings" according to your needs
2. Choose your distribution under "System > Configuration"
3. Follow the steps for your services
### Detailed installation ### Detailed installation
https://docs.froxlor.org/latest/general/installation/ https://docs.froxlor.org/general/installation/index.html
## Help ## Help
@@ -57,16 +54,16 @@ May be found in [COPYING](COPYING)
### Tarball ### Tarball
https://files.froxlor.org/releases/froxlor-latest.tar.gz [MD5](https://files.froxlor.org/releases/froxlor-latest.tar.gz.md5) [SHA1](https://files.froxlor.org/releases/froxlor-latest.tar.gz.sha1) https://files.froxlor.org/releases/froxlor-latest.tar.gz [MD5](https://files.froxlor.org/releases/froxlor-latest.tar.gz.md5) [SHA1](https://files.froxlor.org/releases/froxlor-latest.tar.gz.sha1)
### Debian / Ubuntu repository ### Debian / Ubutnu repository
[HowTo](https://docs.froxlor.org/latest/general/installation/apt-package.html) [HowTo](https://docs.froxlor.org/general/installation/aptpackage.html)
#### Debian #### Debian
``` ```
apt-get -y install apt-transport-https lsb-release ca-certificates curl apt-get -y install apt-transport-https lsb-release ca-certificates curl
curl -sSLo /usr/share/keyrings/deb.froxlor.org-froxlor.gpg https://deb.froxlor.org/froxlor.gpg curl -sSLo /usr/share/keyrings/deb.froxlor.org-froxlor.gpg https://deb.froxlor.org/froxlor.gpg
echo sh -c '"deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/debian $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list' sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/debian $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list'
``` ```
#### Ubuntu #### Ubuntu
@@ -74,7 +71,7 @@ echo sh -c '"deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] htt
``` ```
apt-get -y install apt-transport-https lsb-release ca-certificates curl apt-get -y install apt-transport-https lsb-release ca-certificates curl
curl -sSLo /usr/share/keyrings/deb.froxlor.org-froxlor.gpg https://deb.froxlor.org/froxlor.gpg curl -sSLo /usr/share/keyrings/deb.froxlor.org-froxlor.gpg https://deb.froxlor.org/froxlor.gpg
echo sh -c '"deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list' sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list'
``` ```
## Contributing ## Contributing

View File

@@ -1,47 +1,14 @@
# froxlor's Security Policy # Security Policy
Welcome and thanks for taking interest in [froxlor](https://www.froxlor.org)! ## Supported Versions
We are mostly interested in reports by actual froxlor users but all high quality contributions are welcome. Our main and active version is currently 0.10.x. It will receive maintenance and security updates periodically. The older version 0.9.x will not receive any kind of updates. Please update to [0.10.x](https://github.com/Froxlor/Froxlor/wiki/Updating-Froxlor)
Please try your best to describe a clear and realistic impact for your report and please don't open any public issues on GitHub or social media, we're doing our best to respond through huntr as quickly as we can. | Version | Supported |
| ------- | ------------------ |
With that, good luck hacking us ;) | 0.10.x | :white_check_mark: |
| 0.9.x | :x: |
## Supported versions
- ️✅ **2.x** (`main` git-branch)
- ❌ 0.10.x (`0.10.x` git-branch)
- ❌ 0.9.x (`0.9.x`git-branch)
## Qualifying Vulnerabilities
### Vulnerabilities we really care about
- SQL injection bugs
- server-side code execution bugs
- cross-site scripting vulnerabilities
- cross-site request forgery vulnerabilities
- authentication and authorization flaws
- sensitive information disclosure
### Vulnerabilities we accept
Only reproducable issues on a default/clean setup from the latest stable release of a supported version will be accepted.
## Non-Qualifying Vulnerabilities
- Reports from automated tools or scanners
- Theoretical attacks without proof of exploitability
- Attacks that are the result of a third party library should be reported to the library maintainers
- Social engineering
- Reflected file download
- Physical attacks
- Weak SSL/TLS/SSH algorithms or protocols
- Attacks involving physical access to a users device, or involving a device or network thats already seriously compromised (eg man-in-the-middle).
- The user attacks themselves
- anything in `/doc`
- anything in `/tests`
## Reporting a Vulnerability ## Reporting a Vulnerability
If you think you have found a vulnerability in froxlor, please head over to [https://huntr.dev/repos/froxlor/froxlor](https://huntr.dev/repos/froxlor/froxlor) and use the reporting possibilities there as we are funding the prize-pot for froxlor on this platform. Also, please give us appropriate time to fix the issue and build update-packages before publishing anything into the wild. Alternatively you can send us an email to [team@froxlor.org](team@froxlor.org). If you think you have found a vulnerability in froxlor, please send an email to [team@froxlor.org](mailto:team@froxlor.org) with as many information as possible. Also, please give us appropriate time to fix the issue and build update-packages before publishing anything into the wild.

View File

@@ -2,343 +2,329 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Language
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'panel' => array(
'panel' => [ 'title' => $lng['admin']['panelsettings'],
'title' => lng('admin.panelsettings'), 'fields' => array(
'icon' => 'fa-solid fa-chalkboard-user', 'panel_standardlanguage' => array(
'fields' => [ 'label' => array(
'panel_standardlanguage' => [ 'title' => $lng['login']['language'],
'label' => [ 'description' => $lng['serversettings']['language']['description']
'title' => lng('login.language'), ),
'description' => lng('serversettings.language.description')
],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'standardlanguage', 'varname' => 'standardlanguage',
'type' => 'select', 'type' => 'option',
'default' => 'en', 'default' => 'English',
'option_options_method' => [ 'option_mode' => 'one',
'\\Froxlor\\Language', 'option_options_method' => array(
'\\Froxlor\\User',
'getLanguages' 'getLanguages'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_default_theme' => [ 'panel_default_theme' => array(
'label' => [ 'label' => array(
'title' => lng('panel.theme'), 'title' => $lng['panel']['theme'],
'description' => lng('serversettings.default_theme') 'description' => $lng['serversettings']['default_theme']
], ),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'default_theme', 'varname' => 'default_theme',
'type' => 'select', 'type' => 'option',
'default' => 'Froxlor', 'default' => 'Sparkle',
'option_options_method' => [ 'option_mode' => 'one',
'\\Froxlor\\UI\\Panel\\UI', 'option_options_method' => array(
'\\Froxlor\\UI\\Template',
'getThemes' 'getThemes'
], ),
'save_method' => 'storeSettingDefaultTheme' 'save_method' => 'storeSettingDefaultTheme'
], ),
'panel_allow_theme_change_customer' => [ 'panel_allow_theme_change_customer' => array(
'label' => lng('serversettings.panel_allow_theme_change_customer'), 'label' => $lng['serversettings']['panel_allow_theme_change_customer'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_theme_change_customer', 'varname' => 'allow_theme_change_customer',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_allow_theme_change_admin' => [ 'panel_allow_theme_change_admin' => array(
'label' => lng('serversettings.panel_allow_theme_change_admin'), 'label' => $lng['serversettings']['panel_allow_theme_change_admin'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_theme_change_admin', 'varname' => 'allow_theme_change_admin',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_natsorting' => [ 'panel_natsorting' => array(
'label' => lng('serversettings.natsorting'), 'label' => $lng['serversettings']['natsorting'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'natsorting', 'varname' => 'natsorting',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'panel_paging' => array(
'panel_paging' => [ 'label' => $lng['serversettings']['paging'],
'label' => lng('serversettings.paging'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'paging', 'varname' => 'paging',
'type' => 'number', 'type' => 'int',
'min' => 0, 'int_min' => 0,
'default' => 0, 'default' => 0,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_pathedit' => [ 'panel_pathedit' => array(
'label' => lng('serversettings.pathedit'), 'label' => $lng['serversettings']['pathedit'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'pathedit', 'varname' => 'pathedit',
'type' => 'select', 'type' => 'option',
'default' => 'Manual', 'default' => 'Manual',
'select_var' => [ 'option_mode' => 'one',
'Manual' => lng('serversettings.manual'), 'option_options' => array(
'Dropdown' => lng('serversettings.dropdown') 'Manual' => $lng['serversettings']['manual'],
], 'Dropdown' => $lng['serversettings']['dropdown']
),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_adminmail' => [ 'panel_adminmail' => array(
'label' => lng('serversettings.adminmail'), 'label' => $lng['serversettings']['adminmail'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'adminmail', 'varname' => 'adminmail',
'type' => 'email', 'type' => 'string',
'string_emptyallowed' => true, 'string_type' => 'mail',
'string_emptyallowed' => false,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_adminmail_defname' => [ 'panel_adminmail_defname' => array(
'label' => lng('serversettings.adminmail_defname'), 'label' => $lng['serversettings']['adminmail_defname'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'adminmail_defname', 'varname' => 'adminmail_defname',
'type' => 'text', 'type' => 'string',
'default' => 'Froxlor Administrator', 'default' => 'Froxlor Administrator',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_adminmail_return' => [ 'panel_adminmail_return' => array(
'label' => lng('serversettings.adminmail_return'), 'label' => $lng['serversettings']['adminmail_return'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'adminmail_return', 'varname' => 'adminmail_return',
'type' => 'email', 'type' => 'string',
'string_type' => 'mail',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'panel_decimal_places' => array(
'panel_decimal_places' => [ 'label' => $lng['serversettings']['decimal_places'],
'label' => lng('serversettings.decimal_places'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'decimal_places', 'varname' => 'decimal_places',
'type' => 'number', 'type' => 'int',
'min' => 0, 'int_min' => 0,
'max' => 15, 'int_max' => 15,
'default' => 4, 'default' => 4,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'panel_phpmyadmin_url' => array(
'panel_phpmyadmin_url' => [ 'label' => $lng['serversettings']['phpmyadmin_url'],
'label' => lng('serversettings.phpmyadmin_url'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'phpmyadmin_url', 'varname' => 'phpmyadmin_url',
'type' => 'url', 'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_webmail_url' => [ 'panel_webmail_url' => array(
'label' => lng('serversettings.webmail_url'), 'label' => $lng['serversettings']['webmail_url'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'webmail_url', 'varname' => 'webmail_url',
'type' => 'url', 'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_webftp_url' => [ 'panel_webftp_url' => array(
'label' => lng('serversettings.webftp_url'), 'label' => $lng['serversettings']['webftp_url'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'webftp_url', 'varname' => 'webftp_url',
'type' => 'url', 'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'admin_show_version_login' => [ 'admin_show_version_login' => array(
'label' => lng('admin.show_version_login'), 'label' => $lng['admin']['show_version_login'],
'settinggroup' => 'admin', 'settinggroup' => 'admin',
'varname' => 'show_version_login', 'varname' => 'show_version_login',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'admin_show_version_footer' => array(
'admin_show_version_footer' => [ 'label' => $lng['admin']['show_version_footer'],
'label' => lng('admin.show_version_footer'),
'settinggroup' => 'admin', 'settinggroup' => 'admin',
'varname' => 'show_version_footer', 'varname' => 'show_version_footer',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'admin_show_news_feed' => [ 'admin_show_news_feed' => array(
'label' => lng('admin.show_news_feed'), 'label' => $lng['admin']['show_news_feed'],
'settinggroup' => 'admin', 'settinggroup' => 'admin',
'varname' => 'show_news_feed', 'varname' => 'show_news_feed',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'customer_show_news_feed' => [ 'customer_show_news_feed' => array(
'label' => lng('admin.customer_show_news_feed'), 'label' => $lng['admin']['customer_show_news_feed'],
'settinggroup' => 'customer', 'settinggroup' => 'customer',
'varname' => 'show_news_feed', 'varname' => 'show_news_feed',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'customer_news_feed_url' => [ 'customer_news_feed_url' => array(
'label' => lng('admin.customer_news_feed_url'), 'label' => $lng['admin']['customer_news_feed_url'],
'settinggroup' => 'customer', 'settinggroup' => 'customer',
'varname' => 'news_feed_url', 'varname' => 'news_feed_url',
'type' => 'url', 'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_allow_domain_change_admin' => [ 'panel_allow_domain_change_admin' => array(
'label' => lng('serversettings.panel_allow_domain_change_admin'), 'label' => $lng['serversettings']['panel_allow_domain_change_admin'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_domain_change_admin', 'varname' => 'allow_domain_change_admin',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'panel_allow_domain_change_customer' => array(
'panel_allow_domain_change_customer' => [ 'label' => $lng['serversettings']['panel_allow_domain_change_customer'],
'label' => lng('serversettings.panel_allow_domain_change_customer'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_domain_change_customer', 'varname' => 'allow_domain_change_customer',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'panel_phpconfigs_hidestdsubdomain' => array(
'panel_phpconfigs_hidesubdomains' => [ 'label' => $lng['serversettings']['panel_phpconfigs_hidestdsubdomain'],
'label' => lng('serversettings.panel_phpconfigs_hidesubdomains'),
'settinggroup' => 'panel',
'varname' => 'phpconfigs_hidesubdomains',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'panel_phpconfigs_hidestdsubdomain' => [
'label' => lng('serversettings.panel_phpconfigs_hidestdsubdomain'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'phpconfigs_hidestdsubdomain', 'varname' => 'phpconfigs_hidestdsubdomain',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'panel_customer_hide_options' => array(
'panel_customer_hide_options' => [ 'label' => $lng['serversettings']['panel_customer_hide_options'],
'label' => lng('serversettings.panel_customer_hide_options'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'customer_hide_options', 'varname' => 'customer_hide_options',
'type' => 'select', 'type' => 'option',
'default' => '', 'default' => '',
'select_mode' => 'multiple', 'option_mode' => 'multiple',
'option_emptyallowed' => true, 'option_emptyallowed' => true,
'select_var' => [ 'option_options' => array(
'email' => lng('menue.email.email'), 'email' => $lng['menue']['email']['email'],
'mysql' => lng('menue.mysql.mysql'), 'mysql' => $lng['menue']['mysql']['mysql'],
'domains' => lng('menue.domains.domains'), 'domains' => $lng['menue']['domains']['domains'],
'ftp' => lng('menue.ftp.ftp'), 'ftp' => $lng['menue']['ftp']['ftp'],
'extras' => lng('menue.extras.extras'), 'extras' => $lng['menue']['extras']['extras'],
'extras.directoryprotection' => lng('menue.extras.extras') . " / " . lng('menue.extras.directoryprotection'), 'extras.directoryprotection' => $lng['menue']['extras']['extras'] . " / " . $lng['menue']['extras']['directoryprotection'],
'extras.pathoptions' => lng('menue.extras.extras') . " / " . lng('menue.extras.pathoptions'), 'extras.pathoptions' => $lng['menue']['extras']['extras'] . " / " . $lng['menue']['extras']['pathoptions'],
'extras.logger' => lng('menue.extras.extras') . " / " . lng('menue.logger.logger'), 'extras.logger' => $lng['menue']['extras']['extras'] . " / " . $lng['admin']['loggersystem'],
'extras.backup' => lng('menue.extras.extras') . " / " . lng('menue.extras.backup'), 'extras.backup' => $lng['menue']['extras']['extras'] . " / " . $lng['menue']['extras']['backup'],
'traffic' => lng('menue.traffic.traffic'), 'traffic' => $lng['menue']['traffic']['traffic'],
'traffic.http' => lng('menue.traffic.traffic') . " / HTTP", 'traffic.http' => $lng['menue']['traffic']['traffic'] . " / HTTP",
'traffic.ftp' => lng('menue.traffic.traffic') . " / FTP", 'traffic.ftp' => $lng['menue']['traffic']['traffic'] . " / FTP",
'traffic.mail' => lng('menue.traffic.traffic') . " / Mail", 'traffic.mail' => $lng['menue']['traffic']['traffic'] . " / Mail"
'misc.documentation' => lng('admin.documentation'), ),
], 'save_method' => 'storeSettingField'
'save_method' => 'storeSettingField', ),
'advanced_mode' => true 'panel_imprint_url' => array(
], 'label' => $lng['serversettings']['imprint_url'],
'panel_imprint_url' => [
'label' => lng('serversettings.imprint_url'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'imprint_url', 'varname' => 'imprint_url',
'type' => 'url', 'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_terms_url' => [ 'panel_terms_url' => array(
'label' => lng('serversettings.terms_url'), 'label' => $lng['serversettings']['terms_url'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'terms_url', 'varname' => 'terms_url',
'type' => 'url', 'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_privacy_url' => [ 'panel_privacy_url' => array(
'label' => lng('serversettings.privacy_url'), 'label' => $lng['serversettings']['privacy_url'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'privacy_url', 'varname' => 'privacy_url',
'type' => 'url', 'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_logo_overridetheme' => [ 'panel_logo_overridetheme' => array(
'label' => lng('serversettings.logo_overridetheme'), 'label' => $lng['serversettings']['logo_overridetheme'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'logo_overridetheme', 'varname' => 'logo_overridetheme',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_logo_overridecustom' => [ 'panel_logo_overridecustom' => array(
'label' => lng('serversettings.logo_overridecustom'), 'label' => $lng['serversettings']['logo_overridecustom'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'logo_overridecustom', 'varname' => 'logo_overridecustom',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_logo_image_header' => [ 'panel_logo_image_header' => array(
'label' => lng('serversettings.logo_image_header'), 'label' => $lng['serversettings']['logo_image_header'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'logo_image_header', 'varname' => 'logo_image_header',
'type' => 'image', 'type' => 'image',
'accept' => 'image/jpeg, image/jpg, image/png, image/gif',
'image_name' => 'logo_header', 'image_name' => 'logo_header',
'default' => '', 'default' => '',
'save_method' => 'storeSettingImage' 'save_method' => 'storeSettingImage'
], ),
'panel_logo_image_login' => [ 'panel_logo_image_login' => array(
'label' => lng('serversettings.logo_image_login'), 'label' => $lng['serversettings']['logo_image_login'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'logo_image_login', 'varname' => 'logo_image_login',
'type' => 'image', 'type' => 'image',
'accept' => 'image/jpeg, image/jpg, image/png, image/gif',
'image_name' => 'logo_login', 'image_name' => 'logo_login',
'default' => '', 'default' => '',
'save_method' => 'storeSettingImage' 'save_method' => 'storeSettingImage'
] ),
] )
] )
] )
]; );
?>

View File

@@ -2,236 +2,224 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'accounts' => array(
'accounts' => [ 'title' => $lng['admin']['accountsettings'],
'title' => lng('admin.accountsettings'), 'fields' => array(
'icon' => 'fa-solid fa-users-gear', 'session_sessiontimeout' => array(
'fields' => [ 'label' => $lng['serversettings']['session_timeout'],
'session_sessiontimeout' => [
'label' => lng('serversettings.session_timeout'),
'settinggroup' => 'session', 'settinggroup' => 'session',
'varname' => 'sessiontimeout', 'varname' => 'sessiontimeout',
'type' => 'number', 'type' => 'int',
'min' => 60,
'default' => 600, 'default' => 600,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'session_allow_multiple_login' => [ 'session_allow_multiple_login' => array(
'label' => lng('serversettings.session_allow_multiple_login'), 'label' => $lng['serversettings']['session_allow_multiple_login'],
'settinggroup' => 'session', 'settinggroup' => 'session',
'varname' => 'allow_multiple_login', 'varname' => 'allow_multiple_login',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'login_domain_login' => [ 'login_domain_login' => array(
'label' => lng('serversettings.login_domain_login'), 'label' => $lng['serversettings']['login_domain_login'],
'settinggroup' => 'login', 'settinggroup' => 'login',
'varname' => 'domain_login', 'varname' => 'domain_login',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'login_maxloginattempts' => [ 'login_maxloginattempts' => array(
'label' => lng('serversettings.maxloginattempts'), 'label' => $lng['serversettings']['maxloginattempts'],
'settinggroup' => 'login', 'settinggroup' => 'login',
'varname' => 'maxloginattempts', 'varname' => 'maxloginattempts',
'type' => 'number', 'type' => 'int',
'min' => 1,
'default' => 3, 'default' => 3,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'login_deactivatetime' => [ 'login_deactivatetime' => array(
'label' => lng('serversettings.deactivatetime'), 'label' => $lng['serversettings']['deactivatetime'],
'settinggroup' => 'login', 'settinggroup' => 'login',
'varname' => 'deactivatetime', 'varname' => 'deactivatetime',
'type' => 'number', 'type' => 'int',
'min' => 0,
'default' => 900, 'default' => 900,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'2fa_enabled' => [ '2fa_enabled' => array(
'label' => lng('2fa.2fa_enabled'), 'label' => $lng['2fa']['2fa_enabled'],
'settinggroup' => '2fa', 'settinggroup' => '2fa',
'varname' => 'enabled', 'varname' => 'enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_password_min_length' => [ 'panel_password_min_length' => array(
'label' => lng('serversettings.panel_password_min_length'), 'label' => $lng['serversettings']['panel_password_min_length'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'password_min_length', 'varname' => 'password_min_length',
'type' => 'number', 'type' => 'int',
'min' => 0,
'default' => 0, 'default' => 0,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_password_alpha_lower' => [ 'panel_password_alpha_lower' => array(
'label' => lng('serversettings.panel_password_alpha_lower'), 'label' => $lng['serversettings']['panel_password_alpha_lower'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'password_alpha_lower', 'varname' => 'password_alpha_lower',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_password_alpha_upper' => [ 'panel_password_alpha_upper' => array(
'label' => lng('serversettings.panel_password_alpha_upper'), 'label' => $lng['serversettings']['panel_password_alpha_upper'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'password_alpha_upper', 'varname' => 'password_alpha_upper',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_password_numeric' => [ 'panel_password_numeric' => array(
'label' => lng('serversettings.panel_password_numeric'), 'label' => $lng['serversettings']['panel_password_numeric'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'password_numeric', 'varname' => 'password_numeric',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_password_special_char_required' => [ 'panel_password_special_char_required' => array(
'label' => lng('serversettings.panel_password_special_char_required'), 'label' => $lng['serversettings']['panel_password_special_char_required'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'password_special_char_required', 'varname' => 'password_special_char_required',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_password_special_char' => [ 'panel_password_special_char' => array(
'label' => lng('serversettings.panel_password_special_char'), 'label' => $lng['serversettings']['panel_password_special_char'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'password_special_char', 'varname' => 'password_special_char',
'type' => 'text', 'type' => 'string',
'default' => '!?<>§$%+#=@', 'default' => '!?<>§$%+#=@',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_password_regex' => [ 'panel_password_regex' => array(
'label' => lng('serversettings.panel_password_regex'), 'label' => $lng['serversettings']['panel_password_regex'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'password_regex', 'varname' => 'password_regex',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'customer_accountprefix' => array(
'customer_accountprefix' => [ 'label' => $lng['serversettings']['accountprefix'],
'label' => lng('serversettings.accountprefix'),
'settinggroup' => 'customer', 'settinggroup' => 'customer',
'varname' => 'accountprefix', 'varname' => 'accountprefix',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkUsername' 'checkUsername'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'customer_mysqlprefix' => [ 'customer_mysqlprefix' => array(
'label' => lng('serversettings.mysqlprefix'), 'label' => $lng['serversettings']['mysqlprefix'],
'settinggroup' => 'customer', 'settinggroup' => 'customer',
'varname' => 'mysqlprefix', 'varname' => 'mysqlprefix',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkUsername' 'checkUsername'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'customer_ftpprefix' => [ 'customer_ftpprefix' => array(
'label' => lng('serversettings.ftpprefix'), 'label' => $lng['serversettings']['ftpprefix'],
'settinggroup' => 'customer', 'settinggroup' => 'customer',
'varname' => 'ftpprefix', 'varname' => 'ftpprefix',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'customer_ftpatdomain' => [ 'customer_ftpatdomain' => array(
'label' => lng('serversettings.ftpdomain'), 'label' => $lng['serversettings']['ftpdomain'],
'settinggroup' => 'customer', 'settinggroup' => 'customer',
'varname' => 'ftpatdomain', 'varname' => 'ftpatdomain',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'panel_allow_preset' => [ 'panel_allow_preset' => array(
'label' => lng('serversettings.allow_password_reset'), 'label' => $lng['serversettings']['allow_password_reset'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_preset', 'varname' => 'allow_preset',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'dependency' => [ 'dependency' => array(
'fieldname' => 'panel_allow_preset_admin', 'fieldname' => 'panel_allow_preset_admin',
'fielddata' => [ 'fielddata' => array(
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_preset_admin' 'varname' => 'allow_preset_admin'
], ),
'onlyif' => 0 'onlyif' => 0
] )
], ),
'panel_allow_preset_admin' => [ 'panel_allow_preset_admin' => array(
'label' => lng('serversettings.allow_password_reset_admin'), 'label' => $lng['serversettings']['allow_password_reset_admin'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_preset_admin', 'varname' => 'allow_preset_admin',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'dependency' => [ 'dependency' => array(
'fieldname' => 'panel_allow_preset', 'fieldname' => 'panel_allow_preset',
'fielddata' => [ 'fielddata' => array(
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_preset' 'varname' => 'allow_preset'
], ),
'onlyif' => 1 'onlyif' => 1
] )
], ),
'system_backupenabled' => [ 'system_backupenabled' => array(
'label' => lng('serversettings.backupenabled'), 'label' => $lng['serversettings']['backupenabled'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'backupenabled', 'varname' => 'backupenabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'cronmodule' => 'froxlor/backup', 'cronmodule' => 'froxlor/backup',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_createstdsubdom_default' => [ 'system_createstdsubdom_default' => array(
'label' => lng('serversettings.createstdsubdom_default'), 'label' => $lng['serversettings']['createstdsubdom_default'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'createstdsubdom_default', 'varname' => 'createstdsubdom_default',
'type' => 'select', 'type' => 'option',
'default' => '1', 'default' => '1',
'select_var' => [ 'option_mode' => 'one',
'0' => lng('panel.no'), 'option_options' => array(
'1' => lng('panel.yes') '0' => $lng['panel']['no'],
], '1' => $lng['panel']['yes']
),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
] )
] )
] )
]; );

View File

@@ -2,333 +2,297 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'system' => array(
'system' => [ 'title' => $lng['admin']['systemsettings'],
'title' => lng('admin.systemsettings'), 'fields' => array(
'icon' => 'fa-solid fa-gears', 'system_documentroot_prefix' => array(
'fields' => [ 'label' => $lng['serversettings']['documentroot_prefix'],
'system_documentroot_prefix' => [
'label' => lng('serversettings.documentroot_prefix'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'documentroot_prefix', 'varname' => 'documentroot_prefix',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/webs/', 'default' => '/var/customers/webs/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkPathConflicts' 'checkPathConflicts'
], )
'requires_reconf' => ['http'] ),
], 'system_documentroot_use_default_value' => array(
'system_documentroot_use_default_value' => [ 'label' => $lng['serversettings']['documentroot_use_default_value'],
'label' => lng('serversettings.documentroot_use_default_value'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'documentroot_use_default_value', 'varname' => 'documentroot_use_default_value',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_ipaddress' => [ 'system_ipaddress' => array(
'label' => lng('serversettings.ipaddress'), 'label' => $lng['serversettings']['ipaddress'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ipaddress', 'varname' => 'ipaddress',
'type' => 'select', 'type' => 'option',
'option_options_method' => [ 'option_mode' => 'one',
'option_options_method' => array(
'\\Froxlor\\Domain\\IpAddr', '\\Froxlor\\Domain\\IpAddr',
'getIpAddresses' 'getIpAddresses'
], ),
'default' => '', 'default' => '',
'save_method' => 'storeSettingIpAddress' 'save_method' => 'storeSettingIpAddress'
], ),
'system_defaultip' => [ 'system_defaultip' => array(
'label' => lng('serversettings.defaultip'), 'label' => $lng['serversettings']['defaultip'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'defaultip', 'varname' => 'defaultip',
'type' => 'select', 'type' => 'option',
'select_mode' => 'multiple', 'option_mode' => 'multiple',
'option_options_method' => [ 'option_options_method' => array(
'\\Froxlor\\Domain\\IpAddr', '\\Froxlor\\Domain\\IpAddr',
'getIpPortCombinations' 'getIpPortCombinations'
], ),
'default' => '', 'default' => '',
'save_method' => 'storeSettingDefaultIp' 'save_method' => 'storeSettingDefaultIp'
], ),
'system_defaultsslip' => [ 'system_defaultsslip' => array(
'label' => lng('serversettings.defaultsslip'), 'label' => $lng['serversettings']['defaultsslip'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'defaultsslip', 'varname' => 'defaultsslip',
'type' => 'select', 'type' => 'option',
'select_mode' => 'multiple', 'option_mode' => 'multiple',
'option_options_method' => [ 'option_options_method' => array(
'\\Froxlor\\Domain\\IpAddr', '\\Froxlor\\Domain\\IpAddr',
'getSslIpPortCombinations' 'getSslIpPortCombinations'
], ),
'default' => '', 'default' => '',
'save_method' => 'storeSettingDefaultSslIp' 'save_method' => 'storeSettingDefaultSslIp'
], ),
'system_hostname' => [ 'system_hostname' => array(
'label' => lng('serversettings.hostname'), 'label' => $lng['serversettings']['hostname'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'hostname', 'varname' => 'hostname',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingHostname', 'save_method' => 'storeSettingHostname',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkHostname' 'checkHostname'
] )
], ),
'api_enabled' => [ 'api_enabled' => array(
'label' => lng('serversettings.enable_api'), 'label' => $lng['serversettings']['enable_api'],
'settinggroup' => 'api', 'settinggroup' => 'api',
'varname' => 'enabled', 'varname' => 'enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'api_customer_default' => [ 'system_validatedomain' => array(
'label' => lng('serversettings.api_customer_default'), 'label' => $lng['serversettings']['validate_domain'],
'settinggroup' => 'api',
'varname' => 'customer_default',
'type' => 'select',
'default' => 1,
'select_var' => [
1 => lng('panel.yes'),
0 => lng('panel.no')
],
'save_method' => 'storeSettingField'
],
'system_update_channel' => [
'label' => lng('serversettings.update_channel'),
'settinggroup' => 'system',
'varname' => 'update_channel',
'type' => 'select',
'default' => 'stable',
'select_var' => [
'stable' => lng('serversettings.uc_stable'),
'testing' => lng('serversettings.uc_testing')
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_validate_domain' => [
'label' => lng('serversettings.validate_domain'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'validate_domain', 'varname' => 'validate_domain',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_stdsubdomain' => [ 'system_stdsubdomain' => array(
'label' => lng('serversettings.stdsubdomainhost'), 'label' => $lng['serversettings']['stdsubdomainhost'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'stdsubdomain', 'varname' => 'stdsubdomain',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingHostname' 'save_method' => 'storeSettingHostname'
], ),
'system_mysql_access_host' => [ 'system_mysql_access_host' => array(
'label' => lng('serversettings.mysql_access_host'), 'label' => $lng['serversettings']['mysql_access_host'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mysql_access_host', 'varname' => 'mysql_access_host',
'type' => 'text', 'type' => 'string',
'default' => '127.0.0.1,localhost', 'default' => '127.0.0.1,localhost',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkMysqlAccessHost' 'checkMysqlAccessHost'
], ),
'save_method' => 'storeSettingMysqlAccessHost' 'save_method' => 'storeSettingMysqlAccessHost'
], ),
'system_nssextrausers' => [ 'system_nssextrausers' => array(
'label' => lng('serversettings.nssextrausers'), 'label' => $lng['serversettings']['nssextrausers'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'nssextrausers', 'varname' => 'nssextrausers',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_index_file_extension' => [ 'system_index_file_extension' => array(
'label' => lng('serversettings.index_file_extension'), 'label' => $lng['serversettings']['index_file_extension'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'index_file_extension', 'varname' => 'index_file_extension',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-zA-Z0-9]{1,6}$/', 'string_regexp' => '/^[a-zA-Z0-9]{1,6}$/',
'default' => 'html', 'default' => 'html',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_store_index_file_subs' => array(
'system_store_index_file_subs' => [ 'label' => $lng['serversettings']['system_store_index_file_subs'],
'label' => lng('serversettings.system_store_index_file_subs'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'store_index_file_subs', 'varname' => 'store_index_file_subs',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_httpuser' => [ 'system_httpuser' => array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'httpuser', 'varname' => 'httpuser',
'type' => 'hidden', 'type' => 'hidden',
'default' => 'www-data' 'default' => 'www-data'
], ),
'system_httpgroup' => [ 'system_httpgroup' => array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'httpgroup', 'varname' => 'httpgroup',
'type' => 'hidden', 'type' => 'hidden',
'default' => 'www-data' 'default' => 'www-data'
], ),
'system_report_enable' => [ 'system_report_enable' => array(
'label' => lng('serversettings.report.report'), 'label' => $lng['serversettings']['report']['report'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'report_enable', 'varname' => 'report_enable',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'cronmodule' => 'froxlor/reports', 'cronmodule' => 'froxlor/reports',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_report_webmax' => [ 'system_report_webmax' => array(
'label' => lng('serversettings.report.webmax'), 'label' => $lng['serversettings']['report']['webmax'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'report_webmax', 'varname' => 'report_webmax',
'type' => 'number', 'type' => 'int',
'min' => 0, 'int_min' => 0,
'max' => 150, 'int_max' => 150,
'default' => 90, 'default' => 90,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_report_trafficmax' => [ 'system_report_trafficmax' => array(
'label' => lng('serversettings.report.trafficmax'), 'label' => $lng['serversettings']['report']['trafficmax'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'report_trafficmax', 'varname' => 'report_trafficmax',
'type' => 'number', 'type' => 'int',
'min' => 0, 'int_min' => 0,
'max' => 150, 'int_max' => 150,
'default' => 90, 'default' => 90,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_use_smtp' => [
'label' => lng('serversettings.mail_use_smtp'), 'system_mail_use_smtp' => array(
'label' => $lng['serversettings']['mail_use_smtp'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_use_smtp', 'varname' => 'mail_use_smtp',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_smtp_host' => [ 'system_mail_smtp_host' => array(
'label' => lng('serversettings.mail_smtp_host'), 'label' => $lng['serversettings']['mail_smtp_host'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_smtp_host', 'varname' => 'mail_smtp_host',
'type' => 'text', 'type' => 'string',
'default' => 'localhost', 'default' => 'localhost',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_smtp_port' => [ 'system_mail_smtp_port' => array(
'label' => lng('serversettings.mail_smtp_port'), 'label' => $lng['serversettings']['mail_smtp_port'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_smtp_port', 'varname' => 'mail_smtp_port',
'type' => 'number', 'type' => 'int',
'min' => 1, 'int_min' => 1,
'max' => 65535, 'int_max' => 65535,
'default' => 25, 'default' => 25,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_smtp_usetls' => [ 'system_mail_smtp_usetls' => array(
'label' => lng('serversettings.mail_smtp_usetls'), 'label' => $lng['serversettings']['mail_smtp_usetls'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_smtp_usetls', 'varname' => 'mail_smtp_usetls',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_smtp_auth' => [ 'system_mail_smtp_auth' => array(
'label' => lng('serversettings.mail_smtp_auth'), 'label' => $lng['serversettings']['mail_smtp_auth'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_smtp_auth', 'varname' => 'mail_smtp_auth',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_smtp_user' => [ 'system_mail_smtp_user' => array(
'label' => lng('serversettings.mail_smtp_user'), 'label' => $lng['serversettings']['mail_smtp_user'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_smtp_user', 'varname' => 'mail_smtp_user',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_smtp_passwd' => [ 'system_mail_smtp_passwd' => array(
'label' => lng('serversettings.mail_smtp_passwd'), 'label' => $lng['serversettings']['mail_smtp_passwd'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_smtp_passwd', 'varname' => 'mail_smtp_passwd',
'type' => 'password', 'type' => 'hiddenString',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_apply_specialsettings_default' => [ 'system_apply_specialsettings_default' => array(
'label' => lng('serversettings.apply_specialsettings_default'), 'label' => $lng['serversettings']['apply_specialsettings_default'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apply_specialsettings_default', 'varname' => 'apply_specialsettings_default',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_apply_phpconfigs_default' => array(
'system_apply_phpconfigs_default' => [ 'label' => $lng['serversettings']['apply_phpconfigs_default'],
'label' => lng('serversettings.apply_phpconfigs_default'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apply_phpconfigs_default', 'varname' => 'apply_phpconfigs_default',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_domaindefaultalias' => array(
'system_domaindefaultalias' => [ 'label' => $lng['admin']['domaindefaultalias'],
'label' => lng('admin.domaindefaultalias'), 'settinggroup' => 'system',
'settinggroup' => 'system', 'varname' => 'domaindefaultalias',
'varname' => 'domaindefaultalias', 'type' => 'option',
'type' => 'select', 'default' => '0',
'default' => '0', 'option_mode' => 'one',
'select_var' => [ 'option_options' => array(
'0' => lng('domains.serveraliasoption_wildcard'), '0' => $lng['domains']['serveraliasoption_wildcard'],
'1' => lng('domains.serveraliasoption_www'), '1' => $lng['domains']['serveraliasoption_www'],
'2' => lng('domains.serveraliasoption_none') '2' => $lng['domains']['serveraliasoption_none']
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'hide_incompatible_settings' => array(
'system_hide_incompatible_settings' => [ 'label' => $lng['serversettings']['hide_incompatible_settings'],
'label' => lng('serversettings.hide_incompatible_settings'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'hide_incompatible_settings', 'varname' => 'hide_incompatible_settings',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], )
] )
] )
] );
];

View File

@@ -2,296 +2,270 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2016 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2016-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package \Froxlor\Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Settings; 'groups' => array(
'froxlorvhost' => array(
return [ 'title' => $lng['admin']['froxlorvhost'] . (call_user_func(array('\Froxlor\Settings\FroxlorVhostSettings', 'hasVhostContainerEnabled')) == false ? $lng['admin']['novhostcontainer'] : ''),
'groups' => [ 'fields' => array(
'froxlorvhost' => [
'title' => lng('admin.froxlorvhost') . (call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]) == false ? lng('admin.novhostcontainer') : ''),
'icon' => 'fa-solid fa-wrench',
'fields' => [
/** /**
* Webserver-Vhost * Webserver-Vhost
*/ */
'system_froxlordirectlyviahostname' => [ 'system_froxlordirectlyviahostname' => array(
'label' => lng('serversettings.froxlordirectlyviahostname'), 'label' => $lng['serversettings']['froxlordirectlyviahostname'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'froxlordirectlyviahostname', 'varname' => 'froxlordirectlyviahostname',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_froxloraliases' => [ 'system_froxloraliases' => array(
'label' => lng('serversettings.froxloraliases'), 'label' => $lng['serversettings']['froxloraliases'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'froxloraliases', 'varname' => 'froxloraliases',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^(([a-z0-9\-\._]+, ?)*[a-z0-9\-\._]+)?$/i', 'string_regexp' => '/^(([a-z0-9\-\._]+, ?)*[a-z0-9\-\._]+)?$/i',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingClearCertificates', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
],
/** /**
* SSL / Let's Encrypt * SSL / Let's Encrypt
*/ */
'system_le_froxlor_enabled' => [ 'system_le_froxlor_enabled' => array(
'label' => lng('serversettings.le_froxlor_enabled'), 'label' => $lng['serversettings']['le_froxlor_enabled'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'le_froxlor_enabled', 'varname' => 'le_froxlor_enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingClearCertificates', 'save_method' => 'storeSettingClearCertificates',
'visible' => Settings::Get('system.leenabled') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.leenabled') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
], true), ), true)
'requires_reconf' => ['http'] ),
], 'system_le_froxlor_redirect' => array(
'system_le_froxlor_redirect' => [ 'label' => $lng['serversettings']['le_froxlor_redirect'],
'label' => lng('serversettings.le_froxlor_redirect'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'le_froxlor_redirect', 'varname' => 'le_froxlor_redirect',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
], true) ), true)
], ),
'system_hsts_maxage' => [ 'system_hsts_maxage' => array(
'label' => lng('admin.domain_hsts_maxage'), 'label' => $lng['admin']['domain_hsts_maxage'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'hsts_maxage', 'varname' => 'hsts_maxage',
'type' => 'number', 'type' => 'int',
'min' => 0, 'int_min' => 0,
'max' => 94608000, // 3-years 'int_max' => 94608000, // 3-years
'default' => 10368000, 'default' => 0,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
], true), ), true)
'advanced_mode' => true ),
], 'system_hsts_incsub' => array(
'system_hsts_incsub' => [ 'label' => $lng['admin']['domain_hsts_incsub'],
'label' => lng('admin.domain_hsts_incsub'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'hsts_incsub', 'varname' => 'hsts_incsub',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
], true), ), true)
'advanced_mode' => true ),
], 'system_hsts_preload' => array(
'system_hsts_preload' => [ 'label' => $lng['admin']['domain_hsts_preload'],
'label' => lng('admin.domain_hsts_preload'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'hsts_preload', 'varname' => 'hsts_preload',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
], true), ), true)
'advanced_mode' => true ),
], 'system_honorcipherorder' => array(
'system_honorcipherorder' => [ 'label' => $lng['admin']['domain_honorcipherorder'],
'label' => lng('admin.domain_honorcipherorder'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'honorcipherorder', 'varname' => 'honorcipherorder',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
], true), ), true)
'advanced_mode' => true ),
], 'system_sessiontickets' => array(
'system_sessiontickets' => [ 'label' => $lng['admin']['domain_sessiontickets'],
'label' => lng('admin.domain_sessiontickets'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'sessiontickets', 'varname' => 'sessiontickets',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
], true), ), true)
'advanced_mode' => true ),
],
/** /**
* FCGID * FCGID
*/ */
'system_mod_fcgid_ownvhost' => [ 'system_mod_fcgid_enabled_ownvhost' => array(
'label' => lng('serversettings.mod_fcgid_ownvhost'), 'label' => $lng['serversettings']['mod_fcgid_ownvhost'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_ownvhost', 'varname' => 'mod_fcgid_ownvhost',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], ),
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]), ))
'requires_reconf' => ['system:fcgid'] ),
], 'system_mod_fcgid_httpuser' => array(
'system_mod_fcgid_httpuser' => [ 'label' => $lng['admin']['mod_fcgid_user'],
'label' => lng('admin.mod_fcgid_user'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_httpuser', 'varname' => 'mod_fcgid_httpuser',
'type' => 'text', 'type' => 'string',
'default' => 'froxlorlocal', 'default' => 'froxlorlocal',
'save_method' => 'storeSettingWebserverFcgidFpmUser', 'save_method' => 'storeSettingWebserverFcgidFpmUser',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], ),
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]), ))
'requires_reconf' => ['system:fcgid'] ),
], 'system_mod_fcgid_httpgroup' => array(
'system_mod_fcgid_httpgroup' => [ 'label' => $lng['admin']['mod_fcgid_group'],
'label' => lng('admin.mod_fcgid_group'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_httpgroup', 'varname' => 'mod_fcgid_httpgroup',
'type' => 'text', 'type' => 'string',
'default' => 'froxlorlocal', 'default' => 'froxlorlocal',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], ),
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]), ))
'requires_reconf' => ['system:fcgid'] ),
], 'system_mod_fcgid_defaultini_ownvhost' => array(
'system_mod_fcgid_defaultini_ownvhost' => [ 'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
'label' => lng('serversettings.mod_fcgid.defaultini_ownvhost'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_defaultini_ownvhost', 'varname' => 'mod_fcgid_defaultini_ownvhost',
'type' => 'select', 'type' => 'option',
'default' => '2', 'default' => '2',
'option_options_method' => [ 'option_mode' => 'one',
'option_options_method' => array(
'\\Froxlor\\Http\\PhpConfig', '\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs' 'getPhpConfigs'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], ),
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([ 'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]) ))
], ),
/** /**
* php-fpm * php-fpm
*/ */
'phpfpm_enabled_ownvhost' => [ 'system_phpfpm_enabled_ownvhost' => array(
'label' => lng('phpfpm.ownvhost'), 'label' => $lng['phpfpm']['ownvhost'],
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'enabled_ownvhost', 'varname' => 'enabled_ownvhost',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([ 'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]), ))
'requires_reconf' => ['system:php-fpm'] ),
], 'system_phpfpm_httpuser' => array(
'phpfpm_vhost_httpuser' => [ 'label' => $lng['phpfpm']['vhost_httpuser'],
'label' => lng('phpfpm.vhost_httpuser'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'vhost_httpuser', 'varname' => 'vhost_httpuser',
'type' => 'text', 'type' => 'string',
'default' => 'froxlorlocal', 'default' => 'froxlorlocal',
'save_method' => 'storeSettingWebserverFcgidFpmUser', 'save_method' => 'storeSettingWebserverFcgidFpmUser',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([ 'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]), ))
'requires_reconf' => ['system:php-fpm'] ),
], 'system_phpfpm_httpgroup' => array(
'phpfpm_vhost_httpgroup' => [ 'label' => $lng['phpfpm']['vhost_httpgroup'],
'label' => lng('phpfpm.vhost_httpgroup'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'vhost_httpgroup', 'varname' => 'vhost_httpgroup',
'type' => 'text', 'type' => 'string',
'default' => 'froxlorlocal', 'default' => 'froxlorlocal',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([ 'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]), ))
'requires_reconf' => ['system:php-fpm'] ),
], 'system_phpfpm_defaultini_ownvhost' => array(
'phpfpm_vhost_defaultini' => [ 'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
'label' => lng('serversettings.mod_fcgid.defaultini_ownvhost'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'vhost_defaultini', 'varname' => 'vhost_defaultini',
'type' => 'select', 'type' => 'option',
'default' => '2', 'default' => '2',
'option_options_method' => [ 'option_mode' => 'one',
'option_options_method' => array(
'\\Froxlor\\Http\\PhpConfig', '\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs' 'getPhpConfigs'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([ 'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings', '\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled' 'hasVhostContainerEnabled'
]) ))
], ),
/** /**
* DNS * DNS
*/ */
'system_dns_createhostnameentry' => [ 'system_dns_createhostnameentry' => array(
'label' => lng('serversettings.dns_createhostnameentry'), 'label' => $lng['serversettings']['dns_createhostnameentry'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'dns_createhostnameentry', 'varname' => 'dns_createhostnameentry',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.bind_enable') 'visible' => \Froxlor\Settings::Get('system.bind_enable')
] )
] )
] )
] )
]; );

View File

@@ -2,70 +2,65 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2014 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'crond' => array(
'crond' => [ 'title' => $lng['admin']['cronsettings'],
'title' => lng('admin.cronsettings'), 'fields' => array(
'icon' => 'fa-solid fa-clock-rotate-left', 'system_cronconfig' => array(
'advanced_mode' => true, 'label' => $lng['serversettings']['system_cronconfig'],
'fields' => [
'system_cronconfig' => [
'label' => lng('serversettings.system_cronconfig'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'cronconfig', 'varname' => 'cronconfig',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/etc/cron.d/froxlor', 'default' => '/etc/cron.d/froxlor',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_croncmdline' => [ 'system_croncmdline' => array(
'label' => lng('serversettings.system_croncmdline'), 'label' => $lng['serversettings']['system_croncmdline'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'croncmdline', 'varname' => 'croncmdline',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/usr/bin/nice -n 5 /usr/bin/php -q', 'default' => '/usr/bin/nice -n 5 /usr/bin/php -q',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_crondreload' => [ 'system_crondreload' => array(
'label' => lng('serversettings.system_crondreload'), 'label' => $lng['serversettings']['system_crondreload'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'crondreload', 'varname' => 'crondreload',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/etc/init.d/cron reload', 'default' => '/etc/init.d/cron reload',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_cron_allowautoupdate' => [ 'system_cron_allowautoupdate' => array(
'label' => lng('serversettings.system_cron_allowautoupdate'), 'label' => $lng['serversettings']['system_cron_allowautoupdate'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'cron_allowautoupdate', 'varname' => 'cron_allowautoupdate',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] ),
] 'system_debug_cron' => array(
] 'label' => $lng['serversettings']['cron']['debug'],
] 'settinggroup' => 'system',
]; 'varname' => 'debug_cron',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField'
)
)
)
)
);

View File

@@ -2,218 +2,204 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Settings; 'groups' => array(
'webserver' => array(
return [ 'title' => $lng['admin']['webserversettings'],
'groups' => [ 'fields' => array(
'webserver' => [ 'system_webserver' => array(
'title' => lng('admin.webserversettings'), 'label' => $lng['admin']['webserver'],
'icon' => 'fa-solid fa-server',
'fields' => [
'system_webserver' => [
'label' => lng('admin.webserver'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'webserver', 'varname' => 'webserver',
'type' => 'select', 'type' => 'option',
'default' => 'apache2', 'default' => 'apache2',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'apache2' => 'Apache 2', 'apache2' => 'Apache 2',
'lighttpd' => 'ligHTTPd', 'lighttpd' => 'ligHTTPd',
'nginx' => 'Nginx' 'nginx' => 'Nginx'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkPhpInterfaceSetting' 'checkPhpInterfaceSetting'
], ),
'requires_reconf' => ['http'] 'overview_option' => true
], ),
'system_apache_24' => [ 'system_apache_24' => array(
'label' => lng('serversettings.apache_24'), 'label' => $lng['serversettings']['apache_24'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apache24', 'varname' => 'apache24',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
] )
], ),
'system_apacheitksupport' => [ 'system_apache_itksupport' => array(
'label' => lng('serversettings.apache_itksupport'), 'label' => $lng['serversettings']['apache_itksupport'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apacheitksupport', 'varname' => 'apacheitksupport',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0), 'visible' => (\Froxlor\Settings::Get('system.mod_fcgid') == 0 && \Froxlor\Settings::Get('phpfpm.enabled') == 0),
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], )
'advanced_mode' => true ),
], 'system_http2_support' => array(
'system_http2_support' => [ 'label' => $lng['serversettings']['http2_support'],
'label' => lng('serversettings.http2_support'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'http2_support', 'varname' => 'http2_support',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
], ),
'visible' => Settings::Get('system.use_ssl') 'visible' => \Froxlor\Settings::Get('system.use_ssl')
], ),
'system_dhparams_file' => [ 'system_dhparams_file' => array(
'label' => lng('serversettings.dhparams_file'), 'label' => $lng['serversettings']['dhparams_file'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'dhparams_file', 'varname' => 'dhparams_file',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl'), 'visible' => \Froxlor\Settings::Get('system.use_ssl')
'advanced_mode' => true ),
], 'system_httpuser' => array(
'system_httpuser' => [ 'label' => $lng['admin']['webserver_user'],
'label' => lng('admin.webserver_user'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'httpuser', 'varname' => 'httpuser',
'type' => 'text', 'type' => 'string',
'default' => 'www-data', 'default' => 'www-data',
'save_method' => 'storeSettingWebserverFcgidFpmUser' 'save_method' => 'storeSettingWebserverFcgidFpmUser'
], ),
'system_httpgroup' => [ 'system_httpgroup' => array(
'label' => lng('admin.webserver_group'), 'label' => $lng['admin']['webserver_group'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'httpgroup', 'varname' => 'httpgroup',
'type' => 'text', 'type' => 'string',
'default' => 'www-data', 'default' => 'www-data',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_apacheconf_vhost' => [ 'system_apacheconf_vhost' => array(
'label' => lng('serversettings.apacheconf_vhost'), 'label' => $lng['serversettings']['apacheconf_vhost'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apacheconf_vhost', 'varname' => 'apacheconf_vhost',
'type' => 'text', 'type' => 'string',
'string_type' => 'filedir', 'string_type' => 'filedir',
'default' => '/etc/apache2/sites-enabled/', 'default' => '/etc/apache2/sites-enabled/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['http'] ),
], 'system_apacheconf_diroptions' => array(
'system_apacheconf_diroptions' => [ 'label' => $lng['serversettings']['apacheconf_diroptions'],
'label' => lng('serversettings.apacheconf_diroptions'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apacheconf_diroptions', 'varname' => 'apacheconf_diroptions',
'type' => 'text', 'type' => 'string',
'string_type' => 'filedir', 'string_type' => 'filedir',
'default' => '/etc/apache2/sites-enabled/', 'default' => '/etc/apache2/sites-enabled/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['http'] ),
], 'system_apacheconf_htpasswddir' => array(
'system_apacheconf_htpasswddir' => [ 'label' => $lng['serversettings']['apacheconf_htpasswddir'],
'label' => lng('serversettings.apacheconf_htpasswddir'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apacheconf_htpasswddir', 'varname' => 'apacheconf_htpasswddir',
'type' => 'text', 'type' => 'string',
'string_type' => 'confdir', 'string_type' => 'confdir',
'default' => '/etc/apache2/htpasswd/', 'default' => '/etc/apache2/htpasswd/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_logfiles_directory' => [ 'system_logfiles_directory' => array(
'label' => lng('serversettings.logfiles_directory'), 'label' => $lng['serversettings']['logfiles_directory'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'logfiles_directory', 'varname' => 'logfiles_directory',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/logs/', 'default' => '/var/customers/logs/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['http'] ),
], 'system_logfiles_script' => array(
'system_logfiles_script' => [ 'label' => $lng['serversettings']['logfiles_script'],
'label' => lng('serversettings.logfiles_script'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'logfiles_script', 'varname' => 'logfiles_script',
'type' => 'text', 'type' => 'string',
'string_type' => '',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], )
'advanced_mode' => true ),
], 'system_logfiles_piped' => array(
'system_logfiles_piped' => [ 'label' => $lng['serversettings']['logfiles_piped'],
'label' => lng('serversettings.logfiles_piped'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'logfiles_piped', 'varname' => 'logfiles_piped',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], )
'advanced_mode' => true ),
], 'system_logfiles_format' => array(
'system_logfiles_format' => [ 'label' => $lng['serversettings']['logfiles_format'],
'label' => lng('serversettings.logfiles_format'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'logfiles_format', 'varname' => 'logfiles_format',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
], ),
'visible' => Settings::Get('system.traffictool') != 'webalizer', 'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
'advanced_mode' => true ),
], 'system_logfiles_type' => array(
'system_logfiles_type' => [ 'label' => $lng['serversettings']['logfiles_type'],
'label' => lng('serversettings.logfiles_type'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'logfiles_type', 'varname' => 'logfiles_type',
'type' => 'select', 'type' => 'option',
'default' => '1', 'default' => '1',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'1' => 'combined', '1' => 'combined',
'2' => 'vhost_combined' '2' => 'vhost_combined'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
] )
], ),
'system_errorlog_level' => [ 'system_errorlog_level' => array(
'label' => lng('serversettings.errorlog_level'), 'label' => $lng['serversettings']['errorlog_level'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'errorlog_level', 'varname' => 'errorlog_level',
'type' => 'select', 'type' => 'option',
'default' => (Settings::Get('system.webserver') == 'nginx' ? 'error' : 'warn'), 'default' => (\Froxlor\Settings::Get('system.webserver') == 'nginx' ? 'error' : 'warn'),
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'emerg' => 'emerg', 'emerg' => 'emerg',
'alert' => 'alert', 'alert' => 'alert',
'crit' => 'crit', 'crit' => 'crit',
@@ -222,203 +208,191 @@ return [
'notice' => 'notice', 'notice' => 'notice',
'info' => 'info', 'info' => 'info',
'debug' => 'debug' 'debug' => 'debug'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
] )
], ),
'system_customer_ssl_path' => [ 'system_customersslpath' => array(
'label' => lng('serversettings.customerssl_directory'), 'label' => $lng['serversettings']['customerssl_directory'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'customer_ssl_path', 'varname' => 'customer_ssl_path',
'type' => 'text', 'type' => 'string',
'string_type' => 'confdir', 'string_type' => 'confdir',
'default' => '/etc/ssl/froxlor-custom/', 'default' => '/etc/ssl/froxlor-custom/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_phpappendopenbasedir' => [ 'system_phpappendopenbasedir' => array(
'label' => lng('serversettings.phpappendopenbasedir'), 'label' => $lng['serversettings']['phpappendopenbasedir'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'phpappendopenbasedir', 'varname' => 'phpappendopenbasedir',
'type' => 'text', 'type' => 'string',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_deactivateddocroot' => array(
'system_deactivateddocroot' => [ 'label' => $lng['serversettings']['deactivateddocroot'],
'label' => lng('serversettings.deactivateddocroot'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'deactivateddocroot', 'varname' => 'deactivateddocroot',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['http'] ),
], 'system_default_vhostconf' => array(
'system_default_vhostconf' => [ 'label' => $lng['serversettings']['default_vhostconf'],
'label' => lng('serversettings.default_vhostconf'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'default_vhostconf', 'varname' => 'default_vhostconf',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_default_sslvhostconf' => array(
'system_default_sslvhostconf' => [ 'label' => $lng['serversettings']['default_sslvhostconf'],
'label' => lng('serversettings.default_sslvhostconf'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'default_sslvhostconf', 'varname' => 'default_sslvhostconf',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') == 1, 'visible' => \Froxlor\Settings::Get('system.use_ssl') == 1
'advanced_mode' => true ),
], 'system_include_default_vhostconf' => array(
'system_include_default_vhostconf' => [ 'label' => $lng['serversettings']['includedefault_sslvhostconf'],
'label' => lng('serversettings.includedefault_sslvhostconf'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'include_default_vhostconf', 'varname' => 'include_default_vhostconf',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_apache_globaldiropt' => array(
'system_apacheglobaldiropt' => [ 'label' => $lng['serversettings']['apache_globaldiropt'],
'label' => lng('serversettings.apache_globaldiropt'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apacheglobaldiropt', 'varname' => 'apacheglobaldiropt',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0), 'visible' => (\Froxlor\Settings::Get('system.mod_fcgid') == 0 && \Froxlor\Settings::Get('phpfpm.enabled') == 0),
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], )
'advanced_mode' => true ),
], 'system_apachereload_command' => array(
'system_apachereload_command' => [ 'label' => $lng['serversettings']['apachereload_command'],
'label' => lng('serversettings.apachereload_command'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apachereload_command', 'varname' => 'apachereload_command',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/etc/init.d/apache2 reload', 'default' => '/etc/init.d/apache2 reload',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_phpreload_command' => [ 'system_phpreload_command' => array(
'label' => lng('serversettings.phpreload_command'), 'label' => $lng['serversettings']['phpreload_command'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'phpreload_command', 'varname' => 'phpreload_command',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'nginx' 'nginx'
] )
], ),
'system_nginx_php_backend' => [ 'system_nginx_php_backend' => array(
'label' => lng('serversettings.nginx_php_backend'), 'label' => $lng['serversettings']['nginx_php_backend'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'nginx_php_backend', 'varname' => 'nginx_php_backend',
'type' => 'text', 'type' => 'string',
'default' => '127.0.0.1:8888', 'default' => '127.0.0.1:8888',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'nginx' 'nginx'
] )
], ),
'nginx_fastcgiparams' => [ 'nginx_fastcgiparams' => array(
'label' => lng('serversettings.nginx_fastcgiparams'), 'label' => $lng['serversettings']['nginx_fastcgiparams'],
'settinggroup' => 'nginx', 'settinggroup' => 'nginx',
'varname' => 'fastcgiparams', 'varname' => 'fastcgiparams',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/etc/nginx/fastcgi_params', 'default' => '/etc/nginx/fastcgi_params',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'nginx' 'nginx'
] )
], ),
'defaultwebsrverrhandler_enabled' => [ 'defaultwebsrverrhandler_enabled' => array(
'label' => lng('serversettings.defaultwebsrverrhandler_enabled'), 'label' => $lng['serversettings']['defaultwebsrverrhandler_enabled'],
'settinggroup' => 'defaultwebsrverrhandler', 'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'enabled', 'varname' => 'enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'defaultwebsrverrhandler_err401' => array(
'defaultwebsrverrhandler_err401' => [ 'label' => $lng['serversettings']['defaultwebsrverrhandler_err401'],
'label' => lng('serversettings.defaultwebsrverrhandler_err401'),
'settinggroup' => 'defaultwebsrverrhandler', 'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'err401', 'varname' => 'err401',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
], )
'advanced_mode' => true ),
], 'defaultwebsrverrhandler_err403' => array(
'defaultwebsrverrhandler_err403' => [ 'label' => $lng['serversettings']['defaultwebsrverrhandler_err403'],
'label' => lng('serversettings.defaultwebsrverrhandler_err403'),
'settinggroup' => 'defaultwebsrverrhandler', 'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'err403', 'varname' => 'err403',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
], )
'advanced_mode' => true ),
], 'defaultwebsrverrhandler_err404' => array(
'defaultwebsrverrhandler_err404' => [ 'label' => $lng['serversettings']['defaultwebsrverrhandler_err404'],
'label' => lng('serversettings.defaultwebsrverrhandler_err404'),
'settinggroup' => 'defaultwebsrverrhandler', 'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'err404', 'varname' => 'err404',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'defaultwebsrverrhandler_err500' => array(
'defaultwebsrverrhandler_err500' => [ 'label' => $lng['serversettings']['defaultwebsrverrhandler_err500'],
'label' => lng('serversettings.defaultwebsrverrhandler_err500'),
'settinggroup' => 'defaultwebsrverrhandler', 'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'err500', 'varname' => 'err500',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
], )
'advanced_mode' => true ),
], 'customredirect_enabled' => array(
'customredirect_enabled' => [ 'label' => $lng['serversettings']['customredirect_enabled'],
'label' => lng('serversettings.customredirect_enabled'),
'settinggroup' => 'customredirect', 'settinggroup' => 'customredirect',
'varname' => 'enabled', 'varname' => 'enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'customredirect_default' => [ 'customredirect_default' => array(
'label' => lng('serversettings.customredirect_default'), 'label' => $lng['serversettings']['customredirect_default'],
'settinggroup' => 'customredirect', 'settinggroup' => 'customredirect',
'varname' => 'default', 'varname' => 'default',
'type' => 'select', 'type' => 'option',
'default' => '1', 'default' => '1',
'option_options_method' => ['\\Froxlor\\Domain\\Domain', 'getRedirectCodes'], 'option_mode' => 'one',
'option_options_method' => array('\\Froxlor\\Domain\\Domain', 'getRedirectCodes'),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );

View File

@@ -2,257 +2,242 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Froxlor; 'groups' => array(
use Froxlor\Settings; 'ssl' => array(
'title' => $lng['admin']['sslsettings'],
return [ 'fields' => array(
'groups' => [ 'system_ssl_enabled' => array(
'ssl' => [ 'label' => $lng['serversettings']['ssl']['use_ssl'],
'title' => lng('admin.sslsettings'),
'icon' => 'fa-solid fa-shield',
'fields' => [
'system_use_ssl' => [
'label' => lng('serversettings.ssl.use_ssl'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'use_ssl', 'varname' => 'use_ssl',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'overview_option' => true, 'overview_option' => true
'requires_reconf' => ['http'] ),
], 'system_ssl_protocols' => array(
'system_ssl_protocols' => [ 'label' => $lng['serversettings']['ssl']['ssl_protocols'],
'label' => lng('serversettings.ssl.ssl_protocols'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_protocols', 'varname' => 'ssl_protocols',
'type' => 'select', 'type' => 'option',
'default' => 'TLSv1.2', 'default' => 'TLSv1.2',
'select_mode' => 'multiple', 'option_mode' => 'multiple',
'select_var' => [ 'option_options' => array(
'TLSv1' => 'TLSv1', 'TLSv1' => 'TLSv1',
'TLSv1.1' => 'TLSv1.1', 'TLSv1.1' => 'TLSv1.1',
'TLSv1.2' => 'TLSv1.2', 'TLSv1.2' => 'TLSv1.2',
'TLSv1.3' => 'TLSv1.3' 'TLSv1.3' => 'TLSv1.3'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_ssl_cipher_list' => [ 'system_ssl_cipher_list' => array(
'label' => lng('serversettings.ssl.ssl_cipher_list'), 'label' => $lng['serversettings']['ssl']['ssl_cipher_list'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_cipher_list', 'varname' => 'ssl_cipher_list',
'type' => 'text', 'type' => 'string',
'string_emptyallowed' => false, 'string_emptyallowed' => false,
'default' => 'ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128', 'default' => 'ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_tlsv13_cipher_list' => array(
'system_tlsv13_cipher_list' => [ 'label' => $lng['serversettings']['ssl']['tlsv13_cipher_list'],
'label' => lng('serversettings.ssl.tlsv13_cipher_list'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'tlsv13_cipher_list', 'varname' => 'tlsv13_cipher_list',
'type' => 'text', 'type' => 'string',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'visible' => Settings::Get('system.webserver') == "apache2" && Settings::Get('system.apache24') == 1, 'visible' => \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_ssl_cert_file' => array(
'system_ssl_cert_file' => [ 'label' => $lng['serversettings']['ssl']['ssl_cert_file'],
'label' => lng('serversettings.ssl.ssl_cert_file'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_cert_file', 'varname' => 'ssl_cert_file',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '/etc/ssl/froxlor_selfsigned.pem', 'default' => '/etc/apache2/apache2.pem',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_ssl_key_file' => [ 'system_ssl_key_file' => array(
'label' => lng('serversettings.ssl.ssl_key_file'), 'label' => $lng['serversettings']['ssl']['ssl_key_file'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_key_file', 'varname' => 'ssl_key_file',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '/etc/ssl/froxlor_selfsigned.key', 'default' => '/etc/apache2/apache2.key',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_ssl_cert_chainfile' => [ 'system_ssl_cert_chainfile' => array(
'label' => lng('admin.ipsandports.ssl_cert_chainfile'), 'label' => $lng['admin']['ipsandports']['ssl_cert_chainfile'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_cert_chainfile', 'varname' => 'ssl_cert_chainfile',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_ssl_ca_file' => [ 'system_ssl_ca_file' => array(
'label' => lng('serversettings.ssl.ssl_ca_file'), 'label' => $lng['serversettings']['ssl']['ssl_ca_file'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_ca_file', 'varname' => 'ssl_ca_file',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_apache24_ocsp_cache_path' => [ 'system_apache24_ocsp_cache_path' => array(
'label' => lng('serversettings.ssl.apache24_ocsp_cache_path'), 'label' => $lng['serversettings']['ssl']['apache24_ocsp_cache_path'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apache24_ocsp_cache_path', 'varname' => 'apache24_ocsp_cache_path',
'type' => 'text', 'type' => 'string',
'string_type' => 'string',
'string_emptyallowed' => false, 'string_emptyallowed' => false,
'default' => 'shmcb:/var/run/apache2/ocsp-stapling.cache(131072)', 'default' => 'shmcb:/var/run/apache2/ocsp-stapling.cache(131072)',
'visible' => Settings::Get('system.webserver') == "apache2" && Settings::Get('system.apache24') == 1, 'visible' => \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_sessionticketsenabled' => array(
'system_sessionticketsenabled' => [ 'label' => $lng['admin']['domain_sessionticketsenabled'],
'label' => lng('admin.domain_sessionticketsenabled'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'sessionticketsenabled', 'varname' => 'sessionticketsenabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && (Settings::Get('system.webserver') == "nginx" || (Settings::Get('system.webserver') == "apache2" && Settings::Get('system.apache24') == 1)), 'visible' => \Froxlor\Settings::Get('system.use_ssl') && (\Froxlor\Settings::Get('system.webserver') == "nginx" || (\Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1))
'advanced_mode' => true ),
], 'system_leenabled' => array(
'system_leenabled' => [ 'label' => $lng['serversettings']['leenabled'],
'label' => lng('serversettings.leenabled'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'leenabled', 'varname' => 'leenabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'cronmodule' => 'froxlor/letsencrypt', 'cronmodule' => 'froxlor/letsencrypt',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['http'] ),
], 'system_acmeshpath' => array(
'system_acmeshpath' => [ 'label' => $lng['serversettings']['acmeshpath'],
'label' => lng('serversettings.acmeshpath'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'acmeshpath', 'varname' => 'acmeshpath',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/root/.acme.sh/acme.sh', 'default' => '/root/.acme.sh/acme.sh',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_letsencryptacmeconf' => array(
'system_letsencryptacmeconf' => [ 'label' => $lng['serversettings']['letsencryptacmeconf'],
'label' => lng('serversettings.letsencryptacmeconf'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptacmeconf', 'varname' => 'letsencryptacmeconf',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/etc/apache2/conf-enabled/acme.conf', 'default' => '/etc/apache2/conf-enabled/acme.conf',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['http'] ),
], /**
'system_letsencryptca' => [ * currently the only option anyway
'label' => lng('serversettings.letsencryptca'), *
'system_leapiversion' => array(
'label' => $lng['serversettings']['leapiversion'],
'settinggroup' => 'system',
'varname' => 'leapiversion',
'type' => 'option',
'default' => '2',
'option_mode' => 'one',
'option_options' => array(
'2' => 'ACME v2'
),
'save_method' => 'storeSettingField'
),
*/
'system_letsencryptca' => array(
'label' => $lng['serversettings']['letsencryptca'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptca', 'varname' => 'letsencryptca',
'type' => 'select', 'type' => 'option',
'default' => 'letsencrypt', 'default' => 'letsencrypt',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'letsencrypt_test' => 'Let\'s Encrypt (Test / Staging)', 'letsencrypt_test' => 'Let\'s Encrypt (Test / Staging)',
'letsencrypt' => 'Let\'s Encrypt (Live)', 'letsencrypt' => 'Let\'s Encrypt (Live)',
'buypass_test' => 'Buypass (Test / Staging)', 'buypass_test' => 'Buypass (Test / Staging)',
'buypass' => 'Buypass (Live)', 'buypass' => 'Buypass (Live)',
'zerossl' => 'ZeroSSL (Live)', 'zerossl' => 'ZeroSSL (Live)'
'google' => 'Google (Live)', ),
'google_test' => 'Google (Test / Staging)',
],
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_letsencryptchallengepath' => [ 'system_letsencryptchallengepath' => array(
'label' => lng('serversettings.letsencryptchallengepath'), 'label' => $lng['serversettings']['letsencryptchallengepath'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptchallengepath', 'varname' => 'letsencryptchallengepath',
'type' => 'text', 'type' => 'string',
'string_emptyallowed' => false, 'string_emptyallowed' => false,
'default' => Froxlor::getInstallDir(), 'default' => \Froxlor\Froxlor::getInstallDir(),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true, ),
'requires_reconf' => ['http'] 'system_letsencryptkeysize' => array(
], 'label' => $lng['serversettings']['letsencryptkeysize'],
'system_letsencryptkeysize' => [
'label' => lng('serversettings.letsencryptkeysize'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptkeysize', 'varname' => 'letsencryptkeysize',
'type' => 'select', 'type' => 'option',
'default' => '2048', 'default' => '2048',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'2048' => '2048', '2048' => '2048',
'3072' => '3072', '3072' => '3072',
'4096' => '4096', '4096' => '4096',
'8192' => '8192' '8192' => '8192'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_leecc' => [ 'system_leecc' => array(
'label' => lng('serversettings.letsencryptecc'), 'label' => $lng['serversettings']['letsencryptecc'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'leecc', 'varname' => 'leecc',
'type' => 'select', 'type' => 'option',
'default' => '0', 'default' => '0',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'0' => '-', '0' => '-',
'256' => 'ec-256', '256' => 'ec-256',
'384' => 'ec-384' '384' => 'ec-384'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_letsencryptreuseold' => array(
'system_letsencryptreuseold' => [ 'label' => $lng['serversettings']['letsencryptreuseold'],
'label' => lng('serversettings.letsencryptreuseold'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptreuseold', 'varname' => 'letsencryptreuseold',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_le_domain_dnscheck' => array(
'system_le_domain_dnscheck' => [ 'label' => $lng['serversettings']['le_domain_dnscheck'],
'label' => lng('serversettings.le_domain_dnscheck'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'le_domain_dnscheck', 'varname' => 'le_domain_dnscheck',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], )
'system_le_domain_dnscheck_resolver' => [ )
'label' => lng('serversettings.le_domain_dnscheck_resolver'), )
'settinggroup' => 'system', )
'varname' => 'le_domain_dnscheck_resolver', );
'type' => 'text',
'string_regexp' => '/^(([0-9]+ [a-z0-9\-\._]+, ?)*[0-9]+ [a-z0-9\-\._]+)?$/i',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
]
]
]
]
];

View File

@@ -4,142 +4,125 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'fcgid' => array(
'fcgid' => [ 'title' => $lng['admin']['fcgid_settings'],
'title' => lng('admin.fcgid_settings'), 'websrv_avail' => array(
'icon' => 'fa-brands fa-php',
'websrv_avail' => [
'apache2', 'apache2',
'lighttpd' 'lighttpd'
], ),
'fields' => [ 'fields' => array(
'system_mod_fcgid' => [ 'system_mod_fcgid_enabled' => array(
'label' => lng('serversettings.mod_fcgid'), 'label' => $lng['serversettings']['mod_fcgid'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid', 'varname' => 'mod_fcgid',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkFcgidPhpFpm' 'checkFcgidPhpFpm'
], ),
'overview_option' => true, 'overview_option' => true
'requires_reconf' => ['http', 'system:fcgid'] ),
], 'system_mod_fcgid_configdir' => array(
'system_mod_fcgid_configdir' => [ 'label' => $lng['serversettings']['mod_fcgid']['configdir'],
'label' => lng('serversettings.mod_fcgid.configdir'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_configdir', 'varname' => 'mod_fcgid_configdir',
'type' => 'text', 'type' => 'string',
'string_type' => 'confdir', 'string_type' => 'confdir',
'default' => '/var/www/php-fcgi-scripts/', 'default' => '/var/www/php-fcgi-scripts/',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkPathConflicts' 'checkPathConflicts'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['system:fcgid'] ),
], 'system_mod_fcgid_tmpdir' => array(
'system_mod_fcgid_tmpdir' => [ 'label' => $lng['serversettings']['mod_fcgid']['tmpdir'],
'label' => lng('serversettings.mod_fcgid.tmpdir'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_tmpdir', 'varname' => 'mod_fcgid_tmpdir',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/tmp/', 'default' => '/var/customers/tmp/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['http'] ),
], 'system_mod_fcgid_peardir' => array(
'system_mod_fcgid_peardir' => [ 'label' => $lng['serversettings']['mod_fcgid']['peardir'],
'label' => lng('serversettings.mod_fcgid.peardir'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_peardir', 'varname' => 'mod_fcgid_peardir',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'string_delimiter' => ':', 'string_delimiter' => ':',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '/usr/share/php/:/usr/share/php5/', 'default' => '/usr/share/php/:/usr/share/php5/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_mod_fcgid_wrapper' => array(
'system_mod_fcgid_wrapper' => [ 'label' => $lng['serversettings']['mod_fcgid']['wrapper'],
'label' => lng('serversettings.mod_fcgid.wrapper'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_wrapper', 'varname' => 'mod_fcgid_wrapper',
'type' => 'select', 'type' => 'option',
'select_var' => [ 'option_options' => array(
0 => 'ScriptAlias', 0 => 'ScriptAlias',
1 => 'FcgidWrapper' 1 => 'FcgidWrapper'
], ),
'default' => 1, 'default' => 1,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
], )
'advanced_mode' => true ),
], 'system_mod_fcgid_starter' => array(
'system_mod_fcgid_starter' => [ 'label' => $lng['serversettings']['mod_fcgid']['starter'],
'label' => lng('serversettings.mod_fcgid.starter'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_starter', 'varname' => 'mod_fcgid_starter',
'type' => 'number', 'type' => 'int',
'min' => 0,
'default' => 0, 'default' => 0,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_mod_fcgid_maxrequests' => array(
'system_mod_fcgid_maxrequests' => [ 'label' => $lng['serversettings']['mod_fcgid']['maxrequests'],
'label' => lng('serversettings.mod_fcgid.maxrequests'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_maxrequests', 'varname' => 'mod_fcgid_maxrequests',
'type' => 'number', 'type' => 'int',
'default' => 250, 'default' => 250,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_mod_fcgid_defaultini' => array(
'system_mod_fcgid_defaultini' => [ 'label' => $lng['serversettings']['mod_fcgid']['defaultini'],
'label' => lng('serversettings.mod_fcgid.defaultini'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_defaultini', 'varname' => 'mod_fcgid_defaultini',
'type' => 'select', 'type' => 'option',
'default' => '1', 'default' => '1',
'option_options_method' => [ 'option_mode' => 'one',
'option_options_method' => array(
'\\Froxlor\\Http\\PhpConfig', '\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs' 'getPhpConfigs'),
],
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mod_fcgid_idle_timeout' => [ 'system_mod_fcgid_idle_timeout' => array(
'label' => lng('serversettings.mod_fcgid.idle_timeout'), 'label' => $lng['serversettings']['mod_fcgid']['idle_timeout'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_idle_timeout', 'varname' => 'mod_fcgid_idle_timeout',
'type' => 'number', 'type' => 'int',
'default' => 30, 'default' => 30,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true )
] )
] )
] )
] );
];
?>

View File

@@ -4,158 +4,138 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package \Froxlor\Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Settings; 'groups' => array(
'phpfpm' => array(
return [ 'title' => $lng['admin']['phpfpm_settings'],
'groups' => [ 'fields' => array(
'phpfpm' => [ 'system_phpfpm_enabled' => array(
'title' => lng('admin.phpfpm_settings'), 'label' => $lng['serversettings']['phpfpm'],
'icon' => 'fa-brands fa-php',
'fields' => [
'phpfpm_enabled' => [
'label' => lng('serversettings.phpfpm'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'enabled', 'varname' => 'enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkFcgidPhpFpm' 'checkFcgidPhpFpm'
], ),
'overview_option' => true, 'overview_option' => true
'requires_reconf' => ['http', 'system:php-fpm'] ),
], 'system_phpfpm_defaultini' => array(
'phpfpm_defaultini' => [ 'label' => $lng['serversettings']['mod_fcgid']['defaultini'],
'label' => lng('serversettings.mod_fcgid.defaultini'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'defaultini', 'varname' => 'defaultini',
'type' => 'select', 'type' => 'option',
'default' => '1', 'default' => '1',
'option_options_method' => [ 'option_mode' => 'one',
'option_options_method' => array(
'\\Froxlor\\Http\\PhpConfig', '\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs' 'getPhpConfigs'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'phpfpm_aliasconfigdir' => [ 'system_phpfpm_aliasconfigdir' => array(
'label' => lng('serversettings.phpfpm_settings.aliasconfigdir'), 'label' => $lng['serversettings']['phpfpm_settings']['aliasconfigdir'],
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'aliasconfigdir', 'varname' => 'aliasconfigdir',
'type' => 'text', 'type' => 'string',
'string_type' => 'confdir', 'string_type' => 'confdir',
'default' => '/var/www/php-fpm/', 'default' => '/var/www/php-fpm/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_phpfpm_tmpdir' => array(
'phpfpm_tmpdir' => [ 'label' => $lng['serversettings']['mod_fcgid']['tmpdir'],
'label' => lng('serversettings.mod_fcgid.tmpdir'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'tmpdir', 'varname' => 'tmpdir',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/tmp/', 'default' => '/var/customers/tmp/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'phpfpm_peardir' => [ 'system_phpfpm_peardir' => array(
'label' => lng('serversettings.mod_fcgid.peardir'), 'label' => $lng['serversettings']['mod_fcgid']['peardir'],
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'peardir', 'varname' => 'peardir',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'string_delimiter' => ':', 'string_delimiter' => ':',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '/usr/share/php/:/usr/share/php5/', 'default' => '/usr/share/php/:/usr/share/php5/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_phpfpm_envpath' => array(
'phpfpm_envpath' => [ 'label' => $lng['serversettings']['phpfpm_settings']['envpath'],
'label' => lng('serversettings.phpfpm_settings.envpath'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'envpath', 'varname' => 'envpath',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'string_delimiter' => ':', 'string_delimiter' => ':',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '/usr/local/bin:/usr/bin:/bin', 'default' => '/usr/local/bin:/usr/bin:/bin',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_phpfpm_fastcgi_ipcdir' => array(
'phpfpm_fastcgi_ipcdir' => [ 'label' => $lng['serversettings']['phpfpm_settings']['ipcdir'],
'label' => lng('serversettings.phpfpm_settings.ipcdir'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'fastcgi_ipcdir', 'varname' => 'fastcgi_ipcdir',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/lib/apache2/fastcgi/', 'default' => '/var/lib/apache2/fastcgi/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_phpfpm_use_mod_proxy' => array(
'phpfpm_use_mod_proxy' => [ 'label' => $lng['phpfpm']['use_mod_proxy'],
'label' => lng('phpfpm.use_mod_proxy'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'use_mod_proxy', 'varname' => 'use_mod_proxy',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'visible' => Settings::Get('system.apache24'), 'visible' => \Froxlor\Settings::Get('system.apache24'),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'phpfpm_ini_flags' => [ 'system_phpfpm_ini_flags' => array(
'label' => lng('phpfpm.ini_flags'), 'label' => $lng['phpfpm']['ini_flags'],
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'ini_flags', 'varname' => 'ini_flags',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_phpfpm_ini_values' => array(
'phpfpm_ini_values' => [ 'label' => $lng['phpfpm']['ini_values'],
'label' => lng('phpfpm.ini_values'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'ini_values', 'varname' => 'ini_values',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_phpfpm_ini_admin_flags' => array(
'phpfpm_ini_admin_flags' => [ 'label' => $lng['phpfpm']['ini_admin_flags'],
'label' => lng('phpfpm.ini_admin_flags'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'ini_admin_flags', 'varname' => 'ini_admin_flags',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_phpfpm_ini_admin_values' => array(
'phpfpm_ini_admin_values' => [ 'label' => $lng['phpfpm']['ini_admin_values'],
'label' => lng('phpfpm.ini_admin_values'),
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'ini_admin_values', 'varname' => 'ini_admin_values',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true )
] )
] )
] )
] );
];

View File

@@ -4,77 +4,69 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'perl' => array(
'perl' => [ 'title' => $lng['admin']['perl_settings'],
'title' => lng('admin.perl_settings'), 'fields' => array(
'icon' => 'fa-solid fa-code', 'perl_path' => array(
'fields' => [ 'label' => $lng['serversettings']['perl_path'],
'system_perl_path' => [
'label' => lng('serversettings.perl_path'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'perl_path', 'varname' => 'perl_path',
'type' => 'text', 'type' => 'string',
'default' => '/usr/bin/perl', 'default' => '/usr/bin/perl',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'lighttpd' 'lighttpd'
] )
], ),
'perl_suexecworkaround' => [ 'system_perl_suexecworkaround' => array(
'label' => lng('serversettings.perl.suexecworkaround'), 'label' => $lng['serversettings']['perl']['suexecworkaround'],
'settinggroup' => 'perl', 'settinggroup' => 'perl',
'varname' => 'suexecworkaround', 'varname' => 'suexecworkaround',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
] )
], ),
'perl_suexecpath' => [ 'system_perl_suexeccgipath' => array(
'label' => lng('serversettings.perl.suexeccgipath'), 'label' => $lng['serversettings']['perl']['suexeccgipath'],
'settinggroup' => 'perl', 'settinggroup' => 'perl',
'varname' => 'suexecpath', 'varname' => 'suexecpath',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/www/cgi-bin/', 'default' => '/var/www/cgi-bin/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'apache2' 'apache2'
] )
], ),
'serversettings_perl_server' => [ 'perl_server' => array(
'label' => lng('serversettings.perl_server'), 'label' => $lng['serversettings']['perl_server'],
'settinggroup' => 'serversettings', 'settinggroup' => 'serversettings',
'varname' => 'perl_server', 'varname' => 'perl_server',
'type' => 'text', 'type' => 'string',
'default' => 'unix:/var/run/nginx/cgiwrap-dispatch.sock', 'default' => 'unix:/var/run/nginx/cgiwrap-dispatch.sock',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ 'websrv_avail' => array(
'nginx' 'nginx'
] )
] )
] )
] )
] )
]; );
?>

View File

@@ -2,115 +2,100 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Settings; 'groups' => array(
'statistics' => array(
return [ 'title' => $lng['admin']['statisticsettings'],
'groups' => [ 'fields' => array(
'statistics' => [ 'system_webalizer_quiet' => array(
'title' => lng('admin.statisticsettings'), 'label' => $lng['serversettings']['webalizer_quiet'],
'icon' => 'fa-solid fa-chart-area',
'fields' => [
'system_traffictool' => [
'label' => lng('serversettings.traffictool.toolselect'),
'settinggroup' => 'system',
'varname' => 'traffictool',
'type' => 'select',
'default' => 'goaccess',
'select_var' => [
'webalizer' => lng('serversettings.traffictool.webalizer'),
'awstats' => lng('serversettings.traffictool.awstats'),
'goaccess' => lng('serversettings.traffictool.goaccess')
],
'save_method' => 'storeSettingUpdateTrafficTool',
'requires_reconf' => ['system']
],
'system_webalizer_quiet' => [
'label' => lng('serversettings.webalizer_quiet'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'webalizer_quiet', 'varname' => 'webalizer_quiet',
'type' => 'select', 'type' => 'option',
'default' => 2, 'default' => 2,
'select_var' => [ 'option_mode' => 'one',
0 => lng('admin.webalizer.normal'), 'option_options' => array(
1 => lng('admin.webalizer.quiet'), 0 => $lng['admin']['webalizer']['normal'],
2 => lng('admin.webalizer.veryquiet') 1 => $lng['admin']['webalizer']['quiet'],
], 2 => $lng['admin']['webalizer']['veryquiet']
),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'webalizer' 'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 0
], ),
'system_awstats_path' => [ 'system_awstats_enabled' => array(
'label' => lng('serversettings.awstats_path'), 'label' => $lng['serversettings']['awstats_enabled'],
'settinggroup' => 'system',
'varname' => 'awstats_enabled',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField'
),
'system_awstats_path' => array(
'label' => $lng['serversettings']['awstats_path'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_path', 'varname' => 'awstats_path',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/share/awstats/tools/', 'default' => '/usr/bin/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats' 'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
], ),
'system_awstats_awstatspath' => [ 'system_awstats_awstatspath' => array(
'label' => lng('serversettings.awstats_awstatspath'), 'label' => $lng['serversettings']['awstats_awstatspath'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_awstatspath', 'varname' => 'awstats_awstatspath',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/lib/cgi-bin/', 'default' => '/usr/bin/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats' 'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
], ),
'system_awstats_conf' => [ 'system_awstats_conf' => array(
'label' => lng('serversettings.awstats_conf'), 'label' => $lng['serversettings']['awstats_conf'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_conf', 'varname' => 'awstats_conf',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/etc/awstats/', 'default' => '/etc/awstats/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats', 'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
'requires_reconf' => ['system:awstats'] ),
], 'system_awstats_icons' => array(
'system_awstats_icons' => [ 'label' => $lng['serversettings']['awstats_icons'],
'label' => lng('serversettings.awstats_icons'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_icons', 'varname' => 'awstats_icons',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/share/awstats/icon/', 'default' => '/usr/share/awstats/icon/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats' 'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
], ),
'system_awstats_logformat' => [ 'system_awstats_logformat' => array(
'label' => lng('serversettings.awstats.logformat'), 'label' => $lng['serversettings']['awstats']['logformat'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_logformat', 'varname' => 'awstats_logformat',
'type' => 'text', 'type' => 'string',
'default' => '1', 'default' => '1',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats', 'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
'advanced_mode' => true )
] )
] )
] )
] );
];
?>

View File

@@ -2,168 +2,153 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'mail' => array(
'mail' => [ 'title' => $lng['admin']['mailserversettings'],
'title' => lng('admin.mailserversettings'), 'fields' => array(
'icon' => 'fa-solid fa-envelope', 'system_vmail_uid' => array(
'fields' => [ 'label' => $lng['serversettings']['vmail_uid'],
'system_vmail_uid' => [
'label' => lng('serversettings.vmail_uid'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'vmail_uid', 'varname' => 'vmail_uid',
'type' => 'number', 'type' => 'int',
'default' => 2000, 'default' => 2000,
'min' => 2, 'int_min' => 1,
'max' => 65535, 'int_max' => 65535,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true, ),
'requires_reconf' => ['smtp'] 'system_vmail_gid' => array(
], 'label' => $lng['serversettings']['vmail_gid'],
'system_vmail_gid' => [
'label' => lng('serversettings.vmail_gid'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'vmail_gid', 'varname' => 'vmail_gid',
'type' => 'number', 'type' => 'int',
'default' => 2000, 'default' => 2000,
'min' => 2, 'int_min' => 1,
'max' => 65535, 'int_max' => 65535,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true, ),
'requires_reconf' => ['smtp'] 'system_vmail_homedir' => array(
], 'label' => $lng['serversettings']['vmail_homedir'],
'system_vmail_homedir' => [
'label' => lng('serversettings.vmail_homedir'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'vmail_homedir', 'varname' => 'vmail_homedir',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/mail/', 'default' => '/var/customers/mail/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['smtp'] ),
], 'system_vmail_maildirname' => array(
'system_vmail_maildirname' => [ 'label' => $lng['serversettings']['vmail_maildirname'],
'label' => lng('serversettings.vmail_maildirname'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'vmail_maildirname', 'varname' => 'vmail_maildirname',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => 'Maildir', 'default' => 'Maildir',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'panel_sendalternativemail' => array(
'panel_sendalternativemail' => [ 'label' => $lng['serversettings']['sendalternativemail'],
'label' => lng('serversettings.sendalternativemail'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'sendalternativemail', 'varname' => 'sendalternativemail',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_quota_enabled' => [ 'system_mail_quota_enabled' => array(
'label' => lng('serversettings.mail_quota_enabled'), 'label' => $lng['serversettings']['mail_quota_enabled'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_quota_enabled', 'varname' => 'mail_quota_enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mail_quota' => [ 'system_mail_quota' => array(
'label' => lng('serversettings.mail_quota'), 'label' => $lng['serversettings']['mail_quota'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mail_quota', 'varname' => 'mail_quota',
'type' => 'number', 'type' => 'int',
'default' => 100, 'default' => 100,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'catchall_catchall_enabled' => [ 'system_catchall_enabled' => array(
'label' => lng('serversettings.catchall_enabled'), 'label' => $lng['serversettings']['catchall_enabled'],
'settinggroup' => 'catchall', 'settinggroup' => 'catchall',
'varname' => 'catchall_enabled', 'varname' => 'catchall_enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingResetCatchall' 'save_method' => 'storeSettingResetCatchall'
], ),
'system_mailtraffic_enabled' => [ 'system_mailtraffic_enabled' => array(
'label' => lng('serversettings.mailtraffic_enabled'), 'label' => $lng['serversettings']['mailtraffic_enabled'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mailtraffic_enabled', 'varname' => 'mailtraffic_enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_mdaserver' => array(
'system_mdaserver' => [ 'label' => $lng['serversettings']['mdaserver'],
'label' => lng('serversettings.mdaserver'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mdaserver', 'varname' => 'mdaserver',
'type' => 'select', 'type' => 'option',
'option_mode' => 'one',
'default' => 'dovecot', 'default' => 'dovecot',
'select_var' => [ 'option_options' => array(
'courier' => 'Courier', 'courier' => 'Courier',
'dovecot' => 'Dovecot' 'dovecot' => 'Dovecot'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_mdalog' => array(
'system_mdalog' => [ 'label' => $lng['serversettings']['mdalog'],
'label' => lng('serversettings.mdalog'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mdalog', 'varname' => 'mdalog',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/var/log/mail.log', 'default' => '/var/log/mail.log',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_mtaserver' => array(
'system_mtaserver' => [ 'label' => $lng['serversettings']['mtaserver'],
'label' => lng('serversettings.mtaserver'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mtaserver', 'varname' => 'mtaserver',
'type' => 'select', 'type' => 'option',
'option_mode' => 'one',
'default' => 'postfix', 'default' => 'postfix',
'select_var' => [ 'option_options' => array(
'exim4' => 'Exim4', 'exim4' => 'Exim4',
'postfix' => 'Postfix' 'postfix' => 'Postfix'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_mtalog' => array(
'system_mtalog' => [ 'label' => $lng['serversettings']['mtalog'],
'label' => lng('serversettings.mtalog'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mtalog', 'varname' => 'mtalog',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/var/log/mail.log', 'default' => '/var/log/mail.log',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true )
] )
] )
] )
] );
];
?>

View File

@@ -2,46 +2,41 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'ftpserver' => array(
'ftpserver' => [ 'title' => $lng['admin']['ftpserversettings'],
'title' => lng('admin.ftpserversettings'), 'fields' => array(
'icon' => 'fa-solid fa-arrow-right-arrow-left', 'ftpserver' => array(
'fields' => [ 'label' => $lng['admin']['ftpserver'],
'system_ftpserver' => [
'label' => lng('admin.ftpserver'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ftpserver', 'varname' => 'ftpserver',
'type' => 'select', 'type' => 'option',
'default' => 'proftpd', 'default' => 'proftpd',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'proftpd' => 'Proftpd', 'proftpd' => 'Proftpd',
'pureftpd' => 'Pureftpd' 'pureftpd' => 'Pureftpd'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );
?>

View File

@@ -2,177 +2,161 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Settings; 'groups' => array(
'nameserver' => array(
return [ 'title' => $lng['admin']['nameserversettings'],
'groups' => [ 'fields' => array(
'nameserver' => [ 'nameserver_enable' => array(
'title' => lng('admin.nameserversettings'), 'label' => $lng['serversettings']['bindenable'],
'icon' => 'fa-solid fa-globe',
'fields' => [
'system_bind_enable' => [
'label' => lng('serversettings.bindenable'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'bind_enable', 'varname' => 'bind_enable',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'overview_option' => true, 'overview_option' => true
'requires_reconf' => ['dns'] ),
], 'system_dnsenabled' => array(
'system_dnsenabled' => [ 'label' => $lng['serversettings']['dnseditorenable'],
'label' => lng('serversettings.dnseditorenable'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'dnsenabled', 'varname' => 'dnsenabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_dns_server' => [ 'system_dns_server' => array(
'label' => lng('serversettings.dns_server'), 'label' => $lng['serversettings']['dns_server'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'dns_server', 'varname' => 'dns_server',
'type' => 'select', 'type' => 'option',
'default' => 'Bind', 'default' => 'Bind',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'Bind' => 'Bind9', 'Bind' => 'Bind9',
'PowerDNS' => 'PowerDNS' 'PowerDNS' => 'PowerDNS'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'requires_reconf' => ['dns'] ),
], 'system_bindconf_directory' => array(
'system_bindconf_directory' => [ 'label' => $lng['serversettings']['bindconf_directory'],
'label' => lng('serversettings.bindconf_directory'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'bindconf_directory', 'varname' => 'bindconf_directory',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/etc/bind/', 'default' => '/etc/bind/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'visible' => Settings::Get('system.dns_server') == 'Bind', ),
'requires_reconf' => ['dns:bind'] 'system_bindreload_command' => array(
], 'label' => $lng['serversettings']['bindreload_command'],
'system_bindreload_command' => [
'label' => lng('serversettings.bindreload_command'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'bindreload_command', 'varname' => 'bindreload_command',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/etc/init.d/bind9 reload', 'default' => '/etc/init.d/bind9 reload',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_nameservers' => [ 'system_nameservers' => array(
'label' => lng('serversettings.nameservers'), 'label' => $lng['serversettings']['nameservers'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'nameservers', 'varname' => 'nameservers',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^(([a-z0-9\-\._]+, ?)*[a-z0-9\-\._]+)?$/i', 'string_regexp' => '/^(([a-z0-9\-\._]+, ?)*[a-z0-9\-\._]+)?$/i',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingFieldInsertBindTask' 'save_method' => 'storeSettingFieldInsertBindTask'
], ),
'system_mxservers' => [ 'system_mxservers' => array(
'label' => lng('serversettings.mxservers'), 'label' => $lng['serversettings']['mxservers'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mxservers', 'varname' => 'mxservers',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^(([0-9]+ [a-z0-9\-\._]+, ?)*[0-9]+ [a-z0-9\-\._]+)?$/i', 'string_regexp' => '/^(([0-9]+ [a-z0-9\-\._]+, ?)*[0-9]+ [a-z0-9\-\._]+)?$/i',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_axfrservers' => [ 'system_axfrservers' => array(
'label' => lng('serversettings.axfrservers'), 'label' => $lng['serversettings']['axfrservers'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'axfrservers', 'varname' => 'axfrservers',
'type' => 'text', 'type' => 'string',
'string_type' => 'validate_ip_incl_private', 'string_type' => 'validate_ip_incl_private',
'string_delimiter' => ',', 'string_delimiter' => ',',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_powerdns_mode' => [ 'system_powerdns_mode' => array(
'label' => lng('serversettings.powerdns_mode'), 'label' => $lng['serversettings']['powerdns_mode'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'powerdns_mode', 'varname' => 'powerdns_mode',
'type' => 'select', 'type' => 'option',
'default' => 'Native', 'default' => 'Native',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'Native' => 'Native', 'Native' => 'Native',
'Master' => 'Master' 'Master' => 'Master'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true, ),
'visible' => Settings::Get('system.dns_server') == 'PowerDNS', 'system_dns_createmailentry' => array(
], 'label' => $lng['serversettings']['mail_also_with_mxservers'],
'system_dns_createmailentry' => [
'label' => lng('serversettings.mail_also_with_mxservers'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'dns_createmailentry', 'varname' => 'dns_createmailentry',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_dns_createcaaentry' => [ 'system_dns_createcaaentry' => array(
'label' => lng('serversettings.caa_entry'), 'label' => $lng['serversettings']['caa_entry'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'dns_createcaaentry', 'varname' => 'dns_createcaaentry',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'caa_caa_entry' => array(
'caa_caa_entry' => [ 'label' => $lng['serversettings']['caa_entry_custom'],
'label' => lng('serversettings.caa_entry_custom'),
'settinggroup' => 'caa', 'settinggroup' => 'caa',
'varname' => 'caa_entry', 'varname' => 'caa_entry',
'type' => 'textarea', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_defaultttl' => array(
'system_defaultttl' => [ 'label' => $lng['serversettings']['defaultttl'],
'label' => lng('serversettings.defaultttl'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'defaultttl', 'varname' => 'defaultttl',
'type' => 'number', 'type' => 'int',
'default' => 604800, /* 1 week */ 'default' => 604800, /* 1 week */
'min' => 3600, /* 1 hour */ 'int_min' => 3600, /* 1 hour */
'max' => 2147483647, /* integer max */ 'int_max' => 2147483647, /* integer max */
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_soaemail' => [ 'system_soaemail' => array(
'label' => lng('serversettings.soaemail'), 'label' => $lng['serversettings']['soaemail'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'soaemail', 'varname' => 'soaemail',
'type' => 'email', 'type' => 'string',
'string_type' => 'mail',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );

View File

@@ -2,92 +2,88 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'logging' => array(
'logging' => [ 'title' => $lng['admin']['loggersettings'],
'title' => lng('admin.loggersettings'), 'fields' => array(
'icon' => 'fa-solid fa-file-lines', 'logger_enabled' => array(
'fields' => [ 'label' => $lng['serversettings']['logger']['enable'],
'logger_enabled' => [
'label' => lng('serversettings.logger.enable'),
'settinggroup' => 'logger', 'settinggroup' => 'logger',
'varname' => 'enabled', 'varname' => 'enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'overview_option' => true 'overview_option' => true
], ),
'logger_severity' => [ 'logger_severity' => array(
'label' => lng('serversettings.logger.severity'), 'label' => $lng['serversettings']['logger']['severity'],
'settinggroup' => 'logger', 'settinggroup' => 'logger',
'varname' => 'severity', 'varname' => 'severity',
'type' => 'select', 'type' => 'option',
'default' => 1, 'default' => 1,
'select_var' => [ 'option_mode' => 'one',
1 => lng('admin.logger.normal'), 'option_options' => array(
2 => lng('admin.logger.paranoid') 1 => $lng['admin']['logger']['normal'],
], 2 => $lng['admin']['logger']['paranoid']
),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'logger_logtypes' => [ 'logger_logtypes' => array(
'label' => lng('serversettings.logger.types'), 'label' => $lng['serversettings']['logger']['types'],
'settinggroup' => 'logger', 'settinggroup' => 'logger',
'varname' => 'logtypes', 'varname' => 'logtypes',
'type' => 'select', 'type' => 'option',
'default' => 'syslog,mysql', 'default' => 'syslog,mysql',
'select_mode' => 'multiple', 'option_mode' => 'multiple',
'select_var' => [ 'option_options' => array(
'syslog' => 'syslog', 'syslog' => 'syslog',
'file' => 'file', 'file' => 'file',
'mysql' => 'mysql' 'mysql' => 'mysql'
], ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'logger_logfile' => [ 'logger_logfile' => array(
'label' => lng('serversettings.logger.logfile'), 'label' => $lng['serversettings']['logger']['logfile'],
'settinggroup' => 'logger', 'settinggroup' => 'logger',
'varname' => 'logfile', 'varname' => 'logfile',
'type' => 'text', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'logger_log_cron' => [ 'logger_log_cron' => array(
'label' => lng('serversettings.logger.logcron'), 'label' => $lng['serversettings']['logger']['logcron'],
'settinggroup' => 'logger', 'settinggroup' => 'logger',
'varname' => 'log_cron', 'varname' => 'log_cron',
'type' => 'select', 'type' => 'option',
'default' => 0, 'default' => 0,
'select_var' => [ 'option_mode' => 'one',
0 => lng('serversettings.logger.logcronoption.never'), 'option_options' => array(
1 => lng('serversettings.logger.logcronoption.once'), 0 => $lng['serversettings']['logger']['logcronoption']['never'],
2 => lng('serversettings.logger.logcronoption.always') 1 => $lng['serversettings']['logger']['logcronoption']['once'],
], 2 => $lng['serversettings']['logger']['logcronoption']['always']
),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );
?>

View File

@@ -2,144 +2,133 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Settings; 'groups' => array(
'dkim' => array(
return [ 'title' => $lng['admin']['dkimsettings'],
'groups' => [ 'fields' => array(
'dkim' => [ 'dkim_enabled' => array(
'title' => lng('admin.dkimsettings'), 'label' => $lng['dkim']['use_dkim'],
'icon' => 'fa-solid fa-fingerprint',
'fields' => [
'dkim_use_dkim' => [
'label' => lng('dkim.use_dkim'),
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'use_dkim', 'varname' => 'use_dkim',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingFieldInsertBindTask', 'save_method' => 'storeSettingFieldInsertBindTask',
'overview_option' => true 'overview_option' => true
], ),
'dkim_dkim_prefix' => [ 'dkim_prefix' => array(
'label' => lng('dkim.dkim_prefix'), 'label' => $lng['dkim']['dkim_prefix'],
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_prefix', 'varname' => 'dkim_prefix',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/etc/postfix/dkim/', 'default' => '/etc/postfix/dkim/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'dkim_privkeysuffix' => [ 'dkim_privkeysuffix' => array(
'label' => lng('dkim.privkeysuffix'), 'label' => $lng['dkim']['privkeysuffix'],
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'privkeysuffix', 'varname' => 'privkeysuffix',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\._]+$/i', 'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => '.priv', 'default' => '.priv',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'dkim_domains' => array(
'dkim_dkim_domains' => [ 'label' => $lng['dkim']['dkim_domains'],
'label' => lng('dkim.dkim_domains'),
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_domains', 'varname' => 'dkim_domains',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\._]+$/i', 'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => 'domains', 'default' => 'domains',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'dkim_dkim_dkimkeys' => [ 'dkim_dkimkeys' => array(
'label' => lng('dkim.dkim_dkimkeys'), 'label' => $lng['dkim']['dkim_dkimkeys'],
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_dkimkeys', 'varname' => 'dkim_dkimkeys',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\._]+$/i', 'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => 'dkim-keys.conf', 'default' => 'dkim-keys.conf',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'dkim_dkim_algorithm' => [ 'dkim_algorithm' => array(
'label' => lng('dkim.dkim_algorithm'), 'label' => $lng['dkim']['dkim_algorithm'],
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_algorithm', 'varname' => 'dkim_algorithm',
'type' => 'select', 'type' => 'option',
'default' => 'all', 'default' => 'all',
'select_mode' => 'multiple', 'option_mode' => 'multiple',
'select_var' => [ 'option_options' => array(
'all' => 'All', 'all' => 'All',
'sha1' => 'SHA1', 'sha1' => 'SHA1',
'sha256' => 'SHA256' 'sha256' => 'SHA256'
], ),
'save_method' => 'storeSettingFieldInsertBindTask', 'save_method' => 'storeSettingFieldInsertBindTask'
'advanced_mode' => true ),
], 'dkim_servicetype' => array(
'dkim_dkim_servicetype' => [ 'label' => $lng['dkim']['dkim_servicetype'],
'label' => lng('dkim.dkim_servicetype'),
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_servicetype', 'varname' => 'dkim_servicetype',
'type' => 'select', 'type' => 'option',
'default' => '0', 'default' => '0',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'0' => 'All', '0' => 'All',
'1' => 'E-Mail' '1' => 'E-Mail'
], ),
'save_method' => 'storeSettingFieldInsertBindTask', 'save_method' => 'storeSettingFieldInsertBindTask'
'advanced_mode' => true ),
], 'dkim_keylength' => array(
'dkim_dkim_keylength' => [ 'label' => array(
'label' => [ 'title' => $lng['dkim']['dkim_keylength']['title'],
'title' => lng('dkim.dkim_keylength.title'), 'description' => sprintf($lng['dkim']['dkim_keylength']['description'], \Froxlor\Settings::Get('dkim.dkim_prefix'))
'description' => lng('dkim.dkim_keylength.description', [Settings::Get('dkim.dkim_prefix')]) ),
],
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_keylength', 'varname' => 'dkim_keylength',
'type' => 'select', 'type' => 'option',
'default' => '1024', 'default' => '1024',
'select_var' => [ 'option_mode' => 'one',
'option_options' => array(
'1024' => '1024 Bit', '1024' => '1024 Bit',
'2048' => '2048 Bit' '2048' => '2048 Bit'
], ),
'save_method' => 'storeSettingFieldInsertBindTask' 'save_method' => 'storeSettingFieldInsertBindTask'
], ),
'dkim_dkim_notes' => [ 'dkim_notes' => array(
'label' => lng('dkim.dkim_notes'), 'label' => $lng['dkim']['dkim_notes'],
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_notes', 'varname' => 'dkim_notes',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\._]+$/i', 'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => '', 'default' => '',
'save_method' => 'storeSettingFieldInsertBindTask', 'save_method' => 'storeSettingFieldInsertBindTask'
'advanced_mode' => true ),
], 'dkimrestart_command' => array(
'dkim_dkimrestart_command' => [ 'label' => $lng['dkim']['dkimrestart_command'],
'label' => lng('dkim.dkimrestart_command'),
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkimrestart_command', 'varname' => 'dkimrestart_command',
'type' => 'text', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/etc/init.d/dkim-filter restart', 'default' => '/etc/init.d/dkim-filter restart',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );
?>

View File

@@ -4,49 +4,41 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'spf' => array(
'spf' => [ 'title' => $lng['admin']['spfsettings'],
'title' => lng('admin.spfsettings'), 'fields' => array(
'icon' => 'fa-solid fa-clipboard-check', 'spf_enabled' => array(
'fields' => [ 'label' => $lng['spf']['use_spf'],
'spf_use_spf' => [
'label' => lng('spf.use_spf'),
'settinggroup' => 'spf', 'settinggroup' => 'spf',
'varname' => 'use_spf', 'varname' => 'use_spf',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'overview_option' => true 'overview_option' => true
], ),
'spf_spf_entry' => [ 'spf_entry' => array(
'label' => lng('spf.spf_entry'), 'label' => $lng['spf']['spf_entry'],
'settinggroup' => 'spf', 'settinggroup' => 'spf',
'varname' => 'spf_entry', 'varname' => 'spf_entry',
'type' => 'text', 'type' => 'string',
'default' => '"v=spf1 a mx -all"', 'default' => '"v=spf1 a mx -all"',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );
?>

View File

@@ -2,115 +2,101 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
use Froxlor\Settings; 'groups' => array(
'security' => array(
return [ 'title' => $lng['admin']['security_settings'],
'groups' => [ 'fields' => array(
'security' => [ 'panel_unix_names' => array(
'title' => lng('admin.security_settings'), 'label' => $lng['serversettings']['unix_names'],
'icon' => 'fa-solid fa-user-lock',
'fields' => [
'panel_unix_names' => [
'label' => lng('serversettings.unix_names'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'unix_names', 'varname' => 'unix_names',
'type' => 'checkbox', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_mailpwcleartext' => [ 'system_mailpwcleartext' => array(
'label' => lng('serversettings.mailpwcleartext'), 'label' => $lng['serversettings']['mailpwcleartext'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mailpwcleartext', 'varname' => 'mailpwcleartext',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_passwordcryptfunc' => array(
'system_passwordcryptfunc' => [ 'label' => $lng['serversettings']['passwordcryptfunc'],
'label' => lng('serversettings.passwordcryptfunc'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'passwordcryptfunc', 'varname' => 'passwordcryptfunc',
'type' => 'select', 'type' => 'option',
'default' => PASSWORD_DEFAULT, 'default' => 0,
'option_options_method' => [ 'option_mode' => 'one',
'option_options_method' => array(
'\\Froxlor\\System\\Crypt', '\\Froxlor\\System\\Crypt',
'getAvailablePasswordHashes' 'getAvailablePasswordHashes'
], ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_allow_error_report_admin' => array(
'system_allow_error_report_admin' => [ 'label' => $lng['serversettings']['allow_error_report_admin'],
'label' => lng('serversettings.allow_error_report_admin'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'allow_error_report_admin', 'varname' => 'allow_error_report_admin',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_allow_error_report_customer' => [ 'system_allow_error_report_customer' => array(
'label' => lng('serversettings.allow_error_report_customer'), 'label' => $lng['serversettings']['allow_error_report_customer'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'allow_error_report_customer', 'varname' => 'allow_error_report_customer',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_allow_customer_shell' => [ 'system_allow_customer_shell' => array(
'label' => lng('serversettings.allow_allow_customer_shell'), 'label' => $lng['serversettings']['allow_allow_customer_shell'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'allow_customer_shell', 'varname' => 'allow_customer_shell',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_available_shells' => array(
'system_available_shells' => [ 'label' => $lng['serversettings']['available_shells'],
'label' => lng('serversettings.available_shells'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'available_shells', 'varname' => 'available_shells',
'type' => 'text', 'type' => 'string',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField'
'advanced_mode' => true ),
], 'system_froxlorusergroup' => array(
'system_froxlorusergroup' => [ 'label' => $lng['serversettings']['froxlorusergroup'],
'label' => lng('serversettings.froxlorusergroup'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'froxlorusergroup', 'varname' => 'froxlorusergroup',
'type' => 'text', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ 'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check', '\\Froxlor\\Validate\\Check',
'checkLocalGroup' 'checkLocalGroup'
], ),
'visible' => Settings::Get('system.nssextrausers'), 'visible' => \Froxlor\Settings::Get('system.nssextrausers')
'advanced_mode' => true ),
], )
] )
] )
] );
];

View File

@@ -1,69 +1,59 @@
<?php <?php
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2011- the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2011-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Settings
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
return array(
return [ 'groups' => array(
'groups' => [ 'diskquota' => array(
'diskquota' => [ 'title' => $lng['diskquota'],
'title' => lng('diskquota'), 'fields' => array(
'icon' => 'fa-solid fa-sliders', 'diskquota_enabled' => array(
'advanced_mode' => true, 'label' => $lng['serversettings']['diskquota_enabled'],
'fields' => [
'system_diskquota_enabled' => [
'label' => lng('serversettings.diskquota_enabled'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'diskquota_enabled', 'varname' => 'diskquota_enabled',
'type' => 'checkbox', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'overview_option' => true 'overview_option' => true
], ),
'system_diskquota_repquota_path' => [ 'diskquota_repquota_path' => array(
'label' => lng('serversettings.diskquota_repquota_path.description'), 'label' => $lng['serversettings']['diskquota_repquota_path']['description'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'diskquota_repquota_path', 'varname' => 'diskquota_repquota_path',
'type' => 'text', 'type' => 'string',
'default' => '/usr/sbin/repquota', 'default' => '/usr/sbin/repquota',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_diskquota_quotatool_path' => [ 'diskquota_quotatool_path' => array(
'label' => lng('serversettings.diskquota_quotatool_path.description'), 'label' => $lng['serversettings']['diskquota_quotatool_path']['description'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'diskquota_quotatool_path', 'varname' => 'diskquota_quotatool_path',
'type' => 'text', 'type' => 'string',
'default' => '/usr/bin/quotatool', 'default' => '/usr/bin/quotatool',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
], ),
'system_diskquota_customer_partition' => [ 'diskquota_customer_partition' => array(
'label' => lng('serversettings.diskquota_customer_partition.description'), 'label' => $lng['serversettings']['diskquota_customer_partition']['description'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'diskquota_customer_partition', 'varname' => 'diskquota_customer_partition',
'type' => 'text', 'type' => 'string',
'default' => '/dev/root', 'default' => '/dev/root',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );
?>

View File

@@ -2,195 +2,344 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Admins;
use Froxlor\CurrentUser;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection; use Froxlor\Api\Commands\Admins as Admins;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
if (($page == 'admins' || $page == 'overview') && $userinfo['change_serversettings'] == '1') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins");
$fields = array(
'loginname' => $lng['login']['username'],
'name' => $lng['customer']['name'],
'diskspace' => $lng['customer']['diskspace'],
'diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
'traffic' => $lng['customer']['traffic'],
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
'deactivated' => $lng['admin']['deactivated']
);
try { try {
$admin_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.admins.php'; // get total count
$collection = (new Collection(Admins::class, $userinfo)) $json_result = Admins::getLocal($userinfo)->listingCount();
->withPagination($admin_list_data['admin_list']['columns'], $admin_list_data['admin_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Admins::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$admins = '';
$sortcode = $paging->getHtmlSortCode($lng, true);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
$dec_places = Settings::Get('panel.decimal_places');
foreach ($result['list'] as $row) {
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
// percent-values for progressbar
// For Disk usage
if ($row['diskspace'] > 0) {
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
$disk_doublepercent = round($disk_percent * 2, 2);
} else {
$disk_percent = 0;
$disk_doublepercent = 0;
}
// For Traffic usage
if ($row['traffic'] > 0) {
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
$traffic_doublepercent = round($traffic_percent * 2, 2);
} else {
$traffic_percent = 0;
$traffic_doublepercent = 0;
}
// fix progress-bars if value is >100%
if ($disk_percent > 100) {
$disk_percent = 100;
}
if ($traffic_percent > 100) {
$traffic_percent = 100;
}
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("admins/admins_admin") . "\";");
$count ++;
} }
UI::view('user/table.html.twig', [ $admincount = $result['count'] . " / " . $paging->getEntries();
'listing' => Listing::format($collection, $admin_list_data, 'admin_list'), eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins") . "\";");
'actions_links' => [
[
'href' => $linker->getLink(['section' => 'admins', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.admin_add')
]
]
]);
} elseif ($action == 'su') { } elseif ($action == 'su') {
try { try {
$json_result = Admins::getLocal($userinfo, [ $json_result = Admins::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
$destination_admin = $result['loginname']; $destination_admin = $result['loginname'];
if ($destination_admin != '' && $result['adminid'] != $userinfo['userid']) { if ($destination_admin != '' && $result['adminid'] != $userinfo['userid']) {
$result['switched_user'] = CurrentUser::getData(); $result_stmt = Database::prepare("
$result['adminsession'] = 1; SELECT * FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = :userid
$result['userid'] = $result['adminid']; ");
CurrentUser::setData($result); $result = Database::pexecute_first($result_stmt, array(
'userid' => $userinfo['userid']
));
$log->logAction( $s = \Froxlor\Froxlor::genSessionId();
FroxlorLogger::ADM_ACTION, $ins_stmt = Database::prepare("
LOG_INFO, INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET
"switched adminuser and is now '" . $destination_admin . "'" `hash` = :hash, `userid` = :userid, `ipaddress` = :ip,
); `useragent` = :ua, `lastactivity` = :la,
Response::redirectTo('admin_index.php'); `language` = :lang, `adminsession` = '1'
");
$ins_data = array(
'hash' => $s,
'userid' => $id,
'ip' => $result['ipaddress'],
'ua' => $result['useragent'],
'la' => time(),
'lang' => $result['language']
);
Database::pexecute($ins_stmt, $ins_data);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "switched adminuser and is now '" . $destination_admin . "'");
\Froxlor\UI\Response::redirectTo('admin_index.php', array(
's' => $s
));
} else { } else {
Response::redirectTo('index.php', [ \Froxlor\UI\Response::redirectTo('index.php', array(
'action' => 'login' 'action' => 'login'
]); ));
} }
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Admins::getLocal($userinfo, [ $json_result = Admins::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['loginname'] != '') { if ($result['loginname'] != '') {
if ($result['adminid'] == $userinfo['userid']) { if ($result['adminid'] == $userinfo['userid']) {
Response::standardError('youcantdeleteyourself'); \Froxlor\UI\Response::standard_error('youcantdeleteyourself');
} }
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
Admins::getLocal($userinfo, [ Admins::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->delete(); ))->delete();
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('admin_admin_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_admin_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['loginname']); ), $result['loginname']);
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
Admins::getLocal($userinfo, $_POST)->add(); Admins::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$ipaddress = [];
$ipaddress[-1] = lng('admin.allips'); $language_options = '';
foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $userinfo['language'], true);
}
$ipaddress = \Froxlor\UI\HTML::makeoption($lng['admin']['allips'], "-1");
$ipsandports_stmt = Database::query(" $ipsandports_stmt = Database::query("
SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC
"); ");
while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
$ipaddress[$row['id']] = $row['ip']; $ipaddress .= \Froxlor\UI\HTML::makeoption($row['ip'], $row['id']);
} }
$admin_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_add.php'; $customers_ul = \Froxlor\UI\HTML::makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$domains_ul = \Froxlor\UI\HTML::makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
UI::view('user/form.html.twig', [ $admin_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_add.php';
'formaction' => $linker->getLink(['section' => 'admins']), $admin_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($admin_add_data);
'formdata' => $admin_add_data['admin_add']
]); $title = $admin_add_data['admin_add']['title'];
$image = $admin_add_data['admin_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = Admins::getLocal($userinfo, [ $json_result = Admins::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['loginname'] != '') { if ($result['loginname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
Admins::getLocal($userinfo, $_POST)->update(); Admins::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
$result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places); $result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places);
$result['diskspace'] = round($result['diskspace'] / 1024, $dec_places); $result['diskspace'] = round($result['diskspace'] / 1024, $dec_places);
$result['email'] = $idna_convert->decode($result['email']); $result['email'] = $idna_convert->decode($result['email'] ?? '');
$ipaddress = []; $customers_ul = \Froxlor\UI\HTML::makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, $result['customers'], true, true);
$ipaddress[-1] = lng('admin.allips'); if ($result['customers'] == '-1') {
$ipsandports_stmt = Database::query(" $result['customers'] = '';
SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC
");
while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
$ipaddress[$row['id']] = $row['ip'];
} }
$result = PhpHelper::htmlentitiesArray($result); $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
if ($result['diskspace'] == '-1') {
$result['diskspace'] = '';
}
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
if ($result['traffic'] == '-1') {
$result['traffic'] = '';
}
$domains_ul = \Froxlor\UI\HTML::makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, $result['domains'], true, true);
if ($result['domains'] == '-1') {
$result['domains'] = '';
}
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
if ($result['subdomains'] == '-1') {
$result['subdomains'] = '';
}
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
if ($result['emails'] == '-1') {
$result['emails'] = '';
}
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
if ($result['email_accounts'] == '-1') {
$result['email_accounts'] = '';
}
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
if ($result['email_forwarders'] == '-1') {
$result['email_forwarders'] = '';
}
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
if ($result['email_quota'] == '-1') {
$result['email_quota'] = '';
}
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
if ($result['ftps'] == '-1') {
$result['ftps'] = '';
}
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true);
if ($result['mysqls'] == '-1') {
$result['mysqls'] = '';
}
$language_options = '';
foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $result['def_language'], true);
}
$ipaddress = \Froxlor\UI\HTML::makeoption($lng['admin']['allips'], "-1", $result['ip']);
$ipsandports_stmt = Database::query("
SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `id`, `ip` ORDER BY `ip`, `port` ASC
");
while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
$ipaddress .= \Froxlor\UI\HTML::makeoption($row['ip'], $row['id'], $result['ip']);
}
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$admin_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_edit.php'; $admin_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_edit.php';
$admin_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($admin_edit_data);
UI::view('user/form.html.twig', [ $title = $admin_edit_data['admin_edit']['title'];
'formaction' => $linker->getLink(['section' => 'admins', 'id' => $id]), $image = $admin_edit_data['admin_edit']['image'];
'formdata' => $admin_edit_data['admin_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins_edit") . "\";");
]);
} }
} }
} }

View File

@@ -1,234 +1,443 @@
<?php <?php
/** /*
* This file is part of the Froxlor project. * +----------------------------------------------------------------------+
* Copyright (c) 2010 the Froxlor Team (see authors). * | APC |
* +----------------------------------------------------------------------+
* | Copyright (c) 2006-2011 The PHP Group |
* +----------------------------------------------------------------------+
* | This source file is subject to version 3.01 of the PHP license, |
* | that is bundled with this package in the file LICENSE, and is |
* | available through the world-wide-web at the following url: |
* | http://www.php.net/license/3_01.txt |
* | If you did not receive a copy of the PHP license and are unable to |
* | obtain it through the world-wide-web, please send a note to |
* | license@php.net so we can mail you a copy immediately. |
* +----------------------------------------------------------------------+
* | Authors: Ralf Becker <beckerr@php.net> |
* | Rasmus Lerdorf <rasmus@php.net> |
* | Ilia Alshanetsky <ilia@prohost.org> |
* +----------------------------------------------------------------------+
* *
* This program is free software; you can redistribute it and/or * All other licensing and usage conditions are those of the PHP Group.
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Based on https://github.com/krakjoe/apcu/blob/master/apc.php
* but WITHOUT ANY WARRANTY; without even the implied warranty of * Implemented into Froxlor: Janos Muzsi <muzsij@hypernics.hu>
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @author Janos Muzsi <muzsij@hypernics.hu>
* @author Ralf Becker <beckerr@php.net>
* @author Rasmus Lerdorf <rasmus@php.net>
* @author Ilia Alshanetsky <ilia@prohost.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*
* Based on https://github.com/krakjoe/apcu/blob/master/apc.php, which is
* licensed under the PHP licence (version 3.01), which can be viewed
* online at https://www.php.net/license/3_01.txt
*/ */
define('AREA', 'admin');
use Froxlor\FroxlorLogger; require './lib/init.php';
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
use Froxlor\UI\HTML;
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
$horizontal_bar_size = 950; // 1280px window width $horizontal_bar_size = 950; // 1280px window width
if ($action == 'delete' && function_exists('apcu_clear_cache') && $userinfo['change_serversettings'] == '1') { if ($action == 'delete' && function_exists('apcu_clear_cache') && $userinfo['change_serversettings'] == '1') {
if ($_POST['send'] == 'send') { apcu_clear_cache();
apcu_clear_cache(); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "cleared APCu cache");
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "cleared APCu cache"); header('Location: ' . $linker->getLink(array(
header('Location: ' . $linker->getLink([ 'section' => 'apcuinfo',
'section' => 'apcuinfo', 'page' => 'showinfo'
'page' => 'showinfo' )));
])); exit();
exit();
} else {
HTML::askYesNo('cache_reallydelete', $filename, [
'page' => $page,
'action' => 'delete',
], '', [
'section' => 'apcuinfo',
'page' => 'showinfo'
]);
}
} }
if (!function_exists('apcu_cache_info') || !function_exists('apcu_sma_info')) { if (! function_exists('apcu_cache_info') || ! function_exists('apcu_sma_info')) {
Response::standardError(lng('error.no_apcuinfo')); \Froxlor\UI\Response::standard_error($lng['error']['no_apcuinfo']);
} }
if ($page == 'showinfo' && $userinfo['change_serversettings'] == '1') { if ($page == 'showinfo') {
$cache = apcu_cache_info(); $cache = apcu_cache_info();
$mem = apcu_sma_info(); $mem = apcu_sma_info();
$time = time(); $time = time();
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_apcuinfo"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_apcuinfo");
$passtime = $time - $cache['start_time'] > 0 ? $time - $cache['start_time'] : 1; // zero division
$mem_size = $mem['num_seg'] * $mem['seg_size'];
$mem_avail = $mem['avail_mem'];
$mem_used = $mem_size - $mem_avail;
$seg_size = bsize($mem['seg_size']);
$sharedmem = sprintf($lng['apcuinfo']['sharedmemval'], $mem['num_seg'], $seg_size, $cache['memory_type']);
$req_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits'] + $cache['num_misses']) / $passtime) : 0);
$hit_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits']) / $passtime) : 0);
$miss_rate_user = sprintf("%.2f", $cache['num_misses'] ? (($cache['num_misses']) / $passtime) : 0);
$insert_rate_user = sprintf("%.2f", $cache['num_inserts'] ? (($cache['num_inserts']) / $passtime) : 0);
$apcversion = phpversion('apcu');
$phpversion = phpversion();
$number_vars = $cache['num_entries'];
$starttime = date('Y-m-d H:i:s', $cache['start_time']);
$uptime_duration = duration($cache['start_time']);
$size_vars = bsize($cache['mem_size']);
$num_hits_and_misses = $cache['num_hits'] + $cache['num_misses'];
$num_hits_and_misses = 0 >= $num_hits_and_misses ? 1 : $num_hits_and_misses;
// check for possible empty values that are used in the templates // check for possible empty values that are used in the templates
if (!isset($cache['file_upload_progress'])) { if (! isset($cache['file_upload_progress'])) {
$cache['file_upload_progress'] = lng('logger.unknown'); $cache['file_upload_progress'] = $lng['logger']['unknown'];
} }
if (!isset($cache['num_expunges'])) { if (! isset($cache['num_expunges'])) {
$cache['num_expunges'] = lng('logger.unknown'); $cache['num_expunges'] = $lng['logger']['unknown'];
} }
$overview = [ $runtimelines = '';
'mem_size' => $mem['num_seg'] * $mem['seg_size'],
'mem_avail' => $mem['avail_mem'],
'mem_used' => ($mem['num_seg'] * $mem['seg_size']) - $mem['avail_mem'],
'seg_size' => bsize($mem['seg_size']),
'num_hits' => $cache['num_hits'],
'num_misses' => $cache['num_misses'],
'num_inserts' => $cache['num_inserts'],
'req_rate_user' => sprintf("%.2f",
$cache['num_hits'] ? (($cache['num_hits'] + $cache['num_misses']) / ($time - $cache['start_time'])) : 0),
'hit_rate_user' => sprintf("%.2f",
$cache['num_hits'] ? (($cache['num_hits']) / ($time - $cache['start_time'])) : 0),
'miss_rate_user' => sprintf("%.2f",
$cache['num_misses'] ? (($cache['num_misses']) / ($time - $cache['start_time'])) : 0),
'insert_rate_user' => sprintf("%.2f",
$cache['num_inserts'] ? (($cache['num_inserts']) / ($time - $cache['start_time'])) : 0),
'apcversion' => phpversion('apcu'),
'phpversion' => phpversion(),
'number_vars' => $cache['num_entries'],
'size_vars' => bsize($cache['mem_size']),
'num_hits_and_misses' => 0 >= ($cache['num_hits'] + $cache['num_misses']) ? 1 : ($cache['num_hits'] + $cache['num_misses']),
'file_upload_progress' => $cache['file_upload_progress'],
'num_expunges' => $cache['num_expunges'],
'host' => (function_exists('gethostname')
? gethostname()
: (php_uname('n')
?: (empty($_SERVER['SERVER_NAME'])
? $_SERVER['HOST_NAME']
: $_SERVER['SERVER_NAME']
)
)
),
'server' => $_SERVER['SERVER_SOFTWARE'] ?: '',
'start_time' => $cache['start_time'],
'uptime' => duration($cache['start_time'])
];
$overview['mem_used_percentage'] = number_format(($overview['mem_used'] / $overview['mem_avail']) * 100, 1);
$overview['num_hits_percentage'] = number_format(($overview['num_hits'] / $overview['num_hits_and_misses']) * 100,
1);
$overview['num_misses_percentage'] = number_format(($overview['num_misses'] / $overview['num_hits_and_misses']) * 100,
1);
$overview['readable'] = [
'mem_size' => bsize($overview['mem_size']),
'mem_avail' => bsize($overview['mem_avail']),
'mem_used' => bsize($overview['mem_used']),
'num_hits' => number_format($overview['num_hits']),
'num_misses' => number_format($overview['num_misses']),
'number_vars' => number_format($overview['number_vars']),
];
$overview['runtimelines'] = [];
foreach (ini_get_all('apcu') as $name => $v) { foreach (ini_get_all('apcu') as $name => $v) {
$value = $v['local_value']; $value = $v['local_value'];
$overview['runtimelines'][$name] = $value; eval("\$runtimelines.=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/runtime_line") . "\";");
} }
// Fragementation: (freeseg - 1) / total_seg $freemem = bsize($mem_avail) . sprintf(" (%.1f%%)", $mem_avail * 100 / $mem_size);
$usedmem = bsize($mem_used) . sprintf(" (%.1f%%)", $mem_used * 100 / $mem_size);
$hits = $cache['num_hits'] . @sprintf(" (%.1f%%)", $cache['num_hits'] * 100 / $num_hits_and_misses);
$misses = $cache['num_misses'] . @sprintf(" (%.1f%%)", $cache['num_misses'] * 100 / $num_hits_and_misses);
// Fragmentation: (freeseg - 1) / total_seg
$nseg = $freeseg = $fragsize = $freetotal = 0; $nseg = $freeseg = $fragsize = $freetotal = 0;
for ($i = 0; $i < $mem['num_seg']; $i++) { for ($i = 0; $i < $mem['num_seg']; $i ++) {
$ptr = 0; $ptr = 0;
foreach ($mem['block_lists'][$i] as $block) { foreach ($mem['block_lists'][$i] as $block) {
if ($block['offset'] != $ptr) { if ($block['offset'] != $ptr) {
++$nseg; ++ $nseg;
} }
$ptr = $block['offset'] + $block['size']; $ptr = $block['offset'] + $block['size'];
/* Only consider blocks <5M for the fragmentation % */ /* Only consider blocks <5M for the fragmentation % */
if ($block['size'] < (5 * 1024 * 1024)) { if ($block['size'] < (5 * 1024 * 1024))
$fragsize += $block['size']; $fragsize += $block['size'];
}
$freetotal += $block['size']; $freetotal += $block['size'];
} }
$freeseg += count($mem['block_lists'][$i]); $freeseg += count($mem['block_lists'][$i]);
} }
$overview['fragmentation'] = [];
if ($freeseg > 1) { if ($freeseg > 1) {
$overview['fragmentation']['used_percentage'] = number_format(($fragsize / $freetotal) * 100, 1); $frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize / $freetotal) * 100, bsize($fragsize), bsize($freetotal), $freeseg);
$overview['fragmentation']['used_bytes'] = $fragsize;
$overview['fragmentation']['total_bytes'] = $freetotal;
$overview['fragmentation']['num_frags'] = $freeseg;
$overview['fragmentation']['readable'] = [
'used_bytes' => bsize($fragsize),
'total_bytes' => bsize($freetotal),
'num_frags' => number_format($freeseg)
];
} else { } else {
$overview['fragmentation'] = 0; $frag = "0%";
} }
UI::view('settings/apcuinfo.html.twig', [ foreach (ini_get_all('apcu') as $name => $v) {
'apcuinfo' => $overview $value = $v['local_value'];
]);
}
// pretty printer for byte values
function bsize($size)
{
$i = 0;
$val = ['b', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
while (($size / 1024) > 1) {
$size /= 1024;
++$i;
} }
return sprintf(
'%.2f%s%s', $img_src1 = '';
$size, $img_src2 = '';
'', $img_src3 = '';
$val[$i] if (graphics_avail()) {
$img_src = $linker->getLink(array(
'section' => 'apcuinfo',
'page' => 'img1',
'action' => mt_rand(0, 1000000)
));
eval("\$img_src1=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/img_line") . "\";");
$img_src = $linker->getLink(array(
'section' => 'apcuinfo',
'page' => 'img2',
'action' => mt_rand(0, 1000000)
));
eval("\$img_src2=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/img_line") . "\";");
$img_src = $linker->getLink(array(
'section' => 'apcuinfo',
'page' => 'img3',
'action' => mt_rand(0, 1000000)
));
eval("\$img_src3=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/img_line") . "\";");
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/showinfo") . "\";");
} elseif ($page == 'img1') {
$mem = apcu_sma_info();
$size = 460;
$image = imagecreate($size + 5, $size + 5);
$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$col_red = imagecolorallocate($image, 0xD0, 0x60, 0x30);
$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
$col_black = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $col_white);
$s = $mem['num_seg'] * $mem['seg_size'];
$a = $mem['avail_mem'];
$x = $y = $size / 2;
$fuzz = 0.000001;
// This block of code creates the pie chart. It is a lot more complex than you
// would expect because we try to visualize any memory fragmentation as well.
$angle_from = 0;
$string_placement = array();
for ($i = 0; $i < $mem['num_seg']; $i ++) {
$ptr = 0;
$free = $mem['block_lists'][$i];
uasort($free, 'block_sort');
foreach ($free as $block) {
if ($block['offset'] != $ptr) { // Used block
$angle_to = $angle_from + ($block['offset'] - $ptr) / $s;
if (($angle_to + $fuzz) > 1)
$angle_to = 1;
if (($angle_to * 360) - ($angle_from * 360) >= 1) {
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red);
if (($angle_to - $angle_from) > 0.05) {
array_push($string_placement, array(
$angle_from,
$angle_to
));
}
}
$angle_from = $angle_to;
}
$angle_to = $angle_from + ($block['size']) / $s;
if (($angle_to + $fuzz) > 1)
$angle_to = 1;
if (($angle_to * 360) - ($angle_from * 360) >= 1) {
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_green);
if (($angle_to - $angle_from) > 0.05) {
array_push($string_placement, array(
$angle_from,
$angle_to
));
}
}
$angle_from = $angle_to;
$ptr = $block['offset'] + $block['size'];
}
if ($ptr < $mem['seg_size']) { // memory at the end
$angle_to = $angle_from + ($mem['seg_size'] - $ptr) / $s;
if (($angle_to + $fuzz) > 1)
$angle_to = 1;
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red);
if (($angle_to - $angle_from) > 0.05) {
array_push($string_placement, array(
$angle_from,
$angle_to
));
}
}
}
foreach ($string_placement as $angle) {
text_arc($image, $x, $y, $size, $angle[0] * 360, $angle[1] * 360, $col_black, bsize($s * ($angle[1] - $angle[0])));
}
header("Content-type: image/png");
imagepng($image);
exit();
} elseif ($page == 'img2') {
$cache = apcu_cache_info();
$size = $horizontal_bar_size;
$image = imagecreate($size + 5, 140);
$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$col_red = imagecolorallocate($image, 0xD0, 0x60, 0x30);
$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
$col_black = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $col_white);
$s = $cache['num_hits'] + $cache['num_misses'];
$a = $cache['num_hits'];
fill_box($image, 1, 10, $s ? ($a * ($size - 21) / $s) : $size, 50, $col_black, $col_green /* , sprintf("%.1f%%", $s ? $cache['num_hits'] * 100 / $s : 0) */
); );
fill_box($image, 1, 80, $s ? max(4, ($s - $a) * ($size - 21) / $s) : $size, 50, $col_black, $col_red /* , sprintf("%.1f%%", $s ? $cache['num_misses'] * 100 / $s : 0) */
);
header("Content-type: image/png");
imagepng($image);
exit();
} elseif ($page == 'img3') {
$mem = apcu_sma_info();
$size = $horizontal_bar_size;
$image = imagecreate($size, 70);
$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$col_red = imagecolorallocate($image, 0xD0, 0x60, 0x30);
$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
$col_black = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $col_white);
$s = $mem['num_seg'] * $mem['seg_size'];
$a = $mem['avail_mem'];
$x = 10;
$y = 0;
// This block of code creates the bar chart. It is a lot more complex than you
// would expect because we try to visualize any memory fragmentation as well.
for ($i = 0; $i < $mem['num_seg']; $i ++) {
$ptr = 0;
$free = $mem['block_lists'][$i];
uasort($free, 'block_sort');
foreach ($free as $block) {
if ($block['offset'] != $ptr) { // Used block
$h = ($size - 5) * ($block['offset'] - $ptr) / $s;
if ($h > 0) {
fill_box($image, $y, $x, $h, 50, $col_black, $col_red);
}
$y += $h;
}
$h = ($size - 5) * ($block['size']) / $s;
if ($h > 0) {
fill_box($image, $y, $x, $h, 50, $col_black, $col_green);
}
$y += $h;
$ptr = $block['offset'] + $block['size'];
}
if ($ptr < $mem['seg_size']) { // memory at the end
$h = ($size - 5) * ($mem['seg_size'] - $ptr) / $s;
if ($h > 0) {
fill_box($image, $y, $x, $h, 50, $col_black, $col_red, bsize($mem['seg_size'] - $ptr), $j ++);
}
}
}
header("Content-type: image/png");
imagepng($image);
exit();
}
function graphics_avail()
{
return extension_loaded('gd');
}
// pretty printer for byte values
//
function bsize($s)
{
foreach (array(
'',
'K',
'M',
'G'
) as $i => $k) {
if ($s < 1024)
break;
$s /= 1024;
}
return sprintf("%5.1f %sBytes", $s, $k);
} }
function duration($ts) function duration($ts)
{ {
global $time; global $time;
$years = (int)((($time - $ts) / (7 * 86400)) / 52.177457); $years = (int) ((($time - $ts) / (7 * 86400)) / 52.177457);
$rem = (int)(($time - $ts) - ($years * 52.177457 * 7 * 86400)); $rem = (int) (($time - $ts) - ($years * 52.177457 * 7 * 86400));
$weeks = (int)(($rem) / (7 * 86400)); $weeks = (int) (($rem) / (7 * 86400));
$days = (int)(($rem) / 86400) - $weeks * 7; $days = (int) (($rem) / 86400) - $weeks * 7;
$hours = (int)(($rem) / 3600) - $days * 24 - $weeks * 7 * 24; $hours = (int) (($rem) / 3600) - $days * 24 - $weeks * 7 * 24;
$mins = (int)(($rem) / 60) - $hours * 60 - $days * 24 * 60 - $weeks * 7 * 24 * 60; $mins = (int) (($rem) / 60) - $hours * 60 - $days * 24 * 60 - $weeks * 7 * 24 * 60;
$str = ''; $str = '';
if ($years == 1) { if ($years == 1)
$str .= "$years year, "; $str .= "$years year, ";
} if ($years > 1)
if ($years > 1) {
$str .= "$years years, "; $str .= "$years years, ";
} if ($weeks == 1)
if ($weeks == 1) {
$str .= "$weeks week, "; $str .= "$weeks week, ";
} if ($weeks > 1)
if ($weeks > 1) {
$str .= "$weeks weeks, "; $str .= "$weeks weeks, ";
} if ($days == 1)
if ($days == 1) {
$str .= "$days day,"; $str .= "$days day,";
} if ($days > 1)
if ($days > 1) {
$str .= "$days days,"; $str .= "$days days,";
} if ($hours == 1)
if ($hours == 1) {
$str .= " $hours hour and"; $str .= " $hours hour and";
} if ($hours > 1)
if ($hours > 1) {
$str .= " $hours hours and"; $str .= " $hours hours and";
} if ($mins == 1)
if ($mins == 1) {
$str .= " 1 minute"; $str .= " 1 minute";
} else { else
$str .= " $mins minutes"; $str .= " $mins minutes";
}
return $str; return $str;
} }
function block_sort($array1, $array2)
{
if ($array1['offset'] > $array2['offset']) {
return 1;
} else {
return - 1;
}
}
function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $color2, $text = '', $placeindex = 0)
{
$r = $diameter / 2;
$w = deg2rad((360 + $start + ($end - $start) / 2) % 360);
if (function_exists("imagefilledarc")) {
// exists only if GD 2.0.1 is available
imagefilledarc($im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL | IMG_ARC_EDGED);
} else {
imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start + 1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end - 1)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
imagefill($im, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $color2);
}
if ($text) {
if ($placeindex > 0) {
imageline($im, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $diameter, $placeindex * 12, $color1);
imagestring($im, 4, $diameter, $placeindex * 12, $text, $color1);
} else {
imagestring($im, 4, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $text, $color1);
}
}
}
function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $text, $placeindex = 0)
{
$r = $diameter / 2;
$w = deg2rad((360 + $start + ($end - $start) / 2) % 360);
if ($placeindex > 0) {
imageline($im, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $diameter, $placeindex * 12, $color1);
imagestring($im, 4, $diameter, $placeindex * 12, $text, $color1);
} else {
imagestring($im, 4, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $text, $color1);
}
}
function fill_box($im, $x, $y, $w, $h, $color1, $color2, $text = '', $placeindex = '')
{
global $col_black;
$x1 = $x + $w - 1;
$y1 = $y + $h - 1;
imagerectangle($im, $x, $y1, $x1 + 1, $y + 1, $col_black);
if ($y1 > $y)
imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
else
imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
imagerectangle($im, $x, $y1, $x1, $y, $color1);
if ($text) {
if ($placeindex > 0) {
if ($placeindex < 16) {
$px = 5;
$py = $placeindex * 12 + 6;
imagefilledrectangle($im, $px + 90, $py + 3, $px + 90 - 4, $py - 3, $color2);
imageline($im, $x, $y + $h / 2, $px + 90, $py, $color2);
imagestring($im, 2, $px, $py - 6, $text, $color1);
} else {
if ($placeindex < 31) {
$px = $x + 40 * 2;
$py = ($placeindex - 15) * 12 + 6;
} else {
$px = $x + 40 * 2 + 100 * intval(($placeindex - 15) / 15);
$py = ($placeindex % 15) * 12 + 6;
}
imagefilledrectangle($im, $px, $py + 3, $px - 4, $py - 3, $color2);
imageline($im, $x + $w, $y + $h / 2, $px, $py, $color2);
imagestring($im, 2, $px + 2, $py - 6, $text, $color1);
}
} else {
imagestring($im, 4, $x + 5, $y1 - 16, $text, $color1);
}
}
}

View File

@@ -2,197 +2,225 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2016 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Michael Kaufmann <mkaufmann@nutime.de>
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Frontend
* *
* You should have received a copy of the GNU General Public License * @since 0.9.35
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
* *
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Froxlor;
use Froxlor\FroxlorLogger;
use Froxlor\Http\HttpClient; use Froxlor\Http\HttpClient;
use Froxlor\Install\AutoUpdate;
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
if ($page != 'error') { // define update-uri
// check for webupdate to be enabled define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . $version);
if (Settings::Config('enable_webupdate') != true) { define('RELEASE_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip");
Response::redirectTo($filename, [ define('CHECKSUM_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256");
'page' => 'error',
'errno' => 11 // check for archive-stuff
]); if (! extension_loaded('zip')) {
} \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error',
'errno' => 2
));
}
// 0.10.x requires 7.0 at least
if (version_compare("7.0.0", PHP_VERSION, ">=")) {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error',
'errno' => 10
));
} }
// display initial version check // display initial version check
if ($page == 'overview') { if ($page == 'overview') {
// log our actions // log our actions
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "checking auto-update"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "checking auto-update");
// check for new version // check for new version
try { try {
$result = AutoUpdate::checkVersion(); $latestversion = HttpClient::urlGet(UPDATE_URI, true, 3);
} catch (Exception $e) { } catch (\Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error("Version-check currently unavailable, please try again later");
} }
$latestversion = explode('|', $latestversion);
if ($result == 1) { if (is_array($latestversion) && count($latestversion) >= 1) {
$_version = $latestversion[0];
$_message = isset($latestversion[1]) ? $latestversion[1] : '';
$_link = isset($latestversion[2]) ? $latestversion[2] : htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
// add the branding so debian guys are not gettings confused
// about their version-number
$version_label = $_version . $branding;
$version_link = $_link;
$message_addinfo = $_message;
// not numeric -> error-message
if (! preg_match('/^((\d+\\.)(\d+\\.)(\d+\\.)?(\d+)?(\-(svn|dev|rc)(\d+))?)$/', $_version)) {
// check for customized version to not output
// "There is a newer version of froxlor" besides the error-message
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error',
'errno' => 3
));
} elseif (\Froxlor\Froxlor::versionCompare2($version, $_version) == - 1) {
// there is a newer version - yay
$isnewerversion = 1;
} else {
// nothing new
$isnewerversion = 0;
}
// anzeige über version-status mit ggfls. formular // anzeige über version-status mit ggfls. formular
// zum update schritt #1 -> download // zum update schritt #1 -> download
$text = lng('admin.newerversionavailable') . ' ' . lng('admin.newerversiondetails', [AutoUpdate::getFromResult('version'), Froxlor::VERSION]); if ($isnewerversion == 1) {
$text = 'There is a newer version available. Update to version <b>' . $_version . '</b> now?<br/>(Your current version is: ' . $version . ')';
$upd_formfield = [ $hiddenparams = '<input type="hidden" name="newversion" value="' . $_version . '" />';
'updates' => [ $yesfile = $filename . '?s=' . $s . '&amp;page=getdownload';
'title' => lng('update.update'), eval("echo \"" . \Froxlor\UI\Template::getTemplate("misc/question_yesno", true) . "\";");
'image' => 'fa-solid fa-download', exit();
'sections' => [ } elseif ($isnewerversion == 0) {
'section_autoupd' => [ // all good
'fields' => [ \Froxlor\UI\Response::standard_success('noupdatesavail');
'newversion' => ['type' => 'hidden', 'value' => AutoUpdate::getFromResult('version')]
]
]
],
'buttons' => [
[
'class' => 'btn-outline-secondary',
'label' => lng('panel.cancel'),
'type' => 'reset'
],
[
'label' => lng('update.proceed')
]
]
]
];
UI::view('user/form-note.html.twig', [
'formaction' => $linker->getLink(['section' => 'autoupdate', 'page' => 'getdownload']),
'formdata' => $upd_formfield['updates'],
// alert
'type' => 'warning',
'alert_msg' => $text
]);
} else if ($result < 0 || $result > 1) {
// remote errors
if ($result < 0) {
Response::dynamicError(AutoUpdate::getLastError());
} else { } else {
Response::redirectTo($filename, [ \Froxlor\UI\Response::standard_error('customized_version');
'page' => 'error',
'errno' => $result
]);
} }
} else {
// no new version
Response::standardSuccess('update.noupdatesavail', (Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : ''));
} }
} // download the new archive } // download the new archive
elseif ($page == 'getdownload') { elseif ($page == 'getdownload') {
// retrieve the new version from the form // retrieve the new version from the form
$newversion = isset($_POST['newversion']) ? $_POST['newversion'] : null; $newversion = isset($_POST['newversion']) ? $_POST['newversion'] : null;
$result = 6;
// valid? // valid?
if ($newversion !== null) { if ($newversion !== null) {
$result = AutoUpdate::downloadZip($newversion);
if (!is_numeric($result)) { // define files to get
// to the next step $toLoad = str_replace('{version}', $newversion, RELEASE_URI);
Response::redirectTo($filename, [ $toCheck = str_replace('{version}', $newversion, CHECKSUM_URI);
'page' => 'extract',
'archive' => $result // check for local destination folder
]); if (! is_dir(\Froxlor\Froxlor::getInstallDir() . '/updates/')) {
mkdir(\Froxlor\Froxlor::getInstallDir() . '/updates/');
} }
// name archive
$localArchive = \Froxlor\Froxlor::getInstallDir() . '/updates/' . basename($toLoad);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "Downloading " . $toLoad . " to " . $localArchive);
// remove old archive
if (file_exists($localArchive)) {
@unlink($localArchive);
}
// get archive data
try {
HttpClient::fileGet($toLoad, $localArchive);
} catch (Exception $e) {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error',
'errno' => 4
));
}
// validate the integrity of the downloaded file
$_shouldsum = HttpClient::urlGet($toCheck);
if (! empty($_shouldsum)) {
$_t = explode(" ", $_shouldsum);
$shouldsum = $_t[0];
} else {
$shouldsum = null;
}
$filesum = hash_file('sha256', $localArchive);
if ($filesum != $shouldsum) {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error',
'errno' => 9
));
}
// to the next step
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'extract',
'archive' => basename($localArchive)
));
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => $result 'errno' => 6
]); ));
} // extract and install new version } // extract and install new version
elseif ($page == 'extract') { elseif ($page == 'extract') {
$toExtract = isset($_GET['archive']) ? $_GET['archive'] : null;
$localArchive = \Froxlor\Froxlor::getInstallDir() . '/updates/' . $toExtract;
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$toExtract = isset($_POST['archive']) ? $_POST['archive'] : null; // decompress from zip
$localArchive = Froxlor::getInstallDir() . '/updates/' . $toExtract; $zip = new ZipArchive();
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "Extracting " . $localArchive . " to " . Froxlor::getInstallDir()); $res = $zip->open($localArchive);
$result = AutoUpdate::extractZip($localArchive); if ($res === true) {
if ($result > 0) { $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "Extracting " . $localArchive . " to " . \Froxlor\Froxlor::getInstallDir());
$zip->extractTo(\Froxlor\Froxlor::getInstallDir());
$zip->close();
// success - remove unused archive
@unlink($localArchive);
// wait a bit before we redirect to be sure
sleep(2);
} else {
// error // error
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => $result 'errno' => 8
]); ));
} }
// redirect to update-page
Response::redirectTo('admin_updates.php'); // redirect to update-page?
} else { \Froxlor\UI\Response::redirectTo('admin_updates.php', array(
$toExtract = isset($_GET['archive']) ? $_GET['archive'] : null; 's' => $s
$localArchive = Froxlor::getInstallDir() . '/updates/' . $toExtract; ));
} }
if (!file_exists($localArchive)) { if (! file_exists($localArchive)) {
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 7 'errno' => 7
]); ));
} }
$text = lng('admin.extractdownloadedzip', [$toExtract]); $text = 'Extract downloaded archive "' . $toExtract . '"?';
$hiddenparams = '';
$upd_formfield = [ $yesfile = $filename . '?s=' . $s . '&amp;page=extract&amp;archive=' . $toExtract;
'updates' => [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("misc/question_yesno", true) . "\";");
'title' => lng('update.update'),
'image' => 'fa-solid fa-download',
'sections' => [
'section_autoupd' => [
'fields' => [
'archive' => ['type' => 'hidden', 'value' => $toExtract]
]
]
],
'buttons' => [
[
'class' => 'btn-outline-secondary',
'label' => lng('panel.cancel'),
'type' => 'reset'
],
[
'label' => lng('update.proceed')
]
]
]
];
UI::view('user/form-note.html.twig', [
'formaction' => $linker->getLink(['section' => 'autoupdate', 'page' => 'extract']),
'formdata' => $upd_formfield['updates'],
// alert
'type' => 'warning',
'alert_msg' => $text
]);
} // display error } // display error
elseif ($page == 'error') { elseif ($page == 'error') {
// retrieve error-number via url-parameter // retrieve error-number via url-parameter
$errno = isset($_GET['errno']) ? (int)$_GET['errno'] : 0; $errno = isset($_GET['errno']) ? (int) $_GET['errno'] : 0;
// 2 = no Zlib // 2 = no Zlib
// 3 = custom version detected // 3 = custom version detected
@@ -202,11 +230,6 @@ elseif ($page == 'error') {
// 7 = local archive does not exist // 7 = local archive does not exist
// 8 = could not extract archive // 8 = could not extract archive
// 9 = checksum mismatch // 9 = checksum mismatch
// 10 = <php-7.4 // 10 = <php-7.0
// 11 = enable_webupdate = false \Froxlor\UI\Response::standard_error('autoupdate_' . $errno);
$errmsg = 'autoupdate_' . $errno;
if ($errno == 3) {
$errmsg = 'customized_version';
}
Response::standardError($errmsg);
} }

View File

@@ -4,177 +4,292 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Panel
* *
* You should have received a copy of the GNU General Public License * @since 0.9.34
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Config\ConfigParser;
use Froxlor\FileDir;
use Froxlor\Froxlor;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
if ($userinfo['change_serversettings'] == '1') { if ($userinfo['change_serversettings'] == '1') {
if ($action == 'setconfigured') { if ($action == 'setconfigured') {
Settings::Set('panel.is_configured', '1', true); Settings::Set('panel.is_configured', '1', true);
Response::redirectTo('admin_configfiles.php'); \Froxlor\UI\Response::redirectTo('admin_configfiles.php', array(
's' => $s
));
} }
$customer_tmpdir = '/tmp/';
if (Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_tmpdir') != '') {
$customer_tmpdir = Settings::Get('system.mod_fcgid_tmpdir');
} elseif (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.tmpdir') != '') {
$customer_tmpdir = Settings::Get('phpfpm.tmpdir');
}
// try to convert namserver hosts to ip's
$ns_ips = "";
$known_ns_ips = [];
if (Settings::Get('system.nameservers') != '') {
$nameservers = explode(',', Settings::Get('system.nameservers'));
foreach ($nameservers as $nameserver) {
$nameserver = trim($nameserver);
// DNS servers might be multi homed; allow transfer from all ip
// addresses of the DNS server
$nameserver_ips = \Froxlor\PhpHelper::gethostbynamel6($nameserver);
// append dot to hostname
if (substr($nameserver, - 1, 1) != '.') {
$nameserver .= '.';
}
// ignore invalid responses
if (! is_array($nameserver_ips)) {
// act like \Froxlor\PhpHelper::gethostbynamel6() and return unmodified hostname on error
$nameserver_ips = array(
$nameserver
);
} else {
$known_ns_ips = array_merge($known_ns_ips, $nameserver_ips);
}
if (!empty($ns_ips)) {
$ns_ips .= ',';
}
$ns_ips .= implode(",", $nameserver_ips);
}
}
// AXFR server
if (Settings::Get('system.axfrservers') != '') {
$axfrservers = explode(',', Settings::Get('system.axfrservers'));
foreach ($axfrservers as $axfrserver) {
if (!in_array(trim($axfrserver), $known_ns_ips)) {
if (!empty($ns_ips)) {
$ns_ips .= ',';
}
$ns_ips .= trim($axfrserver);
}
}
}
$replace_arr = Array(
'<SQL_UNPRIVILEGED_USER>' => $sql['user'],
'<SQL_UNPRIVILEGED_PASSWORD>' => 'FROXLOR_MYSQL_PASSWORD',
'<SQL_DB>' => $sql['db'],
'<SQL_HOST>' => $sql['host'],
'<SQL_SOCKET>' => isset($sql['socket']) ? $sql['socket'] : null,
'<SERVERNAME>' => Settings::Get('system.hostname'),
'<SERVERIP>' => Settings::Get('system.ipaddress'),
'<NAMESERVERS>' => Settings::Get('system.nameservers'),
'<NAMESERVERS_IP>' => $ns_ips,
'<VIRTUAL_MAILBOX_BASE>' => Settings::Get('system.vmail_homedir'),
'<VIRTUAL_UID_MAPS>' => Settings::Get('system.vmail_uid'),
'<VIRTUAL_GID_MAPS>' => Settings::Get('system.vmail_gid'),
'<SSLPROTOCOLS>' => (Settings::Get('system.use_ssl') == '1') ? 'imaps pop3s' : '',
'<CUSTOMER_TMP>' => \Froxlor\FileDir::makeCorrectDir($customer_tmpdir),
'<BASE_PATH>' => \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir()),
'<BIND_CONFIG_PATH>' => \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.bindconf_directory')),
'<WEBSERVER_RELOAD_CMD>' => Settings::Get('system.apachereload_command'),
'<CUSTOMER_LOGS>' => \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.logfiles_directory')),
'<FPM_IPCDIR>' => \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir')),
'<WEBSERVER_GROUP>' => Settings::Get('system.httpgroup')
);
// get distro from URL param // get distro from URL param
$distribution = Request::any('distribution'); $distribution = (isset($_GET['distribution']) && $_GET['distribution'] != 'choose') ? $_GET['distribution'] : "";
$reselect = Request::any('reselect', 0); $service = (isset($_GET['service']) && $_GET['service'] != 'choose') ? $_GET['service'] : "";
$daemon = (isset($_GET['daemon']) && $_GET['daemon'] != 'choose') ? $_GET['daemon'] : "";
$distributions_select = "";
$services_select = "";
$daemons_select = "";
// check for possible setting $configfiles = "";
if (empty($distribution)) { $services = "";
$distribution = Settings::Get('system.distribution') ?? ""; $daemons = "";
}
if ($reselect == 1) {
$distribution = '';
}
$distributions_select = []; $config_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/lib/configfiles/');
$services = []; if ($distribution != "") {
$config_dir = FileDir::makeCorrectDir(Froxlor::getInstallDir() . '/lib/configfiles/');
if (!empty($distribution)) { if (! file_exists($config_dir . '/' . $distribution . ".xml")) {
if (!file_exists($config_dir . '/' . $distribution . ".xml")) { trigger_error("Unknown distribution, are you playing around with the URL?");
Response::dynamicError("Unknown distribution"); exit();
}
// update setting if different
if ($distribution != Settings::Get('system.distribution')) {
Settings::Set('system.distribution', $distribution);
} }
// create configparser object // create configparser object
$configfiles = new ConfigParser($config_dir . '/' . $distribution . ".xml"); $configfiles = new \Froxlor\Config\ConfigParser($config_dir . '/' . $distribution . ".xml");
// get distro-info // get distro-info
$dist_display = $configfiles->getCompleteDistroName(); $dist_display = getCompleteDistroName($configfiles);
// get all the services from the distro // get all the services from the distro
$services = $configfiles->getServices(); $services = $configfiles->getServices();
if ($service != "") {
if (! isset($services[$service])) {
trigger_error("Unknown service, are you playing around with the URL?");
exit();
}
$daemons = $services[$service]->getDaemons();
if ($daemon == "") {
foreach ($daemons as $di => $dd) {
$title = $dd->title;
if ($dd->default) {
$title = $title . " (" . strtolower($lng['panel']['default']) . ")";
}
$daemons_select .= \Froxlor\UI\HTML::makeoption($title, $di);
}
}
} else {
foreach ($services as $si => $sd) {
$services_select .= \Froxlor\UI\HTML::makeoption($sd->title, $si);
}
}
} else { } else {
// show list of available distro's // show list of available distro's
$distros = glob($config_dir . '*.xml'); $distros = glob($config_dir . '*.xml');
// tmp array
$distributions_select_data = array();
// read in all the distros // read in all the distros
foreach ($distros as $_distribution) { foreach ($distros as $_distribution) {
// get configparser object // get configparser object
$dist = new ConfigParser($_distribution); $dist = new \Froxlor\Config\ConfigParser($_distribution);
// get distro-info
$dist_display = getCompleteDistroName($dist);
// store in tmp array // store in tmp array
$distributions_select[str_replace(".xml", "", strtolower(basename($_distribution)))] = $dist->getCompleteDistroName(); $distributions_select_data[$dist_display] = str_replace(".xml", "", strtolower(basename($_distribution)));
} }
// sort by distribution name // sort by distribution name
asort($distributions_select); ksort($distributions_select_data);
foreach ($distributions_select_data as $dist_display => $dist_index) {
// create select-box-option
$distributions_select .= \Froxlor\UI\HTML::makeoption($dist_display, $dist_index);
}
} }
if ($distribution != "" && isset($_POST['finish'])) { if ($distribution != "" && $service != "" && $daemon != "") {
unset($_POST['finish']);
unset($_POST['csrf_token']);
$params = $_POST;
$params['distro'] = $distribution;
$params['system'] = [];
foreach ($_POST['system'] as $sysdaemon) {
$params['system'][] = $sysdaemon;
}
$params_content = json_encode($params);
$params_filename = FileDir::makeCorrectFile(Froxlor::getInstallDir() . 'install/' . Froxlor::genSessionId() . '.json');
file_put_contents($params_filename, $params_content);
UI::twigBuffer('settings/configuration-final.html.twig', [ if (! isset($daemons[$daemon])) {
'distribution' => $distribution, trigger_error("Unknown daemon, are you playing around with the URL?");
// alert exit();
'type' => 'info', }
'alert_msg' => lng('admin.configfiles.finishnote'),
'basedir' => Froxlor::getInstallDir(), $confarr = $daemons[$daemon]->getConfig();
'params_filename' => $params_filename
]); $configpage = '';
$distro_editor = $configfiles->distributionEditor;
$commands_pre = "";
$commands_file = "";
$commands_post = "";
$lasttype = '';
$commands = '';
foreach ($confarr as $_action) {
if ($lasttype != '' && $lasttype != $_action['type']) {
$commands = trim($commands);
$numbrows = count(explode("\n", $commands));
eval("\$configpage.=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";");
$lasttype = '';
$commands = '';
}
switch ($_action['type']) {
case "install":
$commands .= strtr($_action['content'], $replace_arr) . "\n";
$lasttype = "install";
break;
case "command":
$commands .= strtr($_action['content'], $replace_arr) . "\n";
$lasttype = "command";
break;
case "file":
if (array_key_exists('content', $_action)) {
$commands_file = getFileContentContainer($_action['content'], $replace_arr, $_action['name'], $distro_editor);
} elseif (array_key_exists('subcommands', $_action)) {
foreach ($_action['subcommands'] as $fileaction) {
if (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "pre") {
$commands_pre .= $fileaction['content'] . "\n";
} elseif (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "post") {
$commands_post .= $fileaction['content'] . "\n";
} elseif ($fileaction['type'] == 'file') {
$commands_file = getFileContentContainer($fileaction['content'], $replace_arr, $_action['name'], $distro_editor);
}
}
}
$realname = $_action['name'];
$commands = trim($commands_pre);
if ($commands != "") {
$numbrows = count(explode("\n", $commands));
eval("\$commands_pre=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";");
}
$commands = trim($commands_post);
if ($commands != "") {
$numbrows = count(explode("\n", $commands));
eval("\$commands_post=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";");
}
eval("\$configpage.=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_subfileblock") . "\";");
$commands = '';
$commands_pre = '';
$commands_post = '';
break;
}
}
$commands = trim($commands);
if ($commands != '') {
$numbrows = count(explode("\n", $commands));
eval("\$configpage.=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";");
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles") . "\";");
} else { } else {
if (!empty($distribution)) { $basedir = \Froxlor\Froxlor::getInstallDir();
// show available services to configure eval("echo \"" . \Froxlor\UI\Template::getTemplate("configfiles/wizard") . "\";");
$fields = $services;
$link_params = ['section' => 'configfiles', 'distribution' => $distribution];
UI::twigBuffer('settings/configuration.html.twig', [
'action' => $linker->getLink($link_params),
'fields' => $fields,
'distribution' => $distribution
]);
} else {
$cfg_formfield = [
'config' => [
'title' => lng('admin.configfiles.serverconfiguration'),
'image' => 'fa-solid fa-wrench',
'description' => lng('admin.configfiles.description'),
'sections' => [
'section_config' => [
'fields' => [
'distribution' => [
'type' => 'select',
'select_var' => $distributions_select,
'label' => lng('admin.configfiles.distribution'),
'selected' => Settings::Get('system.distribution') ?? ''
]
]
]
],
'buttons' => [
[
'class' => 'btn-outline-secondary',
'label' => lng('panel.cancel'),
'type' => 'reset'
],
[
'label' => lng('update.proceed')
]
]
]
];
UI::twigBuffer('user/form-note.html.twig', [
'formaction' => $linker->getLink(['section' => 'configfiles']),
'formdata' => $cfg_formfield['config'],
'actions_links' => (int)Settings::Get('panel.is_configured') == 0 ? [
[
'href' => $linker->getLink([
'section' => 'configfiles',
'page' => 'overview',
'action' => 'setconfigured'
]),
'label' => lng('panel.ihave_configured'),
'class' => 'btn-outline-warning',
'icon' => 'fa-solid fa-circle-check'
]
] : [],
// alert
'type' => 'warning',
'alert_msg' => lng('panel.settings_before_configuration') . ((int)Settings::Get('panel.is_configured') == 1 ? '<br><br>' . lng('panel.system_is_configured') : '')
]);
}
} }
UI::twigOutputBuffer();
} else { } else {
Response::redirectTo('admin_index.php'); \Froxlor\UI\Response::redirectTo('admin_index.php', array(
's' => $s
));
}
// helper functions
function getFileContentContainer($file_content, &$replace_arr, $realname, $distro_editor)
{
$files = "";
$file_content = trim($file_content);
if ($file_content != '') {
$file_content = strtr($file_content, $replace_arr);
$file_content = htmlspecialchars($file_content);
$numbrows = count(explode("\n", $file_content));
eval("\$files=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_file") . "\";");
}
return $files;
}
function getCompleteDistroName($cparser)
{
// get distro-info
$dist_display = $cparser->distributionName;
if ($cparser->distributionCodename != '') {
$dist_display .= " " . $cparser->distributionCodename;
}
if ($cparser->distributionVersion != '') {
$dist_display .= " (" . $cparser->distributionVersion . ")";
}
if ($cparser->deprecated) {
$dist_display .= " [deprecated]";
}
return $dist_display;
} }

View File

@@ -4,67 +4,87 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
const AREA = 'admin'; require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Cronjobs; use Froxlor\Api\Commands\Cronjobs;
use Froxlor\FroxlorLogger;
use Froxlor\UI\Collection;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if (($page == 'cronjobs' || $page == 'overview') && $userinfo['change_serversettings'] == '1') { if ($page == 'cronjobs' || $page == 'overview') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs');
$fields = array(
'c.module' => 'Module',
'c.lastrun' => $lng['cron']['lastrun'],
'c.interval' => $lng['cron']['interval'],
'c.isactive' => $lng['cron']['isactive']
);
try { try {
$cron_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.cronjobs.php'; // get total count
$collection = (new Collection(Cronjobs::class, $userinfo)) $json_result = Cronjobs::getLocal($userinfo)->listingCount();
->withPagination($cron_list_data['cron_list']['columns'], $cron_list_data['cron_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Cronjobs::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$crons = '';
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
$cmod = '';
foreach ($result['list'] as $row) {
if ($cmod != $row['module']) {
$_mod = explode("/", $row['module']);
$module = ucfirst($_mod[1]);
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjobmodule') . "\";");
$cmod = $row['module'];
}
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
$row['isactive'] = ((int) $row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
$description = $lng['crondesc'][$row['desc_lng_key']];
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjob') . "\";");
$count ++;
} }
UI::view('user/table-note.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs') . "\";");
'listing' => Listing::format($collection, $cron_list_data, 'cron_list'),
// alert-box
'type' => 'warning',
'alert_msg' => lng('cron.changewarning')
]);
} elseif ($action == 'new') { } elseif ($action == 'new') {
/* /*
* @TODO later * @TODO later
*/ */
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = Cronjobs::getLocal($userinfo, [ $json_result = Cronjobs::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['cronfile'] != '') { if ($result['cronfile'] != '') {
@@ -72,19 +92,38 @@ if (($page == 'cronjobs' || $page == 'overview') && $userinfo['change_serversett
try { try {
Cronjobs::getLocal($userinfo, $_POST)->update(); Cronjobs::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$cronjobs_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
UI::view('user/form.html.twig', [ // interval
'formaction' => $linker->getLink(['section' => 'cronjobs', 'id' => $id]), $interval_nfo = explode(' ', $result['interval']);
'formdata' => $cronjobs_edit_data['cronjobs_edit'], $interval_value = $interval_nfo[0];
'editid' => $id
]); $interval_interval = '';
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['months'], 'MONTH', $interval_nfo[1]);
// end of interval
$change_cronfile = false;
if (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor') {
$change_cronfile = true;
}
$cronjobs_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
$cronjobs_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($cronjobs_edit_data);
$title = $cronjobs_edit_data['cronjobs_edit']['title'];
$image = $cronjobs_edit_data['cronjobs_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjob_edit') . "\";");
} }
} }
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {

View File

@@ -2,330 +2,493 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Admins;
use Froxlor\Api\Commands\Customers;
use Froxlor\Api\Commands\MysqlServer;
use Froxlor\CurrentUser;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Froxlor;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection; use Froxlor\Api\Commands\Customers as Customers;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if (($page == 'customers' || $page == 'overview') && $userinfo['customers'] != '0') { if ($page == 'customers' && $userinfo['customers'] != '0') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_customers"); // clear request data
unset($_SESSION['requestData']);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
$fields = array(
'c.loginname' => $lng['login']['username'],
'a.loginname' => $lng['admin']['admin'],
'c.name' => $lng['customer']['name'],
'c.email' => $lng['customer']['email'],
'c.firstname' => $lng['customer']['firstname'],
'c.company' => $lng['customer']['company'],
'c.diskspace' => $lng['customer']['diskspace'],
'c.diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
'c.traffic' => $lng['customer']['traffic'],
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
);
try { try {
$customer_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.customers.php'; // get total count
$collection = (new Collection(Customers::class, $userinfo, ['show_usages' => true])) $json_result = Customers::getLocal($userinfo)->listingCount();
->withPagination($customer_list_data['customer_list']['columns'], $customer_list_data['customer_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
if ($userinfo['change_serversettings']) { // initialize pagination and filtering
$collection->has('admin', Admins::class, 'adminid', 'adminid'); $paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
} // get list
$json_result = Customers::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$customers = '';
$sortcode = $paging->getHtmlSortCode($lng, true);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
foreach ($result['list'] as $row) {
$domains_stmt = Database::prepare("
SELECT COUNT(`id`) AS `domains`
FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :cid
AND `parentdomainid` = '0'
AND `id`<> :stdd
");
Database::pexecute($domains_stmt, array(
'cid' => $row['customerid'],
'stdd' => $row['standardsubdomain']
));
$domains = $domains_stmt->fetch(PDO::FETCH_ASSOC);
$row['domains'] = intval($domains['domains']);
$dec_places = Settings::Get('panel.decimal_places');
// get disk-space usages for web, mysql and mail
$usages_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "`
WHERE `customerid` = :cid
ORDER BY `stamp` DESC LIMIT 1
");
$usages = Database::pexecute_first($usages_stmt, array(
'cid' => $row['customerid']
));
if ($usages) {
$row['webspace_used'] = round($usages['webspace'] / 1024, $dec_places);
$row['mailspace_used'] = round($usages['mail'] / 1024, $dec_places);
$row['dbspace_used'] = round($usages['mysql'] / 1024, $dec_places);
} else {
$row['webspace_used'] = 0;
$row['mailspace_used'] = 0;
$row['dbspace_used'] = 0;
}
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
$last_login = ((int) $row['lastlogin_succ'] == 0) ? $lng['panel']['neverloggedin'] : date('d.m.Y', $row['lastlogin_succ']);
/**
* percent-values for progressbar
*/
if ($row['diskspace'] > 0) {
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
$disk_doublepercent = round($disk_percent * 2, 2);
} else {
$disk_percent = 0;
$disk_doublepercent = 0;
}
if ($row['traffic'] > 0) {
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
$traffic_doublepercent = round($traffic_percent * 2, 2);
} else {
$traffic_percent = 0;
$traffic_doublepercent = 0;
}
$islocked = 0;
if ($row['loginfail_count'] >= Settings::Get('login.maxloginattempts') && $row['lastlogin_fail'] > (time() - Settings::Get('login.deactivatetime'))) {
$islocked = 1;
}
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'diskspace traffic mysqls emails email_accounts email_forwarders ftps subdomains');
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
// fix progress-bars if value is >100%
if ($disk_percent > 100) {
$disk_percent = 100;
}
if ($traffic_percent > 100) {
$traffic_percent = 100;
}
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
eval("\$customers.=\"" . \Froxlor\UI\Template::getTemplate("customers/customers_customer") . "\";");
$count ++;
} }
$actions_links = false; $customercount = $result['count'] . " / " . $paging->getEntries();
if (CurrentUser::canAddResource('customers')) { eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers") . "\";");
$actions_links = [
[
'href' => $linker->getLink(['section' => 'customers', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.customer_add')
]
];
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $customer_list_data, 'customer_list'),
'actions_links' => $actions_links
]);
} elseif ($action == 'su' && $id != 0) { } elseif ($action == 'su' && $id != 0) {
try { try {
$json_result = Customers::getLocal($userinfo, [ $json_result = Customers::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
$destination_user = $result['loginname']; $destination_user = $result['loginname'];
if ($destination_user != '') { if ($destination_user != '') {
if ($result['deactivated'] == '1') { if ($result['deactivated'] == '1') {
Response::standardError("usercurrentlydeactivated", $destination_user); \Froxlor\UI\Response::standard_error("usercurrentlydeactivated", $destination_user);
} }
$result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :id
AND `hash` = :hash");
$result = Database::pexecute_first($result_stmt, array(
'id' => $userinfo['userid'],
'hash' => $s
));
$result['switched_user'] = CurrentUser::getData(); $s = \Froxlor\Froxlor::genSessionId();
$result['adminsession'] = 0; $insert = Database::prepare("
$result['userid'] = $result['customerid']; INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET
CurrentUser::setData($result); `hash` = :hash,
`userid` = :id,
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "switched user and is now '" . $destination_user . "'"); `ipaddress` = :ip,
`useragent` = :ua,
`lastactivity` = :lastact,
`language` = :lang,
`adminsession` = '0'");
Database::pexecute($insert, array(
'hash' => $s,
'id' => $id,
'ip' => $result['ipaddress'],
'ua' => $result['useragent'],
'lastact' => time(),
'lang' => $result['language']
));
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "switched user and is now '" . $destination_user . "'");
$target = (isset($_GET['target']) ? $_GET['target'] : 'index'); $target = (isset($_GET['target']) ? $_GET['target'] : 'index');
$redirect = "customer_" . $target . ".php"; $redirect = "customer_" . $target . ".php";
if (!file_exists(Froxlor::getInstallDir() . "/" . $redirect)) { if (! file_exists(\Froxlor\Froxlor::getInstallDir() . "/" . $redirect)) {
$redirect = "customer_index.php"; $redirect = "customer_index.php";
} }
Response::redirectTo($redirect, null, true); \Froxlor\UI\Response::redirectTo($redirect, array(
's' => $s
), true);
} else { } else {
Response::redirectTo('index.php', [ \Froxlor\UI\Response::redirectTo('index.php', array(
'action' => 'login' 'action' => 'login'
]); ));
} }
} elseif ($action == 'unlock' && $id != 0) { } elseif ($action == 'unlock' && $id != 0) {
try { try {
$json_result = Customers::getLocal($userinfo, [ $json_result = Customers::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
$json_result = Customers::getLocal($userinfo, [ $json_result = Customers::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->unlock(); ))->unlock();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('customer_reallyunlock', $filename, [ \Froxlor\UI\HTML::askYesNo('customer_reallyunlock', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['loginname']); ), $result['loginname']);
} }
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Customers::getLocal($userinfo, [ $json_result = Customers::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
$json_result = Customers::getLocal($userinfo, [ $json_result = Customers::getLocal($userinfo, array(
'id' => $id, 'id' => $id,
'delete_userfiles' => (isset($_POST['delete_userfiles']) ? (int)$_POST['delete_userfiles'] : 0) 'delete_userfiles' => (isset($_POST['delete_userfiles']) ? (int) $_POST['delete_userfiles'] : 0)
])->delete(); ))->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNoWithCheckbox('admin_customer_reallydelete', 'admin_customer_alsoremovefiles', $filename, [ \Froxlor\UI\HTML::askYesNoWithCheckbox('admin_customer_reallydelete', 'admin_customer_alsoremovefiles', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['loginname']); ), $result['loginname']);
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
Customers::getLocal($userinfo, $_POST)->add(); Customers::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$mysql_servers = []; $language_options = '';
try {
$result_json = MysqlServer::getLocal($userinfo)->listing(); foreach ($languages as $language_file => $language_name) {
$result_decoded = json_decode($result_json, true)['data']['list']; $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, Settings::Get('panel.standardlanguage'), true);
foreach ($result_decoded as $dbserver => $dbdata) {
$mysql_servers[] = [
'label' => $dbdata['caption'],
'value' => $dbserver
];
}
} catch (Exception $e) {
/* just none */
} }
$phpconfigs = []; $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$gender_options = \Froxlor\UI\HTML::makeoption($lng['gender']['undef'], 0, true, true, true);
$gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['male'], 1, null, true, true);
$gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['female'], 2, null, true, true);
$phpconfigs = array();
$configs = Database::query(" $configs = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
"); ");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'] . " [" . $row['interpreter'] . "]", 'label' => $row['description'] . " [" . $row['interpreter'] . "]<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} else { } else {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'], 'label' => $row['description'] . "<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} }
} }
// hosting plans // hosting plans
$hosting_plans = []; $hosting_plans = "";
$plans = Database::query(" $plans = Database::query("
SELECT * SELECT *
FROM `" . TABLE_PANEL_PLANS . "` FROM `" . TABLE_PANEL_PLANS . "`
ORDER BY name ASC ORDER BY name ASC
"); ");
$hosting_plans = [ if (Database::num_rows() > 0) {
0 => "---" $hosting_plans .= \Froxlor\UI\HTML::makeoption("---", 0, 0, true, true);
]; }
while ($row = $plans->fetch(PDO::FETCH_ASSOC)) { while ($row = $plans->fetch(PDO::FETCH_ASSOC)) {
$hosting_plans[$row['id']] = $row['name']; $hosting_plans .= \Froxlor\UI\HTML::makeoption($row['name'], $row['id'], 0, true, true);
} }
$customer_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_add.php'; $customer_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_add.php';
$customer_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($customer_add_data);
UI::view('user/form.html.twig', [ $title = $customer_add_data['customer_add']['title'];
'formaction' => $linker->getLink(['section' => 'customers']), $image = $customer_add_data['customer_add']['image'];
'formdata' => $customer_add_data['customer_add']
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = Customers::getLocal($userinfo, [ $json_result = Customers::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
/*
* information for moving customer
*/
$available_admins_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
WHERE (`customers` = '-1' OR `customers` > `customers_used`)");
Database::pexecute($available_admins_stmt);
$admin_select = \Froxlor\UI\HTML::makeoption("-----", 0, true, true, true);
$admin_select_cnt = 0;
while ($available_admin = $available_admins_stmt->fetch()) {
$admin_select .= \Froxlor\UI\HTML::makeoption($available_admin['name'] . " (" . $available_admin['loginname'] . ")", $available_admin['adminid'], null, true, true);
$admin_select_cnt ++;
}
/*
* end of moving customer stuff
*/
if ($result['loginname'] != '') { if ($result['loginname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
Customers::getLocal($userinfo, $_POST)->update(); Customers::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$language_options = '';
foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $result['def_language'], true);
}
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
$result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places); $result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places);
$result['diskspace'] = round($result['diskspace'] / 1024, $dec_places); $result['diskspace'] = round($result['diskspace'] / 1024, $dec_places);
$result['email'] = $idna_convert->decode($result['email']); $result['email'] = $idna_convert->decode($result['email'] ?? '');
$result = PhpHelper::htmlentitiesArray($result); $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
if ($result['diskspace'] == '-1') {
$mysql_servers = []; $result['diskspace'] = '';
try {
$result_json = MysqlServer::getLocal($userinfo)->listing();
$result_decoded = json_decode($result_json, true)['data']['list'];
foreach ($result_decoded as $dbserver => $dbdata) {
$mysql_servers[] = [
'label' => $dbdata['caption'],
'value' => $dbserver
];
}
} catch (Exception $e) {
/* just none */
} }
$phpconfigs = []; $traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
if ($result['traffic'] == '-1') {
$result['traffic'] = '';
}
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
if ($result['subdomains'] == '-1') {
$result['subdomains'] = '';
}
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
if ($result['emails'] == '-1') {
$result['emails'] = '';
}
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
if ($result['email_accounts'] == '-1') {
$result['email_accounts'] = '';
}
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
if ($result['email_forwarders'] == '-1') {
$result['email_forwarders'] = '';
}
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
if ($result['email_quota'] == '-1') {
$result['email_quota'] = '';
}
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
if ($result['ftps'] == '-1') {
$result['ftps'] = '';
}
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true);
if ($result['mysqls'] == '-1') {
$result['mysqls'] = '';
}
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$gender_options = \Froxlor\UI\HTML::makeoption($lng['gender']['undef'], 0, ($result['gender'] == '0' ? true : false), true, true);
$gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['male'], 1, ($result['gender'] == '1' ? true : false), true, true);
$gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['female'], 2, ($result['gender'] == '2' ? true : false), true, true);
$phpconfigs = array();
$configs = Database::query(" $configs = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
"); ");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'] . " [" . $row['interpreter'] . "]", 'label' => $row['description'] . " [" . $row['interpreter'] . "]<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} else { } else {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'], 'label' => $row['description'] . "<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} }
} }
// hosting plans // hosting plans
$hosting_plans = "";
$plans = Database::query(" $plans = Database::query("
SELECT * SELECT *
FROM `" . TABLE_PANEL_PLANS . "` FROM `" . TABLE_PANEL_PLANS . "`
ORDER BY name ASC ORDER BY name ASC
"); ");
$hosting_plans = [ if (Database::num_rows() > 0) {
0 => "---" $hosting_plans .= \Froxlor\UI\HTML::makeoption("---", 0, 0, true, true);
];
while ($row = $plans->fetch(PDO::FETCH_ASSOC)) {
$hosting_plans[$row['id']] = $row['name'];
} }
while ($row = $plans->fetch(PDO::FETCH_ASSOC)) {
$available_admins_stmt = Database::prepare(" $hosting_plans .= \Froxlor\UI\HTML::makeoption($row['name'], $row['id'], 0, true, true);
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
WHERE (`customers` = '-1' OR `customers` > `customers_used`)
AND adminid <> :currentadmin
");
Database::pexecute($available_admins_stmt, ['currentadmin' => $result['adminid']]);
$admin_select = [
0 => "---"
];
while ($available_admin = $available_admins_stmt->fetch()) {
$admin_select[$available_admin['adminid']] = $available_admin['name'] . " (" . $available_admin['loginname'] . ")";
} }
$customer_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_edit.php'; $customer_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_edit.php';
$customer_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($customer_edit_data);
UI::view('user/form.html.twig', [ $title = $customer_edit_data['customer_edit']['title'];
'formaction' => $linker->getLink(['section' => 'customers', 'id' => $id]), $image = $customer_edit_data['customer_edit']['image'];
'formdata' => $customer_edit_data['customer_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers_edit") . "\";");
]);
} }
} }
} }

View File

@@ -2,165 +2,173 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin'; use Froxlor\Database\Database;
require __DIR__ . '/lib/init.php'; use Froxlor\Settings;
use Froxlor\Api\Commands\Customers as Customers; use Froxlor\Api\Commands\Customers as Customers;
use Froxlor\Api\Commands\Domains as Domains; use Froxlor\Api\Commands\Domains as Domains;
use Froxlor\Bulk\DomainBulkAction;
use Froxlor\Cron\TaskId;
use Froxlor\Customer\Customer;
use Froxlor\Database\Database;
use Froxlor\Domain\Domain;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\Settings;
use Froxlor\System\Cronjob;
use Froxlor\UI\Collection;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\User;
use Froxlor\Validate\Validate;
use Froxlor\CurrentUser;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'domains' || $page == 'overview') { if ($page == 'domains' || $page == 'overview') {
// Let's see how many customers we have
$json_result = Customers::getLocal($userinfo)->listingCount();
$countcustomers = json_decode($json_result, true)['data'];
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_domains");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_domains");
$fields = array(
'd.domain_ace' => $lng['domains']['domainname'],
'c.name' => $lng['customer']['name'],
'c.firstname' => $lng['customer']['firstname'],
'c.company' => $lng['customer']['company'],
'c.loginname' => $lng['login']['username'],
'd.aliasdomain' => $lng['domains']['aliasdomain']
);
try { try {
$customerCollection = (new Collection(Customers::class, $userinfo)); // get total count
$domain_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.domains.php'; $json_result = Domains::getLocal($userinfo)->listingCount();
$collection = (new Collection(Domains::class, $userinfo)) $result = json_decode($json_result, true)['data'];
->has('customer', Customers::class, 'customerid', 'customerid') // initialize pagination and filtering
->withPagination($domain_list_data['domain_list']['columns'], $domain_list_data['domain_list']['default_sorting']); $paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Domains::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$domains = '';
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
foreach ($result['list'] as $row) {
formatDomainEntry($row, $idna_convert);
$row['customername'] = \Froxlor\User::getCorrectFullUserDetails($row);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
// display a nice list of IP's if it's not an alias for another domain
if (isset($row['aliasdomainid']) && $row['aliasdomainid'] != null && isset($row['aliasdomain']) && $row['aliasdomain'] != '') {
$row['ipandport'] = sprintf($lng['domains']['isaliasdomainof'], $row['aliasdomain']);
} else {
$row['ipandport'] = str_replace("\n", "<br />", $row['ipandport']);
}
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
$count++;
} }
$actions_links = false; $domainscount = $result['count'] . " / " . $paging->getEntries();
if (CurrentUser::canAddResource('domains')) {
$actions_links = [];
$actions_links[] = [
'href' => $linker->getLink(['section' => 'domains', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.domain_add')
];
$actions_links[] = [
'href' => $linker->getLink(['section' => 'domains', 'page' => $page, 'action' => 'import']),
'label' => lng('domains.domain_import'),
'icon' => 'fa-solid fa-file-import',
'class' => 'btn-outline-secondary'
];
}
UI::view('user/table.html.twig', [ // Display the list
'listing' => Listing::format($collection, $domain_list_data, 'domain_list'), eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";");
'actions_links' => $actions_links
]);
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Domains::getLocal($userinfo, [ $json_result = Domains::getLocal($userinfo, array(
'id' => $id, 'id' => $id,
'no_std_subdomain' => true 'no_std_subdomain' => true
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
$alias_check_stmt = Database::prepare(" $alias_check_stmt = Database::prepare("
SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "` SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `aliasdomain`= :id"); WHERE `aliasdomain`= :id");
$alias_check = Database::pexecute_first($alias_check_stmt, [ $alias_check = Database::pexecute_first($alias_check_stmt, array(
'id' => $id 'id' => $id
]); ));
if ($result['domain'] != '') { if ($result['domain'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send' && $alias_check['count'] == 0) { if (isset($_POST['send']) && $_POST['send'] == 'send' && $alias_check['count'] == 0) {
try { try {
Domains::getLocal($userinfo, $_POST)->delete(); Domains::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} elseif ($alias_check['count'] > 0) { } elseif ($alias_check['count'] > 0) {
Response::standardError('domains_cantdeletedomainwithaliases'); \Froxlor\UI\Response::standard_error('domains_cantdeletedomainwithaliases');
} else { } else {
$showcheck = false; $showcheck = false;
if (Domain::domainHasMainSubDomains($id)) { if (\Froxlor\Domain\Domain::domainHasMainSubDomains($id)) {
$showcheck = true; $showcheck = true;
} }
HTML::askYesNoWithCheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, [ \Froxlor\UI\HTML::askYesNoWithCheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $idna_convert->decode($result['domain']), $showcheck); ), $idna_convert->decode($result['domain']), $showcheck);
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
Domains::getLocal($userinfo, $_POST)->add(); Domains::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$customers = [
0 => lng('panel.please_choose') $customers = \Froxlor\UI\HTML::makeoption($lng['panel']['please_choose'], 0, 0, true);
];
$result_customers_stmt = Database::prepare(" $result_customers_stmt = Database::prepare("
SELECT `customerid`, `loginname`, `name`, `firstname`, `company` SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid ") . " ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC"); FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid ") . " ORDER BY COALESCE(NULLIF(`name`,''), `company`) ASC");
$params = []; $params = array();
if ($userinfo['customers_see_all'] == '0') { if ($userinfo['customers_see_all'] == '0') {
$params['adminid'] = $userinfo['adminid']; $params['adminid'] = $userinfo['adminid'];
} }
Database::pexecute($result_customers_stmt, $params); Database::pexecute($result_customers_stmt, $params);
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
$customers[$row_customer['customerid']] = User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')'; $customers .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
} }
$admins = []; $admins = '';
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
$result_admins_stmt = Database::query(" $result_admins_stmt = Database::query("
SELECT `adminid`, `loginname`, `name` SELECT `adminid`, `loginname`, `name`
FROM `" . TABLE_PANEL_ADMINS . "` FROM `" . TABLE_PANEL_ADMINS . "`
WHERE `domains_used` < `domains` OR `domains` = '-1' ORDER BY `name` ASC"); WHERE `domains_used` < `domains` OR `domains` = '-1' ORDER BY `name` ASC");
while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) {
$admins[$row_admin['adminid']] = User::getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')'; $admins .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $userinfo['adminid']);
} }
} }
@@ -175,57 +183,59 @@ if ($page == 'domains' || $page == 'overview') {
$admin_ip_stmt = Database::prepare(" $admin_ip_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC
"); ");
$admin_ip = Database::pexecute_first($admin_ip_stmt, [ $admin_ip = Database::pexecute_first($admin_ip_stmt, array(
'ipid' => $userinfo['ip'] 'ipid' => $userinfo['ip']
]); ));
$result_ipsandports_stmt = Database::prepare(" $result_ipsandports_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC
"); ");
Database::pexecute($result_ipsandports_stmt, [ Database::pexecute($result_ipsandports_stmt, array(
'ipid' => $admin_ip['ip'] 'ipid' => $admin_ip['ip']
]); ));
$result_ssl_ipsandports_stmt = Database::prepare(" $result_ssl_ipsandports_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' AND `ip` = :ipid ORDER BY `ip`, `port` ASC SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' AND `ip` = :ipid ORDER BY `ip`, `port` ASC
"); ");
Database::pexecute($result_ssl_ipsandports_stmt, [ Database::pexecute($result_ssl_ipsandports_stmt, array(
'ipid' => $admin_ip['ip'] 'ipid' => $admin_ip['ip']
]); ));
} }
// Build array holding all IPs and Ports available to this admin // Build array holding all IPs and Ports available to this admin
$ipsandports = []; $ipsandports = array();
while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']'; $row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']';
} }
$ipsandports[] = [ $ipsandports[] = array(
'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'], 'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '<br />',
'value' => $row_ipandport['id'] 'value' => $row_ipandport['id']
]; );
} }
$ssl_ipsandports = []; $ssl_ipsandports = array();
while ($row_ssl_ipandport = $result_ssl_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_ssl_ipandport = $result_ssl_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']'; $row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']';
} }
$ssl_ipsandports[] = [ $ssl_ipsandports[] = array(
'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'], 'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '<br />',
'value' => $row_ssl_ipandport['id'] 'value' => $row_ssl_ipandport['id']
]; );
} }
$standardsubdomains = []; $standardsubdomains = array();
$result_standardsubdomains_stmt = Database::query(" $result_standardsubdomains_stmt = Database::query("
SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`id` = `c`.`standardsubdomain` SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`id` = `c`.`standardsubdomain`
"); ");
while ($row_standardsubdomain = $result_standardsubdomains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_standardsubdomain = $result_standardsubdomains_stmt->fetch(PDO::FETCH_ASSOC)) {
$standardsubdomains[$row_standardsubdomain['id']] = $row_standardsubdomain['id']; $standardsubdomains[] = $row_standardsubdomain['id'];
} }
if (count($standardsubdomains) > 0) { if (count($standardsubdomains) > 0) {
@@ -234,27 +244,23 @@ if ($page == 'domains' || $page == 'overview') {
$standardsubdomains = ''; $standardsubdomains = '';
} }
$domains = [ $domains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, NULL, true);
0 => lng('domains.noaliasdomain')
];
$result_domains_stmt = Database::prepare(" $result_domains_stmt = Database::prepare("
SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0" . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0" . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC
"); ");
$params = []; $params = array();
if ($userinfo['customers_see_all'] == '0') { if ($userinfo['customers_see_all'] == '0') {
$params['adminid'] = $userinfo['adminid']; $params['adminid'] = $userinfo['adminid'];
} }
Database::pexecute($result_domains_stmt, $params); Database::pexecute($result_domains_stmt, $params);
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')'; $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']);
} }
$subtodomains = [ $subtodomains = \Froxlor\UI\HTML::makeoption($lng['domains']['nosubtomaindomain'], 0, NULL, true);
0 => lng('domains.nosubtomaindomain')
];
$result_domains_stmt = Database::prepare(" $result_domains_stmt = Database::prepare("
SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0 AND `d`.`ismainbutsubto` = 0 " . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0 AND `d`.`ismainbutsubto` = 0 " . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
@@ -264,10 +270,10 @@ if ($page == 'domains' || $page == 'overview') {
Database::pexecute($result_domains_stmt, $params); Database::pexecute($result_domains_stmt, $params);
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$subtodomains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')'; $subtodomains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')', $row_domain['id']);
} }
$phpconfigs = []; $phpconfigs = '';
$configs = Database::query(" $configs = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
@@ -275,84 +281,88 @@ if ($page == 'domains' || $page == 'overview') {
"); ");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[$row['id']] = $row['description'] . " [" . $row['interpreter'] . "]"; $phpconfigs .= \Froxlor\UI\HTML::makeoption($row['description'] . " [" . $row['interpreter'] . "]", $row['id'], Settings::Get('phpfpm.defaultini'), true, true);
} else { } else {
$phpconfigs[$row['id']] = $row['description']; $phpconfigs .= \Froxlor\UI\HTML::makeoption($row['description'], $row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true);
} }
} }
// create serveralias options // create serveralias options
$serveraliasoptions = [ $serveraliasoptions = "";
0 => lng('domains.serveraliasoption_wildcard'), $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', Settings::Get('system.domaindefaultalias'), true, true);
1 => lng('domains.serveraliasoption_www'), $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', Settings::Get('system.domaindefaultalias'), true, true);
2 => lng('domains.serveraliasoption_none') $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', Settings::Get('system.domaindefaultalias'), true, true);
];
$subcanemaildomain = [ $subcanemaildomain = \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['never'], '0', '0', true, true);
0 => lng('admin.subcanemaildomain.never'), $subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', '0', true, true);
1 => lng('admin.subcanemaildomain.choosableno'), $subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', '0', true, true);
2 => lng('admin.subcanemaildomain.choosableyes'), $subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['always'], '3', '0', true, true);
3 => lng('admin.subcanemaildomain.always')
]; $add_date = date('Y-m-d');
$domain_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_add.php'; $domain_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_add.php';
$domain_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_add_data);
UI::view('user/form.html.twig', [ $title = $domain_add_data['domain_add']['title'];
'formaction' => $linker->getLink(['section' => 'domains']), $image = $domain_add_data['domain_add']['image'];
'formdata' => $domain_add_data['domain_add']
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = Domains::getLocal($userinfo, [ $json_result = Domains::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['domain'] != '') { if ($result['domain'] != '') {
$subdomains_stmt = Database::prepare(" $subdomains_stmt = Database::prepare("
SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE
`parentdomainid` = :resultid `parentdomainid` = :resultid
"); ");
$subdomains = Database::pexecute_first($subdomains_stmt, [ $subdomains = Database::pexecute_first($subdomains_stmt, array(
'resultid' => $result['id'] 'resultid' => $result['id']
]); ));
$subdomains = $subdomains['count']; $subdomains = $subdomains['count'];
$alias_check_stmt = Database::prepare(" $alias_check_stmt = Database::prepare("
SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE
`aliasdomain` = :resultid `aliasdomain` = :resultid
"); ");
$alias_check = Database::pexecute_first($alias_check_stmt, [ $alias_check = Database::pexecute_first($alias_check_stmt, array(
'resultid' => $result['id'] 'resultid' => $result['id']
]); ));
$alias_check = $alias_check['count']; $alias_check = $alias_check['count'];
$domain_emails_result_stmt = Database::prepare(" $domain_emails_result_stmt = Database::prepare("
SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders`
FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id
"); ");
Database::pexecute($domain_emails_result_stmt, [ Database::pexecute($domain_emails_result_stmt, array(
'customerid' => $result['customerid'], 'customerid' => $result['customerid'],
'id' => $result['id'] 'id' => $result['id']
]); ));
$emails = Database::num_rows(); $emails = Database::num_rows();
$email_forwarders = 0; $email_forwarders = 0;
$email_accounts = 0; $email_accounts = 0;
while ($domain_emails_row = $domain_emails_result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($domain_emails_row = $domain_emails_result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($domain_emails_row['destination'] != '') { if ($domain_emails_row['destination'] != '') {
$domain_emails_row['destination'] = explode(' ', FileDir::makeCorrectDestination($domain_emails_row['destination']));
$domain_emails_row['destination'] = explode(' ', \Froxlor\FileDir::makeCorrectDestination($domain_emails_row['destination']));
$email_forwarders += count($domain_emails_row['destination']); $email_forwarders += count($domain_emails_row['destination']);
if (in_array($domain_emails_row['email_full'], $domain_emails_row['destination'])) { if (in_array($domain_emails_row['email_full'], $domain_emails_row['destination'])) {
$email_forwarders -= 1; $email_forwarders -= 1;
$email_accounts++; $email_accounts ++;
} }
} }
} }
@@ -360,11 +370,11 @@ if ($page == 'domains' || $page == 'overview') {
$ipsresult_stmt = Database::prepare(" $ipsresult_stmt = Database::prepare("
SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id
"); ");
Database::pexecute($ipsresult_stmt, [ Database::pexecute($ipsresult_stmt, array(
'id' => $result['id'] 'id' => $result['id']
]); ));
$usedips = []; $usedips = array();
while ($ipsresultrow = $ipsresult_stmt->fetch(PDO::FETCH_ASSOC)) { while ($ipsresultrow = $ipsresult_stmt->fetch(PDO::FETCH_ASSOC)) {
$usedips[] = $ipsresultrow['id_ipandports']; $usedips[] = $ipsresultrow['id_ipandports'];
} }
@@ -377,14 +387,16 @@ if ($page == 'domains' || $page == 'overview') {
} }
Domains::getLocal($userinfo, $_POST)->update(); Domains::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
if (Settings::Get('panel.allow_domain_change_customer') == '1') { if (Settings::Get('panel.allow_domain_change_customer') == '1') {
$customers = []; $customers = '';
$result_customers_stmt = Database::prepare(" $result_customers_stmt = Database::prepare("
SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "` SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE ( (`subdomains_used` + :subdomains <= `subdomains` OR `subdomains` = '-1' ) WHERE ( (`subdomains_used` + :subdomains <= `subdomains` OR `subdomains` = '-1' )
@@ -393,60 +405,60 @@ if ($page == 'domains' || $page == 'overview') {
AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid ") . ") AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid ") . ")
OR `customerid` = :customerid ORDER BY `name` ASC OR `customerid` = :customerid ORDER BY `name` ASC
"); ");
$params = [ $params = array(
'subdomains' => $subdomains, 'subdomains' => $subdomains,
'emails' => $emails, 'emails' => $emails,
'forwarders' => $email_forwarders, 'forwarders' => $email_forwarders,
'accounts' => $email_accounts, 'accounts' => $email_accounts,
'customerid' => $result['customerid'] 'customerid' => $result['customerid']
]; );
if ($userinfo['customers_see_all'] == '0') { if ($userinfo['customers_see_all'] == '0') {
$params['adminid'] = $userinfo['adminid']; $params['adminid'] = $userinfo['adminid'];
} }
Database::pexecute($result_customers_stmt, $params); Database::pexecute($result_customers_stmt, $params);
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
$customers[$row_customer['customerid']] = User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')'; $customers .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid'], $result['customerid']);
} }
} else { } else {
$customer_stmt = Database::prepare(" $customer_stmt = Database::prepare("
SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "` SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
"); ");
$customer = Database::pexecute_first($customer_stmt, [ $customer = Database::pexecute_first($customer_stmt, array(
'customerid' => $result['customerid'] 'customerid' => $result['customerid']
]); ));
$result['customername'] = User::getCorrectFullUserDetails($customer); $result['customername'] = \Froxlor\User::getCorrectFullUserDetails($customer);
} }
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
if (Settings::Get('panel.allow_domain_change_admin') == '1') { if (Settings::Get('panel.allow_domain_change_admin') == '1') {
$admins = [];
$admins = '';
$result_admins_stmt = Database::prepare(" $result_admins_stmt = Database::prepare("
SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "` SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "`
WHERE (`domains_used` < `domains` OR `domains` = '-1') OR `adminid` = :adminid ORDER BY `name` ASC WHERE (`domains_used` < `domains` OR `domains` = '-1') OR `adminid` = :adminid ORDER BY `name` ASC
"); ");
Database::pexecute($result_admins_stmt, [ Database::pexecute($result_admins_stmt, array(
'adminid' => $result['adminid'] 'adminid' => $result['adminid']
]); ));
while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_admin = $result_admins_stmt->fetch(PDO::FETCH_ASSOC)) {
$admins[$row_admin['adminid']] = User::getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')'; $admins .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_admin) . ' (' . $row_admin['loginname'] . ')', $row_admin['adminid'], $result['adminid']);
} }
} else { } else {
$admin_stmt = Database::prepare(" $admin_stmt = Database::prepare("
SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid SELECT `adminid`, `loginname`, `name` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid
"); ");
$admin = Database::pexecute_first($admin_stmt, [ $admin = Database::pexecute_first($admin_stmt, array(
'adminid' => $result['adminid'] 'adminid' => $result['adminid']
]); ));
$result['adminname'] = User::getCorrectFullUserDetails($admin) . ' (' . $admin['loginname'] . ')'; $result['adminname'] = \Froxlor\User::getCorrectFullUserDetails($admin) . ' (' . $admin['loginname'] . ')';
} }
} }
$domains = [ $result['domain'] = $idna_convert->decode($result['domain']);
0 => lng('domains.noaliasdomain') $domains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, null, true);
];
$result_domains_stmt = Database::prepare(" $result_domains_stmt = Database::prepare("
SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
@@ -454,34 +466,32 @@ if ($page == 'domains' || $page == 'overview') {
AND `c`.`standardsubdomain`<>`d`.`id` AND `d`.`customerid` = :customerid AND `c`.`customerid`=`d`.`customerid` AND `c`.`standardsubdomain`<>`d`.`id` AND `d`.`customerid` = :customerid AND `c`.`customerid`=`d`.`customerid`
ORDER BY `d`.`domain` ASC ORDER BY `d`.`domain` ASC
"); ");
Database::pexecute($result_domains_stmt, [ Database::pexecute($result_domains_stmt, array(
'id' => $result['id'], 'id' => $result['id'],
'customerid' => $result['customerid'] 'customerid' => $result['customerid']
]); ));
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']); $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']);
} }
$subtodomains = [ $subtodomains = \Froxlor\UI\HTML::makeoption($lng['domains']['nosubtomaindomain'], 0, null, true);
0 => lng('domains.nosubtomaindomain')
];
$result_domains_stmt = Database::prepare(" $result_domains_stmt = Database::prepare("
SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = '0' AND `d`.`id` <> :id WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = '0' AND `d`.`id` <> :id
AND `c`.`standardsubdomain`<>`d`.`id` AND `c`.`customerid`=`d`.`customerid`" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . " AND `c`.`standardsubdomain`<>`d`.`id` AND `c`.`customerid`=`d`.`customerid`" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
ORDER BY `d`.`domain` ASC ORDER BY `d`.`domain` ASC
"); ");
$params = [ $params = array(
'id' => $result['id'] 'id' => $result['id']
]; );
if ($userinfo['customers_see_all'] == '0') { if ($userinfo['customers_see_all'] == '0') {
$params['adminid'] = $userinfo['adminid']; $params['adminid'] = $userinfo['adminid'];
} }
Database::pexecute($result_domains_stmt, $params); Database::pexecute($result_domains_stmt, $params);
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$subtodomains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']); $subtodomains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['ismainbutsubto']);
} }
if ($userinfo['ip'] == "-1") { if ($userinfo['ip'] == "-1") {
@@ -495,182 +505,197 @@ if ($page == 'domains' || $page == 'overview') {
$admin_ip_stmt = Database::prepare(" $admin_ip_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid ORDER BY `ip`, `port` ASC
"); ");
$admin_ip = Database::pexecute_first($admin_ip_stmt, [ $admin_ip = Database::pexecute_first($admin_ip_stmt, array(
'ipid' => $userinfo['ip'] 'ipid' => $userinfo['ip']
]); ));
$result_ipsandports_stmt = Database::prepare(" $result_ipsandports_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' AND `ip` = :ipid ORDER BY `ip`, `port` ASC
"); ");
Database::pexecute($result_ipsandports_stmt, [ Database::pexecute($result_ipsandports_stmt, array(
'ipid' => $admin_ip['ip'] 'ipid' => $admin_ip['ip']
]); ));
$result_ssl_ipsandports_stmt = Database::prepare(" $result_ssl_ipsandports_stmt = Database::prepare("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' AND `ip` = :ipid ORDER BY `ip`, `port` ASC SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='1' AND `ip` = :ipid ORDER BY `ip`, `port` ASC
"); ");
Database::pexecute($result_ssl_ipsandports_stmt, [ Database::pexecute($result_ssl_ipsandports_stmt, array(
'ipid' => $admin_ip['ip'] 'ipid' => $admin_ip['ip']
]); ));
} }
$ipsandports = []; $ipsandports = array();
while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_ipandport = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { if (filter_var($row_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']'; $row_ipandport['ip'] = '[' . $row_ipandport['ip'] . ']';
} }
$ipsandports[] = [ $ipsandports[] = array(
'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'], 'label' => $row_ipandport['ip'] . ':' . $row_ipandport['port'] . '<br />',
'value' => $row_ipandport['id'] 'value' => $row_ipandport['id']
]; );
} }
$ssl_ipsandports = []; $ssl_ipsandports = array();
while ($row_ssl_ipandport = $result_ssl_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_ssl_ipandport = $result_ssl_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { if (filter_var($row_ssl_ipandport['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']'; $row_ssl_ipandport['ip'] = '[' . $row_ssl_ipandport['ip'] . ']';
} }
$ssl_ipsandports[] = [ $ssl_ipsandports[] = array(
'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'], 'label' => $row_ssl_ipandport['ip'] . ':' . $row_ssl_ipandport['port'] . '<br />',
'value' => $row_ssl_ipandport['id'] 'value' => $row_ssl_ipandport['id']
]; );
} }
// check that letsencrypt is not activated for wildcard domain // create serveralias options
$serveraliasoptions = "";
$_value = '2';
if ($result['iswildcarddomain'] == '1') { if ($result['iswildcarddomain'] == '1') {
$_value = '0';
$letsencrypt = 0; $letsencrypt = 0;
} elseif ($result['wwwserveralias'] == '1') {
$_value = '1';
} }
// Fudge the result for ssl_redirect to hide the Let's Encrypt steps // Fudge the result for ssl_redirect to hide the Let's Encrypt steps
$result['temporary_ssl_redirect'] = $result['ssl_redirect']; $result['temporary_ssl_redirect'] = $result['ssl_redirect'];
$result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1); $result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1);
$serveraliasoptions = [ $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', $_value, true, true);
0 => lng('domains.serveraliasoption_wildcard'), $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', $_value, true, true);
1 => lng('domains.serveraliasoption_www'), $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', $_value, true, true);
2 => lng('domains.serveraliasoption_none')
];
$subcanemaildomain = [ $subcanemaildomain = \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['never'], '0', $result['subcanemaildomain'], true, true);
0 => lng('admin.subcanemaildomain.never'), $subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', $result['subcanemaildomain'], true, true);
1 => lng('admin.subcanemaildomain.choosableno'), $subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableyes'], '2', $result['subcanemaildomain'], true, true);
2 => lng('admin.subcanemaildomain.choosableyes'), $subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['always'], '3', $result['subcanemaildomain'], true, true);
3 => lng('admin.subcanemaildomain.always') $speciallogfile = ($result['speciallogfile'] == 1 ? $lng['panel']['yes'] : $lng['panel']['no']);
]; $result['add_date'] = date('Y-m-d', $result['add_date']);
$phpconfigs = []; $phpconfigs = '';
$phpconfigs_result_stmt = Database::query(" $phpconfigs_result_stmt = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
"); ");
$c_allowed_configs = Customer::getCustomerDetail($result['customerid'], 'allowed_phpconfigs'); $c_allowed_configs = \Froxlor\Customer\Customer::getCustomerDetail($result['customerid'], 'allowed_phpconfigs');
if (!empty($c_allowed_configs)) { if (! empty($c_allowed_configs)) {
$c_allowed_configs = json_decode($c_allowed_configs, true); $c_allowed_configs = json_decode($c_allowed_configs, true);
} else { } else {
$c_allowed_configs = []; $c_allowed_configs = array();
} }
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
$disabled = !empty($c_allowed_configs) && !in_array($phpconfigs_row['id'], $c_allowed_configs); $disabled = ! empty($c_allowed_configs) && ! in_array($phpconfigs_row['id'], $c_allowed_configs);
if (!$disabled) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]", $phpconfigs_row['id'], $result['phpsettingid'], true, true, null, $disabled);
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]"; } else {
} else { $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true, null, $disabled);
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'];
}
} }
} }
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
if (Settings::Get('panel.allow_domain_change_customer') != '1') { if (Settings::Get('panel.allow_domain_change_customer') != '1') {
$result['customername'] .= ' (<a href="' . $linker->getLink([ $result['customername'] .= ' (<a href="' . $linker->getLink(array('section' => 'customers', 'page' => 'customers',
'section' => 'customers', 'action' => 'su', 'id' => $customer['customerid'])) . '" rel="external">' . $customer['loginname'] . '</a>)';
'page' => 'customers',
'action' => 'su',
'id' => $customer['customerid']
]) . '" rel="external">' . $customer['loginname'] . '</a>)';
} }
$domain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_edit.php'; $domain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_edit.php';
$domain_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_edit_data);
UI::view('user/form.html.twig', [ $title = $domain_edit_data['domain_edit']['title'];
'formaction' => $linker->getLink(['section' => 'domains', 'id' => $id]), $image = $domain_edit_data['domain_edit']['image'];
'formdata' => $domain_edit_data['domain_edit'],
'editid' => $id $speciallogwarning = sprintf($lng['admin']['speciallogwarning'], $lng['admin']['delete_statistics']);
]);
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_edit") . "\";");
} }
} }
} elseif ($action == 'jqGetCustomerPHPConfigs') { } elseif ($action == 'jqGetCustomerPHPConfigs') {
$customerid = intval($_POST['customerid']); $customerid = intval($_POST['customerid']);
$allowed_phpconfigs = Customer::getCustomerDetail($customerid, 'allowed_phpconfigs'); $allowed_phpconfigs = \Froxlor\Customer\Customer::getCustomerDetail($customerid, 'allowed_phpconfigs');
echo !empty($allowed_phpconfigs) ? $allowed_phpconfigs : json_encode([]); echo ! empty($allowed_phpconfigs) ? $allowed_phpconfigs : json_encode(array());
exit();
} elseif ($action == 'jqSpeciallogfileNote') {
$domainid = intval($_POST['id']);
$newval = intval($_POST['newval']);
try {
$json_result = Domains::getLocal($userinfo, [
'id' => $domainid
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($newval != $result['speciallogfile']) {
echo json_encode(['changed' => true, 'info' => lng('admin.speciallogwarning')]);
exit();
}
echo 0;
exit(); exit();
} elseif ($action == 'import') { } elseif ($action == 'import') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$separator = Validate::validate($_POST['separator'], 'separator');
$offset = (int)Validate::validate($_POST['offset'], 'offset', "/[0-9]/i"); $separator = \Froxlor\Validate\Validate::validate($_POST['separator'], 'separator');
$offset = (int) \Froxlor\Validate\Validate::validate($_POST['offset'], 'offset', "/[0-9]/i");
$file_name = $_FILES['file']['tmp_name']; $file_name = $_FILES['file']['tmp_name'];
$result = []; $result = array();
try { try {
$bulk = new DomainBulkAction($file_name, $userinfo); $bulk = new \Froxlor\Bulk\DomainBulkAction($file_name, $userinfo);
$result = $bulk->doImport($separator, $offset); $result = $bulk->doImport($separator, $offset);
} catch (Exception $e) { } catch (Exception $e) {
Response::standardError('domain_import_error', $e->getMessage()); \Froxlor\UI\Response::standard_error('domain_import_error', $e->getMessage());
} }
if (!empty($bulk->getErrors())) { if (! empty($bulk->getErrors())) {
Response::dynamicError(implode("<br>", $bulk->getErrors())); \Froxlor\UI\Response::dynamic_error(implode("<br>", $bulk->getErrors()));
} }
// update customer/admin counters // update customer/admin counters
User::updateCounters(false); \Froxlor\User::updateCounters(false);
Cronjob::inserttask(TaskId::REBUILD_VHOST); \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST);
Cronjob::inserttask(TaskId::REBUILD_DNS); \Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS);
$result_str = $result['imported'] . ' / ' . $result['all'] . (!empty($result['note']) ? ' (' . $result['note'] . ')' : ''); $result_str = $result['imported'] . ' / ' . $result['all'] . (! empty($result['note']) ? ' (' . $result['note'] . ')' : '');
Response::standardSuccess('domain_import_successfully', $result_str, [ \Froxlor\UI\Response::standard_success('domain_import_successfully', $result_str, array(
'filename' => $filename, 'filename' => $filename,
'action' => '', 'action' => '',
'page' => 'domains' 'page' => 'domains'
]); ));
} else { } else {
$domain_import_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php';
UI::view('user/form-note.html.twig', [ $domain_import_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php';
'formaction' => $linker->getLink(['section' => 'domains', 'page' => $page]), $domain_import_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_import_data);
'formdata' => $domain_import_data['domain_import'],
// alert-box $title = $domain_import_data['domain_import']['title'];
'type' => 'info', $image = $domain_import_data['domain_import']['image'];
'alert_msg' => lng('domains.import_description')
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_import") . "\";");
} }
} }
} elseif ($page == 'domainssleditor') {
require_once __DIR__ . '/ssl_editor.php';
} elseif ($page == 'domaindnseditor' && Settings::Get('system.dnsenabled') == '1') { } elseif ($page == 'domaindnseditor' && Settings::Get('system.dnsenabled') == '1') {
require_once __DIR__ . '/dns_editor.php'; require_once __DIR__ . '/dns_editor.php';
} elseif ($page == 'sslcertificates') { } elseif ($page == 'sslcertificates') {
require_once __DIR__ . '/ssl_certificates.php'; require_once __DIR__ . '/ssl_certificates.php';
} elseif ($page == 'logfiles') { } elseif ($page == 'logfiles') {
require_once __DIR__ . '/logfiles_viewer.php'; require_once __DIR__ . '/logfiles_viewer.php';
} }
function formatDomainEntry(&$row, &$idna_convert)
{
$row['domain'] = $idna_convert->decode($row['domain']);
$row['aliasdomain'] = $idna_convert->decode($row['aliasdomain'] ?? '');
$row['ipandport'] = '';
foreach ($row['ipsandports'] as $rowip) {
if (filter_var($rowip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row['ipandport'] .= '[' . $rowip['ip'] . ']:' . $rowip['port'] . "\n";
} else {
$row['ipandport'] .= $rowip['ip'] . ':' . $rowip['port'] . "\n";
}
}
$row['ipandport'] = substr($row['ipandport'], 0, - 1);
$row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date'] ?? '');
$row['termination_css'] = "";
if ($row['termination_date'] != "") {
$cdate = strtotime($row['termination_date'] . " 23:59:59");
$today = time();
if ($cdate < $today) {
$row['termination_css'] = 'domain-expired';
} else {
$row['termination_css'] = 'domain-canceled';
}
}
}

View File

@@ -2,71 +2,61 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Admins as Admins;
use Froxlor\Api\Commands\Froxlor as Froxlor;
use Froxlor\CurrentUser;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\System\Cronjob; use Froxlor\Api\Commands\Froxlor as Froxlor;
use Froxlor\System\Crypt; use Froxlor\Api\Commands\Admins as Admins;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\Validate\Validate;
use Froxlor\Language;
$id = (int)Request::any('id');
if ($action == 'logout') { if ($action == 'logout') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "logged out");
unset($_SESSION['userinfo']);
CurrentUser::setData();
session_destroy();
Response::redirectTo('index.php'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "logged out");
} elseif ($action == 'suback') {
if (is_array(CurrentUser::getField('switched_user'))) { $params = array(
$result = CurrentUser::getData(); 'adminid' => (int) $userinfo['adminid']
$result = $result['switched_user']; );
CurrentUser::setData($result);
$target = (isset($_GET['target']) ? $_GET['target'] : 'index'); if (Settings::Get('session.allow_multiple_login') == '1') {
$redirect = "admin_" . $target . ".php"; $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
if (!file_exists(\Froxlor\Froxlor::getInstallDir() . "/" . $redirect)) { WHERE `userid` = :adminid
$redirect = "admin_index.php"; AND `adminsession` = '1'
} AND `hash` = :hash");
Response::redirectTo($redirect, null, true); $params['hash'] = $s;
} else { } else {
Response::dynamicError("Cannot change back - You've never switched to another user :-)"); $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :adminid
AND `adminsession` = '1'");
} }
Database::pexecute($stmt, $params);
\Froxlor\UI\Response::redirectTo('index.php');
}
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
} }
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_index");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_index");
$params = []; $params = [];
if ($userinfo['customers_see_all'] == '0') { if ($userinfo['customers_see_all'] == '0') {
$params = [ $params = [
@@ -74,34 +64,23 @@ if ($page == 'overview') {
]; ];
} }
$overview_stmt = Database::prepare("SELECT COUNT(*) AS `number_customers`, $overview_stmt = Database::prepare("SELECT COUNT(*) AS `number_customers`,
SUM(case when `diskspace` > 0 then `diskspace` else 0 end) AS `diskspace_assigned`,
SUM(`diskspace_used`) AS `diskspace_used`, SUM(`diskspace_used`) AS `diskspace_used`,
SUM(case when `mysqls` > 0 then `mysqls` else 0 end) AS `mysqls_assigned`,
SUM(`mysqls_used`) AS `mysqls_used`, SUM(`mysqls_used`) AS `mysqls_used`,
SUM(case when `emails` > 0 then `emails` else 0 end) AS `emails_assigned`,
SUM(`emails_used`) AS `emails_used`, SUM(`emails_used`) AS `emails_used`,
SUM(case when `email_accounts` > 0 then `email_accounts` else 0 end) AS `email_accounts_assigned`,
SUM(`email_accounts_used`) AS `email_accounts_used`, SUM(`email_accounts_used`) AS `email_accounts_used`,
SUM(case when `email_forwarders` > 0 then `email_forwarders` else 0 end) AS `email_forwarders_assigned`,
SUM(`email_forwarders_used`) AS `email_forwarders_used`, SUM(`email_forwarders_used`) AS `email_forwarders_used`,
SUM(case when `email_quota` > 0 then `email_quota` else 0 end) AS `email_quota_assigned`,
SUM(`email_quota_used`) AS `email_quota_used`, SUM(`email_quota_used`) AS `email_quota_used`,
SUM(case when `ftps` > 0 then `ftps` else 0 end) AS `ftps_assigned`,
SUM(`ftps_used`) AS `ftps_used`, SUM(`ftps_used`) AS `ftps_used`,
SUM(case when `subdomains` > 0 then `subdomains` else 0 end) AS `subdomains_assigned`,
SUM(`subdomains_used`) AS `subdomains_used`, SUM(`subdomains_used`) AS `subdomains_used`,
SUM(case when `traffic` > 0 then `traffic` else 0 end) AS `traffic_assigned`,
SUM(`traffic_used`) AS `traffic_used` SUM(`traffic_used`) AS `traffic_used`
FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid ")); FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid "));
$overview = Database::pexecute_first($overview_stmt, $params); $overview = Database::pexecute_first($overview_stmt, $params);
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1; $dec_places = Settings::Get('panel.decimal_places');
$overview['diskspace_bytes'] = $overview['diskspace_assigned'] * 1024;
$overview['diskspace_bytes_used'] = $overview['diskspace_used'] * 1024;
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : -1;
$overview['traffic_bytes'] = $overview['traffic_assigned'] * 1024;
$overview['traffic_bytes_used'] = $overview['traffic_used'] * 1024; $overview['traffic_bytes_used'] = $overview['traffic_used'] * 1024;
$overview['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($overview['traffic_used'] * 1024, null, 'bi');
$overview['diskspace_bytes_used'] = $overview['diskspace_used'] * 1024;
$overview['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($overview['diskspace_used'] * 1024, null, 'bi');
$number_domains_stmt = Database::prepare(" $number_domains_stmt = Database::prepare("
SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "` SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "`
@@ -110,11 +89,15 @@ if ($page == 'overview') {
$overview['number_domains'] = $number_domains['number_domains']; $overview['number_domains'] = $number_domains['number_domains'];
$phpversion = phpversion();
$mysqlserverversion = Database::getAttribute(PDO::ATTR_SERVER_VERSION);
$webserverinterface = strtoupper(@php_sapi_name());
if ((isset($_GET['lookfornewversion']) && $_GET['lookfornewversion'] == 'yes') || (isset($lookfornewversion) && $lookfornewversion == 'yes')) { if ((isset($_GET['lookfornewversion']) && $_GET['lookfornewversion'] == 'yes') || (isset($lookfornewversion) && $lookfornewversion == 'yes')) {
try { try {
$json_result = Froxlor::getLocal($userinfo)->checkUpdate(); $json_result = Froxlor::getLocal($userinfo)->checkUpdate();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -124,20 +107,35 @@ if ($page == 'overview') {
$lookfornewversion_addinfo = $result['additional_info']; $lookfornewversion_addinfo = $result['additional_info'];
$isnewerversion = $result['isnewerversion']; $isnewerversion = $result['isnewerversion'];
} else { } else {
$lookfornewversion_lable = lng('admin.lookfornewversion.clickhere'); $lookfornewversion_lable = $lng['admin']['lookfornewversion']['clickhere'];
$lookfornewversion_link = htmlspecialchars($filename . '?page=' . urlencode($page) . '&lookfornewversion=yes'); $lookfornewversion_link = htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
$lookfornewversion_message = ''; $lookfornewversion_message = '';
$lookfornewversion_addinfo = ''; $lookfornewversion_addinfo = '';
$isnewerversion = 0; $isnewerversion = 0;
} }
$cron_last_runs = Cronjob::getCronjobsLastRun(); $dec_places = Settings::Get('panel.decimal_places');
$outstanding_tasks = Cronjob::getOutstandingTasks(); // get everything in bytes for the percentage calculation on the dashboard
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1;
$userinfo['diskspace_bytes_used'] = $userinfo['diskspace_used'] * 1024;
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : - 1;
$userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024;
// additional sys-infos $userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1;
$userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace_used'] * 1024, null, 'bi');
$userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1;
$userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi');
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace diskspace_bytes traffic traffic_bytes mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
$userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
$cron_last_runs = \Froxlor\System\Cronjob::getCronjobsLastRun();
$outstanding_tasks = \Froxlor\System\Cronjob::getOutstandingTasks();
$system_hostname = gethostname();
$meminfo = explode("\n", @file_get_contents("/proc/meminfo")); $meminfo = explode("\n", @file_get_contents("/proc/meminfo"));
$memory = ""; $memory = "";
for ($i = 0; $i < count($meminfo); ++$i) { for ($i = 0; $i < sizeof($meminfo); ++ $i) {
if (substr($meminfo[$i], 0, 3) === "Mem") { if (substr($meminfo[$i], 0, 3) === "Mem") {
$memory .= $meminfo[$i] . PHP_EOL; $memory .= $meminfo[$i] . PHP_EOL;
} }
@@ -148,21 +146,25 @@ if ($page == 'overview') {
$load = number_format($loadArray[0], 2, '.', '') . " / " . number_format($loadArray[1], 2, '.', '') . " / " . number_format($loadArray[2], 2, '.', ''); $load = number_format($loadArray[0], 2, '.', '') . " / " . number_format($loadArray[1], 2, '.', '') . " / " . number_format($loadArray[2], 2, '.', '');
} else { } else {
$load = @file_get_contents('/proc/loadavg'); $load = @file_get_contents('/proc/loadavg');
if (!$load) {
$load = lng('admin.noloadavailable'); if (! $load) {
$load = $lng['admin']['noloadavailable'];
} }
} }
$kernel = '';
if (function_exists('posix_uname')) { if (function_exists('posix_uname')) {
$showkernel = 1;
$kernel_nfo = posix_uname(); $kernel_nfo = posix_uname();
$kernel = $kernel_nfo['release'] . ' (' . $kernel_nfo['machine'] . ')'; $kernel = $kernel_nfo['release'] . ' (' . $kernel_nfo['machine'] . ')';
} else {
$showkernel = 0;
$kernel = '';
} }
// Try to get the uptime // Try to get the uptime
// First: With exec (let's hope it's enabled for the Froxlor - vHost) // First: With exec (let's hope it's enabled for the Froxlor - vHost)
$uptime_array = explode(" ", @file_get_contents("/proc/uptime")); $uptime_array = explode(" ", @file_get_contents("/proc/uptime"));
$uptime = '';
if (is_array($uptime_array) && isset($uptime_array[0]) && is_numeric($uptime_array[0])) { if (is_array($uptime_array) && isset($uptime_array[0]) && is_numeric($uptime_array[0])) {
// Some calculatioon to get a nicly formatted display // Some calculatioon to get a nicly formatted display
$seconds = round($uptime_array[0], 0); $seconds = round($uptime_array[0], 0);
@@ -173,134 +175,230 @@ if ($page == 'overview') {
$minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60)); $minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
$seconds = floor($seconds - ($days * 24 * 60 * 60) - ($hours * 60 * 60) - ($minutes * 60)); $seconds = floor($seconds - ($days * 24 * 60 * 60) - ($hours * 60 * 60) - ($minutes * 60));
$uptime = "{$days}d, {$hours}h, {$minutes}m, {$seconds}s"; $uptime = "{$days}d, {$hours}h, {$minutes}m, {$seconds}s";
// Just cleanup // Just cleanup
unset($uptime_array, $seconds, $minutes, $hours, $days); unset($uptime_array, $seconds, $minutes, $hours, $days);
} else {
// Nothing of the above worked, show an error :/
$uptime = '';
} }
$sysinfo = [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/index") . "\";");
'webserver' => $_SERVER['SERVER_SOFTWARE'] ?? 'unknown',
'phpversion' => phpversion(),
'mysqlserverversion' => Database::getAttribute(PDO::ATTR_SERVER_VERSION),
'phpsapi' => strtoupper(@php_sapi_name()),
'hostname' => gethostname(),
'memory' => $memory,
'load' => $load,
'kernel' => $kernel,
'uptime' => $uptime
];
UI::twig()->addGlobal('userinfo', $userinfo);
UI::view('user/index.html.twig', [
'sysinfo' => $sysinfo,
'overview' => $overview,
'outstanding_tasks' => $outstanding_tasks,
'cron_last_runs' => $cron_last_runs
]);
} elseif ($page == 'change_password') { } elseif ($page == 'change_password') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$old_password = Validate::validate($_POST['old_password'], 'old password');
if (!Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_ADMINS, 'adminid')) { if (isset($_POST['send']) && $_POST['send'] == 'send') {
Response::standardError('oldpasswordnotcorrect'); $old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password');
if (! \Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_ADMINS, 'adminid')) {
\Froxlor\UI\Response::standard_error('oldpasswordnotcorrect');
} }
try { try {
$new_password = Crypt::validatePassword($_POST['new_password'], 'new password'); $new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password');
$new_password_confirm = Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm'); $new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
if ($old_password == '') { if ($old_password == '') {
Response::standardError([ \Froxlor\UI\Response::standard_error(array(
'stringisempty', 'stringisempty',
'changepassword.old_password' 'oldpassword'
]); ));
} elseif ($new_password == '') { } elseif ($new_password == '') {
Response::standardError([ \Froxlor\UI\Response::standard_error(array(
'stringisempty', 'stringisempty',
'changepassword.new_password' 'newpassword'
]); ));
} elseif ($new_password_confirm == '') { } elseif ($new_password_confirm == '') {
Response::standardError([ \Froxlor\UI\Response::standard_error(array(
'stringisempty', 'stringisempty',
'changepassword.new_password_confirm' 'newpasswordconfirm'
]); ));
} elseif ($new_password != $new_password_confirm) { } elseif ($new_password != $new_password_confirm) {
Response::standardError('newpasswordconfirmerror'); \Froxlor\UI\Response::standard_error('newpasswordconfirmerror');
} else { } else {
try { try {
Admins::getLocal($userinfo, [ Admins::getLocal($userinfo, array(
'id' => $userinfo['adminid'], 'id' => $userinfo['adminid'],
'admin_password' => $new_password 'admin_password' => $new_password
])->update(); ))->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'changed password'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'changed password');
Response::redirectTo($filename); \Froxlor\UI\Response::redirectTo($filename, Array(
's' => $s
));
} }
} else { } else {
UI::view('user/change_password.html.twig'); eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_password") . "\";");
} }
} elseif ($page == 'change_language') { } elseif ($page == 'change_language') {
$languages = Language::getLanguages();
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$def_language = Validate::validate($_POST['def_language'], 'default language'); $def_language = \Froxlor\Validate\Validate::validate($_POST['def_language'], 'default language');
if (isset($languages[$def_language])) { if (isset($languages[$def_language])) {
try { try {
Admins::getLocal($userinfo, [ Admins::getLocal($userinfo, array(
'id' => $userinfo['adminid'], 'id' => $userinfo['adminid'],
'def_language' => $def_language 'def_language' => $def_language
])->update(); ))->update();
CurrentUser::setField('language', $def_language);
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
// also update current session
$lng_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `language`= :lng
WHERE `hash`= :hash");
Database::pexecute($lng_stmt, array(
'lng' => $def_language,
'hash' => $s
));
} }
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
Response::redirectTo($filename); \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} else { } else {
$language_options = '';
$default_lang = Settings::Get('panel.standardlanguage'); $default_lang = Settings::Get('panel.standardlanguage');
if ($userinfo['def_language'] != '') { if ($userinfo['def_language'] != '') {
$default_lang = $userinfo['def_language']; $default_lang = $userinfo['def_language'];
} }
UI::view('user/change_language.html.twig', [ foreach ($languages as $language_file => $language_name) {
'languages' => $languages, $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $default_lang, true);
'default_lang' => $default_lang
]);
}
} elseif ($page == 'change_theme') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$theme = Validate::validate($_POST['theme'], 'theme');
try {
Admins::getLocal($userinfo, [
'id' => $userinfo['adminid'],
'theme' => $theme
])->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her theme to '" . $theme . "'"); eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_language") . "\";");
Response::redirectTo($filename); }
} elseif ($page == 'change_theme') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$theme = \Froxlor\Validate\Validate::validate($_POST['theme'], 'theme');
try {
Admins::getLocal($userinfo, array(
'id' => $userinfo['adminid'],
'theme' => $theme
))->update();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
// also update current session
$theme_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `theme`= :theme
WHERE `hash`= :hash");
Database::pexecute($theme_stmt, array(
'theme' => $theme,
'hash' => $s
));
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her theme to '" . $theme . "'");
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} else { } else {
$theme_options = '';
$default_theme = Settings::Get('panel.default_theme'); $default_theme = Settings::Get('panel.default_theme');
if ($userinfo['theme'] != '') { if ($userinfo['theme'] != '') {
$default_theme = $userinfo['theme']; $default_theme = $userinfo['theme'];
} }
$themes_avail = UI::getThemes(); $themes_avail = \Froxlor\UI\Template::getThemes();
foreach ($themes_avail as $t => $d) {
$theme_options .= \Froxlor\UI\HTML::makeoption($d, $t, $default_theme, true);
}
UI::view('user/change_theme.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_theme") . "\";");
'themes' => $themes_avail,
'default_theme' => $default_theme
]);
} }
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_admin') == '1') { } elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_admin') == '1') {
require_once __DIR__ . '/error_report.php';
// only show this if we really have an exception to report
if (isset($_GET['errorid']) && $_GET['errorid'] != '') {
$errid = $_GET['errorid'];
// read error file
$err_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . "/logs/");
$err_file = \Froxlor\FileDir::makeCorrectFile($err_dir . "/" . $errid . "_sql-error.log");
if (file_exists($err_file)) {
$error_content = file_get_contents($err_file);
$error = explode("|", $error_content);
$_error = array(
'code' => str_replace("\n", "", substr($error[1], 5)),
'message' => str_replace("\n", "", substr($error[2], 4)),
'file' => str_replace("\n", "", substr($error[3], 5 + strlen(\Froxlor\Froxlor::getInstallDir()))),
'line' => str_replace("\n", "", substr($error[4], 5)),
'trace' => str_replace(\Froxlor\Froxlor::getInstallDir(), "", substr($error[5], 6))
);
// build mail-content
$mail_body = "Dear froxlor-team,\n\n";
$mail_body .= "the following error has been reported by a user:\n\n";
$mail_body .= "-------------------------------------------------------------\n";
$mail_body .= $_error['code'] . ' ' . $_error['message'] . "\n\n";
$mail_body .= "File: " . $_error['file'] . ':' . $_error['line'] . "\n\n";
$mail_body .= "Trace:\n" . trim($_error['trace']) . "\n\n";
$mail_body .= "-------------------------------------------------------------\n\n";
$mail_body .= "Froxlor-version: " . $version . "\n";
$mail_body .= "DB-version: " . $dbversion . "\n\n";
$mail_body .= "End of report";
$mail_html = nl2br($mail_body);
// send actual report to dev-team
if (isset($_POST['send']) && $_POST['send'] == 'send') {
// send mail and say thanks
$_mailerror = false;
try {
$mail->Subject = '[Froxlor] Error report by user';
$mail->AltBody = $mail_body;
$mail->MsgHTML($mail_html);
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
$mail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
// error when reporting an error...LOLFUQ
\Froxlor\UI\Response::standard_error('send_report_error', $mailerr_msg);
}
// finally remove error from fs
@unlink($err_file);
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
}
// show a nice summary of the error-report
// before actually sending anything
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/send_error_report") . "\";");
} else {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
}
} else {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
}
} elseif ($page == 'apikeys' && Settings::Get('api.enabled') == 1) { } elseif ($page == 'apikeys' && Settings::Get('api.enabled') == 1) {
require_once __DIR__ . '/api_keys.php'; require_once __DIR__ . '/api_keys.php';
} elseif ($page == '2fa' && Settings::Get('2fa.enabled') == 1) { } elseif ($page == '2fa' && Settings::Get('2fa.enabled') == 1) {

View File

@@ -2,92 +2,106 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin'; use Froxlor\Settings;
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\IpsAndPorts; use Froxlor\Api\Commands\IpsAndPorts;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\UI\Collection;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'ipsandports' || $page == 'overview') {
// Do not display attributes that are not used by the current webserver
$websrv = Settings::Get('system.webserver');
$is_nginx = ($websrv == 'nginx');
$is_apache = ($websrv == 'apache2');
$is_apache24 = $is_apache && (Settings::Get('system.apache24') === '1');
if (($page == 'ipsandports' || $page == 'overview') && $userinfo['change_serversettings'] == '1') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_ipsandports");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_ipsandports");
$fields = array(
'ip' => $lng['admin']['ipsandports']['ip'],
'port' => $lng['admin']['ipsandports']['port']
);
try { try {
$ipsandports_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.ipsandports.php'; // get total count
$collection = (new Collection(IpsAndPorts::class, $userinfo)) $json_result = IpsAndPorts::getLocal($userinfo)->listingCount();
->withPagination($ipsandports_list_data['ipsandports_list']['columns'], $ipsandports_list_data['ipsandports_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = IpsAndPorts::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data'];
UI::view('user/table.html.twig', [ $ipsandports = '';
'listing' => Listing::format($collection, $ipsandports_list_data, 'ipsandports_list'), $sortcode = $paging->getHtmlSortCode($lng);
'actions_links' => [ $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
[ $searchcode = $paging->getHtmlSearchCode($lng);
'href' => $linker->getLink(['section' => 'ipsandports', 'page' => $page, 'action' => 'add']), $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
'label' => lng('admin.ipsandports.add') $count = 0;
]
] foreach ($result['list'] as $row) {
]); $row = \Froxlor\PhpHelper::htmlentitiesArray($row);
if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row['ip'] = '[' . $row['ip'] . ']';
}
eval("\$ipsandports.=\"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_ipandport") . "\";");
$count ++;
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports") . "\";");
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = IpsAndPorts::getLocal($userinfo, [ $json_result = IpsAndPorts::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if (isset($result['id']) && $result['id'] == $id) { if (isset($result['id']) && $result['id'] == $id) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
IpsAndPorts::getLocal($userinfo, [ IpsAndPorts::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->delete(); ))->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('admin_ip_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_ip_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['ip'] . ':' . $result['port']); ), $result['ip'] . ':' . $result['port']);
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
@@ -95,56 +109,62 @@ if (($page == 'ipsandports' || $page == 'overview') && $userinfo['change_servers
try { try {
IpsAndPorts::getLocal($userinfo, $_POST)->add(); IpsAndPorts::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$ipsandports_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_add.php';
UI::view('user/form.html.twig', [ $ipsandports_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_add.php';
'formaction' => $linker->getLink(['section' => 'ipsandports']), $ipsandports_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($ipsandports_add_data);
'formdata' => $ipsandports_add_data['ipsandports_add']
]); $title = $ipsandports_add_data['ipsandports_add']['title'];
$image = $ipsandports_add_data['ipsandports_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = IpsAndPorts::getLocal($userinfo, [ $json_result = IpsAndPorts::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['ip'] != '') { if ($result['ip'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
IpsAndPorts::getLocal($userinfo, $_POST)->update(); IpsAndPorts::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$result = PhpHelper::htmlentitiesArray($result);
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$ipsandports_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php'; $ipsandports_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php';
$ipsandports_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($ipsandports_edit_data);
UI::view('user/form.html.twig', [ $title = $ipsandports_edit_data['ipsandports_edit']['title'];
'formaction' => $linker->getLink(['section' => 'ipsandports', 'id' => $id]), $image = $ipsandports_edit_data['ipsandports_edit']['image'];
'formdata' => $ipsandports_edit_data['ipsandports_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_edit") . "\";");
]);
} }
} }
} elseif ($action == 'jqCheckIP') { } elseif ($action == 'jqCheckIP') {
$ip = $_POST['ip'] ?? ""; $ip = $_POST['ip'] ?? "";
if ((filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE) == false) { if ((filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE) == false) {
// returns notice if private network detected so we can display it // returns notice if private network detected so we can display it
echo json_encode(lng('admin.ipsandports.ipnote')); echo json_encode($lng['admin']['ipsandports']['ipnote']);
} else { } else {
echo 0; echo 0;
} }

View File

@@ -2,75 +2,131 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
const AREA = 'admin'; require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SysLog; use Froxlor\Api\Commands\SysLog;
use Froxlor\UI\Collection;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
if ($page == 'log' && $userinfo['change_serversettings'] == '1') { if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
if ($action == '') { if ($action == '') {
$fields = array(
'date' => $lng['logger']['date'],
'type' => $lng['logger']['type'],
'user' => $lng['logger']['user'],
'text' => $lng['logger']['action']
);
try { try {
$syslog_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.syslog.php'; // get total count
$collection = (new Collection(SysLog::class, $userinfo)) $json_result = SysLog::getLocal($userinfo)->listingCount();
->withPagination($syslog_list_data['syslog_list']['columns'], $syslog_list_data['syslog_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$clog = array();
foreach ($result['list'] as $row) {
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
$clog[$row['action']] = array();
}
$clog[$row['action']][$row['logid']] = $row;
} }
UI::view('user/table.html.twig', [ if ($paging->sortfield == 'date' && $paging->sortorder == 'desc') {
'listing' => Listing::format($collection, $syslog_list_data, 'syslog_list'), krsort($clog);
'actions_links' => [ } else {
[ ksort($clog);
'href' => $linker->getLink(['section' => 'logger', 'page' => 'log', 'action' => 'truncate']), }
'label' => lng('logger.truncate'),
'icon' => 'fa-solid fa-recycle', $count = 0;
'class' => 'btn-warning' $log_count = 0;
] $log = '';
] foreach ($clog as $action => $logrows) {
]); $_action = 0;
foreach ($logrows as $row) {
// if ($paging->checkDisplay($i)) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$row['date'] = date("d.m.y H:i:s", $row['date']);
if ($_action != $action) {
switch ($action) {
case \Froxlor\FroxlorLogger::USR_ACTION:
$_action = $lng['admin']['customer'];
break;
case \Froxlor\FroxlorLogger::RES_ACTION:
$_action = $lng['logger']['reseller'];
break;
case \Froxlor\FroxlorLogger::ADM_ACTION:
$_action = $lng['logger']['admin'];
break;
case \Froxlor\FroxlorLogger::CRON_ACTION:
$_action = $lng['logger']['cron'];
break;
case \Froxlor\FroxlorLogger::LOGIN_ACTION:
$_action = $lng['logger']['login'];
break;
case \Froxlor\FroxlorLogger::LOG_ERROR:
$_action = $lng['logger']['intern'];
break;
default:
$_action = $lng['logger']['unknown'];
break;
}
$row['action'] = $_action;
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_action') . "\";");
}
$log_count ++;
$row['type'] = \Froxlor\FroxlorLogger::getInstanceOf()->getLogLevelDesc($row['type']);
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";");
$count ++;
$_action = $action;
}
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";");
} elseif ($action == 'truncate') { } elseif ($action == 'truncate') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
SysLog::getLocal($userinfo, [ SysLog::getLocal($userinfo, array(
'min_to_keep' => 10 'min_to_keep' => 10
])->delete(); ))->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('logger_reallytruncate', $filename, [ \Froxlor\UI\HTML::askYesNo('logger_reallytruncate', $filename, array(
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], TABLE_PANEL_LOG); ), TABLE_PANEL_LOG);
} }
} }
} }

View File

@@ -2,149 +2,126 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
const AREA = 'admin'; require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\User;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
$note_type = null; } elseif (isset($_GET['id'])) {
$note_msg = null; $id = intval($_GET['id']);
}
if ($page == 'message') { if ($page == 'message') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message');
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
if ($_POST['recipient'] == 0 && $userinfo['customers_see_all'] == '1') { if ($_POST['recipient'] == 0 && $userinfo['customers_see_all'] == '1') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to admins'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to admins');
$result = Database::query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`"); $result = Database::query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`");
} elseif ($_POST['recipient'] == 1) { } elseif ($_POST['recipient'] == 1) {
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers');
$result = Database::query('SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`"); $result = Database::query('SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`");
} else { } else {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to customers'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to customers');
$result = Database::prepare(' $result = Database::prepare('
SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`
WHERE `adminid` = :adminid"); WHERE `adminid` = :adminid");
Database::pexecute($result, [ Database::pexecute($result, array(
'adminid' => $userinfo['adminid'] 'adminid' => $userinfo['adminid']
]); ));
} }
} else { } else {
Response::standardError('norecipientsgiven'); \Froxlor\UI\Response::standard_error('norecipientsgiven');
} }
$subject = $_POST['subject']; $subject = $_POST['subject'];
$message = wordwrap($_POST['message'], 70); $message = wordwrap($_POST['message'], 70);
if (!empty($message)) { if (! empty($message)) {
$mailcounter = 0; $mailcounter = 0;
$mail->Body = $message; $mail->Body = $message;
$mail->Subject = $subject; $mail->Subject = $subject;
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$row['firstname'] = isset($row['firstname']) ? $row['firstname'] : ''; $row['firstname'] = isset($row['firstname']) ? $row['firstname'] : '';
$row['company'] = isset($row['company']) ? $row['company'] : ''; $row['company'] = isset($row['company']) ? $row['company'] : '';
$mail->AddAddress($row['email'], User::getCorrectUserSalutation([ $mail->AddAddress($row['email'], \Froxlor\User::getCorrectUserSalutation(array(
'firstname' => $row['firstname'], 'firstname' => $row['firstname'],
'name' => $row['name'], 'name' => $row['name'],
'company' => $row['company'] 'company' => $row['company']
])); )));
$mail->From = $userinfo['email']; $mail->From = $userinfo['email'];
$mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name']; $mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name'];
if (!$mail->Send()) { if (! $mail->Send()) {
if ($mail->ErrorInfo != '') { if ($mail->ErrorInfo != '') {
$mailerr_msg = $mail->ErrorInfo; $mailerr_msg = $mail->ErrorInfo;
} else { } else {
$mailerr_msg = $row['email']; $mailerr_msg = $row['email'];
} }
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg);
Response::standardError('errorsendingmail', $row['email']); \Froxlor\UI\Response::standard_error('errorsendingmail', $row['email']);
} }
$mailcounter++; $mailcounter ++;
$mail->ClearAddresses(); $mail->ClearAddresses();
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s,
'action' => 'showsuccess', 'action' => 'showsuccess',
'sentitems' => $mailcounter 'sentitems' => $mailcounter
]); ));
} else { } else {
Response::standardError('nomessagetosend'); \Froxlor\UI\Response::standard_error('nomessagetosend');
} }
} }
} elseif ($action == 'showsuccess') { }
$sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0;
if ($action == 'showsuccess') {
$success = 1;
$sentitems = isset($_GET['sentitems']) ? (int) $_GET['sentitems'] : 0;
if ($sentitems == 0) { if ($sentitems == 0) {
$note_type = 'info'; $successmessage = $lng['message']['norecipients'];
$note_msg = lng('message.norecipients');
} else { } else {
$note_type = 'success'; $successmessage = str_replace('%s', $sentitems, $lng['message']['success']);
$note_msg = str_replace('%s', $sentitems, lng('message.success'));
} }
} else {
$success = 0;
$sentitems = 0;
$successmessage = '';
} }
$recipients = []; $action = '';
$recipients = '';
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
$recipients[0] = lng('panel.reseller'); $recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['reseller'], 0);
} }
$recipients[1] = lng('panel.customer');
$messages_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/messages/formfield.messages_add.php'; $recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['customer'], 1);
eval("echo \"" . \Froxlor\UI\Template::getTemplate('message/message') . "\";");
UI::view('user/form-note.html.twig', [
'formaction' => $linker->getLink(['section' => 'message']),
'formdata' => $messages_add_data['messages_add'],
'actions_links' => [
[
'href' => $linker->getLink([
'section' => 'settings',
'page' => 'overview',
'part' => 'system',
'em' => 'system_mail_use_smtp'
]),
'label' => lng('admin.smtpsettings'),
'icon' => 'fa-solid fa-gears',
'class' => 'btn-outline-secondary'
]
],
// alert-box
'type' => $note_type,
'alert_msg' => $note_msg
]);
} }

View File

@@ -1,144 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\MysqlServer;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\UI\Collection;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$id = (int)Request::any('id');
if (($page == 'mysqlserver' || $page == 'overview') && $userinfo['change_serversettings'] == '1') {
if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_mysqlserver");
try {
$mysqlserver_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.mysqlserver.php';
$collection = (new Collection(MysqlServer::class, $userinfo))
->withPagination($mysqlserver_list_data['mysqlserver_list']['columns'], $mysqlserver_list_data['mysqlserver_list']['default_sorting']);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $mysqlserver_list_data, 'mysqlserver_list'),
'actions_links' => [
[
'href' => $linker->getLink(['section' => 'mysqlserver', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.mysqlserver.add')
]
]
]);
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = MysqlServer::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['id']) && $result['id'] == $id) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
MysqlServer::getLocal($userinfo, [
'id' => $id
])->delete();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
HTML::askYesNo('admin_mysqlserver_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
], $result['caption'] . ' (' . $result['host'] . ')');
}
}
} elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
MysqlServer::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$mysqlserver_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/mysqlserver/formfield.mysqlserver_add.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'mysqlserver']),
'formdata' => $mysqlserver_add_data['mysqlserver_add']
]);
}
} elseif ($action == 'edit' && $id >= 0) {
try {
$json_result = MysqlServer::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['id']) && $result['id'] == $id) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
MysqlServer::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$result = PhpHelper::htmlentitiesArray($result);
$mysqlserver_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/mysqlserver/formfield.mysqlserver_edit.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'mysqlserver', 'id' => $id]),
'formdata' => $mysqlserver_edit_data['mysqlserver_edit'],
'editid' => $id
]);
}
}
}
}

View File

@@ -4,305 +4,153 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Janos Muzsi <muzsij@hypernics.hu> (2016)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License * Based on https://github.com/amnuts/opcache-gui
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
* *
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @author Janos Muzsi <muzsij@hypernics.hu>
* @author Andrew Collington <andy@amnuts.com>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*
* Based on https://github.com/amnuts/opcache-gui, which is
* licensed under the MIT licence, which can be viewed
* online at https://acollington.mit-license.org/
*/ */
define('AREA', 'admin');
const AREA = 'admin'; require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\FroxlorLogger;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
use Froxlor\UI\HTML;
if ($action == 'reset' && function_exists('opcache_reset') && $userinfo['change_serversettings'] == '1') { if ($action == 'reset' && function_exists('opcache_reset') && $userinfo['change_serversettings'] == '1') {
if ($_POST['send'] == 'send') { opcache_reset();
opcache_reset(); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "reset OPcache");
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "reset OPcache"); header('Location: ' . $linker->getLink(array(
header('Location: ' . $linker->getLink([ 'section' => 'opcacheinfo',
'section' => 'opcacheinfo', 'page' => 'showinfo'
'page' => 'showinfo' )));
])); exit();
exit();
} else {
HTML::askYesNo('cache_reallydelete', $filename, [
'page' => $page,
'action' => 'reset',
], '', [
'section' => 'opcacheinfo',
'page' => 'showinfo'
]);
}
} }
if (!function_exists('opcache_get_configuration')) { if (! function_exists('opcache_get_configuration')) {
Response::standardError(lng('error.no_opcacheinfo')); \Froxlor\UI\Response::standard_error($lng['error']['no_opcacheinfo']);
} }
if ($page == 'showinfo' && $userinfo['change_serversettings'] == '1') { if ($page == 'showinfo') {
$opcache_info = opcache_get_configuration();
$opcache_status = opcache_get_status(false);
$time = time(); $time = time();
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed OPcache info"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed OPcache info");
$optimizationLevels = [ $runtimelines = '';
1 << 0 => 'CSE, STRING construction', if (isset($opcache_info['directives']) && is_array($opcache_info['directives'])) {
1 << 1 => 'Constant conversion and jumps', foreach ($opcache_info['directives'] as $name => $value) {
1 << 2 => '++, +=, series of jumps', $linkname = str_replace('_', '-', $name);
1 << 3 => 'INIT_FCALL_BY_NAME -> DO_FCALL', if ($name == 'opcache.optimization_level' && is_integer($value)) {
1 << 4 => 'CFG based optimization', $value = '0x' . dechex($value);
1 << 5 => 'DFA based optimization', }
1 << 6 => 'CALL GRAPH optimization', if ($name == 'opcache.memory_consumption' && is_integer($value) && $value % (1024 * 1024) == 0) {
1 << 7 => 'SCCP (constant propagation)', $value = $value / (1024 * 1024);
1 << 8 => 'TMP VAR usage', }
1 << 9 => 'NOP removal', if ($value === null || $value === '') {
1 << 10 => 'Merge equal constants', $value = $lng['opcacheinfo']['novalue'];
1 << 11 => 'Adjust used stack', }
1 << 12 => 'Remove unused variables', if ($value === true) {
1 << 13 => 'DCE (dead code elimination)', $value = $lng['opcacheinfo']['true'];
1 << 14 => '(unsafe) Collect constants', }
1 << 15 => 'Inline functions' if ($value === false) {
]; $value = $lng['opcacheinfo']['false'];
}
$jitModes = [ if (is_integer($value)) {
[ $value = number_format($value, 0, '.', ' ');
'flag' => 'CPU-specific optimization', }
'value' => [ $name = str_replace('_', ' ', $name);
'Disable CPU-specific optimization', eval("\$runtimelines.=\"" . \Froxlor\UI\Template::getTemplate("settings/opcacheinfo/runtime_line") . "\";");
'Enable use of AVX, if the CPU supports it'
]
],
[
'flag' => 'Register allocation',
'value' => [
'Do not perform register allocation',
'Perform block-local register allocation',
'Perform global register allocation'
]
],
[
'flag' => 'Trigger',
'value' => [
'Compile all functions on script load',
'Compile functions on first execution',
'Profile functions on first request and compile the hottest functions afterwards',
'Profile on the fly and compile hot functions',
'Currently unused',
'Use tracing JIT. Profile on the fly and compile traces for hot code segments'
]
],
[
'flag' => 'Optimization level',
'value' => [
'No JIT',
'Minimal JIT (call standard VM handlers)',
'Inline VM handlers',
'Use type inference',
'Use call graph',
'Optimize whole script'
]
]
];
$jitModeMapping = [
'tracing' => 1254,
'on' => 1254,
'function' => 1205
];
$status = opcache_get_status(false);
$config = opcache_get_configuration();
$missingConfig = array_diff_key(ini_get_all('zend opcache', false), $config['directives']);
if (!empty($missingConfig)) {
$config['directives'] = array_merge($config['directives'], $missingConfig);
}
$files = [];
if (!empty($status['scripts'])) {
uasort($status['scripts'], static function ($a, $b) {
return $a['hits'] <=> $b['hits'];
});
foreach ($status['scripts'] as &$file) {
$file['full_path'] = str_replace('\\', '/', $file['full_path']);
$file['readable'] = [
'hits' => number_format($file['hits']),
'memory_consumption' => bsize($file['memory_consumption'])
];
}
$files = array_values($status['scripts']);
}
if ($config['directives']['opcache.file_cache_only'] || !empty($status['file_cache_only'])) {
$overview = false;
} else {
$status['opcache_statistics']['start_time'] = $status['opcache_statistics']['start_time'] ?? time();
$status['opcache_statistics']['last_restart_time'] = $status['opcache_statistics']['last_restart_time'] ?? time();
$overview = array_merge(
$status['memory_usage'],
$status['opcache_statistics'],
[
'total_memory' => $config['directives']['opcache.memory_consumption'],
'used_memory_percentage' => round(100 * (
($status['memory_usage']['used_memory'] + $status['memory_usage']['wasted_memory'])
/ $config['directives']['opcache.memory_consumption']
)),
'hit_rate_percentage' => round($status['opcache_statistics']['opcache_hit_rate']),
'used_key_percentage' => round(100 * ($status['opcache_statistics']['num_cached_keys']
/ $status['opcache_statistics']['max_cached_keys']
)),
'wasted_percentage' => round($status['memory_usage']['current_wasted_percentage'], 2),
'readable' => [
'total_memory' => bsize($config['directives']['opcache.memory_consumption']),
'used_memory' => bsize($status['memory_usage']['used_memory']),
'free_memory' => bsize($status['memory_usage']['free_memory']),
'wasted_memory' => bsize($status['memory_usage']['wasted_memory']),
'num_cached_scripts' => number_format($status['opcache_statistics']['num_cached_scripts']),
'hits' => number_format($status['opcache_statistics']['hits']),
'misses' => number_format($status['opcache_statistics']['misses']),
'blacklist_miss' => number_format($status['opcache_statistics']['blacklist_misses']),
'num_cached_keys' => number_format($status['opcache_statistics']['num_cached_keys']),
'max_cached_keys' => number_format($status['opcache_statistics']['max_cached_keys']),
'interned' => null,
'start_time' => (new DateTimeImmutable("@{$status['opcache_statistics']['start_time']}"))
->setTimezone(new DateTimeZone(date_default_timezone_get()))
->format('Y-m-d H:i:s'),
'last_restart_time' => ($status['opcache_statistics']['last_restart_time'] == 0
? 'never'
: (new DateTimeImmutable("@{$status['opcache_statistics']['last_restart_time']}"))
->setTimezone(new DateTimeZone(date_default_timezone_get()))
->format('Y-m-d H:i:s')
)
]
]
);
}
$preload = [];
if (!empty($status['preload_statistics']['scripts'])) {
$preload = $status['preload_statistics']['scripts'];
sort($preload, SORT_STRING);
if ($overview) {
$overview['preload_memory'] = $status['preload_statistics']['memory_consumption'];
$overview['readable']['preload_memory'] = bsize($status['preload_statistics']['memory_consumption']);
} }
} }
if (!empty($status['interned_strings_usage'])) { $cachehits = @$opcache_status['opcache_statistics']['hits'] ?: 0;
$overview['readable']['interned'] = [ $cachemiss = @$opcache_status['opcache_statistics']['misses'] ?: 0;
'buffer_size' => bsize($status['interned_strings_usage']['buffer_size']), $blacklistmiss = @$opcache_status['opcache_statistics']['blacklist_misses'] ?: 0;
'strings_used_memory' => bsize($status['interned_strings_usage']['used_memory']), $cachetotal = $cachehits + $cachemiss + $blacklistmiss;
'strings_free_memory' => bsize($status['interned_strings_usage']['free_memory']),
'number_of_strings' => number_format($status['interned_strings_usage']['number_of_strings'])
];
}
if ($overview && !empty($status['jit'])) { $general = array(
$overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size'] 'version' => (isset($opcache_info['version']['opcache_product_name']) ? $opcache_info['version']['opcache_product_name'] . ' ' : '') . $opcache_info['version']['version'],
? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size'])) 'phpversion' => phpversion(),
: 0 'start_time' => @$opcache_status['opcache_statistics']['start_time'] ? date('Y-m-d H:i:s', $opcache_status['opcache_statistics']['start_time']) : '',
); 'last_restart_time' => @$opcache_status['opcache_statistics']['last_restart_time'] ? date('Y-m-d H:i:s', $opcache_status['opcache_statistics']['last_restart_time']) : $lng['opcacheinfo']['never'],
$overview['readable'] = array_merge($overview['readable'], [ 'oom_restarts' => number_format(@$opcache_status['opcache_statistics']['oom_restarts'] ?: 0, 0, '.', ' '),
'jit_buffer_size' => bsize($status['jit']['buffer_size']), 'hash_restarts' => number_format(@$opcache_status['opcache_statistics']['hash_restarts'] ?: 0, 0, '.', ' '),
'jit_buffer_free' => bsize($status['jit']['buffer_free']) 'manual_restarts' => number_format(@$opcache_status['opcache_statistics']['manual_restarts'] ?: 0, 0, '.', ' '),
]); 'status' => (@$opcache_status['restart_in_progress'] ? $lng['opcacheinfo']['restartinprogress'] : (@$opcache_status['restart_pending'] ? $lng['opcacheinfo']['restartpending'] : (@$opcache_status['cache_full'] ? $lng['opcacheinfo']['cachefull'] : (@$opcache_status['opcache_enabled'] ? $lng['opcacheinfo']['enabled'] : $lng['opcacheinfo']['novalue'])))),
} 'cachedscripts' => number_format(@$opcache_status['opcache_statistics']['num_cached_scripts'] ?: 0, 0, '.', ' '),
'cachehits' => number_format($cachehits, 0, '.', ' ') . ($cachetotal > 0 ? sprintf(" (%.1f %%)", $cachehits / ($cachetotal) * 100) : ''),
$directives = []; 'cachemiss' => number_format($cachemiss, 0, '.', ' ') . ($cachetotal > 0 ? sprintf(" (%.1f %%)", $cachemiss / ($cachetotal) * 100) : ''),
ksort($config['directives']); 'blacklistmiss' => number_format($blacklistmiss, 0, '.', ' ') . ($cachetotal > 0 ? sprintf(" (%.1f %%)", $blacklistmiss / ($cachetotal) * 100) : '')
foreach ($config['directives'] as $k => $v) {
if (in_array($k, ['opcache.max_file_size', 'opcache.memory_consumption', 'opcache.jit_buffer_size']) && $v) {
$v = bsize($v) . " ({$v})";
} elseif ($k === 'opcache.optimization_level') {
$levels = [];
foreach ($optimizationLevels as $level => $info) {
if ($level & $v) {
$levels[] = "{$info} [{$level}]";
}
}
$v = $levels ?: 'none';
} elseif ($k === 'opcache.jit') {
if ($v === '1') {
$v = 'on';
}
if (isset($jitModeMapping[$v]) || is_numeric($v)) {
$levels = [];
foreach (str_split((string)($jitModeMapping[$v] ?? $v)) as $type => $level) {
$levels[] = "{$level}: {$jitModes[$type]['value'][$level]} ({$jitModes[$type]['flag']})";
}
$v = [$v, $levels];
} elseif (empty($v) || strtolower($v) === 'off') {
$v = 'Off';
}
}
$directives[] = [
'k' => $k,
'v' => $v
];
}
$version = array_merge(
$config['version'],
[
'php' => phpversion(),
'server' => $_SERVER['SERVER_SOFTWARE'] ?: '',
'host' => (function_exists('gethostname')
? gethostname()
: (php_uname('n')
?: (empty($_SERVER['SERVER_NAME'])
? $_SERVER['HOST_NAME']
: $_SERVER['SERVER_NAME']
)
)
)
]
); );
UI::view('settings/opcacheinfo.html.twig', [ $usedmem = @$opcache_status['memory_usage']['used_memory'] ?: 0;
'opcacheinfo' => [ $usedmemstr = bsize($usedmem);
'version' => $version, $freemem = @$opcache_status['memory_usage']['free_memory'] ?: 0;
'overview' => $overview, $freememstr = bsize($freemem);
'files' => $files, $totalmem = $usedmem + $freemem;
'preload' => $preload, $wastedmem = @$opcache_status['memory_usage']['wasted_memory'] ?: 0;
'directives' => $directives, $wastedmemstr = bsize($wastedmem);
'blacklist' => $config['blacklist'], if ($totalmem) {
'functions' => get_extension_funcs('Zend OPcache') $memory = array(
] 'total' => bsize($totalmem),
]); 'used' => $usedmemstr . ($totalmem > 0 ? sprintf(" (%.1f %%)", $usedmem / ($totalmem) * 100) : ''),
'free' => $freememstr . ($totalmem > 0 ? sprintf(" (%.1f %%)", $freemem / ($totalmem) * 100) : ''),
'wasted' => $wastedmemstr . ($totalmem > 0 ? sprintf(" (%.1f %%)", $wastedmem / ($totalmem) * 100) : '')
);
}
if (isset($opcache_status['interned_strings_usage'])) {
$usedstring = @$opcache_status['interned_strings_usage']['used_memory'] ?: 0;
$usedstringstr = bsize($usedstring);
$freestring = @$opcache_status['interned_strings_usage']['free_memory'] ?: 0;
$freestringstr = bsize($freestring);
$totalstring = $usedstring + $freestring;
$stringbuffer = array(
'total' => bsize($totalstring),
'used' => $usedstringstr . ($totalstring > 0 ? sprintf(" (%.1f %%)", $usedstring / $totalstring * 100) : ''),
'free' => $freestringstr . ($totalstring > 0 ? sprintf(" (%.1f %%)", $freestring / $totalstring * 100) : ''),
'strcount' => number_format(@$opcache_status['interned_strings_usage']['number_of_strings'] ?: 0, 0, '.', ' ')
);
}
$usedkey = @$opcache_status['opcache_statistics']['num_cached_keys'] ?: 0;
$usedkeystr = number_format($usedkey, 0, '.', ' ');
$totalkey = @$opcache_status['opcache_statistics']['max_cached_keys'] ?: 0;
$wastedkey = $usedkey - (@$opcache_status['opcache_statistics']['num_cached_scripts'] ?: 0);
if (isset($opcache_status['opcache_statistics'])) {
$keystat = array(
'total' => number_format($totalkey, 0, '.', ' '),
'used' => $usedkeystr . ($totalkey > 0 ? sprintf(" (%.1f %%)", $usedkey / ($totalkey) * 100) : ''),
'wasted' => number_format($wastedkey, 0, '.', ' ') . ($totalkey > 0 ? sprintf(" (%.1f %%)", $wastedkey / ($totalkey) * 100) : '')
);
}
$blacklistlines = '';
if (isset($opcache_info['blacklist']) && is_array($opcache_info['blacklist'])) {
foreach ($opcache_info['blacklist'] as $value) {
eval("\$blacklistlines.=\"" . \Froxlor\UI\Template::getTemplate("settings/opcacheinfo/blacklist_line") . "\";");
}
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/opcacheinfo/showinfo") . "\";");
} }
function bsize($size) function bsize($s)
{ {
$i = 0; foreach (array(
$val = ['b', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
while (($size / 1024) > 1) {
$size /= 1024;
++$i;
}
return sprintf(
'%.2f%s%s',
$size,
'', '',
$val[$i] 'K',
); 'M',
'G'
) as $i => $k) {
if ($s < 1024)
break;
$s /= 1024;
}
return sprintf("%5.1f %sBytes", $s, $k);
} }

View File

@@ -2,80 +2,89 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\FpmDaemons;
use Froxlor\Api\Commands\PhpSettings;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Froxlor; use Froxlor\Api\Commands\PhpSettings as PhpSettings;
use Froxlor\UI\Collection; use Froxlor\Api\Commands\FpmDaemons as FpmDaemons;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'overview') { if ($page == 'overview') {
if ($action == '') { if ($action == '') {
try { try {
$phpconf_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.phpconfigs.php'; $json_result = PhpSettings::getLocal($userinfo, array(
$collection = (new Collection(PhpSettings::class, $userinfo, ['with_subdomains' => true])) 'with_subdomains' => true
->withPagination($phpconf_list_data['phpconf_list']['columns'], $phpconf_list_data['phpconf_list']['default_sorting']); ))->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$tablecontent = '';
$count = 0;
if (isset($result['count']) && $result['count'] > 0) {
foreach ($result['list'] as $row) {
if (isset($row['is_default']) && $row['is_default'] == true) {
$row['description'] = "<b>" . $row['description'] . "</b>";
}
$domains = "";
$subdomains_count = count($row['subdomains']);
foreach ($row['domains'] as $configdomain) {
$domains .= $idna_convert->decode($configdomain) . "<br>";
}
$count ++;
if ($subdomains_count == 0 && empty($domains)) {
$domains = $lng['admin']['phpsettings']['notused'];
}
eval("\$tablecontent.=\"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview_overview") . "\";");
}
} }
UI::view('user/table.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview") . "\";");
'listing' => Listing::format($collection, $phpconf_list_data, 'phpconf_list'),
'actions_links' => (bool)$userinfo['change_serversettings'] ? [
[
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.phpsettings.addnew')
]
] : []
]);
} }
if ($action == 'add') { if ($action == 'add') {
if ((int)$userinfo['change_serversettings'] == 1) {
if ((int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
PhpSettings::getLocal($userinfo, $_POST)->add(); PhpSettings::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
if (file_exists(Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php')) {
include Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php'; if (file_exists(\Froxlor\Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php')) {
require_once \Froxlor\Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php';
$result = [ $result = [
'phpsettings' => $phpini 'phpsettings' => DEFAULT_PHPINI
]; ];
} else { } else {
// use first php-config as fallback // use first php-config as fallback
@@ -83,215 +92,251 @@ if ($page == 'overview') {
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
} }
$fpmconfigs = []; $fpmconfigs = '';
$configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC"); $configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
$fpmconfigs[$row['id']] = $row['description']; $fpmconfigs .= \Froxlor\UI\HTML::makeoption($row['description'], $row['id'], 1, true, true);
} }
$phpconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php'; $pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', 'dynamic', true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', 'dynamic', true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', 'dynamic', true, true);
UI::view('user/form-replacers.html.twig', [ $phpconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php';
'formaction' => $linker->getLink(['section' => 'phpsettings']), $phpconfig_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($phpconfig_add_data);
'formdata' => $phpconfig_add_data['phpconfig_add'],
'replacers' => $phpconfig_add_data['phpconfig_replacers'] $title = $phpconfig_add_data['phpconfig_add']['title'];
]); $image = $phpconfig_add_data['phpconfig_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview_add") . "\";");
} }
} else { } else {
Response::standardError('nopermissionsorinvalidid'); \Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'delete') { if ($action == 'delete') {
try { try {
$json_result = PhpSettings::getLocal($userinfo, [ $json_result = PhpSettings::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config
{ {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
PhpSettings::getLocal($userinfo, [ PhpSettings::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->delete(); ))->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('phpsetting_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('phpsetting_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['description']); ), $result['description']);
} }
} else { } else {
Response::standardError('nopermissionsorinvalidid'); \Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'edit') { if ($action == 'edit') {
try { try {
$json_result = PhpSettings::getLocal($userinfo, [ $json_result = PhpSettings::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['change_serversettings'] == 1) { if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
PhpSettings::getLocal($userinfo, $_POST)->update(); PhpSettings::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$fpmconfigs = [];
$fpmconfigs = '';
$configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC"); $configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
$fpmconfigs[$row['id']] = $row['description']; $fpmconfigs .= \Froxlor\UI\HTML::makeoption($row['description'], $row['id'], $result['fpmsettingid'], true, true);
} }
$phpconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php'; $pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', $result['pm'], true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', $result['pm'], true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', $result['pm'], true, true);
UI::view('user/form-replacers.html.twig', [ $phpconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php';
'formaction' => $linker->getLink(['section' => 'phpsettings', 'id' => $id]), $phpconfig_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($phpconfig_edit_data);
'formdata' => $phpconfig_edit_data['phpconfig_edit'],
'replacers' => $phpconfig_edit_data['phpconfig_replacers'], $title = $phpconfig_edit_data['phpconfig_edit']['title'];
'editid' => $id $image = $phpconfig_edit_data['phpconfig_edit']['image'];
]);
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview_edit") . "\";");
} }
} else { } else {
Response::standardError('nopermissionsorinvalidid'); \Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
} }
} }
} elseif ($page == 'fpmdaemons') { } elseif ($page == 'fpmdaemons') {
if ($action == '') {
try {
$fpmconf_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.fpmconfigs.php';
$collection = (new Collection(FpmDaemons::class, $userinfo))
->withPagination($fpmconf_list_data['fpmconf_list']['columns'], $fpmconf_list_data['fpmconf_list']['default_sorting']);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
UI::view('user/table.html.twig', [ if ($action == '') {
'listing' => Listing::format($collection, $fpmconf_list_data, 'fpmconf_list'),
'actions_links' => (bool)$userinfo['change_serversettings'] ? [ try {
[ $json_result = FpmDaemons::getLocal($userinfo)->listing();
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']), } catch (Exception $e) {
'label' => lng('admin.fpmsettings.addnew') \Froxlor\UI\Response::dynamic_error($e->getMessage());
] }
] : [] $result = json_decode($json_result, true)['data'];
]);
$tablecontent = '';
$count = 0;
if (isset($result['count']) && $result['count'] > 0) {
foreach ($result['list'] as $row) {
$configs = "";
foreach ($row['configs'] as $configused) {
$configs .= $configused . "<br>";
}
$count ++;
eval("\$tablecontent.=\"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmdaemons_overview") . "\";");
}
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmdaemons") . "\";");
} }
if ($action == 'add') { if ($action == 'add') {
if ((int)$userinfo['change_serversettings'] == 1) {
if ((int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
FpmDaemons::getLocal($userinfo, $_POST)->add(); FpmDaemons::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$fpmconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php';
UI::view('user/form-replacers.html.twig', [ $pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', 'dynamic', true, true);
'formaction' => $linker->getLink(['section' => 'phpsettings', 'page' => 'fpmdaemons']), $pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', 'dynamic', true, true);
'formdata' => $fpmconfig_add_data['fpmconfig_add'], $pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', 'dynamic', true, true);
'replacers' => $fpmconfig_add_data['fpmconfig_replacers']
]); $fpmconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php';
$fpmconfig_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($fpmconfig_add_data);
$title = $fpmconfig_add_data['fpmconfig_add']['title'];
$image = $fpmconfig_add_data['fpmconfig_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmconfig_add") . "\";");
} }
} else { } else {
Response::standardError('nopermissionsorinvalidid'); \Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'delete') { if ($action == 'delete') {
try { try {
$json_result = FpmDaemons::getLocal($userinfo, [ $json_result = FpmDaemons::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($id == 1) { if ($id == 1) {
Response::standardError('cannotdeletedefaultphpconfig'); \Froxlor\UI\Response::standard_error('cannotdeletedefaultphpconfig');
} }
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config
{ {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
FpmDaemons::getLocal($userinfo, $_POST)->delete(); FpmDaemons::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('fpmsetting_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('fpmsetting_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['description']); ), $result['description']);
} }
} else { } else {
Response::standardError('nopermissionsorinvalidid'); \Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'edit') { if ($action == 'edit') {
try { try {
$json_result = FpmDaemons::getLocal($userinfo, [ $json_result = FpmDaemons::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['change_serversettings'] == 1) { if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
FpmDaemons::getLocal($userinfo, $_POST)->update(); FpmDaemons::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$fpmconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php';
UI::view('user/form-replacers.html.twig', [ $pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', $result['pm'], true, true);
'formaction' => $linker->getLink(['section' => 'phpsettings', 'page' => 'fpmdaemons', 'id' => $id]), $pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', $result['pm'], true, true);
'formdata' => $fpmconfig_edit_data['fpmconfig_edit'], $pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', $result['pm'], true, true);
'replacers' => $fpmconfig_edit_data['fpmconfig_replacers'],
'editid' => $id $fpmconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php';
]); $fpmconfig_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($fpmconfig_edit_data);
$title = $fpmconfig_edit_data['fpmconfig_edit']['title'];
$image = $fpmconfig_edit_data['fpmconfig_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmconfig_edit") . "\";");
} }
} else { } else {
Response::standardError('nopermissionsorinvalidid'); \Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
} }
} }
} }

View File

@@ -4,172 +4,182 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
const AREA = 'admin'; require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\HostingPlans; use Froxlor\Api\Commands\HostingPlans;
use Froxlor\Api\Commands\MysqlServer;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == '' || $page == 'overview') { if ($page == '' || $page == 'overview') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
$fields = array(
'p.name' => $lng['admin']['plans']['name'],
'p.description' => $lng['admin']['plans']['description'],
'adminname' => $lng['admin']['admin'],
'p.ts' => $lng['admin']['plans']['last_update']
);
try { try {
$plan_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.plans.php'; // get total count
$collection = (new Collection(HostingPlans::class, $userinfo)) $json_result = HostingPlans::getLocal($userinfo)->listingCount();
->withPagination($plan_list_data['plan_list']['columns'], $plan_list_data['plan_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = HostingPlans::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $plan_list_data, 'plan_list'),
'actions_links' => [
[
'href' => $linker->getLink(['section' => 'plans', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.plans.add')
]
]
]);
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = HostingPlans::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['adminid'] == $result['adminid']) { $plans = '';
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
foreach ($result['list'] as $row) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$row['ts_format'] = date("d.m.Y H:i", $row['ts']);
eval("\$plans.=\"" . \Froxlor\UI\Template::getTemplate("plans/plans_plan") . "\";");
$count ++;
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans") . "\";");
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = HostingPlans::getLocal($userinfo, array(
'id' => $id
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['adminid'] == $result['adminid']) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
HostingPlans::getLocal($userinfo, [ HostingPlans::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->delete(); ))->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('plan_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('plan_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['name']); ), $result['name']);
} }
} else { } else {
Response::standardError('nopermissionsorinvalidid'); \Froxlor\UI\Response::standard_error('nopermissionsorinvalidid');
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
HostingPlans::getLocal($userinfo, $_POST)->add(); HostingPlans::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$mysql_servers = [];
try {
$result_json = MysqlServer::getLocal($userinfo)->listing();
$result_decoded = json_decode($result_json, true)['data']['list'];
foreach ($result_decoded as $dbserver => $dbdata) {
$mysql_servers[] = [
'label' => $dbdata['caption'],
'value' => $dbserver
];
}
} catch (Exception $e) {
/* just none */
}
$phpconfigs = []; $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$phpconfigs = array();
$configs = Database::query(" $configs = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
"); ");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'] . " [" . $row['interpreter'] . "]", 'label' => $row['description'] . " [" . $row['interpreter'] . "]<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} else { } else {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'], 'label' => $row['description'] . "<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} }
} }
// dummy to avoid unknown variables // dummy to avoid unknown variables
$language_options = null;
$gender_options = null;
$hosting_plans = null; $hosting_plans = null;
$plans_add_data = include_once __DIR__ . '/lib/formfields/admin/plans/formfield.plans_add.php'; $plans_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/plans/formfield.plans_add.php';
$cust_add_data = include_once __DIR__ . '/lib/formfields/admin/customer/formfield.customer_add.php'; $cust_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_add.php';
// unset unneeded stuff // unset unneeded stuff
unset($cust_add_data['customer_add']['sections']['section_a']); unset($cust_add_data['customer_add']['sections']['section_a']);
unset($cust_add_data['customer_add']['sections']['section_b']); unset($cust_add_data['customer_add']['sections']['section_b']);
unset($cust_add_data['customer_add']['sections']['section_cpre']); unset($cust_add_data['customer_add']['sections']['section_cpre']);
// merge // merge
$plans_add_data['plans_add']['sections'] = array_merge($plans_add_data['plans_add']['sections'], $cust_add_data['customer_add']['sections']); $plans_add_data['plans_add']['sections'] = array_merge($plans_add_data['plans_add']['sections'], $cust_add_data['customer_add']['sections']);
$plans_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($plans_add_data);
UI::view('user/form.html.twig', [ $title = $plans_add_data['plans_add']['title'];
'formaction' => $linker->getLink(['section' => 'plans']), $image = $plans_add_data['plans_add']['image'];
'formdata' => $plans_add_data['plans_add']
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = HostingPlans::getLocal($userinfo, [ $json_result = HostingPlans::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if ($result['name'] != '') { if ($result['name'] != '') {
$result['value'] = json_decode($result['value'], true); $result['value'] = json_decode($result['value'], true);
$result = PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
foreach ($result['value'] as $index => $value) { foreach ($result['value'] as $index => $value) {
$result[$index] = $value; $result[$index] = $value;
@@ -177,46 +187,80 @@ if ($page == '' || $page == 'overview') {
$result['allowed_phpconfigs'] = json_encode($result['allowed_phpconfigs']); $result['allowed_phpconfigs'] = json_encode($result['allowed_phpconfigs']);
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
HostingPlans::getLocal($userinfo, $_POST)->update(); HostingPlans::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$mysql_servers = [];
try { $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
$result_json = MysqlServer::getLocal($userinfo)->listing(); if ($result['diskspace'] == '-1') {
$result_decoded = json_decode($result_json, true)['data']['list']; $result['diskspace'] = '';
foreach ($result_decoded as $dbserver => $dbdata) {
$mysql_servers[] = [
'label' => $dbdata['caption'],
'value' => $dbserver
];
}
} catch (Exception $e) {
/* just none */
} }
$phpconfigs = []; $traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
if ($result['traffic'] == '-1') {
$result['traffic'] = '';
}
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
if ($result['subdomains'] == '-1') {
$result['subdomains'] = '';
}
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
if ($result['emails'] == '-1') {
$result['emails'] = '';
}
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
if ($result['email_accounts'] == '-1') {
$result['email_accounts'] = '';
}
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
if ($result['email_forwarders'] == '-1') {
$result['email_forwarders'] = '';
}
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
if ($result['email_quota'] == '-1') {
$result['email_quota'] = '';
}
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
if ($result['ftps'] == '-1') {
$result['ftps'] = '';
}
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true);
if ($result['mysqls'] == '-1') {
$result['mysqls'] = '';
}
$phpconfigs = array();
$configs = Database::query(" $configs = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
"); ");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'] . " [" . $row['interpreter'] . "]", 'label' => $row['description'] . " [" . $row['interpreter'] . "]<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} else { } else {
$phpconfigs[] = [ $phpconfigs[] = array(
'label' => $row['description'], 'label' => $row['description'] . "<br />",
'value' => $row['id'] 'value' => $row['id']
]; );
} }
} }
@@ -228,9 +272,9 @@ if ($page == '' || $page == 'overview') {
$result['documentroot'] = null; $result['documentroot'] = null;
$result['standardsubdomain'] = null; $result['standardsubdomain'] = null;
$result['deactivated'] = null; $result['deactivated'] = null;
$result['def_language'] = null; $language_options = null;
$result['firstname'] = null; $result['firstname'] = null;
$result['gender'] = null; $gender_options = null;
$result['company'] = null; $result['company'] = null;
$result['street'] = null; $result['street'] = null;
$result['zipcode'] = null; $result['zipcode'] = null;
@@ -243,33 +287,33 @@ if ($page == '' || $page == 'overview') {
$result['custom_notes_show'] = null; $result['custom_notes_show'] = null;
$result['api_allowed'] = null; $result['api_allowed'] = null;
$hosting_plans = null; $hosting_plans = null;
$admin_select = []; $admin_select_cnt = null;
$admin_select = null;
$plans_edit_data = include_once __DIR__ . '/lib/formfields/admin/plans/formfield.plans_edit.php'; $plans_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/plans/formfield.plans_edit.php';
$cust_edit_data = include_once __DIR__ . '/lib/formfields/admin/customer/formfield.customer_edit.php'; $cust_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_edit.php';
// unset unneeded stuff // unset unneeded stuff
unset($cust_edit_data['customer_edit']['sections']['section_a']); unset($cust_edit_data['customer_edit']['sections']['section_a']);
unset($cust_edit_data['customer_edit']['sections']['section_b']); unset($cust_edit_data['customer_edit']['sections']['section_b']);
unset($cust_edit_data['customer_edit']['sections']['section_cpre']); unset($cust_edit_data['customer_edit']['sections']['section_cpre']);
unset($cust_edit_data['customer_edit']['sections']['section_d']);
// merge // merge
$plans_edit_data['plans_edit']['sections'] = array_merge($plans_edit_data['plans_edit']['sections'], $cust_edit_data['customer_edit']['sections']); $plans_edit_data['plans_edit']['sections'] = array_merge($plans_edit_data['plans_edit']['sections'], $cust_edit_data['customer_edit']['sections']);
$plans_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($plans_edit_data);
UI::view('user/form.html.twig', [ $title = $plans_edit_data['plans_edit']['title'];
'formaction' => $linker->getLink(['section' => 'plans', 'id' => $id]), $image = $plans_edit_data['plans_edit']['image'];
'formdata' => $plans_edit_data['plans_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans_edit") . "\";");
]);
} }
} }
} elseif ($action == 'jqGetPlanValues') { } elseif ($action == 'jqGetPlanValues') {
$planid = (int)Request::any('planid', 0); $planid = isset($_POST['planid']) ? (int) $_POST['planid'] : 0;
try { try {
$json_result = HostingPlans::getLocal($userinfo, [ $json_result = HostingPlans::getLocal($userinfo, array(
'id' => $planid 'id' => $planid
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
echo $result['value']; echo $result['value'];

View File

@@ -2,52 +2,39 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
use Froxlor\Api\Commands\Froxlor;
use Froxlor\Cron\TaskId;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Database\IntegrityCheck;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\System\Cronjob; use Froxlor\Api\Commands\Froxlor;
use Froxlor\UI\Form;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\User;
use PHPMailer\PHPMailer\PHPMailer;
const AREA = 'admin'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php'; require './lib/init.php';
// get sql-root access data
Database::needRoot(true);
Database::needSqlData();
$sql_root = Database::getSqlData();
Database::needRoot(false);
if ($page == 'overview' && $userinfo['change_serversettings'] == '1') { if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$settings_data = PhpHelper::loadConfigArrayDir('./actions/admin/settings/'); $settings_data = \Froxlor\PhpHelper::loadConfigArrayDir('./actions/admin/settings/');
Settings::loadSettingsInto($settings_data); Settings::loadSettingsInto($settings_data);
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$_part = isset($_GET['part']) ? $_GET['part'] : ''; $_part = isset($_GET['part']) ? $_GET['part'] : '';
if ($_part == '') { if ($_part == '') {
$_part = isset($_POST['part']) ? $_POST['part'] : ''; $_part = isset($_POST['part']) ? $_POST['part'] : '';
@@ -70,127 +57,163 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
// check if the session timeout is too low #815 // check if the session timeout is too low #815
if (isset($_POST['session_sessiontimeout']) && $_POST['session_sessiontimeout'] < 60) { if (isset($_POST['session_sessiontimeout']) && $_POST['session_sessiontimeout'] < 60) {
Response::standardError(lng('error.session_timeout'), lng('error.session_timeout_desc')); \Froxlor\UI\Response::standard_error($lng['error']['session_timeout'], $lng['error']['session_timeout_desc']);
} }
try { if (\Froxlor\UI\Form::processFormEx($settings_data, $_POST, array(
if (Form::processForm($settings_data, $_POST, [ 'filename' => $filename,
'action' => $action,
'page' => $page
), $_part, $settings_all, $settings_part, $only_enabledisable)) {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles due to changed setting");
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST);
// Using nameserver, insert a task which rebuilds the server config
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS);
// cron.d file
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_CRON);
\Froxlor\UI\Response::standard_success('settingssaved', '', array(
'filename' => $filename, 'filename' => $filename,
'action' => $action, 'action' => $action,
'page' => $page 'page' => $page
], $_part, $settings_all, $settings_part, $only_enabledisable)) { ));
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles due to changed setting");
Cronjob::inserttask(TaskId::REBUILD_VHOST);
// Using nameserver, insert a task which rebuilds the server config
Cronjob::inserttask(TaskId::REBUILD_DNS);
// cron.d file
Cronjob::inserttask(TaskId::REBUILD_CRON);
Response::standardSuccess('settingssaved', '', [
'filename' => $filename,
'action' => $action,
'page' => $page
]);
}
} catch (Exception $e) {
Response::dynamicError($e->getMessage(), $e->getCode());
} }
} else { } else {
$_part = isset($_GET['part']) ? $_GET['part'] : ''; $_part = isset($_GET['part']) ? $_GET['part'] : '';
if ($_part == '') { if ($_part == '') {
$_part = isset($_POST['part']) ? $_POST['part'] : ''; $_part = isset($_POST['part']) ? $_POST['part'] : '';
} }
$fields = Form::buildForm($settings_data, $_part); $fields = \Froxlor\UI\Form::buildFormEx($settings_data, $_part);
if ($_part == '' || $_part == 'all') { $settings_page = '';
UI::view('settings/index.html.twig', ['fields' => $fields]); if ($_part == '') {
eval("\$settings_page .= \"" . \Froxlor\UI\Template::getTemplate("settings/settings_overview") . "\";");
} else { } else {
$em = Request::any('em', ''); eval("\$settings_page .= \"" . \Froxlor\UI\Template::getTemplate("settings/settings") . "\";");
UI::view('settings/detailpart.html.twig', ['fields' => $fields, 'em' => $em]);
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/settings_form_begin") . "\";");
eval("echo \$settings_page;");
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/settings_form_end") . "\";");
} }
} elseif ($page == 'phpinfo' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'phpinfo' && $userinfo['change_serversettings'] == '1') {
ob_start(); ob_start();
phpinfo(); phpinfo();
$phpinfo = [ $phpinfo = array(
'phpinfo' => [] 'phpinfo' => array()
]; );
if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) { if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) { foreach ($matches as $match) {
$end = array_keys($phpinfo); $end = array_keys($phpinfo);
$end = end($end); $end = end($end);
if (strlen($match[1])) { if (strlen($match[1])) {
$phpinfo[$match[1]] = []; $phpinfo[$match[1]] = array();
} elseif (isset($match[3])) { } elseif (isset($match[3])) {
$phpinfo[$end][$match[2]] = isset($match[4]) ? [ $phpinfo[$end][$match[2]] = isset($match[4]) ? array(
$match[3], $match[3],
$match[4] $match[4]
] : $match[3]; ) : $match[3];
} else { } else {
$phpinfo[$end][] = $match[2]; $phpinfo[$end][] = $match[2];
} }
} }
$phpinfohtml = '';
foreach ($phpinfo as $name => $section) {
$phpinfoentries = "";
foreach ($section as $key => $val) {
if (is_array($val)) {
eval("\$phpinfoentries .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_3") . "\";");
} elseif (is_string($key)) {
eval("\$phpinfoentries .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_2") . "\";");
} else {
eval("\$phpinfoentries .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_1") . "\";");
}
}
// first header -> show actual php version
if (strtolower($name) == "phpinfo") {
$name = "PHP " . PHP_VERSION;
}
eval("\$phpinfohtml .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_table") . "\";");
}
$phpinfo = $phpinfohtml;
} else { } else {
Response::standardError(lng('error.no_phpinfo')); \Froxlor\UI\Response::standard_error($lng['error']['no_phpinfo']);
} }
UI::view('settings/phpinfo.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo") . "\";");
'phpversion' => PHP_VERSION,
'phpinfo' => $phpinfo
]);
} elseif ($page == 'rebuildconfigs' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'rebuildconfigs' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles");
Cronjob::inserttask(TaskId::REBUILD_VHOST);
Cronjob::inserttask(TaskId::CREATE_QUOTA);
// Using nameserver, insert a task which rebuilds the server config
Cronjob::inserttask(TaskId::REBUILD_DNS);
// cron.d file
Cronjob::inserttask(TaskId::REBUILD_CRON);
Response::standardSuccess('rebuildingconfigs', '', [ $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles");
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST);
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::CREATE_QUOTA);
// Using nameserver, insert a task which rebuilds the server config
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS);
// cron.d file
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_CRON);
\Froxlor\UI\Response::standard_success('rebuildingconfigs', '', array(
'filename' => 'admin_index.php' 'filename' => 'admin_index.php'
]); ));
} else { } else {
HTML::askYesNo('admin_configs_reallyrebuild', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_configs_reallyrebuild', $filename, array(
'page' => $page 'page' => $page
]); ));
} }
} elseif ($page == 'updatecounters' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'updatecounters' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "updated resource-counters");
$updatecounters = User::updateCounters(true); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "updated resource-counters");
UI::view('user/resource-counter.html.twig', [ $updatecounters = \Froxlor\User::updateCounters(true);
'counters' => $updatecounters $customers = '';
]); foreach ($updatecounters['customers'] as $customerid => $customer) {
eval("\$customers.=\"" . \Froxlor\UI\Template::getTemplate("settings/updatecounters_row_customer") . "\";");
}
$admins = '';
foreach ($updatecounters['admins'] as $adminid => $admin) {
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("settings/updatecounters_row_admin") . "\";");
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/updatecounters") . "\";");
} else { } else {
HTML::askYesNo('admin_counters_reallyupdate', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_counters_reallyupdate', $filename, array(
'page' => $page 'page' => $page
]); ));
} }
} elseif ($page == 'wipecleartextmailpws' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'wipecleartextmailpws' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords");
Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `password` = '';"); Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `password` = '';");
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '0' WHERE `settinggroup` = 'system' AND `varname` = 'mailpwcleartext'"); Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '0' WHERE `settinggroup` = 'system' AND `varname` = 'mailpwcleartext'");
Response::redirectTo($filename); \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} else { } else {
HTML::askYesNo('admin_cleartextmailpws_reallywipe', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_cleartextmailpws_reallywipe', $filename, array(
'page' => $page 'page' => $page
]); ));
} }
} elseif ($page == 'wipequotas' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'wipequotas' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all mailquotas");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all mailquotas");
// Set the quota to 0 which means unlimited // Set the quota to 0 which means unlimited
Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = '0';"); Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = '0';");
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota_used` = '0'"); Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota_used` = '0'");
Response::redirectTo($filename); \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} else { } else {
HTML::askYesNo('admin_quotas_reallywipe', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_quotas_reallywipe', $filename, array(
'page' => $page 'page' => $page
]); ));
} }
} elseif ($page == 'enforcequotas' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'enforcequotas' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
@@ -198,6 +221,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$result_stmt = Database::query("SELECT `quota`, `customerid` FROM `" . TABLE_MAIL_USERS . "`"); $result_stmt = Database::query("SELECT `quota`, `customerid` FROM `" . TABLE_MAIL_USERS . "`");
if (Database::num_rows() > 0) { if (Database::num_rows() > 0) {
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
`email_quota_used` = `email_quota_used` + :diff `email_quota_used` = `email_quota_used` + :diff
@@ -206,10 +230,10 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
while ($array = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($array = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$difference = Settings::Get('system.mail_quota') - $array['quota']; $difference = Settings::Get('system.mail_quota') - $array['quota'];
Database::pexecute($upd_stmt, [ Database::pexecute($upd_stmt, array(
'diff' => $difference, 'diff' => $difference,
'customerid' => $customerid 'customerid' => $customerid
]); ));
} }
} }
@@ -217,59 +241,43 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = :quota UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = :quota
"); ");
Database::pexecute($upd_stmt, [ Database::pexecute($upd_stmt, array(
'quota' => Settings::Get('system.mail_quota') 'quota' => Settings::Get('system.mail_quota')
]); ));
// Update the Customer, if the used quota is bigger than the allowed quota // Update the Customer, if the used quota is bigger than the allowed quota
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota` = `email_quota_used` WHERE `email_quota` < `email_quota_used`"); Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota` = `email_quota_used` WHERE `email_quota` < `email_quota_used`");
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, 'enforcing mailquota to all customers: ' . Settings::Get('system.mail_quota') . ' MB'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'enforcing mailquota to all customers: ' . Settings::Get('system.mail_quota') . ' MB');
Response::redirectTo($filename); \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} else { } else {
HTML::askYesNo('admin_quotas_reallyenforce', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_quotas_reallyenforce', $filename, array(
'page' => $page 'page' => $page
]); ));
} }
} elseif ($page == 'integritycheck' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'integritycheck' && $userinfo['change_serversettings'] == '1') {
$integrity = new IntegrityCheck(); $integrity = new \Froxlor\Database\IntegrityCheck();
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$integrity->fixAll(); $integrity->fixAll();
} elseif (isset($_GET['action']) && $_GET['action'] == "fix") { } elseif (isset($_GET['action']) && $_GET['action'] == "fix") {
HTML::askYesNo('admin_integritycheck_reallyfix', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_integritycheck_reallyfix', $filename, array(
'page' => $page 'page' => $page
]); ));
} }
$integritycheck = []; $integritycheck = '';
foreach ($integrity->available as $id => $check) { foreach ($integrity->available as $id => $check) {
$integritycheck[] = [ $displayid = $id + 1;
'displayid' => $id + 1, $result = $integrity->$check();
'result' => $integrity->$check(), $checkdesc = $lng['integrity_check'][$check];
'checkdesc' => lng('integrity_check.' . $check) eval("\$integritycheck.=\"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck_row") . "\";");
];
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck") . "\";");
$integrity_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.integrity.php';
$collection = [
'data' => $integritycheck,
'pagination' => []
];
UI::view('user/table.html.twig', [
'listing' => Listing::formatFromArray($collection, $integrity_list_data['integrity_list'], 'integrity_list'),
'actions_links' => [
[
'href' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'fix']),
'label' => lng('admin.integrityfix'),
'icon' => 'fa-solid fa-screwdriver-wrench',
'class' => 'btn-warning'
]
]
]);
} elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1') {
// check for json-stuff // check for json-stuff
if (!extension_loaded('json')) { if (! extension_loaded('json')) {
Response::standardError('jsonextensionnotfound'); \Froxlor\UI\Response::standard_error('jsonextensionnotfound');
} }
if (isset($_GET['action']) && $_GET['action'] == "export") { if (isset($_GET['action']) && $_GET['action'] == "export") {
@@ -278,9 +286,9 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$json_result = Froxlor::getLocal($userinfo)->exportSettings(); $json_result = Froxlor::getLocal($userinfo)->exportSettings();
$json_export = json_decode($json_result, true)['data']; $json_export = json_decode($json_result, true)['data'];
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
header('Content-disposition: attachment; filename=Froxlor_settings-' . \Froxlor\Froxlor::VERSION . '-' . \Froxlor\Froxlor::DBVERSION . '_' . date('d.m.Y') . '.json'); header('Content-disposition: attachment; filename=Froxlor_settings-' . $version . '-' . $dbversion . '_' . date('d.m.Y') . '.json');
header('Content-type: application/json'); header('Content-type: application/json');
echo $json_export; echo $json_export;
exit(); exit();
@@ -291,55 +299,35 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
if (isset($_FILES["import_file"]["tmp_name"])) { if (isset($_FILES["import_file"]["tmp_name"])) {
$imp_content = file_get_contents($_FILES["import_file"]["tmp_name"]); $imp_content = file_get_contents($_FILES["import_file"]["tmp_name"]);
try { try {
Froxlor::getLocal($userinfo, [ Froxlor::getLocal($userinfo, array(
'json_str' => $imp_content 'json_str' => $imp_content
])->importSettings(); ))->importSettings();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::standardSuccess('settingsimported', '', [ \Froxlor\UI\Response::standard_success('settingsimported', '', array(
'filename' => 'admin_settings.php' 'filename' => 'admin_settings.php'
]); ));
} }
Response::dynamicError("Upload failed"); \Froxlor\UI\Response::dynamic_error("Upload failed");
} }
} else { } else {
$settings_data = include_once dirname(__FILE__) . '/lib/formfields/admin/settings/formfield.settings_import.php'; eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/importexport/index") . "\";");
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'import']),
'formdata' => $settings_data['settings_import'],
'actions_links' => [
[
'class' => 'btn-outline-primary',
'href' => $linker->getLink(['section' => 'settings', 'page' => 'overview']),
'label' => lng('admin.configfiles.overview'),
'icon' => 'fa-solid fa-grip'
],
[
'class' => 'btn-outline-secondary',
'href' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'export']),
'label' => 'Download/export ' . lng('admin.serversettings'),
'icon' => 'fa-solid fa-file-import'
]
]
]);
} }
} elseif ($page == 'testmail') { } elseif ($page == 'testmail') {
$note_type = 'info';
$note_msg = lng('admin.smtptestnote');
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$test_addr = isset($_POST['test_addr']) ? $_POST['test_addr'] : null; $test_addr = isset($_POST['test_addr']) ? $_POST['test_addr'] : null;
// Initialize the mailingsystem /**
$testmail = new PHPMailer(true); * Initialize the mailingsystem
*/
$testmail = new \PHPMailer\PHPMailer\PHPMailer(true);
$testmail->CharSet = "UTF-8"; $testmail->CharSet = "UTF-8";
if (Settings::Get('system.mail_use_smtp')) { if (Settings::Get('system.mail_use_smtp')) {
$testmail->isSMTP(); $testmail->isSMTP();
$testmail->Host = Settings::Get('system.mail_smtp_host'); $testmail->Host = Settings::Get('system.mail_smtp_host');
$testmail->SMTPAuth = Settings::Get('system.mail_smtp_auth') == '1'; $testmail->SMTPAuth = Settings::Get('system.mail_smtp_auth') == '1' ? true : false;
$testmail->Username = Settings::Get('system.mail_smtp_user'); $testmail->Username = Settings::Get('system.mail_smtp_user');
$testmail->Password = Settings::Get('system.mail_smtp_passwd'); $testmail->Password = Settings::Get('system.mail_smtp_passwd');
if (Settings::Get('system.mail_smtp_usetls')) { if (Settings::Get('system.mail_smtp_usetls')) {
@@ -351,7 +339,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
} }
$_mailerror = false; $_mailerror = false;
if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) { if (\PHPMailer\PHPMailer\PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
// set return-to address and custom sender-name, see #76 // set return-to address and custom sender-name, see #76
$testmail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname')); $testmail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
if (Settings::Get('panel.adminmail_return') != '') { if (Settings::Get('panel.adminmail_return') != '') {
@@ -366,56 +354,31 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$testmail->AddAddress($test_addr); $testmail->AddAddress($test_addr);
$testmail->Send(); $testmail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) { } catch (\PHPMailer\PHPMailer\Exception $e) {
$note_type = 'danger'; $mailerr_msg = $e->errorMessage();
$note_msg = $e->getMessage();
$_mailerror = true; $_mailerror = true;
} catch (Exception $e) { } catch (Exception $e) {
$note_type = 'danger'; $mailerr_msg = $e->getMessage();
$note_msg = $e->getMessage();
$_mailerror = true; $_mailerror = true;
} }
if (!$_mailerror) { if (! $_mailerror) {
// success // success
$mail->ClearAddresses(); $mail->ClearAddresses();
Response::standardSuccess('testmailsent', '', [ \Froxlor\UI\Response::standard_success('testmailsent', '', array(
'filename' => 'admin_settings.php', 'filename' => 'admin_settings.php',
'page' => 'testmail' 'page' => 'testmail'
]); ));
} }
} else { } else {
// invalid sender e-mail // invalid sender e-mail
$note_type = 'warning'; $mailerr_msg = "Invalid sender e-mail address: " . Settings::Get('panel.adminmail');
$note_msg = "Invalid sender e-mail address: " . Settings::Get('panel.adminmail'); $_mailerror = true;
} }
} }
$mailtest_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/settings/formfield.settings_mailtest.php'; $mail_smtp_user = Settings::Get('system.mail_smtp_user');
$mail_smtp_host = Settings::Get('system.mail_smtp_host');
$mail_smtp_port = Settings::Get('system.mail_smtp_port');
UI::view('user/form-note.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/testmail") . "\";");
'formaction' => $linker->getLink(['section' => 'settings']),
'formdata' => $mailtest_add_data['mailtest'],
'actions_links' => [
[
'href' => $linker->getLink([
'section' => 'settings',
'page' => 'overview',
'part' => 'system',
'em' => 'system_mail_use_smtp'
]),
'label' => lng('admin.smtpsettings'),
'icon' => 'fa-solid fa-gears',
'class' => 'btn-outline-secondary'
]
],
// alert-box
'type' => $note_type,
'alert_msg' => $note_msg
]);
} elseif ($page == 'toggleSettingsMode') {
if ($userinfo['change_serversettings'] == '1') {
$cmode = Settings::Get('panel.settings_mode');
Settings::Set('panel.settings_mode', (int)(!(bool)$cmode));
}
Response::redirectTo($filename);
} }

View File

@@ -2,192 +2,139 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
const AREA = 'admin'; require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\Language;
use Froxlor\PhpHelper;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\Validate\Validate;
use Froxlor\CurrentUser;
$id = (int)Request::any('id'); if (isset($_POST['subjectid'])) {
$subjectid = intval(Request::any('subjectid')); $subjectid = intval($_POST['subjectid']);
$mailbodyid = intval(Request::any('mailbodyid')); $mailbodyid = intval($_POST['mailbodyid']);
} elseif (isset($_GET['subjectid'])) {
$subjectid = intval($_GET['subjectid']);
$mailbodyid = intval($_GET['mailbodyid']);
}
$available_templates = [ if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$available_templates = array(
'createcustomer', 'createcustomer',
'pop_success', 'pop_success',
'new_database_by_customer', 'new_database_by_customer',
'new_ftpaccount_by_customer', 'new_ftpaccount_by_customer',
'password_reset' 'password_reset'
]; );
// only show templates of features that are enabled #1191 // only show templates of features that are enabled #1191
if ((int)Settings::Get('system.report_enable') == 1) { if ((int) Settings::Get('system.report_enable') == 1) {
array_push($available_templates, 'trafficmaxpercent', 'diskmaxpercent'); array_push($available_templates, 'trafficmaxpercent', 'diskmaxpercent');
} }
if (Settings::Get('panel.sendalternativemail') == 1) {
array_push($available_templates, 'pop_success_alternative');
}
$file_templates = [ $file_templates = array(
'index_html' 'index_html'
]; );
$languages = Language::getLanguages();
if ($action == '') { if ($action == '') {
// email templates // email templates
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_templates"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_templates");
$templates_array = []; if (Settings::Get('panel.sendalternativemail') == 1) {
$available_templates[] = 'pop_success_alternative';
}
$templates_array = array();
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='mails' WHERE `adminid` = :adminid AND `templategroup`='mails'
ORDER BY `language`, `varname` ORDER BY `language`, `varname`");
"); Database::pexecute($result_stmt, array(
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'] 'adminid' => $userinfo['adminid']
]); ));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$parts = []; $parts = array();
preg_match('/^([a-z]([a-z_]+[a-z])*)_(mailbody|subject)$/', $row['varname'], $parts); preg_match('/^([a-z]([a-z_]+[a-z])*)_(mailbody|subject)$/', $row['varname'], $parts);
$templates_array[$row['language']][$parts[1]][$parts[3]] = $row['id']; $templates_array[$row['language']][$parts[1]][$parts[3]] = $row['id'];
} }
$templates = []; $templates = '';
foreach ($templates_array as $language => $template_defs) { foreach ($templates_array as $language => $template_defs) {
foreach ($template_defs as $action => $email) { foreach ($template_defs as $action => $email) {
$templates[] = [ $subjectid = $email['subject'];
'subjectid' => $email['subject'], $mailbodyid = $email['mailbody'];
'mailbodyid' => $email['mailbody'], $template = $lng['admin']['templates'][$action];
'template' => lng('admin.templates.' . $action), eval("\$templates.=\"" . \Froxlor\UI\Template::getTemplate("templates/templates_template") . "\";");
'language' => $language
];
} }
} }
$mail_actions_links = false; $add = false;
foreach ($languages as $language_file => $language_name) { foreach ($languages as $language_file => $language_name) {
$templates_done = [];
$templates_done = array();
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language`= :lang WHERE `adminid` = :adminid AND `language`= :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject' AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'");
"); Database::pexecute($result_stmt, array(
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'lang' => $language_name 'lang' => $language_name
]); ));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templates_done[] = str_replace('_subject', '', $row['varname']); $templates_done[] = str_replace('_subject', '', $row['varname']);
} }
if (count(array_diff($available_templates, $templates_done)) > 0) { if (count(array_diff($available_templates, $templates_done)) > 0) {
$mail_actions_links = [ $add = true;
[
'href' => $linker->getLink(['section' => 'templates', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.templates.template_add')
]
];
} }
} }
$mailtpl_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.mailtemplates.php';
$collection_mail = [
'data' => $templates,
'pagination' => []
];
// filetemplates // filetemplates
$filetemplates = '';
$filetemplateadd = false;
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='files'"); WHERE `adminid` = :adminid AND `templategroup`='files'");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'] 'adminid' => $userinfo['adminid']
]); ));
$filetemplates = [];
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$filetemplates[] = [
'id' => $row['id'],
'template' => lng('admin.templates.' . $row['varname'])
];
}
$file_actions_links = false;
if (Database::num_rows() != count($file_templates)) { if (Database::num_rows() != count($file_templates)) {
$file_actions_links = [ $filetemplateadd = true;
[
'href' => $linker->getLink([
'section' => 'templates',
'page' => $page,
'action' => 'add',
'files' => 'files'
]),
'label' => lng('admin.templates.template_fileadd')
]
];
} }
$filetpl_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.filetemplates.php'; while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$collection_file = [ eval("\$filetemplates.=\"" . \Froxlor\UI\Template::getTemplate("templates/templates_filetemplate") . "\";");
'data' => $filetemplates,
'pagination' => []
];
if ($mail_actions_links === false) {
$mail_actions_links = [];
} }
if ($file_actions_links === false) { eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates") . "\";");
$file_actions_links = [];
}
UI::view('user/table-tpl.html.twig', [
'maillisting' => Listing::formatFromArray($collection_mail, $mailtpl_list_data['mailtpl_list'], 'mailtpl_list'),
'filelisting' => Listing::formatFromArray($collection_file, $filetpl_list_data['filetpl_list'], 'filetpl_list'),
'actions_links' => array_merge($mail_actions_links, $file_actions_links)
]);
} elseif ($action == 'delete' && $subjectid != 0 && $mailbodyid != 0) { } elseif ($action == 'delete' && $subjectid != 0 && $mailbodyid != 0) {
// email templates // email templates
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $subjectid 'id' => $subjectid
]); ));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if ($result['varname'] != '') { if ($result['varname'] != '') {
@@ -196,22 +143,23 @@ if ($action == '') {
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "` DELETE FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid WHERE `adminid` = :adminid
AND (`id` = :ida OR `id` = :idb)"); AND (`id` = :ida OR `id` = :idb)");
Database::pexecute($del_stmt, [ Database::pexecute($del_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'ida' => $subjectid, 'ida' => $subjectid,
'idb' => $mailbodyid 'idb' => $mailbodyid
]); ));
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . $result['language'] . ' - ' . lng('admin.templates.' . str_replace('_subject', '', $result['varname'])) . "'"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])] . "'");
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('admin_template_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_template_reallydelete', $filename, array(
'subjectid' => $subjectid, 'subjectid' => $subjectid,
'mailbodyid' => $mailbodyid, 'mailbodyid' => $mailbodyid,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['language'] . ' - ' . lng('admin.templates.' . str_replace('_subject', '', $result['varname']))); ), $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])]);
} }
} }
} elseif ($action == 'deletef' && $id != 0) { } elseif ($action == 'deletef' && $id != 0) {
@@ -219,101 +167,94 @@ if ($action == '') {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $id 'id' => $id
]); ));
if (Database::num_rows() > 0) { if (Database::num_rows() > 0) {
$row = $result_stmt->fetch(PDO::FETCH_ASSOC); $row = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$del_stmt = Database::prepare(" $del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "` DELETE FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($del_stmt, [ Database::pexecute($del_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $id 'id' => $id
]); ));
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . lng('admin.templates.' . $row['varname']) . "'"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . $lng['admin']['templates'][$row['varname']] . "'");
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('admin_template_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('admin_template_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], lng('admin.templates.' . $row['varname'])); ), $lng['admin']['templates'][$row['varname']]);
} }
} else { } else {
Response::standardError('templatenotfound'); \Froxlor\UI\Response::standard_error('templatenotfound');
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (Settings::Get('panel.sendalternativemail') == 1) {
$available_templates[] = 'pop_success_alternative';
}
if (isset($_POST['prepare']) && $_POST['prepare'] == 'prepare') { if (isset($_POST['prepare']) && $_POST['prepare'] == 'prepare') {
// email templates // email templates
$language = htmlentities(Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); $language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect'));
if (!array_key_exists($language, $languages)) { $template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template');
Response::standardError('templatelanguageinvalid');
}
$template = Validate::validate($_POST['template'], 'template');
$result_stmt = Database::prepare(" $lng_bak = $lng;
SELECT COUNT(*) as def FROM `" . TABLE_PANEL_TEMPLATES . "` foreach ($langs['English'] as $key => $value) {
WHERE `adminid` = :adminid AND `language` = :lang include_once \Froxlor\FileDir::makeSecurePath($value['file']);
AND `templategroup` = 'mails' AND `varname` LIKE :template }
"); if ($language != 'English') {
$result = Database::pexecute_first($result_stmt, [ foreach ($langs[$language] as $key => $value) {
'adminid' => $userinfo['adminid'], include \Froxlor\FileDir::makeSecurePath($value['file']);
'lang' => $language, }
'template' => $template . '%'
]);
if ($result && $result['def'] > 0) {
Response::standardError('templatelanguagecombodefined');
} }
// set target language $subject = $lng['mails'][$template]['subject'];
Language::setLanguage($language); $body = str_replace('\n', "\n", $lng['mails'][$template]['mailbody']);
$subject = lng('mails.' . $template . '.subject'); $lng = $lng_bak;
$body = str_replace('\n', "\n", lng('mails.' . $template . '.mailbody'));
// re set language to user
Language::setLanguage(CurrentUser::getField('def_language'));
$template_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.template_add.php'; $template_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.template_add.php';
$template_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($template_add_data);
UI::view('user/form-replacers.html.twig', [ $title = $template_add_data['template_add']['title'];
'formaction' => $linker->getLink(['section' => 'templates']), $image = $template_add_data['template_add']['image'];
'formdata' => $template_add_data['template_add'],
'replacers' => $template_add_data['template_replacers'] eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates_add_2") . "\";");
]); } elseif (isset($_POST['send']) && $_POST['send'] == 'send') {
} elseif (isset($_POST['send']) && $_POST['send'] == 'send' && !isset($_POST['filesend'])) {
// email templates // email templates
$language = htmlentities(Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); $language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect'));
if (!array_key_exists($language, $languages)) { $template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template');
Response::standardError('templatelanguageinvalid'); $subject = \Froxlor\Validate\Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
} $mailbody = \Froxlor\Validate\Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$template = Validate::validate($_POST['template'], 'template'); $templates = array();
$subject = Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
$mailbody = Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$templates = [];
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language` = :lang WHERE `adminid` = :adminid AND `language` = :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"); AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'lang' => $language 'lang' => $language
]); ));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templates[] = str_replace('_subject', '', $row['varname']); $templates[] = str_replace('_subject', '', $row['varname']);
} }
$templates = array_diff($available_templates, $templates); $templates = array_diff($available_templates, $templates);
if (!in_array($template, $templates)) { if (array_search($template, $templates) === false) {
Response::standardError('templatenotfound'); \Froxlor\UI\Response::standard_error('templatenotfound');
} else { } else {
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET
@@ -324,32 +265,33 @@ if ($action == '') {
`value` = :value"); `value` = :value");
// mail-subject // mail-subject
$ins_data = [ $ins_data = array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'lang' => $language, 'lang' => $language,
'var' => $template . '_subject', 'var' => $template . '_subject',
'value' => $subject 'value' => $subject
]; );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
// mail-body // mail-body
$ins_data = [ $ins_data = array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'lang' => $language, 'lang' => $language,
'var' => $template . '_mailbody', 'var' => $template . '_mailbody',
'value' => $mailbody 'value' => $mailbody
]; );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $language . ' - ' . $template . "'"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $language . ' - ' . $template . "'");
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} }
} elseif (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') { } elseif (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') {
// file templates // file templates
$template = Validate::validate($_POST['template'], 'template'); $template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template');
$filecontent = Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); $filecontent = \Froxlor\Validate\Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET
@@ -359,33 +301,35 @@ if ($action == '') {
`varname` = :var, `varname` = :var,
`value` = :value"); `value` = :value");
$ins_data = [ $ins_data = array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'var' => $template, 'var' => $template,
'value' => $filecontent 'value' => $filecontent
]; );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $template . "'"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $template . "'");
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
} elseif (!isset($_GET['files'])) { ));
} elseif (! isset($_GET['files'])) {
// email templates // email templates
$add = false; $add = false;
$language_options = []; $language_options = '';
$template_options = []; $template_options = '';
foreach ($languages as $language_file => $language_name) { foreach ($languages as $language_file => $language_name) {
$templates = []; $templates = array();
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language` = :lang WHERE `adminid` = :adminid AND `language` = :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"); AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'lang' => $language_name 'lang' => $language_name
]); ));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templates[] = str_replace('_subject', '', $row['varname']); $templates[] = str_replace('_subject', '', $row['varname']);
@@ -393,81 +337,52 @@ if ($action == '') {
if (count(array_diff($available_templates, $templates)) > 0) { if (count(array_diff($available_templates, $templates)) > 0) {
$add = true; $add = true;
$language_options[$language_file] = $language_name; $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $userinfo['language'], true, true);
$templates = array_diff($available_templates, $templates); $templates = array_diff($available_templates, $templates);
foreach ($templates as $template) { foreach ($templates as $template) {
$template_options[$template] = lng('admin.templates.' . $template); $template_options .= \Froxlor\UI\HTML::makeoption($lng['admin']['templates'][$template], $template, NULL, true, true, $language_file) . "\n";
} }
} }
} }
if ($add) { if ($add) {
UI::view('user/form.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates_add_1") . "\";");
'formaction' => $linker->getLink(['section' => 'templates']),
'formdata' => [
'title' => lng('admin.templates.template_add'),
'image' => 'fa-solid fa-plus',
'self_overview' => ['section' => 'templates', 'page' => 'email'],
'sections' => [
'section_a' => [
'title' => lng('admin.templates.template_add'),
'fields' => [
'language' => [
'label' => lng('login.language'),
'type' => 'select',
'select_var' => $language_options,
'selected' => $userinfo['language']
],
'template' => [
'label' => lng('admin.templates.action'),
'type' => 'select',
'select_var' => $template_options
],
'prepare' => [
'type' => 'hidden',
'value' => 'prepare'
]
]
]
]
],
'editid' => $id
]);
} else { } else {
Response::standardError('alltemplatesdefined'); \Froxlor\UI\Response::standard_error('alltemplatesdefined');
} }
} else { } else {
// filetemplates // filetemplates
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='files'"); WHERE `adminid` = :adminid AND `templategroup`='files'");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'] 'adminid' => $userinfo['adminid']
]); ));
if (Database::num_rows() == count($file_templates)) { if (Database::num_rows() == count($file_templates)) {
Response::standardError('alltemplatesdefined'); \Froxlor\UI\Response::standard_error('alltemplatesdefined');
} else { } else {
$templatesdefined = [];
$free_templates = []; $templatesdefined = array();
$free_templates = '';
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templatesdefined[] = $row['varname']; $templatesdefined[] = $row['varname'];
} }
foreach (array_diff($file_templates, $templatesdefined) as $template) { foreach (array_diff($file_templates, $templatesdefined) as $template) {
$free_templates[$template] = lng('admin.templates.' . $template); $free_templates .= \Froxlor\UI\HTML::makeoption($lng['admin']['templates'][$template], $template, '', true);
} }
$filetemplate_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.filetemplate_add.php'; $filetemplate_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.filetemplate_add.php';
$filetemplate_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($filetemplate_add_data);
UI::view('user/form-replacers.html.twig', [ $title = $filetemplate_add_data['filetemplate_add']['title'];
'formaction' => $linker->getLink(['section' => 'templates']), $image = $filetemplate_add_data['filetemplate_add']['image'];
'formdata' => $filetemplate_add_data['filetemplate_add'],
'replacers' => $filetemplate_add_data['filetemplate_replacers'] eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/filetemplates_add") . "\";");
]);
} }
} }
} elseif ($action == 'edit' && $subjectid != 0 && $mailbodyid != 0) { } elseif ($action == 'edit' && $subjectid != 0 && $mailbodyid != 0) {
@@ -475,65 +390,68 @@ if ($action == '') {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :subjectid"); WHERE `adminid` = :adminid AND `id` = :subjectid");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'subjectid' => $subjectid 'subjectid' => $subjectid
]); ));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if ($result['varname'] != '') { if ($result['varname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$subject = Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate'); $subject = \Froxlor\Validate\Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
$mailbody = Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate'); $mailbody = \Froxlor\Validate\Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET
`value` = :value `value` = :value
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id");
// subject // subject
Database::pexecute($upd_stmt, [ Database::pexecute($upd_stmt, array(
'value' => $subject, 'value' => $subject,
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $subjectid 'id' => $subjectid
]); ));
// same query but mailbody // same query but mailbody
Database::pexecute($upd_stmt, [ Database::pexecute($upd_stmt, array(
'value' => $mailbody, 'value' => $mailbody,
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $mailbodyid 'id' => $mailbodyid
]); ));
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $result['varname'] . "'"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $result['varname'] . "'");
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$result = PhpHelper::htmlentitiesArray($result);
$template_name = lng('admin.templates.' . str_replace('_subject', '', $result['varname'])); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$template = $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])];
$subject = $result['value']; $subject = $result['value'];
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `language`, `varname`, `value` SELECT `language`, `varname`, `value`
FROM `" . TABLE_PANEL_TEMPLATES . "` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `id` = :id"); WHERE `id` = :id");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'id' => $mailbodyid 'id' => $mailbodyid
]); ));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$template = str_replace('_mailbody', '', $result['varname']); $template_name = str_replace('_mailbody', '', $result['varname']);
// don't escape the already escaped language-string so save up before htmlentities() // don't escape the already escaped language-string so save up before htmlentities()
$language = $result['language']; $language = $result['language'];
$result = PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$mailbody = $result['value']; $mailbody = $result['value'];
$template_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.template_edit.php'; $template_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.template_edit.php';
$template_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($template_edit_data);
UI::view('user/form-replacers.html.twig', [ $title = $template_edit_data['template_edit']['title'];
'formaction' => $linker->getLink(['section' => 'templates']), $image = $template_edit_data['template_edit']['image'];
'formdata' => $template_edit_data['template_edit'],
'replacers' => $template_edit_data['template_replacers'] eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates_edit") . "\";");
]);
} }
} }
} elseif ($action == 'editf' && $id != 0) { } elseif ($action == 'editf' && $id != 0) {
@@ -541,44 +459,45 @@ if ($action == '') {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $id 'id' => $id
]); ));
if (Database::num_rows() > 0) { if (Database::num_rows() > 0) {
$row = $result_stmt->fetch(PDO::FETCH_ASSOC); $row = $result_stmt->fetch(PDO::FETCH_ASSOC);
// filetemplates // filetemplates
if (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') { if (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') {
$filecontent = Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); $filecontent = \Froxlor\Validate\Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET
`value` = :value `value` = :value
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($upd_stmt, [ Database::pexecute($upd_stmt, array(
'value' => $filecontent, 'value' => $filecontent,
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $id 'id' => $id
]); ));
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $row['varname'] . "'"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $row['varname'] . "'");
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$row = PhpHelper::htmlentitiesArray($row); $row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$filetemplate_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.filetemplate_edit.php'; $filetemplate_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.filetemplate_edit.php';
$filetemplate_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($filetemplate_edit_data);
UI::view('user/form-replacers.html.twig', [ $title = $filetemplate_edit_data['filetemplate_edit']['title'];
'formaction' => $linker->getLink(['section' => 'templates']), $image = $filetemplate_edit_data['filetemplate_edit']['image'];
'formdata' => $filetemplate_edit_data['filetemplate_edit'],
'replacers' => $filetemplate_edit_data['filetemplate_replacers'], eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/filetemplates_edit") . "\";");
'editid' => $id
]);
} }
} else { } else {
Response::standardError('templatenotfound'); \Froxlor\UI\Response::standard_error('templatenotfound');
} }
} }

View File

@@ -2,47 +2,142 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Morton Jonuschat <m.jonuschat@chrome-it.de>
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.syscp.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin'; use Froxlor\Database\Database;
require __DIR__ . '/lib/init.php'; use Froxlor\Settings;
use Froxlor\Traffic\Traffic; if (isset($_POST['id'])) {
use Froxlor\UI\Panel\UI; $id = intval($_POST['id']);
use Froxlor\UI\Request; } elseif (isset($_GET['id'])) {
use Froxlor\UI\Response; $id = intval($_GET['id']);
}
$range = Request::any('range', 'currentmonth'); $months = array(
'0' => 'empty',
'1' => 'jan',
'2' => 'feb',
'3' => 'mar',
'4' => 'apr',
'5' => 'may',
'6' => 'jun',
'7' => 'jul',
'8' => 'aug',
'9' => 'sep',
'10' => 'oct',
'11' => 'nov',
'12' => 'dec'
);
if ($page == 'overview' || $page == 'customers') { if ($page == 'overview' || $page == 'customers') {
try {
$context = Traffic::getCustomerStats($userinfo, $range); $customerview = 1;
} catch (Exception $e) { $stats_tables = '';
if ($e->getCode() === 405) { $minyear_stmt = Database::query("SELECT `year` FROM `" . TABLE_PANEL_TRAFFIC . "` ORDER BY `year` ASC LIMIT 1");
Response::dynamicError(lng('traffic.nocustomers')); $minyear = $minyear_stmt->fetch(PDO::FETCH_ASSOC);
}
Response::dynamicError($e->getMessage()); if (! isset($minyear['year']) || $minyear['year'] == 0) {
$maxyears = 0;
} else {
$maxyears = date("Y") - $minyear['year'];
} }
// pass metrics to the view $params = [];
UI::view('user/traffic.html.twig', $context); if ($userinfo['customers_see_all'] == '0') {
$params = [
'id' => $userinfo['adminid']
];
}
$customer_name_list_stmt = Database::prepare("
SELECT `customerid`,`company`,`name`,`firstname`
FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `deactivated`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :id") . "
ORDER BY name"
);
$traffic_list_stmt = Database::prepare("
SELECT month, SUM(http+ftp_up+ftp_down+mail)*1024 AS traffic
FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE year = :year AND `customerid` = :id
GROUP BY month ORDER BY month"
);
for ($years = 0; $years <= $maxyears; $years ++) {
$overview['year'] = date("Y") - $years;
$overview['type'] = $lng['traffic']['customer'];
$domain_list = '';
$totals = array(
'jan' => 0,
'feb' => 0,
'mar' => 0,
'apr' => 0,
'may' => 0,
'jun' => 0,
'jul' => 0,
'aug' => 0,
'sep' => 0,
'oct' => 0,
'nov' => 0,
'dec' => 0
);
Database::pexecute($customer_name_list_stmt, $params);
while ($customer_name = $customer_name_list_stmt->fetch(PDO::FETCH_ASSOC)) {
$virtual_host = array(
'name' => ($customer_name['company'] == '' ? $customer_name['name'] . ", " . $customer_name['firstname'] : $customer_name['company']),
'customerid' => $customer_name['customerid'],
'jan' => '-',
'feb' => '-',
'mar' => '-',
'apr' => '-',
'may' => '-',
'jun' => '-',
'jul' => '-',
'aug' => '-',
'sep' => '-',
'oct' => '-',
'nov' => '-',
'dec' => '-'
);
Database::pexecute($traffic_list_stmt, array(
'year' => (date("Y") - $years),
'id' => $customer_name['customerid']
));
while ($traffic_month = $traffic_list_stmt->fetch(PDO::FETCH_ASSOC)) {
$virtual_host[$months[(int) $traffic_month['month']]] = \Froxlor\PhpHelper::sizeReadable($traffic_month['traffic'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
$totals[$months[(int) $traffic_month['month']]] += $traffic_month['traffic'];
}
eval("\$domain_list .= sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table_row") . "\");");
}
// sum up totals
$virtual_host = array(
'name' => $lng['traffic']['months']['total']
);
foreach ($totals as $month => $bytes) {
$virtual_host[$month] = ($bytes == 0 ? '-' : \Froxlor\PhpHelper::sizeReadable($bytes, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'));
}
$customerview = 0;
eval("\$total_list = sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table_row") . "\");");
eval("\$stats_tables .= sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table") . "\");");
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("traffic/index") . "\";");
} }

View File

@@ -4,113 +4,109 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2010-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin'; use Froxlor\Database\Database;
require __DIR__ . '/lib/init.php';
use Froxlor\Cron\TaskId;
use Froxlor\Froxlor;
use Froxlor\FroxlorLogger;
use Froxlor\Install\Preconfig;
use Froxlor\Install\Update;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\System\Cronjob;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
use Froxlor\User;
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_updates"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_updates");
if (!Froxlor::isFroxlor()) { /**
throw new Exception('SysCP/customized upgrades are not supported'); * this is a dirty hack but syscp 1.4.2.1 does not
* have any version/dbversion in the database (don't know why)
* so we have to set them both to run a correct upgrade
*/
if (! \Froxlor\Froxlor::isFroxlor()) {
if (Settings::Get('panel.version') == null || Settings::Get('panel.version') == '') {
Settings::Set('panel.version', '1.4.2.1');
}
if (Settings::Get('system.dbversion') == null || Settings::Get('system.dbversion') == '') {
/**
* for syscp-stable (1.4.2.1) this value has to be 0
* so the required table-fields are added correctly
* and the svn-version has its value in the database
* -> bug #54
*/
$result_stmt = Database::query("
SELECT `value` FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `varname` = 'dbversion'");
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['value'])) {
Settings::Set('system.dbversion', (int) $result['value'], false);
} else {
Settings::Set('system.dbversion', 0, false);
}
}
} }
if (Froxlor::hasDbUpdates() || Froxlor::hasUpdates()) { if (\Froxlor\Froxlor::hasDbUpdates() || \Froxlor\Froxlor::hasUpdates()) {
$successful_update = false; $successful_update = false;
$message = ''; $message = '';
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
if ((isset($_POST['update_preconfig']) && isset($_POST['update_changesagreed']) && intval($_POST['update_changesagreed']) != 0) || !isset($_POST['update_preconfig'])) { if ((isset($_POST['update_preconfig']) && isset($_POST['update_changesagreed']) && intval($_POST['update_changesagreed']) != 0) || ! isset($_POST['update_preconfig'])) {
include_once Froxlor::getInstallDir() . 'install/updatesql.php'; eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/update_start') . "\";");
User::updateCounters(); include_once \Froxlor\Froxlor::getInstallDir() . 'install/updatesql.php';
Cronjob::inserttask(TaskId::REBUILD_VHOST);
@chmod(Froxlor::getInstallDir() . '/lib/userdata.inc.php', 0400);
UI::view('install/update.html.twig', [ $redirect_url = 'admin_index.php?s=' . $s;
'checks' => Update::getUpdateTasks() eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/update_end') . "\";");
]);
exit; \Froxlor\User::updateCounters();
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST);
@chmod(\Froxlor\Froxlor::getInstallDir() . '/lib/userdata.inc.php', 0440);
$successful_update = true;
} else { } else {
$message = '<br><br><strong>You have to agree that you have read the update notifications.</strong>'; $message = '<br /><strong class="red">You have to agree that you have read the update notifications.</strong>';
} }
} }
$current_version = Settings::Get('panel.version'); if (! $successful_update) {
$current_db_version = Settings::Get('panel.db_version'); $current_version = Settings::Get('panel.version');
if (empty($current_db_version)) { $current_db_version = Settings::Get('panel.db_version');
$current_db_version = "0"; if (empty($current_db_version)) {
$current_db_version = "0";
}
$new_version = $version;
$new_db_version = $dbversion;
$ui_text = $lng['update']['update_information']['part_a'];
if ($version != $current_version) {
$ui_text = str_replace('%curversion', $current_version, $ui_text);
$ui_text = str_replace('%newversion', $new_version, $ui_text);
} else {
// show db version
$ui_text = str_replace('%curversion', $current_db_version, $ui_text);
$ui_text = str_replace('%newversion', $new_db_version, $ui_text);
}
$update_information = $ui_text;
include_once \Froxlor\Froxlor::getInstallDir() . '/install/updates/preconfig.php';
$preconfig = getPreConfig($current_version, $current_db_version);
if ($preconfig != '') {
$update_information .= '<br />' . $preconfig . $message;
}
$update_information .= $lng['update']['update_information']['part_b'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/index') . "\";");
} }
$new_version = Froxlor::VERSION;
$new_db_version = Froxlor::DBVERSION;
if (Froxlor::VERSION != $current_version) {
$replacer_currentversion = $current_version;
$replacer_newversion = $new_version;
} else {
// show db version
$replacer_currentversion = $current_db_version;
$replacer_newversion = $new_db_version;
}
$ui_text = lng('update.update_information.part_a', [$replacer_newversion, $replacer_currentversion]);
$ui_text .= lng('update.update_information.part_b');
$upd_formfield = [
'updates' => [
'title' => lng('update.update'),
'image' => 'fa-solid fa-download',
'description' => lng('update.description'),
'sections' => [],
'buttons' => [
[
'label' => lng('update.proceed')
]
]
]
];
$preconfig = Preconfig::getPreConfig();
if (!empty($preconfig)) {
$upd_formfield['updates']['sections'] = $preconfig;
}
UI::view('user/form-note.html.twig', [
'formaction' => $linker->getLink(['section' => 'updates']),
'formdata' => $upd_formfield['updates'],
// alert
'type' => !empty($message) ? 'danger' : 'info',
'alert_msg' => $ui_text . $message
]);
} else { } else {
Response::standardSuccess('update.noupdatesavail', Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : ''); $success_message = $lng['update']['noupdatesavail'];
$redirect_url = 'admin_index.php?s=' . $s;
eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/noupdatesavail') . "\";");
} }
} }

120
api.php
View File

@@ -1,44 +1,88 @@
<?php <?php
use voku\helper\AntiXSS;
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
use Froxlor\Api\Api;
use Froxlor\Api\Response;
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/lib/functions.php';
require __DIR__ . '/lib/tables.inc.php';
// set error-handler require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php';
@set_error_handler([
'\\Froxlor\\Api\\Api',
'phpErrHandler'
]);
// Return response // check whether API interface is enabled after all
try { if (\Froxlor\Settings::Get('api.enabled') != 1) {
echo (new Api)->formatMiddleware(@file_get_contents('php://input'))->handle(); // not enabled
} catch (Exception $e) { header("Status: 404 Not found", 404);
echo Response::jsonErrorResponse($e->getMessage(), $e->getCode()); header($_SERVER["SERVER_PROTOCOL"] . " 404 Not found", 404);
exit();
}
// we're talking json here
header("Content-Type:application/json");
// get our request
$request = @file_get_contents('php://input');
// check if present
if (empty($request)) {
json_response(400, "Invalid request");
}
// decode json request
$decoded_request = json_decode($request, true);
// is it valid?
if (is_null($decoded_request)) {
json_response(400, "Invalid JSON");
}
/**
* check for xss attempts and clean request
*/
$antiXss = new AntiXSS();
$request = $antiXss->xss_clean($request);
// validate content
try {
$decoded_request = stripcslashes_deep($decoded_request);
$request = \Froxlor\Api\FroxlorRPC::validateRequest($decoded_request);
// now actually do it
$cls = "\\Froxlor\\Api\\Commands\\" . $request['command']['class'];
$method = $request['command']['method'];
$apiObj = new $cls($decoded_request['header'], $request['params']);
// call the method with the params if any
echo $apiObj->$method();
} catch (Exception $e) {
json_response($e->getCode(), $e->getMessage());
}
exit();
/**
* output json result
*
* @param int $status
* @param string $status_message
* @param mixed $data
*
* @return void
*/
function json_response($status, $status_message = '', $data = null)
{
if (isset($_SERVER["SERVER_PROTOCOL"]) && ! empty($_SERVER["SERVER_PROTOCOL"])) {
$resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status;
if (! empty($status_message)) {
$resheader .= ' ' . str_replace("\n", " ", $status_message);
}
header($resheader);
}
$response = array();
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
echo $json_response;
exit();
}
function stripcslashes_deep($value)
{
return is_array($value) ? array_map('stripcslashes_deep', $value) : stripcslashes($value);
} }

View File

@@ -1,186 +1,243 @@
<?php <?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
if (!defined('AREA')) { if (!defined('AREA')) {
header("Location: index.php"); header("Location: index.php");
exit(); exit();
} }
use Froxlor\Database\Database; /**
use Froxlor\FroxlorLogger; * This file is part of the Froxlor project.
use Froxlor\UI\HTML; * Copyright (c) 2018 the Froxlor Team (see authors).
use Froxlor\UI\Listing; *
use Froxlor\UI\Panel\UI; * For the full copyright and license information, please view the COPYING
use Froxlor\UI\Request; * file that was distributed with this source code. You can also view the
use Froxlor\UI\Response; * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2018-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* @since 0.10.0
*
*/
// redirect if this customer has no permission for API usage use Froxlor\Database\Database;
if ($userinfo['adminsession'] == 0 && $userinfo['api_allowed'] == 0) {
Response::redirectTo('customer_index.php');
}
// redirect if this admin has no permission for API usage
if ($userinfo['adminsession'] == 1 && $userinfo['api_allowed'] == 0) {
Response::redirectTo('admin_index.php');
}
// This file is being included in admin_index and customer_index // This file is being included in admin_index and customer_index
// and therefore does not need to require lib/init.php // and therefore does not need to require lib/init.php
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = :id"); $del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = :id");
$id = (int)Request::any('id'); $success_message = "";
$id = isset($_POST['id']) ? (int) $_POST['id'] : (isset($_GET['id']) ? (int) $_GET['id'] : 0);
$area = AREA;
// do the delete and then just show a success-message and the apikeys list again // do the delete and then just show a success-message and the apikeys list again
if ($action == 'delete' && $id > 0) { if ($action == 'delete') {
HTML::askYesNo('apikey_reallydelete', $filename, [ if ($id > 0) {
'id' => $id, if (isset($_POST['send']) && $_POST['send'] == 'send') {
'page' => $page, $chk = (AREA == 'admin' && $userinfo['customers_see_all'] == '1') ? true : false;
'action' => 'deletesure' if (AREA == 'customer') {
], '', [ $chk_stmt = Database::prepare("
'section' => 'index', SELECT c.customerid FROM `" . TABLE_PANEL_CUSTOMERS . "` c
'page' => $page LEFT JOIN `" . TABLE_API_KEYS . "` ak ON ak.customerid = c.customerid
]); WHERE ak.`id` = :id AND c.`customerid` = :cid
} elseif (isset($_POST['send']) && $_POST['send'] == 'send' && $action == 'deletesure' && $id > 0) { ");
$chk = (AREA == 'admin' && $userinfo['customers_see_all'] == '1') ? true : false; $chk = Database::pexecute_first($chk_stmt, array(
if (AREA == 'customer') { 'id' => $id,
$chk_stmt = Database::prepare(" 'cid' => $userinfo['customerid']
SELECT c.customerid FROM `" . TABLE_PANEL_CUSTOMERS . "` c ));
LEFT JOIN `" . TABLE_API_KEYS . "` ak ON ak.customerid = c.customerid } elseif (AREA == 'admin' && $userinfo['customers_see_all'] == '0') {
WHERE ak.`id` = :id AND c.`customerid` = :cid $chk_stmt = Database::prepare("
"); SELECT a.adminid FROM `" . TABLE_PANEL_ADMINS . "` a
$chk = Database::pexecute_first($chk_stmt, [ LEFT JOIN `" . TABLE_API_KEYS . "` ak ON ak.adminid = a.adminid
'id' => $id, WHERE ak.`id` = :id AND a.`adminid` = :aid
'cid' => $userinfo['customerid'] ");
]); $chk = Database::pexecute_first($chk_stmt, array(
} elseif (AREA == 'admin' && $userinfo['customers_see_all'] == '0') { 'id' => $id,
$chk_stmt = Database::prepare(" 'aid' => $userinfo['adminid']
SELECT a.adminid FROM `" . TABLE_PANEL_ADMINS . "` a ));
LEFT JOIN `" . TABLE_API_KEYS . "` ak ON ak.adminid = a.adminid }
WHERE ak.`id` = :id AND a.`adminid` = :aid if ($chk !== false) {
"); Database::pexecute($del_stmt, array(
$chk = Database::pexecute_first($chk_stmt, [ 'id' => $id
'id' => $id, ));
'aid' => $userinfo['adminid'] $success_message = sprintf($lng['apikeys']['apikey_removed'], $id);
]); }
} } else {
if ($chk !== false) { \Froxlor\UI\HTML::askYesNo('api_reallydelete', $filename, array(
Database::pexecute($del_stmt, [ 'page' => $page,
'id' => $id 'action' => $action,
]); 'id' => $id
Response::standardSuccess('apikeys.apikey_removed', $id, [ ), $id);
'filename' => $filename, }
'page' => $page
]);
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { $ins_stmt = Database::prepare("
$ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_API_KEYS . "` SET
INSERT INTO `" . TABLE_API_KEYS . "` SET `apikey` = :key, `secret` = :secret, `adminid` = :aid, `customerid` = :cid, `valid_until` = '-1', `allowed_from` = ''
`apikey` = :key, `secret` = :secret, `adminid` = :aid, `customerid` = :cid, `valid_until` = '-1', `allowed_from` = '' ");
"); // customer generates for himself, admins will see a customer-select-box later
// customer generates for himself, admins will see a customer-select-box later if (AREA == 'admin') {
if (AREA == 'admin') { $cid = 0;
$cid = 0; } elseif (AREA == 'customer') {
} elseif (AREA == 'customer') { $cid = $userinfo['customerid'];
$cid = $userinfo['customerid'];
}
$key = hash('sha256', openssl_random_pseudo_bytes(64 * 64));
$secret = hash('sha512', openssl_random_pseudo_bytes(64 * 64 * 4));
Database::pexecute($ins_stmt, [
'key' => $key,
'secret' => $secret,
'aid' => $userinfo['adminid'],
'cid' => $cid
]);
Response::standardSuccess('apikeys.apikey_added', '', [
'filename' => $filename,
'page' => $page
]);
} }
HTML::askYesNo('apikey_reallyadd', $filename, [ $key = hash('sha256', openssl_random_pseudo_bytes(64 * 64));
'id' => $id, $secret = hash('sha512', openssl_random_pseudo_bytes(64 * 64 * 4));
'page' => $page, Database::pexecute($ins_stmt, array(
'action' => $action 'key' => $key,
], '', [ 'secret' => $secret,
'section' => 'index', 'aid' => $userinfo['adminid'],
'page' => $page 'cid' => $cid
]); ));
exit; $success_message = $lng['apikeys']['apikey_added'];
} elseif ($action == 'jqEditApiKey') {
$keyid = isset($_POST['id']) ? (int) $_POST['id'] : 0;
$allowed_from = isset($_POST['allowed_from']) ? $_POST['allowed_from'] : "";
$valid_until = isset($_POST['valid_until']) ? (int) $_POST['valid_until'] : -1;
// validate allowed_from
if (!empty($allowed_from)) {
$ip_list = array_map('trim', explode(",", $allowed_from));
$_check_list = $ip_list;
foreach ($_check_list as $idx => $ip) {
if (\Froxlor\Validate\Validate::validate_ip2($ip, true, 'invalidip', true, true) == false) {
unset($ip_list[$idx]);
}
}
$ip_list = array_map('inet_ntop', array_map('inet_pton', $ip_list));
$allowed_from = implode(",", array_unique($ip_list));
}
if ($valid_until <= 0 || !is_numeric($valid_until)) {
$valid_until = -1;
}
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_API_KEYS . "` SET
`valid_until` = :vu, `allowed_from` = :af
WHERE `id` = :keyid AND `adminid` = :aid AND `customerid` = :cid
");
if (AREA == 'admin') {
$cid = 0;
} elseif (AREA == 'customer') {
$cid = $userinfo['customerid'];
}
Database::pexecute($upd_stmt, array(
'keyid' => $keyid,
'af' => $allowed_from,
'vu' => $valid_until,
'aid' => $userinfo['adminid'],
'cid' => $cid
));
echo json_encode(true);
exit();
} }
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed api::api_keys"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed api::api_keys");
// select all my (accessible) api-keys // select all my (accessible) certificates
$keys_stmt_query = "SELECT ak.*, c.loginname, a.loginname as adminname $keys_stmt_query = "SELECT ak.*, c.loginname, a.loginname as adminname
FROM `" . TABLE_API_KEYS . "` ak FROM `" . TABLE_API_KEYS . "` ak
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` c ON `c`.`customerid` = `ak`.`customerid` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` c ON `c`.`customerid` = `ak`.`customerid`
LEFT JOIN `" . TABLE_PANEL_ADMINS . "` a ON `a`.`adminid` = `ak`.`adminid` LEFT JOIN `" . TABLE_PANEL_ADMINS . "` a ON `a`.`adminid` = `ak`.`adminid`
WHERE "; WHERE ";
$qry_params = []; $qry_params = array();
if (AREA == 'admin' && $userinfo['customers_see_all'] == '0') { if (AREA == 'admin' && $userinfo['customers_see_all'] == '0') {
// admin with only customer-specific permissions // admin with only customer-specific permissions
$keys_stmt_query .= "ak.adminid = :adminid "; $keys_stmt_query .= "ak.adminid = :adminid ";
$qry_params['adminid'] = $userinfo['adminid']; $qry_params['adminid'] = $userinfo['adminid'];
$fields = [ $fields = array(
'a.loginname' => lng('login.username') 'a.loginname' => $lng['login']['username']
]; );
} elseif (AREA == 'customer') { } elseif (AREA == 'customer') {
// customer-area // customer-area
$keys_stmt_query .= "ak.customerid = :cid "; $keys_stmt_query .= "ak.customerid = :cid ";
$qry_params['cid'] = $userinfo['customerid']; $qry_params['cid'] = $userinfo['customerid'];
$fields = [ $fields = array(
'c.loginname' => lng('login.username') 'c.loginname' => $lng['login']['username']
]; );
} else { } else {
// admin who can see all customers / reseller / admins // admin who can see all customers / reseller / admins
$keys_stmt_query .= "1 "; $keys_stmt_query .= "1 ";
$fields = [ $fields = array(
'a.loginname' => lng('login.username') 'a.loginname' => $lng['login']['username']
]; );
} }
//$keys_stmt_query .= $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit(); $paging = new \Froxlor\UI\Paging($userinfo, TABLE_API_KEYS, $fields);
$keys_stmt_query .= $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit();
$keys_stmt = Database::prepare($keys_stmt_query); $keys_stmt = Database::prepare($keys_stmt_query);
Database::pexecute($keys_stmt, $qry_params); Database::pexecute($keys_stmt, $qry_params);
$all_keys = $keys_stmt->fetchAll(PDO::FETCH_ASSOC); $all_keys = $keys_stmt->fetchAll(PDO::FETCH_ASSOC);
$apikeys = "";
$apikeys_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.apikeys.php'; if (count($all_keys) == 0) {
$collection = [ $count = 0;
'data' => $all_keys, $message = $lng['apikeys']['no_api_keys'];
'pagination' => [] $sortcode = "";
]; $searchcode = "";
$pagingcode = "";
eval("\$apikeys.=\"" . \Froxlor\UI\Template::getTemplate("api_keys/keys_error", true) . "\";");
} else {
$count = count($all_keys);
$paging->setEntries($count);
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$tpl = 'user/table.html.twig'; foreach ($all_keys as $idx => $key) {
if ($paging->checkDisplay($idx)) {
UI::view($tpl, [ // my own key
'listing' => Listing::formatFromArray($collection, $apikeys_list_data['apikeys_list'], 'apikeys_list'), $isMyKey = false;
'actions_links' => (int)$userinfo['api_allowed'] == 1 ? [ if ($key['adminid'] == $userinfo['adminid'] && ((AREA == 'admin' && $key['customerid'] == 0) || (AREA == 'customer' && $key['customerid'] == $userinfo['customerid']))) {
[ // this is mine
'href' => $linker->getLink(['section' => 'index', 'page' => $page, 'action' => 'add']), $isMyKey = true;
'label' => lng('apikeys.key_add') }
]
] : null, $adminCustomerLink = "";
]); if (AREA == 'admin') {
if ($isMyKey) {
$adminCustomerLink = $key['adminname'];
} else {
$adminCustomerLink = '<a href="' . $linker->getLink(array(
'section' => (empty($key['customerid']) ? 'admins' : 'customers'),
'page' => (empty($key['customerid']) ? 'admins' : 'customers'),
'action' => 'su',
'id' => (empty($key['customerid']) ? $key['adminid'] : $key['customerid'])
)) . '" rel="external">' . (empty($key['customerid']) ? $key['adminname'] : $key['loginname']) . '</a>';
}
} else {
// customer do not need links
$adminCustomerLink = $key['loginname'];
}
// escape stuff
$row = \Froxlor\PhpHelper::htmlentitiesArray($key);
// shorten keys
$row['_apikey'] = substr($row['apikey'], 0, 20) . '...';
$row['_secret'] = substr($row['secret'], 0, 20) . '...';
// check whether the api key is not valid anymore
$isValid = true;
if ($row['valid_until'] >= 0) {
if ($row['valid_until'] < time()) {
$isValid = false;
}
// format
$row['valid_until'] = date('Y-m-d', $row['valid_until']);
} else {
// infinity
$row['valid_until'] = "";
}
eval("\$apikeys.=\"" . \Froxlor\UI\Template::getTemplate("api_keys/keys_key", true) . "\";");
} else {
continue;
}
}
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("api_keys/keys_list", true) . "\";");

View File

@@ -1,64 +0,0 @@
#!/usr/bin/env php
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
declare(strict_types=1);
use Symfony\Component\Console\Application;
use Froxlor\Cli\RunApiCommand;
use Froxlor\Cli\ConfigServices;
use Froxlor\Cli\PhpSessionclean;
use Froxlor\Cli\SwitchServerIp;
use Froxlor\Cli\UpdateCommand;
use Froxlor\Cli\InstallCommand;
use Froxlor\Cli\MasterCron;
use Froxlor\Cli\UserCommand;
use Froxlor\Cli\ValidateAcmeWebroot;
use Froxlor\Froxlor;
// validate correct php version
if (version_compare("7.4.0", PHP_VERSION, ">=")) {
die('Froxlor requires at least php-7.4. Please validate that your php-cli version is suitable.');
}
// ensure that default timezone is set
if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
@date_default_timezone_set(@date_default_timezone_get());
}
require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/lib/tables.inc.php';
$application = new Application('froxlor-cli', Froxlor::getFullVersion());
$application->add(new RunApiCommand());
$application->add(new ConfigServices());
$application->add(new PhpSessionclean());
$application->add(new SwitchServerIp());
$application->add(new UpdateCommand());
$application->add(new InstallCommand());
$application->add(new MasterCron());
$application->add(new UserCommand());
$application->add(new ValidateAcmeWebroot());
$application->run();

2
cache/.gitignore vendored
View File

@@ -1,2 +0,0 @@
!.gitignore
*

View File

@@ -13,24 +13,24 @@
"name": "Michael Kaufmann", "name": "Michael Kaufmann",
"email": "team@froxlor.org", "email": "team@froxlor.org",
"role": "Lead Developer" "role": "Lead Developer"
},
{
"name": "Robert Förster",
"email": "team@froxlor.org",
"role": "Package Maintainer"
} }
], ],
"support": { "support": {
"email": "team@froxlor.org", "email": "team@froxlor.org",
"issues": "https://github.com/Froxlor/Froxlor/issues", "issues": "https://github.com/Froxlor/Froxlor/issues",
"forum": "https://forum.froxlor.org/", "forum": "https://forum.froxlor.org/",
"wiki": "https://github.com/Froxlor/Froxlor/wiki",
"irc": "irc://irc.libera.chat/froxlor",
"source": "https://github.com/Froxlor/Froxlor", "source": "https://github.com/Froxlor/Froxlor",
"docs": "https://docs.froxlor.org/", "docs": "https://github.com/Froxlor/Froxlor/wiki"
"chat": "https://discord.froxlor.org/"
}, },
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/d00p"
}
],
"require": { "require": {
"php": "^7.4 || ^8.0", "php": "^7.1 || ^8.0",
"ext-session": "*", "ext-session": "*",
"ext-ctype": "*", "ext-ctype": "*",
"ext-pdo": "*", "ext-pdo": "*",
@@ -44,17 +44,11 @@
"ext-json": "*", "ext-json": "*",
"ext-openssl": "*", "ext-openssl": "*",
"ext-fileinfo": "*", "ext-fileinfo": "*",
"ext-gmp": "*",
"ext-gd": "*",
"phpmailer/phpmailer": "~6.0", "phpmailer/phpmailer": "~6.0",
"monolog/monolog": "^1.24", "monolog/monolog": "^1.24",
"robthree/twofactorauth": "^1.6", "robthree/twofactorauth": "^1.6",
"froxlor/idna-convert-legacy": "^2.1", "froxlor/idna-convert-legacy": "^2.1",
"voku/anti-xss": "^4.1", "voku/anti-xss": "^4.1"
"twig/twig": "^3.3",
"erusev/parsedown": "^1.7",
"symfony/console": "^5.4",
"pear/net_dns2": "^1.5"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9", "phpunit/phpunit": "^9",
@@ -65,8 +59,7 @@
"sebastian/phpcpd": "^6.0", "sebastian/phpcpd": "^6.0",
"phploc/phploc": "^7.0", "phploc/phploc": "^7.0",
"phpmd/phpmd": "^2.10", "phpmd/phpmd": "^2.10",
"phpunit/php-timer" : "^5", "phpunit/php-timer" : "^5"
"phpstan/phpstan": "^1.8"
}, },
"suggest": { "suggest": {
"ext-bcmath": "*", "ext-bcmath": "*",

2044
composer.lock generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

1893
css/jquery-ui.min.css vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,116 +2,143 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SubDomains as SubDomains;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Domain\Domain;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection; use Froxlor\Api\Commands\SubDomains as SubDomains;
use Froxlor\UI\HTML; use Froxlor\Api\Commands\Certificates as Certificates;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\Validate\Validate;
use Froxlor\CurrentUser;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'domains')) { if (Settings::IsInList('panel.customer_hide_options', 'domains')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'overview' || $page == 'domains') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_domains");
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";");
} elseif ($page == 'domains') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_domains::domains"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_domains::domains");
$fields = array(
$parentdomain_id = (int)Request::any('pid', '0'); 'd.domain_ace' => $lng['domains']['domainname'],
'd.aliasdomain' => $lng['domains']['aliasdomain']
);
try { try {
$domain_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.domains.php'; // get total count
$collection = (new Collection(SubDomains::class, $userinfo)) $json_result = SubDomains::getLocal($userinfo)->listingCount();
->withPagination($domain_list_data['domain_list']['columns'], $domain_list_data['domain_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = SubDomains::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$domains = '';
$parentdomains_count = 0;
$domains_count = $paging->getEntries();
$domain_array = array();
foreach ($result['list'] as $row) {
formatDomainEntry($row, $idna_convert);
if ($row['parentdomainid'] == '0' && $row['caneditdomain'] == '1') {
$parentdomains_count ++;
}
$domain_array[$row['parentdomainname']][] = $row;
} }
$actions_links = false; foreach ($domain_array as $parentdomain => $sdomains) {
if (CurrentUser::canAddResource('subdomains')) { // PARENTDOMAIN
$actions_links = [ if (Settings::Get('system.awstats_enabled') == '1') {
[ $statsapp = 'awstats';
'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains', 'action' => 'add']), } else {
'label' => lng('domains.subdomain_add') $statsapp = 'webalizer';
] }
$row = [
'domain' => $idna_convert->decode($parentdomain ?? '')
]; ];
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_delimiter") . "\";");
foreach ($sdomains as $domain) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($domain);
// show docroot nicely
if (strpos($row['documentroot'], $userinfo['documentroot']) === 0) {
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['documentroot']));
}
// get ssl-ips if activated
$show_ssledit = false;
if (Settings::Get('system.use_ssl') == '1' && \Froxlor\Domain\Domain::domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) {
$show_ssledit = true;
}
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
}
} }
UI::view('user/table.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domainlist") . "\";");
'listing' => Listing::format($collection, $domain_list_data, 'domain_list'),
'actions_links' => $actions_links,
'entity_info' => lng('domains.description')
]);
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = SubDomains::getLocal($userinfo, [ $json_result = SubDomains::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
$alias_stmt = Database::prepare("SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` = :aliasdomain"); $alias_stmt = Database::prepare("SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` = :aliasdomain");
$alias_check = Database::pexecute_first($alias_stmt, [ $alias_check = Database::pexecute_first($alias_stmt, array(
"aliasdomain" => $id "aliasdomain" => $id
]); ));
if (isset($result['parentdomainid']) && $result['parentdomainid'] != '0' && $alias_check['count'] == 0) { if (isset($result['parentdomainid']) && $result['parentdomainid'] != '0' && $alias_check['count'] == 0) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
SubDomains::getLocal($userinfo, $_POST)->delete(); SubDomains::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('domains_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('domains_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $idna_convert->decode($result['domain'])); ), $idna_convert->decode($result['domain']));
} }
} else { } else {
Response::standardError('domains_cantdeletemaindomain'); \Froxlor\UI\Response::standard_error('domains_cantdeletemaindomain');
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if ($userinfo['subdomains_used'] < $userinfo['subdomains'] || $userinfo['subdomains'] == '-1') { if ($userinfo['subdomains_used'] < $userinfo['subdomains'] || $userinfo['subdomains'] == '-1') {
@@ -119,11 +146,12 @@ if ($page == 'overview' || $page == 'domains') {
try { try {
SubDomains::getLocal($userinfo, $_POST)->add(); SubDomains::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$stmt = Database::prepare("SELECT `id`, `domain`, `documentroot`, `ssl_redirect`,`isemaildomain`,`letsencrypt` FROM `" . TABLE_PANEL_DOMAINS . "` $stmt = Database::prepare("SELECT `id`, `domain`, `documentroot`, `ssl_redirect`,`isemaildomain`,`letsencrypt` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
@@ -131,15 +159,16 @@ if ($page == 'overview' || $page == 'domains') {
AND `email_only` = '0' AND `email_only` = '0'
AND `caneditdomain` = '1' AND `caneditdomain` = '1'
ORDER BY `domain` ASC"); ORDER BY `domain` ASC");
Database::pexecute($stmt, [ Database::pexecute($stmt, array(
"customerid" => $userinfo['customerid'] "customerid" => $userinfo['customerid']
]); ));
$domains = []; $domains = '';
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$domains[$row['domain']] = $idna_convert->decode($row['domain']); $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row['domain']), $row['domain']);
} }
$aliasdomains[0] = lng('domains.noaliasdomain'); $aliasdomains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, NULL, true);
$domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` $domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
WHERE `d`.`aliasdomain` IS NULL WHERE `d`.`aliasdomain` IS NULL
AND `d`.`id` <> `c`.`standardsubdomain` AND `d`.`id` <> `c`.`standardsubdomain`
@@ -148,24 +177,24 @@ if ($page == 'overview' || $page == 'domains') {
AND `d`.`email_only`='0' AND `d`.`email_only`='0'
AND `d`.`customerid`= :customerid AND `d`.`customerid`= :customerid
ORDER BY `d`.`domain` ASC"); ORDER BY `d`.`domain` ASC");
Database::pexecute($domains_stmt, [ Database::pexecute($domains_stmt, array(
"customerid" => $userinfo['customerid'] "customerid" => $userinfo['customerid']
]); ));
while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$aliasdomains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']); $aliasdomains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id']);
} }
$redirectcode = []; $redirectcode = '';
if (Settings::Get('customredirect.enabled') == '1') { if (Settings::Get('customredirect.enabled') == '1') {
$codes = Domain::getRedirectCodesArray(); $codes = \Froxlor\Domain\Domain::getRedirectCodesArray();
foreach ($codes as $rc) { foreach ($codes as $rc) {
$redirectcode[$rc['id']] = $rc['code'] . ' (' . lng('redirect_desc.' . $rc['desc']) . ')'; $redirectcode .= \Froxlor\UI\HTML::makeoption($rc['code'] . ' (' . $lng['redirect_desc'][$rc['desc']] . ')', $rc['id']);
} }
} }
// check if we at least have one ssl-ip/port, #1179 // check if we at least have one ssl-ip/port, #1179
$ssl_ipsandports = false; $ssl_ipsandports = '';
$ssl_ip_stmt = Database::prepare(" $ssl_ip_stmt = Database::prepare("
SELECT COUNT(*) as countSSL SELECT COUNT(*) as countSSL
FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip
@@ -174,19 +203,17 @@ if ($page == 'overview' || $page == 'domains') {
"); ");
Database::pexecute($ssl_ip_stmt); Database::pexecute($ssl_ip_stmt);
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC); $resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) { if (isset($resultX['countSSL']) && (int) $resultX['countSSL'] > 0) {
$ssl_ipsandports = true; $ssl_ipsandports = 'notempty';
} }
$openbasedir = [ $openbasedir = \Froxlor\UI\HTML::makeoption($lng['domain']['docroot'], 0, NULL, true) . \Froxlor\UI\HTML::makeoption($lng['domain']['homedir'], 1, NULL, true);
0 => lng('domain.docroot'), $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
1 => lng('domain.homedir'),
2 => lng('domain.docparent')
];
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$phpconfigs = []; $phpconfigs = '';
if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs'])) { $has_phpconfigs = false;
if (isset($userinfo['allowed_phpconfigs']) && ! empty($userinfo['allowed_phpconfigs'])) {
$has_phpconfigs = true;
$allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY); $allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY);
$phpconfigs_result_stmt = Database::query(" $phpconfigs_result_stmt = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
@@ -195,51 +222,49 @@ if ($page == 'overview' || $page == 'domains') {
WHERE c.id IN (" . implode(", ", $allowed_cfg) . ") WHERE c.id IN (" . implode(", ", $allowed_cfg) . ")
"); ");
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]"; $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]", $phpconfigs_row['id'], Settings::Get('phpfpm.defaultini'), true, true);
} else { } else {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description']; $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], Settings::Get('system.mod_fcgid_defaultini'), true, true);
} }
} }
} }
$subdomain_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_add.php'; $subdomain_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_add.php';
$subdomain_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($subdomain_add_data);
UI::view('user/form.html.twig', [ $title = $subdomain_add_data['domain_add']['title'];
'formaction' => $linker->getLink(['section' => 'domains']), $image = $subdomain_add_data['domain_add']['image'];
'formdata' => $subdomain_add_data['domain_add']
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_add") . "\";");
} }
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = SubDomains::getLocal($userinfo, [ $json_result = SubDomains::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if (isset($result['customerid']) && $result['customerid'] == $userinfo['customerid']) { if (isset($result['customerid']) && $result['customerid'] == $userinfo['customerid']) {
if ((int) $result['caneditdomain'] == 0) {
Response::standardError('domaincannotbeedited', $result['domain']);
}
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
SubDomains::getLocal($userinfo, $_POST)->update(); SubDomains::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$result['domain'] = $idna_convert->decode($result['domain']); $result['domain'] = $idna_convert->decode($result['domain']);
$domains[0] = lng('domains.noaliasdomain'); $domains = \Froxlor\UI\HTML::makeoption($lng['domains']['noaliasdomain'], 0, $result['aliasdomain'], true);
// also check ip/port combination to be the same, #176 // also check ip/port combination to be the same, #176
$domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d` , `" . TABLE_PANEL_CUSTOMERS . "` `c` , `" . TABLE_DOMAINTOIP . "` `dip` $domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d` , `" . TABLE_PANEL_CUSTOMERS . "` `c` , `" . TABLE_DOMAINTOIP . "` `dip`
WHERE `d`.`aliasdomain` IS NULL WHERE `d`.`aliasdomain` IS NULL
@@ -254,90 +279,88 @@ if ($page == 'overview' || $page == 'domains') {
WHERE `id_domain` = :id) WHERE `id_domain` = :id)
GROUP BY `d`.`id`, `d`.`domain` GROUP BY `d`.`id`, `d`.`domain`
ORDER BY `d`.`domain` ASC"); ORDER BY `d`.`domain` ASC");
Database::pexecute($domains_stmt, [ Database::pexecute($domains_stmt, array(
"id" => $result['id'], "id" => $result['id'],
"customerid" => $userinfo['customerid'] "customerid" => $userinfo['customerid']
]); ));
while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']); $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']);
} }
if (preg_match('/^https?\:\/\//', $result['documentroot']) && Validate::validateUrl($result['documentroot'])) { if (preg_match('/^https?\:\/\//', $result['documentroot']) && \Froxlor\Validate\Validate::validateUrl($result['documentroot'])) {
if (Settings::Get('panel.pathedit') == 'Dropdown') { if (Settings::Get('panel.pathedit') == 'Dropdown') {
$urlvalue = $result['documentroot']; $urlvalue = $result['documentroot'];
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
} else { } else {
$urlvalue = ''; $urlvalue = '';
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot'], true); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot'], true);
} }
} else { } else {
$urlvalue = ''; $urlvalue = '';
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot']); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot']);
} }
$redirectcode = []; $redirectcode = '';
if (Settings::Get('customredirect.enabled') == '1') { if (Settings::Get('customredirect.enabled') == '1') {
$def_code = Domain::getDomainRedirectId($id); $def_code = \Froxlor\Domain\Domain::getDomainRedirectId($id);
$codes = Domain::getRedirectCodesArray(); $codes = \Froxlor\Domain\Domain::getRedirectCodesArray();
foreach ($codes as $rc) { foreach ($codes as $rc) {
$redirectcode[$rc['id']] = $rc['code'] . ' (' . lng('redirect_desc.' . $rc['desc']) . ')'; $redirectcode .= \Froxlor\UI\HTML::makeoption($rc['code'] . ' (' . $lng['redirect_desc'][$rc['desc']] . ')', $rc['id'], $def_code);
} }
} }
// check if we at least have one ssl-ip/port, #1179 // check if we at least have one ssl-ip/port, #1179
$ssl_ipsandports = false; $ssl_ipsandports = '';
$ssl_ip_stmt = Database::prepare(" $ssl_ip_stmt = Database::prepare("
SELECT COUNT(*) as countSSL SELECT COUNT(*) as countSSL
FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip
LEFT JOIN `" . TABLE_DOMAINTOIP . "` dti ON dti.id_ipandports = pip.id LEFT JOIN `" . TABLE_DOMAINTOIP . "` dti ON dti.id_ipandports = pip.id
WHERE `dti`.`id_domain` = :id_domain AND pip.`ssl`='1' WHERE `dti`.`id_domain` = :id_domain AND pip.`ssl`='1'
"); ");
Database::pexecute($ssl_ip_stmt, [ Database::pexecute($ssl_ip_stmt, array(
"id_domain" => $result['id'] "id_domain" => $result['id']
]); ));
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC); $resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) { if (isset($resultX['countSSL']) && (int) $resultX['countSSL'] > 0) {
$ssl_ipsandports = true; $ssl_ipsandports = 'notempty';
} }
// Fudge the result for ssl_redirect to hide the Let's Encrypt steps // Fudge the result for ssl_redirect to hide the Let's Encrypt steps
$result['temporary_ssl_redirect'] = $result['ssl_redirect']; $result['temporary_ssl_redirect'] = $result['ssl_redirect'];
$result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1); $result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1);
$openbasedir = [ $openbasedir = \Froxlor\UI\HTML::makeoption($lng['domain']['docroot'], 0, $result['openbasedir_path'], true) . \Froxlor\UI\HTML::makeoption($lng['domain']['homedir'], 1, $result['openbasedir_path'], true);
0 => lng('domain.docroot'),
1 => lng('domain.homedir'),
2 => lng('domain.docparent')
];
// create serveralias options // create serveralias options
$serveraliasoptions = []; $serveraliasoptions = "";
$serveraliasoptions_selected = '2'; $_value = '2';
if ($result['iswildcarddomain'] == '1') { if ($result['iswildcarddomain'] == '1') {
$serveraliasoptions_selected = '0'; $_value = '0';
} elseif ($result['wwwserveralias'] == '1') { } elseif ($result['wwwserveralias'] == '1') {
$serveraliasoptions_selected = '1'; $_value = '1';
} }
$serveraliasoptions[0] = lng('domains.serveraliasoption_wildcard'); $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', $_value, true, true);
$serveraliasoptions[1] = lng('domains.serveraliasoption_www'); $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', $_value, true, true);
$serveraliasoptions[2] = lng('domains.serveraliasoption_none'); $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', $_value, true, true);
$ips_stmt = Database::prepare("SELECT `p`.`ip` AS `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` `p` $ips_stmt = Database::prepare("SELECT `p`.`ip` AS `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` `p`
LEFT JOIN `" . TABLE_DOMAINTOIP . "` `dip` LEFT JOIN `" . TABLE_DOMAINTOIP . "` `dip`
ON ( `dip`.`id_ipandports` = `p`.`id` ) ON ( `dip`.`id_ipandports` = `p`.`id` )
WHERE `dip`.`id_domain` = :id_domain WHERE `dip`.`id_domain` = :id_domain
GROUP BY `p`.`ip`"); GROUP BY `p`.`ip`");
Database::pexecute($ips_stmt, [ Database::pexecute($ips_stmt, array(
"id_domain" => $result['id'] "id_domain" => $result['id']
]); ));
$domainips = []; $result_ipandport['ip'] = '';
while ($rowip = $ips_stmt->fetch(PDO::FETCH_ASSOC)) { while ($rowip = $ips_stmt->fetch(PDO::FETCH_ASSOC)) {
$domainips[] = ['item' => $rowip['ip']]; $result_ipandport['ip'] .= $rowip['ip'] . "<br />";
} }
$phpconfigs = []; $phpconfigs = '';
if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs'])) { $has_phpconfigs = false;
if (isset($userinfo['allowed_phpconfigs']) && ! empty($userinfo['allowed_phpconfigs'])) {
$has_phpconfigs = true;
$allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY); $allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY);
$phpconfigs_result_stmt = Database::query(" $phpconfigs_result_stmt = Database::query("
SELECT c.*, fc.description as interpreter SELECT c.*, fc.description as interpreter
@@ -346,40 +369,152 @@ if ($page == 'overview' || $page == 'domains') {
WHERE c.id IN (" . implode(", ", $allowed_cfg) . ") WHERE c.id IN (" . implode(", ", $allowed_cfg) . ")
"); ");
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]"; $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]", $phpconfigs_row['id'], $result['phpsettingid'], true, true);
} else { } else {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description']; $phpconfigs .= \Froxlor\UI\HTML::makeoption($phpconfigs_row['description'], $phpconfigs_row['id'], $result['phpsettingid'], true, true);
} }
} }
} }
$alias_stmt = Database::prepare("SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain`= :aliasdomain"); $alias_stmt = Database::prepare("SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain`= :aliasdomain");
$alias_check = Database::pexecute_first($alias_stmt, [ $alias_check = Database::pexecute_first($alias_stmt, array(
"aliasdomain" => $result['id'] "aliasdomain" => $result['id']
]); ));
$alias_check = $alias_check['count']; $alias_check = $alias_check['count'];
$result = PhpHelper::htmlentitiesArray($result); $domainip = $result_ipandport['ip'];
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$subdomain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_edit.php'; $subdomain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_edit.php';
$subdomain_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($subdomain_edit_data);
UI::view('user/form.html.twig', [ $title = $subdomain_edit_data['domain_edit']['title'];
'formaction' => $linker->getLink(['section' => 'domains', 'id' => $id]), $image = $subdomain_edit_data['domain_edit']['image'];
'formdata' => $subdomain_edit_data['domain_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains_edit") . "\";");
]);
} }
} else { } else {
Response::standardError('domains_canteditdomain'); \Froxlor\UI\Response::standard_error('domains_canteditdomain');
} }
} }
} elseif ($page == 'domainssleditor') { } elseif ($page == 'domainssleditor') {
require_once __DIR__ . '/ssl_editor.php';
if ($action == '' || $action == 'view') {
// get domain
try {
$json_result = SubDomains::getLocal($userinfo, array(
'id' => $id
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result_domain = json_decode($json_result, true)['data'];
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$do_insert = isset($_POST['do_insert']) ? (($_POST['do_insert'] == 1) ? true : false) : false;
try {
if ($do_insert) {
Certificates::getLocal($userinfo, $_POST)->add();
} else {
Certificates::getLocal($userinfo, $_POST)->update();
}
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
// back to domain overview
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'domains',
's' => $s
));
}
$stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
WHERE `domainid`= :domainid");
$result = Database::pexecute_first($stmt, array(
"domainid" => $id
));
$do_insert = false;
// if no entry can be found, behave like we have empty values
if (! is_array($result) || ! isset($result['ssl_cert_file'])) {
$result = array(
'ssl_cert_file' => '',
'ssl_key_file' => '',
'ssl_ca_file' => '',
'ssl_cert_chainfile' => ''
);
$do_insert = true;
}
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$ssleditor_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domain_ssleditor.php';
$ssleditor_form = \Froxlor\UI\HtmlForm::genHTMLForm($ssleditor_data);
$title = $ssleditor_data['domain_ssleditor']['title'];
$image = $ssleditor_data['domain_ssleditor']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domain_ssleditor") . "\";");
}
} elseif ($page == 'domaindnseditor' && $userinfo['dnsenabled'] == '1' && Settings::Get('system.dnsenabled') == '1') { } elseif ($page == 'domaindnseditor' && $userinfo['dnsenabled'] == '1' && Settings::Get('system.dnsenabled') == '1') {
require_once __DIR__ . '/dns_editor.php'; require_once __DIR__ . '/dns_editor.php';
} elseif ($page == 'sslcertificates') { } elseif ($page == 'sslcertificates') {
require_once __DIR__ . '/ssl_certificates.php'; require_once __DIR__ . '/ssl_certificates.php';
} elseif ($page == 'logfiles') { } elseif ($page == 'logfiles') {
require_once __DIR__ . '/logfiles_viewer.php'; require_once __DIR__ . '/logfiles_viewer.php';
} }
function formatDomainEntry(&$row, &$idna_convert)
{
$row['domain'] = $idna_convert->decode($row['domain']);
$row['aliasdomain'] = $idna_convert->decode($row['aliasdomain'] ?? '');
$row['domainalias'] = $idna_convert->decode($row['domainalias'] ?? '');
/**
* check for set ssl-certs to show different state-icons
*/
// nothing (ssl_global)
$row['domain_hascert'] = 0;
$ssl_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domainid");
Database::pexecute($ssl_stmt, array(
"domainid" => $row['id']
));
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
// own certificate (ssl_customer_green)
$row['domain_hascert'] = 1;
} else {
// check if it's parent has one set (shared)
if ($row['parentdomainid'] != 0) {
$ssl_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domainid");
Database::pexecute($ssl_stmt, array(
"domainid" => $row['parentdomainid']
));
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
// parent has a certificate (ssl_shared)
$row['domain_hascert'] = 2;
}
}
}
$row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date'] ?? '');
$row['termination_css'] = "";
if ($row['termination_date'] != "") {
$cdate = strtotime($row['termination_date'] . " 23:59:59");
$today = time();
if ($cdate < $today) {
$row['termination_css'] = 'domain-expired';
} else {
$row['termination_css'] = 'domain-canceled';
}
}
}

View File

@@ -2,101 +2,130 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\EmailAccounts;
use Froxlor\Api\Commands\EmailForwarders;
use Froxlor\Api\Commands\Emails;
use Froxlor\Api\Commands\EmailDomains;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection; use Froxlor\Api\Commands\Emails as Emails;
use Froxlor\UI\HTML; use Froxlor\Api\Commands\EmailAccounts as EmailAccounts;
use Froxlor\UI\Listing; use Froxlor\Api\Commands\EmailForwarders as EmailForwarders;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\Validate\Check;
use Froxlor\CurrentUser;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'email') || $userinfo['emails'] == 0) { if (Settings::IsInList('panel.customer_hide_options', 'email')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
if ($page == 'overview' || $page == 'emails') { } elseif (isset($_GET['id'])) {
$result_stmt = Database::prepare(" $id = intval($_GET['id']);
SELECT COUNT(DISTINCT `domainid`) as maildomains FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid`= :cid
");
$domain_count = Database::pexecute_first($result_stmt, [
"cid" => $userinfo['customerid']
]);
if ($domain_count['maildomains'] && $domain_count['maildomains'] > 1) {
try {
$emaildomain_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.emails_overview.php';
$collection = (new Collection(EmailDomains::class, $userinfo))
->withPagination($emaildomain_list_data['emaildomain_list']['columns'],
$emaildomain_list_data['emaildomain_list']['default_sorting']);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $emaildomain_list_data, 'emaildomain_list'),
'actions_links' => CurrentUser::canAddResource('emails') ? [
[
'href' => $linker->getLink(['section' => 'email', 'page' => 'email_domain', 'action' => 'add']),
'label' => lng('emails.emails_add')
]
] : null,
]);
} else {
// only emails for one domain -> show email address listing directly
$page = 'email_domain';
}
} }
if ($page == 'email_domain') {
$email_domainid = Request::any('domainid', 0); if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_email");
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/email") . "\";");
} elseif ($page == 'emails') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_email::emails"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_email::emails");
$fields = array(
$sql_search = []; 'd.domain_ace' => $lng['domains']['domainname'],
if ($email_domainid > 0) { 'm.email_full' => $lng['emails']['emailaddress'],
$sql_search = ['sql_search' => ['m.domainid' => ['op' => '=', 'value' => $email_domainid]]]; 'm.destination' => $lng['emails']['forwarders']
} );
try { try {
$email_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.emails.php'; // get total count
$collection = (new Collection(Emails::class, $userinfo, $sql_search)) $json_result = Emails::getLocal($userinfo)->listingCount();
->withPagination($email_list_data['email_list']['columns'], $result = json_decode($json_result, true)['data'];
$email_list_data['email_list']['default_sorting']); // initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Emails::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$emails = array();
$emailscount = $paging->getEntries();
foreach ($result['list'] as $row) {
if (! isset($emails[$row['domain']]) || ! is_array($emails[$row['domain']])) {
$emails[$row['domain']] = array();
}
$emails[$row['domain']][$row['email_full']] = $row;
}
if ($paging->sortfield == 'd.domain_ace' && $paging->sortorder == 'desc') {
krsort($emails);
} else {
ksort($emails);
}
$count = 0;
$accounts = '';
$emails_count = 0;
$domainname = '';
foreach ($emails as $domainid => $emailaddresses) {
if ($paging->sortfield == 'm.email_full' && $paging->sortorder == 'desc') {
krsort($emailaddresses);
} else {
ksort($emailaddresses);
}
foreach ($emailaddresses as $row) {
if ($domainname != $idna_convert->decode($row['domain'])) {
$domainname = $idna_convert->decode($row['domain']);
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_domain") . "\";");
}
$emails_count ++;
$row['email'] = $idna_convert->decode($row['email']);
$row['email_full'] = $idna_convert->decode($row['email_full']);
$row['destination'] = explode(' ', $row['destination']);
uasort($row['destination'], 'strcasecmp');
$dest_list = $row['destination'];
foreach ($dest_list as $dest_id => $destination) {
$row['destination'][$dest_id] = $idna_convert->decode($row['destination'][$dest_id]);
if ($row['destination'][$dest_id] == $row['email_full']) {
unset($row['destination'][$dest_id]);
}
}
$destinations_count = count($row['destination']);
$row['destination'] = implode(', ', $row['destination']);
if (strlen($row['destination']) > 35) {
$row['destination'] = substr($row['destination'], 0, 32) . '... (' . $destinations_count . ')';
}
$row['mboxsize'] = \Froxlor\PhpHelper::sizeReadable($row['mboxsize'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_email") . "\";");
$count ++;
}
} }
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
@@ -104,69 +133,47 @@ if ($page == 'email_domain') {
FROM `" . TABLE_PANEL_DOMAINS . "` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid`= :cid AND `isemaildomain` = '1' WHERE `customerid`= :cid AND `isemaildomain` = '1'
"); ");
$result2 = Database::pexecute_first($result_stmt, [ $result2 = Database::pexecute_first($result_stmt, array(
"cid" => $userinfo['customerid'] "cid" => $userinfo['customerid']
]); ));
$emaildomains_count = $result2['emaildomains']; $emaildomains_count = $result2['emaildomains'];
$actions_links = []; eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails") . "\";");
if ($email_domainid > 0) {
$actions_links[] = [
'class' => 'btn-outline-primary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'emails',
]),
'label' => lng('emails.back_to_overview'),
'icon' => 'fa-solid fa-reply'
];
}
if (CurrentUser::canAddResource('emails')) {
$actions_links[] = [
'href' => $linker->getLink(['section' => 'email', 'page' => 'email_domain', 'action' => 'add', 'domainid' => $email_domainid]),
'label' => lng('emails.emails_add')
];
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $email_list_data, 'email_list'),
'actions_links' => $actions_links,
'entity_info' => lng('emails.description')
]);
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if (isset($result['email']) && $result['email'] != '') { if (isset($result['email']) && $result['email'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
Emails::getLocal($userinfo, [ Emails::getLocal($userinfo, array(
'id' => $id, 'id' => $id,
'delete_userfiles' => ($_POST['delete_userfiles'] ?? 0) 'delete_userfiles' => ($_POST['delete_userfiles'] ?? 0)
])->delete(); ))->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
if ($result['popaccountid'] != '0') { if ($result['popaccountid'] != '0') {
$show_checkbox = true; $show_checkbox = true;
} else { } else {
$show_checkbox = false; $show_checkbox = false;
} }
HTML::askYesNoWithCheckbox('email_reallydelete', 'admin_customer_alsoremovemail', $filename, [ \Froxlor\UI\HTML::askYesNoWithCheckbox('email_reallydelete', 'admin_customer_alsoremovemail', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $idna_convert->decode($result['email_full']), $show_checkbox); ), $idna_convert->decode($result['email_full']), $show_checkbox);
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
@@ -175,93 +182,78 @@ if ($page == 'email_domain') {
try { try {
$json_result = Emails::getLocal($userinfo, $_POST)->add(); $json_result = Emails::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, 'page' => $page,
'action' => 'edit', 'action' => 'edit',
'id' => $result['id'] 'id' => $result['id'],
]); 's' => $s
));
} else { } else {
$result_stmt = Database::prepare("SELECT `id`, `domain`, `customerid` FROM `" . TABLE_PANEL_DOMAINS . "` $result_stmt = Database::prepare("SELECT `id`, `domain`, `customerid` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid`= :cid WHERE `customerid`= :cid
AND `isemaildomain`='1' AND `isemaildomain`='1'
ORDER BY `domain_ace` ASC"); ORDER BY `domain_ace` ASC");
Database::pexecute($result_stmt, [ Database::pexecute($result_stmt, array(
"cid" => $userinfo['customerid'] "cid" => $userinfo['customerid']
]); ));
$domains = []; $domains = '';
$selected_domain = "";
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($email_domainid == $row['id']) { $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row['domain']), $row['domain']);
$selected_domain = $row['domain'];
}
$domains[$row['domain']] = $idna_convert->decode($row['domain']);
} }
if (count($domains) > 0) { // $iscatchall = \Froxlor\UI\HTML::makeyesno('iscatchall', '1', '0', '0');
$email_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_add.php';
if (Settings::Get('catchall.catchall_enabled') != '1') { $email_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_add.php';
unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']);
} if (Settings::Get('catchall.catchall_enabled') != '1') {
UI::view('user/form.html.twig', [ unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']);
'formaction' => $linker->getLink(['section' => 'email']),
'formdata' => $email_add_data['emails_add']
]);
} else {
Response::standardError('emails.noemaildomainaddedyet');
} }
$email_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($email_add_data);
$title = $email_add_data['emails_add']['title'];
$image = $email_add_data['emails_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails_add") . "\";");
} }
} else { } else {
Response::standardError('allresourcesused'); \Froxlor\UI\Response::standard_error('allresourcesused');
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if (isset($result['email']) && $result['email'] != '') { if (isset($result['email']) && $result['email'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
Response::redirectTo($filename, [
'page' => $page
]);
}
$result['email'] = $idna_convert->decode($result['email']); $result['email'] = $idna_convert->decode($result['email']);
$result['email_full'] = $idna_convert->decode($result['email_full']); $result['email_full'] = $idna_convert->decode($result['email_full']);
$result['destination'] = explode(' ', $result['destination']); $result['destination'] = explode(' ', $result['destination']);
uasort($result['destination'], 'strcasecmp'); uasort($result['destination'], 'strcasecmp');
$forwarders = []; $forwarders = '';
$forwarders_count = 0; $forwarders_count = 0;
foreach ($result['destination'] as $dest_id => $destination) { foreach ($result['destination'] as $dest_id => $destination) {
$destination = $idna_convert->decode($destination); $destination = $idna_convert->decode($destination);
if ($destination != $result['email_full'] && $destination != '') { if ($destination != $result['email_full'] && $destination != '') {
$forwarders[] = [ eval("\$forwarders.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_edit_forwarder") . "\";");
'item' => $destination, $forwarders_count ++;
'href' => $linker->getLink([
'section' => 'email',
'page' => 'forwarders',
'action' => 'delete',
'id' => $id,
'forwarderid' => $dest_id
]),
'label' => lng('panel.delete'),
'classes' => 'btn btn-sm btn-danger'
];
$forwarders_count++;
} }
$result['destination'][$dest_id] = $destination; $result['destination'][$dest_id] = $destination;
} }
$destinations_count = count($result['destination']); $destinations_count = count($result['destination']);
$result = PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$email_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_edit.php'; $email_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_edit.php';
@@ -269,47 +261,47 @@ if ($page == 'email_domain') {
unset($email_edit_data['emails_edit']['sections']['section_a']['fields']['mail_catchall']); unset($email_edit_data['emails_edit']['sections']['section_a']['fields']['mail_catchall']);
} }
UI::view('user/form.html.twig', [ $email_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($email_edit_data);
'formaction' => $linker->getLink(['section' => 'email']),
'formdata' => $email_edit_data['emails_edit'], $title = $email_edit_data['emails_edit']['title'];
'editid' => $id $image = $email_edit_data['emails_edit']['image'];
]);
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails_edit") . "\";");
} }
} elseif ($action == 'togglecatchall' && $id != 0) { } elseif ($action == 'togglecatchall' && $id != 0) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
try { try {
Emails::getLocal($userinfo, [ Emails::getLocal($userinfo, array(
'id' => $id, 'id' => $id,
'iscatchall' => ($result['iscatchall'] == '1' ? 0 : 1) 'iscatchall' => ($result['iscatchall'] == '1' ? 0 : 1)
])->update(); ))->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, 'page' => $page,
'domainid' => $email_domainid,
'action' => 'edit', 'action' => 'edit',
'id' => $id, 'id' => $id,
]); 's' => $s
));
} }
} elseif ($page == 'accounts') { } elseif ($page == 'accounts') {
$email_domainid = Request::any('domainid', 0);
if ($action == 'add' && $id != 0) { if ($action == 'add' && $id != 0) {
if ($userinfo['email_accounts'] == '-1' || ($userinfo['email_accounts_used'] < $userinfo['email_accounts'])) { if ($userinfo['email_accounts'] == '-1' || ($userinfo['email_accounts_used'] < $userinfo['email_accounts'])) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -317,69 +309,47 @@ if ($page == 'email_domain') {
try { try {
EmailAccounts::getLocal($userinfo, $_POST)->add(); EmailAccounts::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'email_domain', 'page' => 'emails',
'domainid' => $email_domainid,
'action' => 'edit', 'action' => 'edit',
'id' => $id 'id' => $id,
]); 's' => $s
));
} else { } else {
if (Check::checkMailAccDeletionState($result['email_full'])) {
Response::standardError([ if (\Froxlor\Validate\Check::checkMailAccDeletionState($result['email_full'])) {
\Froxlor\UI\Response::standard_error(array(
'mailaccistobedeleted' 'mailaccistobedeleted'
], $result['email_full']); ), $result['email_full']);
} }
$result['email_full'] = $idna_convert->decode($result['email_full']); $result['email_full'] = $idna_convert->decode($result['email_full']);
$result = PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$quota = Settings::Get('system.mail_quota'); $quota = Settings::Get('system.mail_quota');
$account_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addaccount.php'; $account_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addaccount.php';
$account_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($account_add_data);
UI::view('user/form.html.twig', [ $title = $account_add_data['emails_addaccount']['title'];
'formaction' => $linker->getLink(['section' => 'email', 'id' => $id]), $image = $account_add_data['emails_addaccount']['image'];
'formdata' => $account_add_data['emails_addaccount'],
'actions_links' => [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_add") . "\";");
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid,
'action' => 'edit',
'id' => $id
]),
'label' => lng('emails.emails_edit'),
'icon' => 'fa-solid fa-pen'
],
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid
]),
'label' => lng('menue.email.emails'),
'icon' => 'fa-solid fa-envelope'
]
],
]);
} }
} else { } else {
Response::standardError([ \Froxlor\UI\Response::standard_error(array(
'allresourcesused', 'allresourcesused',
'allocatetoomuchquota' 'allocatetoomuchquota'
], $quota); ), $quota);
} }
} elseif ($action == 'changepw' && $id != 0) { } elseif ($action == 'changepw' && $id != 0) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -388,57 +358,34 @@ if ($page == 'email_domain') {
try { try {
EmailAccounts::getLocal($userinfo, $_POST)->update(); EmailAccounts::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'email_domain', 'page' => 'emails',
'domainid' => $email_domainid,
'action' => 'edit', 'action' => 'edit',
'id' => $id 'id' => $id,
]); 's' => $s
));
} else { } else {
$result['email_full'] = $idna_convert->decode($result['email_full']); $result['email_full'] = $idna_convert->decode($result['email_full']);
$result = PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$account_changepw_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangepasswd.php'; $account_changepw_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangepasswd.php';
$account_changepw_form = \Froxlor\UI\HtmlForm::genHTMLForm($account_changepw_data);
UI::view('user/form.html.twig', [ $title = $account_changepw_data['emails_accountchangepasswd']['title'];
'formaction' => $linker->getLink(['section' => 'email', 'id' => $id]), $image = $account_changepw_data['emails_accountchangepasswd']['image'];
'formdata' => $account_changepw_data['emails_accountchangepasswd'],
'actions_links' => [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_changepw") . "\";");
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid,
'action' => 'edit',
'id' => $id
]),
'label' => lng('emails.emails_edit'),
'icon' => 'fa-solid fa-pen'
],
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid
]),
'label' => lng('menue.email.emails'),
'icon' => 'fa-solid fa-envelope'
]
],
]);
} }
} }
} elseif ($action == 'changequota' && Settings::Get('system.mail_quota_enabled') == '1' && $id != 0) { } elseif ($action == 'changequota' && Settings::Get('system.mail_quota_enabled') == '1' && $id != 0) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -447,57 +394,34 @@ if ($page == 'email_domain') {
try { try {
EmailAccounts::getLocal($userinfo, $_POST)->update(); EmailAccounts::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'email_domain', 'page' => 'emails',
'domainid' => $email_domainid,
'action' => 'edit', 'action' => 'edit',
'id' => $id 'id' => $id,
]); 's' => $s
));
} else { } else {
$result['email_full'] = $idna_convert->decode($result['email_full']); $result['email_full'] = $idna_convert->decode($result['email_full']);
$result = PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$quota_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangequota.php'; $quota_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangequota.php';
$quota_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($quota_edit_data);
UI::view('user/form.html.twig', [ $title = $quota_edit_data['emails_accountchangequota']['title'];
'formaction' => $linker->getLink(['section' => 'email', 'id' => $id]), $image = $quota_edit_data['emails_accountchangequota']['image'];
'formdata' => $quota_edit_data['emails_accountchangequota'],
'actions_links' => [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_changequota") . "\";");
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid,
'action' => 'edit',
'id' => $id
]),
'label' => lng('emails.emails_edit'),
'icon' => 'fa-solid fa-pen'
],
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid
]),
'label' => lng('menue.email.emails'),
'icon' => 'fa-solid fa-envelope'
]
],
]);
} }
} }
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -506,34 +430,32 @@ if ($page == 'email_domain') {
try { try {
EmailAccounts::getLocal($userinfo, $_POST)->delete(); EmailAccounts::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'email_domain', 'page' => 'emails',
'domainid' => $email_domainid,
'action' => 'edit', 'action' => 'edit',
'id' => $id 'id' => $id,
]); 's' => $s
));
} else { } else {
HTML::askYesNoWithCheckbox('email_reallydelete_account', 'admin_customer_alsoremovemail', $filename, [ \Froxlor\UI\HTML::askYesNoWithCheckbox('email_reallydelete_account', 'admin_customer_alsoremovemail', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'domainid' => $email_domainid,
'action' => $action 'action' => $action
], $idna_convert->decode($result['email_full'])); ), $idna_convert->decode($result['email_full']));
} }
} }
} }
} elseif ($page == 'forwarders') { } elseif ($page == 'forwarders') {
$email_domainid = Request::any('domainid', 0);
if ($action == 'add' && $id != 0) { if ($action == 'add' && $id != 0) {
if ($userinfo['email_forwarders_used'] < $userinfo['email_forwarders'] || $userinfo['email_forwarders'] == '-1') { if ($userinfo['email_forwarders_used'] < $userinfo['email_forwarders'] || $userinfo['email_forwarders'] == '-1') {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -542,60 +464,37 @@ if ($page == 'email_domain') {
try { try {
EmailForwarders::getLocal($userinfo, $_POST)->add(); EmailForwarders::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'email_domain', 'page' => 'emails',
'domainid' => $email_domainid,
'action' => 'edit', 'action' => 'edit',
'id' => $id 'id' => $id,
]); 's' => $s
));
} else { } else {
$result['email_full'] = $idna_convert->decode($result['email_full']); $result['email_full'] = $idna_convert->decode($result['email_full']);
$result = PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$forwarder_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addforwarder.php'; $forwarder_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addforwarder.php';
$forwarder_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($forwarder_add_data);
UI::view('user/form.html.twig', [ $title = $forwarder_add_data['emails_addforwarder']['title'];
'formaction' => $linker->getLink(['section' => 'email', 'id' => $id]), $image = $forwarder_add_data['emails_addforwarder']['image'];
'formdata' => $forwarder_add_data['emails_addforwarder'],
'actions_links' => [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/forwarder_add") . "\";");
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid,
'action' => 'edit',
'id' => $id
]),
'label' => lng('emails.emails_edit'),
'icon' => 'fa-solid fa-pen'
],
[
'class' => 'btn-secondary',
'href' => $linker->getLink([
'section' => 'email',
'page' => 'email_domain',
'domainid' => $email_domainid
]),
'label' => lng('menue.email.emails'),
'icon' => 'fa-solid fa-envelope'
]
],
]);
} }
} }
} else { } else {
Response::standardError('allresourcesused'); \Froxlor\UI\Response::standard_error('allresourcesused');
} }
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Emails::getLocal($userinfo, [ $json_result = Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -617,22 +516,21 @@ if ($page == 'email_domain') {
try { try {
EmailForwarders::getLocal($userinfo, $_POST)->delete(); EmailForwarders::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'email_domain', 'page' => 'emails',
'domainid' => $email_domainid,
'action' => 'edit', 'action' => 'edit',
'id' => $id 'id' => $id,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('email_reallydelete_forwarder', $filename, [ \Froxlor\UI\HTML::askYesNo('email_reallydelete_forwarder', $filename, array(
'id' => $id, 'id' => $id,
'forwarderid' => $forwarderid, 'forwarderid' => $forwarderid,
'page' => $page, 'page' => $page,
'domainid' => $email_domainid,
'action' => $action 'action' => $action
], $idna_convert->decode($result['email_full']) . ' -> ' . $idna_convert->decode($forwarder)); ), $idna_convert->decode($result['email_full']) . ' -> ' . $idna_convert->decode($forwarder));
} }
} }
} }

View File

@@ -2,89 +2,93 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer'; use Froxlor\Settings;
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\CustomerBackups as CustomerBackups;
use Froxlor\Api\Commands\DirOptions as DirOptions; use Froxlor\Api\Commands\DirOptions as DirOptions;
use Froxlor\Api\Commands\DirProtections as DirProtections; use Froxlor\Api\Commands\DirProtections as DirProtections;
use Froxlor\Customer\Customer; use Froxlor\Api\Commands\CustomerBackups as CustomerBackups;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings;
use Froxlor\UI\Collection;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras')) { if (Settings::IsInList('panel.customer_hide_options', 'extras')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras");
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/extras") . "\";");
} elseif ($page == 'htpasswds') {
if ($page == 'overview' || $page == 'htpasswds') {
// redirect if this customer sub-page is hidden via settings // redirect if this customer sub-page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras.directoryprotection')) { if (Settings::IsInList('panel.customer_hide_options', 'extras.directoryprotection')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htpasswds"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htpasswds");
$fields = [ $fields = array(
'username' => lng('login.username'), 'username' => $lng['login']['username'],
'path' => lng('panel.path') 'path' => $lng['panel']['path']
]; );
try { try {
$htpasswd_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htpasswd.php'; // get total count
$collection = (new Collection(DirProtections::class, $userinfo)) $json_result = DirProtections::getLocal($userinfo)->listingCount();
->withPagination($htpasswd_list_data['htpasswd_list']['columns'], $htpasswd_list_data['htpasswd_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = DirProtections::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
$htpasswds = '';
foreach ($result['list'] as $row) {
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
}
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
eval("\$htpasswds.=\"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_htpasswd") . "\";");
$count ++;
} }
UI::view('user/table.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds") . "\";");
'listing' => Listing::format($collection, $htpasswd_list_data, 'htpasswd_list'),
'actions_links' => [
[
'href' => $linker->getLink(['section' => 'extras', 'page' => 'htpasswds', 'action' => 'add']),
'label' => lng('extras.directoryprotection_add')
]
],
'entity_info' => lng('extras.description')
]);
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = DirProtections::getLocal($userinfo, [ $json_result = DirProtections::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -93,21 +97,22 @@ if ($page == 'overview' || $page == 'htpasswds') {
try { try {
DirProtections::getLocal($userinfo, $_POST)->delete(); DirProtections::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
if (strpos($result['path'], $userinfo['documentroot']) === 0) { if (strpos($result['path'], $userinfo['documentroot']) === 0) {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']); $result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
} }
HTML::askYesNo('extras_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('extras_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['username'] . ' (' . $result['path'] . ')'); ), $result['username'] . ' (' . $result['path'] . ')');
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
@@ -115,28 +120,30 @@ if ($page == 'overview' || $page == 'htpasswds') {
try { try {
DirProtections::getLocal($userinfo, $_POST)->add(); DirProtections::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php'; $htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php';
$htpasswd_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($htpasswd_add_data);
UI::view('user/form.html.twig', [ $title = $htpasswd_add_data['htpasswd_add']['title'];
'formaction' => $linker->getLink(['section' => 'extras']), $image = $htpasswd_add_data['htpasswd_add']['image'];
'formdata' => $htpasswd_add_data['htpasswd_add']
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = DirProtections::getLocal($userinfo, [ $json_result = DirProtections::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -145,63 +152,90 @@ if ($page == 'overview' || $page == 'htpasswds') {
try { try {
DirProtections::getLocal($userinfo, $_POST)->update(); DirProtections::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
if (strpos($result['path'], $userinfo['documentroot']) === 0) { if (strpos($result['path'], $userinfo['documentroot']) === 0) {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']); $result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
} }
$result = PhpHelper::htmlentitiesArray($result);
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$htpasswd_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_edit.php'; $htpasswd_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_edit.php';
$htpasswd_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($htpasswd_edit_data);
UI::view('user/form.html.twig', [ $title = $htpasswd_edit_data['htpasswd_edit']['title'];
'formaction' => $linker->getLink(['section' => 'extras', 'id' => $id]), $image = $htpasswd_edit_data['htpasswd_edit']['image'];
'formdata' => $htpasswd_edit_data['htpasswd_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_edit") . "\";");
]);
} }
} }
} }
} elseif ($page == 'htaccess') { } elseif ($page == 'htaccess') {
// redirect if this customer sub-page is hidden via settings // redirect if this customer sub-page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras.pathoptions')) { if (Settings::IsInList('panel.customer_hide_options', 'extras.pathoptions')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess");
$fields = array(
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']); 'path' => $lng['panel']['path'],
'options_indexes' => $lng['extras']['view_directory'],
'error404path' => $lng['extras']['error404path'],
'error403path' => $lng['extras']['error403path'],
'error500path' => $lng['extras']['error500path'],
'options_cgi' => $lng['extras']['execute_perl']
);
try { try {
$htaccess_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htaccess.php'; // get total count
$collection = (new Collection(DirOptions::class, $userinfo)) $json_result = DirOptions::getLocal($userinfo)->listingCount();
->withPagination($htaccess_list_data['htaccess_list']['columns'], $htaccess_list_data['htaccess_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = DirOptions::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
$htaccess = '';
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
foreach ($result['list'] as $row) {
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
}
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
$row['options_indexes'] = str_replace('1', $lng['panel']['yes'], $row['options_indexes']);
$row['options_indexes'] = str_replace('0', $lng['panel']['no'], $row['options_indexes']);
$row['options_cgi'] = str_replace('1', $lng['panel']['yes'], $row['options_cgi']);
$row['options_cgi'] = str_replace('0', $lng['panel']['no'], $row['options_cgi']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
eval("\$htaccess.=\"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_htaccess") . "\";");
$count ++;
} }
UI::view('user/table.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess") . "\";");
'listing' => Listing::format($collection, $htaccess_list_data, 'htaccess_list'),
'actions_links' => [
[
'href' => $linker->getLink(['section' => 'extras', 'page' => 'htaccess', 'action' => 'add']),
'label' => lng('extras.pathoptions_add')
]
],
'entity_info' => lng('extras.description')
]);
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = DirOptions::getLocal($userinfo, [ $json_result = DirOptions::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -210,17 +244,18 @@ if ($page == 'overview' || $page == 'htpasswds') {
try { try {
DirOptions::getLocal($userinfo, $_POST)->delete(); DirOptions::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNo('extras_reallydelete_pathoptions', $filename, [ \Froxlor\UI\HTML::askYesNo('extras_reallydelete_pathoptions', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], str_replace($userinfo['documentroot'], '/', $result['path'])); ), str_replace($userinfo['documentroot'], '/', $result['path']));
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
@@ -228,29 +263,31 @@ if ($page == 'overview' || $page == 'htpasswds') {
try { try {
DirOptions::getLocal($userinfo, $_POST)->add(); DirOptions::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']); $cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
$htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php'; $htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php';
$htaccess_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($htaccess_add_data);
UI::view('user/form.html.twig', [ $title = $htaccess_add_data['htaccess_add']['title'];
'formaction' => $linker->getLink(['section' => 'extras']), $image = $htaccess_add_data['htaccess_add']['image'];
'formdata' => $htaccess_add_data['htaccess_add']
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_add") . "\";");
} }
} elseif (($action == 'edit') && ($id != 0)) { } elseif (($action == 'edit') && ($id != 0)) {
try { try {
$json_result = DirOptions::getLocal($userinfo, [ $json_result = DirOptions::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -259,86 +296,106 @@ if ($page == 'overview' || $page == 'htpasswds') {
try { try {
DirOptions::getLocal($userinfo, $_POST)->update(); DirOptions::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
if (strpos($result['path'], $userinfo['documentroot']) === 0) { if (strpos($result['path'], $userinfo['documentroot']) === 0) {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']); $result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
} }
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']);
$result = PhpHelper::htmlentitiesArray($result); $result['error404path'] = $result['error404path'];
$result['error403path'] = $result['error403path'];
$result['error500path'] = $result['error500path'];
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
/*
* $options_indexes = \Froxlor\UI\HTML::makeyesno('options_indexes', '1', '0', $result['options_indexes']);
* $options_cgi = \Froxlor\UI\HTML::makeyesno('options_cgi', '1', '0', $result['options_cgi']);
*/
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$htaccess_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_edit.php'; $htaccess_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_edit.php';
$htaccess_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($htaccess_edit_data);
UI::view('user/form.html.twig', [ $title = $htaccess_edit_data['htaccess_edit']['title'];
'formaction' => $linker->getLink(['section' => 'extras', 'id' => $id]), $image = $htaccess_edit_data['htaccess_edit']['image'];
'formdata' => $htaccess_edit_data['htaccess_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_edit") . "\";");
]);
} }
} }
} }
} elseif ($page == 'backup') { } elseif ($page == 'backup') {
// redirect if this customer sub-page is hidden via settings // redirect if this customer sub-page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras.backup')) { if (Settings::IsInList('panel.customer_hide_options', 'extras.backup')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
if (Settings::Get('system.backupenabled') == 1) { if (Settings::Get('system.backupenabled') == 1) {
if ($action == 'abort') { if ($action == 'abort' && isset($_POST['send']) && $_POST['send'] == 'send') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob");
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob"); try {
try { CustomerBackups::getLocal($userinfo, $_POST)->delete();
CustomerBackups::getLocal($userinfo, $_POST)->delete(); } catch (Exception $e) {
} catch (Exception $e) { \Froxlor\UI\Response::dynamic_error($e->getMessage());
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page,
'action' => ''
]);
} else {
HTML::askYesNo('extras_reallydelete_backup', $filename, [
'backup_job_entry' => $id,
'section' => 'extras',
'page' => $page,
'action' => $action
]);
} }
} elseif ($action == '') { \Froxlor\UI\Response::standard_success('backupaborted');
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup"); \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page,
'action' => '',
's' => $s
));
}
if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup");
// check whether there is a backup-job for this customer // check whether there is a backup-job for this customer
try { try {
$backup_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.backups.php'; $json_result = CustomerBackups::getLocal($userinfo)->listing();
$collection = (new Collection(CustomerBackups::class, $userinfo));
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$existing_backupJob = null;
if ($result['count'] > 0) {
$existing_backupJob = array_shift($result['list']);
} }
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
CustomerBackups::getLocal($userinfo, $_POST)->add(); CustomerBackups::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::standardSuccess('backupscheduled'); \Froxlor\UI\Response::standard_success('backupscheduled');
} else { } else {
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
UI::view('user/form-datatable.html.twig', [ if (! empty($existing_backupJob)) {
'formaction' => $linker->getLink(['section' => 'extras']), $action = "abort";
'formdata' => $backup_data['backup'], $row = $existing_backupJob['data'];
'tabledata' => Listing::format($collection, $backup_list_data, 'backup_list'),
]); $row['path'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['destdir']));
$row['backup_web'] = ($row['backup_web'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_mail'] = ($row['backup_mail'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_dbs'] = ($row['backup_dbs'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
}
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
$backup_form = \Froxlor\UI\HtmlForm::genHTMLForm($backup_data);
$title = $backup_data['backup']['title'];
$image = $backup_data['backup']['image'];
if (! empty($existing_backupJob)) {
// overwrite backup_form after we took everything from it we needed
eval("\$backup_form = \"" . \Froxlor\UI\Template::getTemplate("extras/backup_listexisting") . "\";");
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/backup") . "\";");
} }
} }
} else { } else {
Response::standardError('backupfunctionnotenabled'); \Froxlor\UI\Response::standard_error('backupfunctionnotenabled');
} }
} }

View File

@@ -2,83 +2,90 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Ftps as Ftps;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection; use Froxlor\Api\Commands\Ftps as Ftps;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\CurrentUser;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'ftp')) { if (Settings::IsInList('panel.customer_hide_options', 'ftp')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
$id = (int)Request::any('id', 0); $id = 0;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'overview' || $page == 'accounts') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp");
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/ftp') . "\";");
} elseif ($page == 'accounts') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts");
$fields = array(
'username' => $lng['login']['username'],
'homedir' => $lng['panel']['path'],
'description' => $lng['panel']['ftpdesc']
);
try { try {
$ftp_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.ftps.php'; // get total count
$collection = (new Collection(Ftps::class, $userinfo)) $json_result = Ftps::getLocal($userinfo)->listingCount();
->withPagination($ftp_list_data['ftp_list']['columns'], $ftp_list_data['ftp_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Ftps::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$ftps_count = $paging->getEntries();
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
$accounts = '';
foreach ($result['list'] as $row) {
if (strpos($row['homedir'], $userinfo['documentroot']) === 0) {
$row['documentroot'] = str_replace($userinfo['documentroot'], "/", $row['homedir']);
} else {
$row['documentroot'] = $row['homedir'];
}
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir($row['documentroot']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_account') . "\";");
$count ++;
} }
$actions_links = false; eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts') . "\";");
if (CurrentUser::canAddResource('ftps')) {
$actions_links = [
[
'href' => $linker->getLink(['section' => 'ftp', 'page' => 'accounts', 'action' => 'add']),
'label' => lng('ftp.account_add')
]
];
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $ftp_list_data, 'ftp_list'),
'actions_links' => $actions_links,
'entity_info' => lng('ftp.description')
]);
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Ftps::getLocal($userinfo, [ $json_result = Ftps::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -87,20 +94,21 @@ if ($page == 'overview' || $page == 'accounts') {
try { try {
Ftps::getLocal($userinfo, $_POST)->delete(); Ftps::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
HTML::askYesNoWithCheckbox('ftp_reallydelete', 'admin_customer_alsoremoveftphomedir', $filename, [ \Froxlor\UI\HTML::askYesNoWithCheckbox('ftp_reallydelete', 'admin_customer_alsoremoveftphomedir', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $result['username']); ), $result['username']);
} }
} else { } else {
Response::standardError('ftp_cantdeletemainaccount'); \Froxlor\UI\Response::standard_error('ftp_cantdeletemainaccount');
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if ($userinfo['ftps_used'] < $userinfo['ftps'] || $userinfo['ftps'] == '-1') { if ($userinfo['ftps_used'] < $userinfo['ftps'] || $userinfo['ftps'] == '-1') {
@@ -108,54 +116,68 @@ if ($page == 'overview' || $page == 'accounts') {
try { try {
Ftps::getLocal($userinfo, $_POST)->add(); Ftps::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/'); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/');
if (Settings::Get('customer.ftpatdomain') == '1') { if (Settings::Get('customer.ftpatdomain') == '1') {
$domainlist = []; $domainlist = array();
$domains = '';
$result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` $result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid`= :customerid ORDER BY `domain` ASC"); WHERE `customerid`= :customerid");
Database::pexecute($result_domains_stmt, [ Database::pexecute($result_domains_stmt, array(
"customerid" => $userinfo['customerid'] "customerid" => $userinfo['customerid']
]); ));
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domainlist[$row_domain['domain']] = $idna_convert->decode($row_domain['domain']); $domainlist[] = $row_domain['domain'];
} }
}
if (Settings::Get('system.allow_customer_shell') == '1') { sort($domainlist);
$shells['/bin/false'] = "/bin/false";
$shells_avail = Settings::Get('system.available_shells'); if (isset($domainlist[0]) && $domainlist[0] != '') {
if (!empty($shells_avail)) { foreach ($domainlist as $dom) {
$shells_avail_arr = explode(",", $shells_avail); $domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($dom), $dom);
$shells_avail_arr = array_map("trim", $shells_avail_arr);
foreach ($shells_avail_arr as $shell) {
$shells[$shell] = $shell;
} }
} }
} }
$ftp_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_add.php'; if (Settings::Get('system.allow_customer_shell') == '1') {
$shells = \Froxlor\UI\HTML::makeoption("/bin/false", "/bin/false", "/bin/false");
$shells_avail = Settings::Get('system.available_shells');
if (! empty($shells_avail)) {
$shells_avail = explode(",", $shells_avail);
$shells_avail = array_map("trim", $shells_avail);
foreach ($shells_avail as $_shell) {
$shells .= \Froxlor\UI\HTML::makeoption($_shell, $_shell, "/bin/false");
}
}
}
UI::view('user/form.html.twig', [ // $sendinfomail = \Froxlor\UI\HTML::makeyesno('sendinfomail', '1', '0', '0');
'formaction' => $linker->getLink(['section' => 'ftp']),
'formdata' => $ftp_add_data['ftp_add'] $ftp_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_add.php';
]); $ftp_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($ftp_add_data);
$title = $ftp_add_data['ftp_add']['title'];
$image = $ftp_add_data['ftp_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_add') . "\";");
} }
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = Ftps::getLocal($userinfo, [ $json_result = Ftps::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -164,40 +186,55 @@ if ($page == 'overview' || $page == 'accounts') {
try { try {
Ftps::getLocal($userinfo, $_POST)->update(); Ftps::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
if (strpos($result['homedir'], $userinfo['documentroot']) === 0) { if (strpos($result['homedir'], $userinfo['documentroot']) === 0) {
$homedir = str_replace($userinfo['documentroot'], "/", $result['homedir']); $homedir = str_replace($userinfo['documentroot'], "/", $result['homedir']);
} else { } else {
$homedir = $result['homedir']; $homedir = $result['homedir'];
} }
$homedir = FileDir::makeCorrectDir($homedir); $homedir = \Froxlor\FileDir::makeCorrectDir($homedir);
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir); $pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir);
if (Settings::Get('customer.ftpatdomain') == '1') {
$domains = '';
$result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid");
Database::pexecute($result_domains_stmt, array(
"customerid" => $userinfo['customerid']
));
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']);
}
}
if (Settings::Get('system.allow_customer_shell') == '1') { if (Settings::Get('system.allow_customer_shell') == '1') {
$shells['/bin/false'] = "/bin/false"; $shells = \Froxlor\UI\HTML::makeoption("/bin/false", "/bin/false", $result['shell']);
$shells_avail = Settings::Get('system.available_shells'); $shells_avail = Settings::Get('system.available_shells');
if (!empty($shells_avail)) { if (! empty($shells_avail)) {
$shells_avail_arr = explode(",", $shells_avail); $shells_avail = explode(",", $shells_avail);
$shells_avail_arr = array_map("trim", $shells_avail_arr); $shells_avail = array_map("trim", $shells_avail);
foreach ($shells_avail_arr as $shell) { foreach ($shells_avail as $_shell) {
$shells[$shell] = $shell; $shells .= \Froxlor\UI\HTML::makeoption($_shell, $_shell, $result['shell']);
} }
} }
} }
$ftp_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_edit.php'; $ftp_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_edit.php';
$ftp_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($ftp_edit_data);
UI::view('user/form.html.twig', [ $title = $ftp_edit_data['ftp_edit']['title'];
'formaction' => $linker->getLink(['section' => 'ftp', 'id' => $id]), $image = $ftp_edit_data['ftp_edit']['image'];
'formdata' => $ftp_edit_data['ftp_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_edit') . "\";");
]);
} }
} }
} }

View File

@@ -2,86 +2,71 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Customers as Customers;
use Froxlor\CurrentUser;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Froxlor;
use Froxlor\FroxlorLogger;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\System\Crypt; use Froxlor\Api\Commands\Customers as Customers;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
use Froxlor\Validate\Validate;
use Froxlor\Language;
use Froxlor\System\Cronjob;
use Froxlor\Cron\TaskId;
if ($action == 'logout') { if ($action == 'logout') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, 'logged out'); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, 'logged out');
unset($_SESSION['userinfo']); $params = array(
CurrentUser::setData(); "customerid" => $userinfo['customerid']
session_destroy(); );
if (Settings::Get('session.allow_multiple_login') == '1') {
Response::redirectTo('index.php'); $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
} elseif ($action == 'suback') { WHERE `userid` = :customerid
if (is_array(CurrentUser::getField('switched_user'))) { AND `adminsession` = '0'
$result = CurrentUser::getData(); AND `hash` = :hash");
$result = $result['switched_user']; $params["hash"] = $s;
CurrentUser::setData($result);
$target = (isset($_GET['target']) ? $_GET['target'] : 'index');
$redirect = "admin_" . $target . ".php";
if (!file_exists(Froxlor::getInstallDir() . "/" . $redirect)) {
$redirect = "admin_index.php";
}
Response::redirectTo($redirect, null, true);
} else { } else {
Response::dynamicError("Cannot change back - You've never switched to another user :-)"); $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :customerid
AND `adminsession` = '0'");
} }
Database::pexecute($stmt, $params);
\Froxlor\UI\Response::redirectTo('index.php');
} }
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_index"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_index");
$domain_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` $domain_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `parentdomainid` = '0' AND `parentdomainid` = '0'
AND `id` <> :standardsubdomain AND `id` <> :standardsubdomain
"); ");
Database::pexecute($domain_stmt, [ Database::pexecute($domain_stmt, array(
"customerid" => $userinfo['customerid'], "customerid" => $userinfo['customerid'],
"standardsubdomain" => $userinfo['standardsubdomain'] "standardsubdomain" => $userinfo['standardsubdomain']
]); ));
$domains = '';
$domainArray = array();
$domainArray = [];
while ($row = $domain_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $domain_stmt->fetch(PDO::FETCH_ASSOC)) {
$domainArray[] = $idna_convert->decode($row['domain']); $domainArray[] = $idna_convert->decode($row['domain']);
} }
natsort($domainArray); natsort($domainArray);
$domains = implode(',<br />', $domainArray);
// standard-subdomain // standard-subdomain
$stdsubdomain = ''; $stdsubdomain = '';
@@ -91,10 +76,10 @@ if ($page == 'overview') {
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `id` = :standardsubdomain AND `id` = :standardsubdomain
"); ");
$std_domain = Database::pexecute_first($std_domain_stmt, [ $std_domain = Database::pexecute_first($std_domain_stmt, array(
"customerid" => $userinfo['customerid'], "customerid" => $userinfo['customerid'],
"standardsubdomain" => $userinfo['standardsubdomain'] "standardsubdomain" => $userinfo['standardsubdomain']
]); ));
$stdsubdomain = $std_domain['domain']; $stdsubdomain = $std_domain['domain'];
} }
@@ -104,171 +89,292 @@ if ($page == 'overview') {
// get disk-space usages for web, mysql and mail // get disk-space usages for web, mysql and mail
$usages_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "` WHERE `customerid` = :cid ORDER BY `stamp` DESC LIMIT 1"); $usages_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "` WHERE `customerid` = :cid ORDER BY `stamp` DESC LIMIT 1");
$usages = Database::pexecute_first($usages_stmt, [ $usages = Database::pexecute_first($usages_stmt, array(
'cid' => $userinfo['customerid'] 'cid' => $userinfo['customerid']
]); ));
// get everything in bytes for the percentage calculation on the dashboard // get everything in bytes for the percentage calculation on the dashboard
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1; $userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1;
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : -1; $userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : - 1;
$userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024; $userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024;
if ($usages) { if ($usages) {
$userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi');
$userinfo['mailspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mail'] * 1024, null, 'bi');
$userinfo['dbspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mysql'] * 1024, null, 'bi');
$userinfo['total_used'] = \Froxlor\PhpHelper::sizeReadable(($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024, null, 'bi');
$userinfo['diskspace_bytes_used'] = $usages['webspace'] * 1024; $userinfo['diskspace_bytes_used'] = $usages['webspace'] * 1024;
$userinfo['mailspace_used'] = $usages['mail'] * 1024;
$userinfo['dbspace_used'] = $usages['mysql'] * 1024;
$userinfo['total_bytes_used'] = ($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024; $userinfo['total_bytes_used'] = ($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024;
} else { } else {
$userinfo['diskspace_used'] = 0;
$userinfo['mailspace_used'] = 0;
$userinfo['dbspace_used'] = 0;
$userinfo['total_used'] = 0;
$userinfo['diskspace_bytes_used'] = 0; $userinfo['diskspace_bytes_used'] = 0;
$userinfo['total_bytes_used'] = 0; $userinfo['total_bytes_used'] = 0;
$userinfo['mailspace_used'] = 0;
$userinfo['dbspace_used'] = 0;
} }
$userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1;
$userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1;
$userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi');
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace diskspace_bytes traffic traffic_bytes mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
UI::twig()->addGlobal('userinfo', $userinfo); $userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
UI::view('user/index.html.twig', [
'domains' => $domainArray, $services_enabled = "";
'stdsubdomain' => $stdsubdomain $se = array();
]); if ($userinfo['imap'] == '1')
$se[] = "IMAP";
if ($userinfo['pop3'] == '1')
$se[] = "POP3";
if ($userinfo['phpenabled'] == '1')
$se[] = "PHP";
if ($userinfo['perlenabled'] == '1')
$se[] = "Perl/CGI";
if ($userinfo['api_allowed'] == '1')
$se[] = '<a href="customer_index.php?s=' . $s . '&page=apikeys">API</a>';
$services_enabled = implode(", ", $se);
eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/index') . "\";");
} elseif ($page == 'change_password') { } elseif ($page == 'change_password') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$old_password = Validate::validate($_POST['old_password'], 'old password');
if (!Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) { if (isset($_POST['send']) && $_POST['send'] == 'send') {
Response::standardError('oldpasswordnotcorrect'); $old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password');
if (! \Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) {
\Froxlor\UI\Response::standard_error('oldpasswordnotcorrect');
} }
try { try {
$new_password = Crypt::validatePassword($_POST['new_password'], 'new password'); $new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password');
$new_password_confirm = Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm'); $new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
if ($old_password == '') { if ($old_password == '') {
Response::standardError([ \Froxlor\UI\Response::standard_error(array(
'stringisempty', 'stringisempty',
'changepassword.old_password' 'oldpassword'
]); ));
} elseif ($new_password == '') { } elseif ($new_password == '') {
Response::standardError([ \Froxlor\UI\Response::standard_error(array(
'stringisempty', 'stringisempty',
'changepassword.new_password' 'newpassword'
]); ));
} elseif ($new_password_confirm == '') { } elseif ($new_password_confirm == '') {
Response::standardError([ \Froxlor\UI\Response::standard_error(array(
'stringisempty', 'stringisempty',
'changepassword.new_password_confirm' 'newpasswordconfirm'
]); ));
} elseif ($new_password != $new_password_confirm) { } elseif ($new_password != $new_password_confirm) {
Response::standardError('newpasswordconfirmerror'); \Froxlor\UI\Response::standard_error('newpasswordconfirmerror');
} else { } else {
// Update user password // Update user password
try { try {
Customers::getLocal($userinfo, [ Customers::getLocal($userinfo, array(
'id' => $userinfo['customerid'], 'id' => $userinfo['customerid'],
'new_customer_password' => $new_password 'new_customer_password' => $new_password
])->update(); ))->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed password'); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed password');
// Update ftp password // Update ftp password
if (isset($_POST['change_main_ftp']) && $_POST['change_main_ftp'] == 'true') { if (isset($_POST['change_main_ftp']) && $_POST['change_main_ftp'] == 'true') {
$cryptPassword = Crypt::makeCryptPassword($new_password); $cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($new_password);
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "` $stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
SET `password` = :password SET `password` = :password
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `username` = :username"); AND `username` = :username");
$params = [ $params = array(
"password" => $cryptPassword, "password" => $cryptPassword,
"customerid" => $userinfo['customerid'], "customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname'] "username" => $userinfo['loginname']
]; );
Database::pexecute($stmt, $params); Database::pexecute($stmt, $params);
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed main ftp password'); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed main ftp password');
} }
// Update statistics password // Update statistics password
if (isset($_POST['change_stats']) && $_POST['change_stats'] == 'true') { if (isset($_POST['change_stats']) && $_POST['change_stats'] == 'true') {
$new_stats_password = Crypt::makeCryptPassword($new_password, true); $new_stats_password = \Froxlor\System\Crypt::makeCryptPassword($new_password, true);
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTPASSWDS . "` $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTPASSWDS . "`
SET `password` = :password SET `password` = :password
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `username` = :username"); AND `username` = :username");
$params = [ $params = array(
"password" => $new_stats_password, "password" => $new_stats_password,
"customerid" => $userinfo['customerid'], "customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname'] "username" => $userinfo['loginname']
]; );
Database::pexecute($stmt, $params); Database::pexecute($stmt, $params);
Cronjob::inserttask(TaskId::REBUILD_VHOST);
} }
Response::redirectTo($filename); \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} }
} else { } else {
UI::view('user/change_password.html.twig'); eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/change_password') . "\";");
} }
} elseif ($page == 'change_language') { } elseif ($page == 'change_language') {
$languages = Language::getLanguages();
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$def_language = Validate::validate($_POST['def_language'], 'default language'); $def_language = \Froxlor\Validate\Validate::validate($_POST['def_language'], 'default language');
if (isset($languages[$def_language])) { if (isset($languages[$def_language])) {
try { try {
Customers::getLocal($userinfo, [ Customers::getLocal($userinfo, array(
'id' => $userinfo['customerid'], 'id' => $userinfo['customerid'],
'def_language' => $def_language 'def_language' => $def_language
])->update(); ))->update();
CurrentUser::setField('language', $def_language);
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
// also update current session
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `language` = :lang
WHERE `hash` = :hash");
Database::pexecute($stmt, array(
"lang" => $def_language,
"hash" => $s
));
} }
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
Response::redirectTo($filename); \Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} else { } else {
$default_lang = Settings::Get('panel.standardlanguage'); $default_lang = Settings::Get('panel.standardlanguage');
if ($userinfo['def_language'] != '') { if ($userinfo['def_language'] != '') {
$default_lang = $userinfo['def_language']; $default_lang = $userinfo['def_language'];
} }
UI::view('user/change_language.html.twig', [ $language_options = '';
'languages' => $languages, foreach ($languages as $language_file => $language_name) {
'default_lang' => $default_lang $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $default_lang, true);
]); }
eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/change_language') . "\";");
} }
} elseif ($page == 'change_theme') { } elseif ($page == 'change_theme') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$theme = Validate::validate($_POST['theme'], 'theme'); $theme = \Froxlor\Validate\Validate::validate($_POST['theme'], 'theme');
try { try {
Customers::getLocal($userinfo, [ Customers::getLocal($userinfo, array(
'id' => $userinfo['customerid'], 'id' => $userinfo['customerid'],
'theme' => $theme 'theme' => $theme
])->update(); ))->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'"); // also update current session
Response::redirectTo($filename); $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `theme` = :theme
WHERE `hash` = :hash");
Database::pexecute($stmt, array(
"theme" => $theme,
"hash" => $s
));
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'");
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
} else { } else {
$default_theme = Settings::Get('panel.default_theme'); $default_theme = Settings::Get('panel.default_theme');
if ($userinfo['theme'] != '') { if ($userinfo['theme'] != '') {
$default_theme = $userinfo['theme']; $default_theme = $userinfo['theme'];
} }
$themes_avail = UI::getThemes(); $theme_options = '';
$themes_avail = \Froxlor\UI\Template::getThemes();
foreach ($themes_avail as $t => $d) {
$theme_options .= \Froxlor\UI\HTML::makeoption($d, $t, $default_theme, true);
}
UI::view('user/change_theme.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/change_theme') . "\";");
'themes' => $themes_avail,
'default_theme' => $default_theme
]);
} }
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_customer') == '1') { } elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_customer') == '1') {
require_once __DIR__ . '/error_report.php';
// only show this if we really have an exception to report
if (isset($_GET['errorid']) && $_GET['errorid'] != '') {
$errid = $_GET['errorid'];
// read error file
$err_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . "/logs/");
$err_file = \Froxlor\FileDir::makeCorrectFile($err_dir . "/" . $errid . "_sql-error.log");
if (file_exists($err_file)) {
$error_content = file_get_contents($err_file);
$error = explode("|", $error_content);
$_error = array(
'code' => str_replace("\n", "", substr($error[1], 5)),
'message' => str_replace("\n", "", substr($error[2], 4)),
'file' => str_replace("\n", "", substr($error[3], 5 + strlen(\Froxlor\Froxlor::getInstallDir()))),
'line' => str_replace("\n", "", substr($error[4], 5)),
'trace' => str_replace(\Froxlor\Froxlor::getInstallDir(), "", substr($error[5], 6))
);
// build mail-content
$mail_body = "Dear froxlor-team,\n\n";
$mail_body .= "the following error has been reported by a user:\n\n";
$mail_body .= "-------------------------------------------------------------\n";
$mail_body .= $_error['code'] . ' ' . $_error['message'] . "\n\n";
$mail_body .= "File: " . $_error['file'] . ':' . $_error['line'] . "\n\n";
$mail_body .= "Trace:\n" . trim($_error['trace']) . "\n\n";
$mail_body .= "-------------------------------------------------------------\n\n";
$mail_body .= "Froxlor-version: " . $version . "\n";
$mail_body .= "DB-version: " . $dbversion . "\n\n";
$mail_body .= "End of report";
$mail_html = str_replace("\n", "<br />", $mail_body);
// send actual report to dev-team
if (isset($_POST['send']) && $_POST['send'] == 'send') {
// send mail and say thanks
$_mailerror = false;
try {
$mail->Subject = '[Froxlor] Error report by user';
$mail->AltBody = $mail_body;
$mail->MsgHTML($mail_html);
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
$mail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
// error when reporting an error...LOLFUQ
\Froxlor\UI\Response::standard_error('send_report_error', $mailerr_msg);
}
// finally remove error from fs
@unlink($err_file);
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
}
// show a nice summary of the error-report
// before actually sending anything
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/send_error_report") . "\";");
} else {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
}
} else {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s
));
}
} elseif ($page == 'apikeys' && Settings::Get('api.enabled') == 1) { } elseif ($page == 'apikeys' && Settings::Get('api.enabled') == 1) {
require_once __DIR__ . '/api_keys.php'; require_once __DIR__ . '/api_keys.php';
} elseif ($page == '2fa' && Settings::Get('2fa.enabled') == 1) { } elseif ($page == '2fa' && Settings::Get('2fa.enabled') == 1) {

View File

@@ -2,53 +2,119 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
const AREA = 'customer'; require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SysLog; use Froxlor\Api\Commands\SysLog;
use Froxlor\Database\Database;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) { if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
if ($page == 'log') { if ($page == 'log') {
if ($action == '') { if ($action == '') {
$fields = array(
'date' => $lng['logger']['date'],
'type' => $lng['logger']['type'],
'user' => $lng['logger']['user'],
'text' => $lng['logger']['action']
);
try { try {
$syslog_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.syslog.php'; // get total count
$collection = (new Collection(SysLog::class, $userinfo)) $json_result = SysLog::getLocal($userinfo)->listingCount();
->withPagination($syslog_list_data['syslog_list']['columns'], $syslog_list_data['syslog_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
UI::view('user/table.html.twig', [ $result = json_decode($json_result, true)['data'];
'listing' => Listing::format($collection, $syslog_list_data, 'syslog_list') $sortcode = $paging->getHtmlSortCode($lng);
]); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$clog = array();
foreach ($result['list'] as $row) {
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
$clog[$row['action']] = array();
}
$clog[$row['action']][$row['logid']] = $row;
}
if ($paging->sortfield == 'date' && $paging->sortorder == 'desc') {
krsort($clog);
} else {
ksort($clog);
}
$count = 0;
$log_count = 0;
$log = '';
foreach ($clog as $action => $logrows) {
$_action = 0;
foreach ($logrows as $row) {
// if ($paging->checkDisplay($i)) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$row['date'] = date("d.m.y H:i:s", $row['date']);
if ($_action != $action) {
switch ($action) {
case \Froxlor\FroxlorLogger::USR_ACTION:
$_action = $lng['admin']['customer'];
break;
case \Froxlor\FroxlorLogger::RES_ACTION:
$_action = $lng['logger']['reseller'];
break;
case \Froxlor\FroxlorLogger::ADM_ACTION:
$_action = $lng['logger']['admin'];
break;
case \Froxlor\FroxlorLogger::CRON_ACTION:
$_action = $lng['logger']['cron'];
break;
case \Froxlor\FroxlorLogger::LOGIN_ACTION:
$_action = $lng['logger']['login'];
break;
case \Froxlor\FroxlorLogger::LOG_ERROR:
$_action = $lng['logger']['intern'];
break;
default:
$_action = $lng['logger']['unknown'];
break;
}
$row['action'] = $_action;
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_action') . "\";");
}
$log_count ++;
$row['type'] = \Froxlor\FroxlorLogger::getInstanceOf()->getLogLevelDesc($row['type']);
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";");
$count ++;
$_action = $action;
}
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";");
} }
} }

View File

@@ -2,46 +2,30 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Mysqls;
use Froxlor\Api\Commands\MysqlServer;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Collection; use Froxlor\Api\Commands\Mysqls as Mysqls;
use Froxlor\UI\HTML;
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\CurrentUser;
// redirect if this customer page is hidden via settings or no resources given // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'mysql') || $userinfo['mysqls'] == 0) { if (Settings::IsInList('panel.customer_hide_options', 'mysql')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
// get sql-root access data // get sql-root access data
@@ -50,54 +34,90 @@ Database::needSqlData();
$sql_root = Database::getSqlData(); $sql_root = Database::getSqlData();
Database::needRoot(false); Database::needRoot(false);
$id = (int)Request::any('id'); if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'overview' || $page == 'mysqls') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql");
Database::needSqlData();
$sql = Database::getSqlData();
$lng['mysql']['description'] = str_replace('<SQL_HOST>', $sql['host'], $lng['mysql']['description']);
eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysql') . "\";");
} elseif ($page == 'mysqls') {
if ($action == '') { if ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
$fields = array(
$multiple_mysqlservers = count(json_decode($userinfo['allowed_mysqlserver'] ?? '[]', true)) > 1; 'databasename' => $lng['mysql']['databasename'],
'description' => $lng['mysql']['databasedescription']
);
try { try {
$mysql_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.mysqls.php'; // get total count
$collection = (new Collection(Mysqls::class, $userinfo)) $json_result = Mysqls::getLocal($userinfo)->listingCount();
->withPagination($mysql_list_data['mysql_list']['columns'], $mysql_list_data['mysql_list']['default_sorting']); $result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Mysqls::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data'];
$actions_links = false; $mysqls_count = $paging->getEntries();
if (CurrentUser::canAddResource('mysqls')) { $sortcode = $paging->getHtmlSortCode($lng);
$actions_links = [ $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
[ $searchcode = $paging->getHtmlSearchCode($lng);
'href' => $linker->getLink(['section' => 'mysql', 'page' => 'mysqls', 'action' => 'add']), $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
'label' => lng('mysql.database_create') $count = 0;
] $mysqls = '';
];
$dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `" . TABLE_PANEL_DATABASES . "`");
$dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC);
$count_mysqlservers = $dbserver['numservers'];
// Begin root-session
Database::needRoot(true);
foreach ($result['list'] as $row) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$mbdata_stmt = Database::prepare("SELECT SUM(data_length + index_length) as MB FROM information_schema.TABLES
WHERE table_schema = :table_schema
GROUP BY table_schema");
$mbdata = Database::pexecute_first($mbdata_stmt, array(
"table_schema" => $row['databasename']
));
if (!$mbdata) {
$mbdata = array('MB' => 0);
}
$row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";");
$count ++;
} }
Database::needRoot(false);
// End root-session
UI::view('user/table.html.twig', [ eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls') . "\";");
'listing' => Listing::format($collection, $mysql_list_data, 'mysql_list'),
'actions_links' => $actions_links,
'entity_info' => lng('mysql.description')
]);
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { try {
$json_result = Mysqls::getLocal($userinfo, [ $json_result = Mysqls::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
if (isset($result['databasename']) && $result['databasename'] != '') { if (isset($result['databasename']) && $result['databasename'] != '') {
Database::needRoot(true, $result['dbserver'], false);
Database::needRoot(true, $result['dbserver']);
Database::needSqlData(); Database::needSqlData();
$sql_root = Database::getSqlData(); $sql_root = Database::getSqlData();
Database::needRoot(false); Database::needRoot(false);
if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) { if (! isset($sql_root[$result['dbserver']]) || ! is_array($sql_root[$result['dbserver']])) {
$result['dbserver'] = 0; $result['dbserver'] = 0;
} }
@@ -105,21 +125,22 @@ if ($page == 'overview' || $page == 'mysqls') {
try { try {
Mysqls::getLocal($userinfo, $_POST)->delete(); Mysqls::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$dbnamedesc = $result['databasename']; $dbnamedesc = $result['databasename'];
if (isset($result['description']) && $result['description'] != '') { if (isset($result['description']) && $result['description'] != '') {
$dbnamedesc .= ' (' . $result['description'] . ')'; $dbnamedesc .= ' (' . $result['description'] . ')';
} }
HTML::askYesNo('mysql_reallydelete', $filename, [ \Froxlor\UI\HTML::askYesNo('mysql_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
], $dbnamedesc); ), $dbnamedesc);
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
@@ -128,38 +149,42 @@ if ($page == 'overview' || $page == 'mysqls') {
try { try {
Mysqls::getLocal($userinfo, $_POST)->add(); Mysqls::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$mysql_servers = [];
try { $dbservers_stmt = Database::query("SELECT DISTINCT `dbserver` FROM `" . TABLE_PANEL_DATABASES . "`");
$result_json = MysqlServer::getLocal($userinfo)->listing(); $mysql_servers = '';
$result_decoded = json_decode($result_json, true)['data']['list']; $count_mysqlservers = 0;
foreach ($result_decoded as $dbserver => $dbdata) { while ($dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC)) {
$mysql_servers[$dbserver] = $dbdata['caption']; Database::needRoot(true, $dbserver['dbserver']);
} Database::needSqlData();
} catch (Exception $e) { $sql_root = Database::getSqlData();
/* just none */ $mysql_servers .= \Froxlor\UI\HTML::makeoption($sql_root['caption'], $dbserver['dbserver']);
$count_mysqlservers ++;
} }
Database::needRoot(false);
$mysql_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_add.php'; $mysql_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_add.php';
$mysql_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($mysql_add_data);
UI::view('user/form.html.twig', [ $title = $mysql_add_data['mysql_add']['title'];
'formaction' => $linker->getLink(['section' => 'mysql']), $image = $mysql_add_data['mysql_add']['image'];
'formdata' => $mysql_add_data['mysql_add']
]); eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_add') . "\";");
} }
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { try {
$json_result = Mysqls::getLocal($userinfo, [ $json_result = Mysqls::getLocal($userinfo, array(
'id' => $id 'id' => $id
])->get(); ))->get();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
@@ -168,30 +193,30 @@ if ($page == 'overview' || $page == 'mysqls') {
try { try {
$json_result = Mysqls::getLocal($userinfo, $_POST)->update(); $json_result = Mysqls::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
Response::redirectTo($filename, [ \Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page 'page' => $page,
]); 's' => $s
));
} else { } else {
$mysql_servers = [];
try { $dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `" . TABLE_PANEL_DATABASES . "`");
$result_json = MysqlServer::getLocal($userinfo)->listing(); $dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC);
$result_decoded = json_decode($result_json, true)['data']['list']; $count_mysqlservers = $dbserver['numservers'];
foreach ($result_decoded as $dbserver => $dbdata) {
$mysql_servers[$dbserver] = $dbdata['caption'] . ' (' . $dbdata['host'] . (isset($dbdata['port']) && !empty($dbdata['port']) ? ':' . $dbdata['port'] : '').')'; Database::needRoot(true, $result['dbserver']);
} Database::needSqlData();
} catch (Exception $e) { $sql_root = Database::getSqlData();
/* just none */ Database::needRoot(false);
}
$mysql_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_edit.php'; $mysql_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_edit.php';
$mysql_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($mysql_edit_data);
UI::view('user/form.html.twig', [ $title = $mysql_edit_data['mysql_edit']['title'];
'formaction' => $linker->getLink(['section' => 'mysql', 'id' => $id]), $image = $mysql_edit_data['mysql_edit']['image'];
'formdata' => $mysql_edit_data['mysql_edit'],
'editid' => $id eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_edit') . "\";");
]);
} }
} }
} }

View File

@@ -2,52 +2,169 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Florian Lippert <flo@syscp.org> (2003-2009)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
define('AREA', 'customer');
$intrafficpage = 1;
require './lib/init.php';
const AREA = 'customer'; use Froxlor\Database\Database;
require __DIR__ . '/lib/init.php';
use Froxlor\Traffic\Traffic;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'traffic')) { if (Settings::IsInList('panel.customer_hide_options', 'traffic')) {
Response::redirectTo('customer_index.php'); \Froxlor\UI\Response::redirectTo('customer_index.php');
} }
$range = Request::any('range', 'currentyear'); $traffic = '';
$month = null;
$year = null;
if ($page == 'current') { if (isset($_POST['month']) && isset($_POST['year'])) {
$range = 'currentmonth'; $month = intval($_POST['month']);
$year = intval($_POST['year']);
} elseif (isset($_GET['month']) && isset($_GET['year'])) {
$month = intval($_GET['month']);
$year = intval($_GET['year']);
} // BAM! $_GET???
elseif (isset($_GET['page']) && $_GET['page'] == 'current') {
if (date('d') != '01') {
$month = date('m');
$year = date('Y');
} else {
if (date('m') == '01') {
$month = 12;
$year = date('Y') - 1;
} else {
$month = date('m') - 1;
$year = date('Y');
}
}
} }
try { if (! is_null($month) && ! is_null($year)) {
$context = Traffic::getCustomerStats($userinfo, $range); $traf['byte'] = 0;
} catch (Exception $e) { $result_stmt = Database::prepare("SELECT SUM(`http`) as 'http', SUM(`ftp_up`) AS 'ftp_up', SUM(`ftp_down`) as 'ftp_down', SUM(`mail`) as 'mail', `day`, `month`, `year`
Response::dynamicError($e->getMessage()); FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid`= :customerid
AND `month` = :month
AND `year` = :year
GROUP BY `day`
ORDER BY `day` DESC");
$params = array(
"customerid" => $userinfo['customerid'],
"month" => $month,
"year" => $year
);
Database::pexecute($result_stmt, $params);
$traffic_complete['http'] = 0;
$traffic_complete['ftp'] = 0;
$traffic_complete['mail'] = 0;
$show = '';
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$http = $row['http'];
$ftp = $row['ftp_up'] + $row['ftp_down'];
$mail = $row['mail'];
$traf['byte'] = $http + $ftp + $mail;
$traffic_complete['http'] += $http;
$traffic_complete['ftp'] += $ftp;
$traffic_complete['mail'] += $mail;
$traf['day'] = $row['day'] . '.';
if (extension_loaded('bcmath')) {
$traf['ftptext'] = bcdiv($row['ftp_up'], 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . bcdiv($row['ftp_down'], 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['ftp'] = bcdiv($ftp, 1024, Settings::Get('panel.decimal_places'));
} else {
$traf['ftptext'] = round($row['ftp_up'] / 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . round($row['ftp_down'] / 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['ftp'] = round($ftp / 1024, Settings::Get('panel.decimal_places'));
}
getReadableTraffic($traf,'httptext', $http, 1024, "MiB (HTTP)");
getReadableTraffic($traf,'http', $http, 1024);
getReadableTraffic($traf,'mailtext', $mail, 1024, "MiB (Mail)");
getReadableTraffic($traf,'mail', $mail, 1024);
getReadableTraffic($traf,'byte', $traf['byte'], (1024 * 1024));
eval("\$traffic.=\"" . \Froxlor\UI\Template::getTemplate('traffic/traffic_month') . "\";");
$show = $lng['traffic']['months'][intval($row['month'])] . ' ' . $row['year'];
}
$traffic_complete['http'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['http'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
$traffic_complete['ftp'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['ftp'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
$traffic_complete['mail'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['mail'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
eval("echo \"" . \Froxlor\UI\Template::getTemplate('traffic/traffic_details') . "\";");
} else {
$result_stmt = Database::prepare("
SELECT `month`, `year`, SUM(`http`) AS http, SUM(`ftp_up`) AS ftp_up, SUM(`ftp_down`) AS ftp_down, SUM(`mail`) AS mail
FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = :customerid
GROUP BY `year`, `month`
ORDER BY `year` DESC, `month` DESC
LIMIT 12
");
Database::pexecute($result_stmt, array(
"customerid" => $userinfo['customerid']
));
$traffic_complete['http'] = 0;
$traffic_complete['ftp'] = 0;
$traffic_complete['mail'] = 0;
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$http = $row['http'];
$ftp_up = $row['ftp_up'];
$ftp_down = $row['ftp_down'];
$mail = $row['mail'];
$traffic_complete['http'] += $http;
$traffic_complete['ftp'] += $ftp_up + $ftp_down;
$traffic_complete['mail'] += $mail;
$traf['month'] = $row['month'];
$traf['year'] = $row['year'];
$traf['monthname'] = $lng['traffic']['months'][intval($row['month'])] . " " . $row['year'];
$traf['byte'] = $http + $ftp_up + $ftp_down + $mail;
if (extension_loaded('bcmath')) {
$traf['ftptext'] = bcdiv($ftp_up, 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . bcdiv($ftp_down, 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['ftp'] = bcdiv(($ftp_up + $ftp_down), 1024, Settings::Get('panel.decimal_places'));
} else {
$traf['ftptext'] = round($ftp_up / 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . round($ftp_down / 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['ftp'] = round(($ftp_up + $ftp_down) / 1024, Settings::Get('panel.decimal_places'));
}
getReadableTraffic($traf,'httptext', $http, 1024, "MiB (HTTP)");
getReadableTraffic($traf,'http', $http, 1024);
getReadableTraffic($traf,'mailtext', $mail, 1024, "MiB (Mail)");
getReadableTraffic($traf,'mail', $mail, 1024);
getReadableTraffic($traf,'byte', $traf['byte'], (1024 * 1024));
eval("\$traffic.=\"" . \Froxlor\UI\Template::getTemplate('traffic/traffic_traffic') . "\";");
}
$traffic_complete['http'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['http'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
$traffic_complete['ftp'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['ftp'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
$traffic_complete['mail'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['mail'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
eval("echo \"" . \Froxlor\UI\Template::getTemplate('traffic/traffic') . "\";");
} }
// pass metrics to the view function getReadableTraffic(&$traf, $index, $value, $divisor, $desc = "")
UI::view('user/traffic.html.twig', $context); {
if (extension_loaded('bcmath')) {
$traf[$index] = bcdiv($value, $divisor,Settings::Get('panel.decimal_places')).(!empty($desc) ? " ".$desc : "");
} else {
$traf[$index] = round($value / $divisor, Settings::Get('panel.decimal_places')).(!empty($desc) ? " ".$desc : "");
}
}

View File

@@ -1,99 +1,70 @@
<?php <?php
if (! defined('AREA')) {
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
if (!defined('AREA')) {
header("Location: index.php"); header("Location: index.php");
exit(); exit();
} }
use Froxlor\Api\Commands\DomainZones; /**
use Froxlor\Dns\Dns; * This file is part of the Froxlor project.
use Froxlor\UI\Collection; * Copyright (c) 2016 the Froxlor Team (see authors).
use Froxlor\UI\HTML; *
use Froxlor\UI\Listing; * For the full copyright and license information, please view the COPYING
use Froxlor\UI\Panel\UI; * file that was distributed with this source code. You can also view the
use Froxlor\UI\Request; * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
use Froxlor\UI\Response; *
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2016-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
*
*/
use Froxlor\Api\Commands\DomainZones as DomainZones;
// This file is being included in admin_domains and customer_domains // This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php // and therefore does not need to require lib/init.php
$domain_id = (int)Request::any('domain_id'); $domain_id = isset($_GET['domain_id']) ? (int) $_GET['domain_id'] : null;
$record = isset($_POST['dns_record']) ? trim($_POST['dns_record']) : null; $record = isset($_POST['record']['record']) ? trim($_POST['record']['record']) : null;
$type = isset($_POST['dns_type']) ? $_POST['dns_type'] : 'A'; $type = isset($_POST['record']['type']) ? $_POST['record']['type'] : 'A';
$prio = isset($_POST['dns_mxp']) ? (int)$_POST['dns_mxp'] : null; $prio = isset($_POST['record']['prio']) ? (int) $_POST['record']['prio'] : null;
$content = isset($_POST['dns_content']) ? trim($_POST['dns_content']) : null; $content = isset($_POST['record']['content']) ? trim($_POST['record']['content']) : null;
$ttl = isset($_POST['dns_ttl']) ? (int)$_POST['dns_ttl'] : 18000; $ttl = isset($_POST['record']['ttl']) ? (int) $_POST['record']['ttl'] : 18000;
// get domain-name // get domain-name
$domain = Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo); $domain = \Froxlor\Dns\Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo);
$errors = ""; $errors = "";
$success_message = ""; $success_message = "";
// action for adding a new entry // action for adding a new entry
if ($action == 'add_record' && !empty($_POST)) { if ($action == 'add_record' && ! empty($_POST)) {
try { try {
DomainZones::getLocal($userinfo, [ DomainZones::getLocal($userinfo, array(
'id' => $domain_id, 'id' => $domain_id,
'record' => $record, 'record' => $record,
'type' => $type, 'type' => $type,
'prio' => $prio, 'prio' => $prio,
'content' => $content, 'content' => $content,
'ttl' => $ttl 'ttl' => $ttl
])->add(); ))->add();
$success_message = lng('success.dns_record_added'); $success_message = $lng['success']['dns_record_added'];
$record = $prio = $content = ""; $record = $prio = $content = "";
} catch (Exception $e) { } catch (Exception $e) {
$errors = str_replace("\n", "<br>", $e->getMessage()); $errors = str_replace("\n", "<br>", $e->getMessage());
} }
} elseif ($action == 'delete') { } elseif ($action == 'delete') {
$entry_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
HTML::askYesNo('dnsentry_reallydelete', $filename, [
'id' => $entry_id,
'domain_id' => $domain_id,
'page' => $page,
'action' => 'deletesure'
], '', [
'section' => 'domains',
'page' => $page,
'domain_id' => $domain_id
]);
} elseif (isset($_POST['send']) && $_POST['send'] == 'send' && $action == 'deletesure' && !empty($_POST)) {
$entry_id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
$domain_id = isset($_POST['domain_id']) ? (int)$_POST['domain_id'] : 0;
// remove entry // remove entry
if ($entry_id > 0 && $domain_id > 0) { $entry_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
if ($entry_id > 0) {
try { try {
DomainZones::getLocal($userinfo, [ DomainZones::getLocal($userinfo, array(
'entry_id' => $entry_id, 'entry_id' => $entry_id,
'id' => $domain_id 'id' => $domain_id
])->delete(); ))->delete();
// success message (inline) // success message (inline)
$success_message = lng('success.dns_record_deleted'); $success_message = $lng['success']['dns_record_deleted'];
} catch (Exception $e) { } catch (Exception $e) {
$errors = str_replace("\n", "<br>", $e->getMessage()); $errors = str_replace("\n", "<br>", $e->getMessage());
} }
@@ -102,48 +73,60 @@ if ($action == 'add_record' && !empty($_POST)) {
// select all entries // select all entries
try { try {
$dns_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.dns.php'; // get list
$collection = (new Collection(DomainZones::class, $userinfo, ['id' => $domain_id]))
->withPagination($dns_list_data['dns_list']['columns'], $dns_list_data['dns_list']['default_sorting'], ['domain_id='.$domain_id]);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
try {
$json_result = DomainZones::getLocal($userinfo, [ $json_result = DomainZones::getLocal($userinfo, [
'id' => $domain_id 'id' => $domain_id
])->get(); ])->listing();
} catch (Exception $e) { } catch (Exception $e) {
Response::dynamicError($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$dom_entries = $result['list'];
// show editor
$record_list = "";
$existing_entries = "";
$type_select = "";
$entriescount = 0;
if (! empty($dom_entries)) {
$entriescount = count($dom_entries);
foreach ($dom_entries as $entry) {
$entry['content'] = wordwrap($entry['content'], 100, '<br>', true);
eval("\$existing_entries.=\"" . \Froxlor\UI\Template::getTemplate("dns_editor/entry_bit", true) . "\";");
}
}
// available types
$type_select_values = array(
'A',
'AAAA',
'CAA',
'CNAME',
'DNAME',
'LOC',
'MX',
'NS',
'RP',
'SRV',
'SSHFP',
'TXT'
);
asort($type_select_values);
foreach ($type_select_values as $_type) {
$type_select .= \Froxlor\UI\HTML::makeoption($_type, $_type, $type);
}
eval("\$record_list=\"" . \Froxlor\UI\Template::getTemplate("dns_editor/list", true) . "\";");
try {
$json_result = DomainZones::getLocal($userinfo, array(
'id' => $domain_id
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
$zonefile = implode("\n", $result); $zonefile = implode("\n", $result);
$dns_add_data = include_once dirname(__FILE__) . '/lib/formfields/formfield.dns_add.php'; eval("echo \"" . \Froxlor\UI\Template::getTemplate("dns_editor/index", true) . "\";");
UI::view('user/dns-editor.html.twig', [
'listing' => Listing::format($collection, $dns_list_data, 'dns_list', ['domain_id' => $domain_id]),
'actions_links' => [
[
'href' => $linker->getLink([
'section' => 'domains',
'page' => 'domains',
'action' => 'edit',
'id' => $domain_id
]),
'label' => lng('admin.domain_edit'),
'icon' => 'fa-solid fa-pen'
],
[
'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains']),
'label' => lng('panel.backtooverview'),
'icon' => 'fa-solid fa-reply'
]
],
'formaction' => $linker->getLink(['section' => 'domains', 'action' => 'add_record', 'domain_id' => $domain_id]),
'formdata' => $dns_add_data['dns_add'],
// alert-box
'type' => (!empty($errors) ? 'danger' : (!empty($success_message) ? 'success' : 'warning')),
'alert_msg' => (!empty($errors) ? $errors : (!empty($success_message) ? $success_message : lng('dns.howitworks'))),
'zonefile' => $zonefile,
]);

View File

@@ -2,66 +2,212 @@
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2018 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Froxlor team <team@froxlor.org> (2018-)
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* GNU General Public License for more details. * @package API-example
* @since 0.10.0
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
class FroxlorAPI class FroxlorAPI
{ {
private string $url;
private string $key;
private string $secret;
private ?array $lastError = null;
private ?string $lastStatusCode = null;
public function __construct($url, $key, $secret) /**
{ * URL to api.php of your froxlor installation
$this->url = $url; *
$this->key = $key; * @var string
$this->secret = $secret; */
} private $host = "";
public function request($command, array $data = []) /**
{ * your api-key
$payload = [ *
'command' => $command, * @var string
'params' => $data */
]; private $api_key = "";
$ch = curl_init($this->url); /**
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); * your api-secret
curl_setopt($ch, CURLOPT_HEADER, 0); *
curl_setopt($ch, CURLOPT_USERPWD, $this->key . ":" . $this->secret); * @var string
curl_setopt($ch, CURLOPT_TIMEOUT, 30); */
curl_setopt($ch, CURLOPT_POST, 1); private $api_secret = "";
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$this->lastStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); /**
* last cURL error message
*
* @var string
*/
private $last_error = "";
return json_decode($result ?? curl_error($ch), true); /**
} * last response header received
*
* @var array
*/
private $last_header = array();
public function getLastStatusCode(): ?string /**
{ * last response data received
return $this->lastStatusCode; *
} * @var array
*/
private $last_body = array();
/**
* create FroxlorAPI object
*
* @param string $host
* URL to api.php of your froxlor installation
* @param string $api_key
* your api-key
* @param string $api_secret
* your api-secret
*
* @return FroxlorAPI
*/
public function __construct(string $host, string $api_key, string $api_secret)
{
$this->host = $host;
$this->api_key = $api_key;
$this->api_secret = $api_secret;
}
/**
* send request to froxlor api
*
* @param string $command
* @param array $params
*
* @return FroxlorAPI
*/
public function request(string $command, array $params = array()): FroxlorAPI
{
// build request array
$request = [
'header' => [
'apikey' => $this->api_key,
'secret' => $this->api_secret
],
'body' => [
'command' => $command
]
];
// add parameter to request-body if any
if (! empty($params)) {
$request['body']['params'] = $params;
}
// reset last data
$this->last_header = array();
$this->last_body = array();
// send actual request
$response = $this->requestCurl(json_encode($request));
// decode response
$resp = json_decode($response[1], true);
// set body to data-part of response
$this->last_body = $resp['data'];
// set header of response
$this->last_header = [
'status' => $resp['status'],
'status_message' => $resp['status_message']
];
// check for error in api response
if (isset($this->last_header['status']) && $this->last_header['status'] >= 400) {
// set last-error message
$this->last_error .= "[" . $this->last_header['status'] . "] " . $this->last_header['status_message'];
}
return $this;
}
/**
* returns last response header
*
* @return array status|status_message
*/
public function getLastHeader(): array
{
return $this->last_header;
}
/**
* returns last response data
*
* @return array
*/
public function getLastResponse(): array
{
if (!empty($this->getLastError())) {
// nothing is returned when the last call
// was not successful
return [];
}
return $this->last_body;
}
/**
* return last known error message
*
* @return string
*/
public function getLastError(): string
{
return $this->last_error;
}
/**
* send cURL request to api
*
* @param string $data
* json array
*
* @return array header|body
*/
private function requestCurl(string $data): array
{
// reset last error message
$this->last_error = "";
$ch = curl_init($this->host);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
$verbose = fopen('php://temp', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
if (! $data = curl_exec($ch)) {
$this->last_error = 'Curl execution error: ' . curl_error($ch) . "\n";
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
$this->last_error .= "Verbose information: " . htmlspecialchars($verboseLog) . "\n";
}
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($data, 0, $header_size);
$body = substr($data, $header_size);
curl_close($ch);
return array(
$header,
$body
);
}
} }

View File

@@ -4,7 +4,7 @@
require __DIR__ . '/FroxlorAPI.php'; require __DIR__ . '/FroxlorAPI.php';
// create object of FroxlorAPI with URL, apikey and apisecret // create object of FroxlorAPI with URL, apikey and apisecret
$fapi = new FroxlorAPI('http://127.0.0.1/api.php', 'your-api-key', 'your-api-secret'); $fapi = new FroxlorAPI('https://froxlor.your-host.tld/api.php', 'your-api-key', 'your-api-secret');
// customer data // customer data
$data = [ $data = [
@@ -16,17 +16,19 @@ $data = [
'new_customer_password' => 's0mEcRypt1cpassword' . uniqid() 'new_customer_password' => 's0mEcRypt1cpassword' . uniqid()
]; ];
// send request // send request
$response = $fapi->request('Customers.add', $data); $fapi->request('Customers.add', $data);
// check for error // check for error
if ($fapi->getLastStatusCode() != 200) { if (! empty($fapi->getLastError())) {
echo "HTTP-STATUS: " . $fapi->getLastStatusCode() . PHP_EOL; echo "Error: " . $fapi->getLastError();
echo "Description: " . $response['message'] . PHP_EOL; exit();
exit();
} }
// get response of request
$request = $fapi->getLastResponse();
// view response data // view response data
var_dump($response); var_dump($request);
/* /*
array(60) { array(60) {

View File

@@ -4,17 +4,19 @@
require __DIR__ . '/FroxlorAPI.php'; require __DIR__ . '/FroxlorAPI.php';
// create object of FroxlorAPI with URL, apikey and apisecret // create object of FroxlorAPI with URL, apikey and apisecret
$fapi = new FroxlorAPI('http://localhost/api.php', 'your-api-key', 'your-api-secret'); $fapi = new FroxlorAPI('https://froxlor.your-host.tld/api.php', 'your-api-key', 'your-api-secret');
// send request // send request
$response = $fapi->request('Froxlor.listFunctions'); $fapi->request('Froxlor.listFunctions');
// check for error // check for error
if ($fapi->getLastStatusCode() != 200) { if (! empty($fapi->getLastError())) {
echo "HTTP-STATUS: " . $fapi->getLastStatusCode() . PHP_EOL; echo "Error: " . $fapi->getLastError();
echo "Description: " . $response['message'] . PHP_EOL; exit();
exit();
} }
// get response of request
$request = $fapi->getLastResponse();
// view response data // view response data
var_dump($response); var_dump($request);

View File

@@ -1,117 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
if (!defined('AREA')) {
header("Location: index.php");
exit();
}
use Froxlor\FileDir;
use Froxlor\Froxlor;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\Database\Database;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php
$errid = Request::any('errorid');
if (!empty($errid)) {
// read error file
$err_dir = FileDir::makeCorrectDir(Froxlor::getInstallDir() . "/logs/");
$err_file = FileDir::makeCorrectFile($err_dir . "/" . $errid . "_sql-error.log");
if (file_exists($err_file)) {
$error_content = file_get_contents($err_file);
$error = explode("|", $error_content);
$_error = [
'code' => str_replace("\n", "", substr($error[1], 5)),
'message' => str_replace("\n", "", substr($error[2], 4)),
'file' => str_replace("\n", "", substr($error[3], 5 + strlen(Froxlor::getInstallDir()))),
'line' => str_replace("\n", "", substr($error[4], 5)),
'trace' => str_replace(Froxlor::getInstallDir(), "", substr($error[5], 6))
];
// build mail-content
$mail_body = "Dear froxlor-team,\n\n";
$mail_body .= "the following error has been reported by a user:\n\n";
$mail_body .= "-------------------------------------------------------------\n";
$mail_body .= $_error['code'] . ' ' . $_error['message'] . "\n\n";
$mail_body .= "File: " . $_error['file'] . ':' . $_error['line'] . "\n\n";
$mail_body .= "Trace:\n" . trim($_error['trace']) . "\n\n";
$mail_body .= "-------------------------------------------------------------\n\n";
$mail_body .= "User-Area: " . AREA . "\n";
$mail_body .= "Froxlor-version: " . Froxlor::VERSION . "\n";
$mail_body .= "DB-version: " . Froxlor::DBVERSION . "\n\n";
try {
$mail_body .= "Database: " . Database::getAttribute(PDO::ATTR_SERVER_VERSION);
} catch (\Exception $e) {
/* ignore */
}
$mail_body .= "End of report";
$mail_html = nl2br($mail_body);
// send actual report to dev-team
if (isset($_POST['send']) && $_POST['send'] == 'send') {
// send mail and say thanks
$_mailerror = false;
try {
$mail->Subject = '[Froxlor] Error report by user';
$mail->AltBody = $mail_body;
$mail->MsgHTML($mail_html);
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
$mail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
// error when reporting an error...LOLFUQ
Response::standardError('send_report_error', $mailerr_msg);
}
// finally remove error from fs
@unlink($err_file);
Response::standardSuccess('sent_error_report', '', ['filename' => 'index.php']);
}
// show a nice summary of the error-report
// before actually sending anything
UI::view('user/error_report.html.twig', [
'mail_html' => $mail_body,
'errorid' => $errid
]);
} else {
Response::redirectTo($filename);
}
} else {
Response::redirectTo($filename);
}

706
index.php

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +1,3 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
return <<<'FROXLORSQL'
DROP TABLE IF EXISTS `ftp_groups`; DROP TABLE IF EXISTS `ftp_groups`;
CREATE TABLE `ftp_groups` ( CREATE TABLE `ftp_groups` (
`id` int(20) NOT NULL auto_increment, `id` int(20) NOT NULL auto_increment,
@@ -36,13 +10,15 @@ CREATE TABLE `ftp_groups` (
KEY `customerid` (`customerid`) KEY `customerid` (`customerid`)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `ftp_users`; DROP TABLE IF EXISTS `ftp_users`;
CREATE TABLE `ftp_users` ( CREATE TABLE `ftp_users` (
`id` int(20) NOT NULL auto_increment, `id` int(20) NOT NULL auto_increment,
`username` varchar(255) NOT NULL, `username` varchar(255) NOT NULL,
`uid` int(5) NOT NULL default '0', `uid` int(5) NOT NULL default '0',
`gid` int(5) NOT NULL default '0', `gid` int(5) NOT NULL default '0',
`password` varchar(255) NOT NULL, `password` varchar(128) NOT NULL,
`homedir` varchar(255) NOT NULL default '', `homedir` varchar(255) NOT NULL default '',
`shell` varchar(255) NOT NULL default '/bin/false', `shell` varchar(255) NOT NULL default '/bin/false',
`login_enabled` enum('N','Y') NOT NULL default 'N', `login_enabled` enum('N','Y') NOT NULL default 'N',
@@ -60,13 +36,14 @@ CREATE TABLE `ftp_users` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `mail_users`; DROP TABLE IF EXISTS `mail_users`;
CREATE TABLE `mail_users` ( CREATE TABLE `mail_users` (
`id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL auto_increment,
`email` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '',
`username` varchar(255) NOT NULL default '', `username` varchar(255) NOT NULL default '',
`password` varchar(255) NOT NULL default '', `password` varchar(128) NOT NULL default '',
`password_enc` varchar(255) NOT NULL default '', `password_enc` varchar(128) NOT NULL default '',
`uid` int(11) NOT NULL default '0', `uid` int(11) NOT NULL default '0',
`gid` int(11) NOT NULL default '0', `gid` int(11) NOT NULL default '0',
`homedir` varchar(255) NOT NULL default '', `homedir` varchar(255) NOT NULL default '',
@@ -83,6 +60,7 @@ CREATE TABLE `mail_users` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `mail_virtual`; DROP TABLE IF EXISTS `mail_virtual`;
CREATE TABLE `mail_virtual` ( CREATE TABLE `mail_virtual` (
`id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL auto_increment,
@@ -124,6 +102,7 @@ CREATE TABLE `panel_admins` (
`customers_see_all` tinyint(1) NOT NULL default '0', `customers_see_all` tinyint(1) NOT NULL default '0',
`domains` int(15) NOT NULL default '0', `domains` int(15) NOT NULL default '0',
`domains_used` int(15) NOT NULL default '0', `domains_used` int(15) NOT NULL default '0',
`domains_see_all` tinyint(1) NOT NULL default '0',
`caneditphpsettings` tinyint(1) NOT NULL default '0', `caneditphpsettings` tinyint(1) NOT NULL default '0',
`change_serversettings` tinyint(1) NOT NULL default '0', `change_serversettings` tinyint(1) NOT NULL default '0',
`diskspace` int(15) NOT NULL default '0', `diskspace` int(15) NOT NULL default '0',
@@ -149,7 +128,7 @@ CREATE TABLE `panel_admins` (
`lastlogin_fail` int(11) unsigned NOT NULL default '0', `lastlogin_fail` int(11) unsigned NOT NULL default '0',
`loginfail_count` int(11) unsigned NOT NULL default '0', `loginfail_count` int(11) unsigned NOT NULL default '0',
`reportsent` tinyint(4) unsigned NOT NULL default '0', `reportsent` tinyint(4) unsigned NOT NULL default '0',
`theme` varchar(50) NOT NULL default 'Froxlor', `theme` varchar(50) NOT NULL default 'Sparkle',
`custom_notes` text, `custom_notes` text,
`custom_notes_show` tinyint(1) NOT NULL default '0', `custom_notes_show` tinyint(1) NOT NULL default '0',
`type_2fa` tinyint(1) NOT NULL default '0', `type_2fa` tinyint(1) NOT NULL default '0',
@@ -160,6 +139,7 @@ CREATE TABLE `panel_admins` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_customers`; DROP TABLE IF EXISTS `panel_customers`;
CREATE TABLE `panel_customers` ( CREATE TABLE `panel_customers` (
`customerid` int(11) unsigned NOT NULL auto_increment, `customerid` int(11) unsigned NOT NULL auto_increment,
@@ -176,7 +156,7 @@ CREATE TABLE `panel_customers` (
`phone` varchar(50) NOT NULL default '', `phone` varchar(50) NOT NULL default '',
`fax` varchar(50) NOT NULL default '', `fax` varchar(50) NOT NULL default '',
`email` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '',
`customernumber` varchar(100) NOT NULL default '', `customernumber` varchar(255) NOT NULL default '',
`def_language` varchar(100) NOT NULL default '', `def_language` varchar(100) NOT NULL default '',
`diskspace` bigint(30) NOT NULL default '0', `diskspace` bigint(30) NOT NULL default '0',
`diskspace_used` bigint(30) NOT NULL default '0', `diskspace_used` bigint(30) NOT NULL default '0',
@@ -211,21 +191,21 @@ CREATE TABLE `panel_customers` (
`imap` tinyint(1) NOT NULL default '1', `imap` tinyint(1) NOT NULL default '1',
`perlenabled` tinyint(1) NOT NULL default '0', `perlenabled` tinyint(1) NOT NULL default '0',
`dnsenabled` tinyint(1) NOT NULL default '0', `dnsenabled` tinyint(1) NOT NULL default '0',
`theme` varchar(50) NOT NULL default 'Froxlor', `theme` varchar(50) NOT NULL default 'Sparkle',
`custom_notes` text, `custom_notes` text,
`custom_notes_show` tinyint(1) NOT NULL default '0', `custom_notes_show` tinyint(1) NOT NULL default '0',
`lepublickey` mediumtext default NULL, `lepublickey` mediumtext default NULL,
`leprivatekey` mediumtext default NULL, `leprivatekey` mediumtext default NULL,
`leregistered` tinyint(1) NOT NULL default '0', `leregistered` tinyint(1) NOT NULL default '0',
`allowed_phpconfigs` text NOT NULL, `allowed_phpconfigs` varchar(500) NOT NULL default '',
`type_2fa` tinyint(1) NOT NULL default '0', `type_2fa` tinyint(1) NOT NULL default '0',
`data_2fa` varchar(25) NOT NULL default '', `data_2fa` varchar(25) NOT NULL default '',
`api_allowed` tinyint(1) NOT NULL default '1', `api_allowed` tinyint(1) NOT NULL default '1',
`logviewenabled` tinyint(1) NOT NULL default '0', `logviewenabled` tinyint(1) NOT NULL default '0',
`allowed_mysqlserver` text NOT NULL,
PRIMARY KEY (`customerid`), PRIMARY KEY (`customerid`),
UNIQUE KEY `loginname` (`loginname`) UNIQUE KEY `loginname` (`loginname`)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_databases`; DROP TABLE IF EXISTS `panel_databases`;
@@ -240,6 +220,7 @@ CREATE TABLE `panel_databases` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_domains`; DROP TABLE IF EXISTS `panel_domains`;
CREATE TABLE `panel_domains` ( CREATE TABLE `panel_domains` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -303,6 +284,7 @@ CREATE TABLE `panel_domains` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_ipsandports`; DROP TABLE IF EXISTS `panel_ipsandports`;
CREATE TABLE `panel_ipsandports` ( CREATE TABLE `panel_ipsandports` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -329,6 +311,7 @@ CREATE TABLE `panel_ipsandports` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_htaccess`; DROP TABLE IF EXISTS `panel_htaccess`;
CREATE TABLE `panel_htaccess` ( CREATE TABLE `panel_htaccess` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -344,6 +327,7 @@ CREATE TABLE `panel_htaccess` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_htpasswds`; DROP TABLE IF EXISTS `panel_htpasswds`;
CREATE TABLE `panel_htpasswds` ( CREATE TABLE `panel_htpasswds` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -357,6 +341,7 @@ CREATE TABLE `panel_htpasswds` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_sessions`; DROP TABLE IF EXISTS `panel_sessions`;
CREATE TABLE `panel_sessions` ( CREATE TABLE `panel_sessions` (
`hash` varchar(32) NOT NULL default '', `hash` varchar(32) NOT NULL default '',
@@ -374,6 +359,7 @@ CREATE TABLE `panel_sessions` (
) ENGINE=HEAP; ) ENGINE=HEAP;
DROP TABLE IF EXISTS `panel_settings`; DROP TABLE IF EXISTS `panel_settings`;
CREATE TABLE `panel_settings` ( CREATE TABLE `panel_settings` (
`settingid` int(11) unsigned NOT NULL auto_increment, `settingid` int(11) unsigned NOT NULL auto_increment,
@@ -402,7 +388,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('dkim', 'dkim_prefix', '/etc/postfix/dkim/'), ('dkim', 'dkim_prefix', '/etc/postfix/dkim/'),
('dkim', 'dkim_domains', 'domains'), ('dkim', 'dkim_domains', 'domains'),
('dkim', 'dkim_dkimkeys', 'dkim-keys.conf'), ('dkim', 'dkim_dkimkeys', 'dkim-keys.conf'),
('dkim', 'dkimrestart_command', 'service dkim-filter restart'), ('dkim', 'dkimrestart_command', '/etc/init.d/dkim-filter restart'),
('dkim', 'privkeysuffix', '.priv'), ('dkim', 'privkeysuffix', '.priv'),
('admin', 'show_news_feed', '0'), ('admin', 'show_news_feed', '0'),
('admin', 'show_version_login', '0'), ('admin', 'show_version_login', '0'),
@@ -540,7 +526,7 @@ opcache.validate_timestamps'),
('system', 'documentroot_prefix', '/var/customers/webs/'), ('system', 'documentroot_prefix', '/var/customers/webs/'),
('system', 'logfiles_directory', '/var/customers/logs/'), ('system', 'logfiles_directory', '/var/customers/logs/'),
('system', 'ipaddress', 'SERVERIP'), ('system', 'ipaddress', 'SERVERIP'),
('system', 'apachereload_command', 'service apache2 reload'), ('system', 'apachereload_command', '/etc/init.d/apache2 reload'),
('system', 'last_traffic_run', '000000'), ('system', 'last_traffic_run', '000000'),
('system', 'vmail_uid', '2000'), ('system', 'vmail_uid', '2000'),
('system', 'vmail_gid', '2000'), ('system', 'vmail_gid', '2000'),
@@ -548,7 +534,7 @@ opcache.validate_timestamps'),
('system', 'vmail_maildirname', 'Maildir'), ('system', 'vmail_maildirname', 'Maildir'),
('system', 'bind_enable', '0'), ('system', 'bind_enable', '0'),
('system', 'bindconf_directory', '/etc/bind/'), ('system', 'bindconf_directory', '/etc/bind/'),
('system', 'bindreload_command', 'service bind9 reload'), ('system', 'bindreload_command', '/etc/init.d/bind9 reload'),
('system', 'hostname', 'SERVERNAME'), ('system', 'hostname', 'SERVERNAME'),
('system', 'mysql_access_host', 'localhost'), ('system', 'mysql_access_host', 'localhost'),
('system', 'lastcronrun', ''), ('system', 'lastcronrun', ''),
@@ -568,12 +554,14 @@ opcache.validate_timestamps'),
('system', 'last_archive_run', '000000'), ('system', 'last_archive_run', '000000'),
('system', 'mod_fcgid_configdir', '/var/www/php-fcgi-scripts'), ('system', 'mod_fcgid_configdir', '/var/www/php-fcgi-scripts'),
('system', 'mod_fcgid_tmpdir', '/var/customers/tmp'), ('system', 'mod_fcgid_tmpdir', '/var/customers/tmp'),
('system', 'ssl_cert_file', '/etc/ssl/froxlor_selfsigned.pem'), ('system', 'ssl_cert_file', '/etc/apache2/apache2.pem'),
('system', 'use_ssl', '0'), ('system', 'use_ssl', '0'),
('system', 'default_vhostconf', ''), ('system', 'default_vhostconf', ''),
('system', 'default_sslvhostconf', ''), ('system', 'default_sslvhostconf', ''),
('system', 'mail_quota_enabled', '0'), ('system', 'mail_quota_enabled', '0'),
('system', 'mail_quota', '100'), ('system', 'mail_quota', '100'),
('system', 'webalizer_enabled', '1'),
('system', 'awstats_enabled', '0'),
('system', 'httpuser', 'www-data'), ('system', 'httpuser', 'www-data'),
('system', 'httpgroup', 'www-data'), ('system', 'httpgroup', 'www-data'),
('system', 'webserver', 'apache2'), ('system', 'webserver', 'apache2'),
@@ -582,12 +570,12 @@ opcache.validate_timestamps'),
('system', 'mod_fcgid_peardir', '/usr/share/php/:/usr/share/php5/'), ('system', 'mod_fcgid_peardir', '/usr/share/php/:/usr/share/php5/'),
('system', 'index_file_extension', 'html'), ('system', 'index_file_extension', 'html'),
('system', 'mod_fcgid_maxrequests', '250'), ('system', 'mod_fcgid_maxrequests', '250'),
('system', 'ssl_key_file','/etc/ssl/froxlor_selfsigned.key'), ('system', 'ssl_key_file','/etc/apache2/apache2.key'),
('system', 'ssl_ca_file', ''), ('system', 'ssl_ca_file', ''),
('system', 'debug_cron', '0'), ('system', 'debug_cron', '0'),
('system', 'store_index_file_subs', '1'), ('system', 'store_index_file_subs', '1'),
('system', 'stdsubdomain', ''), ('system', 'stdsubdomain', ''),
('system', 'awstats_path', '/usr/share/awstats/tools/'), ('system', 'awstats_path', '/usr/bin/'),
('system', 'awstats_conf', '/etc/awstats/'), ('system', 'awstats_conf', '/etc/awstats/'),
('system', 'awstats_logformat', '1'), ('system', 'awstats_logformat', '1'),
('system', 'defaultttl', '604800'), ('system', 'defaultttl', '604800'),
@@ -595,7 +583,7 @@ opcache.validate_timestamps'),
('system', 'ftpserver', 'proftpd'), ('system', 'ftpserver', 'proftpd'),
('system', 'dns_createmailentry', '0'), ('system', 'dns_createmailentry', '0'),
('system', 'dns_createcaaentry', '1'), ('system', 'dns_createcaaentry', '1'),
('system', 'froxlordirectlyviahostname', '1'), ('system', 'froxlordirectlyviahostname', '0'),
('system', 'report_enable', '1'), ('system', 'report_enable', '1'),
('system', 'report_webmax', '90'), ('system', 'report_webmax', '90'),
('system', 'report_trafficmax', '90'), ('system', 'report_trafficmax', '90'),
@@ -609,7 +597,7 @@ opcache.validate_timestamps'),
('system', 'mod_fcgid_ownvhost', '0'), ('system', 'mod_fcgid_ownvhost', '0'),
('system', 'mod_fcgid_httpuser', 'froxlorlocal'), ('system', 'mod_fcgid_httpuser', 'froxlorlocal'),
('system', 'mod_fcgid_httpgroup', 'froxlorlocal'), ('system', 'mod_fcgid_httpgroup', 'froxlorlocal'),
('system', 'awstats_awstatspath', '/usr/lib/cgi-bin/'), ('system', 'awstats_awstatspath', '/usr/bin/'),
('system', 'mod_fcgid_defaultini_ownvhost', '2'), ('system', 'mod_fcgid_defaultini_ownvhost', '2'),
('system', 'awstats_icons', '/usr/share/awstats/icon/'), ('system', 'awstats_icons', '/usr/share/awstats/icon/'),
('system', 'ssl_cert_chainfile', ''), ('system', 'ssl_cert_chainfile', ''),
@@ -621,7 +609,7 @@ opcache.validate_timestamps'),
('system', 'apache24', '1'), ('system', 'apache24', '1'),
('system', 'apache24_ocsp_cache_path', 'shmcb:/var/run/apache2/ocsp-stapling.cache(131072)'), ('system', 'apache24_ocsp_cache_path', 'shmcb:/var/run/apache2/ocsp-stapling.cache(131072)'),
('system', 'documentroot_use_default_value', '0'), ('system', 'documentroot_use_default_value', '0'),
('system', 'passwordcryptfunc', '2y'), ('system', 'passwordcryptfunc', '3'),
('system', 'axfrservers', ''), ('system', 'axfrservers', ''),
('system', 'powerdns_mode', 'Native'), ('system', 'powerdns_mode', 'Native'),
('system', 'customer_ssl_path', '/etc/ssl/froxlor-custom/'), ('system', 'customer_ssl_path', '/etc/ssl/froxlor-custom/'),
@@ -633,7 +621,7 @@ opcache.validate_timestamps'),
('system', 'mtaserver', 'postfix'), ('system', 'mtaserver', 'postfix'),
('system', 'mailtraffic_enabled', '1'), ('system', 'mailtraffic_enabled', '1'),
('system', 'cronconfig', '/etc/cron.d/froxlor'), ('system', 'cronconfig', '/etc/cron.d/froxlor'),
('system', 'crondreload', 'service cron reload'), ('system', 'crondreload', '/etc/init.d/cron reload'),
('system', 'croncmdline', '/usr/bin/nice -n 5 /usr/bin/php -q'), ('system', 'croncmdline', '/usr/bin/nice -n 5 /usr/bin/php -q'),
('system', 'cron_allowautoupdate', '0'), ('system', 'cron_allowautoupdate', '0'),
('system', 'dns_createhostnameentry', '0'), ('system', 'dns_createhostnameentry', '0'),
@@ -642,7 +630,9 @@ opcache.validate_timestamps'),
('system', 'leprivatekey', 'unset'), ('system', 'leprivatekey', 'unset'),
('system', 'lepublickey', 'unset'), ('system', 'lepublickey', 'unset'),
('system', 'letsencryptca', 'letsencrypt'), ('system', 'letsencryptca', 'letsencrypt'),
('system', 'letsencryptchallengepath', '/var/www/html/froxlor'), ('system', 'letsencryptcountrycode', 'DE'),
('system', 'letsencryptstate', 'Hessen'),
('system', 'letsencryptchallengepath', '/var/www/froxlor'),
('system', 'letsencryptkeysize', '4096'), ('system', 'letsencryptkeysize', '4096'),
('system', 'letsencryptreuseold', 0), ('system', 'letsencryptreuseold', 0),
('system', 'leenabled', '0'), ('system', 'leenabled', '0'),
@@ -663,14 +653,13 @@ opcache.validate_timestamps'),
('system', 'mail_smtp_auth', '1'), ('system', 'mail_smtp_auth', '1'),
('system', 'mail_smtp_user', ''), ('system', 'mail_smtp_user', ''),
('system', 'mail_smtp_passwd', ''), ('system', 'mail_smtp_passwd', ''),
('system', 'hsts_maxage', '10368000'), ('system', 'hsts_maxage', '0'),
('system', 'hsts_incsub', '0'), ('system', 'hsts_incsub', '0'),
('system', 'hsts_preload', '0'), ('system', 'hsts_preload', '0'),
('system', 'leregistered', '0'), ('system', 'leregistered', '0'),
('system', 'leaccount', ''), ('system', 'leaccount', ''),
('system', 'nssextrausers', '1'), ('system', 'nssextrausers', '0'),
('system', 'le_domain_dnscheck', '1'), ('system', 'le_domain_dnscheck', '1'),
('system', 'le_domain_dnscheck_resolver', '1.1.1.1'),
('system', 'ssl_protocols', 'TLSv1.2'), ('system', 'ssl_protocols', 'TLSv1.2'),
('system', 'tlsv13_cipher_list', ''), ('system', 'tlsv13_cipher_list', ''),
('system', 'honorcipherorder', '0'), ('system', 'honorcipherorder', '0'),
@@ -686,7 +675,7 @@ opcache.validate_timestamps'),
('system', 'froxloraliases', ''), ('system', 'froxloraliases', ''),
('system', 'apply_specialsettings_default', '1'), ('system', 'apply_specialsettings_default', '1'),
('system', 'apply_phpconfigs_default', '1'), ('system', 'apply_phpconfigs_default', '1'),
('system', 'hide_incompatible_settings', '1'), ('system', 'hide_incompatible_settings', '0'),
('system', 'include_default_vhostconf', '0'), ('system', 'include_default_vhostconf', '0'),
('system', 'soaemail', ''), ('system', 'soaemail', ''),
('system', 'domaindefaultalias', '0'), ('system', 'domaindefaultalias', '0'),
@@ -694,20 +683,14 @@ opcache.validate_timestamps'),
('system', 'froxlorusergroup', ''), ('system', 'froxlorusergroup', ''),
('system', 'froxlorusergroup_gid', ''), ('system', 'froxlorusergroup_gid', ''),
('system', 'acmeshpath', '/root/.acme.sh/acme.sh'), ('system', 'acmeshpath', '/root/.acme.sh/acme.sh'),
('system', 'distribution', ''),
('system', 'update_channel', 'stable'),
('system', 'updatecheck_data', ''),
('system', 'update_notify_last', '2.0.14'),
('system', 'traffictool', 'goaccess'),
('api', 'enabled', '0'), ('api', 'enabled', '0'),
('api', 'customer_default', '1'),
('2fa', 'enabled', '1'), ('2fa', 'enabled', '1'),
('panel', 'decimal_places', '4'), ('panel', 'decimal_places', '4'),
('panel', 'adminmail', 'admin@SERVERNAME'), ('panel', 'adminmail', 'admin@SERVERNAME'),
('panel', 'phpmyadmin_url', ''), ('panel', 'phpmyadmin_url', ''),
('panel', 'webmail_url', ''), ('panel', 'webmail_url', ''),
('panel', 'webftp_url', ''), ('panel', 'webftp_url', ''),
('panel', 'standardlanguage', 'en'), ('panel', 'standardlanguage', 'English'),
('panel', 'pathedit', 'Manual'), ('panel', 'pathedit', 'Manual'),
('panel', 'paging', '20'), ('panel', 'paging', '20'),
('panel', 'natsorting', '1'), ('panel', 'natsorting', '1'),
@@ -715,7 +698,7 @@ opcache.validate_timestamps'),
('panel', 'allow_domain_change_admin', '0'), ('panel', 'allow_domain_change_admin', '0'),
('panel', 'allow_domain_change_customer', '0'), ('panel', 'allow_domain_change_customer', '0'),
('panel', 'frontend', 'froxlor'), ('panel', 'frontend', 'froxlor'),
('panel', 'default_theme', 'Froxlor'), ('panel', 'default_theme', 'Sparkle'),
('panel', 'password_min_length', '0'), ('panel', 'password_min_length', '0'),
('panel', 'adminmail_defname', 'Froxlor Administrator'), ('panel', 'adminmail_defname', 'Froxlor Administrator'),
('panel', 'adminmail_return', ''), ('panel', 'adminmail_return', ''),
@@ -724,7 +707,6 @@ opcache.validate_timestamps'),
('panel', 'allow_preset_admin', '0'), ('panel', 'allow_preset_admin', '0'),
('panel', 'password_regex', ''), ('panel', 'password_regex', ''),
('panel', 'phpconfigs_hidestdsubdomain', '0'), ('panel', 'phpconfigs_hidestdsubdomain', '0'),
('panel', 'phpconfigs_hidesubdomains', '1'),
('panel', 'allow_theme_change_admin', '1'), ('panel', 'allow_theme_change_admin', '1'),
('panel', 'allow_theme_change_customer', '1'), ('panel', 'allow_theme_change_customer', '1'),
('panel', 'password_alpha_lower', '1'), ('panel', 'password_alpha_lower', '1'),
@@ -741,9 +723,8 @@ opcache.validate_timestamps'),
('panel', 'logo_image_login', ''), ('panel', 'logo_image_login', ''),
('panel', 'logo_overridetheme', '0'), ('panel', 'logo_overridetheme', '0'),
('panel', 'logo_overridecustom', '0'), ('panel', 'logo_overridecustom', '0'),
('panel', 'settings_mode', '0'), ('panel', 'version', '0.10.38'),
('panel', 'version', '2.0.14'), ('panel', 'db_version', '202112310');
('panel', 'db_version', '202303150');
DROP TABLE IF EXISTS `panel_tasks`; DROP TABLE IF EXISTS `panel_tasks`;
@@ -754,7 +735,6 @@ CREATE TABLE `panel_tasks` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO `panel_tasks` (`type`) VALUES ('99'); INSERT INTO `panel_tasks` (`type`) VALUES ('99');
@@ -771,6 +751,7 @@ CREATE TABLE `panel_templates` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_traffic`; DROP TABLE IF EXISTS `panel_traffic`;
CREATE TABLE `panel_traffic` ( CREATE TABLE `panel_traffic` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -788,6 +769,7 @@ CREATE TABLE `panel_traffic` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_traffic_admins`; DROP TABLE IF EXISTS `panel_traffic_admins`;
CREATE TABLE `panel_traffic_admins` ( CREATE TABLE `panel_traffic_admins` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -805,6 +787,7 @@ CREATE TABLE `panel_traffic_admins` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_diskspace`; DROP TABLE IF EXISTS `panel_diskspace`;
CREATE TABLE `panel_diskspace` ( CREATE TABLE `panel_diskspace` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -821,6 +804,29 @@ CREATE TABLE `panel_diskspace` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_languages`;
CREATE TABLE `panel_languages` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`language` varchar(30) NOT NULL DEFAULT '',
`iso` char(3) NOT NULL DEFAULT 'foo',
`file` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO `panel_languages` (`id`, `language`, `iso`, `file`) VALUES
(1, 'Deutsch', 'de', 'lng/german.lng.php'),
(2, 'English', 'en', 'lng/english.lng.php'),
(3, 'Fran&ccedil;ais', 'fr', 'lng/french.lng.php'),
(4, 'Portugu&ecirc;s', 'pt', 'lng/portugues.lng.php'),
(5, 'Italiano', 'it', 'lng/italian.lng.php'),
(6, 'Nederlands', 'nl', 'lng/dutch.lng.php'),
(7, 'Svenska', 'sv', 'lng/swedish.lng.php'),
(8, '&#268;esk&aacute; republika', 'cs', 'lng/czech.lng.php');
DROP TABLE IF EXISTS `panel_syslog`; DROP TABLE IF EXISTS `panel_syslog`;
CREATE TABLE IF NOT EXISTS `panel_syslog` ( CREATE TABLE IF NOT EXISTS `panel_syslog` (
`logid` bigint(20) NOT NULL auto_increment, `logid` bigint(20) NOT NULL auto_increment,
@@ -833,6 +839,7 @@ CREATE TABLE IF NOT EXISTS `panel_syslog` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_fpmdaemons`; DROP TABLE IF EXISTS `panel_fpmdaemons`;
CREATE TABLE `panel_fpmdaemons` ( CREATE TABLE `panel_fpmdaemons` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
@@ -854,8 +861,10 @@ CREATE TABLE `panel_fpmdaemons` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO `panel_fpmdaemons` (`id`, `description`, `reload_cmd`, `config_dir`) VALUES INSERT INTO `panel_fpmdaemons` (`id`, `description`, `reload_cmd`, `config_dir`) VALUES
(1, 'System default', 'service php7.4-fpm restart', '/etc/php/7.4/fpm/pool.d/'); (1, 'System default', 'service php7.3-fpm restart', '/etc/php/7.3/fpm/pool.d/');
DROP TABLE IF EXISTS `panel_phpconfigs`; DROP TABLE IF EXISTS `panel_phpconfigs`;
@@ -887,9 +896,10 @@ CREATE TABLE `panel_phpconfigs` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO `panel_phpconfigs` (`id`, `description`, `binary`, `file_extensions`, `mod_fcgid_starter`, `mod_fcgid_maxrequests`, `pass_authorizationheader`, `phpsettings`) VALUES
(1, 'Default Config', '/usr/bin/php-cgi', 'php', '-1', '-1', '1', 'allow_url_fopen = Off\r\nallow_url_include = Off\r\nauto_append_file =\r\nauto_globals_jit = On\r\nauto_prepend_file =\r\nbcmath.scale = 0\r\ncli_server.color = On\r\ndefault_charset = "UTF-8"\r\ndefault_mimetype = "text/html"\r\ndefault_socket_timeout = 60\r\nasp_tags = Off\r\ndisable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,curl_exec,curl_multi_exec,exec,parse_ini_file,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,system\r\ndisplay_errors = Off\r\ndisplay_startup_errors = Off\r\ndoc_root =\r\nenable_dl = Off\r\nerror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE\r\nexpose_php = Off\r\nfile_uploads = On\r\nhtml_errors = On\r\nignore_repeated_errors = Off\r\nignore_repeated_source = Off\r\ninclude_path = ".:{PEAR_DIR}"\r\nimplicit_flush = Off\r\nldap.max_links = -1\r\nlog_errors = On\r\nlog_errors_max_len = 1024\r\nmail.add_x_header = Off\r\nmax_execution_time = 30\r\nmax_file_uploads = 20\r\nmax_input_time = 60\r\nmemory_limit = 128M\r\n{OPEN_BASEDIR_C}open_basedir = "{OPEN_BASEDIR}"\r\noutput_buffering = 4096\r\npost_max_size = 16M\r\nprecision = 14\r\nregister_argc_argv = Off\r\nreport_memleaks = On\r\nrequest_order = "GP"\r\nsendmail_path = "/usr/sbin/sendmail -t -i -f {CUSTOMER_EMAIL}"\r\nserialize_precision = -1\r\nsession.auto_start = 0\r\nsession.cache_expire = 180\r\nsession.cache_limiter = nocache\r\nsession.cookie_domain =\r\nsession.cookie_httponly =\r\nsession.cookie_lifetime = 0\r\nsession.cookie_path = /\r\nsession.cookie_samesite =\r\nsession.gc_divisor = 1000\r\nsession.gc_maxlifetime = 1440\r\nsession.gc_probability = 0\r\nsession.name = PHPSESSID\r\nsession.referer_check =\r\nsession.save_handler = files\r\nsession.save_path = "{TMP_DIR}"\r\nsession.serialize_handler = php\r\nsession.sid_bits_per_character = 5\r\nsession.sid_length = 26\r\nsession.trans_sid_tags = "a=href,area=href,frame=src,form="\r\nsession.use_cookies = 1\r\nsession.use_only_cookies = 1\r\nsession.use_strict_mode = 0\r\nsession.use_trans_sid = 0\r\nshort_open_tag = On\r\nupload_max_filesize = 32M\r\nupload_tmp_dir = "{TMP_DIR}"\r\nvariables_order = "GPCS"\r\nopcache.restrict_api = "{DOCUMENT_ROOT}"\r\n'), INSERT INTO `panel_phpconfigs` (`id`, `description`, `binary`, `file_extensions`, `mod_fcgid_starter`, `mod_fcgid_maxrequests`, `phpsettings`) VALUES
(2, 'Froxlor Vhost Config', '/usr/bin/php-cgi', 'php', '-1', '-1', '1', 'allow_url_fopen = On\r\nallow_url_include = Off\r\nauto_append_file =\r\nauto_globals_jit = On\r\nauto_prepend_file =\r\nbcmath.scale = 0\r\ncli_server.color = On\r\ndefault_charset = "UTF-8"\r\ndefault_mimetype = "text/html"\r\ndefault_socket_timeout = 60\r\nasp_tags = Off\r\ndisable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,curl_multi_exec,parse_ini_file,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,system\r\ndisplay_errors = Off\r\ndisplay_startup_errors = Off\r\ndoc_root =\r\nenable_dl = Off\r\nerror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE\r\nexpose_php = Off\r\nfile_uploads = On\r\nhtml_errors = On\r\nignore_repeated_errors = Off\r\nignore_repeated_source = Off\r\ninclude_path = ".:{PEAR_DIR}"\r\nimplicit_flush = Off\r\nldap.max_links = -1\r\nlog_errors = On\r\nlog_errors_max_len = 1024\r\nmail.add_x_header = Off\r\nmax_execution_time = 60\r\nmax_file_uploads = 20\r\nmax_input_time = 60\r\nmemory_limit = 128M\r\noutput_buffering = 4096\r\npost_max_size = 16M\r\nprecision = 14\r\nregister_argc_argv = Off\r\nreport_memleaks = On\r\nrequest_order = "GP"\r\nsendmail_path = "/usr/sbin/sendmail -t -i -f {CUSTOMER_EMAIL}"\r\nserialize_precision = -1\r\nsession.auto_start = 0\r\nsession.cache_expire = 180\r\nsession.cache_limiter = nocache\r\nsession.cookie_domain =\r\nsession.cookie_httponly =\r\nsession.cookie_lifetime = 0\r\nsession.cookie_path = /\r\nsession.cookie_samesite =\r\nsession.gc_divisor = 1000\r\nsession.gc_maxlifetime = 1440\r\nsession.gc_probability = 0\r\nsession.name = PHPSESSID\r\nsession.referer_check =\r\nsession.save_handler = files\r\nsession.save_path = "{TMP_DIR}"\r\nsession.serialize_handler = php\r\nsession.sid_bits_per_character = 5\r\nsession.sid_length = 26\r\nsession.trans_sid_tags = "a=href,area=href,frame=src,form="\r\nsession.use_cookies = 1\r\nsession.use_only_cookies = 1\r\nsession.use_strict_mode = 0\r\nsession.use_trans_sid = 0\r\nshort_open_tag = On\r\nupload_max_filesize = 32M\r\nupload_tmp_dir = "{TMP_DIR}"\r\nvariables_order = "GPCS"\r\nopcache.restrict_api = ""\r\n'); (1, 'Default Config', '/usr/bin/php-cgi', 'php', '-1', '-1', 'allow_url_fopen = Off\r\nallow_url_include = Off\r\nauto_append_file =\r\nauto_globals_jit = On\r\nauto_prepend_file =\r\nbcmath.scale = 0\r\ncli_server.color = On\r\ndefault_charset = "UTF-8"\r\ndefault_mimetype = "text/html"\r\ndefault_socket_timeout = 60\r\nasp_tags = Off\r\ndisable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,curl_exec,curl_multi_exec,exec,parse_ini_file,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,system\r\ndisplay_errors = Off\r\ndisplay_startup_errors = Off\r\ndoc_root =\r\nenable_dl = Off\r\nerror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE\r\nexpose_php = Off\r\nfile_uploads = On\r\nhtml_errors = On\r\nignore_repeated_errors = Off\r\nignore_repeated_source = Off\r\ninclude_path = ".:{PEAR_DIR}"\r\nimplicit_flush = Off\r\nldap.max_links = -1\r\nlog_errors = On\r\nlog_errors_max_len = 1024\r\nmail.add_x_header = Off\r\nmax_execution_time = 30\r\nmax_file_uploads = 20\r\nmax_input_time = 60\r\nmemory_limit = 128M\r\n{OPEN_BASEDIR_C}open_basedir = "{OPEN_BASEDIR}"\r\noutput_buffering = 4096\r\npost_max_size = 16M\r\nprecision = 14\r\nregister_argc_argv = Off\r\nreport_memleaks = On\r\nrequest_order = "GP"\r\nsendmail_path = "/usr/sbin/sendmail -t -i -f {CUSTOMER_EMAIL}"\r\nserialize_precision = -1\r\nsession.auto_start = 0\r\nsession.cache_expire = 180\r\nsession.cache_limiter = nocache\r\nsession.cookie_domain =\r\nsession.cookie_httponly =\r\nsession.cookie_lifetime = 0\r\nsession.cookie_path = /\r\nsession.cookie_samesite =\r\nsession.gc_divisor = 1000\r\nsession.gc_maxlifetime = 1440\r\nsession.gc_probability = 0\r\nsession.name = PHPSESSID\r\nsession.referer_check =\r\nsession.save_handler = files\r\nsession.save_path = "{TMP_DIR}"\r\nsession.serialize_handler = php\r\nsession.sid_bits_per_character = 5\r\nsession.sid_length = 26\r\nsession.trans_sid_tags = "a=href,area=href,frame=src,form="\r\nsession.use_cookies = 1\r\nsession.use_only_cookies = 1\r\nsession.use_strict_mode = 0\r\nsession.use_trans_sid = 0\r\nshort_open_tag = On\r\nupload_max_filesize = 32M\r\nupload_tmp_dir = "{TMP_DIR}"\r\nvariables_order = "GPCS"\r\nopcache.restrict_api = "{DOCUMENT_ROOT}"\r\n'),
(2, 'Froxlor Vhost Config', '/usr/bin/php-cgi', 'php', '-1', '-1', 'allow_url_fopen = On\r\nallow_url_include = Off\r\nauto_append_file =\r\nauto_globals_jit = On\r\nauto_prepend_file =\r\nbcmath.scale = 0\r\ncli_server.color = On\r\ndefault_charset = "UTF-8"\r\ndefault_mimetype = "text/html"\r\ndefault_socket_timeout = 60\r\nasp_tags = Off\r\ndisable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,curl_multi_exec,parse_ini_file,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,system\r\ndisplay_errors = Off\r\ndisplay_startup_errors = Off\r\ndoc_root =\r\nenable_dl = Off\r\nerror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE\r\nexpose_php = Off\r\nfile_uploads = On\r\nhtml_errors = On\r\nignore_repeated_errors = Off\r\nignore_repeated_source = Off\r\ninclude_path = ".:{PEAR_DIR}"\r\nimplicit_flush = Off\r\nldap.max_links = -1\r\nlog_errors = On\r\nlog_errors_max_len = 1024\r\nmail.add_x_header = Off\r\nmax_execution_time = 60\r\nmax_file_uploads = 20\r\nmax_input_time = 60\r\nmemory_limit = 128M\r\noutput_buffering = 4096\r\npost_max_size = 16M\r\nprecision = 14\r\nregister_argc_argv = Off\r\nreport_memleaks = On\r\nrequest_order = "GP"\r\nsendmail_path = "/usr/sbin/sendmail -t -i -f {CUSTOMER_EMAIL}"\r\nserialize_precision = -1\r\nsession.auto_start = 0\r\nsession.cache_expire = 180\r\nsession.cache_limiter = nocache\r\nsession.cookie_domain =\r\nsession.cookie_httponly =\r\nsession.cookie_lifetime = 0\r\nsession.cookie_path = /\r\nsession.cookie_samesite =\r\nsession.gc_divisor = 1000\r\nsession.gc_maxlifetime = 1440\r\nsession.gc_probability = 0\r\nsession.name = PHPSESSID\r\nsession.referer_check =\r\nsession.save_handler = files\r\nsession.save_path = "{TMP_DIR}"\r\nsession.serialize_handler = php\r\nsession.sid_bits_per_character = 5\r\nsession.sid_length = 26\r\nsession.trans_sid_tags = "a=href,area=href,frame=src,form="\r\nsession.use_cookies = 1\r\nsession.use_only_cookies = 1\r\nsession.use_strict_mode = 0\r\nsession.use_trans_sid = 0\r\nshort_open_tag = On\r\nupload_max_filesize = 32M\r\nupload_tmp_dir = "{TMP_DIR}"\r\nvariables_order = "GPCS"\r\nopcache.restrict_api = ""\r\n');
DROP TABLE IF EXISTS `cronjobs_run`; DROP TABLE IF EXISTS `cronjobs_run`;
@@ -912,12 +922,13 @@ INSERT INTO `cronjobs_run` (`id`, `module`, `cronfile`, `cronclass`, `interval`,
(3, 'froxlor/reports', 'usage_report', '\\Froxlor\\Cron\\Traffic\\ReportsCron', '1 DAY', '1', 'cron_usage_report'), (3, 'froxlor/reports', 'usage_report', '\\Froxlor\\Cron\\Traffic\\ReportsCron', '1 DAY', '1', 'cron_usage_report'),
(4, 'froxlor/core', 'mailboxsize', '\\Froxlor\\Cron\\System\\MailboxsizeCron', '6 HOUR', '1', 'cron_mailboxsize'), (4, 'froxlor/core', 'mailboxsize', '\\Froxlor\\Cron\\System\\MailboxsizeCron', '6 HOUR', '1', 'cron_mailboxsize'),
(5, 'froxlor/letsencrypt', 'letsencrypt', '\\Froxlor\\Cron\\Http\\LetsEncrypt\\AcmeSh', '5 MINUTE', '0', 'cron_letsencrypt'), (5, 'froxlor/letsencrypt', 'letsencrypt', '\\Froxlor\\Cron\\Http\\LetsEncrypt\\AcmeSh', '5 MINUTE', '0', 'cron_letsencrypt'),
(6, 'froxlor/backup', 'backup', '\\Froxlor\\Cron\\System\\BackupCron', '1 DAY', '0', 'cron_backup'); (6, 'froxlor/backup', 'backup', '\\Froxlor\\Cron\\System\\BackupCron', '1 DAY', '1', 'cron_backup');
DROP TABLE IF EXISTS `ftp_quotalimits`; DROP TABLE IF EXISTS `ftp_quotalimits`;
CREATE TABLE IF NOT EXISTS `ftp_quotalimits` ( CREATE TABLE IF NOT EXISTS `ftp_quotalimits` (
`name` varchar(255) default NULL, `name` varchar(30) default NULL,
`quota_type` enum('user','group','class','all') NOT NULL default 'user', `quota_type` enum('user','group','class','all') NOT NULL default 'user',
`per_session` enum('false','true') NOT NULL default 'false', `per_session` enum('false','true') NOT NULL default 'false',
`limit_type` enum('soft','hard') NOT NULL default 'hard', `limit_type` enum('soft','hard') NOT NULL default 'hard',
@@ -930,13 +941,15 @@ CREATE TABLE IF NOT EXISTS `ftp_quotalimits` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO `ftp_quotalimits` (`name`, `quota_type`, `per_session`, `limit_type`, `bytes_in_avail`, `bytes_out_avail`, `bytes_xfer_avail`, `files_in_avail`, `files_out_avail`, `files_xfer_avail`) VALUES INSERT INTO `ftp_quotalimits` (`name`, `quota_type`, `per_session`, `limit_type`, `bytes_in_avail`, `bytes_out_avail`, `bytes_xfer_avail`, `files_in_avail`, `files_out_avail`, `files_xfer_avail`) VALUES
('froxlor', 'user', 'false', 'hard', 0, 0, 0, 0, 0, 0); ('froxlor', 'user', 'false', 'hard', 0, 0, 0, 0, 0, 0);
DROP TABLE IF EXISTS `ftp_quotatallies`; DROP TABLE IF EXISTS `ftp_quotatallies`;
CREATE TABLE IF NOT EXISTS `ftp_quotatallies` ( CREATE TABLE IF NOT EXISTS `ftp_quotatallies` (
`name` varchar(255) NOT NULL, `name` varchar(30) NOT NULL,
`quota_type` enum('user','group','class','all') NOT NULL, `quota_type` enum('user','group','class','all') NOT NULL,
`bytes_in_used` float NOT NULL, `bytes_in_used` float NOT NULL,
`bytes_out_used` float NOT NULL, `bytes_out_used` float NOT NULL,
@@ -947,6 +960,7 @@ CREATE TABLE IF NOT EXISTS `ftp_quotatallies` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `redirect_codes`; DROP TABLE IF EXISTS `redirect_codes`;
CREATE TABLE IF NOT EXISTS `redirect_codes` ( CREATE TABLE IF NOT EXISTS `redirect_codes` (
`id` int(5) NOT NULL auto_increment, `id` int(5) NOT NULL auto_increment,
@@ -957,6 +971,7 @@ CREATE TABLE IF NOT EXISTS `redirect_codes` (
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO `redirect_codes` (`id`, `code`, `desc`, `enabled`) VALUES INSERT INTO `redirect_codes` (`id`, `code`, `desc`, `enabled`) VALUES
(1, '---', 'rc_default', 1), (1, '---', 'rc_default', 1),
(2, '301', 'rc_movedperm', 1), (2, '301', 'rc_movedperm', 1),
@@ -965,6 +980,7 @@ INSERT INTO `redirect_codes` (`id`, `code`, `desc`, `enabled`) VALUES
(5, '307', 'rc_tempred', 1); (5, '307', 'rc_tempred', 1);
DROP TABLE IF EXISTS `domain_redirect_codes`; DROP TABLE IF EXISTS `domain_redirect_codes`;
CREATE TABLE IF NOT EXISTS `domain_redirect_codes` ( CREATE TABLE IF NOT EXISTS `domain_redirect_codes` (
`rid` int(5) NOT NULL, `rid` int(5) NOT NULL,
@@ -983,9 +999,7 @@ CREATE TABLE IF NOT EXISTS `domain_ssl_settings` (
`ssl_cert_chainfile` mediumtext, `ssl_cert_chainfile` mediumtext,
`ssl_csr_file` mediumtext, `ssl_csr_file` mediumtext,
`ssl_fullchain_file` mediumtext, `ssl_fullchain_file` mediumtext,
`validfromdate` datetime DEFAULT NULL, `expirationdate` datetime DEFAULT NULL,
`validtodate` datetime DEFAULT NULL,
`issuer` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY (`domainid`) UNIQUE KEY (`domainid`)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
@@ -1039,15 +1053,3 @@ CREATE TABLE `api_keys` (
KEY customerid (customerid) KEY customerid (customerid)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_usercolumns`;
CREATE TABLE `panel_usercolumns` (
`adminid` int(11) NOT NULL default '0',
`customerid` int(11) NOT NULL default '0',
`section` varchar(500) NOT NULL default '',
`columns` text NOT NULL,
UNIQUE KEY `user_section` (`adminid`, `customerid`, `section`),
KEY adminid (adminid),
KEY customerid (customerid)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
FROXLORSQL;

View File

@@ -4,64 +4,27 @@
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors).
* *
* This program is free software; you can redistribute it and/or * For the full copyright and license information, please view the COPYING
* modify it under the terms of the GNU General Public License * file that was distributed with this source code. You can also view the
* as published by the Free Software Foundation; either version 2 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * @copyright (c) the authors
* but WITHOUT ANY WARRANTY; without even the implied warranty of * @author Michael Kaufmann <mkaufmann@nutime.de>
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * @author Froxlor team <team@froxlor.org> (2010-)
* GNU General Public License for more details. * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Install
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/ */
if (! file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
use Froxlor\UI\Panel\UI; // get hint-template
use Froxlor\Install\Install; $vendor_hint = file_get_contents(dirname(__DIR__) . '/templates/Sparkle/misc/vendormissinghint.tpl');
// replace values
require dirname(__DIR__) . '/lib/functions.php'; $vendor_hint = str_replace("<FROXLOR_INSTALL_DIR>", dirname(__DIR__), $vendor_hint);
$vendor_hint = str_replace("<CURRENT_YEAR>", date('Y', time()), $vendor_hint);
// define default theme for configurehint, etc. die($vendor_hint);
$_deftheme = 'Froxlor';
// validate correct php version
if (version_compare("7.4.0", PHP_VERSION, ">=")) {
die(view($_deftheme . '/misc/phprequirementfailed.html.twig', [
'{{ basehref }}' => '../',
'{{ froxlor_min_version }}' => '7.4.0',
'{{ current_version }}' => PHP_VERSION,
'{{ current_year }}' => date('Y', time()),
]));
} }
// validate vendor autoloader
if (!file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
die(view($_deftheme . '/misc/vendormissinghint.html.twig', [
'{{ basehref }}' => '../',
'{{ froxlor_install_dir }}' => dirname(__DIR__),
'{{ current_year }}' => date('Y', time()),
]));
}
// check installation status
if (file_exists(dirname(__DIR__) . '/lib/userdata.inc.php')) {
header("Location: ../");
exit;
}
require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/lib/tables.inc.php'; require __DIR__ . '/lib/class.FroxlorInstall.php';
// init twig $frxinstall = new FroxlorInstall();
UI::initTwig(true); $frxinstall->run();
UI::sendHeaders();
$installer = new Install();
$installer->handle();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Function showUpdateStep
*
* outputs and logs the current
* update progress
*
* @param
* string task/status
* @param
* bool needs_status (if false, a linebreak will be added)
*
* @return string formatted output and log-entry
*/
function showUpdateStep($task = null, $needs_status = true)
{
set_time_limit(30);
if (! $needs_status)
echo "<b>";
// output
echo $task;
if (! $needs_status) {
echo "</b><br />";
}
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, $task);
}
/**
* Function lastStepStatus
*
* outputs [OK] (success), [??] (warning) or [!!] (failure)
* of the last update-step
*
* @param
* int status (0 = success, 1 = warning, 2 = failure)
*
* @return string formatted output and log-entry
*/
function lastStepStatus($status = -1, $message = '')
{
switch ($status) {
case 0:
$status_sign = ($message != '') ? '[' . $message . ']' : '[OK]';
$status_color = 'ok';
break;
case 1:
$status_sign = ($message != '') ? '[' . $message . ']' : '[??]';
$status_color = 'warn';
break;
case 2:
$status_sign = ($message != '') ? '[' . $message . ']' : '[!!]';
$status_color = 'err';
break;
default:
$status_sign = '[unknown]';
$status_color = 'unknown';
break;
}
// output
echo "<span class=\"update-step update-step-" . $status_color . "\">" . $status_sign . "</span><br />";
if ($status == - 1 || $status == 2) {
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
} elseif ($status == 0 || $status == 1) {
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Success');
}
}

102
install/lng/english.lng.php Normal file
View File

@@ -0,0 +1,102 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Language
*
*/
$lng['requirements']['title'] = 'Checking system requirements...';
$lng['requirements']['installed'] = 'installed';
$lng['requirements']['not_true'] = 'no';
$lng['requirements']['notfound'] = 'not found';
$lng['requirements']['notinstalled'] = 'not installed';
$lng['requirements']['activated'] = 'enabled';
$lng['requirements']['phpversion'] = 'PHP version >= 7.1';
$lng['requirements']['newerphpprefered'] = 'Good, but php-7.4 is preferred.';
$lng['requirements']['phppdo'] = 'PHP PDO extension and PDO-MySQL driver...';
$lng['requirements']['phpsession'] = 'PHP session-extension...';
$lng['requirements']['phpctype'] = 'PHP ctype-extension...';
$lng['requirements']['phpsimplexml'] = 'PHP SimpleXML-extension...';
$lng['requirements']['phpxml'] = 'PHP XML-extension...';
$lng['requirements']['phpfilter'] = 'PHP filter-extension...';
$lng['requirements']['phpposix'] = 'PHP posix-extension...';
$lng['requirements']['phpbcmath'] = 'PHP bcmath-extension...';
$lng['requirements']['phpcurl'] = 'PHP curl-extension...';
$lng['requirements']['phpmbstring'] = 'PHP mbstring-extension...';
$lng['requirements']['phpzip'] = 'PHP zip-extension...';
$lng['requirements']['phpjson'] = 'PHP json-extension...';
$lng['requirements']['bcmathdescription'] = 'Traffic-calculation related functions will not work correctly!';
$lng['requirements']['zipdescription'] = 'The auto-update feature requires the zip extension.';
$lng['requirements']['openbasedir'] = 'open_basedir...';
$lng['requirements']['openbasedirenabled'] = 'Froxlor will not work properly with open_basedir enabled. Please disable open_basedir for Froxlor in the corresponding php.ini';
$lng['requirements']['mysqldump'] = 'MySQL dump tool';
$lng['requirements']['mysqldumpmissing'] = 'Automatic backup of possible existing database is not possible. Please install mysql-client tools';
$lng['requirements']['diedbecauseofrequirements'] = 'Cannot install Froxlor without these requirements! Try to fix them and retry.';
$lng['requirements']['froxlor_succ_checks'] = 'All requirements are satisfied';
$lng['install']['lngtitle'] = 'Froxlor install - choose language';
$lng['install']['language'] = 'Installation language';
$lng['install']['lngbtn_go'] = 'Change language';
$lng['install']['title'] = 'Froxlor install - setup';
$lng['install']['welcometext'] = 'Thank you for choosing Froxlor. Please fill out the following fields with the required information to start the installation.<br /><b>Attention:</b> If the database you chose for Froxlor already exists on your System, it will be erased with all containing data!';
$lng['install']['database'] = 'Database connection';
$lng['install']['mysql_host'] = 'MySQL-Hostname';
$lng['install']['mysql_database'] = 'Database name';
$lng['install']['mysql_forcecreate'] = 'Backup and overwrite database if exists?';
$lng['install']['mysql_unpriv_user'] = 'Username for the unprivileged MySQL-account';
$lng['install']['mysql_unpriv_pass'] = 'Password for the unprivileged MySQL-account';
$lng['install']['mysql_root_user'] = 'Username for the MySQL-root-account';
$lng['install']['mysql_root_pass'] = 'Password for the MySQL-root-account';
$lng['install']['mysql_ssl_ca_file'] = 'MySQL server certificate file path';
$lng['install']['mysql_ssl_verify_server_certificate'] = 'Verify MySQL TLS certificate';
$lng['install']['admin_account'] = 'Administrator Account';
$lng['install']['admin_user'] = 'Administrator Username';
$lng['install']['admin_pass1'] = 'Administrator Password';
$lng['install']['admin_pass2'] = 'Administrator-Password (confirm)';
$lng['install']['activate_newsfeed'] = 'Enable the official newsfeed<br><small>(https://inside.froxlor.org/news/)</small>';
$lng['install']['serversettings'] = 'Server settings';
$lng['install']['distribution'] = 'Distribution';
$lng['install']['servername'] = 'Server name (FQDN, no ip-address)';
$lng['install']['serverip'] = 'Server IP';
$lng['install']['webserver'] = 'Webserver';
$lng['install']['apache2'] = 'Apache 2.2';
$lng['install']['apache24'] = 'Apache 2.4';
$lng['install']['lighttpd'] = 'LigHTTPd';
$lng['install']['nginx'] = 'NGINX';
$lng['install']['httpuser'] = 'HTTP username';
$lng['install']['httpgroup'] = 'HTTP groupname';
$lng['install']['testing_mysql'] = 'Checking MySQL-root access...';
$lng['install']['testing_mysql_fail'] = 'There seems to be a problem with the database-connection. Cannot continue. Please go back and check your credentials.';
$lng['install']['backup_old_db'] = 'Creating backup of old database...';
$lng['install']['backup_binary_missing'] = 'Could not find mysqldump';
$lng['install']['backup_failed'] = 'Could not backup database';
$lng['install']['check_db_exists'] = 'Checking database...';
$lng['install']['db_exists'] = 'Unable to create database. A database with the same name exists and should not be overwritten';
$lng['install']['prepare_db'] = 'Preparing database...';
$lng['install']['create_mysqluser_and_db'] = 'Creating database and username...';
$lng['install']['testing_new_db'] = 'Testing if database and user have been created correctly...';
$lng['install']['importing_data'] = 'Importing data...';
$lng['install']['changing_data'] = 'Adjusting settings...';
$lng['install']['creating_entries'] = 'Inserting new values...';
$lng['install']['adding_admin_user'] = 'Creating admin-account...';
$lng['install']['creating_configfile'] = 'Creating configfile...';
$lng['install']['creating_configfile_temp'] = 'File was saved in %s, please move to ' . dirname(dirname(__DIR__)) . '/lib/userdata.inc.php';
$lng['install']['creating_configfile_failed'] = 'Could not create ' . dirname(dirname(__DIR__)) . '/lib/userdata.inc.php, please create it manually with the following content:';
$lng['install']['froxlor_succ_installed'] = 'Froxlor was installed successfully.';
$lng['click_here_to_refresh'] = 'Click here to check again';
$lng['click_here_to_goback'] = 'Click here to go back';
$lng['click_here_to_continue'] = 'Click here to continue';
$lng['click_here_to_login'] = 'Click here to login.';

View File

@@ -0,0 +1,87 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Language
*
*/
$lng['requirements']['title'] = 'Vérification des prérequis système...';
$lng['requirements']['installed'] = 'installé';
$lng['requirements']['not_true'] = 'non';
$lng['requirements']['notfound'] = 'introuvable';
$lng['requirements']['notinstalled'] = 'non installé';
$lng['requirements']['activated'] = 'activé';
$lng['requirements']['phpversion'] = 'PHP version >= 7.1';
$lng['requirements']['phppdo'] = 'extension PHP PDO et pilote PDO-MySQL ...';
$lng['requirements']['phpxml'] = 'extension PHP XML...';
$lng['requirements']['phpfilter'] = 'extension PHP filter ...';
$lng['requirements']['phpposix'] = 'extension PHP posix ...';
$lng['requirements']['phpbcmath'] = 'extension PHP bcmath ...';
$lng['requirements']['phpcurl'] = 'extension PHP curl...';
$lng['requirements']['phpmbstring'] = 'extension PHP mbstring...';
$lng['requirements']['bcmathdescription'] = 'Les fonctions de calcul de traffic ne fonctionneront pas correctement!';
$lng['requirements']['openbasedir'] = 'open_basedir...';
$lng['requirements']['openbasedirenabled'] = 'Froxlor ne fonctionnera pas correctement avec open_basedir activé. Merci de désactiver open_basedir pour Froxlor dans le php.ini correspondant';
$lng['requirements']['diedbecauseofrequirements'] = 'Impossible d\'installer Froxlor sans ces prérequis! Essayez de les corriger et essayez à nouveau.';
$lng['requirements']['froxlor_succ_checks'] = 'Tous les prérequis sont vérifiés';
$lng['install']['lngtitle'] = 'Installation de Froxlor - choisisez la langue';
$lng['install']['language'] = 'Langue d\'installation';
$lng['install']['lngbtn_go'] = 'Changer la langue';
$lng['install']['title'] = 'Installation de Froxlor - paramètrage';
$lng['install']['welcometext'] = 'Merci d\'avoir choisi Froxlor. Merci de remplir les champs suivant avec les informations nécessaires pour démarrer l\'installation.<br /><b>Attention:</b> Si la base de données que vous choisissez existe déjà sur votre système, elle sera écrasée ainsi que les données contenues!';
$lng['install']['database'] = 'Connexion à la base de données';
$lng['install']['mysql_host'] = 'Nom d\'hôte MySQL';
$lng['install']['mysql_database'] = 'Nom de la base de données';
$lng['install']['mysql_unpriv_user'] = 'Nom d\'utilisateur pour le compte non priviligié MySQL';
$lng['install']['mysql_unpriv_pass'] = 'Mot de passe pour le compte non priviligié MySQL';
$lng['install']['mysql_root_user'] = 'Nom d\'utilisateur pour le compte MySQL root';
$lng['install']['mysql_root_pass'] = 'Mot de passe pour le compte MySQL root';
$lng['install']['admin_account'] = 'Compte administrateur';
$lng['install']['admin_user'] = 'Nom d\'utilisateur administrateur';
$lng['install']['admin_pass1'] = 'Mot de passe administrateur';
$lng['install']['admin_pass2'] = 'Mot de passe administrateur (confirmez)';
$lng['install']['serversettings'] = 'Réglages serveur';
$lng['install']['distribution'] = 'Distribution';
$lng['install']['servername'] = 'Nom du serveur (FQDN, pas d\'adresse IP)';
$lng['install']['serverip'] = 'Adresse IP du serveur';
$lng['install']['webserver'] = 'Serveur Web';
$lng['install']['apache2'] = 'Apache 2';
$lng['install']['apache24'] = 'Apache 2.4';
$lng['install']['lighttpd'] = 'LigHTTPd';
$lng['install']['nginx'] = 'NGINX';
$lng['install']['httpuser'] = 'Nom d\'utilisateur HTTP';
$lng['install']['httpgroup'] = 'Nom de groupe HTTP';
$lng['install']['testing_mysql'] = 'Vérification de l\'accès root MySQL...';
$lng['install']['testing_mysql_fail'] = 'Il semble y avoir un problème avec la connexion à la base de données. Impossible de continuer. Merci de revenir en arrière et de vérifier les informations d\'identification.';
$lng['install']['backup_old_db'] = 'Création des sauvegardes de l\'ancienne base de données...';
$lng['install']['backup_binary_missing'] = 'Impossible de trouver mysqldump';
$lng['install']['backup_failed'] = 'Impossible de sauvegarde la base de données';
$lng['install']['prepare_db'] = 'Préparation de la base de données...';
$lng['install']['create_mysqluser_and_db'] = 'Création de la base de données et l\'utilisateur...';
$lng['install']['testing_new_db'] = 'Teste si la base de données et l\'utilisateur ont été créés correctement...';
$lng['install']['importing_data'] = 'Import des données...';
$lng['install']['changing_data'] = 'Ajustement des paramètres...';
$lng['install']['creating_entries'] = 'Insertion des nouvelles valeurs...';
$lng['install']['adding_admin_user'] = 'Création du compte administrateur...';
$lng['install']['creating_configfile'] = 'Création du fichier de configuration...';
$lng['install']['creating_configfile_temp'] = 'Le fichier a été enregistré dans %s, merci de le déplacer dans ' . dirname(dirname(__DIR__)) . '/lib/userdata.inc.php';
$lng['install']['creating_configfile_failed'] = 'Impossible de créer ' . dirname(dirname(__DIR__)) . '/lib/userdata.inc.php, merci de le créer manuellement avec le contenu suivant:';
$lng['install']['froxlor_succ_installed'] = 'Froxlor a été installé avec succès.';
$lng['click_here_to_refresh'] = 'Cliquez ici pour vérifier à nouveau';
$lng['click_here_to_goback'] = 'Cliquez ici pour revenir';
$lng['click_here_to_continue'] = 'Cliquez ici pour continuer';
$lng['click_here_to_login'] = 'Cliquez ici pour vous connecter.';

102
install/lng/german.lng.php Normal file
View File

@@ -0,0 +1,102 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Language
*
*/
$lng['requirements']['title'] = 'Prüfe Systemvoraussetzungen...';
$lng['requirements']['installed'] = 'installiert';
$lng['requirements']['not_true'] = 'nein';
$lng['requirements']['notfound'] = 'nicht gefunden';
$lng['requirements']['notinstalled'] = 'nicht installiert';
$lng['requirements']['activated'] = 'ist aktiviert.';
$lng['requirements']['phpversion'] = 'PHP Version >= 7.1';
$lng['requirements']['newerphpprefered'] = 'Passt, aber php-7.4 wird bevorzugt.';
$lng['requirements']['phppdo'] = 'PHP PDO Erweiterung und PDO-MySQL Treiber...';
$lng['requirements']['phpsession'] = 'PHP session-Erweiterung...';
$lng['requirements']['phpctype'] = 'PHP ctype-Erweiterung...';
$lng['requirements']['phpsimplexml'] = 'PHP SimpleXML-Erweiterung...';
$lng['requirements']['phpxml'] = 'PHP XML-Erweiterung...';
$lng['requirements']['phpfilter'] = 'PHP filter-Erweiterung...';
$lng['requirements']['phpposix'] = 'PHP posix-Erweiterung...';
$lng['requirements']['phpbcmath'] = 'PHP bcmath-Erweiterung...';
$lng['requirements']['phpcurl'] = 'PHP curl-Erweiterung...';
$lng['requirements']['phpmbstring'] = 'PHP mbstring-Erweiterung...';
$lng['requirements']['phpzip'] = 'PHP zip-Erweiterung...';
$lng['requirements']['phpjson'] = 'PHP json-Erweiterung...';
$lng['requirements']['bcmathdescription'] = 'Traffic-Berechnungs bezogene Funktionen stehen nicht vollständig zur Verfügung!';
$lng['requirements']['zipdescription'] = 'Die Auto-Update Funktion benötigt die zip Erweiterung.';
$lng['requirements']['openbasedir'] = 'open_basedir genutzt wird...';
$lng['requirements']['openbasedirenabled'] = 'Froxlor wird mit aktiviertem open_basedir nicht vollständig funktionieren. Bitte deaktivieren Sie open_basedir für Froxlor in der entsprechenden php.ini';
$lng['requirements']['mysqldump'] = 'MySQL dump Tool';
$lng['requirements']['mysqldumpmissing'] = 'Ein automatisches Backup einer möglicherweise schon existierenden Datenbank nicht möglich. Bitte mysql-client installieren';
$lng['requirements']['diedbecauseofrequirements'] = 'Kann Froxlor ohne diese Voraussetzungen nicht installieren! Beheben Sie die angezeigten Probleme und versuchen Sie es erneut.';
$lng['requirements']['froxlor_succ_checks'] = 'Alle Vorraussetzungen sind erfüllt';
$lng['install']['lngtitle'] = 'Froxlor Installation - Sprache auswählen';
$lng['install']['language'] = 'Sprache für die Installation';
$lng['install']['lngbtn_go'] = 'Sprache ändern';
$lng['install']['title'] = 'Froxlor Installation - Einrichtung';
$lng['install']['welcometext'] = 'Vielen Dank dass Sie sich für Froxlor entschieden haben. Um die Installation von Froxlor zu starten, füllen Sie bitte alle Felder mit den geforderten Angaben aus.<br /><b>Achtung:</b> Eine eventuell existierende Datenbank, die den selben Namen hat wie den Gewählten, wird mit allen enthaltenen Daten gelöscht!';
$lng['install']['database'] = 'Datenbankverbindung';
$lng['install']['mysql_host'] = 'MySQL-Hostname';
$lng['install']['mysql_database'] = 'Datenbank Name';
$lng['install']['mysql_forcecreate'] = 'Datenbank sichern und überschreiben wenn vorhanden?';
$lng['install']['mysql_unpriv_user'] = 'Benutzername für den unprivilegierten MySQL-Account';
$lng['install']['mysql_unpriv_pass'] = 'Passwort für den unprivilegierten MySQL-Account';
$lng['install']['mysql_root_user'] = 'Benutzername für den MySQL-Root-Account';
$lng['install']['mysql_root_pass'] = 'Passwort für den MySQL-Root-Account';
$lng['install']['mysql_ssl_ca_file'] = 'MySQL-Server Zertifikatspfad';
$lng['install']['mysql_ssl_verify_server_certificate'] = 'Validieren des MySQL-Server Zertifikats';
$lng['install']['admin_account'] = 'Admin-Zugang';
$lng['install']['admin_user'] = 'Administrator-Benutzername';
$lng['install']['admin_pass1'] = 'Administrator-Passwort';
$lng['install']['admin_pass2'] = 'Administrator-Passwort (Bestätigung)';
$lng['install']['activate_newsfeed'] = 'Aktiviere das offizielle Newsfeed<br><small>(https://inside.froxlor.org/news/)</small>';
$lng['install']['serversettings'] = 'Servereinstellungen';
$lng['install']['distribution'] = 'Distribution';
$lng['install']['servername'] = 'Servername (FQDN, keine IP-Adresse)';
$lng['install']['serverip'] = 'Server-IP';
$lng['install']['webserver'] = 'Webserver';
$lng['install']['apache2'] = 'Apache 2';
$lng['install']['apache24'] = 'Apache 2.4';
$lng['install']['lighttpd'] = 'LigHTTPd';
$lng['install']['nginx'] = 'NGINX';
$lng['install']['httpuser'] = 'HTTP Username';
$lng['install']['httpgroup'] = 'HTTP Gruppenname';
$lng['install']['testing_mysql'] = 'Teste MySQL-Root Zugang...';
$lng['install']['testing_mysql_fail'] = 'Bei der Verwendung der Datenbank gibt es scheinbar Probleme. Installation kann nicht fortgesetzt werden. Bitte Zugangsdaten prüfen und erneut versuchen.';
$lng['install']['backup_old_db'] = 'Sicherung vorheriger Datenbank...';
$lng['install']['backup_binary_missing'] = 'Konnte mysqldump nicht finden';
$lng['install']['backup_failed'] = 'Sicherung fehlgeschlagen';
$lng['install']['check_db_exists'] = 'Databenbank wird geprüft...';
$lng['install']['db_exists'] = 'Datenbank kann nicht erstellt werden. Eine Datenbank mit dem selben Namen existiert bereits und soll nicht überschrieben werden.';
$lng['install']['prepare_db'] = 'Datenbank wird vorbereitet...';
$lng['install']['create_mysqluser_and_db'] = 'Erstelle Datenbank und Benutzer...';
$lng['install']['testing_new_db'] = 'Teste, ob Datenbank und Benutzer korrekt angelegt wurden...';
$lng['install']['importing_data'] = 'Importiere Daten...';
$lng['install']['changing_data'] = 'Einstellungen anpassen...';
$lng['install']['creating_entries'] = 'Trage neue Werte ein...';
$lng['install']['adding_admin_user'] = 'Erstelle Admin-Benutzer...';
$lng['install']['creating_configfile'] = 'Erstelle Konfigurationsdatei...';
$lng['install']['creating_configfile_temp'] = 'Datei wurde in %s gespeichert, bitte nach ' . dirname(dirname(__DIR__)) . '/lib/userdata.inc.php verschieben.';
$lng['install']['creating_configfile_failed'] = 'Konnte ' . dirname(dirname(__DIR__)) . '/lib/userdata.inc.php nicht erstellen, bitte manuell mit folgendem Inhalt anlegen:';
$lng['install']['froxlor_succ_installed'] = 'Froxlor wurde erfolgreich installiert.';
$lng['click_here_to_refresh'] = 'Hier klicken, um erneut zu prüfen';
$lng['click_here_to_goback'] = 'Einen Schritt zurück';
$lng['click_here_to_continue'] = 'Installation fortführen';
$lng['click_here_to_login'] = 'Hier geht es weiter zum Login-Fenster.';

View File

@@ -0,0 +1,32 @@
#!/usr/bin/php
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2018 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2018-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
*
*/
// Check if we're in the CLI
if (@php_sapi_name() !== 'cli') {
die('This script will only work in the shell.');
}
require dirname(dirname(__DIR__)) . '/vendor/autoload.php';
// give control to command line handler
try {
\Froxlor\Cli\ConfigServicesCmd::processParameters($argc, $argv);
} catch (Exception $e) {
\Froxlor\Cli\ConfigServicesCmd::printerr($e->getMessage());
exit(1);
}

View File

@@ -0,0 +1,32 @@
#!/usr/bin/php
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2016 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2016-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
*
*/
// Check if we're in the CLI
if (@php_sapi_name() !== 'cli') {
die('This script will only work in the shell.');
}
require dirname(dirname(__DIR__)) . '/vendor/autoload.php';
// give control to command line handler
try {
\Froxlor\Cli\SwitchServerIpCmd::processParameters($argc, $argv);
} catch (Exception $e) {
\Froxlor\Cli\SwitchServerIpCmd::printerr($e->getMessage());
exit(1);
}

View File

@@ -0,0 +1,637 @@
@charset "UTF-8";
/* RESET */
html, body, div, ul, ol, li, dl, dt, dd, h1, h2, h3, h4, h5, h6, pre,
form, p, blockquote, fieldset, input {
margin: 0;
padding: 0;
}
h1, h2, h3, h4, h5, h6, pre, code, address, caption, cite, code, em,
strong, th {
font-size: 1em;
font-weight: 400;
font-style: normal;
}
ul, ol {
list-style: none;
}
fieldset, img {
border: none;
}
caption, th {
text-align: left;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
article, aside, details, figcaption, figure, footer, header, hgroup,
menu, nav, section {
display: block;
}
/* TYPE */
html, body {
font: 12px/18px 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial,
Verdana, sans-serif;
background-color: #f5f5f5;
color: #444;
-webkit-font-smoothing: subpixel-antialiased;
}
body {
margin: 0;
padding: 0;
}
.dark {
background-color: #e9edf0;
border-bottom: 1px solid #d1d5d8;
}
header img {
padding: 10px 0 10px 10px;
}
h1 {
display: none;
}
h2, h3 {
margin: 0 0 1em 0;
padding: 0;
font-weight: bold;
}
h2 {
font-size: 17px;
}
h3 {
font-size: 15px;
}
img {
border: 0;
vertical-align: middle;
}
td a {
text-decoration: none;
}
.bradius {
border-radius: 5px 5px 5px 5px;
box-shadow: rgba(0, 0, 0, 0.34902) 0 1px 3px 0;
}
/* FOOTER */
footer {
clear: both;
text-align: center;
color: #888;
font-size: 10px !important;
margin: 10px 0;
}
footer a, footer a:active, footer a:visited {
color: #888;
}
.install {
background-color: #fff;
margin: 20px auto 12px;
width: 800px;
}
p {
margin: 0 10px !important;
}
.installsec {
margin-top: 10px;
padding: 0;
text-align: left;
}
.installsec table {
width: 100%;
padding: 0 10px;
margin: 15px 0 15px 0;
}
.installsec h2 {
display: block;
border-bottom: 1px solid #d1d5d8;
margin: 0;
padding: 5px 15px 15px 15px;
}
.installsec form {
width: 800px;
margin: 0 auto;
padding: 10px 0 0;
text-align: left;
}
.installsec fieldset {
border: 0;
float: left;
clear: left;
width: 600px;
margin: 0 100px 10px;
padding: 0;
}
.installsec fieldset p, .installsec fieldset h3 {
clear: both;
}
.installsec legend {
display: none;
}
.installsec label {
float: left;
margin-right: 0;
margin-top: 8px;
text-align: left;
}
p.submit {
text-align: right;
padding-right: 46px;
}
.installsec aside {
border-top: 1px solid #d1d5d8;
clear: both;
float: none;
width: auto;
text-align: right;
padding: 10px;
}
.line {
border: 0;
width: 800px;
border-bottom: 1px solid #d1d5d8;
}
.messagewrapper {
width: 650px;
margin: 0 auto;
padding: 120px 0 0;
overflow: hidden;
}
.messagewrapperfull {
width: 100%;
margin: 0 auto;
padding: 0;
overflow: hidden;
}
.overviewsearch {
position: absolute;
top: 155px;
right: 36px;
font-size: 80%;
}
.overviewadd {
padding: 10px;
font-weight: 700;
}
/*
* error message display
*/
.errorcontainer {
background: url(../img/icons/error_big.png) 10px center no-repeat
#ffedef;
border: 1px solid #ffc2ca;
padding: 10px 10px 10px 68px !important;
margin: 10px 0 10px 0 !important;
text-align: left !important;
overflow: hidden;
box-shadow: 0 0 0 black;
}
.errortitle {
font-weight: 700;
color: #c00 !important;
}
.error {
font-weight: 400 !important;
color: #c00 !important;
}
/*
* warning message display
*/
.warningcontainer, .ui-dialog {
background: url(../img/icons/warning_big.png) 10px center no-repeat
#fffecc;
border: 1px solid #f3c37e;
padding: 10px 10px 10px 68px !important;
margin: 10px 0 10px 0 !important;
text-align: left !important;
overflow: hidden;
box-shadow: 0 0 0 black;
}
.ui-dialog {
padding: 10px !important;
}
.warningtitle, .ui-dialog-titlebar {
font-weight: 700;
color: #D57D00;
}
.warning, .ui-dialog-content {
color: #D57D00 !important;
}
/*
* success message display
*/
.successcontainer {
background: url(../img/icons/ok_big.png) 10px center no-repeat #E2F9E3;
border: 1px solid #9C9;
padding: 10px 10px 10px 68px !important;
margin: 10px 0 10px 0 !important;
text-align: left !important;
overflow: hidden;
box-shadow: 0 0 0 black;
}
.successtitle {
font-weight: 700;
color: #060 !important;
}
.success {
font-weight: 400 !important;
}
/*
* neutral/info message display
*/
.neutralcontainer {
background: url(../img/icons/info_big.png) 10px center no-repeat #d2eaf6;
border: 1px solid #b7d8ed;
padding: 10px 10px 10px 68px !important;
margin: 10px 0 10px 0 !important;
text-align: left !important;
overflow: hidden;
box-shadow: 0 0 0 black;
}
.neutraltitle {
font-weight: 700;
color: #3188c1 !important;
}
.neutral {
font-weight: 400 !important;
color: #3188c1 !important;
}
/* std hyperlink */
a, a:active, a:visited {
color: #176fa1;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.infotext {
font-size: 11px;
}
/*
* main container
*/
.main {
margin: 105px 10px 0 240px;
background-color: #fff;
padding: 30px 30px 30px 30px;
min-height: 400px;
}
.noborder {
width: 100%;
border-spacing: 0;
border-collapse: separate;
border: 0;
}
.noborder td {
border: 0;
}
table {
width: 100%;
border-spacing: 0;
border: 1px solid #d1d5d8;
border-collapse: separate;
box-shadow: 0 0 0 black !important;
}
table thead th, table th {
border-top: 1px solid #d1d5d8;
border-bottom: 1px solid #d1d5d8;
height: 25px !important;
padding: 5px 0 5px 8px;
background-color: #e9edf0;
font-weight: bold;
}
table thead:first-child th, table:first-child th {
border-top: none !important;
}
table th {
border-top: 0;
}
th a:hover {
text-decoration: none;
}
th a img {
}
th a:nth-child(odd) img {
position: relative;
top: -5px;
left: 4px;
}
th a:nth-child(even) img {
position: relative;
top: 3px;
left: -7px;
}
table thead:first-child th {
border-top: 0;
}
.disabled td, .disabled td a {
color: #cfcfcf;
}
table tbody td {
border-bottom: 1px dotted #ccc;
}
table tbody tr:last-child td {
border-bottom: 0;
}
.formtable {
width: 100%;
border-spacing: 0;
border: 0;
border-collapse: separate;
margin: 0 0 0;
}
.formtable tbody td {
border: 0;
border-bottom: 1px dotted #ccc;
min-height: 20px;
}
.formtable label {
float: none;
display: block;
padding: 0;
margin: 0;
width: 100%;
text-align: left;
}
td {
padding: 5px 10px;
min-height: 20px;
}
table tfoot td {
height: 25px;
border-top: 1px solid #d1d5d8;
background-color: #f2f8fa;
}
.tfootleft {
text-align: left;
}
.maintitle {
padding-top: 20px;
}
/* input elements */
input {
background: #fff url(../img/text_align_left.png) no-repeat 5px 4px;
color: #333;
padding: 2px 4px 2px 24px;
height: 22px;
border: 1px solid #d9d9d9;
margin-bottom: 5px;
border-radius: 3px;
}
textarea {
background: #fff url(../img/text_align_left.png) no-repeat 5px 4px;
color: #333;
padding: 4px 4px 2px 24px;
border: 1px solid #d9d9d9;
margin-bottom: 5px;
border-radius: 3px;
}
input[type="password"] {
background: #fff url(../img/password.png) no-repeat 5px 4px;
}
/*
* BUTTONS
*/
input[type="button"], input[type="submit"], input[type="reset"] {
margin: 0 5px;
padding: 5px 14px;
outline: 0;
border: 0;
background-color: #eee;
min-width: 80px;
height: 26px;
background-image: none;
}
.loginsec input[type="button"], .loginsec input[type="submit"],
.loginsec input[type="reset"] {
margin: 0 1px;
}
input[type="button"]:hover, input[type="submit"]:hover, input[type="reset"]:hover
{
color: #333;
background-color: #dcdcdc;
}
input[type="button"]:active, input[type="submit"]:active, input[type="reset"]:active
{
-webkit-box-shadow: inset 0 1px 8px rgba(0, 0, 0, 0.25);
-moz-box-shadow: inset 0 1px 8px rgba(0, 0, 0, 0.25);
box-shadow: inset 0 1px 8px rgba(0, 0, 0, 0.25);
color: white !important;
}
input[type="submit"], input[class="yesbutton"] {
color: white;
background-color: #35aa47;
}
input[type="submit"]:hover, input[class="yesbutton"]:hover {
color: white;
background-color: #1d943b;
}
input[class="submit"]:active, input[class="yesbutton"]:active {
background-color: #35aa47;
}
input[class="nobutton"], input[type="reset"] {
color: white;
background-color: #d84a38;
}
input[class="nobutton"]:hover, input[type="reset"]:hover {
color: white;
background-color: #c53727;
}
input[class="nobutton"]:active, input[type="reset"]:active {
background-color: #dd4b39;
}
input[type="checkbox"] {
background: #dae7ee;
padding: 0;
margin: 0 5px 0 0;
vertical-align: middle;
height: 26px;
}
input[type="radio"] {
vertical-align: middle;
margin: 0 10px 0 10px;
height: 22px;
}
select {
background: #fff;
padding: 4px;
color: #333;
border: 1px solid #d9d9d9;
margin-bottom: 5px;
min-width: 100px;
}
select.dropdown {
padding: 2px 4px 2px 24px;
height: 26px;
border: 1px solid #d9d9d9;
margin-bottom: 5px;
border-radius: 3px;
background: url(../../../../templates/Sparkle/assets/img/icons/down.png)
no-repeat 9px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.maintable {
width: 90%;
}
.update_progess {
padding: 2em;
text-align: left;
}
.preconfig {
text-align: left;
margin-top: 20px;
margin-bottom: 5px;
margin-right: 15px;
margin-left: 15px;
}
.preconfigitem {
padding: .15em;
border-bottom: 1px solid #ccc;
}
.preconfdesc {
display: block;
margin-bottom: .5em;
font-size: 120%;
}
.installprogress {
width: 100%;
background-color: #e4e4e4;
height: 5px;
border-bottom: 1px solid #d1d5d8;
}
.installprogress .bar {
background-color: #35aa47;
height: 5px;
}
.red {
color: #ff0000;
}
.green {
color: green;
}
.orange {
color: orange;
}
.blue {
color: blue;
}
.install-block {
width: 65%;
}
.install-step {
width: 250px;
}
.install-h3 {
text-align: center;
}
.install-text {
margin: 20px 20px 0 !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Some files were not shown because too many files have changed in this diff Show More